ese 531: digital signal processing - seas.upenn.eduese531/spring2018/handouts/lec19.pdf · "...

58
ESE 531: Digital Signal Processing Lec 19: March 29, 2018 Discrete Fourier Transform, Pt 2 Penn ESE 531 Spring 2018 – Khanna Adapted from M. Lustig, EECS Berkeley

Upload: phamdien

Post on 08-Sep-2018

221 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: ESE 531: Digital Signal Processing - seas.upenn.eduese531/spring2018/handouts/lec19.pdf · " Use DFT to do linear convolution (via circular convolution) 19 ... Linear Convolution

ESE 531: Digital Signal Processing

Lec 19: March 29, 2018 Discrete Fourier Transform, Pt 2

Penn ESE 531 Spring 2018 – Khanna Adapted from M. Lustig, EECS Berkeley

Page 2: ESE 531: Digital Signal Processing - seas.upenn.eduese531/spring2018/handouts/lec19.pdf · " Use DFT to do linear convolution (via circular convolution) 19 ... Linear Convolution

Today

!  Review: "  Discrete Fourier Transform (DFT) "  Circular Convolution

!  Fast Convolution Methods

2 Penn ESE 531 Spring 2018 - Khanna

Page 3: ESE 531: Digital Signal Processing - seas.upenn.eduese531/spring2018/handouts/lec19.pdf · " Use DFT to do linear convolution (via circular convolution) 19 ... Linear Convolution

Discrete Fourier Transform

!  The DFT

!  It is understood that,

3 Penn ESE 531 Spring 2018 – Khanna Adapted from M. Lustig, EECS Berkeley

Page 4: ESE 531: Digital Signal Processing - seas.upenn.eduese531/spring2018/handouts/lec19.pdf · " Use DFT to do linear convolution (via circular convolution) 19 ... Linear Convolution

4

DFT vs DTFT

!  Back to example

4 Penn ESE 531 Spring 2018 – Khanna Adapted from M. Lustig, EECS Berkeley

Page 5: ESE 531: Digital Signal Processing - seas.upenn.eduese531/spring2018/handouts/lec19.pdf · " Use DFT to do linear convolution (via circular convolution) 19 ... Linear Convolution

Properties of the DFS/DFT

Penn ESE 531 Spring 2018 – Khanna Adapted from M. Lustig, EECS Berkeley

Page 6: ESE 531: Digital Signal Processing - seas.upenn.eduese531/spring2018/handouts/lec19.pdf · " Use DFT to do linear convolution (via circular convolution) 19 ... Linear Convolution

Properties (Continued)

Penn ESE 531 Spring 2018 – Khanna Adapted from M. Lustig, EECS Berkeley

Page 7: ESE 531: Digital Signal Processing - seas.upenn.eduese531/spring2018/handouts/lec19.pdf · " Use DFT to do linear convolution (via circular convolution) 19 ... Linear Convolution

Duality

7 Penn ESE 531 Spring 2018 - Khanna

Page 8: ESE 531: Digital Signal Processing - seas.upenn.eduese531/spring2018/handouts/lec19.pdf · " Use DFT to do linear convolution (via circular convolution) 19 ... Linear Convolution

Duality

8 Penn ESE 531 Spring 2018 - Khanna

Page 9: ESE 531: Digital Signal Processing - seas.upenn.eduese531/spring2018/handouts/lec19.pdf · " Use DFT to do linear convolution (via circular convolution) 19 ... Linear Convolution

Proof of Duality

9 Penn ESE 531 Spring 2018 - Khanna

Page 10: ESE 531: Digital Signal Processing - seas.upenn.eduese531/spring2018/handouts/lec19.pdf · " Use DFT to do linear convolution (via circular convolution) 19 ... Linear Convolution

Proof of Duality

10 Penn ESE 531 Spring 2018 - Khanna

Page 11: ESE 531: Digital Signal Processing - seas.upenn.eduese531/spring2018/handouts/lec19.pdf · " Use DFT to do linear convolution (via circular convolution) 19 ... Linear Convolution

Proof of Duality

11 Penn ESE 531 Spring 2018 - Khanna

