Filter for RGB color

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
matjo
Posts: 2
Joined: 2013-12-04T04:39:02-07:00
Authentication code: 6789

Filter for RGB color

Post 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
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Filter for RGB color

Post 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".
Last edited by snibgo on 2013-12-04T15:41:28-07:00, edited 1 time in total.
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Filter for RGB color

Post 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.
matjo
Posts: 2
Joined: 2013-12-04T04:39:02-07:00
Authentication code: 6789

Re: Filter for RGB color

Post by matjo »

Thank you very much, exactly what I was looking for.
Post Reply