###introduction
前面在低通滤波文章中探讨了低通滤波,去除噪声。在此,使用高通滤波,提取图像边缘,进而锐化图像。
###highpass filter & sharpen image
与低通滤波器相反,高通滤波器允许图像高频部分通过,而高频部分证实图像的边缘信息(或者噪声)。
得到如下的图像
###sharpen image
将高通滤波器提取的高频部分加到原图上,从而强化图像的边缘信息,达到锐化图像的效果。
[外链图片转存失败(img-NAPyosss-1568454959130)(https://img-blog.csdn.net/20170517173349553?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc2lsZW5jZTIwMTU=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)]
锐化效果对比如下
###demo
%% 高通滤波,锐化图像
moon=imread('moon.tif');
[m,n]=size(moon);
I=im2double(moon);
figure;
subplot(1,2,1),imshow(moon),title('moon');
I_spectrum=fft2(I);
I_spectrum=fftshift(I_spectrum);
subplot(1,2,2),imshow(log(1+abs(I_spectrum)),[]),title('fourier spectrum of moon');
%% highpass filter
H=zeros(m,n);
centerx=m/2;
centery=n/2;
D0=60; % 可调节通带半径来控制通过的高频分量
for x=1:m
for y=1:n
H(x,y)=exp(-((x-centerx)^2+(y-centery)^2)/(2*D0^2)); %计算高斯滤波模板
end
end
H=1-H;
figure,imshow(H,[]),title('gaussian filter');
g1=H.*I_spectrum;% 高频部分图像,边缘图像
g2=g1+I_spectrum;
% 先反中心化,在转到空域图像
g3=ifftshift(g2);
I2=real(ifft2(g3));
figure,imshow(real(ifft2(ifftshift(g1))),[]),title('edge of moon');
figure;
subplot(1,2,1),imshow(log(1+abs(g2)),[]),title('fouier image sharpen by gaussian filter');
subplot(1,2,2),imshow(I2,[]),title('sharpen image');
参考文献:http://blog.csdn.net/zhoufan900428/article/details/17201293