discrete fourier transformation –ii - 会津大学 -...

22
Produced by Qiangfu Zhao (Since 1995), All rights reserved © DSP-Lec08/1 Digital signal processing: Lecture 8 Discrete Fourier Transformation –II Chapter 4: Fast Fourier Transformation

Upload: buihuong

Post on 27-Jun-2018

219 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Discrete Fourier Transformation –II - 会津大学 - …web-ext.u-aizu.ac.jp/~qf-zhao/TEACHING/DSP/lec08.pdf• Convolution based on FFT. • Filtering based on FFT. • Cross-correlation

Produced by Qiangfu Zhao (Since 1995), All rights reserved © DSP-Lec08/1

Digital signal processing: Lecture 8

Discrete Fourier Transformation –II

Chapter 4: Fast Fourier Transformation

Page 2: Discrete Fourier Transformation –II - 会津大学 - …web-ext.u-aizu.ac.jp/~qf-zhao/TEACHING/DSP/lec08.pdf• Convolution based on FFT. • Filtering based on FFT. • Cross-correlation

Produced by Qiangfu Zhao (Since 1995), All rights reserved © DSP-Lec08/2

Topics of last lecture• Discrete Fourier

transformation (DFT)• Linearity• Periodicity• Periodicity Symmetry• Direct computation of

DFT

• 離散フーリエ変換(DFT)

• DFTの線形性

• DFTの周期性

• DFTの対称性

• DFTの直接的計算

Page 3: Discrete Fourier Transformation –II - 会津大学 - …web-ext.u-aizu.ac.jp/~qf-zhao/TEACHING/DSP/lec08.pdf• Convolution based on FFT. • Filtering based on FFT. • Cross-correlation

Produced by Qiangfu Zhao (Since 1995), All rights reserved © DSP-Lec08/3

Topics of this lecture• Fast Fourier transform.• Computational cost of

FFT.• Convolution based on

FFT.• Filtering based on FFT.• Cross-correlation based

on FFT.

• 高速フーリエ変換

• FFTの計算量

• FFTに基づく畳み込み

• FFTに基づくフィルタリング

• FFTに基づく相関

Page 4: Discrete Fourier Transformation –II - 会津大学 - …web-ext.u-aizu.ac.jp/~qf-zhao/TEACHING/DSP/lec08.pdf• Convolution based on FFT. • Filtering based on FFT. • Cross-correlation

Produced by Qiangfu Zhao (Since 1995), All rights reserved © DSP-Lec08/4

The fast Fourier transform (FFT)

• The basic idea is to use the symmetric and periodic properties of e-j2πkn/N.

• Suppose that N=2p.

• The DFT can be divided into two parts as follows:

• Since the computational cost for each part is (N/2)2, and we can combine the results using N computations, the total cost can be reduced.

∑∑∑==

=

+==oddn

knN

evenn

knN

N

n

knN WnxWnxWnxkX )()()()(

1

0

Page 5: Discrete Fourier Transformation –II - 会津大学 - …web-ext.u-aizu.ac.jp/~qf-zhao/TEACHING/DSP/lec08.pdf• Convolution based on FFT. • Filtering based on FFT. • Cross-correlation

Produced by Qiangfu Zhao (Since 1995), All rights reserved © DSP-Lec08/5

)()(

))(())((

))(12())(2(

))(12())(2(

)()()()(

10

2

12

01

12

0 20

2

12

0

12

0 2

12

0

212

0

2

1

0

kXWkX

WrxWWrx

WrxWWrx

WrxWWrx

WnxWnxWnxkX

kN

krN

N/

r

kN

krN/

rN

krN

N/

r

kN

krN/

rN

krN/

rN

kN

krN/

rN

oddn

knN

evenn

knN

N

n

knN

+=

+=

++=

++=

+==

∑∑

∑∑

∑∑

∑∑∑

=

=

=

=

=

=

==

=

Page 6: Discrete Fourier Transformation –II - 会津大学 - …web-ext.u-aizu.ac.jp/~qf-zhao/TEACHING/DSP/lec08.pdf• Convolution based on FFT. • Filtering based on FFT. • Cross-correlation

Produced by Qiangfu Zhao (Since 1995), All rights reserved © DSP-Lec08/6

12/,...,1,0 ,)()()2/(

12/,...,1,0 ,)()()( :follows as )( find can We

since Also,

property theused have we,derivation above theIn

10

10

2/

2

))2//(2()/2(22

−=−=+

−=+=

−=

===

+

−−

NkkXWkXNkXNkkXWkXkX

kXWW

WeeW

kN

kN

NkN

kN

NNjNj

Nππ

Page 7: Discrete Fourier Transformation –II - 会津大学 - …web-ext.u-aizu.ac.jp/~qf-zhao/TEACHING/DSP/lec08.pdf• Convolution based on FFT. • Filtering based on FFT. • Cross-correlation

