• 大小: 71KB
    文件类型: .m
    金币: 2
    下载: 1 次
    发布日期: 2021-05-23
  • 语言: Matlab
  • 标签: matlaB  

资源简介

基于轮廓提取的多边形近似匹配算法 matlaB编的

资源截图

代码片段和文件信息

 %script FILE FOR CONTOUR FOLLOWING IN A BINARY IMAGE
%AUTHOR : RAJJAN SINGH THAKUR (VIT UNIVERSITY)
%DATE :14/2/09
function [cntcnt2area1area2]= mobanpipei()

% for(i=1:100)
%     for(j=1:100)

%         a(ij)=0;
%     end
% end
%  c=roipoly(a);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                     图像轮廓提取                       %       
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%a=imread(‘000.bmp‘);
%%c=im2bw(rgb2gray(a)254/255);
%imshow(c);
%%t=0;
%s=input(‘press l to select row from left and r to select row from right \n enter the alphabet within  single quote \n press enter after each result to continue‘);
%switch(s)
%case ‘l‘
    %%for(i=1:size(c1));
       %% for(j=1:size(c2));
            %%if(c(ij)==0)
               %% t=t+1;
               %% col2(t:)=[ij];
               %% break;
           %% end
       %% end
    %%end
    
%case ‘r‘
   % for(i=1:size(c1));
    %    for(j=size(c2):-1:1);
  %          if(c(ij)==1)
  %              t=t+1;
   %             col2(t:)=[ij];
   %             break;
   %         end
   %     end
  %  end
%otherwise 
   % []
%end

%FUNCTION TO COMPUTE THE CONTOUR IN BINARY IMAGE
%%[k1mn]=contour_b_trial_2(ccol2(11)col2(12));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                     图像轮廓提取                       %       
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                     多边形近似                        %       
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%k=im2bw(k10);
k=openpic();

h=boundaries(k4‘cw‘); 
h=h{1};
[M1N1]=size(k);
xmin=min(h(:1));
ymin=min(h(:2));
bim=bound2im(hM1N1xminymin);
[xy]=minperpoly(k3);
b2=connectpoly(xy);
B2=bound2im(b2M1N1xminymin);
B3=zeros(size(B21)size(B22));
for i=1:size(B21)
    for j=1:size(B22)
        if B2(ij)==0
            B3(ij)=0;
        end
        if B2(ij)==1
            B3(ij)=255;
        end
    end
end
B3=mat2gray(B3);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                     多边形近似                        %       
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                  Harris角点检测                       %       
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[coutmarked_imgcd] = cpda(B3);
%%ori_im2=B3;  
%%fx = [5 0 -5;8 0 -8;5 0 -5];          % % la gaucienne,ver axe x
%%Ix = filter2(fxori_im2);              % la convolution vers axe x
%%fy = [5 8 5;0 0 0;-5 -8 -5];          % la gaucienne,ver axe y
%%Iy = filter2(fyori_im2);              % la convolution vers axe y
%%Ix2 = Ix.^2;
%%Iy2 = Iy.^2;
%%Ixy = Ix.*Iy;
%%clear Ix;
%%clear Iy;

%%h= fspecial(‘gaussian‘[3 3]2);      % générer une fonction gaussienne,sigma=2

%%Ix2 = filter2(hIx2)

评论

共有 条评论