select blue pixel and generate pbm

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
yogourt58
Posts: 2
Joined: 2012-08-18T12:10:14-07:00
Authentication code: 67789

select blue pixel and generate pbm

Post by yogourt58 »

Hello,
i am new on this forum,hello every body,
I want to convert a .jpg image in a .pbm binary image.
I 'll like to select only the blue pixels to fill them with black, and let all the other in white. is it possible with Image magick?
I have read all the subjects with "pbm" and cannot find an answer.
Thanks a lot.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: select blue pixel and generate pbm

Post by fmw42 »

I am not sure what colors you have in your image. If there are other near shades of blue that you want to include then you need to use -fuzz. If pure blue only, then it can be left out or use -fuzz 0%. Try this


convert image.jpg -fuzz 10% -fill white +opaque blue -fill black -opaque blue result.pgm

you fill the non blue with white using -fill white +opaque blue and you then fill the blue with black using -fill black -opaque blue. then set the image type to pgm (graylevel, which will be binary b/w).

see
http://www.imagemagick.org/Usage/color_basics/#opaque
http://www.imagemagick.org/script/comma ... php#opaque
http://www.imagemagick.org/script/comma ... s.php#fuzz
yogourt58
Posts: 2
Joined: 2012-08-18T12:10:14-07:00
Authentication code: 67789

Re: select blue pixel and generate pbm

Post by yogourt58 »

Thanks a lot, for the links also. It seems to run quiet well, even on the complex image (botanical image) I am working on.
Yog
Post Reply