Applying different Colors to an Image

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
Licy
Posts: 2
Joined: 2016-06-09T07:25:51-07:00
Authentication code: 1151

Applying different Colors to an Image

Post by Licy »

Hello All,

I am using Imagemagick version 6.9.3-6 to apply different colors on one image. For this, first I created a Split image with the colors that I needed using this command - convert -size 50x367 gradient:Red-orange -size 50x367 gradient:orange-pink -append split.png (All images can be found at this link - https://www.dropbox.com/sh/l5r50t8yy1r0 ... usDOa?dl=0). I then used split.png on 1.png to get 1_colored.png using the following command : convert 1.png split.png -clut 1_colored.png.

1_colored.png is not exactly what was desired, but somewhat close to. When I use the same script for images like 2.png or similar images, i get a completely undesirable output. Please see 2_colored.png. I was expecting output somewhat close to 1_colored.png

How can I modify the above script to get uniform color highlights that you can see in example1.jpg and example2.jpg. Also, what should I do to get an output like bottomcolor1.jpg where only bottom part of the image has a different color.

Thanks,
Licy
Licy
Posts: 2
Joined: 2016-06-09T07:25:51-07:00
Authentication code: 1151

Re: Applying different Colors to an Image

Post by Licy »

Guys,

I haven't received a reply to my earlier question. So, please let me know if you need any other details?

Thanks
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Applying different Colors to an Image

Post by snibgo »

"-clut" changes colors. When the input is greyscale (which the hair photos are, more or less), it will change black into red and white into orange.

Your image 2.png has no white. The lightest part of the hair is about 30%, and there isn't much of that. You can stretch the input before applying the clut:

Code: Select all

convert 2.png -background Black -level 0,30% split.png -clut 2a.png
To apply an image across part of the image, create a same-size mask the same size, white where you want the effect, black where you dont, 75% gray where you want 75% of the effect, and so on. Then:

Code: Select all

convert original.png effected.png mask.png -composite out.png
snibgo's IM pages: im.snibgo.com
Post Reply