0% found this document useful (0 votes)
10 views13 pages

Frequency Enhancement-1

The document discusses image enhancement techniques in the frequency domain, focusing on Fourier transforms and filtering methods. It explains the process of frequency domain filtering, including low-pass and high-pass filters, and provides MATLAB code for implementing these filters. The document also highlights the importance of the cut-off frequency and the separability of filter transfer functions in image processing.

Uploaded by

fabian mbigili
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views13 pages

Frequency Enhancement-1

The document discusses image enhancement techniques in the frequency domain, focusing on Fourier transforms and filtering methods. It explains the process of frequency domain filtering, including low-pass and high-pass filters, and provides MATLAB code for implementing these filters. The document also highlights the importance of the cut-off frequency and the separability of filter transfer functions in image processing.

Uploaded by

fabian mbigili
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 13

IMAGE ENHANCEMENT IN THE FREQUENCY

Frequency refersDOMAIN
to the rate of repetition of some periodic event.
In image processing, spatial frequency refers to the variation of image brightness
with its position in space.
A varying signal can be transformed into a series of simple periodic variations.
The Fourier transform decomposes a signal into a set of sine waves of different
characteristics like frequency and phase.
If we compute the Fourier Transform of an image, and then immediately inverse
transform the result, we can regain the same image because a Fourier transform is
perfectly reversible.
IMAGE ENHANCEMENT IN THE FREQUENCY
DOMAIN
On the other hand, if we multiply each element of the Fourier
coefficient by a suitably chosen weighting function then we can
accentuate certain frequency components and attenuate others.
The corresponding changes in the spatial form can be seen after an
inverse transform is computed.
This selective enhancement or suppression of frequency components
is termed Fourier filtering or frequency domain filtering.
IMAGE ENHANCEMENT IN THE
FREQUENCY DOMAIN
 The spatial representation of image data describes the adjacency relationship
between the pixels.
 On the other hand, the frequency domain representation clusters the image
data according to their frequency distribution.
 In frequency domain filtering, the image data is dissected into various spectral
bands, where each band depicts a specific range of details within the image.
 The process of selective frequency inclusion or exclusion is termed frequency
domain filtering.
 It is possible to perform filtering in the frequency domain by specifying the
frequencies that should be kept and the frequencies that should be discarded.
 Spatial domain filtering is accomplished by convolving the image with a filter
kernel.
IMAGE ENHANCEMENT IN THE FREQUENCY DOMAIN

Convolution in spatial domain = Multiplication in the frequency domain

If filtering in spatial domain is done by convolving the input image f(m, n) with the
filter kernel h(m, n),

Filtering in spatial domain  f m, n   h m, n 

In the frequency domain, filtering corresponds to the multiplication of the image


spectrum by the Fourier transform of the filter kernel, which is referred to as the
frequency response of the filter

Filtering in the frequency domain F k , l  h k , l 


IMAGE ENHANCEMENT IN THE
FREQUENCY DOMAIN
Filtering in the frequency domain F k , l  h k , l 
 Here, F(k, l) is the spectrum of the input image and H(k, l) is the spectrum of the
filter kernel.
 Thus, frequency domain filtering is accomplished by taking the Fourier transform
of the image and the Fourier transform of the kernel, multiplying the two Fourier
transforms, and taking the inverse Fourier transform of the result.
 The multiplication of the Fourier transforms need to be carried out point by point.
 This point-by-point multiplication requires that the Fourier transforms of the
image and the kernel themselves have the same dimensions.
 As convolution kernels are commonly much smaller than the images they are
used to filter, it is required to zero pad out the kernel to the size of the image to
accomplish this process.
Low-pass Filtering in Frequency Domain
The low-pass filter mask can be broadly classified into two types:
(i) non-separable filter mask, and
(ii) separable filter mask.
(i)Non-separable Filter Transfer Function
The non-separable filter transfer function is given by
1, for k 2  l 2  D0
H k , l  
0, otherwise
Here, D0 is the cut-off frequency of the low-pass filter.
 The cut-off frequency determines the amount of frequency
components passed by the filter.
 The smaller the value of D0, the greater the number of image
components eliminated by the filter.
 The value of D0 is chosen in such a way that the components of
Low-pass Filtering in Frequency Domain
(ii) Separable Low-pass Filter Transfer Function
The expression for a separable low-pass filter transfer function is given below:
1, for k Dk and l Dl
H k , l  
0, otherwise

Butterworth Low-pass Filter The transfer function of a two-dimensional


Butterworth low-pass filter is given by
1
H k , l   2n
 k l
2 2 
1  
 D0 

In the above expression, n refers to the filter order and D0


