æè¿°é¢ç²å½¢è²è¾¹ççå形维æ°matlabç¨åº:
ããim=imread('e:\4.bmp');
imshow(im);
gr=im;
level = graythresh(gr);
figure,imshow(gr);
bw=im2bw(gr,0.5);
%bw= bwperim(bw);
%bw=~bw;
figure,imshow(bw);
ããbw=edge(bw,'canny');
ããfigure,imshow(bw);
ããsi=size(bw);
ããminblock=1;
ããmaxblock=16;
ããflag=0;
ããn=linspace(0,0,maxblock-minblock+1);
ããfor k=minblock:maxblock
ãã for y=1:k:si(2)-k
ãã for x=1:k:si(1)-k
ãã flag=0;
ãã for y1=y:y+k-1
ãã for x1=x:x+k-1
ãã if bw(x1,y1)==1
ãã flag=1;
ãã end;
ãã end;
ãã end;
ãã if flag==1
ãã n(k-minblock+1)=n(k-minblock+1)+1;
ãã end;
ãã end;
ãã end;
ããend;
ããaa=[minblock:maxblock];
ããxx1=-log(aa);
ããyy1=log(n);
ããa=polyfit(yy1,xx1,1);
ããx=polyval(a,yy1);
ããfigure,plot(xx1,yy1,'k+',x,yy1,'r');
ããD=1/a(1);
温馨提示:内容为网友见解,仅供参考