Page 1 of 1

Filter for RGB color

Posted: 2013-12-04T04:42:07-07:00
by matjo
I want to make all pixels of a certain #RGB white/black in an image or the inverse rendering all other pixels black. What is the best way to do that?

for example I want the image to only show pixels with RGB value of #22A906

Best regards

Re: Filter for RGB color

Posted: 2013-12-04T08:37:01-07:00
by snibgo
To make all pixels other than #22a906 black:

Code: Select all

convert in.png -fill black +opaque #22a906 out.png
See http://www.imagemagick.org/script/comma ... php#opaque

EDIT: Oops, I meant "+opaque" not "-opaque".

Re: Filter for RGB color

Posted: 2013-12-04T15:20:38-07:00
by fmw42

Code: Select all

convert in.png -fill white +opaque " #22a906" -fill black -opaque "#22a906" out.png
This will make #22a906 into black and the rest of the image into white. The +opaque means everything but the specified color.

Re: Filter for RGB color

Posted: 2013-12-05T16:48:20-07:00
by matjo
Thank you very much, exactly what I was looking for.