You are on page 1of 61

BITS F442

Spatial Domain to Frequency Domain- Part-1

BITS Pilani Instructor-In-Charge: Rajitha K


Hyderabad Campus
Why Spatial Domain to Frequency Domain?

• Noise removal as it is high frequency components

• Image enhancement more efficient:

• Fast computation

• Conceptual insights for various image processing

– E.g., spatial frequency info. (smooth, moderate change, fast


change, etc.)

• For efficient storage and transmission

– Pick a few “representatives” (basis)

– Just store/send the “contribution” from each basis

BITS Pilani, Hyderabad Campus


What is high frequency and low frequency images?

One Dimensional
representation

BITS Pilani, Hyderabad Campus


Low and high frequency images

BITS Pilani, Hyderabad Campus


Low and High Spatial frequencies

High frequencies
correspond to pixel
values that change
rapidly across the
image
High frequency

Low frequency
components correspond
to large scale features
in the image
Low frequency

BITS Pilani, Hyderabad Campus


Frequency Domain

The rate at which intensity values


change, that is, over how many
pixels does a cycle of periodically
repeating intensity variations occur.

One cycle

Two cycles

BITS Pilani, Hyderabad Campus


Frequency Domain

Based on the concept that any function can be represented as


superposition of sinusoidal waves.

Frequency domain is an alternative way to store and reproduce the


spatial domain image

In 'frequency domain', each channel has 'amplitude' values that are


stored in locations based on X,Y 'frequencies'. Since this is a
digital representation, the frequencies are multiples of a 'smallest'
or unit frequency and the pixel coordinates represent the indices or
integer multiples of this unit frequency.

BITS Pilani, Hyderabad Campus


Fourier’s Idea

Any function that periodically repeats itself can be expressed as a sum of sines and
cosines of different frequencies each multiplied by a different coefficient – a Fourier
series

BITS Pilani, Hyderabad Campus


Spatial domain to Frequency domain

Based on Fourier transform concepts.


Fourier’ concepts:
Fourier series: Any periodic function can be represented as
sum of sines and cosines of different frequencies
multiplied by a different coefficient.
Fourier transform: Any function that is not periodic but area
under the curve is finite.

BITS Pilani, Hyderabad Campus


Periodic function

A function which repeats its value in regular intervals


Mathematically,
f(x + T) = f(x)
Where T is the fundamental period

BITS Pilani, Hyderabad Campus


Periodic signals

Electrocardiogram (ECG): Measure of the dipole moment


caused by depolarization and repolarization of heart
muscle cells.

BITS Pilani, Hyderabad Campus


Fourier transformations

The process of working out what 'waves' comprise an


Image

Addition of sufficient number of sine waves of just the right


frequency and amplitude, in order to reproduce the same
image pattern

BITS Pilani, Hyderabad Campus


Fourier transform..

Based on the concept of complex number sinusoidal waves


Hence the results of transform cannot be visualized directly.
Real and imaginary part may contain negative values and
do not form viewable images.

BITS Pilani, Hyderabad Campus


Complex number

BITS Pilani, Hyderabad Campus


Complex numbers..

Polar form of representation


C= |C|(cosѲ+jsinѲ)
J= sqrt (-1) Magnitude is telling how much of a certain frequency
component is in the image.
Phase is telling where that certain frequency lies in the
image.

|C| =
R I
2 2 Magnitude

Ѳ = arctan(I/R) Phase
Based on Euler’s formula,

BITS Pilani, Hyderabad Campus


Complex number ..

Real part ---- How much of a cosine of that


frequency required

Imaginary part ------ How much of a sine of that


frequency required

Magnitude ---------Amplitude of combined cosine


and sine

Phase ----- Relative proportions of sine and


cosine
BITS Pilani, Hyderabad Campus
Visualization of Frequency Domain

Original image Magnitude image Phase image

BITS Pilani, Hyderabad Campus


Why do we do Fourier Transform?

BITS Pilani, Hyderabad Campus


Original Image
Why do we do Fourier Transform?

Transformed Inverse
Image Transformation

Inverse Transformed Image

BITS Pilani, Hyderabad Campus


Why do we do Fourier Transform?

BITS Pilani, Hyderabad Campus


Basics of Image Transformation

Image transform refers to a class of unitary matrices used


for representation of images.
Based on Unitary transformation.
Image is represented as a series summation of set of
unitary matrices.
Unitary matrices:
A matrix A is a unitary matrix if,
A-1 = A*T Where A* is conjugate of A

Unitary matrix is a complex matrix.

BITS Pilani, Hyderabad Campus


Example of linear transformation

1 2
Rotate the image   through 30 degrees.
3 4
Get the transformation matrix. Apply inverse
transformation and check the result.
Transformed matrix =  0.64  0.28 
 
 3.08 4.44 
After inverse transform =
 0.869 0.505    0.64  0.28 
   
  0.505 0.869   3.08 4.44 
Output =  1 2 
3 4
 

BITS Pilani, Hyderabad Campus


Unitary Transformation

Unitary Transformation
Transformation that preserves the inner product: the
inner product of two vectors before the transformation
is equal to their inner product after the transformation.

Orthogonal matrix
Real-valued unitary matrix is also an orthogonal matrix

BITS Pilani, Hyderabad Campus


Fourier Transform components

BITS Pilani, Hyderabad Campus


Reconstruction of the image

BITS Pilani, Hyderabad Campus


Magnitude and Phase of Image

• Inimage processing, often only the magnitude of


the Fourier Transform is displayed, as it contains
most of the information of the geometric structure
of the spatial domain image.

•However, to re-transform the Fourier image into


the correct spatial domain after some processing
in the frequency domain, both magnitude and
phase of the Fourier image should be used.

BITS Pilani, Hyderabad Campus


BITS Pilani, Hyderabad Campus
Phase vs. Magnitude

Oppenheim, A.V.; Lim, J.S., The importance of phase in


signals, IEEE Proceedings, v. 69, No 5, 1981, pp.: 529-
541
It was shown that the phase in the Fourier spectrum of a
signal is much more informative than the magnitude:
particularly in the Fourier spectrum of images phase
contains the information about all shapes, edges,
orientation of all objects, etc.

BITS Pilani, Hyderabad Campus


Impulses and their sifting property
• Basis for linear system and Fourier
analysis.
An impulse is a generalized function or distribution.
Also called Dirac delta function or delta function
PSF

δ(t) = 0 if t ≠ 0
= Infinity at
t=0
Sifting property and Fourier Transform

Decompose signal or image into different


frequency components based on the
sifting property of Image response
function. Ultimately Fourier transform of
image response function convolved with
the function will result in frequency
domain
Sifting property yields the value of
function at the location of unit impulse
Impulse Train
The impulse train, is an infinite set of
equally-spaced impulses
Fourier Transform Functions of one
continuous variable

Fourier Transform of continuous function f(x) of


a continuous variable x is

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

Inverse Fourier Transform Fourier Transform


 Pair
f ( x)   F (u)e j 2uxdu

Fourier transform of a function

Function Fourier
transform
Sampling and Fourier Transform

Continuous
function f(t)
Sampling

Function (ft) and Impulse


Train

Product of f(t) and impulse


train and sampled values
Effects of sampling (Aliasing)

Proper sampling Improper sampling


Critical Sampling

Input

Reconstructed
BITS Pilani, Hyderabad Campus
Frequency domain specific filters

- Low pass filters- Smoothening filters

- High pass filters- sharpening filters

- Notch filters- Band stop filter and useful for periodic


noise removal

BITS Pilani, Hyderabad Campus


Lowpass filters

BITS Pilani, Hyderabad Campus


High pass filters

BITS Pilani, Hyderabad Campus


Notch filter and periodic noise

BITS Pilani, Hyderabad Campus


DFT …
Converts a finite list of equally-spaced samples of a
function into the list of coefficients of a finite
combination of complex sinusoids, ordered by their
frequencies, that has those same sample values.

Sampling a continuous
function
Sampling increment in the spatial and
frequency domain

N- Total number of samples


Δx – sampling interval in spatial domain
Δu - sampling interval in frequency domain
DFT…
DFT for two variables
DFT
ux vy
M 1N 1  j 2 (  )
F (u, v)   f ( x, y ) e M N

x0y0

Inverse DFT
ux vy
M  1N  1 j 2 (  )
1
f ( x, y)   
MN u  0 v  0
F (u , v )e M N
2D Rectangular function
V

u=-2, v=2 u=-1, v=2 u=0, v=2 u=1, v=2 u=2, v=2

u=-2, v=1 u=-1, v=1 u=0, v=1 u=1, v=1 u=2, v=1

U
u=-2, v=0 u=-1, v=0 u=0, v=0 u=1, v=0 u=2, v=0

u=-2, v=-1 u=-1, v=-1 u=0, v=-1 u=1, v=-1 u=2, v=-1

u=-2, v=-2 u=-1, v=-2 u=0, v=-2 u=1, v=-2 u=2, v=-2

Note, buv and b-u,-v have similar frequencies but inverted shifts
Visualizing the Fourier Transform Image using Matlab
Routines
• F(u,v) is a Fourier transform of f(x,y) and it has complex entries.

F = fft2(f);
• In order to display the Fourier Spectrum |F(u,v)|
– Reduce dynamic range of |F(u,v)| by displaying the log:

D = log(1+abs(F));
– Cyclically rotate the image so that F(0,0) is in the center:
Example:
D = fftshift(D);
|F(u)| = 100 4 2 1 0 0 1 2 4
Display in Range([0..10]):
log(1+|F(u)|) = 4.62 1.61 1.01 0.69 0 0 0.69 1.01 1.61
log(1+|F(u)|)/0.0462 = 10 4 2 1 0 0 1 2 4
fftshift(log(1+|F(u)|) = 0 1 2 4 10 4 2 1 0
DFT Basis images

Real Imaginary
Original DFT

DFT plot
Properties of DFT
Relationship between spatial and frequency
intervals.
1
u 
Mx
1
v 
Ny
Where u &v are the sampling
frequency interval

x, y are spatial sampling interval


Separability
• 2D Fourier transformation has been
converted to two 1D Fourier
transformation.

• Operation becomes simpler

ux vy ux vy
kernel is  j 2 ( )  j 2 ( )  j 2 ( )
separable: e N
e N
e N
Translation
f(x,y) F(u,v)

• Translation in spatial domain:

• Translation in frequency domain:

)
N

Magnitude of fourier spectrum after translation remains same. Only


an additional phase difference is added.
Translation example
Translation
DFT Properties: Rotation
• Rotating f(x,y) by θ rotates F(u,v) by θ
DFT Properties: Periodicity
• The DFT and its inverse are periodic with
period N

|F(u)|

|F(u-N/2)|
DFT Properties: Symmetry

• If f(x,y) is real, then


DFT Properties: Addition/Multiplication
&
scaling

but …

1   u v 
f (ax  by)   F  ,  
ab   a b  
Average Value

N 1
F (0,0)   f ( x, y)
x , y 0

Average value of f is equal


to
F (0,0)
N2

You might also like