Skip to content
Related Articles

Related Articles

MATLAB – Ideal Lowpass Filter in Image Processing

View Discussion
Improve Article
Save Article
  • Last Updated : 22 Apr, 2020
View Discussion
Improve Article
Save Article

In the field of Image Processing, Ideal Lowpass Filter (ILPF) is used for image smoothing in the frequency domain. It removes high-frequency noise from a digital image and preserves low-frequency components.

It can be specified by the function-

 $H(u, v)=\left\{\begin{array}{ll}1 & D(u, v) \leq D_{0} \\ 0 & D(u, v)>D_{0}\end{array}\right.$

D_{0} is a positive constant. ILPF passes all the frequencies within a circle of radius D_{0} from the origin without attenuation and cuts off all the frequencies outside the circle.

This D_{0} is the transition point between H(u, v) = 1 and H(u, v) = 0, so this is termed as cutoff frequency.

D(u, v) is the Euclidean Distance from any point (u, v) to the origin of the frequency plane, i.e,
 $D(u, v)=\sqrt{\left(u^{2}+v^{2}\right)}$


Step 1: Input – Read an image
Step 2: Saving the size of the input image in pixels
Step 3: Get the Fourier Transform of the input_image
Step 4: Assign the Cut-off Frequency D_{0}
Step 5: Designing filter: Ideal Low Pass Filter
Step 6: Convolution between the Fourier Transformed input image and the filtering mask
Step 7: Take Inverse Fourier Transform of the convoluted image
Step 8: Display the resultant image as output

Implementation in MATLAB:

% MATLAB Code | Ideal Low Pass Filter
% Reading input image : input_image 
input_image = imread('[name of input image file].[file format]');
% Saving the size of the input_image in pixels-
% M : no of rows (height of the image)
% N : no of columns (width of the image)
[M, N] = size(input_image);
% Getting Fourier Transform of the input_image
% using MATLAB library function fft2 (2D fast fourier transform)  
FT_img = fft2(double(input_image));
% Assign Cut-off Frequency  
D0 = 30; % one can change this value accordingly
% Designing filter
u = 0:(M-1);
idx = find(u>M/2);
u(idx) = u(idx)-M;
v = 0:(N-1);
idy = find(v>N/2);
v(idy) = v(idy)-N;
% MATLAB library function meshgrid(v, u) returns
% 2D grid which contains the coordinates of vectors
% v and u. Matrix V with each row is a copy 
% of v, and matrix U with each column is a copy of u
[V, U] = meshgrid(v, u);
% Calculating Euclidean Distance
D = sqrt(U.^2+V.^2);
% Comparing with the cut-off frequency and 
% determining the filtering mask
H = double(D <= D0);
% Convolution between the Fourier Transformed
% image and the mask
G = H.*FT_img;
% Getting the resultant image by Inverse Fourier Transform
% of the convoluted image using MATLAB library function 
% ifft2 (2D inverse fast fourier transform)  
output_image = real(ifft2(double(G)));
% Displaying Input Image and Output Image
subplot(2, 1, 1), imshow(input_image),
subplot(2, 1, 2), imshow(output_image, [ ]);

Input Image –


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!