Page 1 of 1

How to keep specific colors and remove rest ?

Posted: 2013-01-09T01:16:46-07:00
by 9428949494
Image
You can see the image i just wish to keep two colors
color 1 -#609018
color 2- #489000 and remove all rest colors.

Whats the best way to do it ?

I searched a lot in the forum but couldnt find any better way to do it.

Thanks for help in advance.

Re: How to keep specific colors and remove rest ?

Posted: 2013-01-09T03:45:25-07:00
by Bonzo
You do not realy give enough information but with what you have given you could either create a mask for the colours you want to keep or change the colours of the ones you do not want.

Example of the second method - you may be able to do the red and black in the same command.

Code: Select all

convert -fill white -fuzz 10% -opaque red output.jpg

Re: How to keep specific colors and remove rest ?

Posted: 2013-01-09T12:08:21-07:00
by fmw42
try the following. make an image for each color and make everything but that color transparent (none). Then combine the images.

Note your hex colors are way off with regard to the image you posted. The following is a unix IM command. For windows, change the \( to ( and the same for \) to ) and change the line ending \ to ^. Also change % to %%. See http://www.imagemagick.org/Usage/windows/. Generally a good idea when you post to a topic to include your IM version and platform.


convert qp5vz7.png \
\( -clone 0 -channel rgba -fuzz 10% -fill none +opaque "#62921E" \) \
\( -clone 0 -channel rgba -fuzz 10% -fill none +opaque "#208C09" \) \
-delete 0 -compose plus -composite -compose over -background white -flatten qp5vz7_result.png

I assume the labeling of the hex colors inside the ellipse will be removed; otherwise you need to keep black as well and then distinguishing the labels from the black ellipse will require another solution.

Re: How to keep specific colors and remove rest ?

Posted: 2013-02-06T17:07:06-07:00
by anthony
This should really be in users forum, not IM developers.

However... IM Examples to the rescue...
http://www.imagemagick.org/Usage/color_ ... z_distance

This example is really about the Fuzz factor, but it demonstrates a number of techniques of matching (keeping or removing) a list of colors.

Another technique is to use a HALD table, though that is probably better for removing for a very odd shaped swath of colors.