欢迎来到天天文库
浏览记录
ID:37854242
大小:912.50 KB
页数:3页
时间:2019-06-01
《MATLAB肤色检测》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、RGB=imread('1.jpg');YCbCr=rgb2ycbcr(RGB);%½«RGB¸ñʽת»¯³ÉYCbCr¸ñʽY=YCbCr(:,:,1);%ÌáÈ¡ÁÁ¶ÈCb=YCbCr(:,:,2);Cr=YCbCr(:,:,3);imshow(RGB);title('RGB');%ÏÔʾÔͼfigure,imshow(YCbCr);title('YCbCr');%ÏÔʾYCbCrͼI=RGB;rows=size(YCbCr,1);%¼ÆËãÐÐÊýcolumns=size(YCbCr,2);%¼ÆËãÁÐÊý%ÒÔÏÂΪÓÃÍÖÔ²·½·¨Åж¨·ôÉ«ÇøÓò
2、ºÍ·Ç·ôÉ«ÇøÓò£¬½øÐжþÖµ»¯k=(2.53/180)*pi;m=sin(k);n=cos(k);cx=109.38;cy=152.02;ecx=1.60;ecy=2.41;a=25.39;b=14.03;fori=1:rowsforj=1:columnsifY(i,j)<80I(i,j,:)=0;elseif(Y(i,j)<=230&&Y(i,j)>=80)x=(double(Cb(i,j))-cx)*n+(double(Cr(i,j))-cy)*m;y=(double(Cr(i,j))-cy)*n-(double(Cb(i,j))-cx)*m;if((x-ecx)^
3、2/a^2+(y-ecy)^2/b^2)<=1I(i,j,:)=255;elseI(i,j,:)=0;endelseifY(i,j)>230x=(double(Cb(i,j))-cx)*n+(double(Cr(i,j))-cy)*m;y=(double(Cr(i,j))-cy)*n-(double(Cb(i,j))-cx)*m;if((x-ecx)^2/(1.1*a)^2+(y-ecy)^2/(1.1*b)^2)<=1I(i,j,:)=255;elseI(i,j,:)=0;endendendendfigure,imshow(I);%ÏÔʾ¶þÖµ»¯ºóµÄͼÏñ
此文档下载收益归作者所有