From this answer, I know how to create a High-pass Butterworth filter.
From this video, I know that, lowpasskernel = 1 - highpasskernel
.
So, I created the following Low-pass Butterworth Filter,
function [out, kernel] = butterworth_lp(I, Dl, n)
height = size(I, 1);
width = size(I, 2);
[u, v] = meshgrid(-floor(width/2):floor(width/2)-1,-floor(height/2):floor(height/2)-1);
% lp_kernel = 1 - hp_kernel
kernel = 1 - butter_hp_kernel(u, v, Dl, n);
% fft the image
I_fft_shifted = fftshift(fft2(double(I)));
% apply lowpass filter
I_fft_shift_filtered = I_fft_shifted .* kernel;
% inverse FFT, get real components
out = real(ifft2(ifftshift(I_fft_shift_filtered)));
% normalize and cast
out = (out - min(out(:))) / (max(out(:)) - min(out(:)));
out = uint8(255*out);
function k = butter_hp_kernel(u, v, Dh, n)
uv = u.^2+v.^2;
D = sqrt(uv);
frac = Dh./D;
p = 2*n;
denom = frac.^p;
k = 1./denom;
Output
This isn't a low-pass filter output.
So, what is the issue with my code?
Okay. I have solved the problem by following the following formula (Page #8/48),
Output
Source Code
butter_lp_kernel.m
ifftshow.m
butterworth_lpf.m