0
votes

Is it possible to separate an image into channels based on arbitrary colors? If I have an image that's visually pink, white and black, is it possible to create 3 separate images describing the "pinkyness" "whiteness" and "blackness" channels?

My purpose is to mutate - let's say - pink into yellow, black into blue and white into red.

Ideally this should be possible with ImageMagick

I would use color substitution but it would substitutes all colors close to pink with one single colors, whereas I want to preserve the different levels of intensity of pink.

Using this image as an example, I'd like to turn the knit part rom pink/white/black into blue/yellow/green.

1
It can be done but ImageMagick doesn’t really lend itself to things that need visual feedback and eyeballing on a case-by-case basis such as setting thresholds for affected hues. I would go for Photoshop’s Replace Colour tool.Mark Setchell

1 Answers

1
votes

You need to use the hue channel from HCL or HSL, etc and mask and swap hues. I have a bash Unix shell script, replace color, for Imagemagick that will do that.

Input:

enter image description here

replacecolor -i "#BA3A67" -o blue Adidas-pink.png Adidas-blue.png

#BA3A67 is your input pinkish color that I measured. Blue is the desired output color. Any opaque color can be use and specified as a color name or hex value or rgb(rr,gg,bb) triplet.

enter image description here

The script cannot change gray tones (black, gray, white), since the hue is the same as red. But you can still change black and/or white (or any color) in imagemagick using:

convert image.suffix -fuzz XX% -fill newcolor -opaque oldcolor output.suffix

Where XX is some percent tolerance.

See http://www.fmwconcepts.com/imagemagick/replacecolor/index.php