I want to be able to crank up the saturation and contrast of an image but minimize the effect on flesh tones (if any) in the image. Needless to say, it doesn't have to get it right 100% of the time, just as long as it gets it more or less right most of the time.
How can I accomplish this?
exclude flesh tones from color transformation?
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: exclude flesh tones from color transformation?
Oh that should be reasonably simple..
Create a mask of the image defining the 'flesh tones'.
One simpe way would be to make any 'flesh color' transparent for example...
Note that the Fuzz Factor is a 3 dimensional sphere in the RGB colorspace (or whatever colorspace the image is in). A different color space or smaller 'spheres' with a number of different color centers, may work better to define what you mean by 'flesh-tone'
It may also vary by the lighting and the 'race' of the person in the image, as well as just how big a difference there is between 'flesh' and 'background'.
Can you please post your 'flesh-tone' color definition when you have worked it out. It would be a useful thing to have, especially for programs that classify images.
Once you have the above the way you want it, do your saturation changes, and just overlay back over your original image. The 'flashy' parts will appear unchanged though the 'holes' you made in the image.
NOTE the use of PNG in the above. Do not use JPG as 1/ it is lossy and losses quality from read/save cycle, and 2/ it does not understand transparency.
Create a mask of the image defining the 'flesh tones'.
One simpe way would be to make any 'flesh color' transparent for example...
Code: Select all
convert image.jpg -matte -fuzz 40% -transparent '#DF9E25' non-flesh.png
It may also vary by the lighting and the 'race' of the person in the image, as well as just how big a difference there is between 'flesh' and 'background'.
Can you please post your 'flesh-tone' color definition when you have worked it out. It would be a useful thing to have, especially for programs that classify images.
Once you have the above the way you want it, do your saturation changes, and just overlay back over your original image. The 'flashy' parts will appear unchanged though the 'holes' you made in the image.
NOTE the use of PNG in the above. Do not use JPG as 1/ it is lossy and losses quality from read/save cycle, and 2/ it does not understand transparency.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: exclude flesh tones from color transformation?
Skin tone examples here:
http://www.idigitalemotion.com/tutorial ... ntone.html
http://www.polykarbon.com/tutorials/skintones/tone1.htm
This is going to be used for thumbnailing basically so ultimate quality loss isn't that big of a concern.
http://www.idigitalemotion.com/tutorial ... ntone.html
http://www.polykarbon.com/tutorials/skintones/tone1.htm
This is going to be used for thumbnailing basically so ultimate quality loss isn't that big of a concern.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: exclude flesh tones from color transformation?
Thanks.
Okay that gives you a three point gradient though RGB (or whatever) colorspace.
From that you will expand the number of colors to 5 or 9 points, and then adjust the fuzz or thickness of the line to match all the flesh colors of that type.
Keep us informed of your progress in matching skin tones, even roughly.
For example will you have some automatic way of figuring out what skin tone gradient is needed for some particular image. and what sort of fuzz factor you use.
PS: I am quite certain that a different color space will probably match better than RGB which is probably about the worst colorspace for real-life images. Its designed for computer monitors, not humans, just as CYMK was designed for printers.
Okay that gives you a three point gradient though RGB (or whatever) colorspace.
From that you will expand the number of colors to 5 or 9 points, and then adjust the fuzz or thickness of the line to match all the flesh colors of that type.
Keep us informed of your progress in matching skin tones, even roughly.
For example will you have some automatic way of figuring out what skin tone gradient is needed for some particular image. and what sort of fuzz factor you use.
PS: I am quite certain that a different color space will probably match better than RGB which is probably about the worst colorspace for real-life images. Its designed for computer monitors, not humans, just as CYMK was designed for printers.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/