内容发布更新时间 : 2024/12/23 6:34:23星期一 下面是文章的全部内容请认真阅读。
.
1.傅里叶变换
I=imread('d:\\3_1.tif','tif'); subplot(3,2,1); imshow(I);
title('3_1原始图像'); I=double(I); G1=fft2(I); subplot(3,2,2);
imshow(log(abs(G1)),[]); title('3_1幅度谱图'); [m,n]=size(I); for i=1:m for j=1:n
I2(i,j)=(-1)^(i+j).*I(i,j); end end
subplot(3,2,3); imshow(I2);
title('3_1原始中心对称图像'); G2=fft2(I2); subplot(3,2,4);
imshow(log(abs(G2)),[]);
Word 资料
.
title('3_1中心对称幅度谱图'); I3=imrotate(I2,45,'bilinear'); subplot(3,2,5); imshow(I3);
title('旋转45度图像'); G3=fft2(I3); subplot(3,2,6);
imshow(log(abs(G3)),[]); title('旋转45度幅度谱图'); 2.理想低通、高通滤波 低通滤波器:dl0=50 高通滤波器:dh0=30 I=imread('d:\\test5.gif','gif'); subplot(2,2,1); imshow(I); title('test5原图');
f=double(I); % chage into double as MATLAB doesn’t suppor calculation
% of image in unsigned int type subplot(2,2,2); G=fft2(f);
imshow(log(abs(G)),[]);
Word 资料
.
title('test5幅度谱图');
g=fft2(f); % fourier transform
g=fftshift(g); % zero-frequency area centralized [M,N]=size(g);
dl0=50; %cutoff frequency m=fix(M/2); n=fix(N/2); for i=1:M for j=1:N
d=sqrt((i-m)^2+(j-n)^2); if(d<=dl0) h=1; else h=0; end result(i,j)=h*g(i,j); end end
result=ifftshift(result); Gl1=ifft2(result); Gl2=uint8(real(Gl1)); subplot(2,2,3); imshow(Gl2) ;
title('test5低通滤波图');
Word 资料
.
dh0=30; for i=1:M for j=1:N
d=sqrt((i-m)^2+(j-n)^2); if(d>=dh0) h=1; else h=0; end result(i,j)=h*g(i,j); end end
result=ifftshift(result); Gh1=ifft2(result); Gh2=uint8(real(Gh1)); subplot(2,2,4); imshow(Gh2) ; title('test5高通滤波图');
Word 资料