Produced by Qiangfu Zhao (Since 1995), All rights reserved © DSP-Lec08/7

Graphically, we have

Page 8: Discrete Fourier Transformation –II - 会津大学 - …web-ext.u-aizu.ac.jp/~qf-zhao/TEACHING/DSP/lec08.pdf• Convolution based on FFT. • Filtering based on FFT. • Cross-correlation

Produced by Qiangfu Zhao (Since 1995), All rights reserved © DSP-Lec08/8

This process can be continued

Page 9: Discrete Fourier Transformation –II - 会津大学 - …web-ext.u-aizu.ac.jp/~qf-zhao/TEACHING/DSP/lec08.pdf• Convolution based on FFT. • Filtering based on FFT. • Cross-correlation

Butterfly operation• The division is continued until N=2.• For N=2, two outputs can be obtained from two

inputs using the butterfly operation.

Produced by Qiangfu Zhao (Since 1995), All rights reserved © DSP-Lec08/9

)21.4( )()()()20.4( )()()(

1

1

rXWqXrXrXWqXqX

kNss

kNss

−=

+=

+

+

Page 10: Discrete Fourier Transformation –II - 会津大学 - …web-ext.u-aizu.ac.jp/~qf-zhao/TEACHING/DSP/lec08.pdf• Convolution based on FFT. • Filtering based on FFT. • Cross-correlation

Flow of FFT (Fig. 4.6 p. 56)

Produced by Qiangfu Zhao (Since 1995), All rights reserved © DSP-Lec08/10

Page 11: Discrete Fourier Transformation –II - 会津大学 - …web-ext.u-aizu.ac.jp/~qf-zhao/TEACHING/DSP/lec08.pdf• Convolution based on FFT. • Filtering based on FFT. • Cross-correlation

Produced by Qiangfu Zhao (Since 1995), All rights reserved © DSP-Lec08/11

Computational cost of FFT• An N-point DFT can be divided into two N/2-point

DFTs.• Computation amount is reduced (if N>2) to

N+2(N/2)2 from N2.

• Similarly, the N/2-point DFT can be divided into two N/4-point DFTs.

• This division can be continued until there are only two points.

• The total number of multiplications is (N/2)log2N.• The total number of additions is Nlog2N.

Page 12: Discrete Fourier Transformation –II - 会津大学 - …web-ext.u-aizu.ac.jp/~qf-zhao/TEACHING/DSP/lec08.pdf• Convolution based on FFT. • Filtering based on FFT. • Cross-correlation

Find the convolution sum of two N-point discrete signals (p. 62)

∑=

−=N

kknxkxny

nyNnxnxN

021

21

)()()(

by calculated )( signal discretepoint -2An :Result).( and )( signals discretepoint - Two :Given

Produced by Qiangfu Zhao (Since 1995), All rights reserved © DSP-Lec08/12

Page 13: Discrete Fourier Transformation –II - 会津大学 - …web-ext.u-aizu.ac.jp/~qf-zhao/TEACHING/DSP/lec08.pdf• Convolution based on FFT. • Filtering based on FFT. • Cross-correlation

Find the convolution sum with FFT

• If we find the convolution sum directly, the number of computations will be O(N2).

• If we use FFT, the computation cost can be reduced to Nlog2N.

• For this purpose, we need the following steps:– Step 1: Extend each signal to 2N-1 points;– Step 2: Find the DFT of each signal;– Step 3: Multiply the results;– Step 4: Find the IDFT.

• The cost will be 2xNlog2(2N)=O(Nlog2N).

Produced by Qiangfu Zhao (Since 1995), All rights reserved © DSP-Lec08/13

(p. 62)

Page 14: Discrete Fourier Transformation –II - 会津大学 - …web-ext.u-aizu.ac.jp/~qf-zhao/TEACHING/DSP/lec08.pdf• Convolution based on FFT. • Filtering based on FFT. • Cross-correlation

Example 4.3 p. 62-63

Produced by Qiangfu Zhao (Since 1995), All rights reserved © DSP-Lec08/14

Page 15: Discrete Fourier Transformation –II - 会津大学 - …web-ext.u-aizu.ac.jp/~qf-zhao/TEACHING/DSP/lec08.pdf• Convolution based on FFT. • Filtering based on FFT. • Cross-correlation

Find the response of an FIR filter

Produced by Qiangfu Zhao (Since 1995), All rights reserved © DSP-Lec08/15

∑=

−=N

kknxkhny

nxnh

0)()()(

by calculated system theof Response :Result

:system theofInput :)( system LTIan of response Impulse:)(

:Given

Merit: We can use FFT to reduce the computational cost.Problem: The length of x(n) can be much longer!

Page 16: Discrete Fourier Transformation –II - 会津大学 - …web-ext.u-aizu.ac.jp/~qf-zhao/TEACHING/DSP/lec08.pdf• Convolution based on FFT. • Filtering based on FFT. • Cross-correlation

Filtering with an FIR system

Produced by Qiangfu Zhao (Since 1995), All rights reserved © DSP-Lec08/16

Taken from Digital Signal Processing, written by Oppenheim, and translated by H. Date.

Page 17: Discrete Fourier Transformation –II - 会津大学 - …web-ext.u-aizu.ac.jp/~qf-zhao/TEACHING/DSP/lec08.pdf• Convolution based on FFT. • Filtering based on FFT. • Cross-correlation

Produced by Qiangfu Zhao (Since 1995), All rights reserved © DSP-Lec08/17

Overlap-add method for finding the response of an FIR filter using convolution.

Taken from Digital Signal Processing, written by Oppenheim, and translated by H. Date.

Page 18: Discrete Fourier Transformation –II - 会津大学 - …web-ext.u-aizu.ac.jp/~qf-zhao/TEACHING/DSP/lec08.pdf• Convolution based on FFT. • Filtering based on FFT. • Cross-correlation

Find the cross-correlation of two signals

• Cross-correlation is a measure of similarity between two signals or patterns.

• Cross-correlation can be used to find features in an unknown signal by comparing it to a known one. It has applications in pattern (e.g. image and text) detection, which is useful for information retrieval.

• The cross-correlation is similar to the convolution of two signals. Convolution involves reversing a signal, then shifting it and multiplying by another signal.

• Both cross-correlation and convolution can be found efficiently using FFT.

Produced by Qiangfu Zhao (Since 1995), All rights reserved © DSP-Lec08/18

Page 19: Discrete Fourier Transformation –II - 会津大学 - …web-ext.u-aizu.ac.jp/~qf-zhao/TEACHING/DSP/lec08.pdf• Convolution based on FFT. • Filtering based on FFT. • Cross-correlation

Produced by Qiangfu Zhao (Since 1995), All rights reserved © DSP-Lec08/19

Definition of cross-correlation

n.correlatio-auto called is ncorrelatio-cross thesame, theare )( and )( If conjugate.

complex theindicatesasterisk t superscrip thewhere

)()()()(

by defined is correction-cross their ),( and )( signals twoGiven

21

2*121

21

nxnx

mnxmxnxnx

nxnx

m∑∞

−∞=

+=⊗

Page 20: Discrete Fourier Transformation –II - 会津大学 - …web-ext.u-aizu.ac.jp/~qf-zhao/TEACHING/DSP/lec08.pdf• Convolution based on FFT. • Filtering based on FFT. • Cross-correlation

Produced by Qiangfu Zhao (Since 1995), All rights reserved © DSP-Lec08/20

Finding the cross-correlation using FFT

• Similar to convolution theorem, we have

• Therefore, we can find the cross-correlation efficiently using FFT as follows:– Step 1: Extend the lengths (durations) of the two

signals to 2N-1;– Step 2: Find the DFT of the two signals.– Step 3: Find the complex conjugate of DFT[x1(n)].– Step 4: Multiplication.– Step 5: Find the IDFT.

)]([DFT)]([DFT)]()([DFT 2*

121 nxnxnxnx ⋅=⊗

Page 21: Discrete Fourier Transformation –II - 会津大学 - …web-ext.u-aizu.ac.jp/~qf-zhao/TEACHING/DSP/lec08.pdf• Convolution based on FFT. • Filtering based on FFT. • Cross-correlation

Homework

Produced by Qiangfu Zhao (Since 1995), All rights reserved © DSP-Lec08/21

• Revise the program given in p. 63, and find x3(n)=x1(n)*x2(n), using FFT, where * is the convolution sum, and x1(n) and x2(n) are given below.– To understand the basic steps, see slide 13.– Plot and print x1,x2, and x3; and their FFTs.– Submit the hardcopies before the deadline.

x1=[1 2 3 4 5 6 7 8];x2=[1 2 3 4 5 4 3 2];

Page 22: Discrete Fourier Transformation –II - 会津大学 - …web-ext.u-aizu.ac.jp/~qf-zhao/TEACHING/DSP/lec08.pdf• Convolution based on FFT. • Filtering based on FFT. • Cross-correlation

Quiz and self-evaluation

0

0.2

0.4

0.6

0.8

1

1.2T1

T2

T3T4

T5

Name: Student ID: .

• For a N=16 point DFT, how many percent of computations can we reduce if we use FFT? The rate of reduction is calculated as follows:

Answer:

• How about the reduction rate for N=64?

Answer:

% DFTofCost

FFTofCost - DFTofCost =R