Digital Signal Processing - University of California, …ee123/fa12/Notes/Lecture09.pdf ·...

13
M. Lustig, EECS UC Berkeley EE123 Digital Signal Processing Lecture 9 1 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 2 • Spectrum of a bird chirping – Interesting,.... but... – Does not tell the whole story – No temporal information! M. Lustig, EECS UC Berkeley 0 0.5 1 1.5 2 2.5 x 10 4 0 100 200 300 400 500 600 Hz Spectrum of a bird chirp Example of spectral analysis x[n] n 3 • 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 DTFT M. Lustig, EECS UC Berkeley Time Dependent Fourier Transform X [n, !)= 1 X m=-1 x[n + m]w[m]e -j !m *Also called Short-time Fourier Transform (STFT) 4

Transcript of Digital Signal Processing - University of California, …ee123/fa12/Notes/Lecture09.pdf ·...

M. Lustig, EECS UC Berkeley

EE123Digital Signal Processing

Lecture 9

1

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

2

• 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

3

• 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)

4

• 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)

5

M. Lustig, EECS UC Berkeley

Spectrogram

Time, s

Fre

qu

en

cy,

Hz

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

6

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

7

M. Lustig, EECS UC Berkeley

Discrete Transforms (Finite)

• Today:– Start with DFT ⇒ Frequency only

– Short-time DFT ⇒ Time-Frequency

– Wavelets ⇒ More flexible/better Time-frequency

–Wavelets ⇒ Sparsity ⇒ ⇒ Compression ⇒ denoising ⇒ approximation

8

t

!

�t · �! � 1

2

�t

�!

M. Lustig, EECS UC Berkeley

Heisenberg Boxes

• Time-Frequency uncertainty principle http://www.jonasclaesson.com

9

�! =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

10

X[r, k] =L�1X

m=0

x[rR+m]w[m]e�j2⇡km/N

�! =2⇡

L

�t = L

M. Lustig, EECS UC Berkeley

Discrete STFT

optional

!

tone STFT coefficient

11

x[rR+m]wL[m] =1

N

N�1X

k=0

X[n, k]ej2⇡km/N

M. Lustig, EECS UC Berkeley

STFT Reconstruction

• For non-overlapping windows, R=L :

• What is the problem?

x[n] =x[n� rL]

wL[n� rL]

rL n (r + 1)R� 1

12

x[rR+m]wL[m] =1

N

N�1X

k=0

X[n, k]ej2⇡km/N

M. Lustig, EECS UC Berkeley

STFT Reconstruction

• For non-overlapping windows, R=L :

• For stable reconstruction must overlap window 50% (at least)

x[n] =x[n� rL]

wL[n� rL]

rL n (r + 1)R� 1

13

M. Lustig, EECS UC Berkeley

STFT Reconstruction

• For stable reconstruction must overlap window 50% (at least)

• For Hann, Bartlett reconstruct with overlap and add. No division!

14

M. Lustig, EECS UC Berkeley

Applications

• Time Frequency Analysis

Spectrogram of FM radio

t=0 t=2sec

88.5

88.6

88.4

15

M. Lustig, EECS UC Berkeley

Applications

• Time Frequency Analysis

Spectrogram of Demodulated FM radio (Adele on 96.5 MHz)

0

19KHz

38KHz

57KHz

16

M. Lustig, EECS UC Berkeley

Applications

• Time Frequency Analysis

Spectrogram of digital communications - Frequency Shift Keying

t=0 t=1sec

17

Time, s

Fre

quency, H

z

1 2 3 4 5 6 7 80

1000

2000

3000

4000

M. Lustig, EECS UC Berkeley

Applications

• Time Frequency Analysis

Spectrogram of Orca whale

18

M. Lustig, EECS UC Berkeley

Applications

• Noise removal

• Recall bird chirp x[n]

n

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

19

M. Lustig, EECS UC Berkeley

Application

• Denoising of Sparse spectrograms

• Spectrum is sparse! can implement adaptive filter, or just threshold!

Time, s

Fre

quency, H

z

2 4 6 8 10 12 14 16 180

1000

2000

3000

4000

20

M. Lustig, EECS UC Berkeley

Limitations of Discrete STFT

• Need overlapping ⇒ Not orthogonal

• Computationally intensive O(MN log N)

• Same size Heisenberg boxes

21

M. Lustig, EECS UC Berkeley

From STFT to Wavelets

• Basic Idea:–low-freq changes slowly - fast tracking unimportant–Fast tracking of high-freq is important in many apps.–Must adapt Heisenberg box to frequency

• Back to continuous time for a bit.....

22

�t

�!Sf(u,⌦) =

Z 1

�1f(t)w(t� u)e�j⌦tdt

Wf(u, s) =

Z 1

�1f(t)

1ps ⇤(

t� u

s)dt

u

M. Lustig, EECS UC Berkeley

From STFT to Wavelets

• Continuous time�t

�!

u

�t

�!

*Morlet - Grossmann

23

Z 1

�1| (t)|2dt = 1

