• 大小: 1KB
    文件类型: .zip
    金币: 2
    下载: 0 次
    发布日期: 2024-01-05
  • 语言: 其他
  • 标签: hand  segmentation  

资源简介

hand_segmentation hand_segmentation hand_segmentation

资源截图

代码片段和文件信息

function skin = hand_segmentation(im)
%imgrgb=imread(‘IMG_2755.jpg‘);
[w h]=size(im(::1));
%Laplacian 八邻域模板滤波
h1=[-1-1-1;-19-1;-1-1-1];
bw1=imfilter(imh1);
% bw1=im;
[mnc]=size(bw1);
% delete strFilec;
%将RGB色彩空间转换为Ycbcr色彩空间
imgrgb3=rgb2ycbcr(bw1);
y=imgrgb3(::1);
cb=imgrgb3(::2);
cr=imgrgb3(::3);
%==================================
%在Ycbcr色彩空间中分割肤色区域
cb=double(cb);
cr=double(cr);
y=double(y);
bwycbcr=zeros(mn);
for i=1:m
    for j=1:n
        if y(ij)<125
            cb1=108+(125-y(ij))*10/109;
            cr1=154-(125-y(ij))*10/109;
            wcb=23+(y(ij)-16)*23.97/109;
            wcr=20+(y(ij)-16)*18.76/109;
            cb1=(cb(ij)-cb1)*46.97/wcb+cb1;
            cr1=(cr(ij)-cr1)*38.76/wcr+cr1;
        elseif y(ij)>188
            cb1=108+(y(ij)-188)*10/47;
            cr1=154+(y(ij)-188)*22/47;
            wcb=14+(235-y(ij))*32.97/47;
            wcr=10+(235-y(ij))*28.76/47;
            cb1=(cb(ij)-cb1)*46.97/wcb+cb1;
            cr1=(cr(ij)-cr1)*38.76/wcr+cr1;
        else
            cb1=cb(ij);
            cr1=cr(ij);
        end
        x1=[-0.819 0.574]*[cb1-109.38;cr1-152.02];
        y1=[-0.574 -0.819]*[cb1-109.38;cr1-152.02];
        if (x1-1.60).^2/644.6521+(y1-2.41).^2/196.8409<=1
            bwycbcr(ij)=1;
        else bwycbcr(ij)=0;
        end
    end 
end
%strWrite=strcat(‘a‘strFile1);
%imwrite(bwycbcrstrWrite‘jpg‘);

%figure(1)
%subplot(221);
%imshow(im);
title(‘原始图像‘);
%figure(2)
%subplot(222);
%imshow(bw1);
%figure(3)
title(‘Laplacian滤波‘);
%subplot(223);
%imshow(bwycbcr); 
%figure(4)
title(‘Ycbcr皮肤颜色模型‘);
%subplot(224);
%把bwycbcr拉伸到[01]
bw2=imadjust(bwycbcr[01]);
bw2=imageclose(bw2);
skin=bw2;
%去除少像素连通区域
skin=bwareaopen(skinround(w*h/10));
%imshow(skin); 
title(‘去除少数像素‘);
%imwrite(skin‘result.bmp‘);






 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     文件        1952  2011-07-15 09:27  hand_segmentation.m
     目录           0  2018-04-17 11:31  新建文件夹\

评论

共有 条评论