Match colors.

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
gsso

Match colors.

Post by gsso »

I'm searching for a way to match colors using ImageMagick.

Let's say I'v got those samples here:
ImageImageImage

What I would like to do is get the faces on those photos as close in both color and luminance to the sample skin_tone below:
Image

I'v tried composing them with the skin tone using threshold blend mode as well as the colorize one, but both give results that I just can't use.
I'v gone so far as to put the skin_tone onto the samples with colorize, then making a difference mask using the colorized sample and the skin_tone image and then using that with CopyOpacity from the oryginal sample to get just the parts on the image (eyes and nose and mouth), but I would still like to be able to match the colors using the skin_tone.jpg to get something like this:
Image

any ideas?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Match colors.

Post by fmw42 »

try either

# get average skin tone and colorize a grayscale image using +level-colors
color=`convert skin_tone.jpg -scale 1x1! -format "%[pixel:s.p{0,0}]" info:`
convert sample_2.jpg -colorspace gray +level-colors black,$color sample_2_skin_A.jpg
Image

or

# composite the two images
convert skin_tone.jpg \( sample_2.jpg -colorspace gray \) -compose multiply -composite sample_2_skin_C.jpg
Image

You can use -modulate to brighten it a little also, or change the saturation or hue

convert sample_2_skin_A.jpg -modulate 110,100,100 sample_2_skin_A_b110.jpg
Image

see http://www.imagemagick.org/script/comma ... p#modulate
gsso

Re: Match colors.

Post by gsso »

Ah yes, thanks for the reply. I'v tried those previosly, but what I want to do is match the overal lightness and hue and saturation.. not loosing the color of the eyes or mouth.

I'm up to something so when I'll finish I'll post it here.
Post Reply