•Three shorter Midterms: Digital Signal Processingee123/sp14/Notes/Lecture09_Spect...Based on...
Transcript of •Three shorter Midterms: Digital Signal Processingee123/sp14/Notes/Lecture09_Spect...Based on...
M. Lustig, EECS UC Berkeley
EE123Digital Signal Processing
Lecture 9
based on slides by J.M. Kahn1
M. Lustig, EECS UC Berkeley
Announcements
• Lab 01 part I and II posted will post III today or tomorrow
• Lab-bash Tuesday 2-3pm 521 Cory • Three shorter Midterms:
– 02/26 in class– 04/02 in class– 04/30 (or 28 TBD) in class– 05/05 or 05/06 (TBD) project presentations.
• Posters and demos
2
M. Lustig, EECS UC Berkeley
Announcements
• Last time: –Frequency analysis with DFT–Windowing
• Today:– Continue – Effect of zero-padding– Start Short-time Fourier Transform
3
Windows Properties
These are characteristic of the window type
Window Main-lobe Sidelobe �s
Sidelobe �20 log10
�s
Rect4⇡
M + 10.09 21
Bartlett8⇡
M + 10.05 26
Hann8⇡
M + 10.0063 44
Hamming8⇡
M + 10.0022 53
Blackman12⇡
M + 10.0002 74
Most of these (Bartlett, Hann, Hamming) have a transition widththat is twice that of the rect window.
Warning: Always check what’s the definition of M
Adapted from A Course In Digital Signal Processing by Boaz Porat, Wiley, 1997
Miki Lustig UCB. Based on Course Notes by J.M Kahn Spring 2014, EE123 Digital Signal Processing
4
Windows Examples
Here we consider several examples. As before, the sampling rate is⌦s
/2⇡ = 1/T = 20 Hz.Rectangular Window, L = 32
0 5 10 15 20 25 300
0.2
0.4
0.6
0.8
1
1.2
n
w[n
]
Rectangular Window, L = 32
-20 -10 0 10 200
5
10
15
20
25
30
35
40
/2 (Hz)
|W(ejT)|
DTFT of Rectangular Window
0 5 10 15 20 25 30
-1.5
-1
-0.5
0
0.5
1
1.5
n
v[n]
Sampled, Windowed Signal, Rectangular Window, L = 32
-20 -10 0 10 200
5
10
15
20
/2 (Hz)
|V(ejT)|
DTFT of Sampled, Windowed Signal
Miki Lustig UCB. Based on Course Notes by J.M Kahn Spring 2014, EE123 Digital Signal Processing
Ω
ωT
ωT
5
Windows Examples
Triangular Window, L = 32
0 5 10 15 20 25 300
0.2
0.4
0.6
0.8
1
1.2
n
w[n
]
Triangular Window, L = 32
-20 -10 0 10 200
5
10
15
20
/2 (Hz)
|W(ejT)|
DTFT of Triangular Window
0 5 10 15 20 25 30
-1.5
-1
-0.5
0
0.5
1
1.5
n
v[n]
Sampled, Windowed Signal, Triangular Window, L = 32
-20 -10 0 10 200
2
4
6
8
/2 (Hz)
|V(ejT)|
DTFT of Sampled, Windowed Signal
Miki Lustig UCB. Based on Course Notes by J.M Kahn Spring 2014, EE123 Digital Signal Processing
ωT
ωT
6
Windows Examples
Hamming Window, L = 32
0 5 10 15 20 25 300
0.2
0.4
0.6
0.8
1
1.2
n
w[n
]
Hamming Window, L = 32
-20 -10 0 10 200
5
10
15
20
/2 (Hz)
|W(ejT)|
DTFT of Hamming Window
0 5 10 15 20 25 30
-1.5
-1
-0.5
0
0.5
1
1.5
n
v[n]
Sampled, Windowed Signal, Hamming Window, L = 32
-20 -10 0 10 200
2
4
6
8
10
/2 (Hz)
|V(ejT)|
DTFT of Sampled, Windowed Signal
Miki Lustig UCB. Based on Course Notes by J.M Kahn Spring 2014, EE123 Digital Signal Processing
ωT
ωT
7
M. Lustig, EECS UC Berkeley
Windows Examples
Hamming Window, L = 64
0 10 20 30 40 50 600
0.2
0.4
0.6
0.8
1
1.2
nw
[n]
Hamming Window, L = 64
-20 -10 0 10 200
5
10
15
20
25
30
35
40
/2 (Hz)
|W(ejT)|
DTFT of Hamming Window
0 10 20 30 40 50 60
-1.5
-1
-0.5
0
0.5
1
1.5
n
v[n]
Sampled, Windowed Signal, Hamming Window, L = 64
-20 -10 0 10 200
5
10
15
20
/2 (Hz)
|V(ejT)|
DTFT of Sampled, Windowed Signal
Miki Lustig UCB. Based on Course Notes by J.M Kahn Spring 2014, EE123 Digital Signal Processing
ωT
ωT
8
M. Lustig, EECS UC Berkeley
Optimal Window: Kaiser
• Minimum main-lobe width for a given side-lobe energy %
• Window is parametrized with L and β– β determines side-lobe level– L determines main-lobe width
Rsidelobes
|H(ej!)|2d!R ⇡�⇡ |H(ej!)|2d!
OS Eq 10.12
9
M. Lustig, EECS UC Berkeley
Exampley = sin(2⇡0.1992n) + 0.005 sin(2⇡0.25n) | 0 n < 128
10
M. Lustig, EECS UC Berkeley
Example
11
Zero-Padding
In preparation for taking an N-point DFT, we may zero-padthe windowed block of signal samples to a block length N � L:
(v [n] 0 n L� 1
0 L n N � 1
This zero-padding has no e↵ect on the DTFT of v [n], sincethe DTFT is computed by summing over �1 < n < 1.
E↵ect of Zero Padding
We take the N-point DFT of the zero-padded v [n], to obtainthe block of N spectral samples:
V [k], 0 k N � 1
Miki Lustig UCB. Based on Course Notes by J.M Kahn Spring 2014, EE123 Digital Signal Processing
12
Zero-Padding
Consider the DTFT of the zero-padded v [n]. Since thezero-padded v [n] is of length N, its DTFT can be written:
V (e j!) =N�1X
n=0
v [n]e�jn!, �1 < ! < 1
The N-point DFT of v [n] is given by:
V [k] =N�1X
n=0
v [n]W kn
N
=N�1X
n=0
v [n]e�j(2⇡/N)nk , 0 k N � 1
We see that V [k] corresponds to the samples of V (e j!):
V [k] = V (e j!)��!=k
2⇡N
, 0 k N � 1
To obtain samples at more closely spaced frequencies, wezero-pad v [n] to longer block length N. The spectrum is thesame, we just have more samples.
Miki Lustig UCB. Based on Course Notes by J.M Kahn Spring 2014, EE123 Digital Signal Processing
13
Frequency Analysis with DFT
Note that the ordering of the DFT samples is unusual.
V [k] =N�1X
n=0
v [n]W nk
N
The DC sample of the DFT is k = 0
V [0] =N�1X
n=0
v [n]W 0n
N
=N�1X
n=0
v [n]
The positive frequencies are the first N/2 samplesThe first N/2 negative frequencies are circularly shifted
((�k))N
= N � k
so they are the last N/2 samples. (Use fftshift to reorder)
Miki Lustig UCB. Based on Course Notes by J.M Kahn Spring 2014, EE123 Digital Signal Processing
14
Frequency Analysis with DFT Examples:
Hamming Window, L = 32, N = 32
0 5 10 15 20 25 30
-1.5
-1
-0.5
0
0.5
1
1.5
n
Zero
-Padded v
[n]
Sampled, Windowed Signal, Hamming Window, L = 32, Zero-Padded to N = 32
0 5 10 15 20 25 300
2
4
6
8
10
k
|V[k
]|
N-Point DFT of Sampled, Windowed, Zero-Padded Signal
0 5 10 15 200
2
4
6
8
10
/2 (Hz)
|V[k
]|,
|V(ejT)|
Spectrum of Sampled, Windowed, Zero-Padded Signal
|V(ej T)||V[k ]|,
k = k2 /NT
Miki Lustig UCB. Based on Course Notes by J.M Kahn Spring 2014, EE123 Digital Signal Processing
ωT
15
Frequency Analysis with DFT Examples:
Hamming Window, L = 32, Zero-Padded to N = 64
0 10 20 30 40 50 60
-1.5
-1
-0.5
0
0.5
1
1.5
n
Zero
-Padded v
[n]
Sampled, Windowed Signal, Hamming Window, L = 32, Zero-Padded to N = 64
0 10 20 30 40 50 600
2
4
6
8
10
k
|V[k
]|
N-Point DFT of Sampled, Windowed, Zero-Padded Signal
0 5 10 15 200
2
4
6
8
10
/2 (Hz)
|V[k
]|,
|V(ejT)|
Spectrum of Sampled, Windowed, Zero-Padded Signal
|V(ej T)||V[k ]|,
k = k2 /NT
Miki Lustig UCB. Based on Course Notes by J.M Kahn Spring 2014, EE123 Digital Signal Processing
ωT
16
000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000 00000000000 000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000
Rect window
iDFT20
17
000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000 00000000000 000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000
iDFT200
18
http://www.neuroradiologycases.com
A 40 yo pt with a history of lower limb weakness referred for mri screening of brain and whole spine for cord. MRI sagittal T2 screening of dorsal region shows a faint uniform linear high signal at the center of the cord. The signal abnormality likely to represent:
(1) Cord demyelination.(2) Syrinx (spinal cord disease).(3) Artifact.
Answer : Its an artifact, known as truncation or Gibbs artifact
19
Frequency Analysis with DFT
Length of window determines spectral resolution
Type of window determines side-lobe amplitude.(Some windows have better tradeo↵ betweenresolution-sidelobe)
Zero-padding approximates the DTFT better. Does notintroduce new information!
Miki Lustig UCB. Based on Course Notes by J.M Kahn Spring 2014, EE123 Digital Signal Processing
20
Potential Problems and Solutions
Potential Problems and Solutions
Problem Possible Solutions
1. Spectral error a. Filter signal to reduce frequency content above ⌦
s
/2 = ⇡/T .
from aliasing Ch.4 b. Increase sampling frequency ⌦
s
= 2⇡/T .
2. Insu�cient frequency a. Increase L
resolution. b. Use window having narrow main lobe.
3. Spectral error a. Use window having low side lobes.
from leakage b. Increase L
4. Missing features a. Increase L,
due to spectral sampling. b. Increase N by zero-padding v [n] to length N > L.
Miki Lustig UCB. Based on Course Notes by J.M Kahn Spring 2014, EE123 Digital Signal Processing
21
iSpectrum Example
22
M. Lustig, EECS UC Berkeley
Discrete Transforms (Finite)
• DFT is only one out of a LARGE class of transforms
• Used for:–Analysis–Compression–Denoising–Detection–Recognition–Approximation (Sparse)
Sparse representation has been one of the hottest research topics in the last 15 years in sp
23
• Spectrum of a bird chirping– Interesting,.... but...– Does not tell the whole story– No temporal information!
M. Lustig, EECS UC Berkeley
Example: Bird Chirp
Play Sound!
0 0.5 1 1.5 2 2.5
x 104
0
100
200
300
400
500
600
Hz
Spectrum of a bird chirp
No temporal information!
Miki Lustig UCB. Based on Course Notes by J.M Kahn Fall 2011, EE123 Digital Signal Processing
Example of spectral analysis
x[n]
n
24
• To get temporal information, use part of the signal around every time point
• Mapping from 1D ⇒ 2D, n discrete, w cont.
• Simply slide a window and compute DTFTM. Lustig, EECS UC Berkeley
Time Dependent Fourier Transform
X[n,!) =1X
m=�1x[n+m]w[m]e�j!m
*Also called Short-time Fourier Transform (STFT)
25
• To get temporal information, use part of the signal around every time point
M. Lustig, EECS UC Berkeley
Time Dependent Fourier Transform
X[n,!) =1X
m=�1x[n+m]w[m]e�j!m
*Also called Short-time Fourier Transform (STFT)
26
M. Lustig, EECS UC Berkeley
Spectrogram
Time, s
Fre
quency, H
z
2 4 6 8 10 12 14 16 180
1000
2000
3000
4000
0 500 1000 1500 2000 2500 3000 3500 4000 45000
5
10
15
20
25
30
Frequency, Hz
0 500 1000 1500 2000 2500 3000 3500 4000 45000
2
4
6
8
10
12
Frequency, Hz
0 500 1000 1500 2000 2500 3000 3500 4000 45000
5
10
15
20
25
30
Frequency, Hz
0 500 1000 1500 2000 2500 3000 3500 4000 45000
2
4
6
8
10
12
Frequency, Hz
27
Xr[k] =L�1X
m=0
x[rR+m]w[m]e�j2⇡km/N
M. Lustig, EECS UC Berkeley
Discrete Time Dependent FT
• L - Window length• R - Jump of samples • N - DFT length
• Tradeoff between time and frequency resolution
28
t
!
�t · �! � 1
2
�t
�!
M. Lustig, EECS UC Berkeley
Heisenberg Boxes
• Time-Frequency uncertainty principle http://www.jonasclaesson.com
29
�! =2⇡
N
�t = N
�! ·�t = 2⇡
M. Lustig, EECS UC Berkeley
DFT
X[k] =N�1X
n=0
x[n]e�j2⇡kn/N
!
tone DFT coefficient
30