资源描述:
《各类滤波器的MATLAB程序清单.doc》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、各类滤波器的MATLAB程序一、理想低通滤波器IA=imread('lena.bmp');[f1,f2]=freqspace(size(IA),'meshgrid');Hd=ones(size(IA));r=sqrt(f1.^2+f2.^2);Hd(r>0.2)=0;Y=fft2(double(IA));Y=fftshift(Y);Ya=Y.*Hd;Ya=ifftshift(Ya);Ia=ifft2(Ya);figuresubplot(2,2,1),imshow(uint8(IA));subplot(2,2,2),imshow(uint8(Ia));figuresu
2、rf(Hd,'Facecolor','interp','Edgecolor','none','Facelighting','phong');二、理想高通滤波器IA=imread('lena.bmp');[f1,f2]=freqspace(size(IA),'meshgrid');Hd=ones(size(IA));r=sqrt(f1.^2+f2.^2);Hd(r<0.2)=0;Y=fft2(double(IA));Y=fftshift(Y);Ya=Y.*Hd;Ya=ifftshift(Ya);Ia=real(ifft2(Ya));figuresubplot(2,2,
3、1),imshow(uint8(IA));subplot(2,2,2),imshow(uint8(Ia));figuresurf(Hd,'Facecolor','interp','Edgecolor','none','Facelighting','phong');三、Butterworth低通滤波器IA=imread('lena.bmp');[f1,f2]=freqspace(size(IA),'meshgrid');D=0.3;r=f1.^2+f2.^2;n=4;fori=1:size(IA,1)forj=1:size(IA,2)t=r(i,j)/(D*D);Hd
4、(i,j)=1/(t^n+1);endendY=fft2(double(IA));Y=fftshift(Y);Ya=Y.*Hd;Ya=ifftshift(Ya);Ia=real(ifft2(Ya));figuresubplot(2,2,1),imshow(uint8(IA));subplot(2,2,2),imshow(uint8(Ia));figuresurf(Hd,'Facecolor','interp','Edgecolor','none','Facelighting','phong');三、Butterworth高通滤波器IA=imread('lena.bm
5、p');[f1,f2]=freqspace(size(IA),'meshgrid');D=0.3;r=f1.^2+f2.^2;n=4;fori=1:size(IA,1)forj=1:size(IA,2)t=(D*D)/r(i,j);Hd(i,j)=1/(t^n+1);endendY=fft2(double(IA));Y=fftshift(Y);Ya=Y.*Hd;Ya=ifftshift(Ya);Ia=real(ifft2(Ya));figuresubplot(2,2,1),imshow(uint8(IA));subplot(2,2,2),imshow(uint8(I
6、a));figuresurf(Hd,'Facecolor','interp','Edgecolor','none','Facelighting','phong');三、高斯低通滤波器IA=imread('lena.bmp');IB=imread('babarra.bmp');[f1,f2]=freqspace(size(IA),'meshgrid');D=100/size(IA,1);r=f1.^2+f2.^2;Hd=ones(size(IA));fori=1:size(IA,1)forj=1:size(IA,2)t=r(i,j)/(D*D);Hd(i,j)=exp
7、(-t);endendY=fft2(double(IA));Y=fftshift(Y);Ya=Y.*Hd;Ya=ifftshift(Ya);Ia=real(ifft2(Ya));figuresubplot(2,2,1),imshow(uint8(IA));subplot(2,2,2),imshow(uint8(Ia));figuresurf(Hd,'Facecolor','interp','Edgecolor','none','Facelighting','phong');三、高斯高通滤波器IA=imread('lena.bmp');IB=imread('bab