First time here? Check out the FAQ!

Ask Your Question
5

Skin detection

asked Oct 19 '12

ognamdik gravatar image

updated Oct 19 '12

From the image below, I want the input (left image) to have an output (right image). image description

I've tried adaptive threshold, canny, skin detection, blurring, dilating and eroding, finding contours then floodfilling it, and approxPolyDP but still can't get the right output. I can not floodfill right because there are many contours. what am I doing wrong?

Here's a sample of the SkinDetection code:

#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
Mat src;
int main(){
    src = imread("open_1a.jpg");
    if (src.empty())
        return -1;
    blur( src, src, Size(3,3) );
    Mat hsv;
    cvtColor(src, hsv, CV_BGR2HSV);
    Mat bw;
    //inRange(hsv, Scalar(0, 40, 60), Scalar(20, 150, 255), bw);
    inRange(hsv, Scalar(0, 10, 60), Scalar(20, 150, 255), bw);
    imshow("src", src);
    imshow("dst", bw);
    waitKey(0);
    return 0;
}

here's the input and the output of the code above: image description

Preview: (hide)

Comments

1

Could you post your output images ? What method are you using for skin segmentation ?

Tina123 gravatar imageTina123 (Oct 19 '12)edit

@Tina123 added the output image to the post above.

ognamdik gravatar imageognamdik (Oct 19 '12)edit

2 answers

Sort by » oldest newest most voted
2

answered Oct 19 '12

elmiguelao gravatar image

I've tried using the thresholds (see this Q&A) skin_out = (H < 20) ^ (S > 48) ^ (V > 80), they should work better than those you are using. Of course with the dilate(5x5 window)-erode(5x5 window) afterwards, to join smaller patches. But the image you are showing is overexposed, so the Hue threshold is most likely failing in some parts, since the implementation in openCV yields a range [0..180}, you also will need to extend the Hue threshold to cover something like [170..180} ^ [0..20] or so.

Preview: (hide)
1

answered Oct 19 '12

imran gravatar image

Try to use only the Hue and Saturation channels, exclude the Value channel. You should get a better result then.

Preview: (hide)

Question Tools

Stats

Asked: Oct 19 '12

Seen: 14,206 times

Last updated: Oct 19 '12