Filter RGB Colors

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
TPMarketing
Posts: 1
Joined: 2014-04-05T11:38:38-07:00
Authentication code: 6789

Filter RGB Colors

Post by TPMarketing »

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 achieve that?

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

Thanks

_____________

website
Last edited by TPMarketing on 2014-04-07T09:14:16-07:00, edited 1 time in total.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Filter RGB Colors

Post by fmw42 »

Code: Select all

convert image -fuzz XX% -fill "#002865" +opaque black result
where XX=0 (or remove -fuxx XX%) if you want a perfect match to #002865.

If you want to change #002865 to white and the rest black, then

Code: Select all

convert image -fuzz XX% -fill "#002865" -opaque white +opaque black result
see
http://www.imagemagick.org/Usage/color_basics/#replace
Post Reply