What is skin colour range in rgb?

I've seen several questions about skin colour already but didn't found an exact skin colour range in rgba. Can someone tell what is a min-max rgba colours for example for a middle-aged European man?

My code is like this:

   //Here should be scin min max rgba range
static CvScalar min = cvScalar(0, 0, 130, 0);//BGR-A
static CvScalar max= cvScalar(140, 110, 255, 0);//BGR-A

public static void main(String[] args) {
    //read image
    IplImage orgImg = cvLoadImage("colordetectimage.jpg");
    //create binary image of original size
    IplImage imgThreshold = cvCreateImage(cvGetSize(orgImg), 8, 1);
    //apply thresholding
    cvInRangeS(orgImg, min, max, imgThreshold);
    //smooth filter- median
    cvSmooth(imgThreshold, imgThreshold, CV_MEDIAN, 13);
    //save
    cvSaveImage("threshold.jpg", imgThreshold); }

So I need to just specify rgba values here.

Upvotes: 1

Views: 2356

Answers (1)

Stephen C
Stephen C

Reputation: 719576

There is no real answer to this. Skin tone is highly variable (even for middle age Caucasian men), and when you then throw in lighting effects (over exposure, under exposure, low light, colored incident light) you can't distinguish skin from non-skin based solely on RGB values of pixels.

My advice would be to pick a sensible first approximation, and then tweak the parameters. And don't expect to be able to pick accurately detect skin without taking the context into account ... somehow.

You could take your first approximation by looking at one of the color charts that you get from Googling "skin tone color chart rgb". Take your pick ...


@Stephen C what do u mean by "pick sensible first approximation, and then tweak the parameters" ? Just picking 1 color from a palette and what then?

(Ignoring the issue of lighting effects.) Since colors in RGB define a 3-D space, I propose that there is a region of that space where the colors are "skin" tones. The problem is to get a reasonable approximation of that region, you could start with a color chart of "skin" tones, plot them in 3-D and figure out a simple 3-D hull that encloses them ... and doesn't enclose colors that don't look right to your eye. Then try your "skin detection" based on the hull and adjust accordingly.

Upvotes: 3

Related Questions