Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect skin tone from an image

I am trying to develop an application which will detect the color of the face once an image is provided. I was able to find out the face detection algorithm from OpenCV and integrate it. However I could not find any example or interface by which I can detect the color of the face.

I have the logic which I am presenting. Please let me know if there is anything available for this or do I need to write the separate function for this?

Logic: in the given image area, find the color detail which is repeated mostly in the given. I have gone through the histogram and not sure how it will be of help.

Any help will be greatly appreciated.

like image 571
Nareshkumar Avatar asked Feb 04 '23 02:02

Nareshkumar


1 Answers

To detect skin tone of a face (or any image!), I highly recommend that you use the HSV color space (or a more complex colorspace such as LAB) rather than the default RGB colorspace, because RGB values will vary a lot depending on strong or dim lighting and shadows, etc. Whereas HSV is much better at handling lighting differences, and it gives you an easy to use color value.

HSV means Hue-Saturation-Value, where the Hue is the color. eg: a Hue of 0 is red and a Hue of 50 might be green. Saturation is the greyness, so that a Saturation value near 0 means it is dull or grey looking whereas as a Saturation value of 200 might be a very strong color (eg: red if Hue is 0). And Value is the brightness of the pixel, so 0 is black and 255 is white.

So whether you use a histogram or not is upto you, but either way you should first convert your image to HSV, then you can look for the most common Hue value using a histogram or just a simple search. The Hue value will be the skin tone or color you want. And if you want to make it a bit more advanced, you could take into account the values of Saturation and brightness Value to decide if it is actually black or white or grey rather than a color at all.

I have some more OpenCV RGB to HSV conversion info on my HSV tutorial page at:

http://www.shervinemami.co.cc/colorConversion.html

like image 86
Shervin Emami Avatar answered Feb 08 '23 16:02

Shervin Emami