Introduction
Ghassan Hamarneh
hamarneh@sfu.ca
We examined signals with real values at different
times, e.g., f ( n ) = [… 0 0 1 4 3 (1) 9 0 … ].
The values could also be complex, e.g.
f(1) = 5+4j
where j = i = sqrt(-1)
f ( 4 ) = - 4.3021
In addition to examining a value of a signal at a
particular time, we can examine a value at a
particular spatial location.
We will now examine a new representation where
we measure the “value” of the signal at a particular
“frequency”.
1
Ghassan Hamarneh
hamarneh@sfu.ca
2
Introduction
Ghassan Hamarneh
hamarneh@sfu.ca
Why study the Fourier Domain?
• Provides different view of signals that allows for
new insights and understanding.
• Important for deriving the sampling theorem,
which is critical for guiding data collection.
• Used in many applications, e.g., creating MRI
images, filtering/enhancing (bio)signals and
images, telecommunications, digital signal
processing in electronic devices for all sorts of
applications, solving mathematical problems, etc.
• Basis for understanding other transforms, e.g.
Laplacian transform and z-transform.
3
Waves
Ghassan Hamarneh
hamarneh@sfu.ca
Mechanical waves
https://www.physicsclassroom.com/
image copyright:
http://intothecontinuum.tu
mblr.com/post/2916063883
5/is-it-possible-to-visualize3-dimensional-standing
3D propagation
of wave
Sound wave
https://brilliant.org/practice/waves-1/
Electromagnetic
wave
https://en.wikipedia
.org/wiki/Electroma
gnetic_radiation
https://giphy.com/gifs/waveslongitudinal-transverseog52So0BUmZVe
4
Frequency
Ghassan Hamarneh
hamarneh@sfu.ca
Spring
motion
Hz
Human cochlea: hearing sound waves
nanometer
Spectral sensitivities of human cone cells
5
Wave & Frequency
Temporal sine wave
wavelength = speed / freq.
frequency (cycles per second)
Hertz (Hz)
Amplitude
speed = distance / time
Asin(2π ft + φ )
time
Radian frequency
ω = 2 π f (rad/sec)
distance
Acos(2π fx + φ )
Period
= wavelength / P
= wavelength * f
Phase (radians)
Spatial cosine signal
(cycles per meter)
Ghassan Hamarneh
hamarneh@sfu.ca
π radians = 180 degrees
P=1/f
6
Fourier Transform
Ghassan Hamarneh
hamarneh@sfu.ca
Joseph Fourier
1768- 1830
• Fourier Domain
not spatial or temporal
• Signals (1D, 2D, …) decomposed into sum
of sine or cosine signals with different
amplitudes, frequencies, phases
desired
signal
7
Fourier Transform
Ghassan Hamarneh
hamarneh@sfu.ca
Fourier transform describes (informally)
“how much” of “each frequency” does the signal contain
frequency: cycles or repetition per unit time or per unit length
Value
s(t)
Contribution,
power,
energy,…
S(f)
Time
1D
Fourier
transform
Frequency f
8
Fourier Transform
Ghassan Hamarneh
hamarneh@sfu.ca
• Given a 1D signal s(t), how do we find “how much” of
frequency fi does the signal contain?
• Calculate “similarity” of s(t) to sinusoids with different
frequency fi = {f1 ,f2, f3, …}
“Similarity”
f1
s(t)
f2
Frequency f
f3
Time
f4
f5
f6
f7
9
Signal Similarity
r=[2 2 5]
q=[5 2 2]
•
s=[2 3 6]
•
dot product between s & a = s1a1+s2a2+s3a3 = len(s)*len(a)*cos(angle(s,a))
b=[0 1 0] c=[0 0 1]
len(s)=sqrt(2^2+3^2+6^2) = 7
len(r)=sqrt(2^2+2^2+5^2) = 5.74
len(q)=sqrt(5^2+2^2+2^2) = 5.74
len(a)=len(b)=len(c)=1
•
Inner product between
•
angle between:
•
•
a=[1 0 0]
Ghassan Hamarneh
hamarneh@sfu.ca
s
r
s and a = 2*1+3*0+6*0=2
s and b = 2*0+3*1+6*0=3
s and c = 2*0+3*0+6*1=6
s and r = 2*2+3*2+6*5=40
s and q = 2*5+3*2+6*2=28
s and a = acos(2 / [ 7*1] )=1.281 rad = 73.4 deg
s and b = acos(3 / [ 7*1] )=1.128 rad = 64.62 deg
s and c = acos(6 / [ 7*1] )=0.541 rad = 31.0 deg
s and r = acos(40/ [7*5.74])*180/pi = 5.89 deg
s and q = acos(32/[7*5.74])*180/pi = 37.21 deg
1D signals can be represented as vectors
Similarity between signals:
proportional to cos(angle between signals)
inversely proportional to angle between signals
proportional to dot product between signals
c
q
b
a
10
Basis Functions
Ghassan Hamarneh
hamarneh@sfu.ca
(x1,x2,x3,….)
11
Basis Functions
Ghassan Hamarneh
hamarneh@sfu.ca
(x1,x2,x3,….)
12
Fourier Transform
Ghassan Hamarneh
hamarneh@sfu.ca
• Calculate “similarity” of s(t) to sin ( 2π fi t )
– At each t multiply s(t) by sin ( 2π fi t ), then add up all the values for all t’s
– Larger value è more similar
"similarity between s(t) and sin(2π ft)" =
( )
( )
( )
()
( )
... + s t−2 sin(2π ft −2 ) + s t−1 sin(2π ft −1 ) + s t0 sin(2π ft 0 ) + s t1 sin(2π ft1 ) + s t2 sin(2π ft 2 ) + ...
∞
( )
()
similarity f = ∑ s t sin(2π ft)
t=−∞
( )
()
X ( f ) = ∫ s (t ) cos(2π ft) dt ± j ∫ s (t ) sin(2π ft) dt
( )
∞
()
X f = ∫ s t sin(2π ft) dt
−∞
?
∞
X f = ∫ s t cos(2π ft) dt
−∞
∞
∞
−∞
−∞
13
Ghassan Hamarneh
hamarneh@sfu.ca
Frequency Analysis of
Continuous-Time Signals: Aperiodic Case
( )
∞
∞
()
()
X f = ∫ s t cos(2π ft) dt ± j ∫ s t sin(2π ft) dt
−∞
−∞
e jφ = cos φ + j sin φ
()
()
⎧Analysis equation
⎪
⎪ direct transfrom
Fourier Transfrom ⎨
⎪Synthesis equation
Very similar pair of
⎪⎩ inverse
equations è Duality
transfrom
What applies one way
(time à frequency)
typically applies the
other way
(freq. à time)
e jf - e- jf
sin (f ) =
2j
Euler Formula
( )
∞
()
X f = ∫ x t e− j 2π ft dt
()
−∞
∞
( )
x t =∫ X f e
−∞
e jf + e- jf
cos (f ) =
2
j 2 π ft
dF
14
Fourier Transform
Ghassan Hamarneh
hamarneh@sfu.ca
2D sinusoid
sin(2π f x x + 2π f y y)
=
15
Ghassan Hamarneh
hamarneh@sfu.ca
Basis Functions
(x1,x2,x3,….)
16
Ghassan Hamarneh
hamarneh@sfu.ca
Fourier Transform – sines/cosines
cos(0x+0y)
cos(0x+1y)
cos(0x+4y)
cos(1x+0y)
cos(2x+3y)
cos(4x+0y)
i=1; for fx=0:4, for fy=0:4,
subplot(5,5,i);
h=ezsurf(['cos(',num2str(fx),'*x +',num2str(fy),' *y)'],200);
i=i+1; drawnow; axis off; colormap gray;set(h,'linestyle','none');
end; end
17
cos(4x+4y)
Ghassan Hamarneh
hamarneh@sfu.ca
Fourier Transform
Higher Dimensions
()
s t
∞
( )
∞
()
()
S f = ∫ s t cos(2π ft) dt − j ∫ s t sin(2π ft) dt
( )
−∞
−∞
s x, y
∞
−∞
−∞
−∞
∫ s ( x, y ) cos(2π f x + 2π f y) dx dy − j...
( )
s ( x, y, z )
S ( f , f , f ) = ∫∫∫ s ( x, y, z ) cos(2π ( f x + f y + f z ))dxdy − j...
S fx, f y = ∫
x
y
z
x
x
written using Euler Formula: e
y
y
z
(
− j 2 π f x x+ f y y+ f z z
)
18
Aperiodic/Periodic and
Continuous/Discrete signals
Ghassan Hamarneh
hamarneh@sfu.ca
Note the horizontal axis could be time or frequency
19
Important signals
constant
train of pulses
f
Ghassan Hamarneh
hamarneh@sfu.ca
f
f
f
rectangular pulse
impulse at zero
f
f
f
f
f
f
sinusoid
sinc
f
f
20
Fourier Transform
Ghassan Hamarneh
hamarneh@sfu.ca
Aperiodic (A) ↔ Continuous (C)
Periodic (P) ↔ Discrete (D)
E.g. a continuous (C)
and periodic (P) time
signal will have a (càA)
Aperiodic and (PàD)
Discrete Fourier
representation
Time à Fourier
AC è CA
AD è CP
PC è DA
PD è DP
Fourier à Time
AC è CA
AD è CP
PC è DA
PD è DP
21
Fourier Transform
Making a signal slower in time
Signal taking longer time
Stretching a signal in time
Ghassan Hamarneh
hamarneh@sfu.ca
Lower frequency
content
Frequency domain
representation
shrinking or
compressing
22
Fourier Transform
Ghassan Hamarneh
hamarneh@sfu.ca
ω=2πf axis
for f, divide by 2π
• A cosine signal has a single frequency, so
Fourier is just an impulse at that frequency
• Slower cosine (stretched) implies lower
frequency, single impulse in the Fourier
domain will move closer to zero frequency
• PCèAD: The cosine is Periodic and
Continuous, so (remember AC,PD) the
Fourier will be Aperiodic and discrete
23
Fourier Transform
•
•
•
Ghassan Hamarneh
hamarneh@sfu.ca
A constant signal does not change in time, so it is not similar to any sinusoid
except the one with zero frequency, hence the Fourier of a constant is an
impulse at zero frequency.
Imagine any signal in time with some Fourier transform. Then imagine you
infinitely stretch the time signal, i.e., make it infinitely slow, until it becomes
a a constant. It’s Fourier will compress until it becomes just an impulse at
zero.
PCè DA.
Continuous in time è Aperiodic in frequency.
Periodic in time (repetitive) è Discrete in frequency
stretch in time
compress in frequency
24
Fourier Transform
Ghassan Hamarneh
hamarneh@sfu.ca
• PD è DP: A train of impulses is Discrete and Periodic in time,
so it’s Fourier is Periodic and Discrete in frequency.
• If the train of impulses is slower in time (i.e., stretch), it will
shrink in frequency.
• The spacing between impulses in time is T (sec), the spacing
between impulses in frequency is f=1/T (Hz) (or w=2pi/T
rad/sec).
25
Fourier Transform
Ghassan Hamarneh
hamarneh@sfu.ca
• AC è CA. The Sinc function (sin(x)/x) is Aperiodic
and Continuous, so its Fourier is Continuous and
Aperiodic.
• If the sinc gets narrower (faster in time), Fourier
will stretch in frequency.
• Width of rectangle in frequency is 2B Hz. First zero
crossing of Sinc is at 1/(2B) sec.
26
Duality
Ghassan Hamarneh
hamarneh@sfu.ca
• AC-PD
- Continuous signal has aperiodic Fourier transform
Aperiodic signal has continuous Fourier.
- Discrete signal has periodic Fourier
Periodic signal has discrete Fourier
• A constant signal in time has an impulse as its FT
An impulse signal has a constant FT
• Rectangular pulse in time è Sinc in frequency
Sinc in frequency è Rectangular pulse in time
2B rectangle width (time of frequency) è
First zero of sinc (frequency or time) is at 1/(2B)
Linearity
Ghassan Hamarneh
hamarneh@sfu.ca
• If you multiply the signal by a constant K, the Fourier
transform of the signal will be multiplied by the same
constant
• The Fourier transform of a sum of signals is the sum
of their Fourier transforms
• If x(t) = A g(t) + B h(t) then
Fourier transform of x(t) is
X(f) = A G(f) + B H(f)
where
G(f) is the Fourier transform of g(t),
H(f) is the Fourier transform of h(t), and
A and B are scalar constants
Ghassan Hamarneh
hamarneh@sfu.ca
Discrete-Time and Discrete Fourier
cont. in time, aperiodic in freq.
aperiodic in time, cont. in freq.
AC ßà CA
Discrete Fourier Transform
discrete in time, periodic in freq.
periodic in time, periodic in freq.
DP ßàPD
( )
∞
()
X f =∫ x t e
()
−∞
N −1
()
X k = ∑x n e
n=0
Discrete samples:
sample 0,1,…,n,…,N-1
− j 2 π ft
dt
k
− j 2π n
N
Discrete frequencies:
0/N,1/N, 2/N, …., k/N,…
29
Fourier Series (FS)
Fourier Transform (FT)
Ghassan Hamarneh
hamarneh@sfu.ca
For x(t) of duration T, set ω0 = 2π
T .
x(t) : 0 ≤ t ≤ T
X[k] : k = . . . , 2, 1, 0, 1, 2, . . .
PC in time
DA in frequency
X[k] =
x(t) =
1
T
" T
x(t) :
X(ω) :
X(ω) =
∞< t < ∞
∞< ω < ∞
" ∞
t= ∞
x(t) e jkω0 t dt
t=0
x(t) =
∞
!
x(t) e jωt dt
X[k] ejkω0 t
1
2π
" ∞
AC in time
CA in frequency
X(ω) ejωt dω
ω= ∞
k= ∞
What is the Fourier value at frequency 0? Substitute w=0 or k=0 è sum or integral of signal.
Discrete Fourier Transform (DFT)
Discrete-Time Fourier Transform
(DTFT)
For x[n] of length N, set ω0 = 2π
N .
x[n] : n = 0, 1, . . . , N
X[k] : k = 0, 1, . . . , N
PD in time
DP in frequency
X[k] =
N
!1
1
1
x[n] : n = . . . , 2, 1, 0, 1, 2, . . .
X(ω) :
π≤ω≤ π
X(ω) =
x[n] e jkω0 n
∞
!
n= ∞
n=0
1 !
X[k] ejkω0 n
N
N 1
x[n] =
x[n] e jωn
x[n] =
1
2π
" π
AD in time
CP in frequency
X(ω) ejωn dω
ω= π
k=0
Source https://www.princeton.edu/~cuff/ele201/kulkarni_text/frequency.pdf
Figure 4.5: Definitions of the forward and inverse Fourier transforms in each of
the four cases.
30
Ghassan Hamarneh
hamarneh@sfu.ca
()
N −1
()
X k = ∑x n e
n=0
− j 2π
k
n
N
MATLAB arrays
Index of first element is 1
A(0) è error
A(1) è first entry of A
0,1,…,N-1 è 1,2,…N
n è n-1
kè k-1
31
Ghassan Hamarneh
hamarneh@sfu.ca
%% Fourier Transform of triangular pulse
syms x t w X
tau = 1;
s = (1-2*abs(t)/tau); % signal from -tau/2 to tau/2
ezplot(s , [-tau/2 , tau/2]);
S = int( s *exp(-1i*w*t),t,-tau/2,tau/2);
ezplot(S,[-30,30,-0.2,0.8]);
1 - 2 abs(t)
0.8
1
-(4 (cos(w/ 2) - 1))/w 2
0.7
0.9
0.6
0.8
0.5
0.7
0.6
0.4
0.5
0.3
0.4
0.2
0.3
0.1
0.2
0.1
0
0
-0.1
-0.5
-0.4
-0.3
-0.2
-0.1
0
0.1
0.2
0.3
0.4
0.5
t
%% Fourier Transform of rectangular pulse
s = '1'; % signal from -tau/2 to tau/2
ezplot(s , [-tau/2 , tau/2]);
S = int( 1 *exp(-1i*w*t),t,-tau/2,tau/2);
ezplot(S,[-30,30,-0.5,1]);
-0.2
-30
-20
-10
0
10
20
30
w
(2 sin(w/ 2))/w
1
1
2
1.8
1.6
0.5
1.4
1.2
1
0
0.8
0.6
0.4
32
0.2
0
-0.5
-0.4
-0.3
-0.2
-0.1
0
x
0.1
0.2
0.3
0.4
0.5
-0.5
-30
-20
-10
0
w
10
20
30
Ghassan Hamarneh
hamarneh@sfu.ca
33
Fourier(t)
signal (t)
Match left with right
Ghassan Hamarneh
hamarneh@sfu.ca
34
Match left with right
s1
Ghassan Hamarneh
hamarneh@sfu.ca
Low frequencies.
No dominant
frequency (no peeks)
s2
s3
s4
These two are a mix
of two sinusoids (two
peaks). s5 has a
strong low freq.
FT{rect}= sinc
one is slower, and
one is faster
s5
35
Ghassan Hamarneh
hamarneh@sfu.ca
36
Ghassan Hamarneh
3 cycles
hamarneh@sfu.ca
per sec
1 and 5:
single
frequency.
shifted up. Its sum is not zero
map to d vs
e? Find the
difference.
2 is the fastest
changing. So
which Fourier?
faster freq. (2Hz) is stronger
3 vs 4 map
to b vs c?
Two
frequencies
1 and 2 Hz.
Which
frequency
is the
stronger?
2 cycles per
second
non-zero FT at f=0 ⟺
signal has a non-zero sum
or area under the curve
37
Ghassan Hamarneh
hamarneh@sfu.ca
38
Introduction
Ghassan Hamarneh
hamarneh@sfu.ca
When we opened the biosignal/image data files and loaded the data,
we obtained arrays/tensors of numbers, e.g., size D1xD2 = 3x1024.
We worked with a finite number of samples along discrete points in
space and/or time. We defined operations on these signals, e.g.,
convolution.
In the physical world (not digital), the signals are continuous.
Measurements of physical properties (e.g., temperature, pressure, and
voltage, concentration) may be made at any location in space or time.
We also learned that we could represent signals in the Fourier domain
to captures their underlying frequencies (changes as cycles per unit
time, or per unit distance along x, y, z).
Next, we will examine how the Fourier representation, along with the
convolution operation, allow us to derive the rules governing
discretizing continuous signals, i.e., the Sampling Theorem.
A key to this derivation is another Fourier Transform duality property.
39
Ghassan Hamarneh
hamarneh@sfu.ca
40
Ghassan Hamarneh
hamarneh@sfu.ca
Fourier Transform Properties
• Aperiodic ↔ Continuous
• Periodic ↔ Discrete
• Shrinking in one domain ↔ stretching in the other
• Rectangular pulse ↔ Sinc
• Impulse ↔ constant
• Comb (train of impulses) ↔ Comb (train of impulses)
• Multiplication ↔ Convolution
41
Ghassan Hamarneh
hamarneh@sfu.ca
Convolution-Multiplication Duality
• Convolution in “one domain” is a multiplication in the “other”
• Convolution in the spatial/termporal domain ↔
Multiplication in the frequency domain (and vice versa)
• To convolve signal s(t) with signal h(t) to obtain g(t):
1)
2)
3)
4)
Take FT of s(t) è S(f)
Take FT of h(t) è H(f)
Multiply S(f) by H(f). This gives FT of g(t), i.e. gives G(f)
Take inverse FT of G(f) to obtain g(t)
• s(t)⊛h(t) = g(t) ↔ S(f)H(f)=G(f)
• FT(s(t)⊛h(t)) = S(f)H(f)
(where FT(s)=S, FT(h)=H, FT(g)=G)
42
Ghassan Hamarneh
hamarneh@sfu.ca
FT
F
If
x1 ( n ) ↔ X 1 ( w)
FT
z
and
FT
F
x2 ( n ) ↔ X 2 ( w )
then x ( n ) = x1 ( n ) ∗ x2 ( n ) ↔ X ( w) = X 1 ( w) X 2 ( w)
43