0% found this document useful (0 votes)
71 views21 pages

Image Enhance Frequency Domain Student

The document discusses the Fourier transform and its applications in image processing. It introduces the Fourier transform as decomposing a function into sine and cosine components. The Fourier transform of an image represents the image in the frequency domain. Low frequencies correspond to slowly varying regions while higher frequencies correspond to edges. The Fourier transform allows for filtering images by modifying frequency components.

Uploaded by

Shrijeet Jain
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)
71 views21 pages

Image Enhance Frequency Domain Student

The document discusses the Fourier transform and its applications in image processing. It introduces the Fourier transform as decomposing a function into sine and cosine components. The Fourier transform of an image represents the image in the frequency domain. Low frequencies correspond to slowly varying regions while higher frequencies correspond to edges. The Fourier transform allows for filtering images by modifying frequency components.

Uploaded by

Shrijeet Jain
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/ 21

Background

• Any periodic function can be expressed as the sum of


sines and cosines of different frequencies, each
Image multiplied by a different coefficient.
Enhancement in – We called this sum a Fourier series.
the Frequency
Domain • Even function that are not periodic can be expressed
as the integral of sines and cosines multiplied by a
weighting function.
– This formation is the Fourier transform.

Example 1
Fourier transform
basis functions

Approximating a
square wave as the
sum of sine waves

1
Fourier Transform in the
Example 2 Frequency Domain

• Fourier transform F(u) of f(x) is defined as



F (u)   f ( x)e j 2uxdx


• The inverse Fourier Transform is



time domain frequency domain time domain frequency domain f ( x)   F (u)e j 2uxdu


• DFT for Discrete function f(x), x=0,1,..M-1


M 1
1
F (u ) 
M
 f ( x )e
x 0
 j 2ux / M
for u=0,1,..M-1
• Inverse DFT
M 1
f ( x)   F (u )e j 2ux / M
u 0
time domain frequency domain time domain frequency domain

Complex Spectra
• Euler’s formula: e j  cos   j sin
• In general, the components of Fourier transform are complex
1 M 1 quantities in the following form:
F (u )   f ( x )[cos 2ux / M  j sin 2ux / M ]
M x 0 F(u) = R(u) + jI(u)
for u  0,1, 2,..., M  1
and can be written as
• Each term of the Fourier transform is composed
of the sum of all values of the function f(x). F(u) = |F(u)|ej(u)
– M2 summations and multiplications • The spectra is usually represented by the amplitude of a specific
frequency
– The values of f(x) are multiplied by sines and cosines • Amplitude or spectrum of Fourier transform
of various frequencies.
– The domain (values of u) over which the values of
|F(u)| = (R2(u)+I2(u))1/2
F(u) range is appropriately called the frequency
domain, because u determines the frequency of the
components of the transform.
– Each of the M terms of F(u) is called a frequency
component of the transform.

2
Periodicity of 1-D DFT 2-D Discrete Fourier Transform
M 1
1
From DFT: F (u ) 
M
 f ( x )e
x 0
 j 2ux / M
For an image of size MxN pixels
F(u) = F(u+kM) We display only in this range
2-D DFT
M 1 N 1
1
F ( u, v ) 
MN
 f ( x, y )e
x 0 y 0
 j 2 ( ux / M  vy / N )

u = frequency in x direction, u = 0 ,…, M-1


v = frequency in y direction, v = 0 ,…, N-1
-M 0 M 2M

DFT repeats itself every M points (Period = M)


2-D IDFT
M 1 N 1
u is the number of complete cycles of the sinusoid that fits into
the width M of the image. These form the basis functions of the
f ( x, y )   F (u, v)e
u 0 v 0
j 2 ( ux / M  vy / N )

x = 0 ,…, M-1
frequency domain representation and the weights for each sine y = 0 ,…, N-1
and cosine function are known as Fourier coefficients.

2-D Discrete Fourier Transform


Filtering in the Frequency Domain
F(u,v) can be written as: • What is the “frequency” of an image?
F (u, v)  R(u, v)  jI (u, v) or F (u, v )  F (u, v ) e j ( u ,v ) – Since frequency is directly related rate of
change, it is not difficult intuitively to associate
F (u, v )  R(u, v )2  I (u, v )2 magnitude frequencies with pattern of intensity variations
where
in an image.
 I ( u, v )  • The low frequencies correspond to the slowly
 (u, v )  tan 1   phase varying components of an image.
 R ( u, v )  • The higher frequencies begin to correspond to