Page 12: ESE 531: Digital Signal Processing - seas.upenn.eduese531/spring2018/handouts/lec19.pdf · " Use DFT to do linear convolution (via circular convolution) 19 ... Linear Convolution

Discrete Fourier Series

!  Properties of WN:  "  WN

0 = WNN = WN

2N = ... = 1  "  WN

k+r = WNkWN

r and, WNk+N = WN

!  Example: WNkn (N=6)

12 Penn ESE 531 Spring 2018 – Khanna Adapted from M. Lustig, EECS Berkeley

Page 13: ESE 531: Digital Signal Processing - seas.upenn.eduese531/spring2018/handouts/lec19.pdf · " Use DFT to do linear convolution (via circular convolution) 19 ... Linear Convolution

Proof of Duality

13 Penn ESE 531 Spring 2018 - Khanna

Page 14: ESE 531: Digital Signal Processing - seas.upenn.eduese531/spring2018/handouts/lec19.pdf · " Use DFT to do linear convolution (via circular convolution) 19 ... Linear Convolution

Circular Convolution

!  Circular Convolution:

For two signals of length N

14 Penn ESE 531 Spring 2018 – Khanna Adapted from M. Lustig, EECS Berkeley

Page 15: ESE 531: Digital Signal Processing - seas.upenn.eduese531/spring2018/handouts/lec19.pdf · " Use DFT to do linear convolution (via circular convolution) 19 ... Linear Convolution

Compute Circular Convolution Sum

15 Penn ESE 531 Spring 2018 – Khanna Adapted from M. Lustig, EECS Berkeley

Page 16: ESE 531: Digital Signal Processing - seas.upenn.eduese531/spring2018/handouts/lec19.pdf · " Use DFT to do linear convolution (via circular convolution) 19 ... Linear Convolution

Result

16

y[0]=2 y[1]=2 y[2]=3 y[3]=4

Penn ESE 531 Spring 2018 – Khanna Adapted from M. Lustig, EECS Berkeley

Page 17: ESE 531: Digital Signal Processing - seas.upenn.eduese531/spring2018/handouts/lec19.pdf · " Use DFT to do linear convolution (via circular convolution) 19 ... Linear Convolution

Circular Convolution

!  For x1[n] and x2[n] with length N

"  Very useful!! (for linear convolutions with DFT)

17 Penn ESE 531 Spring 2018 – Khanna Adapted from M. Lustig, EECS Berkeley

Page 18: ESE 531: Digital Signal Processing - seas.upenn.eduese531/spring2018/handouts/lec19.pdf · " Use DFT to do linear convolution (via circular convolution) 19 ... Linear Convolution

Multiplication

!  For x1[n] and x2[n] with length N

18 Penn ESE 531 Spring 2018 – Khanna Adapted from M. Lustig, EECS Berkeley

Page 19: ESE 531: Digital Signal Processing - seas.upenn.eduese531/spring2018/handouts/lec19.pdf · " Use DFT to do linear convolution (via circular convolution) 19 ... Linear Convolution

Linear Convolution

!  Next.... "  Using DFT, circular convolution is easy

"  Matrix multiplication… more later

"  But, linear convolution is useful, not circular "  So, show how to perform linear convolution with circular

convolution "  Use DFT to do linear convolution (via circular

convolution)

19 Penn ESE 531 Spring 2018 – Khanna Adapted from M. Lustig, EECS Berkeley

Page 20: ESE 531: Digital Signal Processing - seas.upenn.eduese531/spring2018/handouts/lec19.pdf · " Use DFT to do linear convolution (via circular convolution) 19 ... Linear Convolution

Linear Convolution

!  We start with two non-periodic sequences:

"  E.g. x[n] is a signal and h[n] a filter’s impulse response

20 Penn ESE 531 Spring 2018 – Khanna Adapted from M. Lustig, EECS Berkeley

Page 21: ESE 531: Digital Signal Processing - seas.upenn.eduese531/spring2018/handouts/lec19.pdf · " Use DFT to do linear convolution (via circular convolution) 19 ... Linear Convolution

Linear Convolution

!  We start with two non-periodic sequences:

"  E.g. x[n] is a signal and h[n] a filter’s impulse response

!  We want to compute the linear convolution:

"  y[n] is nonzero for 0 ≤ n ≤ L+P-2 (ie. length M=L+P-1)

