⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fourier_discriptors.m

📁 fourier descriptors in matlab
💻 M
字号:

im=imread('book.jpg');
im=rgb2gray(im);
im= mat2gray(padarray(im, [200 200]));
[k l]=size(im);
a_s=[2 0 0;0 2 0;0 0 1];
a_t=[1 0 0;0 1 0;100 -100 1];

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% The blocks which are not to be used should be commented  %%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%-------------------------------------------------------------
			%Scaling 
%-------------------------------------------------------------

 tform_s=maketform('affine',a_s);
 im_r=mat2gray(imtransform(im, tform_s,'bilinear'));

%-------------------------------------------------------------
			%Translation
%-------------------------------------------------------------


 tform_t=maketform('affine',a_t);
 im_r = imtransform(im, tform_t,... 
                         'XData',[1 (size(im,2)+a_t(3,1))],...
                         'YData', [1 (size(im,1)+a_t(3,2))]);    


%--------------------------------------------------------------
			%Rotation
%--------------------------------------------------------------

%im_r=imrotate(im,90,'crop');


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% The results are in the array results( ); and can be read from there %%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

im=edge(im,'canny',.5);
im_r=mat2gray(edge(im_r,'canny',.5));
figure, imshow(im);
figure, imshow(im_r);
[k l]=size(im);
s=0;
sr=0;
for p=1:k
    for q=1:l
        if im(p,q)==1
            s=s+1;
            y(s)=complex(p,q);
        end
    end
end
a_fd=fft(y');
a_fd(1)=0;
a_fd=(abs(a_fd)/abs(a_fd(2)))';
a_fd=a_fd(1:15);
[k l]=size(im_r);
for p=1:k
    for q=1:l
        if im_r(p,q)==1
           sr=sr+1;
           yr(sr)=complex(p,q); 
        end
    end
end
ar_fd=fft((yr)');
ar_fd(1)=0;
ar_fd=(abs(ar_fd)/abs(ar_fd(2)))';
ar_fd=ar_fd(1:15);
results(:,1)=a_fd;
results(:,2)=ar_fd;
results(:,3)=a_fd-ar_fd;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -