Page 1 of 1

[SOLVED] Convert non-black pixels to white

Posted: 2010-10-26T07:50:21-07:00
by dstrout
I am trying to process JPEG images that contain two letters that are nearly black, on a background that is nearly white. I have managed to make the letters fully black, and the background fully white by using white-threshold and black-threshold. However, the images also have little "squiggles" in them that are a darker gray color. I am wanting to remove these, and make them just white. Therefore, I was wondering if there is any way to, after fixing the letters and the background, just make all pixels that are not black, white. I have tried setting the white-threshold to 100%, but that does not work. Any other ideas?

And yes, this is a CAPTCHA, but this is just an experimental project. I am not hacking anything.

Re: Convert non-black pixels to white

Posted: 2010-10-26T09:58:51-07:00
by fmw42
First, to get pure black and white and no grays, you want to just use -threshold.

Second, if you really want to change all colors that are not say black to white, then use -fill white +opaque black

see

http://www.imagemagick.org/script/comma ... #threshold
http://www.imagemagick.org/script/comma ... php#opaque

Re: Convert non-black pixels to white

Posted: 2010-10-26T11:53:25-07:00
by dstrout
Thank you very much! That did the trick. Oh, and BTW, I knew I could just use -threshold, but I needed to set individual thresholds for black and white, otherwise it didn't work properly.

Thanks again!