21 Penn ESE 531 Spring 2018 – Khanna Adapted from M. Lustig, EECS Berkeley

Requires L*P multiplications

Page 22: ESE 531: Digital Signal Processing - seas.upenn.eduese531/spring2018/handouts/lec19.pdf · " Use DFT to do linear convolution (via circular convolution) 19 ... Linear Convolution

Linear Convolution via Circular Convolution

!  Zero-pad x[n] by P-1 zeros

!  Zero-pad h[n] by L-1 zeros

!  Now, both sequences are length M=L+P-1

22 Penn ESE 531 Spring 2018 – Khanna Adapted from M. Lustig, EECS Berkeley

Page 23: ESE 531: Digital Signal Processing - seas.upenn.eduese531/spring2018/handouts/lec19.pdf · " Use DFT to do linear convolution (via circular convolution) 19 ... Linear Convolution

Linear Convolution via Circular Convolution

!  Now, both sequences are length M=L+P-1 !  We can now compute the linear convolution using a

circular one with length M=L+P-1

23 Penn ESE 531 Spring 2018 – Khanna Adapted from M. Lustig, EECS Berkeley

Page 24: ESE 531: Digital Signal Processing - seas.upenn.eduese531/spring2018/handouts/lec19.pdf · " Use DFT to do linear convolution (via circular convolution) 19 ... Linear Convolution

Example

24 Penn ESE 531 Spring 2018 – Khanna Adapted from M. Lustig, EECS Berkeley

Page 25: ESE 531: Digital Signal Processing - seas.upenn.eduese531/spring2018/handouts/lec19.pdf · " Use DFT to do linear convolution (via circular convolution) 19 ... Linear Convolution

Example

25 Penn ESE 531 Spring 2018 – Khanna Adapted from M. Lustig, EECS Berkeley

Page 26: ESE 531: Digital Signal Processing - seas.upenn.eduese531/spring2018/handouts/lec19.pdf · " Use DFT to do linear convolution (via circular convolution) 19 ... Linear Convolution

Example

26 Penn ESE 531 Spring 2018 – Khanna Adapted from M. Lustig, EECS Berkeley

Page 27: ESE 531: Digital Signal Processing - seas.upenn.eduese531/spring2018/handouts/lec19.pdf · " Use DFT to do linear convolution (via circular convolution) 19 ... Linear Convolution

Linear Convolution with DFT

!  In practice we can implement a circulant convolution using the DFT property:

27 Penn ESE 531 Spring 2018 – Khanna Adapted from M. Lustig, EECS Berkeley

Page 28: ESE 531: Digital Signal Processing - seas.upenn.eduese531/spring2018/handouts/lec19.pdf · " Use DFT to do linear convolution (via circular convolution) 19 ... Linear Convolution

Linear Convolution with DFT

!  In practice we can implement a circulant convolution using the DFT property:

!  Advantage: DFT can be computed with Nlog2N complexity (FFT algorithm later!)

!  Drawback: Must wait for all the samples -- huge delay -- incompatible with real-time filtering

28 Penn ESE 531 Spring 2018 – Khanna Adapted from M. Lustig, EECS Berkeley

Page 29: ESE 531: Digital Signal Processing - seas.upenn.eduese531/spring2018/handouts/lec19.pdf · " Use DFT to do linear convolution (via circular convolution) 19 ... Linear Convolution

Block Convolution

!  Problem: "  An input signal x[n], has very long length (could be

considered infinite) "  An impulse response h[n] has length P "  We want to take advantage of DFT/FFT and compute

convolutions in blocks that are shorter than the signal

!  Approach: "  Break the signal into small blocks "  Compute convolutions "  Combine the results

29 Penn ESE 531 Spring 2018 – Khanna Adapted from M. Lustig, EECS Berkeley

Page 30: ESE 531: Digital Signal Processing - seas.upenn.eduese531/spring2018/handouts/lec19.pdf · " Use DFT to do linear convolution (via circular convolution) 19 ... Linear Convolution

Block Convolution

30 Penn ESE 531 Spring 2018 – Khanna Adapted from M. Lustig, EECS Berkeley

