digital signal processing lecture 8€¦ · apply n-dft and n-idft where n=l+m-1. thus, if l and m...

38
Remote Sensing Laboratory Dept. of Information Engineering and Computer Science University of Trento Via Sommarive, 14, I-38123 Povo, Trento, Italy Remote Sensing Laboratory Dept. of Information Engineering and Computer Science University of Trento Via Sommarive, 14, I-38123 Povo, Trento, Italy Digital Signal Processing Lecture 8 Digital Signal Processing Lecture 8 E-mail: demir@disi.unitn.it Web page: http://rslab.disi.unitn.it Quote of the Day Any sufficiently advanced technology is indistinguishable from magic. Arthur C. Clarke

Upload: others

Post on 30-Nov-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Digital Signal Processing Lecture 8€¦ · Apply N-DFT and N-IDFT where N=L+M-1. Thus, if L and M are smaller than N apply zero padding to xm[n] and h[n]. We set N = L + M -1 (the

Remote Sensing LaboratoryDept. of Information Engineering and Computer Science

University of TrentoVia Sommarive, 14, I-38123 Povo, Trento, Italy

Remote Sensing LaboratoryDept. of Information Engineering and Computer Science

University of TrentoVia Sommarive, 14, I-38123 Povo, Trento, Italy

Digital Signal ProcessingLecture 8

Digital Signal ProcessingLecture 8

E-mail: [email protected] page: http://rslab.disi.unitn.it

Quote of the DayAny sufficiently advanced technology is

indistinguishable from magic.

Arthur C. Clarke

Page 2: Digital Signal Processing Lecture 8€¦ · Apply N-DFT and N-IDFT where N=L+M-1. Thus, if L and M are smaller than N apply zero padding to xm[n] and h[n]. We set N = L + M -1 (the

University of Trento, Italy B. Demir

Page 3: Digital Signal Processing Lecture 8€¦ · Apply N-DFT and N-IDFT where N=L+M-1. Thus, if L and M are smaller than N apply zero padding to xm[n] and h[n]. We set N = L + M -1 (the

University of Trento, Italy B. Demir

DFT: Filtering of Long Data Sequences

The input signal x[n] is often very long especially in real-time signal processing applications.

There are applications where we need to perform a linear convolution of a finite length sequence with a sequence that is of length that is much greater than that of the first sequence.

Let h[n] be a finite length sequence of length M and x[n] be a sequence of a finite length much greater than M.

Our objective is to develop computationally efficient DFT based methods to implement linear convolution of h[n] and x[n].

The strategy is to segment the input signal into fixed-size blocks prior to processing and to compute DFT based methods for each block separately.

Page 4: Digital Signal Processing Lecture 8€¦ · Apply N-DFT and N-IDFT where N=L+M-1. Thus, if L and M are smaller than N apply zero padding to xm[n] and h[n]. We set N = L + M -1 (the

University of Trento, Italy B. Demir

DFT: Filtering of Long Data Sequences

Two approaches to real-time linear filtering of long inputs:

Overlap-Add Method

Overlap-Save Method

Page 5: Digital Signal Processing Lecture 8€¦ · Apply N-DFT and N-IDFT where N=L+M-1. Thus, if L and M are smaller than N apply zero padding to xm[n] and h[n]. We set N = L + M -1 (the

University of Trento, Italy B. Demir

Overlap Add

The linear convolution of a discrete-time signal of length L and a discrete-time signal of length M produces a discrete-time convolved result of length L+M-1.

Remember:

In overlap add method, input signal x[n] is divided into non overlapping blocks xm[n] with length L.

Each input block xm[n] is individually convolved with h[n] to produce the output ym[n].

1 2 1 2[ ] [ ] [ ] [ ] [ ] [ ] [ ]x n x n h n x n h n x n h n

Page 6: Digital Signal Processing Lecture 8€¦ · Apply N-DFT and N-IDFT where N=L+M-1. Thus, if L and M are smaller than N apply zero padding to xm[n] and h[n]. We set N = L + M -1 (the

University of Trento, Italy

Overlap Add

B. Demir

Page 7: Digital Signal Processing Lecture 8€¦ · Apply N-DFT and N-IDFT where N=L+M-1. Thus, if L and M are smaller than N apply zero padding to xm[n] and h[n]. We set N = L + M -1 (the

University of Trento, Italy B. Demir

Overlap Add-Filtering

Apply N-DFT and N-IDFT where N=L+M-1.

Thus, if L and M are smaller than N apply zero padding to xm[n] and h[n].

We set N = L + M -1 (the length of the linear convolution result) and zero pad xm[n] and h[n] to define n = 0,1, … ,N -1.

Using DFT for Linear Convolution:

1. Take N-DFT of xm[n] to give Xm[k], k = 0,1, … ,N -1.

2. Take N-DFT of h[n] to give H[k], k = 0,1, … ,N -1.

3. Multiply: Ym[k] = Xm[k]H[k], k = 0,1, … ,N -1.

4. Take N-IDFT of Ym[k] to give ym[n], n = 0,1, … ,N -1.

Page 8: Digital Signal Processing Lecture 8€¦ · Apply N-DFT and N-IDFT where N=L+M-1. Thus, if L and M are smaller than N apply zero padding to xm[n] and h[n]. We set N = L + M -1 (the

University of Trento, Italy B. Demir

Overlap Add

Page 9: Digital Signal Processing Lecture 8€¦ · Apply N-DFT and N-IDFT where N=L+M-1. Thus, if L and M are smaller than N apply zero padding to xm[n] and h[n]. We set N = L + M -1 (the

University of Trento, Italy B. Demir

Overlap Add

Page 10: Digital Signal Processing Lecture 8€¦ · Apply N-DFT and N-IDFT where N=L+M-1. Thus, if L and M are smaller than N apply zero padding to xm[n] and h[n]. We set N = L + M -1 (the

University of Trento, Italy B. Demir

Overlap Add

Output blocks ym[n] must be fitted together appropriately to generate: x[n]*h[n]

If you DO NOT overlap and add, but only append the output blocks ym[n] , then you will not get the true y[n] sequence.

Page 11: Digital Signal Processing Lecture 8€¦ · Apply N-DFT and N-IDFT where N=L+M-1. Thus, if L and M are smaller than N apply zero padding to xm[n] and h[n]. We set N = L + M -1 (the

University of Trento, Italy B. Demir

Overlap Save

The Overlap-Save method aims at segmenting x[n] into overlapping blocks.

Accordingly, all input blocks xm[n] are of length N = (L + M - 1) and contain sequential samples from x[n].

Input block xm[n] for m > 1 overlaps containing the last M-1 points of the previous block xm-1[n].

For m = 1, there is no previous block, so the first M-1 points are zeros.

Page 12: Digital Signal Processing Lecture 8€¦ · Apply N-DFT and N-IDFT where N=L+M-1. Thus, if L and M are smaller than N apply zero padding to xm[n] and h[n]. We set N = L + M -1 (the

University of Trento, Italy B. Demir

Overlap Save

Page 13: Digital Signal Processing Lecture 8€¦ · Apply N-DFT and N-IDFT where N=L+M-1. Thus, if L and M are smaller than N apply zero padding to xm[n] and h[n]. We set N = L + M -1 (the

University of Trento, Italy B. Demir

Overlap Save

The last M‐1 samples from the previous input block must be used for use inthe current input block.

1

2

11

2

1 samples from x [n]

3

1 samples from x [n

[ ] 0,0,...0, [0], [1],..., [ 1]

[ ] [ 1],..., [ 1], [ ],..., [2 1]

[ ] [2 1],..., [2 1]

M zeros

last M

last M

x n x x x L

x n x L M x L x L x L

x n x L M x L

]

, [2 ],..., [3 1]x L x L

Page 14: Digital Signal Processing Lecture 8€¦ · Apply N-DFT and N-IDFT where N=L+M-1. Thus, if L and M are smaller than N apply zero padding to xm[n] and h[n]. We set N = L + M -1 (the

University of Trento, Italy B. Demir

Overlap Save

Apply the N-DFT and N-IDFT where: N = L + M -1

Only one-time zero-padding of h[n] of length M << L < N is requiredto have h[n] with n = 0,1,…,N-1

The input blocks xm[n] are of length N to start, so no zero-padding isnecessary.

Page 15: Digital Signal Processing Lecture 8€¦ · Apply N-DFT and N-IDFT where N=L+M-1. Thus, if L and M are smaller than N apply zero padding to xm[n] and h[n]. We set N = L + M -1 (the

University of Trento, Italy

N = L + M- 1.

Let xm[n] is defined for n = 0,1,…,N-1 and h[n] is defined for n = 0,1,…,M-1

We zero pad h[n] to have n = 0,1,…,N-1

1. Take N-DFT of xm[n] to give Xm[k], k = 0,1,…,N-1.

2. Take N-DFT of h[n] to give H[k], k = 0,1,…,N-1.

3. Multiply: Ym[k] = Xm[k] H[k], k = 0,1,…,N-1.

4. Take N-IDFT of Ym[k] to give ym[n], n = 0,1,…,N-1.

The first M -1 points of each output block are discarded due to overcome with aliasing. The remaining L points of each output block are appended to form y[n].

B. Demir

Overlap Save

Page 16: Digital Signal Processing Lecture 8€¦ · Apply N-DFT and N-IDFT where N=L+M-1. Thus, if L and M are smaller than N apply zero padding to xm[n] and h[n]. We set N = L + M -1 (the

University of Trento, Italy B. Demir

Overlap Save

Page 17: Digital Signal Processing Lecture 8€¦ · Apply N-DFT and N-IDFT where N=L+M-1. Thus, if L and M are smaller than N apply zero padding to xm[n] and h[n]. We set N = L + M -1 (the

University of Trento, Italy

Despite the fact that the DFT is a vector with finite size, computing it forlarge values of N is very intensive. In order to compute each

N complex multiplications and N-1 complex additions (that iscomputationally expensive) for each k are needed.

Thus DFT has O(N2) computations, whereas it is possible to reduce it toO(Nlog2N) by fast Fourier Transform (FFT) algorithm .

21

0

[ ] , 0,1,... 1N j kn

N

n

X k x n e k N

B. Demir

Discrete Fourier Transform (DFT)

Page 18: Digital Signal Processing Lecture 8€¦ · Apply N-DFT and N-IDFT where N=L+M-1. Thus, if L and M are smaller than N apply zero padding to xm[n] and h[n]. We set N = L + M -1 (the

University of Trento, Italy B. Demir

Fast Fourier Transform(FFT) Algorithm

It is numerically efficient way to calculate DFT;

It is not another Fourier Representation, but it is an algorithm.

N 1000 106 109

N2 106 1012 1018

Nlog2N 104 20x106 30x109

1018ns ~31.2 years30x109ns ~30 seconds

Lets suppose that each operation

takes 1 ns

Page 19: Digital Signal Processing Lecture 8€¦ · Apply N-DFT and N-IDFT where N=L+M-1. Thus, if L and M are smaller than N apply zero padding to xm[n] and h[n]. We set N = L + M -1 (the

University of Trento, Italy B. Demir

Fast Fourier Transform (FFT) Algorithm

FFT exploits symmetry of the complex exponential:

periodicity of the complex exponential:

The FFT algorithm relies on the fact that the task of computing the N-point DFTof a signal can be broken down into two tasks, each involving an N/2-pointDFT.

2Nk k

N NW W

k N kN NW W

/ 2 / 22 2 2 22

2 2(cos( ) sin( )) ( 1)

k N k N kN j j j jk jN N N NN

k kj j kN NN

W e e e e e

e j e W

2 2 2 2 2

2 2(cos( 2 ) sin( 2 ))

k N k N kj j j jk N jN N N NN

k kj j kN NN

W e e e e e

e j e W

Page 20: Digital Signal Processing Lecture 8€¦ · Apply N-DFT and N-IDFT where N=L+M-1. Thus, if L and M are smaller than N apply zero padding to xm[n] and h[n]. We set N = L + M -1 (the

University of Trento, Italy

Radix-2 FFT

Page 21: Digital Signal Processing Lecture 8€¦ · Apply N-DFT and N-IDFT where N=L+M-1. Thus, if L and M are smaller than N apply zero padding to xm[n] and h[n]. We set N = L + M -1 (the

University of Trento, Italy

Radix-2 FFT

B. Demir

Page 22: Digital Signal Processing Lecture 8€¦ · Apply N-DFT and N-IDFT where N=L+M-1. Thus, if L and M are smaller than N apply zero padding to xm[n] and h[n]. We set N = L + M -1 (the

University of Trento, Italy B. Demir

It aims to build a big DFT from smaller ones.

Assume N=2m

Separate x[n] into two sequence of length N/2– Even indexed samples in the first sequence– Odd indexed samples in the other sequence

FFT Algorithm -Decimation in Time

Page 23: Digital Signal Processing Lecture 8€¦ · Apply N-DFT and N-IDFT where N=L+M-1. Thus, if L and M are smaller than N apply zero padding to xm[n] and h[n]. We set N = L + M -1 (the

University of Trento, Italy B. Demir

even indices odd indices

FFT Algorithm -Decimation in Time

Page 24: Digital Signal Processing Lecture 8€¦ · Apply N-DFT and N-IDFT where N=L+M-1. Thus, if L and M are smaller than N apply zero padding to xm[n] and h[n]. We set N = L + M -1 (the

University of Trento, Italy B. Demir

2

2 22 2k k k2 22

[ ] [ ] [ ], 0 / 2 1

[ ] [ ] [ ] [ ] [ ], 0 / 2 12 2 2

( 1)

kN

Nk kN N

N NN j jj jk kN NN NN N

X k G k W H k k N

N N NX k G k W H k G k W H k k N

W e e e e W

FFT Algorithm -Decimation in Time

Page 25: Digital Signal Processing Lecture 8€¦ · Apply N-DFT and N-IDFT where N=L+M-1. Thus, if L and M are smaller than N apply zero padding to xm[n] and h[n]. We set N = L + M -1 (the

University of Trento, Italy

FFT Algorithm -Decimation in Time

Page 26: Digital Signal Processing Lecture 8€¦ · Apply N-DFT and N-IDFT where N=L+M-1. Thus, if L and M are smaller than N apply zero padding to xm[n] and h[n]. We set N = L + M -1 (the

University of Trento, Italy

FFT Algorithm -Decimation in Time

Page 27: Digital Signal Processing Lecture 8€¦ · Apply N-DFT and N-IDFT where N=L+M-1. Thus, if L and M are smaller than N apply zero padding to xm[n] and h[n]. We set N = L + M -1 (the

University of Trento, Italy

FFT Algorithm -Decimation in Time

Page 28: Digital Signal Processing Lecture 8€¦ · Apply N-DFT and N-IDFT where N=L+M-1. Thus, if L and M are smaller than N apply zero padding to xm[n] and h[n]. We set N = L + M -1 (the

University of Trento, Italy

FFT Algorithm -Decimation in Time

If we keep splitting, we can reduce the computational complexity more.

Page 29: Digital Signal Processing Lecture 8€¦ · Apply N-DFT and N-IDFT where N=L+M-1. Thus, if L and M are smaller than N apply zero padding to xm[n] and h[n]. We set N = L + M -1 (the

University of Trento, Italy

FFT Algorithm -Decimation in Time

Page 30: Digital Signal Processing Lecture 8€¦ · Apply N-DFT and N-IDFT where N=L+M-1. Thus, if L and M are smaller than N apply zero padding to xm[n] and h[n]. We set N = L + M -1 (the

University of Trento, Italy

FFT Algorithm -Decimation in Time

Page 31: Digital Signal Processing Lecture 8€¦ · Apply N-DFT and N-IDFT where N=L+M-1. Thus, if L and M are smaller than N apply zero padding to xm[n] and h[n]. We set N = L + M -1 (the

University of Trento, Italy

FFT Algorithm -Decimation in Time

Page 32: Digital Signal Processing Lecture 8€¦ · Apply N-DFT and N-IDFT where N=L+M-1. Thus, if L and M are smaller than N apply zero padding to xm[n] and h[n]. We set N = L + M -1 (the

University of Trento, Italy

FFT Algorithm -Decimation in Time

Page 33: Digital Signal Processing Lecture 8€¦ · Apply N-DFT and N-IDFT where N=L+M-1. Thus, if L and M are smaller than N apply zero padding to xm[n] and h[n]. We set N = L + M -1 (the

University of Trento, Italy

FFT Algorithm -Decimation in Time

Page 34: Digital Signal Processing Lecture 8€¦ · Apply N-DFT and N-IDFT where N=L+M-1. Thus, if L and M are smaller than N apply zero padding to xm[n] and h[n]. We set N = L + M -1 (the

University of Trento, Italy

FFT Algorithm -Decimation in Time

Page 35: Digital Signal Processing Lecture 8€¦ · Apply N-DFT and N-IDFT where N=L+M-1. Thus, if L and M are smaller than N apply zero padding to xm[n] and h[n]. We set N = L + M -1 (the

University of Trento, Italy B. Demir

FFT Algorithm-Decimation in Time

Page 36: Digital Signal Processing Lecture 8€¦ · Apply N-DFT and N-IDFT where N=L+M-1. Thus, if L and M are smaller than N apply zero padding to xm[n] and h[n]. We set N = L + M -1 (the

University of Trento, Italy

FFT algorithm that we have included is called radix-2 FFT, as the butterfly

sell has 2 inputs and 2 outputs;

More efficient FFT can be implemented if using other radix numbers;

For Radix-4 FFT, the basic operation unit is based on 4 variables (4

inputs and 4 outputs)

B. Demir

Fast Fourier Transform Algorithm

Page 37: Digital Signal Processing Lecture 8€¦ · Apply N-DFT and N-IDFT where N=L+M-1. Thus, if L and M are smaller than N apply zero padding to xm[n] and h[n]. We set N = L + M -1 (the

University of Trento, Italy

Summary

B. Demir

Page 38: Digital Signal Processing Lecture 8€¦ · Apply N-DFT and N-IDFT where N=L+M-1. Thus, if L and M are smaller than N apply zero padding to xm[n] and h[n]. We set N = L + M -1 (the

University of Trento, Italy

Advice for FFT Users

B. Demir