You are on page 1of 42

Introduction to

Spectral
Techniques
Feb 11, 12, 2019
2

Spatial and Frequency Domain


• Spatial (time) domain techniques operate
directly on pixels
– Main advantage : they can be visualized easily
• Same operations can also be done in the
Frequency domain
– Based on the decomposition of image signals into sine and
cosine functions using the well-known Fourier transform
• Frequency domain deals with the frequency
components of the image
• Frequency domain techniques are based on
modifying the Fourier transform of an image
3

Spatial a
and
Frequency domain time domain frequency domain

b
d=a+b+c
d
time domain frequency domain

c
time domain frequency domain

time domain frequency domain


4

Spatial and Frequency Domain


• Spatial and Frequency domain are precisely
different representations of the same
information
• A change in the problem representation can
help solve problem faster
• Most of the image processing applications are
real time applications which require faster
algorithms
• The Frequency domain holds the key to the
requirements of speed and simplicity of
operations
• How?
5

Spatial and Frequency Domain

• In general, mathematical transforms are


required to convert the image data in the
spatial domain to frequency components in
the frequency domain

• Inverse transforms convert the results of


frequency domain manipulations back to the
original spatial domain for human observation
6

Spatial Frequencies in Image Processing


• The rate of change of pixel intensity of an image in
space
• It can be visualized using the line profile of the image
in any row or column
– Profile is a plot of the intensity of the pixels in a row or a column
(These intensity profiles  very useful in IP )

• These intensity profiles are a collection of either


sinusoidal signals or non-sinusoidal signals
– The high frequency components in the image are due to rapidly
changing data (e.g., edges); and
– The low frequency components are responsible for the contrast
and other large-scale features of the image
7

Types of Image Transforms

• Two categories of transforms available:


– Sinusoidal (orthogonal)
• Fourier Transform, Discrete Cosine Transform,
Discrete Sine Transform
• Fourier method is useful in converting a spatial
description of an image in terms of image frequency
components
– Non-Sinusoidal
• Uses basis functions non-Sinusoidal in nature
• Haar, Walsh, and Hadamard Transforms
8

Image Transforms: Practical Applications (1)


• Transforms convert spatial information to
frequency domain information, where certain
operations are easier to perform
– For ex: convolution operation can be reduced to matrix
multiplication in the frequency domain leading to
faster execution and efficient design of algorithms

• Transforms are very useful in gaining


valuable insight into concepts such as
sampling (discretization)
9

Image Transforms: Practical Applications (2)


• Property of energy preservation - the signal
energy is preserved
• Property of energy compaction - a large
fraction of the average energy of the image is
packed into a few components
– This uneven distribution of energy in the transformed image
results in many components having negligible energy
• This implied that most of the energy packed into a few
coefficients, resulting in more 0s and small nos.,
enabling better image compression, as 0s need not be
sent across the transmission channel
10

Image Transforms: Practical Applications (3)


• Spatial frequency transforms help in
assessing the image quality
• Frequency components indicate repetitive
noise patterns and also the presence/
absence of high/low/mid frequencies that
exist in an image
– A slight noise added to an image will result in a different
transform of the image

• Solution?
– To remove certain frequencies, set their corresponding F(u)
coefficients to zero! See how it can be done…
11

Joseph Fourier (1768-1830)


Fourier was obsessed with the physics of heat and developed
the Fourier transform theory to model heat-flow problems
• Had crazy idea (1807):
Any periodic function can be rewritten as a
weighted sum of Sines and Cosines of
different frequencies.
• Don‟t believe it?
– Neither did Lagrange, Laplace (his mentors), Poisson
and others; and his work not translated into English
until 1878!
• But it‟s true!
– called Fourier Series; Possibly the greatest tool
used in Engineering
During the past 50 years, entire industries and academic
disciplines have flourished as a result of Fourier’s ideas
12

Fourier Transform: Basic Ideas


 A periodic function can be represented by the sum of
sines/cosines functions of different frequencies, multiplied by a
different coefficient (Fourier Series)
 Non-periodic functions (whose area under the curve is finite) can
also be represented as the integral of sines/cosines multiplied by
weighing function (Fourier Transform)
13

Fourier Transform: A Review


• Both representations share the important
characteristics that a function, expressed in
either a Fourier series or Fourier Transform,
can be reconstructed completely via an inverse
process, with no loss of information

• This characteristics allow us to work in the


Fourier domain and then return to the original
domain of the function without losing any
information
14

Fourier Transform: Why?


• Mathematically, it is easy to analyze effects of
transmission medium, noise, etc. on simple sine/cos
functions, then add to get effect on complex signal
15