represents the cut-off frequency
%This code is used to Butterworth lowpass fi lter
clc clc;
clear all clc
close all clear all
[a,b]=freqspace(256,'meshgrid'); close all
H=zeros(256,256); a=imread('noise Image.png');
d=abs(a)<0.5&abs(b)<0.5; im=rgb2gray(a);
fc=40;%Cutoff frequency
H(d)=1;
n=4;
imshow(H) [co,ro] = size(im);
title('separable LPF transfer Function') cx = round(co/2); % fi nd the centre of the image
cy = round (ro/2);
imf=fftshift(fft2(im));
separable LPF transfer Function
H=zeros(co,ro);
for i = 1 : co
for j =1 : ro
d = (i-cx).^2 + (j-cy).^ 2;
H(i,j) = 1/(1+((d/fc/fc).^(2*n)));
end
end
outf = imf.*H;
%outf = imf;
out = abs(ifft2(outf));

imshow(im),title('Original Image'),
figure,imshow(uint8(abs(imf))),title('transformed Image')
figure,imshow(uint8(out)),title('Lowpass Filterd Image')
High-pass Filter in Frequency
Domain
The low-pass filters and high-pass filters are
complementary to each other.
The 2D ideal0, high-pass
if D k , l  Dfilter is one whose transfer function
H k ,the
satisfies l  relation 0

 1, if D k , l   D
0

where D0 is the cut-off distance measured from the origin of the


frequency plane. The cross-section of an ideal high-pass filter
Butterworth High-pass Filter
The transfer function of a two-
dimensional ButterworthHfilter is given
1 by
k,l    2n
 D0 
1 
2 2 
 k l 
Cross-section of an
Where n is the order of the filter, D0 is the ideal high-pass filter
cut-off frequency.
Problem Write a MATLAB program that performs a two-dimensional Butterworth high-
pass filter of the given image for two different cut-off frequencies.
%This code is used to Butterworth highpass fi lter
close all;
clear all;
clc;
a=imread('noise Image.png');
im=rgb2gray(a);
fc=40;
n=1;
[co,ro] = size(im);
cx = round(co/2); % fi nd the centre of the image
cy = round (ro/2);
imf=fftshift(fft2(im));
H=zeros(co,ro);
for i = 1 : co
for j =1 : ro
d = (i-cx).^2 + (j-cy).^ 2;
if d ~= 0
H(i,j) = 1/(1+((fc*fc/d).^(2*n)));
end
end
end
outf = imf.*H;
out = abs(ifft2(outf));
imshow(im),title('Original Image'),figure,imshow(uint8(out)),title('Highpass Filterd
Image')
Low-pass and High-pass Gaussian Filter.
The Gaussian filter is popular for the absence of ringing and noise leakage artifacts.
The transfer function of a two-dimensional Gaussian low-pass filter is given by


 m2  n2 
1
h m, n   e 2 2
2 2

The transfer function is separable which can be written as

m2 n2
1  1 
h m, n  
2
2 2
e 2
 e
2 2 2 2
Low-pass and High-pass Gaussian Filter.
m2 n2
1  1 
h m, n  
2
2 2
e 2
 e
2 2
2 2

The above equation implies that the Gaussian filter can


be implemented by applying two 1D Gaussian filters.
The MATLAB code to implement a Gaussian low-pass filter
and a high-pass filter
%This code is used to gaussian highpass fi lter
Low-pass and High-pass Gaussian Filter. close all;
%This code is used to gaussian lowpass filter clear all;
clc clc;
clear all c=imread('jordan Hosseaa.png');
close all im=rgb2gray(c);
c=imread('jordan Hosseaa.png'); fc=100;
im=rgb2gray(c); imf = fftshift(fft2(im));
fc=10; [co,ro]=size(im);
imf = fftshift(fft2(im)); cx = round(co/2); % fi nd the centre of the image
[co,ro]=size(im); cy = round (ro/2);
cx = round(co/2); % fi nd the centre of the image H = zeros(co,ro);
cy = round (ro/2); for i = 1 : co
H = zeros(co,ro); for j = 1 : ro
for i = 1 : co d = (i-cx).^2 + (j-cy).^2;
for j = 1 : ro H(i,j) = exp(-d/2/fc/fc);
d = (i-cx).^2 + (j-cy).^2; end
H(i,j) = exp(-d/2/fc/fc); end
end % H = gaussian_fi lter(co,ro, fc);
end H = 1-H;
outf= imf.*H; out = zeros(co,ro);
out=abs(ifft2(outf)); outf= imf.*H;
imshow(im),title('Original out=abs(ifft2(outf));
Image'),figure,imshow(uint8(out)), imshow(im),title('Original
title('GaussianLowpass Filtered Image') Image'),figure,imshow((out)),title('Filterd Image')
figure,imshow(H),title('2D View of H'),figure,surf(H), figure,imshow(H),title('2D View of H'),figure,surf(H),
title('3D View of H') title('3D View of H')

You might also like