I'm trying to create an application that will take an image and adjust all shades of a particular colour (red for example) to a corresponding shade of another colour (like blue). I have successfully done this using either -recolor or -color-matrix but in both cases I can't work out how to programatically calculate the transformation matrix values for a given target colour.
Say for example I have an image of a man wearing a red t-shirt. I can convert the image so that it looks like he is wearing a blue t-shirt using:
Code: Select all
convert C:\test\red.png -recolor "0 1 0 0 1 0 1 0 0" C:\test\blue.png
Code: Select all
convert C:\test\red.png -color-matrix ^
"0.0 1.0 0.0 0.0, 0.0, ^
0.0 1.0 0.0 0.0, 0.0, ^
1.0 0.0 0.0 0.0, 0.0, ^
0.0 0.0 0.0 1.0, 0.0, ^
0.0 0.0 0.0 0.0, 1.0" C:\test\blue.png
Perhaps I'm barking up the wrong tree with this method and there is another way (or it's impossible!)? Any help greatly appreciated.
I am using IM version 6.7.1-8 Q16 with Windows 7 command line.
Many thanks,
Alan