低通滤波的matlab实现

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

四种低通滤波器:一、理想低通滤波器I=imread('bb.jpg');T=rgb2gray(I);figure(1);subplot(1,2,1),imshow(uint8(I));title('原图像');subplot(1,2,2),imshow(uint8(T));title('理想低通滤波所得图像');[f1,f2]=freqspace(size(T),'meshgrid');H=ones(size(T));r=sqrt(f1.^2+f2.^2);H(r0.1)=0;Y=fft2(double(T));Y=fftshift(Y);Ya=Y.*H;Ya=ifftshift(Ya);I=ifft2(Ya);figure(2);surf(H,'Facecolor','interp','Edgecolor','none','Facelighting','phong');title('频谱图');二、巴特沃斯低通滤波器I=imread('bb.jpg');T=rgb2gray(I);figure(1);subplot(1,2,1),imshow(uint8(I));title('原图像');subplot(1,2,2),imshow(uint8(T));title('巴特沃斯低通滤波所得图像');[f1,f2]=freqspace(size(T),'meshgrid');D=0.3;r=f1.^2+f2.^2;n=4;fori=1:size(T,1)forj=1:size(T,2)t=r(i,j)/(D*D);H(i,j)=1/(t^n+1);endendY=fft2(double(T));Y=fftshift(Y);Ya=Y.*H;Ya=ifftshift(Ya);I=real(ifft2(Ya));figure(2);surf(H,'Facecolor','interp','Edgecolor','none','Facelighting','phong');title('频谱图');三、梯形滤波器I=imread('bb.jpg');T=rgb2gray(I);figure(1);subplot(1,2,1),imshow(uint8(I));title('原图像');subplot(1,2,2),imshow(uint8(T));title('梯形低通滤波所得图像');[f1,f2]=freqspace(size(T),'meshgrid');D=100/size(I,1);D0=0.1;D1=0.4;r=sqrt(f1.^2+f2.^2);H=zeros(size(T));H(rD0)=1;fori=1:size(T,1)forj=1:size(I,2)ifr(i,j)=D0&r(i,j)=D1H(i,j)=(D1-r(i,j))/(D1-D0);endendendY=fft2(double(T));Y=fftshift(Y);Ya=Y.*H;Ya=ifftshift(Ya);I=real(ifft2(Ya));figure(2);surf(H,'Facecolor','interp','Edgecolor','none','Facelighting','phong');title('频谱图');四、高斯低通滤波器I=imread('bb.jpg');T=rgb2gray(I);figure(1);subplot(1,2,1),imshow(uint8(I));title('原图像');subplot(1,2,2),imshow(uint8(T));title('高斯低通滤波所得图像');[f1,f2]=freqspace(size(T),'meshgrid');D=100/size(I,1);r=f1.^2+f2.^2;H=ones(size(T));fori=1:size(T,1)forj=1:size(T,2)t=r(i,j)/(D*D);H(i,j)=exp(-t);endendY=fft2(double(T));Y=fftshift(Y);Ya=Y.*H;Ya=ifftshift(Ya);I=real(ifft2(Ya));figure(2);surf(H,'Facecolor','interp','Edgecolor','none','Facelighting','phong');title('频谱图');

1 / 7
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功