How can I achieve a difference of gaussian high pass filter?

2.8k Views Asked by At

Seeing this answer, is this already an high-pass filter?

1

There are 1 best solutions below

0
On

You need to use the Fourier transform and zero the low frequencies. Something like this:

I = imread('cameraman.tif');

%fourier transform
If = fftshift(fft2(I));

%create the filter as a mask with circle of radius 50
rx = (1:size(I,1)) - size(I,1)/2;
ry = (1:size(I,2)) - size(I,2)/2;

[X,Y] = meshgrid(rx,ry);
R = sqrt(X.^2 + Y.^2);
Ifhw = If;
Ifhw(R < 25) = 0;  % we kill the low frequencies

%get the inversed fourier transform
Ihw = abs(ifft2(Iflw));


%use the abs log for visualization purposes
abslog = @(X)(log(abs(X)+1));

figure
subplot(2,2,3)
imshow(abslog(If), [])
title('fft in the original image')
subplot(2,2,4)
imshow(abslog(Iflw), [])
title('fft low pass filter image')

subplot(2,2,1)
imshow(I, [])
title('original image')
subplot(2,2,2)
imshow(Ilw, [])
title('low pass filter image')

enter image description here