What is the background theory of this Skin Detection in RGB code?
1 view (last 30 days)
Show older comments
Thanh Nguyen Bui
on 19 Sep 2015
Commented: Thanh Nguyen Bui
on 24 Sep 2015
Hi, I am new to MATLAB and here too. I would like to know more about how the following code works and its background theory.
Currently I am doing my Bachelor Thesis about gesture recognition. For skin detection I found the following code on YouTube whose author is Anirudh Sharma ( https://www.youtube.com/watch?v=gvtqSJx3Y98 ). The most important part of the code looks like this (based on my implement):
vid = videoinput('winvideo',1,'RGB24_640x480');
... %Some webcam setup code after this
data = getsnapshot(vid);
I = imsubtract(data(:,:,1), rgb2gray(data));
I = medfilt2(I,[3 3]);
I = imadjust(I);
level = graythresh(I);
Ibw = im2bw(I,level);
I know it is unusual to use RGB color space to detect skin instead of YCrCb, HSV, etc... but turned out it worked pretty well, fast and robust - especially with a monotone background. But the point is, how could the skin-toned region appears clearly on the background after subtracting the Grayscale from the Red plane (I = imsubtract(data(:,:,1), rgb2gray(data));)? Is there a theory background of this?
So far I haven't found yet any reliable document about this. I also have no hope contacting the author as his video was uploaded 2 years ago and his email or Google+ on his YouTube account are unavailable. I know some people have already asked about this code before but none of them satisfy me. Therefore it would be great if there is an theoretical and practical explanation about this.
Thank you so much in advance.
0 Comments
Accepted Answer
Image Analyst
on 19 Sep 2015
It can work in RGB color space for certain controlled situations, like skin tones that are similar and illumination levels and color that are consistent. It's not the most robust way to do it but it can work provided everything works out just right.
But I'm not sure what your question means. "how could the skin-toned region appears clearly on the background after subtracting the Grayscale from the Red plane" What does that mean - appears clearly? Do you want to mask out the non-skin so that it's black? Or what???
5 Comments
Image Analyst
on 21 Sep 2015
Well look at your hand. See how it's the same color (intensity) as the background? Try it also with the blue channel and you'll see the hand won't be the same color - it will be darker. Also post your background image (the one without the hand in there at all).
More Answers (0)
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!