Matlab:在分割时删除皮肤部分

时间:2016-10-04 21:42:00

标签: matlab image-processing

如何在细分中去除皮肤部分?

首先,我把第一张照片缩小了,因为照片有些吓人,我会在最后部分给出图片。

enter image description here

我正在使用RGB& ycbcr分割,但似乎分割效果不佳。

clear all;
  close all;
  clc;

   img=imread('acne.jpg');


 %ycbcr segmentation
   img_ycbcr=img;  %image from the previous segmentation
   ycbcr=rgb2ycbcr(img_ycbcr);
   cb=ycbcr(:,:,2);
   cr=ycbcr(:,:,3);


    %Detect Skin
    %[r,c,v] = find(cb>=77 & cb<=127 & cr>=133 & cr<=173);
     [r c v] = find(cb<=77 | cb >=127 | cr<=133 | cr>=173);
    numid = size(r,1);

    %Mark Skin Pixels
    for i=1:numid
        img_ycbcr(r(i),c(i),:) = 0;
       % bin(r(i),c(i)) = 1;
    end

    figure
    title('ycbcr segmentation');
   imshow(img_ycbcr);

 %==============================================================
  %rgb segmentation

img_rgb=img_ycbcr;
r=img_rgb(:,:,1);
g=img_rgb(:,:,2);
b=img_rgb(:,:,3);


[row col v]= find(b>0.79*g-67 & b<0.78*g+42 & b>0.836*g-14 & b<0.836*g+44 ); %non skin pixels
numid=size(row,1);

for i=1:numid
    img_rgb(row(i),col(i),:)=0;
end


figure
imshow(img_rgb);

enter image description here

这是我的样本:

enter image description here

1 个答案:

答案 0 :(得分:2)

我同意Adriaan。不要只使用颜色,使用其他信息,如形状和边缘。

最后两个彩色平板似乎对比度最高,所以让我们使用其中一个:

Nipple = imread('N8y6Q.jpg')

Nipple = imadjust(Nipple(:,:,2));

imshow(Nipple)

grayscale of the green plane of the image

[centers, radii] = imfindcircles(Nipple, [30,60]);

hold on

imshow(Nipple);
viscircles(centers, radii);

grayscale with segmented area

圆形霍夫变换是一种查找圆形物体的有效方法,如果您知道近似半径范围并且满足约。对象的位置和大小。

如果没有,您可以尝试其他经典方法,例如(Canny)边缘检测,使用霍夫中心点作为标记 - &gt;区域生长,适合蛇等。