You are on page 1of 5

Code

clc;
clear all;
close all;
input_image = rgb2gray(imread('saturn.jpg'));
[M, N] = size(input_image);
FT_img = fft2(double(input_image));
n = 2; n1=5; n2=10;
D0 = 20;
% Designing filter
u = 0:(M-1);
v = 0:(N-1);
idx = find(u > M/2);
u(idx) = u(idx) - M;
idy = find(v > N/2);
v(idy) = v(idy) - N;
[V, U] = meshgrid(v, u);
% Calculating Euclidean Distance
D = sqrt(U.^2 + V.^2);
% determining the filtering mask
H = 1./(1 + (D./D0).^(2*n));
H1 = 1./(1 + (D./D0).^(2*n1));
H2 = 1./(1 + (D./D0).^(2*n2));
G = H.*FT_img;
G1 = H1.*FT_img;
G2= H2.*FT_img;
output_image = real(ifft2(double(G)));
output_image1 = real(ifft2(double(G1)));
output_image2 = real(ifft2(double(G2)));
% Displaying Input Image and Output Image
subplot(1, 4, 1), imshow(input_image);
title('original image');
subplot(1, 4, 2), imshow(output_image, [ ]);
title('filtered image for order 2')
subplot(1, 4, 3), imshow(output_image1, [ ]);
title('filtered image for order 5')
subplot(1, 4, 4), imshow(output_image2, [ ]);
title('filtered image for order 10')
Simulations
Output

Result/Conclusion:
Hence, we have smoothened the given image with butterworth low pass filter
using three order values 2, 5 and 10. As the order increases, the smoothening
action also increased.
Note: A Butterworth filter of order 1 has no ringing artifact. Generally ringing is
imperceptible in filters of order 2. But it can become a significant factor in
filters of a higher order. For a specific cut-off frequency, ringing increases with
an increase in the filter order.

You might also like