How to detect skin here?

2 次查看(过去 30 天)
Zahra kamkar
Zahra kamkar 2014-4-6
Hello. In the last topic, I tried to find the region for the eyes. Thankfully I could do it. Then I asked some friends from here to tell me how to find skin to divide eyelids from eye. The programs were helpful but now, I need to detect skin, just with the following method. Could anyone help me please? This is the rule for skin detection for my project:
(R>95)AND(G>40)AND(B>20)AND(max{R,G,B}-min{R,G,B}>15)AND( R>15)
The first part of my project, namely, detection of eye region is:
if true
% i=imread('pic8.jpg');
subplot(5,5,1)
imshow(i)
title('original image');
iycbcr=rgb2ycbcr(i);
iycbcr = im2double(iycbcr);
subplot(5,5,2)
imshow(iycbcr)
title('YCBCR space');
y=iycbcr(:,:,1);
cb=iycbcr(:,:,2);
cr=iycbcr(:,:,3);
ccb=cb.^2;
subplot(5,5,3)
imshow(ccb)
title('CB^2');
ccr=(1-cr).^2;
subplot(5,5,4)
imshow(ccr)
title('(1-CR)^2');
cbcr=ccb./cr;
subplot(5,5,5)
imshow(cbcr)
title('CB/CR');
igray=rgb2gray(i);
igray=~igray;
subplot(5,5,6)
imshow(igray)
title('Gray space');
g=1./3;
l=g*ccb;
m=g*ccr;
n=g*cbcr;
eyemapchr=l+m+n;
subplot(5,5,7)
imshow(eyemapchr)
title('Chrom Eyemap');
t=histeq(eyemapchr);
subplot(5,5,8)
imshow(t)
title('Equalized image');
SE=strel('disk',15,8);
o=imdilate(igray,SE);
p=1+imerode(igray,SE);
eyemaplum=o./p;
subplot(5,5,9)
imshow(eyemaplum)
title('Lum Eyemap');
cc=and(t,eyemaplum);
subplot(5,5,10)
imshow(cc)
title('AND of Lum&Chrom');
subplot(5,5,11)
imshow(i);
I=im2double(i);
title('original image');
R=I(:,:,1);
G=I(:,:,2);
B=I(:,:,3);
newi=I.*repmat(cc,[1,1,3]);
subplot(5,5,12)
imshow(newi)
title('Multiplication');
end
  1 个评论
Mohammad Farhad Aryan
Hi Zahra,
I need to detect the skin part of the image in my research too and found some tutorials worked on the same issue but using different rules.
Could you please tell me how do you make this rule (specially numbers of each color component) such the one you are using in your project?
(R>95)AND(G>40)AND(B>20)AND(max{R,G,B}-min{R,G,B}>15)AND( R>15)

请先登录,再进行评论。

回答(1 个)

Image Analyst
Image Analyst 2014-4-6
There will be a lot of ambiguous pixels if you have a pink skinned baby in pink clothing. Why do you need to find the skin? Just find the eyes, and pink pixels. Who cares if the pink is clothing or baby. It doesn't matter if all you want to do it find the eyes on the face.
  2 个评论
Zahra kamkar
Zahra kamkar 2014-4-6
hi Analyst. Thanks for your attention. I need to do all the parts of the paper that I have chosen. You know, unfortunately, I have set my codes to this image and they are not appropriate enough to other images so I have to detect the skin in this image as well. Now, imagine that I have detected the skin as I have done it with another method before, how I can calculate the measure of openness of the eye region ? This is my code which I have detected skin in and I need to calculate eye openness:
if true
% i=imread('pic8.jpg');
subplot(5,5,1)
imshow(i)
title('original image');
iycbcr=rgb2ycbcr(i);
iycbcr = im2double(iycbcr);
subplot(5,5,2)
imshow(iycbcr)
title('YCBCR space');
y=iycbcr(:,:,1);
cb=iycbcr(:,:,2);
cr=iycbcr(:,:,3);
ccb=cb.^2;
subplot(5,5,3)
imshow(ccb)
title('CB^2');
ccr=(1-cr).^2;
subplot(5,5,4)
imshow(ccr)
title('(1-CR)^2');
cbcr=ccb./cr;
subplot(5,5,5)
imshow(cbcr)
title('CB/CR');
igray=rgb2gray(i);
igray=~igray;
subplot(5,5,6)
imshow(igray)
title('Gray space');
g=1./3;
l=g*ccb;
m=g*ccr;
n=g*cbcr;
eyemapchr=l+m+n;
subplot(5,5,7)
imshow(eyemapchr)
title('Chrom Eyemap');
t=histeq(eyemapchr);
subplot(5,5,8)
imshow(t)
title('Equalized image');
SE=strel('disk',15,8);
o=imdilate(igray,SE);
p=1+imerode(igray,SE);
eyemaplum=o./p;
subplot(5,5,9)
imshow(eyemaplum)
title('Lum Eyemap');
cc=and(t,eyemaplum);
subplot(5,5,10)
imshow(cc)
title('AND of Lum&Chrom');
subplot(5,5,11)
imshow(i);
I=im2double(i);
title('original image');
R=I(:,:,1);
G=I(:,:,2);
B=I(:,:,3);
newi=I.*repmat(cc,[1,1,3]);
subplot(5,5,12)
imshow(newi)
title('Multiplication');
%Convert from the sRGB to the LAB color space
cform = makecform('srgb2lab');
t = applycform(newi,cform);
subplot(5,5,13)
imshow(t)
k=t(:,:,2);
subplot(5,5,14)
imshow(k)
L=graythresh(t(:,:,2));
BW1=im2bw(t(:,:,2),L);
subplot(5,5,15)
imshow(BW1)
M=graythresh(t(:,:,3));
subplot(5,5,16)
imshow(M)
BW2=im2bw(t(:,:,3),M);
subplot(5,5,17)
imshow(BW2)
O=BW1.*BW2;
subplot(5,5,18)
imshow(o)
BW3=edge(o,'canny');
subplot(5,5,19)
imshow(BW3)
end
Image Analyst
Image Analyst 2014-4-6
Well how does your paper describe it? I'm sure there are different methods. If you say you can find the skin then I would look for all non-skin black "islands" inside your skin mask. First you need to find the eyes and not any other non-skin pixels like freckled, moles, nostrils, ear holes or any other non-skin areas that may also be there. For example you can look at their color. If they're dark, then they're not sclera. So try to find all the light blobs inside the skin mask. Then see if those areas are next to another non-skin area, which would be the iris. Measure the area and estimate the degree to which that eye is open of closed. I'm sure the code will be at least 3 times as long as what you've got here, maybe longer, so keep working on it.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Feature Detection and Extraction 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by