matlab 图像 高通滤波器,基于matlab数字图像处理之高通滤波器

  • Post author:
  • Post category:其他


实践二: 理想高通滤波器、Butterworth高通滤波器、高斯高通滤波器

2.1.1 理想高通滤波器实践代码:

I=imread(‘girl.bmp’);

subplot(221),imshow(I);

title(‘原图像’);

s=fftshift(fft2(I));

subplot(223),

imshow(abs(s),[]);

title(‘图像傅里叶变换所得频谱’);

subplot(224),

imshow(log(abs(s)),[]);

title(‘图像傅里叶变换取对数所得频谱’);

[a,b]=size(s);

a0=round(a/2);

b0=round(b/2);

d=10;

p=0.2;q=0.5;

for i=1:a

for j=1:b

distance=sqrt((i-a0)^2+(j-b0)^2);

if distance<=d h=0;

else h=1;

end;

s(i,j)=(p+q*h)*s(i,j);

end;

end;

s=uint8(real(ifft2(ifftshift(s))));

subplot(222),

imshow(s);title(‘高通滤波所得图像’);

I=imread(‘girl.bmp’);

[f1,f2]=freqspace(size(I),’meshgrid’);

Hd=ones(size(I));

r=sqrt(f1.^2+f2.^2);

Hd(r<0.2)=0;

figure

surf(Hd,’Facecolor’,’interp’,’Edgecolor’,’none’,’Facelighting’,’phong’); % 画三维曲面(色)图

2.1.2 理想高通滤波器实践结果截图: