0% found this document useful (0 votes)
31 views53 pages

Lec 4 Frequency Domain Filtering-I

Uploaded by

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

Lec 4 Frequency Domain Filtering-I

Uploaded by

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

Image Processing

Discrete Fourier Transform


Ioannis Ivrissimtzis
Overview

Discrete Fourier Transform (DFT)

The spectrum of DFT

The convolution theorem

Filtering in the frequency domain


Discrete Fourier Transform

The Discrete Fourier Transform (DFT) is described by the matrix

where
2D DFT
The 2D DFT is given by Z = T · A · T', where T is the matrix of the
1D DFT.

Using matrix notation we write in a single equation the computations


for the whole transformation.

Instead, we could write an equation giving a single element of the


transform:
n 1 n 1
Z (u, v)    A( x , y ) e  2i ( ux  vy ) / n

x 0 y 0
2D DFT

The matrix T is complex, that is, its elements are complex numbers, not
real numbers.

The same is generally true for the transform Z of an image. Its elements
have a real part R(u,v) and an imaginary part I(u,v) :

Z (u, v)  R(u, v)  i  I (u, v)

So, generally, Z is not an image.


2D DFT
We can go around this problem by using real functions of the transform,
that is, the spectrum:

Z (u, v)  R 2 (u, v)  I 2 (u, v)

and the phase angle:


 I (u , v) 
 (u, v)  tan 
1

 R (u , v ) 

Usually, we visualize the DFT by visualizing its spectrum.


Overview

Discrete Fourier Transform (DFT)

The spectrum of the DFT

The convolution theorem

Filtering in the frequency domain


The spectrum of DFT

Log enhanced
Original image
Fourier transform
The spectrum of DFT

Original image Fourier transform

The large coefficients concentrate on the four corners of the transform.


Low and high frequencies

Why are the low frequencies at the four corners of the transform?

As an example, we consider the DFT matrix of order 7.

We will visualize the elements of the matrix, which are complex


numbers, as points on the plane.

We will visualize the rows of the matrix, which give the basis of the
transform, by connecting these points with edges.
Low and high frequencies
The DFT matrix for n=7:

where
Low and high frequencies
A complex number can be described by the pair (r,φ) where r is its
distance from the origin and φ its angle with the x-axis.

If z1 = (r1 , φ1) and z2 = (r2 , φ2) are two complex numbers then:

z1 · z2 = (r1 · r2 , φ1 + φ2)

Here we have ω = (1 , 2π / 7), giving

ωn = (1 , 2πn / 7)
Low and high frequencies

The visualisation of the first row of the matrix (first element of the new
basis) is trivial as there is only one point.
Low and high frequencies

Visualisation of the second row.


Low and high frequencies

Visualisation of the second row.


Low and high frequencies

Visualisation of the second row.


Low and high frequencies

Visualisation of the second row.


Low and high frequencies

Visualisation of the second row. We made one full anticlockwise circle.


Low and high frequencies

Visualisation of the third row.


Low and high frequencies

Visualisation of the third row.


Low and high frequencies

Visualisation of the third row.


Low and high frequencies

Visualisation of the third row.


Low and high frequencies

Visualisation of the third row.


Low and high frequencies

Visualisation of the third row. We made two full anticlockwise circles.


Low and high frequencies

Visualisation of the fourth row.


Low and high frequencies

Visualisation of the fourth row.


Low and high frequencies

Visualisation of the fourth row.


Low and high frequencies

Visualisation of the fourth row.


Low and high frequencies

Visualisation of the fourth row. We made three full anticlockwise circles.


Low and high frequencies

Visualisation of the last row.


Low and high frequencies

Visualisation of the last row.


Low and high frequencies

Visualisation of the last row.


Low and high frequencies

Visualisation of the last row.


Low and high frequencies

The visualisation of the last row. We made one full clockwise circle.
Low and high frequencies

Frequencies of the 1D DFT

Top rows Low frequencies

High frequencies

Bottom rows Low frequencies


Low and high frequencies

Frequencies of the 2D DFT

High
Low

Low
Low Low Low

High High

Low Low Low


Spectrum shift
A doubly periodic image has a doubly periodic discrete Fourier
transform.
Spectrum shift
We shift the origin of the transform to the centre.

Now the low frequency information is in the centre of the DFT.


Spectrum shift

Shifted
Log enhanced
Original image log enhanced
transform
transform
Overview

Discrete Fourier Transform (DFT)

The spectrum of DFT

The convolution theorem

Filtering in the frequency domain


The convolution theorem

Let f be an image and h be a filter. If necessary, we assume that


any of them or both are extended with 0’s beyond their boundary,
so they have the same dimension.

Let F and H be the corresponding DFT transforms.


The convolution theorem

The convolution theorem states that:

f ( x, y )  h( x, y )  H (u, v)  F (u, v)

The symbol  on the left hand side denotes convolution. That is,
the usual linear filtering of the image f by the filter h, as described
earlier in the course.

The multiplication  in the right hand side is component-wise (not


matrix multiplication).
Overview

Discrete Fourier Transform (DFT)

The spectrum of DFT

The convolution theorem

Filtering in the frequency domain


Frequency domain filters

By finding the DFT of a spatial linear filter we can create an equivalent


frequency domain filter.

By the convolution theorem, filtering in the frequency domain requires


component-wise multiplication instead of matrix convolution.
Frequency domain filters

If a spatial filter is large, instead of matrix convolution, it is


computationally more efficient to:

Find the DFT of the image and the filter

Do the filtering in the frequency domain

Inverse the DFT to go back to the spatial domain.


Ideal lowpass filter
We can also directly design filters for the frequency domain.

Assume that the frequency domain has been shifted and the low
frequencies are at the centre of the transform.

Consider the filter H with values 1 near the centre of the image and
values 0 further from the centre.
Ideal lowpass filter

This filter retains the low frequencies and eliminates the high
frequencies.

Remember that the filter H(u,v) acts on the transform F(u,v) by


component-wise multiplication H (u, v)  F (u, v)
Ideal lowpass filters

This filter is called the ideal lowpass filter.

The exact definition of the ideal lowpass filter is

1 if d (u, v)  d 0
H (u, v)  
0 if d (u, v)  d 0

where d(u,v) is the distance of (u,v) from the centre of the filter and d0 is
a positive number (the radius of the white circle).
Lowpass filters
The ideal lowpass filter is discontinuous. Frequencies just inside the
white circle are preserved, while neighbouring frequencies just outside
the white circle are completely eliminated.

The Butterworth lowpass filter of order n addresses this problem. It is


described by the equation:
1
H (u , v) 
1  (d (u , v) / d 0 ) 2 n

The Gaussian lowpass filter is also smooth:


 d 2 ( u ,v ) / d 0
H (u, v)  e
Ideal highpass filters
In some applications we are interested in the details of the image. For
example, we might want to enhance a blurred image.

The details of the image correspond to the high frequencies of the DFT
and can be extracted by a highpass filter.

We can construct a highpass filter from a lowpass:

H highpass  1  H lowpass
Highpass filters

The ideal highpass filter


Other ideal filters
The ideal bandpass filter retains the frequencies inside a given band
and eliminates all the other.

The ideal bandreject filter eliminates the frequencies inside a given


band and retains all the other.

Ideal bandpass filter Ideal bandreject filter


Example
A lowpass filter for the DFT frequency domain.

Shifted DFT

Lowpass filter Inverse DFT

You might also like