Remove color range, and keep another

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
Alfa

Remove color range, and keep another

Post by Alfa »

Hello

I need help, I've read lots of threads but I'm not getting it. Maybe someone have some clues.

I want remove from image "A" all colors that dont exist in pallete "P", so the final image "B" will be transparent excluding the colors that exist on pallette P
Can I do this with IM?

Image "A"
Image



Palette "P"

Image

Image "B" (output)

Image

Sorry for my bad english.
Thank you in advance for any help or directions to explore, and Merry Christmas to all
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Remove color range, and keep another

Post by fmw42 »

If you know or can measure the exact color values you want to remove then you can do it by a series of -fill none -opaque somecolor. These two commands can be chained in the same command. If you want to remove near colors you can add -fuzz before -fill none.

try this for example to remove the dark blue:

convert 35543221.png -channel rgba -alpha set -fuzz 10% -fill none -opaque "#3030CE" 35543221_test.png


see http://www.imagemagick.org/Usage/color_basics/#replace
Post Reply