Fourier Transform: Some Observations


16

Fourier Transform: Some Observations


Approximating a square wave as the sum of
sine waves
17

It goes like this ….

Approximating a
square wave as
the sum of sine
waves
18

Fourier Transform: Example


• Removing undesirable frequencies

• To remove certain frequencies, set their


corresponding F(u) coefficients to zero!
19

We will be dealing only with

functions (images) of finite duration,

so the Fourier transform

is the tool in which we are interested


20

Sine and Cosine Functions (Recall)


has a value 1 at the origin and
performs exactly one full cycle b/w
the origin and the point x = 2π

The same is true for the


corresponding sine
function, except that its
value is zero at the origin

Amplitude of these functions is 1 as they oscillates b/w


peak values ±1
Multiplying by a constant „a‟ changes the peak values of
the function to ±a and its amplitude to „a‟
21

Frequency and Amplitude (Recall)


No. of oscillations of cos(x) over the distance T = 2π is 1
Thus, the value of angular frequency

Modify the function to


gives a compressed cosine wave that
oscillates 3 times faster than the
original function cos(x)
Performs 3 full cycles over a distance
of 2π, thus ω = 3

In general, function with amplitude „a‟


and angular frequency „ω‟

Relation b/w angular frequency


and the “common” frequency f:
22

Phase (Recall)
• In general, the function f(x-d) is the original
function f(x) shifted to the right by a distance „d‟
• Shifting a cosine function along the x-axis by a
distance :

changes the phase of the cosine wave, and φ


denotes the phase angle of the resulting function
• A sine function is just a cosine function shifted to
the right by a quarter period
• Taking cosine function with phase 0 as a reference,
the phase angle of the corresponding sine function
is
23

Phase
• Cosine and sine functions are “orthogonal” in a sense
that they can be used to create new “sinusoidal”
functions with arbitrary frequency, phase, and
amplitude

The resulting amplitude C and the phase angle are


defined as:

A = B = 0.5 and resulting = 450


24

Complex-valued Sine Functions and


Euler’s Notation

• Reminds the representation of real


and imaginary components of
complex nos
in the 2D plane and

• Euler‟s famous notation of complex nos along the unit


circle: is Euler no.
(can be derived from the well-known Taylor series)

• Complex notation makes it easy to combine orthogonal


pairs of sine functions with identical frequencies 𝜔
25

Fourier Series of Periodic Functions


• Can we decompose non-sinusoidal function into a
sum of cosine and sine functions ? Yes
• (Almost) any periodic function 𝑔(𝑥) with fundamental
frequency can be described as a sum of sinusoids

• This infinite sum is called a Fourier Series


• Summed sines and cosines are multiples of the
fundamental frequency (harmonics)
• 𝐴𝑘 and 𝐵𝑘 – Fourier coefficients
• Not known initially but derived from original function 𝑔(𝑥) during
Fourier analysis
26

Fourier Integral
• For non-periodic functions we can get similar
results by letting 𝑇  ∞
• Similar ideas yield Fourier Integral
– Integration of densely packed sines and cosines

where coefficients are again the weights for the corresponding


cosine and sine functions with (continuous) frequency 𝜔

Fourier Integral is the basis of the Fourier Spectrum


and the Fourier Transform …
27

Fourier Integral
reconstruct the original
function from its spectrum

compute the spectrum from a given function g(x)

• This representation of 𝑔(𝑥) involves infinitely many densely


spaced frequency values 𝜔, the corresponding coefficients are
continuous functions as well
• Fourier Spectrum - Continuous distribution of frequency
components contained in the original signal
• Fourier Integral describes the original function 𝑔(𝑥) as a sum of
infinitely many cosine and sine functions, with the corresponding
Fourier coefficients contained in the functions 𝐴(𝜔) and 𝐵(𝜔)
• A signal 𝑔(𝑥) is uniquely & fully represented by the corresponding
coefficient functions 𝐴(𝜔) and 𝐵(𝜔)
28

Fourier Transform
• Fourier Transform: Transition of function 𝑔(𝑥) to
its Fourier spectrum 𝐺(𝜔)

Also, check for other


common definitions of
the Fourier transform

• Inverse Fourier Transform: Reconstruction of


original function 𝑔(𝑥) from its Fourier spectrum 𝐺(𝜔)
• 𝑔(𝑥) and 𝐺(𝜔) constitute
Fourier transform pair
𝑔(𝑥) ↔ 𝐺(𝜔) or
29

The spectrum produced by the Fourier


