Page 1 of 1

Deskew - remove added pixels

Posted: 2016-08-01T15:10:04-07:00
by Masejoer
The handful of forum results don't help with this issue. I have an image that is being de-skewed by about 5%. This rotates the image and leaves solid colors where data didn't exist. I cannot seem to get auto-crop to work, at all.

Code: Select all

convert input -background black -set option:deskew:auto-crop 1 -deskew 40 output
I've tried:

Code: Select all

convert in.jpg -background green -set option:deskew:auto-crop 1 -deskew 40% -fuzz 5% -trim +repage out.jpg
Which doesn't work. I've used various auto-crop values with no luck. I just need the introduced-color to be completely removed after the deskew.

Re: Deskew - remove added pixels

Posted: 2016-08-01T15:20:53-07:00
by fmw42
What is your IM version and platform? Please always provide that, since syntax differs. Can you post your image to some free hosting service so we can examine and test. You can then put the URL here.

Please read the topmost post in this forum at viewtopic.php?f=1&t=9620

Re: Deskew - remove added pixels

Posted: 2016-08-01T19:49:28-07:00
by fmw42
Masejoer wrote:The handful of forum results don't help with this issue. I have an image that is being de-skewed by about 5%. This rotates the image and leaves solid colors where data didn't exist. I cannot seem to get auto-crop to work, at all.

Code: Select all

convert input -background black -set option:deskew:auto-crop 1 -deskew 40 output
I've tried:

Code: Select all

convert in.jpg -background green -set option:deskew:auto-crop 1 -deskew 40% -fuzz 5% -trim +repage out.jpg
Which doesn't work. I've used various auto-crop values with no luck. I just need the introduced-color to be completely removed after the deskew.

Generally I use % for the deskew value, e.g. 40% to get reasonable results.

I made some tests and cannot get the auto-crop to work. See my bug report at viewtopic.php?f=3&t=30206#p135998

In my tests I found that a white background worked well with 40%, but a black background did not and needed 30% to work. So try other values for your green background.

try

Code: Select all

convert input -deskew XX% -fuzz YY% -trim +repage output
though that may leave some background. If so, then add -shave ZZxZZ after -trim, where XX is deskew percent, YY is a small fuzz percent and ZZ is in pixels.

Code: Select all

convert input -deskew XX% -fuzz YY% -trim +repage -shave ZZxZZ output

Re: Deskew - remove added pixels

Posted: 2016-08-02T12:20:55-07:00
by Masejoer
I'm running ImageMagick-7.0.1-6 Q16-x64 on Windows (.bat) and 7.0.2-5 Q16-x64 on Ubuntu (.sh).

Every time I try deskew xx% in Ubuntu, it fails to do anything, so I've been using the value without percent symbol. Maybe another bug.

Thanks for the bug report, fmw42.

Current image:
http://www.masejoer.com/Images/IM/testcheck22.jpg

Re: Deskew - remove added pixels

Posted: 2016-08-02T15:56:30-07:00
by fmw42
From my experience -deskew does not work well for angle above about 5% and probably not well also if the sides are not straight

Re: Deskew - remove added pixels

Posted: 2016-08-03T09:28:06-07:00
by Masejoer
fmw42 wrote:From my experience -deskew does not work well for angle above about 5% and probably not well also if the sides are not straight
I've had great luck running the deskew to get the images straight, and extremely angles (40 degrees) if I deskew twice. I just can't get good consistent cropping from the deskewed output - perspective distortion being the worst. I'm still amazed at how well imagemagick generally does on most things.

Re: Deskew - remove added pixels

Posted: 2016-08-03T09:40:51-07:00
by fmw42
You could try my unperspective script if on Unix. Interesting about deskew twice. I have never tried that.

Re: Deskew - remove added pixels

Posted: 2016-08-03T12:40:08-07:00
by Masejoer
Does anyone know the real difference between "-deskew 40%" and "-deskew 40"? Some images deskew perfect with 40%, while others only deskew with "40". "40%" will just fail to deskew if it can't get a straight line, "40" will simply rotate the image a lot if not successful.