资源描述:
《低通滤波的matlab实现.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、四种低通滤波器:一、理想低通滤波器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(r>0.1)=0;Y=fft2(double(T));Y=fft
2、shift(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(uint
3、8(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','
4、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);
5、D0=0.1;D1=0.4;r=sqrt(f1.^2+f2.^2);H=zeros(size(T));H(r=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',
6、'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.^
7、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('频谱图');