Chapter 3
FrequencyTransform
s
&
Im processing in the FrequencyDom
age
ain
Introduction
 The spatial domain refers to the representation of an
image as the array of gray-level intensity.
 The electromagnetic spectrum consist of sinusoidel
waves of different wavelengths (frequencies).
 The frequency content of an image refers to the rate at
which the gray levels change in the image
 Rapidly changing brightness values correspond to
high frequency terms, slowly changing brightness
values correspond to low frequency terms
 The Fourier transform is a mathematical tool that
analyses a signal (e.g. images) into its spectral
components depending on its wavelength (i.e.
frequency) content.
Fourier Transforms
 In 1822, Jean B. Fourier has shown that any function f(x) that
have bounded area with the x-axis can be expressed as a linear
combination of sine and/or cosine waves of different
frequencies.
 This is also applicable functions of 2 variables, e.g. images.
+

+

=

+

Q. Can we recover the different
frequencies of this signal?
Fourier Transforms
 Fourier transform converts a signal from time (or space) domain
to frequency domain
Illustration of Fourier Theory for images

Every row is Sine wave of
frequncy 1

Sine wave with frequncy 2

Combined waves frequncy 1+2+3

Sine wave with frequncy 3

Mixed waves with frequncy 5, 2 &1
MATLAB generated images
 MATLAB can be used to generate images with patterns of and
desired rate of change of brightness.
 For this we need to use trigonometric functions of 2 variables as
indicated by the following example code:
clear all;
A=zeros(256,256);
B=A;
for i=1:1:256
for j=1:1:256
A(i,j)=a1*sin(pi*(a2*i+a3*j)/m);
B(i,j)=b1cos(pi*(b2*i+b3*j)/n); //m and n are to be powers of 2.
end
end
C=A+B;
imshow(C);
imwrite(C, 'SinoPattern2.bmp')
Images generated from Sinoside function
Fourier Transform - Definition

 The Discrete Fourier Transform (DFT) of f(x) is defined as:

1
F(u) = 
M

M −1

∑
x =0

2π u x
f ( x) cos(
)
M

− 1 M −1
2π u x 
∑ f ( x) sin( M )
M x =0


And the inverse DFT (IDFT) is defined as:

2π u x M −1
2π u x
f(x) = ∑ R (u ) cos(
) − ∑ I (u ) sin(
)
M
M
u =0
u =0
M −1

 The u values u = 0, 1, ..., M-1) is the frequency domain of f(x).
 One can use Excel to implement Fourier tranforms.
Fourier Transform - continued
 Unlike f(x), F(u) is a complex valued function, i.e. is a pair of
functions involving trigonometric functions:
1
R(u) =
M
I(u) = −

1
M

M −1

∑ f ( x) cos(2πux / M ),

called the real part, and

x =0
M −1

∑ f ( x) sin(2πux / M ),

called the imaginary part.

x =0

i.e. F(u) ≡ [ R(u ) I (u )].

 F is represented by its MAGNITUDE and PHASE rather that its
REAL and IMAGINARY parts,
 where: MAGNITUDE(u) = SQRT( R(u)^2+IMAGINARY(u)^2 )
 The phase angle of the transform is:

I (u )
φ (u ) = tan (
).
R(u )
−1

PHASE(u) = ATAN( IMAGINARY(u)/REAL(u) )
The 2-dimensional DFT
 The DFT of a digitised function f(x,y) (i.e. an image) is defined as:

 1
F(u, v) = 
 MN

M −1 N −1