transform is a new representative of the
signal in a space of frequencies.

Apparently, this “frequency space” and


the original “signal/image space” are
dual and interchangeable mathematical
representations.
30

Fourier Transform Pairs


(cosine and sine functions)

g(x) GRe(ω)

g(x) GRe(ω)
Cos 3x

g(x) GIm(ω)
Cos 5x

g(x) GIm(ω)
Sin 3x

Sin 5x
31

Fourier Transform Pairs


(Gaussian Functions and Rectangular Pulses)
g(x) GRe(ω)

g(x) GRe(ω)
σ=1

σ=3

g(x) GRe(ω)

b=1

2𝑏 sin(𝑏𝜔)
𝐺 𝜔 = b=2
2𝜋(𝑏𝜔)
32

Fourier Transform – Imp Properties

• Symmetry

• Linearity

• Similarity/Scaling

• Shift property

• Convolution property
Convolution in spatial domain
 Multiplication (pointwise) in frequency domain
33

Working with Discrete Signals

• Discrete Fourier Transform (DFT)

• How a continuous function can be


converted to a discrete signal?

• The process is called sampling


34

Sampling
• A continuous function 𝑓(𝑥) is discretized as:
{ f ( x0 ), f ( x0  x), f ( x0  2x),..., f ( x0  (M  1)x)}

{ f (0), f (1), f (2),..., f (M  1)}

M samples from continuous function


They are taken at
equally spaced,
but otherwise
arbitrary points
x0  1st arbitrary
located point in
the sequence
35

Impulse Function
∞ if 𝑥 = 0
𝛿 𝑥 =
0 if 𝑥 ≠ 0

Sampling with Impulse Function


Shifting
property of
impulse

The continuous
signal g(x) is
sampled at
position x0 = 3

sum of pulse
shifted sequence or
impulses pulse train
36

Sampling with Comb Function


Extending this pulse train to infinity in both directions,
gives the “comb” or “Shah” function
The process of discretizing a continuous
function by taking samples at regular
integral intervals:

The function value g(x) is


transferred to the resulting
function ḡ(x) only at integral
positions x = xi ∈ ℤ

To take samples at regular but


arbitrary intervals 𝜏, the
sampling function is simply
scaled along the time/space axis:
37

Effects of Sampling in Frequency Space

Comb Function and its Fourier Transform

Note that the actual height of


the 𝛿-pulses is undefined and
shown only for illustration.
38

Effects of Sampling in Frequency Space


What happens to the Fourier spectrum during discretization ?
(when we multiply a function in signal space by comb function )
Remember convolution property …

Fourier spectrum of the sampling function is a comb function again


and therefore consists of a sequence of regularly spaced pulses
Also,
• Convolving an arbitrary function with the impulse returns the
original function;
• Convolving with a shifted pulse also reproduces the original
function, though shifted by the same distance
39

Aliasing and the Sampling Theorem

As a consequence, the spectrum 𝐺 𝜔 of the original continuous


signal becomes replicated (with a period 2𝜋⁄𝜏) in the Fourier
spectrum of 𝐺 (𝜔) of a sampled signal at every pulse of the sampling
function‟s spectrum; i.e., infinitely many times.
As long as spectral replicas in
𝐺 (𝜔) do not overlap, the original
spectrum 𝐺 𝜔 , and hence the
original continuous function can
be reconstructed without loss
from any replica of 𝐺 𝜔 in the
periodic spectrum 𝐺 (𝜔).
The maximum allowed signal
(𝑔(𝑥)) frequency depends on the
sampling frequency used to
discretize the signal
Spectral effects of sampling
40

Discrete and Periodic Functions

The signals and spectra given here


are for illustration purpose only. They
do not really correspond each other
41

Discrete Signals
• If a continuous signal 𝑔(𝑥) is
sampled at regular intervals 𝜏, then
the corresponding Fourier spectrum
becomes periodic with a period of
length 𝜔𝑠 = 2𝜋 𝜏
• Sampling in signal space leads to
periodicity in frequency space and
vice versa
• Image is a 2D function!
– For discrete functions we need only finite
number of sequences
– Ex: consider the discrete sequence
1, 1, 1, 1, -1, -1, -1, -1, -1
It is discrete approximation of square wave
References
• Digital Image Processing - An
Algorithmic Introduction using Java by
Dr. Wilhelm Burger and Dr. Mark J. Burge
• R. C. Gonzalez and R. E. Woods, Digital
Image Processing, Third Edition,
Pearson, 2012.
• Computer Vision course by Dr. S.
Narasimhan

You might also like