Implementation and comparison of Low pass filters in Frequency domain

Preview:

Citation preview

IMPLEMENTATION AND COMPARISON OF LOW PASS FILTERS IN FREQUENCY DOMAIN

PRESENTERS:ZARA TARIQ 1573119SAPNA KUMARI 1573131

AGENDA Introduction Low Pass Filters Comparison Between Types of LPF Implementation of LPF Demonstration of Implementation in MATLAB

INTRODUCTION - FILTERS IN FREQENCY DOMAINImage filtering in frequency domain can be grouped in three, depending on the effects:

2. High pass filters (sharpening filters)3. Notch Filters (band-stop filters)

1. Low pass filters (smoothing filters)

LOW PASS FILTERS (LPF)Why Is It Used?: Creates a blurred (or smoothed) image Reduces the high frequencies and leave the low frequencies of the

Fourier transformation to relatively unchanged

How Does It Works? Low frequency components correspond to slow changes in images Used to remove high spatial frequency noise from a digital image The low-pass filters usually employ moving window operator which

affects one pixel of the image at a time, changing its value by some function of a local region (window) of pixels.

The operator moves over the image to affect all the pixels in the image.

COMPARISON BETWEEN TYPES OF LPFIdeal LPF: Cuts off all components that are greater than distance Do from center

Butterworth LPF: The transfer function of a Butterworth low pass filter of order n with cut-off

frequency at distance D0 from the origin No clear cut-off between passed & filtered frequencies

Gaussian LPF: Does not have sharp discontinuity Transfer function is smooth, like Butterworth filter

nDvuDvuH 2

