第十一章 描述

链码

%f=imread('Free.tif');
%f=g2;
%f=rgb2gray(f);
%imshow(f)
%h=fspecial('average',9);
%g=imfilter(f,h,'replicate');
%imshow(g)
%g=im2bw(g,0.5);
%imshow(g)
B=boundaries(g2);%B为边界坐标
d=cellfun('length',B);
[max_d,k]=max(d);
b=B{k};%B中最长边界
[M,N]=size(g);
g=bound2im(b,M,N,min(b(:,1)),min(b(:,2)));%生成一幅二值图像,大小M*N,起点为b最小坐标
imshow(g)
[s,su]=bsubsamp(b,10);%对b二次取样,su按比例取得边界点集合
g2=bound2im(s,M,N,min(s(:,1)),min(s(:,2)));
imshow(g2,[])
cn=connectpoly(s(:,1),s(:,2));%对二次取样点连接
g2=bound2im(cn,M,N,min(cn(:,1)),min(cn(:,2)));
imshow(g2,[])
c=fchcode(su);%freeman链码
c.x0y0%链码起点
w=c.fcc;%链码坐标

fourier.eng.hmc.edu/e161/dipum/
MPP


B=imread('leaf.tif');
b=boundaries(B,4,'cw');
b=b{1};
[M,N]=size(B);
xmin=min(b(:,1));
ymin=min(b(:,2));
bim=bound2im(b,M,N,xmin,ymin);
imshow(bim);
[x,y]=minperpoly(B,2);
b2=connectpoly(x,y);
B2=bound2im(b2,M,N,xmin,ymin);
imshow(B2)
[x,y]=minperpoly(B,4);
b3=connectpoly(x,y);
B3=bound2im(b3,M,N,xmin,ymin);
imshow(B3)
[x,y]=minperpoly(B,8);
b4=connectpoly(x,y);
B4=bound2im(b4,M,N,xmin,ymin);
imshow(B4)

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_41244435/article/details/83720264