You are on page 1of 3

Experiment no 4:

Aim of the experiment:

To perform the ideal low pass filtering in the given image.

Theory: Low-pass filters are used for image smoothing and noise reduction.
Matlab code:
clc;
clear all;
close all;
im3=imread('Fig0333(a)(test_pattern_blurring_orig).tif');
im2=double(im3);
% im3=imresize(im1,[200 200]);
[m,n]=size(im2);
im1=[im2, zeros(m,(q-n));zeros((p-m),q)];
%% Multiply with (-1)^(x+y)
for x=1:p
for y=1:q
im(x,y)=(im1(x,y)*((-1)^(x+y)));
end
end
%% Compute DFT
Im=fft2(im);
u=p/2;v=q/2;
%% Distance from origin
D=input('Enter the distance from the origine::');
for i=1:p
for j=1:q
d(i,j)=(((i-u)^2)+((j-v)^2))^.5;
if d(i,j)<=D
H(i,j)=1;
else
H(i,j)=0;
end
end
end
imshow(im2,[]);
figure(2);
imshow(H);

IM=H.*Im;
img=real(ifft2(double(IM)));
for i=1:m
for j=1:n
img1(i,j)=(img(i,j).*((-1)^(i+j)));
end
end
figure(3);
imshow(img1,[]);

Results and Discussion:

Fig :

Original image

Fig: Filter transfer function

Fig: Filtered image

You might also like