faster and faster gray level changes in the image.
For the purpose of viewing, we usually display only the – such as edges.
magnitude part of F(u,v)

3
• The term Spatial frequency is used to describe the rate of
change of pixel intensity of an image in space.
• It can be visualized using the line profile of the pixels in a row
or a column
• The profile is a plot of the intensity of the pixels in a row or a
column
• X-axis – Distance of the pixels from the origin
• Y-axis – Grey Value (0-255)
• Intensity profile is a collection of either sinusoidal signals such
as sine, cosine, and harmonic signals, or non-sinusoidal signals
such as square waves
• Intensity change can be expressed as
I = sin(ux)
u-spatial frequency
sin(ux) ranges from -1 to +1

4
Fourier Examples Discrete Fourier Transform -
Raw Image Fourier Amplitude
Magnitude
Sinusoid, DC term + side lobes
higher frequency wide spacing

Sinusoid, DC term+ side lobes Original image Fourier transform Logarithmic operator applied
lower frequency close spacing

• The image contains components of all frequencies, but


their magnitude gets smaller for higher frequencies
• Low frequencies contain more image information than
the higher ones
Sinusoid, Titled spectrum • Two dominating directions in the Fourier image,
tilted vertical and horizontal. These originate from the
regular patterns in the background

Discrete Fourier Transform


Discrete Fourier Transform - Phase

Phase image Re-transform using only magnitude

• The value of each point determines the phase of the


corresponding frequency
• The phase information is crucial to reconstruct the
correct image in the spatial domain

5
Inverse Transform Phase Carries More Information
Raw
Images:

Magnitude
and
Phase:

Reconstruct
(inverse FFT)
mixing the
magnitude and
phase images

If we attempt to reconstruct the image with an inverse Fourier


Transform after destroying either the phase information or the
amplitude information, then the reconstruction will fail. Phase “Wins”

The spectrum of DFT The spectrum of DFT

Original image Fourier transform


Log enhanced
Original image
Fourier transform

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

25 26

6
Low and high frequencies Low and high frequencies
The DFT matrix for n=7:
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.

where

27 28

Low and high frequencies Low and high frequencies

Visualisation of the fourth row. The visualisation of the last row. We made one full clockwise circle.

29 30

7
Low and high frequencies Low and high frequencies

Frequencies of the 1D DFT Frequencies of the 2D DFT

High
Low

Low
Top rows Low frequencies

Low Low Low

High frequencies
High High

Bottom rows Low frequencies


Low Low Low
31 32

Spectrum shift Spectrum shift


A doubly periodic image has a doubly periodic discrete Fourier We shift the origin of the transform to the centre.
transform.
Now the low frequency information is in the centre of the DFT.

36 37

8
Spectrum shift Filtering steps:

Shifted
1) Multiply the input image by (-1)x+y to center
Log enhanced the transform.
Original image log enhanced
transform
transform 2) Compute DFT F(u, v)
3) Multiply F(u,v) by a filter function H(u,v)
G(u,v) = F(u,v)H(u,v)
4) Computer the inverse DFT of G(u,v)
5) Obtain the real part of g(x,y)
6) Multiply g(x,y) with (-1)x+y
38

Why (-1)x?
(1) x  (cos   j sin  ) x  (e j ) x  e jx
1 M 1 • Modulation in the space domain
M
 (1) x f ( x)e  j 2ux / M
x 0
F[(-1)x+yf(x, y)]= F(u-M/2,v-N/2)

1 M 1 • Shift the origin of F(u,v) to frequency



M
e 
x 0
j x
f ( x)e  j 2ux / M coordinates (M/2, N/2),
M 1
– the center of (u, v), u=0,…M-1, v=0,…N-1.
1

M
 f ( x )e
x 0
jx  j 2ux / M – frequency rectangle

M 1  2 jx ( u 
M
1 M

)/M
 f ( x )e 2
 F (u  )
M x 0 2

9
Lowpass filter

Highpass filter

Gaussian Filters
Smoothing Frequency-Domain Filters
• Frequency-Domain Filtering:
• Fourier Transform pair G(u,v) = H(u,v)F(u,v)
of Gaussian function
 H (u )  Aeu / 2
2 2


