全文预览

数字的图像处理期末大作业

上传者:徐小白 |  格式:doc  |  页数:13 |  大小:685KB

文档介绍
j-1)-IMG(i+1,j-1)+IMG(i-1,j+1)+IMG(i,j+1)+IMG(i+1,j+1);G1(i,j)=IMG(i-1,j)+IMG(i-1,j+1)+IMG(i,j+1)-IMG(i,j-1)-IMG(i+1,j-1)-IMG(i+1,j);G2(i,j)=-IMG(i-1,j-1)-IMG(i-1,j)-IMG(i,j-1)+IMG(i+1,j)+IMG(i,j+1)+IMG(i+1,j+1);endendfigure;imshow(H1);title('水平边缘');figure;imshow(H2);title('垂直边缘');figure;imshow(G1);title('-45度边缘');figure;imshow(G2);title('+45度边缘');Z=zeros(m,n);fori=1:mforj=1:nZ(i,j)=H1(i,j)+H2(i,j)+G1(i,j)+G2(i,j);endendfigure;imshow(Z);title('提取的边缘');%4.对提取的边缘进行二值化T=sum(Z(:))/(m*n);T2=20;whileT2>0.5Y1=0;Y2=0;N1=0;N2=0;N1=double(N1);N2=double(N2);Y1=double(Y1);Y2=double(Y2);fori=1:mforj=1:nif(Z(i,j)>T)Y1=Y1+double(Z(i,j));N1=N1+1;elseY2=Y2+double(Z(i,j));N2=N2+1;endendendt1=Y1/N1;t2=Y2/N2;T1=(t1+t2)/2;T2=abs(T-T1);T=T1endGS=zeros(m,n);fori=1:mforj=1:nifZ(i,j)>TGS(i,j)=0;elseGS(i,j)=255;end

收藏

分享

举报
下载此文档