What I'd like to do is change the green (and associated shades) in the following image to shades of purple, as given in the gradient file. Originally the figures were converted to grey-scale then CLUT was used to add the purple with the gradient file, but this causes all different colors to change to purple as well rather than just green.
Input: https://www.dropbox.com/s/19yqxbbhu66xg ... g.tif?dl=0
CLUT gradient: https://www.dropbox.com/s/2zprm9i2fj733 ... p.png?dl=0
The result should be like this:
https://www.dropbox.com/s/6ftbyhlvazr1z ... 5.tif?dl=0
After reading through some of the IM tutorials it seems like that if you want to change a color in a picture, such as going from shades of green to shades purple, tools like CLUT and level-color are good. I also played around with Fred's huemap (which is awesome), but from what I can tell I think I need something slightly different because the purples I get look a bit off due to S and V variations compared to the gradient.
I think I got on a bit of a tangent, but I started looking at trying to isolate the green in the image (and do some kind of mask) and applying the gradient with CLUT, but I couldn't work out how to get the green parts of the picture by themselves.
Would anyone have suggestions?
Changing a specific color in an image
Changing a specific color in an image
Last edited by hobboy on 2015-05-12T19:48:19-07:00, edited 1 time in total.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Changing a specific color in an image
Where is the input file? Your first file is all purple, the second is the clut and the last is your desired result.
Also what version of IM are you using and what platform. Please always provide that with your questions.
Also what version of IM are you using and what platform. Please always provide that with your questions.
Re: Changing a specific color in an image
Sorry about that. Would you mind trying that first input image again, the image should have greens, browns and greys.
I'm using the ImageMagick-6.9.1-2 from source on Linux mint predominantly, and also the portable exe on Windows.
I'm using the ImageMagick-6.9.1-2 from source on Linux mint predominantly, and also the portable exe on Windows.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Changing a specific color in an image
Sorry, I just looked at the dropbox displayed image, which only shows purple. But now when I download it, it looks fine. The issue is that it is CMYK tiff, which apparently does not display correctly on the dropbox displayed page.
I will try to work on it tomorrow or the next day. I am rather busy right now. But it is likely that it will need to be converted to RGB, then processed, then converted back to cmyk, if you really need a cmyk result. The best way is to use the US Web Coated Swop profile in the image.
The only idea I have is to use my script huemap at http://www.fmwconcepts.com/imagemagick/huemap/index.php after convert from CMYK to sRGB, then after huemap, convert back to CMYK as described above.
Feel free to try that yourself in the mean time.
Note that GIMP has a similar tool to my huemap that works interactively. That is where I got the idea to reproduce something like it for IM. You can try that also. Perhaps it will suit your needs, if it is just this one image.
I will try to work on it tomorrow or the next day. I am rather busy right now. But it is likely that it will need to be converted to RGB, then processed, then converted back to cmyk, if you really need a cmyk result. The best way is to use the US Web Coated Swop profile in the image.
The only idea I have is to use my script huemap at http://www.fmwconcepts.com/imagemagick/huemap/index.php after convert from CMYK to sRGB, then after huemap, convert back to CMYK as described above.
Feel free to try that yourself in the mean time.
Note that GIMP has a similar tool to my huemap that works interactively. That is where I got the idea to reproduce something like it for IM. You can try that also. Perhaps it will suit your needs, if it is just this one image.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Changing a specific color in an image
Try the following. I used a tool to measure three green shades in your original and then the same for the purple shades in your desired result. This looks pretty good to me.
Code: Select all
convert 2.0-Ch-Fig-2.25-g.tif -profile /Users/fred/images/profiles/sRGB.icc \
-fuzz 20% -fill "#8155a2" -opaque "#45ae4a" -fill "#3b264a" -opaque "#337136" -fill "#57356c" \
-profile /Users/fred/images/profiles/USWebCoatedSWOP.icc result.tif