Page 1 of 1

Need assistance on colorizing a grayscale image without affecting black/white hues

Posted: 2016-07-18T13:38:36-07:00
by BenFacilis
Here's another original image:
https://postimg.org/image/bpig021c1/

What I'm trying to achieve:
https://postimg.org/image/vguq10pr5/

This is what I get currently...
https://postimg.org/image/3ky9pvqg7/
...using the .NET wrapper:
image.Colorize(new MagickColor("#ffff00"), (Percentage)50);

Instead of washing out the black/white hues, I'd like to only saturate the various shades of grey with shades of whatever hex color I pass in.

If you load up Photoshop, go to Image > Hue/Saturation and configure the HSL for 60/70%/50%, you'll get the desired result.

How would I go about doing this, given these values?

Re: Need assistance on colorizing a grayscale image without affecting black/white hues

Posted: 2016-07-18T15:58:34-07:00
by fmw42
Try this (unix syntax). Please always provide your IM version and platform when asking questions on this forum, since syntax may vary.

Code: Select all

convert background1_original.jpg \
\( -size 1x1 xc:black xc:"hsl(60,70%,50%)" xc:white +append -resize 512x1! \) \
-interpolate bilinear -clut result.jpg
If on unix systems, see my script tintilize at the link below.

Re: Need assistance on colorizing a grayscale image without affecting black/white hues

Posted: 2016-07-18T16:19:30-07:00
by BenFacilis
Thanks a million! Going to try this out

Re: Need assistance on colorizing a grayscale image without affecting black/white hues

Posted: 2016-07-18T16:34:13-07:00
by GeeMack
BenFacilis wrote:How would I go about doing this, given these values?
Like the idea fmw42 provided above, I'd probably create a color lookup table to apply to the original image. Using IM7 on a Windows 7 64 system I can get a near match to your "background1_edited.jpg" example with a command like this...

Code: Select all

magick background1_original.jpg ^
   ( -size 1x256 gradient:#000000-#dddd33 gradient:#dddd33-#ffffff -append ) -clut output.jpg
That makes a lookup table which is a gradient running from black to yellow with the hex value "#dddd33" to white. The "-clut" operation applies that table to your "background1_original.jpg" and outputs "output.jpg".

Also as fmw42 mentioned, the exact syntax would depend on your version of IM and your operating system.