您好,欢迎访问三七文档
当前位置:首页 > IT计算机/网络 > 图形图像 > 数字图像处理人脸识别matlab程序代码。
数字图像处理人脸识别程序代码程序代码:clear;I=imread('E:\02089008.jpg');%%插入图像地址O=rgb2ntsc(I);G=O(:,:,2);[mn]=size(G);U=zeros(m,n);fori=1:mforj=1:nifG(i,j)0.03&&G(i,j)0.16U(i,j)=1;endendendsr=strel('disk',6);C=imclose(U,sr);L=bwlabel(C);B=regionprops(L,'area');Se=[B.Area];Sm=max(Se);ifSmm*n/27B1=bwareaopen(C,Sm);k_y1=m;k2=m;l2=n;fori=1:mifany(B1(i,:))==1k_y1=i;breakendendfori=k_y1:mifB1(i,:)==0k2=i;breakendendforj=1:nifany(B1(:,j))==1l_y1=j;breakendendforj=l_y1:nifB1(:,j)==0l2=j;breakendendk_y=k2-k_y1;l=l2-l_y1;ifk_y.5*l&&k_y3*lI1=imcrop(B1,[l_y1k_y1l.4*k_y]);[n1m1]=size(I1);L1=bwlabel(I1);E=regionprops(L1,'area');Si=[E.Area];Sm=max(Si);ifSm/(n1*m1).3B2=bwareaopen(I1,floor(.5*Sm));g_y1=m1;g2=m1;forj=1:m1ifany(B2(:,j))==1g_y1=j;breakendendforj=g_y1:m1ifB2(:,j)==0;g2=j;breakendendg=g2-g_y1;figure;imshow(I);holdonh1=line([l_y1+g_y1,l_y1+g_y1+g],[k_y1,k_y1]);h2=line([l_y1+g_y1+g,l_y1+g_y1+g],[k_y1,k_y1+1.1*g]);h3=line([l_y1+g_y1+g,l_y1+g_y1],[k_y1+1.1*g,k_y1+1.1*g]);h4=line([l_y1+g_y1,l_y1+g_y1],[k_y1+1.1*g,k_y1]);h=[h1h2h3h4];set(h,'Color',[100],'LineWidth',2);elsefigure;imshow(I);endelsefigure;imshow(I);endelsefigure;imshow(I);end示例:源图像:处理后为:
本文标题:数字图像处理人脸识别matlab程序代码。
链接地址:https://www.777doc.com/doc-2133737 .html