h( x)  2    Ae
  2 2 2 x 2
In many instances the frequency response of
• Depicted in figures are
the filter is known, but its impulse response
is unknown, or it is desired to filter a given
low-pass and high-pass spatial frequency
Gaussian filters, and
their spatial response,
as well as FIR masking Filter H(u,v)
filter approximation. – Ideal filter
– Butterworth filter
– Gaussian Filter

10
Ideal lowpass filter Ideal lowpass filter
We can also directly design filters for the frequency domain.
This filter retains the low frequencies and eliminates the high
Assume that the frequency domain has been shifted and the low frequencies.
frequencies are at the centre of the transform.
Remember that the filter H(u,v) acts on the transform F(u,v) by
Consider the filter H with values 1 near the centre of the image and component-wise multiplication H (u , v )  F (u , v )
values 0 further from the centre.

46 47

Direct Construction of Frequency Domain Filters

• Ideal lowpass filters (ILPF)


– Cut off all high-frequency components of the Fourier transform
that are at a distance greater than a specified distance D0
(cut off frequency) from the origin of the (centered) transform
– The transfer function (frequency domain filter) is defined by
1 if D (u , v)  D0
H (u , v )  
0 if D (u , v)  D0
– D(u,v) is the distance from point (u,v) to the origin (center) of the
frequency domain filter

– Usually, the image to be filtered is even-sized, in this case, the


center of the filter is (M/2,N/2). Then the distance D(u,v) can be
obtained by
48 D(u, v)  [(u  M / 2) 2  (v  N / 2) 2 ]1/ 2 49

11
Note that the origin (0, 0) is at the center and not the corner of the
image .

The abrupt transition from 1 to 0 of the transfer function


H (u, v) cannot be realized in practice, using electronic
components. However, it can be simulated on a computer.
Notice the severe ringing effect in the blurred images, which is a
characteristic of ideal filters. It is due to the discontinuity in the
50 filter transfer function. 51

Effects of Ideal Low Pass Filters Ringing and Blurring


• Blurring can be modeled as
the convolution of a high
resolution (original) image with
a low pass filter. Which parameter of ILPF responsible for blurring and ringing?

52 53

12
Butterworth Low pass Filters Butterworth Low pass Filters
• A butterworth low pass filter (BLPF) of order n with cutoff frequency
• Softer Blurring + no Ringing at a distance D0 from the origin is given by the following transfer
function 1
H (u, v) 
1  [ D(u, v) / D0 ]2 n

– BLPF does not have a sharp discontinuity


– For BLPF, the cutoff frequency is defined as the frequency at which the
transfer function has value which is half of the maximum

54 55

Butterworth LPF with n=2; D0=36

Frequency response does not have a sharp transition as in the


ideal LPF.

This is more appropriate for image smoothing than the ideal LPF,
56
since this does not introduce ringing. 57

13
Examples of Application of BLPF Butterworth Low pass Filters
• Same order but with different • To check whether a Butterworth low pass filter suffer the ringing
effect as dose the ILPF, we need to examine the pattern of its
cutoff frequencies equivalent spatial filter
– The larger the cutoff frequency,
the more details are reserved

58 59

• BLPF of order 1 shows no ringing effect, but


cutoff is not sharp
• Order 2 shows mild ringing effect, but less
than that of ILPF
• Therefore, the order of BLPF can be selected
Original D0=80, n=1 D0=80, n=2 D0=80, n=3 D0=80, n=5
based on tradeoff between sharp cutoff and
ringing effect
• Order 20 exhibits the characteristics of ILPF
• In general, order 2 is a good compromise
D0=80, n=10 D0=80, n=20 D0=80, n=50 between effective low-pass filtering and
acceptable ringing characteristics
60 61

14
Gaussian Low pass Filters Gaussian Low pass Filters
• 1D Gaussian distribution function is given
• GLPF is given by the following (centered ) transfer
by  ( x  x ) / 2
2 2 function
f ( x)  Ae 0

 ( v v0 ) 2 ] / 2 2
