Download - CIS 350 – 4 The FREQUENCY Domain
![Page 1: CIS 350 – 4 The FREQUENCY Domain](https://reader036.vdocuments.net/reader036/viewer/2022062723/56813e8f550346895da8da60/html5/thumbnails/1.jpg)
CIS 350 – 4
The FREQUENCY Domain
Dr. Rolf Lakaemper
![Page 2: CIS 350 – 4 The FREQUENCY Domain](https://reader036.vdocuments.net/reader036/viewer/2022062723/56813e8f550346895da8da60/html5/thumbnails/2.jpg)
Some of these slides base on the textbook
Digital Image Processingby Gonzales/Woods
Chapter 4
![Page 3: CIS 350 – 4 The FREQUENCY Domain](https://reader036.vdocuments.net/reader036/viewer/2022062723/56813e8f550346895da8da60/html5/thumbnails/3.jpg)
Frequency Domain
So far we processed the image ‘directly’, i.e. the transformation was a function of the image itself.
We called this the SPATIAL domain.
So what’s the FREQUENCY domain ?
![Page 4: CIS 350 – 4 The FREQUENCY Domain](https://reader036.vdocuments.net/reader036/viewer/2022062723/56813e8f550346895da8da60/html5/thumbnails/4.jpg)
Sound
Let’s first forget about images, and look at SOUND.
SOUND: 1 dimensional function of changing (air-)pressure in time
Pre
ssur
e
Time t
![Page 5: CIS 350 – 4 The FREQUENCY Domain](https://reader036.vdocuments.net/reader036/viewer/2022062723/56813e8f550346895da8da60/html5/thumbnails/5.jpg)
Sound
SOUND: if the function is periodic, we perceive it as sound with a certain frequency (else it’s noise). The frequency defines the pitch.
Pre
ssur
e
Time t
![Page 6: CIS 350 – 4 The FREQUENCY Domain](https://reader036.vdocuments.net/reader036/viewer/2022062723/56813e8f550346895da8da60/html5/thumbnails/6.jpg)
Sound
The AMPLITUDE of the curve defines the VOLUME
![Page 7: CIS 350 – 4 The FREQUENCY Domain](https://reader036.vdocuments.net/reader036/viewer/2022062723/56813e8f550346895da8da60/html5/thumbnails/7.jpg)
Sound
The SHAPE of the curve defines the sound character
Flute String
Brass
![Page 8: CIS 350 – 4 The FREQUENCY Domain](https://reader036.vdocuments.net/reader036/viewer/2022062723/56813e8f550346895da8da60/html5/thumbnails/8.jpg)
Sound
How can the
SHAPE
of the curve be defined ?
![Page 9: CIS 350 – 4 The FREQUENCY Domain](https://reader036.vdocuments.net/reader036/viewer/2022062723/56813e8f550346895da8da60/html5/thumbnails/9.jpg)
Sound
Listening to an orchestra, you can distinguish between different instruments,
although the sound is aSINGLE FUNCTION !
Flute
String
Brass
![Page 10: CIS 350 – 4 The FREQUENCY Domain](https://reader036.vdocuments.net/reader036/viewer/2022062723/56813e8f550346895da8da60/html5/thumbnails/10.jpg)
Sound
If the sound produced by an orchestra is the sum of different instruments, could it be possible that there are BASIC SOUNDS,
that can be combined to produce every single sound ?
![Page 11: CIS 350 – 4 The FREQUENCY Domain](https://reader036.vdocuments.net/reader036/viewer/2022062723/56813e8f550346895da8da60/html5/thumbnails/11.jpg)
Sound
The answer (Charles Fourier, 1822):
Any function that periodically repeats itself can be expressed as
the sum of sines/cosines of different frequencies, each
multiplied by a different coefficient
![Page 12: CIS 350 – 4 The FREQUENCY Domain](https://reader036.vdocuments.net/reader036/viewer/2022062723/56813e8f550346895da8da60/html5/thumbnails/12.jpg)
Sound
Or differently:
Since a flute produces a sine-curve like sound, a (huge) group of
(outstanding) talented flautists could replace a classical
orchestra.
(Don’t take this remark seriously, please)
![Page 13: CIS 350 – 4 The FREQUENCY Domain](https://reader036.vdocuments.net/reader036/viewer/2022062723/56813e8f550346895da8da60/html5/thumbnails/13.jpg)
1D Functions
A look at SINE / COSINEThe sine-curve is defined by:
• Frequency (the number of oscillations between 0 and 2*PI)
• Amplitude (the height)
• Phase (the starting angle value)
• The constant y-offset, or DC (direct current)
![Page 14: CIS 350 – 4 The FREQUENCY Domain](https://reader036.vdocuments.net/reader036/viewer/2022062723/56813e8f550346895da8da60/html5/thumbnails/14.jpg)
1D Functions
The general sine-shaped function:
f(t) = A * sin(t + ) + c
Amplitude
Frequency
Phase
Constant offset(usually set to 0)
![Page 15: CIS 350 – 4 The FREQUENCY Domain](https://reader036.vdocuments.net/reader036/viewer/2022062723/56813e8f550346895da8da60/html5/thumbnails/15.jpg)
1D Functions
Remember Fourier:
…A function…can be expressed as the sum of sines/cosines…
What happens if we add sine and cosine ?
![Page 16: CIS 350 – 4 The FREQUENCY Domain](https://reader036.vdocuments.net/reader036/viewer/2022062723/56813e8f550346895da8da60/html5/thumbnails/16.jpg)
1D Functions
a * sin(t) + b * cos(t)
= A * sin(t + )
(with A=sqrt(a^2+b^2) and tan = b/a)
Adding sine and cosine of the same frequency yields just another sine function with different
phase and amplitude, but same frequency.
Or: adding a cosine simply shifts the sine function left/right and stretches it in y-direction. It does NOT change the
sine-character and frequency of the curve.
![Page 17: CIS 350 – 4 The FREQUENCY Domain](https://reader036.vdocuments.net/reader036/viewer/2022062723/56813e8f550346895da8da60/html5/thumbnails/17.jpg)
1D Functions
Remember Fourier, part II:
Any function that periodically repeats itself…
=> To change the shape of the function, we must add sine-like
functions with different frequencies.
![Page 18: CIS 350 – 4 The FREQUENCY Domain](https://reader036.vdocuments.net/reader036/viewer/2022062723/56813e8f550346895da8da60/html5/thumbnails/18.jpg)
1D Functions
This applet shows the result:
Applet: Fourier Synthesis
![Page 19: CIS 350 – 4 The FREQUENCY Domain](https://reader036.vdocuments.net/reader036/viewer/2022062723/56813e8f550346895da8da60/html5/thumbnails/19.jpg)
1D Functions
What did we do ?
• Choose a sine curve having a certain frequency, called the base-frequency
• Choose sine curves having an integer multiple frequency of the base-frequency
• Shift each single one horizontally using the cosine-factor
• Choose the amplitude-ratio of each single frequency
• Sum them up
![Page 20: CIS 350 – 4 The FREQUENCY Domain](https://reader036.vdocuments.net/reader036/viewer/2022062723/56813e8f550346895da8da60/html5/thumbnails/20.jpg)
1D Functions
This technique is called the
FOURIER SYNTHESIS,
the parameters needed are the sine/cosine ratios of each frequency.
The parameters are called theFOURIER COEFFICIENTS
![Page 21: CIS 350 – 4 The FREQUENCY Domain](https://reader036.vdocuments.net/reader036/viewer/2022062723/56813e8f550346895da8da60/html5/thumbnails/21.jpg)
1D Functions
As a formula:
f(x)= a0/2 + k=1..n akcos(kx) + bksin(kx)
Fourier Coefficients
![Page 22: CIS 350 – 4 The FREQUENCY Domain](https://reader036.vdocuments.net/reader036/viewer/2022062723/56813e8f550346895da8da60/html5/thumbnails/22.jpg)
Note:
The set of ak, bk TOTALLY defines the CURVE synthesized !
We can therefore describe the SHAPE of the curve or the
CHARACTER of the sound by the (finite ?) set of FOURIER
COEFFICIENTS !
1D Functions
![Page 23: CIS 350 – 4 The FREQUENCY Domain](https://reader036.vdocuments.net/reader036/viewer/2022062723/56813e8f550346895da8da60/html5/thumbnails/23.jpg)
Examples for curves, expressed by the sum of sines/cosines (the
FOURIER SERIES):
1D Functions
![Page 24: CIS 350 – 4 The FREQUENCY Domain](https://reader036.vdocuments.net/reader036/viewer/2022062723/56813e8f550346895da8da60/html5/thumbnails/24.jpg)
SAWTOOTH Function
1D Functions
f(x) = ½ - 1/pi * n 1/n *sin (n*pi*x)
Freq. sin cos
1 1 0
2 1/2 0
3 1/3 0
4 1/4 0
![Page 25: CIS 350 – 4 The FREQUENCY Domain](https://reader036.vdocuments.net/reader036/viewer/2022062723/56813e8f550346895da8da60/html5/thumbnails/25.jpg)
SQUARE WAVE Function
1D Functions
f(x) = 4/pi * n=1,3,5 1/n *sin (n*pi*x)
Freq. sin cos
1 1 0
3 1/3 0
5 1/5 0
7 1/7 0
![Page 26: CIS 350 – 4 The FREQUENCY Domain](https://reader036.vdocuments.net/reader036/viewer/2022062723/56813e8f550346895da8da60/html5/thumbnails/26.jpg)
What does the set of FOURIER COEFFICIENTS tell about the
character of the shape ?
(MATLAB Demo)
1D Functions
![Page 27: CIS 350 – 4 The FREQUENCY Domain](https://reader036.vdocuments.net/reader036/viewer/2022062723/56813e8f550346895da8da60/html5/thumbnails/27.jpg)
Result:
Steep slopes introduce HIGH FREQUENCIES.
1D Functions
![Page 28: CIS 350 – 4 The FREQUENCY Domain](https://reader036.vdocuments.net/reader036/viewer/2022062723/56813e8f550346895da8da60/html5/thumbnails/28.jpg)
Motivation for Image Processing:
Steep slopes showed areas of high contrast…
…so it would be nice to be able to get the set of FOURIER
COEFFICIENTS if an arbitrary (periodically) function is given.
(So far we talked about 1D functions, not images, this was just a motivation)
1D Functions
![Page 29: CIS 350 – 4 The FREQUENCY Domain](https://reader036.vdocuments.net/reader036/viewer/2022062723/56813e8f550346895da8da60/html5/thumbnails/29.jpg)
The Problem now:
Given an arbitrary but periodically 1D function (e.g. a sound), can you tell the FOURIER COEFFICIENTS
to construct it ?
1D Functions
![Page 30: CIS 350 – 4 The FREQUENCY Domain](https://reader036.vdocuments.net/reader036/viewer/2022062723/56813e8f550346895da8da60/html5/thumbnails/30.jpg)
The answer (Charles Fourier):
YES.
1D Functions
![Page 31: CIS 350 – 4 The FREQUENCY Domain](https://reader036.vdocuments.net/reader036/viewer/2022062723/56813e8f550346895da8da60/html5/thumbnails/31.jpg)
We don’t want to explain the mathematics behind the answer
here, but simply use the MATLAB Fourier Transformation Function.
Later we’ll understand what’s going on
1D Functions
![Page 32: CIS 350 – 4 The FREQUENCY Domain](https://reader036.vdocuments.net/reader036/viewer/2022062723/56813e8f550346895da8da60/html5/thumbnails/32.jpg)
MATLAB - function fft:
Input: A vector, representing the discrete function
Output: The Fourier Coefficients as vector of imaginary numbers,
scaled for some reasons
1D Functions
![Page 33: CIS 350 – 4 The FREQUENCY Domain](https://reader036.vdocuments.net/reader036/viewer/2022062723/56813e8f550346895da8da60/html5/thumbnails/33.jpg)
Example:
1D Functions
x=0:2*pi/(2047):2*pi;s=sin(x)+cos(x) + sin(2*x) + 0.3*cos(2*x);f=fft(s);
1.3 1026.2 - 1022.8i
310.1 - 1022.1i
-0.4 +
1.6i
Freq. 0 Freq. 1 Freq. 2 Freq. 3
cos
sin
![Page 34: CIS 350 – 4 The FREQUENCY Domain](https://reader036.vdocuments.net/reader036/viewer/2022062723/56813e8f550346895da8da60/html5/thumbnails/34.jpg)
1D Functions
Fr Re Im
0 1.3 0
1 1026.2 1022.8
2 310.1 1022.1
Fr Re Im
0 ~0 0
1 ~1 ~1
2 ~0.3 ~1
1.3 1026.2 - 1022.8i
310.1 - 1022.1i
-0.4 + 1.6i
Transformation: t(a) = 2*a / length(result-vector)
![Page 35: CIS 350 – 4 The FREQUENCY Domain](https://reader036.vdocuments.net/reader036/viewer/2022062723/56813e8f550346895da8da60/html5/thumbnails/35.jpg)
1D Functions
The fourier coefficients are given by:
F=fft(function)L=length(F); %this is always = length(function)
Coefficient for cosine, frequency k-times the base frequency:
real(F(k+1)) * 2 / L
Coefficient for sine, frequency k-times the base frequency:
imag(F(k+1)) * 2 / L
![Page 36: CIS 350 – 4 The FREQUENCY Domain](https://reader036.vdocuments.net/reader036/viewer/2022062723/56813e8f550346895da8da60/html5/thumbnails/36.jpg)
1D Functions
An application using the Fourier Transform:
Create an autofocus system for a digital camera
We did this already, but differently !
(MATLAB DEMO)
![Page 37: CIS 350 – 4 The FREQUENCY Domain](https://reader036.vdocuments.net/reader036/viewer/2022062723/56813e8f550346895da8da60/html5/thumbnails/37.jpg)
1D Functions
Second application:
Describe and compare 2-dimensional shapes using the Fourier Transform !
![Page 38: CIS 350 – 4 The FREQUENCY Domain](https://reader036.vdocuments.net/reader036/viewer/2022062723/56813e8f550346895da8da60/html5/thumbnails/38.jpg)
2D Functions
From Sound to Images:
2D Fourier Transform
![Page 39: CIS 350 – 4 The FREQUENCY Domain](https://reader036.vdocuments.net/reader036/viewer/2022062723/56813e8f550346895da8da60/html5/thumbnails/39.jpg)
2D Functions
The idea:Extend the base functions to 2
dimensions:
fu(x) = sin(ux)
fu,v(x,y) = sin(ux + vy)
![Page 40: CIS 350 – 4 The FREQUENCY Domain](https://reader036.vdocuments.net/reader036/viewer/2022062723/56813e8f550346895da8da60/html5/thumbnails/40.jpg)
2D Functions
Some examples:
The base function, direction x: u=1, v=0
y
x
![Page 41: CIS 350 – 4 The FREQUENCY Domain](https://reader036.vdocuments.net/reader036/viewer/2022062723/56813e8f550346895da8da60/html5/thumbnails/41.jpg)
2D Functions
The base function, direction y: u=0, v=1
![Page 42: CIS 350 – 4 The FREQUENCY Domain](https://reader036.vdocuments.net/reader036/viewer/2022062723/56813e8f550346895da8da60/html5/thumbnails/42.jpg)
2D Functions
u=2, v=0
![Page 43: CIS 350 – 4 The FREQUENCY Domain](https://reader036.vdocuments.net/reader036/viewer/2022062723/56813e8f550346895da8da60/html5/thumbnails/43.jpg)
2D Functions
u=0, v=2
![Page 44: CIS 350 – 4 The FREQUENCY Domain](https://reader036.vdocuments.net/reader036/viewer/2022062723/56813e8f550346895da8da60/html5/thumbnails/44.jpg)
2D Functions
u=1, v=1
![Page 45: CIS 350 – 4 The FREQUENCY Domain](https://reader036.vdocuments.net/reader036/viewer/2022062723/56813e8f550346895da8da60/html5/thumbnails/45.jpg)
2D Functions
u=1, v=2
![Page 46: CIS 350 – 4 The FREQUENCY Domain](https://reader036.vdocuments.net/reader036/viewer/2022062723/56813e8f550346895da8da60/html5/thumbnails/46.jpg)
2D Functions
u=1, v=3
![Page 47: CIS 350 – 4 The FREQUENCY Domain](https://reader036.vdocuments.net/reader036/viewer/2022062723/56813e8f550346895da8da60/html5/thumbnails/47.jpg)
2D Functions
As in 1D, the 2D image can be phase-shifted by adding a weighted cosine function:
fu,v(x,y) = ak sin(ux + vy) + bk cos(ux + vy)
+ =
![Page 48: CIS 350 – 4 The FREQUENCY Domain](https://reader036.vdocuments.net/reader036/viewer/2022062723/56813e8f550346895da8da60/html5/thumbnails/48.jpg)
2D Functions
As basic functions, we get a pair of sine/cosine functions for every pair of
frequency-multiples (u,v):
sin
cos
sin
cos
sin
cos
sin
cos
sin
cos
sin
cos
sin
cos
sin
cos
sin
cos
sin
cos
sin
cos
sin
cos
v
u
![Page 49: CIS 350 – 4 The FREQUENCY Domain](https://reader036.vdocuments.net/reader036/viewer/2022062723/56813e8f550346895da8da60/html5/thumbnails/49.jpg)
2D Functions
Every single sin/cos function gets a weight, which is the Fourier Coefficient:
a
b
a
b
a
b
a
b
v
u
a
b
a
b
a
b
a
b
a
b
a
b
a
b
a
b
![Page 50: CIS 350 – 4 The FREQUENCY Domain](https://reader036.vdocuments.net/reader036/viewer/2022062723/56813e8f550346895da8da60/html5/thumbnails/50.jpg)
2D Functions
Summing all basic functions with their given weight gives a new function.
As in 1D:Every 2D function can be synthesized using the
basic functions with specific weights.
As in 1D:The set of weights defines the 2D function.
![Page 51: CIS 350 – 4 The FREQUENCY Domain](https://reader036.vdocuments.net/reader036/viewer/2022062723/56813e8f550346895da8da60/html5/thumbnails/51.jpg)
2D Functions
Example:
Summing basic functions of different frequencies:
![Page 52: CIS 350 – 4 The FREQUENCY Domain](https://reader036.vdocuments.net/reader036/viewer/2022062723/56813e8f550346895da8da60/html5/thumbnails/52.jpg)
2D Functions
Example:
Summing basic functions of different frequencies:
![Page 53: CIS 350 – 4 The FREQUENCY Domain](https://reader036.vdocuments.net/reader036/viewer/2022062723/56813e8f550346895da8da60/html5/thumbnails/53.jpg)
2D Functions
MATLAB Demo: Bear Reconstruction