Page 31: ESE 531: Digital Signal Processing - seas.upenn.eduese531/spring2018/handouts/lec19.pdf · " Use DFT to do linear convolution (via circular convolution) 19 ... Linear Convolution

Overlap-Add Method

!  Decompose into non-overlapping segments

!  The input signal is the sum of segments

31 Penn ESE 531 Spring 2018 – Khanna Adapted from M. Lustig, EECS Berkeley

Page 32: ESE 531: Digital Signal Processing - seas.upenn.eduese531/spring2018/handouts/lec19.pdf · " Use DFT to do linear convolution (via circular convolution) 19 ... Linear Convolution

Example

32 Penn ESE 531 Spring 2018 – Khanna Adapted from M. Lustig, EECS Berkeley

L=11

Page 33: ESE 531: Digital Signal Processing - seas.upenn.eduese531/spring2018/handouts/lec19.pdf · " Use DFT to do linear convolution (via circular convolution) 19 ... Linear Convolution

Overlap-Add Method

!  The output is:

"  Each output segment xr[n]*h[n] is length N=L+P-1 "  h[n] has length P "  xr[n] has length L

33 Penn ESE 531 Spring 2018 – Khanna Adapted from M. Lustig, EECS Berkeley

Page 34: ESE 531: Digital Signal Processing - seas.upenn.eduese531/spring2018/handouts/lec19.pdf · " Use DFT to do linear convolution (via circular convolution) 19 ... Linear Convolution

Overlap-Add Method

!  We can compute xr[n]*h[n] using circular convolution with the DFT

!  Using the DFT: "  Zero-pad xr[n] to length N "  Zero-pad h[n] to length N and compute DFTN{hzp[n]}

"  Only need to do once

34 Penn ESE 531 Spring 2018 – Khanna Adapted from M. Lustig, EECS Berkeley

Page 35: ESE 531: Digital Signal Processing - seas.upenn.eduese531/spring2018/handouts/lec19.pdf · " Use DFT to do linear convolution (via circular convolution) 19 ... Linear Convolution

Overlap-Add Method

!  We can compute xr[n]*h[n] using circular convolution with the DFT

!  Using the DFT: "  Zero-pad xr[n] to length N "  Zero-pad h[n] to length N and compute DFTN{hzp[n]}

"  Only need to do once

"  Compute:

!  Results are of length N=L+P-1 "  Neighboring results overlap by P-1 "  Add overlaps to get final sequence

35 Penn ESE 531 Spring 2018 – Khanna Adapted from M. Lustig, EECS Berkeley

Page 36: ESE 531: Digital Signal Processing - seas.upenn.eduese531/spring2018/handouts/lec19.pdf · " Use DFT to do linear convolution (via circular convolution) 19 ... Linear Convolution

Example of Overlap-Add

36

y

y

y

Penn ESE 531 Spring 2018 – Khanna Adapted from M. Lustig, EECS Berkeley

L=11

L+P-1=16

Page 37: ESE 531: Digital Signal Processing - seas.upenn.eduese531/spring2018/handouts/lec19.pdf · " Use DFT to do linear convolution (via circular convolution) 19 ... Linear Convolution

Example of Overlap-Add

37

y

y

y

Penn ESE 531 Spring 2018 – Khanna Adapted from M. Lustig, EECS Berkeley

L=11

L+P-1=16

Page 38: ESE 531: Digital Signal Processing - seas.upenn.eduese531/spring2018/handouts/lec19.pdf · " Use DFT to do linear convolution (via circular convolution) 19 ... Linear Convolution

Example of Overlap-Add

38

y

y

y

Penn ESE 531 Spring 2018 – Khanna Adapted from M. Lustig, EECS Berkeley

L=11

L+P-1=16

Page 39: ESE 531: Digital Signal Processing - seas.upenn.eduese531/spring2018/handouts/lec19.pdf · " Use DFT to do linear convolution (via circular convolution) 19 ... Linear Convolution

Overlap-Save Method

!  Basic idea: !  Split input into overlapping segments with length

L+P-1  "  P-1 sample overlap

!  Perform circular convolution in each segment, and

keep the L sample portion which is a valid linear convolution

39 Penn ESE 531 Spring 2018 – Khanna Adapted from M. Lustig, EECS Berkeley

