Ask Your Question

Skin detection

asked 2012-10-18 23:14:05 -0600

ognamdik gravatar image

updated 2012-10-19 02:06:32 -0600

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);
    return 0;

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

edit retag flag offensive close merge delete



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

Tina123 gravatar imageTina123 ( 2012-10-19 01:46:27 -0600 )edit

@Tina123 added the output image to the post above.

ognamdik gravatar imageognamdik ( 2012-10-19 02:07:49 -0600 )edit

2 answers

Sort by ยป oldest newest most voted

answered 2012-10-19 02:48:10 -0600

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.

edit flag offensive delete link more

answered 2012-10-19 07:43:33 -0600

imran gravatar image

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

edit flag offensive delete link more

Question Tools


Asked: 2012-10-18 23:14:05 -0600

Seen: 13,896 times

Last updated: Oct 19 '12