Background filling after rotation/deskew
Posted: 2013-01-02T11:03:38-07:00
Hi,
after I use -rotate or -deskew there are white corners in the image.
Example: http://imgur.com/8bZQ6
What I'd like to do is fill up those corners as best as possible... cropping is not an option.
I've quite like this solution I've found for rotation:
convert image.png -virtual-pixel Edge +distort SRT 10 out.png
Example: http://imgur.com/edMS0
But I'd also like something similar for -deskew. Any ideas how to do that?
So far the best I've come up with is using the border pixels...
Note: my implementation is wrong - it only takes the approximation of the left and right borders... it also uses some bash scripting.
convert image.png -background `convert image.png -resize 100x1! \( +clone -crop 1x1+0+0 \) +append -crop 2x1+99+0 -resize 1x1 txt:- | tail -1 | cut -b 30-50` -rotate 10 out.png
Example: http://imgur.com/4wDPO
So, any ideas how to best fill those pesky white corners, that also works with -deskew, and other transformations?
after I use -rotate or -deskew there are white corners in the image.
Example: http://imgur.com/8bZQ6
What I'd like to do is fill up those corners as best as possible... cropping is not an option.
I've quite like this solution I've found for rotation:
convert image.png -virtual-pixel Edge +distort SRT 10 out.png
Example: http://imgur.com/edMS0
But I'd also like something similar for -deskew. Any ideas how to do that?
So far the best I've come up with is using the border pixels...
Note: my implementation is wrong - it only takes the approximation of the left and right borders... it also uses some bash scripting.
convert image.png -background `convert image.png -resize 100x1! \( +clone -crop 1x1+0+0 \) +append -crop 2x1+99+0 -resize 1x1 txt:- | tail -1 | cut -b 30-50` -rotate 10 out.png
Example: http://imgur.com/4wDPO
So, any ideas how to best fill those pesky white corners, that also works with -deskew, and other transformations?