www.pudn.com > lianma.rar > main.txt, change:2011-12-19,size:661b


f=imread('D:\query images.tif'); 
figure;imshow(f); 
%se=strel('disk',10); 
%fc=imclose(f,se); 
fc=imfill(f,'hole'); 
%figure,imshow(fc) 
se=strel('disk',15); 
fco=imopen(fc,se); 
 
bw=fco; 
%figure,imshow(bw); 
trainset=train(); 
 
[L,num] = bwlabel(bw); %标记 
tic; 
for t=1:num 
    [r c]=find(L==t); 
    r1=min(r); 
    c1=min(c); 
    r2=max(r); 
    c2=max(c); 
   z=bw(r1:r2,c1:c2); 
   x=dailianma(z); 
   xset{t}=x; 
  %与训练样本进行匹配 
    d(t)=norm(abs(xset{t}(1:50))-abs(trainset(1:50))); 
 
if (d(t)<10&&d(t)>9)||(d(t)<19&&d(t)>17)||(d(t)>15&&d(t)<16) 
       rectangle('Position',[c1,r1,c2-c1,r2-r1],'EdgeColor','g'); %显示结果 
end 
end 
toc;