H (u, v)  e [(u u0 )  e D ( u ,v ) / 2 D0 2
2 2

– x0 is the center of the distribution


– σ is the standard deviation controlling the
shape (width) of the curve – (u0,v0) is the center of the transfer function

– A is a normalization constant to ensure the


– Dose GLPF suffer from the ringing effect?
area under the curve is one.
– The Fourier transform of a Gaussian function
is also a Gaussian function
62 63

Gaussian Low pass Filter Gaussian Low pass Filter

15
Other Low pass filtering examples Frequency-Domain Filtering
Ideal LPF Butterworth LPF Gaussian LPF

67

High pass filtering


Sharpening Frequency-Domain Filter
Edges and sharp transitions in gray values in an image contribute
significantly to high-frequency content of its Fourier transform.
• High pass filtering:
Regions of relatively uniform gray values in an image contribute
to low-frequency content of its Fourier transform. Hhp(u,v) = 1-Hlp(u,v)
• Given a low pass filter Hlp(u,v), find the
Hence, image sharpening in the Frequency domain can be done
spatial representation of the high pass
by attenuating the low-frequency content of its Fourier transform.
This would be a high pass filter! filter
For simplicity, we will consider only those filters that are real
and radially symmetric. (1) Compute the inverse DFT of Hlp(u,v)
(2) Multiply the real part of the result with (-1)x+y
68

16
Sharpening Frequency-Domain Filter Sharpening Frequency-Domain Filter

Ideal High pass Filter


• H(u,v)= 0 if D(u,v) D0
= 1 if D(u,v)>D0
• The center is at (u,v)=(M/2, N/2)
D(u,v)=[(u-M/2)2+(v-N/2)2]1/2
• Cutoff frequency is D0

17
Ideal High pass Filter Butterworth High pass Filter

• Butterworth filter has no sharp cutoff


1
H (u, v) 
1  [ D0 / D(u, v)]2 n

• At cutoff frequency D0: H(u, v)=0.5

Butterworth High pass Filter

•Frequency response does not


have a sharp transition as in
the ideal HPF.
•This is more appropriate for
image sharpening than the
ideal HPF, since this not
introduce ringing.
IHPF

18
Gaussian High pass Filter Gaussian High pass Filter

• Gaussian high pass filter (GHPF)


( u ,v ) / 2 2
H (u, v)  1  e  D
2

• Let  = D0

H (u, v)  1  e  D
2
( u ,v ) / 2 D02

Periodic Noise Reduction by Frequency


Domain Filtering
• Periodic noise is due to the electrical or electromechanical
interference during image acquisition.

• Can be estimated through the inspection of the Fourier


spectrum of the image.

• Periodic noise can be reduced significantly via


frequency domain filtering

Approach

A selective filter is used to isolate the noise

19
Periodic Noise Reduction by Frequency
Domain Filtering
A Butterworth bandreject
filter of order 4, with the • Band reject filters
appropriate radius and
width to enclose
– Remove or attenuate a band of frequencies.
completely the noise
impulses 1 if D(u, v)  D0  W / 2

H (u, v)  0 if D0  W / 2  D(u, v)  D0  W / 2
1 D(u, v)  D0  W / 2
 if

• D0 is the radius.
• D(u, v) is the distance from the origin, and
• W is the width of the frequency band.

82

Butterworth and Gaussian Band reject Filters Band reject Filters

• Butterworth band reject filter (order n)


1
H (u, v)  2n
 D(u, v)W 
1  2 2
 D (u, v)  D0 

• Gaussian band reject filter


2
1  D 2 ( u ,v )  D02 
  
2  D ( u ,v )W 
H (u, v)  1  e

20
Band pass filter Notch filters
• Notch filter rejects (passes) frequencies in
• Obtained form band reject filter predefined neighborhoods about a center
Hbp(u,v)=1-Hbr(u,v) frequency.
• The goal of the band pass filter is to isolate 0 if D1 (u, v)  D0 or D2 (u, v)  D0
the noise pattern from the original image, H (u, v)  
1 otherwise
which can help simplify the analysis of where
noise, reasonably independent of image
content.

D1 (u, v)  (u  M / 2  u0 )2  (v  N / 2  v0 )2 
1/ 2

D (u, v)  (u  M / 2  u ) 
1/ 2
2 0
2
 (v  N / 2  v0 )2

Notch filters
Notch filters
• Butterworth notch filter
1
H (u, v)  n
 D02 
1 
 1
D (u , v ) D2 (u, v) 

• Gaussian notch filter


1  D ( u ,v ) D2 ( u ,v ) 
  1 
2  D02 
H (u, v)  1  e

• Note that these notch filters will become


high pass when u0=v0=0

21

You might also like