0 ]/),([11),(

Ideal LPF

Butterworth LPF

Gaussian LPF

IMPLEMENTATION OF ALL TYPES OF LPF

EXAMPLE 1 - NOISY BIRD IMAGE

Original Image of noisy miner bathing image

Result of Ideal Low Pass Filter

Result of Butterworth Low Pass Filter

Result of Gaussian Low Pass Filter

Result of Butterworth Low Pass Filter Result of Gaussian Low Pass Filter

Original Image Result of Ideal Low Pass Filter

Fourier Spectrum of Bird Image

Result of Butterworth Low Pass Filter Result of Gaussian Low Pass Filter

Original Image Result of Ideal Low Pass Filter

Spectrum of Bird Image

IMPLEMENTATION OF ALL TYPES OF LPF

EXAMPLE 2 - SIBERIAN HUSKY FOX IMAGE

Original Image of Siberian Husky Fox image

Result of Ideal Low Pass Filter

Result of Butterworth Low Pass Filter

Result of Gaussian Low Pass Filter

Result of Butterworth Low Pass Filter Result of Gaussian Low Pass Filter

Original Image Result of Ideal Low Pass Filter

Fourier Spectrum of Siberian Husky Fox Image

Result of Butterworth Low Pass Filter Result of Gaussian Low Pass Filter

Original Image Result of Ideal Low Pass Filter

Spectrum of Siberian Husky Fox Image

IMPLEMENTATION OF ALL TYPES OF LPF

EXAMPLE 3 - ROSE FLOWER IMAGE

Original Image of Rose Flower image

Result of Ideal Low Pass Filter

Result of Butterworth Low Pass Filter

Result of Gaussian Low Pass Filter

Result of Butterworth Low Pass Filter Result of Gaussian Low Pass Filter

Original Image Result of Ideal Low Pass Filter

Fourier Spectrum of Rose Flower Image

Result of Butterworth Low Pass Filter Result of Gaussian Low Pass Filter

Original Image Result of Ideal Low Pass Filter

Spectrum of Rose Flower Image

IMPLEMENTATION OF ALL TYPES OF LPF

EXAMPLE 4 - CAT IMAGE

Original Image of Wild Cat image

Result of Ideal Low Pass Filter

Result of Butterworth Low Pass Filter

Result of Gaussian Low Pass Filter

Result of Butterworth Low Pass Filter Result of Gaussian Low Pass Filter

Original Image Result of Ideal Low Pass Filter

Fourier Spectrum of Wild Cat Image

Result of Butterworth Low Pass Filter Result of Gaussian Low Pass Filter

Original Image Result of Ideal Low Pass Filter

Spectrum of Wild Cat Image

IMPLEMENTATION OF ALL TYPES OF LPF

EXAMPLE 5 - MOVIE POSTER IMAGE

Original Image of Movie Poster image

Result of Ideal Low Pass Filter

Result of Butterworth Low Pass Filter

Result of Gaussian Low Pass Filter

Result of Butterworth Low Pass Filter Result of Gaussian Low Pass Filter

Original Image Result of Ideal Low Pass Filter

Fourier Spectrum of Movie Poster Image

Result of Butterworth Low Pass Filter Result of Gaussian Low Pass Filter

Original Image Result of Ideal Low Pass Filter

Spectrum of Movie Poster Image

DEMONSTRATION OF IMPLEMENTATION IN

MATLAB

APPENDIX – MATLAB CODELow Pass Filter Function

H = lpfilter(type, M, N, D0, n)

[U, V] = dftuv(M, N);

D = sqrt(U.^2 + V.^2);

switch type

case 'ideal'

H = double(D <=D0);

case 'btw'

if nargin == 4

n = 1;

end

H = 1./(1 + (D./D0).^(2*n));

case 'gaussian'

H = exp(-(D.^2)./(2*(D0^2)));

otherwise

error('Unknown filter type.')

end

APPENDIX – MATLAB CODEIdeal Low Pass Filter

fox=imread('fox.jpg');

fox=rgb2gray(fox);

imshow(fox)

PQ = paddedsize(size(fox));

D0 = 0.05*PQ(1);

H = lpfilter('ideal', PQ(1), PQ(2), D0);

F=fft2(double(fox),size(H,1),size(H,2));

LPFS_fox = H.*F;

LPF_fox=real(ifft2(LPFS_fox));

LPF_fox=LPF_fox(1:size(fox,1), 1:size(fox,2));

figure, imshow(LPF_fox, [])

Fc=fftshift(F);

Fcf=fftshift(LPFS_fox);

S1=log(1+abs(Fc));

S2=log(1+abs(Fcf));

figure, imshow(S1,[])

figure, imshow(S2,[])

APPENDIX – MATLAB CODEButterworth Low Pass Filter

fox=imread('fox.jpg');fox=rgb2gray(fox);imshow(fox)PQ = paddedsize(size(fox));

D0 = 0.05*PQ(1);H = lpfilter('btw', PQ(1), PQ(2), D0);

F=fft2(double(fox),size(H,1),size(H,2));

LPFS_fox = H.*F;

LPF_fox=real(ifft2(LPFS_fox));

LPF_fox=LPF_fox(1:size(fox,1), 1:size(fox,2));figure, imshow(LPF_fox, [])

Fc=fftshift(F);Fcf=fftshift(LPFS_fox);S1=log(1+abs(Fc));S2=log(1+abs(Fcf));figure, imshow(S1,[])figure, imshow(S2,[])

APPENDIX – MATLAB CODEGaussian Low Pass Filter

fox=imread('fox.jpg');fox=rgb2gray(fox);imshow(fox)PQ = paddedsize(size(fox));D0 = 0.05*PQ(1);H = lpfilter('gaussian', PQ(1), PQ(2), D0);F=fft2(double(fox),size(H,1),size(H,2));LPFS_fox = H.*F;LPF_fox=real(ifft2(LPFS_fox));LPF_fox=LPF_fox(1:size(fox,1), 1:size(fox,2));figure, imshow(LPF_fox, [])Fc=fftshift(F);Fcf=fftshift(LPFS_fox);S1=log(1+abs(Fc));S2=log(1+abs(Fcf));figure, imshow(S1,[])figure, imshow(S2,[])

APPENDIX – MATLAB CODEMeshgrid Frequency Matrices.

function [U, V] = dftuv(M, N)

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);

APPENDIX – MATLAB CODEPadding for Fourier Transform

function PQ = paddedsize(AB, CD, PARAM)

if nargin == 1

PQ = 2*AB;

elseif nargin == 2 & ~ischar(CD)

PQ = AB + CD - 1;

PQ = 2 * ceil(PQ / 2);

elseif nargin == 2

m = max(AB);

P = 2^nextpow2(2*m);

PQ = [P, P];

elseif nargin == 3

m = max([AB CD]);

P = 2^nextpow2(2*m);

PQ = [P, P];

else

error('Wrong number of inputs.')

end

THANK YOU!

Recommended