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.
The histogram represents the amount of pixels of a given color which are in the image.
For example, lets say you have this 3x3 image:
3 4 3 1 1 1 2 2 1
The histogram would be: count: 4 2 2 1 color: 1 2 3 4
from this you would have that the color which is found most is the color 1. It probably also would make sense to sum up very similar color.
For example use count(2) = sum(hist(1), hist(2), hist(3)); (being hist the number of pixels in that color)
There's no such function in OpenCV and by reason. Face detection is very complex problem and there are only few approaches that do the work. For example, OpenCV implements Viola & Jones face detection algorithm which is known as one of the best such algorithms. Some other implementations use neural networks etc.
So, face detection problem in some general complex scenes isn't as easy as it seems. I'm afraid that using face color information wouldn't be good enough to give stable results. There are some papers suggesting such techniques but conditions under which algorithm works are mostly limited (e.g. only one face per image or very simple background).
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: