Documente Academic
Documente Profesional
Documente Cultură
Convolution
Aim
How to perform convolution in real-time systems efficiently? Is convolution in time domain equivalent to multiplication of the transformed sequence?
6 5 4 x1(n) 3 2 1 0 -2 -1 0 1 sample 2 3 4
x1 (n)
DFT DFT
20
X 1 (k )
x
x2 (n) X 2 (k )
Linear Convolution
X 3 (k )
IDFT
x3 (n)
3 x2(n)
0 -2
-1
1 samples
x1 (n) x2 (n)
Contents
Review of convolution techniques Linear convolution and circular convolution
relationship to filtering
Introduction
0
( n)
h( n)
LTI system
1, n = 0 0, otherwise
x ( n) =
k =-
x(k ) (n - k )
represent x(n) as sum of delayed and weighted impulse Let h(n) be the output for (n) input h(n) is the impulse response Then h(n k ) is the output for (n k ) input LTI linear time invariance
x ( n)
LTI system
y ( n)
h( n)
k =
x ( k ) h( n k )
y(n) is sum of lots of delayed impulse responses This equation is called the CONVOLUTION SUM
Linear Convolution
x ( n)
Filter
y ( n)
h( n)
Consider unit step input: x(n) = u (n) And example filter: h( n) = a n u ( n) Task: find y(n) Filtering is the operation of convolving a signal with the filters impulse response.
y ( n) = x ( n) * h( n) =
m =
x ( m) h( n m)
Digital Signal Processing. Slide 4.6
y ( n) = 1 + a + a 2 + + a 3 , n > 0 1 a n +1 = u ( n) 1 a
x(n) h(n) for a=1.3
1 x(n) 0.5 0 1 h(n) 0.5 0 4 y(n) 2 0 0 5 0 0
10 samples
15
20
10 samples
15
20
10 samples
15
20
10 samples
15
20
15
20 samples
25
30
35
40
10
15
20 samples
25
30
35
40
x3 p (n) = IDFS{ X 3 p (k ) = X 1 p (k ) X 2 p (k )}
x1 p (n) x2 p (n)
DFS DFS
X 1 p (k )
x
X 2 p (k )
X 3 p (k )
IDFS
x3 p (n)
Write X 3 p (k ) = x1 p (l ) x2 p (r ) e
l =0 r =0 N 1 N 1 j 2 ( lk rk ) N
then
2 j nk 1 N 1 x3 p (n) = X 3 p (k ) e N N k =0 and finally (proof-tutorial question)
x3 p (n) = x1 p (l ) x2 p (n l ).
l =0
N 1
x ( m) x ( n m)
1 2
Periodic convolution:
Sum over one period
Example A
Example B
So far we have x3 p (n) from a convolution of x1 p (n) with x2 p (n) Since X 3 p (k ) = X 1 p (k ) X 2 p (k ) we can also obtain x3 p (n) from the IDFS of X 3 p (k )
X 1 p (k ) = x1 p (n) e- j
n=0
3 . nk
= [6,
Similarly
3e j 6 , 3e j 6 ,
3e + j 6 ] 3e j 6 ]
X 2 p (k ) = [6,
X 3 p (k ) = [36, 3e j 3 , 3e j 3 ]
Hence
x3 p (n) =
Periodic - Aperiodic
So far we have considered periodic signals
Periodic convolution
Direct Via DFS
Circular Convolution
Consider aperiodic signals x1 (n) and x2 (n)
x1 p (n) and x2 p (n) are periodic extensions of x1 (n) and x2 (n). N -1 x3 (n) = one period of x1 p (l ) x2 p (n l ) l =0 x3 (n) = x1 (n) x2 (n)
Example
Consider Linear convolution of x1 (n) x2 (n)
We desire that circular and linear convolution give identical results, then we can use FFTs for fast filtering This can be achieved by applying zero-padding to the signals before performing circular convolution For a signal x1 (n) of length N1 and signal x2 (n) of length N 2 Zero-pad x1 (n) with N 2 1 zeros Zero-pad x2 (n) with N1 1 zeros
Example
For a signal x1 (n) of length N1 and signal x2 (n) of length N 2 Zero-pad x1 (n) with N 2 1 zeros to give x1' (n) ' Zero-pad x2 (n) with N1 1 zeros to give x2 (n)
Summary
' ' x1 (n) * x2 (n) = x1' (n) x2 (n) = IDFT { X 1' (k ) X 2 (k )}
6 5 4 x1(n) 3 2 1 0 -2 -1 0 1 sample 2 3 4
N2 1
x1 (n)
00..00
x '1 (n)
DFT
X 1 (k )
x
x2 (n)
X 3 (k )
IDFT
x3 (n)
3 x2(n)
X 2 (k )
0 -2
-1
1 samples
Linear Convolution
x1 (n) x2 (n)
x3
10 0 -2 20
2 4 samples IFFT(X1.*X2)
x3
10 0 -2
2 samples
Complexity
Direct implementation N 2 multiplies DFT Implementation
4 [2 (2 N ) 2
for complex multiplications
+ 2N
+ (2 N ) 2 ] =
1 IDFT
48 N 2 + 8 N
x 10
FFT Implementation
Direct Implementation
0 0
150
200
Block Filtering
FFT-based convolution has advantage of lower computational complexity
But if data is long, must wait until all the data is captured Long delay
Solution
Use block filtering Use FFT-based convolution on short blocks of data Then join blocks together
Overlap-add Procedure
y ( n) =
m =
x ( m) h ( n m)
x(n) : data; divide into blocks of length L h(n) : impulse response; length M
Perform linear convolution using FFT Each block of x( n) padded with M-1 zeros Each block of h( n) padded with L-1 zeros
y1 ( n) = IFFT { X '1 (k ) H '(k ) }
First block Computed once and stored
M 1 zeros M 1 zeros
M 1 zeros
+
Digital Signal Processing. Slide 4.23
Overlap-save Procedure
y ( n) =
m =
x ( m) h ( n m)
x(n) : data; divide into blocks of length L h(n) : impulse response; length M Perform linear convolution using FFT Each block of x( n) consists of
the last M-1 data points from previous data block follow by L new points
Discard the first M-1 samples, only last L samples are saved
M 1 zeros
L L L
L
x1[ n]
M 1 M 1
x2 [n] x3[n]
M 1
y1[n]
M 1 M 1
y2 [ n ] y3 [n]
Correlation
Operation to determine some measure of similarity between two signals Correlation of two signals x(n) and y ( n) is defined as
rxy (l ) =
n =
x ( n) y ( n l ) ,
l = 0, 1, 2,...
l is the index of the correlation function rxy (l ) and is referred to as lag Autocorrelation is the special case when x( n) = y ( n)
s ( n) =
m =
x ( m) y ( n m)
Time reversed and delayed samples of y[m]
= x ( n) y ( n)
Correlation
rxy (l ) =
n = n =
x ( n) y ( n l )
Delayed samples of y[n]
= x(l ) y (l )
Therefore, correlation can be implemented by a convolution algorithm providing one of the inputs is given time-inversed
Property of Correlation
We can write rxy (l ) =
=
ryx (l ) =
n = n =
x ( n) y ( n l )
l = 0, 1, 2...
x(n + l ) y(n),
n = n =
Similarly,
y ( n) x ( n l )
l = 0, 1, 2...
y(n + l ) x(n),
rxy (l ) = ryx (l )
For the autocorrelation function, we obtain an even function
rxx (l ) = rxx (l )