Z 1

�1 (t)dt = 0

M. Lustig, EECS UC Berkeley

From STFT to Wavelets

• The function is called a mother wavelet–Must satisfy:

Wf(u, s) =

Z 1

�1f(t)

1ps ⇤(

t� u

s)dt

⇒ Band-Pass

⇒ unit norm

24

w(t� u)ej⌦t1ps (

t� u

s)

s = 1

⌦lo

s = 3

M. Lustig, EECS UC Berkeley

STFT and Wavelets “Atoms”

STFT Atoms Wavelet Atoms

u u

⌦hi

u u

25

• Mexican Hat

• Haar

M. Lustig, EECS UC Berkeley

Examples of Wavelets

(t) = (1� t2)e�t2/2

(t) =

8<

:

�1 0 t < 12

1

12 t < 1

0 otherwise

26

M. Lustig, EECS UC Berkeley

Example: Mexican Hat

log(s)

u

SombreroWavelet

27

Wf(u, s) =1ps

Z 1

�1f(t) ⇤(

t� u

s)dt

=�f(t) ⇤ s(t)

(u)

s =1ps (

t

s)

M. Lustig, EECS UC Berkeley

Wavelets Transform

• Can be written as linear filtering

• Wavelet coefficients are a result of bandpass filtering

28

i = [1, 2, 3, · · · ]

M. Lustig, EECS UC Berkeley

Wavelet Transform

• Many different constructions for different signals–Haar good for piece-wise constant signals–Battle-Lemarie’ : Spline polynomials

• Can construct Orthogonal wavelets– For example: dyadic Haar is orthonormal

i,n(t) =1p2i (

t� 2in

2i)

29

M. Lustig, EECS UC Berkeley

Orthonormal Haar

Same scalenon-overlapping

Orthogonal between scales

30

M. Lustig, EECS UC Berkeley

Orthonormal Haar

Same scalenon-overlapping

Orthogonal between scales

31

M. Lustig, EECS UC Berkeley

Scaling function

i,n(t) =1p2i (

t� 2in

2i)

• Problem: –Every stretch only covers half remaining

bandwidth–Need Infinite functions

• Solution:–Plug low-pass spectrum with a scaling function

i=mi=m+1i=m+2i=m+3

32

�M. Lustig, EECS UC Berkeley

Scaling function

i,n(t) =1p2i (

t� 2in

2i)

• Problem: –Every stretch only covers half remaining

bandwidth–Need Infinite functions

• Solution:–Plug low-pass spectrum with a scaling function

i=mi=m+1

33

�(t) =

⇢1 0 t < 1

0 otherwise

M. Lustig, EECS UC Berkeley

Haar Scaling function

(t) =

8<

:

�1 0 t < 12

1

12 t < 1

0 otherwise

34

M. Lustig, EECS UC Berkeley

Back to Discrete

• Early 80’s, theoretical work by Morlett, Grossman and Meyer (math, geophysics)

• Late 80’s link to DSP by Daubechies and Mallat.

• From CWT to DWT not so trivial!• Must take care to maintain properties

35

!

n

W [k] =N�1X

n=0

x[n] k[n]

M. Lustig, EECS UC Berkeley

Discrete Wavelet Transform

36

1p2

!

t

k = 1k = 0

M. Lustig, EECS UC Berkeley

Example: Discrete Haar WaveletHaar for n=2

1p2

mother wavelet

scalingfunction

detail

approximation

37

M. Lustig, EECS UC Berkeley

Example: Discrete Haar WaveletHaar for n=8 1p

2

!

t

1p2

1p2

1p2

1p2

1p2

1p2

1p2

k=0

k=1

k=2

k=3

k=4

k=5

k=6

k=7

s=22

s=21

s=20

scaling

38

M. Lustig, EECS UC Berkeley

Fast DWT

• Fast Pyramidal Decomposition

• Complexity is O(N), less than FFT

n . --[@j-{f} -0-c_

0.1 WL __, 1

) •y • J . \ • I

'

' 1'

l ..J > f ' -......

is CJ{J/) Ass !kJIJ FAT! fl:_f;(Q#sJ )( U cTZ 0)/ ·-

i -

h[n] g[n]

39

M. Lustig, EECS UC Berkeley

Fast DWT

n . --[@j-{f} -0-c_

0.1 WL __, 1

) •y • J . \ • I

'

' 1'

l ..J > f ' -......

is CJ{J/) Ass !kJIJ FAT! fl:_f;(Q#sJ )( U cTZ 0)/ ·-

i -

40

M. Lustig, EECS UC Berkeley

x[n]

Haar

Haar DWT Example

41

M. Lustig, EECS UC Berkeley

DFT

Haar

Approximation from 25/256 coefficients

42

M. Lustig, EECS UC Berkeley

Example: Denoising Noisy Signals

Haar

43

M. Lustig, EECS UC Berkeley

Example: Denoising by Thresholding

noisy

denoisedlargest 25 coefficients

44

45 46

Noisy Wavelet Denoised

47 48

49