Page 1 of 1

how to change skin color to some hex or RGB color?

Posted: 2014-08-13T03:47:57-07:00
by ravikum
Hello,
I have a "face in hole" type of application.

I have cut hole in the place of monalisa's face and feathered it. (PNG)
Users upload their photos and adjust the faces in hole.
And, I send the monalisa's PNG and users photo to my script and using imagemagick, it composes them into a JPG.

I know the Hex and RGB color of monalisa's face.
So, whatever may be the color of the user's face, I want to replace that with the color of monalisa.

I have tried

Code: Select all

-fill tint -tint 100
and

Code: Select all

-fill tint -colorize 50%
and

Code: Select all

\( +clone +matte -fill monalisacolor -colorize 100% \) -compose overlay -composite
I tried to do this using -modulate hue. but hue is in %.
So, don't understand how to use this.

are there any other commands I can use to replace the skin color

Please suggest me various commands that I can use to do this effectively.

Thanks.

Re: how to change skin color to some hex or RGB color?

Posted: 2014-08-13T04:59:10-07:00
by snibgo
ravikum wrote:I have cut hole in the place of monalisa's face and feathered it. (PNG)
I suppose you have made the monalisa's face transparent, so you can "-compose Over -composite" that PNG over the user's photo. But I don't understand what you are doing.

Can you upload a sample monolisa face and user photo to somewhere like dropbox.com and paste the URLs here?

Re: how to change skin color to some hex or RGB color?

Posted: 2014-08-13T06:30:26-07:00
by ravikum
Thanks for the reply here are the example images.
Image
and
Image

the girl face is kept behind monalisa face and
monalisa girl -geometry left top -compose DstOver -composite output.

Thanks

Re: how to change skin color to some hex or RGB color?

Posted: 2014-08-13T10:00:50-07:00
by fmw42
You could try -remap or if on Linux/MacOSX or Windows with Cygwin, you could try my script histmatch at the my signature link below this topic. You might need to crop the two photos to just around the faces to remove excess colors. For remap, use -unique-colors of the Mona Lisa face to create the colormap image.

What colors do you have for the monalisa image?

see
http://www.imagemagick.org/Usage/quantize/#remap

In the future, please provide your IM version and platform.

If you cannot figure this out, then please supply the original Mona Lisa image before the transparency.

Re: how to change skin color to some hex or RGB color?

Posted: 2014-08-13T11:10:45-07:00
by fmw42
Neither of the above seemed to work very well. But this seems to work. You can adjust the hex color and/or the saturation in -modulate. I have added some noise to emulate the mona lisa image, but you can remove that if you want.

try this

Code: Select all

convert face.jpg +sigmoidal-contrast 3,100 -seed 100 -attenuate 0.75 +noise gaussian \
\( -clone 0 -fill "#86491A" -colorize 100 \) -compose colorize -composite -modulate 100,110,100 face_result.jpg
I cannot say that the same arguments will work for every face image. Some tuning of the modulate and/or hex value may be needed depending upon skin tones in the face image.