Page 40: ESE 531: Digital Signal Processing - seas.upenn.eduese531/spring2018/handouts/lec19.pdf · " Use DFT to do linear convolution (via circular convolution) 19 ... Linear Convolution

Example of Overlap-Save

40 Penn ESE 531 Spring 2018 – Khanna Adapted from M. Lustig, EECS Berkeley

L+P-1=16

Page 41: ESE 531: Digital Signal Processing - seas.upenn.eduese531/spring2018/handouts/lec19.pdf · " Use DFT to do linear convolution (via circular convolution) 19 ... Linear Convolution

Circular to Linear Convolution

!  An L-point sequence circularly convolved with a P-point sequence "  with L - P zeros padded, P < L

!  gives an L-point result with "  the first P - 1 values incorrect and "  the next L - P + 1 the correct linear convolution result

41 Penn ESE 531 Spring 2018 - Khanna

Page 42: ESE 531: Digital Signal Processing - seas.upenn.eduese531/spring2018/handouts/lec19.pdf · " Use DFT to do linear convolution (via circular convolution) 19 ... Linear Convolution

Example of Overlap-Save

42 Penn ESE 531 Spring 2018 – Khanna Adapted from M. Lustig, EECS Berkeley

L+P-1=16 P-1=5 Overlap samples

Page 43: ESE 531: Digital Signal Processing - seas.upenn.eduese531/spring2018/handouts/lec19.pdf · " Use DFT to do linear convolution (via circular convolution) 19 ... Linear Convolution

Example of Overlap-Save

43 Penn ESE 531 Spring 2018 – Khanna Adapted from M. Lustig, EECS Berkeley

L+P-1=16

Page 44: ESE 531: Digital Signal Processing - seas.upenn.eduese531/spring2018/handouts/lec19.pdf · " Use DFT to do linear convolution (via circular convolution) 19 ... Linear Convolution

Discrete Cosine Transform

!  Similar to the discrete Fourier transform (DFT), but using only real numbers

!  Widely used in lossy compression applications (eg. Mp3, JPEG)

!  Why use it?

44 Penn ESE 531 Spring 2018 - Khanna

Page 45: ESE 531: Digital Signal Processing - seas.upenn.eduese531/spring2018/handouts/lec19.pdf · " Use DFT to do linear convolution (via circular convolution) 19 ... Linear Convolution

DFT Problems

!  For processing 1-D or 2-D signals (especially coding), a common method is to divide the signal into “frames” and then apply an invertible transform to each frame that compresses the information into few coefficients.

!  The DFT has some problems when used for this purpose: "  N real x[n] ↔ N complex X[k] : 2 real, N/2 − 1 conjugate pairs "  DFT is of the periodic signal formed by replicating x[n]

45 Penn ESE 531 Spring 2018 - Khanna

Page 46: ESE 531: Digital Signal Processing - seas.upenn.eduese531/spring2018/handouts/lec19.pdf · " Use DFT to do linear convolution (via circular convolution) 19 ... Linear Convolution

DFT Problems

!  For processing 1-D or 2-D signals (especially coding), a common method is to divide the signal into “frames” and then apply an invertible transform to each frame that compresses the information into few coefficients.

!  The DFT has some problems when used for this purpose: "  N real x[n] ↔ N complex X[k] : 2 real, N/2 − 1 conjugate pairs "  DFT is of the periodic signal formed by replicating x[n] ⇒ Spurious frequency components from boundary discontinuity

46 Penn ESE 531 Spring 2018 - Khanna

The Discrete Cosine Transform (DCT) overcomes these problems.

Page 47: ESE 531: Digital Signal Processing - seas.upenn.eduese531/spring2018/handouts/lec19.pdf · " Use DFT to do linear convolution (via circular convolution) 19 ... Linear Convolution

Discrete Cosine Transform

!  To form the Discrete Cosine Transform (DCT), replicate x[0 : N − 1] but in reverse order and insert a zero between each pair of samples:

47 Penn ESE 531 Spring 2018 - Khanna

Page 48: ESE 531: Digital Signal Processing - seas.upenn.eduese531/spring2018/handouts/lec19.pdf · " Use DFT to do linear convolution (via circular convolution) 19 ... Linear Convolution

FIR GLP: Type II

