1、function r, zhongxindian=ff %输出各切片最大内切圆半径及圆心坐标a=zeros(512,512);b=zeros(512,512);for i=1:512for j=1:512a(i,j)=i-257; %横坐标的对应b(i,j)=j-257; %纵坐标的对应endend %图像在 xyz 面上的 x 轴、y 轴坐标zhongxindian=zeros(100,2);r=zeros(100,1);for k=0:99t=strcat(f:/,int2str(i),.bmp);b=imread(t);b=zhuanhua(b);%将 01 互换blunkuo=edge
2、(b,sobel);%提取轮廓bgujia=bwmorph(b,skel,inf);%提取骨架%寻找内切圆x0,y0,v0=find(b0lunkuo);a0,b0,c0=find(b0gujia);m=length(a0);n=length(x0);juli=zeros(m,n);cunfang=zeros(m,2);for i=1:mfor j=1:np1=a0(i);q1=b0(i);p2=x0(j);q2=y0(j);juli(i,j)=sqrt(a(p1,q1)-a(p2,q2)2+(b(p1,q1)-b(p2,q2)2);%骨架上的各个点到轮廓的距离endzx,zxxh=min(juli(i,:);%骨架上一点到轮廓的最短距离即以骨架上各个点为圆心的内切园的半径cunfang(i,1)=zx;cunfang(i,2)=zxxh;endzd,zdxh=max(cunfang(:,1);%寻找半径中最大的半径和其对应的圆心坐标g=a0(zdxh);h=b0(zdxh);zhongxindian(k+1,1)=a(g,h);zhongxindian(k+1,2)=b(g,h);r(k+1)=zd;end