∑∑ f ( x, y) cos(2π (u x / M + v y / N )
x =0 y =0


∑∑ f ( x, y) sin(2π (u x / M + v y / N )
x =0 y =0

and the inverse DFT is defined in a similar manner as before.
1
−
MN

M −1 N −1

f ( x, y) = ∑ ∑ R(u, v) cos(2π (u x / M + v y / N ) −
N −1M −1

u =0 v =0

N −1M −1

∑ ∑ I (u , v) sin( 2π (u x / M + v y / N )

u =0 v =0

 Note that, F(0,0) = the average value of f(x,y) and is refered to as
the DC component of the spectrum.
 It is a common practice to multiply the image f(x,y) by (-1) x+y. In
this case, the DFT of (f(x,y)(-1)x+y) has its origin located at the
centre of the image, i.e. at (u,v)=(M/2,N/2).
The Fourier spectrum – in 2D
The Fourier spectrum – in 2D

• The original image
contains two principal
features: edges run
approximately at ±45ο .
•

The Fourier spectrum
shows important
components in the
same directions.
Fourier Spectrum

Original image

Log enhanced version
of Fourier Spectrum

Inverse Fourier

The FTs also tend to have bright lines that are
perpendicular to lines in the original letter. If the
letter has circular segments, then so does the FT.
Filtering in the Frequency Domain – Scheme
The Notch filter
 A simple filter that forces the average image value to become 0.
 The average value of an image f(x,y) is the DC component of the
DFT spectrum i.e. F(0,0). The Notch filter is defined as follows:

0
H (u, v) = 
1

Original
image

if (u, v) = (M/2, N/2)
otherwise.

Image after
Notch filter
application

 Note that the edges stand out more than before filtering.
 When the average value is 0, some values of the filtered image
are negative, but for display purposes pixel values are shifted.
Low-pass and High-pass filtering
 Low frequencies in the DFT spectrum correspond to image
values over smooth areas, while high frequencies
correspond to detailed features such as edges & noise.
 A filter that suppresses high frequencies but allows low ones
is called Low-pass filter, while a filter that reduces low
frequencies and allows high ones is called High-pass filter.
 Examples of such filters are obtained from circular Gaussian
functions of 2 variables (see next slide)

1
−( u 2 + v 2 ) / 2σ 2
H ( u ,v ) =
e
,
- Lowpass filter,
2
2πσ
1
−( u 2 + v 2 ) / 2σ 2
H ( u ,v ) =
(1 − e
) - Highpass filter .
2
2πσ
Low-pass & High-pass filtering - Example

Low pass filtering

High pass filtering

Low pass filtering results in blurring effects, while High pass
filtering results in sharper edges.
Wavelet Transforms
 Wavelet analysis allows the use of long time intervals for
more precise low-frequency information, and shorter
intervals for high-frequency information.
 A wavelet (i.e. small wave) is a mathematical function
used to analyse a continuous-time signal into different
frequency components at different resolution scale.
 A wavelet transform of a function is a representation of f
wavelets. The wavelets are scaled and translated copies
of a finite-length or fast-decaying oscillating waveform
ψ(t), known as the mother wavelet.
 There are many wavelet filters to choose from. Here we
only discuss the Discrete Wavelet Transform.
Wavelet Transforms -Properties
 The Wavelet transform is a short time anlysis tool
of finite energy quasi-stationary signals at multiresolutions.
 The Discrete wavelet transform (DWT) provide a
compact representation of a signal’s frequency
commponents with strong spatial support.
 DWT decomposes a signal into frequency subbands
at different scales from which it can be perfectly
recontructed.
 2D-signals such as images can be decomposed in
many different ways.
The Haar Wavelet
The Haar wavelet is a
discontinuous, and
resembles a step function.
It is a crude version of the
Truncated cosine.

The Haar wavelet
0.6
0.4
0.2
0
-2

-0.2 0

2

4

6

8

10

-0.4
-0.6

 It can be implemented using a simple filter:
If X={x1,x2,x3,x4 ,x5 ,x6 ,x7 ,x8 } is a time-signal of length 8, then
the Haar wavelet decomposes X into an aproximation
subband containing the Low frequencies and a detail
subband containing the high frequencies:
Low= {x2+x1, x4+x3 , x6+x5 , x8+x7 }/√2

High= {x2-x1, x4-x3 , x6-x5 , x8-x7 }/√2
Haar Wavelet – in MATLAB
Wavelet Decomposition of Images
A Haar wavelet decompose images first on the rows and then on the
columns resulting in 4 subbands, the LL-subband which an approximation of
the original image while the other subbands contain the missing details
The LL-subband output from any stage can be decomposed further.
Original
Image

1 stage Transformation
After 2 stages

…
Different Decomposition Schemes.
 The previous 2 decomposition scheme is known as
the Pyrimad scheme, whereby at successive stages
only the LL subband is wavelet transdormed.
 Other decomposition schemes include:
 The standard scheme – At every stage all the
image is wavelet transformd
 The wavelet packet – After stage 1, a non-LL
subband is transformed only if it satisfied
certain condition.
 The Quincux – During each stage, the columns
decomposition is only applied on the L-subband
Statistical Properties of Wavelet subbands
LL subband

HL subband

700

6000

600

5000

500

4000

400

3000

300

2000

200
100

1000

0

0
1

LH subband

Original pixels distribution of Mandrill
3000
2500
frequency

2000
1500
1000
500
1
20
39
58
77
96
115
134
153
172
191
210
229
248

0
coefficient value

1 25 49 73 97 121 145 169 193 217 241

25 49 73 97 121 145 169 193 217 241

8000
7000
6000
5000
4000
3000
2000
1000
0

HH subband
6000
5000
4000
3000
2000
1000
0

1 25 49 73 97 121 145 169 193 217 241

1 25 49 73 97 121 145 169 193 217 241

The distribution of the LL-subband approximate that of the original but all nonLL subbands have a Laplacian distribution. This remains valid at all depths.
Applications of Wavelet Transforms
 The list of applications is growing fast. These include:
 Image and video Compression
 Feature detection and recognition
 Image denoising
 Face Recognition
 Signal interpulation
 Most applications benefit from the statistical propererty
of the non-LL subbands (The laplacian distribution of
the wavelet coefficients in these subbands).
Wavelet-based Feature detection
 Non-LL subbands of a wavelet decomposed image contains high

frequencies (i.e. image features) which are highlighted. These
significant coefficients are the furthest away from the mean.
 Thresholding reveals the main features.

Horizontal features

σ

Vertical features
Extracting significant coefficients

Best value for sigma is related to the STD

28
Feature enhancement method using wavelet subband segmentation

NSC

-

+

µ≅0

SC
29
End of Chapter 3

Digital Image Processing_ ch3 enhancement freq-domain

  • 1.
  • 2.
    Introduction  The spatialdomain refers to the representation of an image as the array of gray-level intensity.  The electromagnetic spectrum consist of sinusoidel waves of different wavelengths (frequencies).  The frequency content of an image refers to the rate at which the gray levels change in the image  Rapidly changing brightness values correspond to high frequency terms, slowly changing brightness values correspond to low frequency terms  The Fourier transform is a mathematical tool that analyses a signal (e.g. images) into its spectral components depending on its wavelength (i.e. frequency) content.
  • 3.
    Fourier Transforms  In1822, Jean B. Fourier has shown that any function f(x) that have bounded area with the x-axis can be expressed as a linear combination of sine and/or cosine waves of different frequencies.  This is also applicable functions of 2 variables, e.g. images. + + = + Q. Can we recover the different frequencies of this signal?
  • 4.
    Fourier Transforms  Fouriertransform converts a signal from time (or space) domain to frequency domain
  • 5.
    Illustration of FourierTheory for images Every row is Sine wave of frequncy 1 Sine wave with frequncy 2 Combined waves frequncy 1+2+3 Sine wave with frequncy 3 Mixed waves with frequncy 5, 2 &1
  • 6.
    MATLAB generated images MATLAB can be used to generate images with patterns of and desired rate of change of brightness.  For this we need to use trigonometric functions of 2 variables as indicated by the following example code: clear all; A=zeros(256,256); B=A; for i=1:1:256 for j=1:1:256 A(i,j)=a1*sin(pi*(a2*i+a3*j)/m); B(i,j)=b1cos(pi*(b2*i+b3*j)/n); //m and n are to be powers of 2. end end C=A+B; imshow(C); imwrite(C, 'SinoPattern2.bmp')
  • 7.
    Images generated fromSinoside function
  • 8.
    Fourier Transform -Definition  The Discrete Fourier Transform (DFT) of f(x) is defined as: 1 F(u) =  M M −1 ∑ x =0 2π u x f ( x) cos( ) M − 1 M −1 2π u x  ∑ f ( x) sin( M ) M x =0  And the inverse DFT (IDFT) is defined as: 2π u x M −1 2π u x f(x) = ∑ R (u ) cos( ) − ∑ I (u ) sin( ) M M u =0 u =0 M −1  The u values u = 0, 1, ..., M-1) is the frequency domain of f(x).  One can use Excel to implement Fourier tranforms.
  • 9.
    Fourier Transform -continued  Unlike f(x), F(u) is a complex valued function, i.e. is a pair of functions involving trigonometric functions: 1 R(u) = M I(u) = − 1 M M −1 ∑ f ( x) cos(2πux / M ), called the real part, and x =0 M −1 ∑ f ( x) sin(2πux / M ), called the imaginary part. x =0 i.e. F(u) ≡ [ R(u ) I (u )].  F is represented by its MAGNITUDE and PHASE rather that its REAL and IMAGINARY parts,  where: MAGNITUDE(u) = SQRT( R(u)^2+IMAGINARY(u)^2 )  The phase angle of the transform is: I (u ) φ (u ) = tan ( ). R(u ) −1 PHASE(u) = ATAN( IMAGINARY(u)/REAL(u) )
  • 10.
    The 2-dimensional DFT The DFT of a digitised function f(x,y) (i.e. an image) is defined as:  1 F(u, v) =   MN M −1 N −1 ∑∑ f ( x, y) cos(2π (u x / M + v y / N ) x =0 y =0  ∑∑ f ( x, y) sin(2π (u x / M + v y / N ) x =0 y =0  and the inverse DFT is defined in a similar manner as before. 1 − MN M −1 N −1 f ( x, y) = ∑ ∑ R(u, v) cos(2π (u x / M + v y / N ) − N −1M −1 u =0 v =0 N −1M −1 ∑ ∑ I (u , v) sin( 2π (u x / M + v y / N ) u =0 v =0  Note that, F(0,0) = the average value of f(x,y) and is refered to as the DC component of the spectrum.  It is a common practice to multiply the image f(x,y) by (-1) x+y. In this case, the DFT of (f(x,y)(-1)x+y) has its origin located at the centre of the image, i.e. at (u,v)=(M/2,N/2).
  • 11.
  • 12.
    The Fourier spectrum– in 2D • The original image contains two principal features: edges run approximately at ±45ο . • The Fourier spectrum shows important components in the same directions.
  • 13.
    Fourier Spectrum Original image Logenhanced version of Fourier Spectrum Inverse Fourier The FTs also tend to have bright lines that are perpendicular to lines in the original letter. If the letter has circular segments, then so does the FT.
  • 15.
    Filtering in theFrequency Domain – Scheme
  • 16.
    The Notch filter A simple filter that forces the average image value to become 0.  The average value of an image f(x,y) is the DC component of the DFT spectrum i.e. F(0,0). The Notch filter is defined as follows: 0 H (u, v) =  1 Original image if (u, v) = (M/2, N/2) otherwise. Image after Notch filter application  Note that the edges stand out more than before filtering.  When the average value is 0, some values of the filtered image are negative, but for display purposes pixel values are shifted.
  • 17.
    Low-pass and High-passfiltering  Low frequencies in the DFT spectrum correspond to image values over smooth areas, while high frequencies correspond to detailed features such as edges & noise.  A filter that suppresses high frequencies but allows low ones is called Low-pass filter, while a filter that reduces low frequencies and allows high ones is called High-pass filter.  Examples of such filters are obtained from circular Gaussian functions of 2 variables (see next slide) 1 −( u 2 + v 2 ) / 2σ 2 H ( u ,v ) = e , - Lowpass filter, 2 2πσ 1 −( u 2 + v 2 ) / 2σ 2 H ( u ,v ) = (1 − e ) - Highpass filter . 2 2πσ
  • 18.
    Low-pass & High-passfiltering - Example Low pass filtering High pass filtering Low pass filtering results in blurring effects, while High pass filtering results in sharper edges.
  • 19.
    Wavelet Transforms  Waveletanalysis allows the use of long time intervals for more precise low-frequency information, and shorter intervals for high-frequency information.  A wavelet (i.e. small wave) is a mathematical function used to analyse a continuous-time signal into different frequency components at different resolution scale.  A wavelet transform of a function is a representation of f wavelets. The wavelets are scaled and translated copies of a finite-length or fast-decaying oscillating waveform ψ(t), known as the mother wavelet.  There are many wavelet filters to choose from. Here we only discuss the Discrete Wavelet Transform.
  • 20.
    Wavelet Transforms -Properties The Wavelet transform is a short time anlysis tool of finite energy quasi-stationary signals at multiresolutions.  The Discrete wavelet transform (DWT) provide a compact representation of a signal’s frequency commponents with strong spatial support.  DWT decomposes a signal into frequency subbands at different scales from which it can be perfectly recontructed.  2D-signals such as images can be decomposed in many different ways.
  • 21.
    The Haar Wavelet TheHaar wavelet is a discontinuous, and resembles a step function. It is a crude version of the Truncated cosine. The Haar wavelet 0.6 0.4 0.2 0 -2 -0.2 0 2 4 6 8 10 -0.4 -0.6  It can be implemented using a simple filter: If X={x1,x2,x3,x4 ,x5 ,x6 ,x7 ,x8 } is a time-signal of length 8, then the Haar wavelet decomposes X into an aproximation subband containing the Low frequencies and a detail subband containing the high frequencies: Low= {x2+x1, x4+x3 , x6+x5 , x8+x7 }/√2 High= {x2-x1, x4-x3 , x6-x5 , x8-x7 }/√2
  • 22.
  • 23.
    Wavelet Decomposition ofImages A Haar wavelet decompose images first on the rows and then on the columns resulting in 4 subbands, the LL-subband which an approximation of the original image while the other subbands contain the missing details The LL-subband output from any stage can be decomposed further. Original Image 1 stage Transformation After 2 stages …
  • 24.
    Different Decomposition Schemes. The previous 2 decomposition scheme is known as the Pyrimad scheme, whereby at successive stages only the LL subband is wavelet transdormed.  Other decomposition schemes include:  The standard scheme – At every stage all the image is wavelet transformd  The wavelet packet – After stage 1, a non-LL subband is transformed only if it satisfied certain condition.  The Quincux – During each stage, the columns decomposition is only applied on the L-subband
  • 25.
    Statistical Properties ofWavelet subbands LL subband HL subband 700 6000 600 5000 500 4000 400 3000 300 2000 200 100 1000 0 0 1 LH subband Original pixels distribution of Mandrill 3000 2500 frequency 2000 1500 1000 500 1 20 39 58 77 96 115 134 153 172 191 210 229 248 0 coefficient value 1 25 49 73 97 121 145 169 193 217 241 25 49 73 97 121 145 169 193 217 241 8000 7000 6000 5000 4000 3000 2000 1000 0 HH subband 6000 5000 4000 3000 2000 1000 0 1 25 49 73 97 121 145 169 193 217 241 1 25 49 73 97 121 145 169 193 217 241 The distribution of the LL-subband approximate that of the original but all nonLL subbands have a Laplacian distribution. This remains valid at all depths.
  • 26.
    Applications of WaveletTransforms  The list of applications is growing fast. These include:  Image and video Compression  Feature detection and recognition  Image denoising  Face Recognition  Signal interpulation  Most applications benefit from the statistical propererty of the non-LL subbands (The laplacian distribution of the wavelet coefficients in these subbands).
  • 27.
    Wavelet-based Feature detection Non-LL subbands of a wavelet decomposed image contains high frequencies (i.e. image features) which are highlighted. These significant coefficients are the furthest away from the mean.  Thresholding reveals the main features. Horizontal features σ Vertical features
  • 28.
    Extracting significant coefficients Bestvalue for sigma is related to the STD 28
  • 29.
    Feature enhancement methodusing wavelet subband segmentation NSC - + µ≅0 SC 29
  • 30.