48 Penn ESE 531 Spring 2018 - Khanna

Page 49: ESE 531: Digital Signal Processing - seas.upenn.eduese531/spring2018/handouts/lec19.pdf · " Use DFT to do linear convolution (via circular convolution) 19 ... Linear Convolution

Discrete Cosine Transform

!  To form the Discrete Cosine Transform (DCT), replicate x[0 : N − 1] but in reverse order and insert a zero between each pair of samples:

!  Take the DFT of length 4N real, symmetric, odd-sample-only sequence

49 Penn ESE 531 Spring 2018 - Khanna

Page 50: ESE 531: Digital Signal Processing - seas.upenn.eduese531/spring2018/handouts/lec19.pdf · " Use DFT to do linear convolution (via circular convolution) 19 ... Linear Convolution

Discrete Cosine Transform

!  To form the Discrete Cosine Transform (DCT), replicate x[0 : N − 1] but in reverse order and insert a zero between each pair of samples:

!  Take the DFT of length 4N real, symmetric, odd-sample-only sequence

!  Result is real, symmetric and anti-periodic: only need first N values

50 Penn ESE 531 Spring 2018 - Khanna

Page 51: ESE 531: Digital Signal Processing - seas.upenn.eduese531/spring2018/handouts/lec19.pdf · " Use DFT to do linear convolution (via circular convolution) 19 ... Linear Convolution

Discrete Cosine Transform

!  Result is real, symmetric and anti-periodic: only need first N values

51 Penn ESE 531 Spring 2018 - Khanna

Page 52: ESE 531: Digital Signal Processing - seas.upenn.eduese531/spring2018/handouts/lec19.pdf · " Use DFT to do linear convolution (via circular convolution) 19 ... Linear Convolution

Discrete Cosine Transform

52 Penn ESE 531 Spring 2018 - Khanna

Page 53: ESE 531: Digital Signal Processing - seas.upenn.eduese531/spring2018/handouts/lec19.pdf · " Use DFT to do linear convolution (via circular convolution) 19 ... Linear Convolution

Basis Functions

53 Penn ESE 531 Spring 2018 - Khanna

Page 54: ESE 531: Digital Signal Processing - seas.upenn.eduese531/spring2018/handouts/lec19.pdf · " Use DFT to do linear convolution (via circular convolution) 19 ... Linear Convolution

DFT of Sine Wave

54 Penn ESE 531 Spring 2018 - Khanna

Page 55: ESE 531: Digital Signal Processing - seas.upenn.eduese531/spring2018/handouts/lec19.pdf · " Use DFT to do linear convolution (via circular convolution) 19 ... Linear Convolution

DFT of Sine Wave

55 Penn ESE 531 Spring 2018 - Khanna

Page 56: ESE 531: Digital Signal Processing - seas.upenn.eduese531/spring2018/handouts/lec19.pdf · " Use DFT to do linear convolution (via circular convolution) 19 ... Linear Convolution

DCT of Sine Wave

56 Penn ESE 531 Spring 2018 - Khanna

Page 57: ESE 531: Digital Signal Processing - seas.upenn.eduese531/spring2018/handouts/lec19.pdf · " Use DFT to do linear convolution (via circular convolution) 19 ... Linear Convolution

Big Ideas

!  Discrete Fourier Transform (DFT) "  For finite signals assumed to be zero outside of defined

length "  N-point DFT is sampled DTFT at N points "  DFT properties inherited from DFS, but circular

operations!

!  Fast Convolution Methods "  Use circular convolution (i.e DFT) to perform fast linear

convolution "  Overlap-Add, Overlap-Save

!  DCT useful for frame rate compression of large signals

57 Penn ESE 531 Spring 2018 – Khanna Adapted from M. Lustig, EECS Berkeley

Page 58: ESE 531: Digital Signal Processing - seas.upenn.eduese531/spring2018/handouts/lec19.pdf · " Use DFT to do linear convolution (via circular convolution) 19 ... Linear Convolution

Admin

!  HW 8 due tomorrow !  Project

"  Work in groups of up to 2 "  Can work alone if you want "  Use Piazza to find partners

58 Penn ESE 531 Spring 2018 – Khanna Adapted from M. Lustig, EECS Berkeley