Page 1 of 1

Trim noisy image

Posted: 2016-03-30T22:38:03-07:00
by il_mix
Hi, everyone!

I need to trim the white border from some grayscale (actually B/W) images. These are scans of paper pages (comix strips), and there are some noisy pixels that prevent a good trim with this "standard" ImageMagick command

Code: Select all

convert input -bordercolor white -border 1x1 -fuzz 50% -trim +repage output
As said, these are B/W images, so the "fuzz" parameter is quite useless (pixel values are 0 or 255).
Here is an example of input and trimmed image. Due to some noise on the border (need to zoom to view it) the trim algorithm fails (better, didn't meet my needs).

INPUT
Image

OUTPUT
Image

Any idea about how to trim the full border?

Thanks!
MIX

Re: Trim noisy image

Posted: 2016-03-30T23:20:03-07:00
by fmw42
Please supply your IM version and platform when asking questions. Please post an example actual image so others can test. You can post to some free hosting service such as dropbox.com and put the URL here.

Please read viewtopic.php?f=1&t=9620

Re: Trim noisy image

Posted: 2016-03-31T00:05:50-07:00
by il_mix
About the IM version I will have to wait this evening to update the message.
About the "actual image", the two images are actual input/output of the command I wrote. There are no contents in the panels, but if a script works on the posted image it is enough for me. Also, since the panels content may vary, I think that empty panels are the "worst case" regarding border trimming.

Re: Trim noisy image

Posted: 2016-03-31T02:26:26-07:00
by snibgo
I suggest you de-noise the image and find what trim would be obtained. Then crop the original to that trim. For example:

Code: Select all


f:\web\im>%IM%convert input_zpshxil0xao.png -median 5x5 -format %@ info:
2221x3062+134+89

f:\web\im>%IM%convert input_zpshxil0xao.png -crop 2221x3062+134+89 c.png
You will need a script to get the ouput from the first convert into the second.

Re: Trim noisy image

Posted: 2016-03-31T04:03:21-07:00
by il_mix
@snibgo, I'll give it a try. I think I can do quite a hard median without screwing the results, given the images I'm working on.
I also thought about trimming (or medianing, given your hint) all images than crop with a median (arithmetical) of the results.