Module Convolution Digital Signal Processing. Slide 4. Aim How to perform convolution in real-time systems efficiently? Is convolution in time domain equivalent to multiplication of the transformed sequence? x (n) x (n) 6 5 4 - - 4 sample 4 - - 4 x ( n) DFT X ( k) X ( k) x ( n) x ( DFT x IDFT X ( x ( n) x ( n) x x 5 5 Linear Convolution - - 4 5 6 7 IFFT(X.*X) 5 5 - - 4 5 Digital Signal Processing. Slide 4.
Contents Review of convolution techniques Linear convolution and circular convolution relationship to filtering Fast algorithms for digital filters block filtering Digital Signal Processing. Slide 4. Introduction δ ( n) hn ( ) LTI system, n = Let δ ( n) be the unit impulse sequence δ (n) =, otherwise We can write xn ( ) = xk ( ) δ ( n- k) k = - represent x(n) as sum of delayed and weighted impulse Let hn ( ) be the output for δ ( n) input hn ( ) is the impulse response Then hn ( k) is the output for δ ( n k) input LTI linear time invariance Digital Signal Processing. Slide 4.4
xn ( ) y( n) LTI system hn ( ) Then by superposition y( n) = x( k) h( n k) k = y(n) is sum of lots of delayed impulse responses This equation is called the CONVOLUTION SUM Digital Signal Processing. Slide 4.5 Linear Convolution xn ( ) y( n) Filter hn ( ) Consider unit step input: And example filter: Task: find y(n) xn ( ) = un ( ) hn ( ) = aun n ( ) Filtering is the operation of convolving a signal with the filter s impulse response. yn ( ) = xn ( )* hn ( ) = x( mhn ) ( m) m= Digital Signal Processing. Slide 4.6
For this example: yn ( ) =, n< y() = x() h() = (all other terms are zero) yn a a a n ( ) = + + + +, > a = a n+ un ( ) x(n) h(n) y(n).5 x(n) h(n) for a= -.8 5 5-5 5-5 5 5 5 4 x(n) h(n) y(n).5 x(n) h(n) for a=. 5 5 5 5 5 5 5 5 5 4 x(n) h(n) y(n).5 x(n) h(n) for a=.7 5 5.5 5 5 4 5 5 5 5 4 Digital Signal Processing. Slide 4.7 Periodic and Circular Convolution Develop ideas in terms of periodic signals and DFS, then extend to aperiodic signals. Given periodic signals x ( ) p n and x ( ) p n with discrete Fourier series coefficients given by what is x ( ) p n formed from { } x ( n) = IDFS X ( k) = X ( k) X ( k) p p p p X ( ) p k and X ( ) p k x ( ) p n x ( ) p n DFS DFS X ( ) p k x X ( ) p k X ( ) p k x IDFS ( ) p n Digital Signal Processing. Slide 4.8
Write N N X ( k) = x ( l) x ( r) e p p p l= r= then N x ( n) = X ( k) e p p N k = N p p p l= m= π j nk N π j ( lk rk) N and finally (proof-tutorial question) x ( n) = x ( l) x ( n l). Compare to linear convolution x ( n) = x ( m) x ( n m) Linear convolution: Sum over infinite extent of signals Periodic convolution: Sum over one period Digital Signal Processing. Slide 4.9 Example A Digital Signal Processing. Slide 4.
Example B So far we have x ( ) p n from a convolution of x ( ) p n with x ( ) p n Since Xp( k) = Xp( k) Xp( k) we can also obtain x ( ) p n from the IDFS of X ( ) k p Similarly Hence X ( k) = x ( n) e p p n= p = - j. nk π jπ 6 + jπ 6 [6, e, e ] X k e e jπ 6 jπ 6 ( ) = [6,, ] X k = e e p x ( n) = X ( k) e p p k = jπ jπ ( ) [6,, ] π. nk = [,, ] - as before j Digital Signal Processing. Slide 4. Periodic - Aperiodic So far we have considered periodic signals Periodic convolution Direct Via DFS Now consider aperiodic signals Circular convolution Treat aperiodic signals as one period of periodic signals Digital Signal Processing. Slide 4.
Circular Convolution Consider aperiodic signals x ( n) and x ( n) x ( n) and x ( n) are periodic extensions of x ( n) and x ( n). p p N - x( n) = one period of xp( l) xp( n l) l= x ( n) = x ( n) x ( n) { } { } DFT x ( n) = DFT x ( n) x ( n) = X ( k) X ( k) The symbol means circular convolution Perform periodic extension Take one period of the result of periodic convolution Digital Signal Processing. Slide 4. Example Consider Linear convolution of x ( n) x ( n) Consider Circular convolution of x ( n) x ( n) different length different values Digital Signal Processing. Slide 4.4
Relationship between Linear Convolution and Circular Convolution Why are we interested? Linear convolution is the filtering operation Filters are a very important application of DSP Would like to implement filters efficiently FFT is a fast DFT Maybe we can use FFTs to implement filters (?) Digital Signal Processing. Slide 4.5 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 of length N and signal of length N Zero-pad with N zeros Zero-pad with N zeros Digital Signal Processing. Slide 4.6
Example For a signal of length N and signal of length N Zero-pad with N zeros to give ' Zero-pad ' with N zeros to give Equivalent to linear convolution Digital Signal Processing. Slide 4.7 Summary { } x ( n)* x ( n) = x ( n) x ( n) = IDFT X ( k) X ( k) ' ' ' ' given that and { } X ( k) = DFT x( n) x ' ( n) is a zero-padded version of x ( n) * means Linear Convolution means Circular Convolution Digital Signal Processing. Slide 4.8
6 x (n) x (n) 5 4 - - 4 sample 4 x ( n) x ( n) N.... N x'( n) x'( n) DFT DFT X ( k) x X ( k) X ( k) IDFT x ( n) - - 4 Linear Convolution x ( n) x ( n) x - 4 6 IFFT(X.*X) x - 4 6 Digital Signal Processing. Slide 4.9 Direct implementation N multiplies Complexity DFT Implementation 4 [ ( ) + + ( ) ] = 48 + 8 N N N N N for complex multiplications DFTs of N- points FFT Implementation Product of sequences of length N IDFT N N 4 logn + N + logn = Nlog N + 8N Number of multiplications.5.5.5.5 4 x 4 Direct Implementation FFT Implementation 5 5 N Digital Signal Processing. Slide 4.
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 Sectioned convolution: two main methods Overlap add Overlap save Digital Signal Processing. Slide 4. Overlap-add Procedure yn ( ) = xmhn ( ) ( m) m= xn ( ) : data; divide into blocks of length hn ( ) : impulse response; length M L Perform linear convolution using FFT Each block of xn ( ) padded with M- zeros Each block of hn ( ) padded with L- zeros { } y ( n) = IFFT X ' ( k) H '( k) First block Computed once and stored Size of FFT: next integer power of greater than or equal to L+M- M is fixed by the filter impulse response Choose to obtain convenient size of FFT Digital Signal Processing. Slide 4.
Note that the length of y ( n) is L+M- first L are true values M- are in the overlap { } y ( n) = IFFT X ' ( k) H '( k) second block y ( n) is added to y ( n) with a shift of L L L L M zeros M zeros M zeros + + Digital Signal Processing. Slide 4. Overlap-save Procedure yn ( ) = xmhn ( ) ( m) m= xn ( ) : data; divide into blocks of length hn ( ) : impulse response; length M L Perform linear convolution using FFT Each block of xn ( ) consists of the last M- data points from previous data block follow by L new points Each block of hn ( ) padded with L- zeros { } y ( n) = IFFT X ' ( k) H '( k) First block Computed once and stored Size of FFT: next integer power of greater than or equal to L+M- M is fixed by the filter impulse response Choose to obtain convenient size of FFT Digital Signal Processing. Slide 4.4
Note that the length of is L+M- last L are true values M- are in the overlap { } y ( n) = IFFT X ' ( k) H '( k) second block Discard the first M-, only last L are saved M zeros L L L L x [ n] M x [ n] M x [ n] M y[ n] M y [ n] M y [ n] Digital Signal Processing. Slide 4.5 Correlation Operation to determine some measure of similarity between two signals Correlation of two signals xn ( ) and y( n) is defined as r ( l) = x( n) y( n l), l =, ±, ±,... xy n= l is the index of the correlation function rxy () l and is referred to as lag Autocorrelation is the special case when xn ( ) = y( n) Digital Signal Processing. Slide 4.6
Relationship between correlation and convolution Convolution s( n) = x( m) y( n m) m= = xn ( ) y( n) Time reversed and delayed of y[m] Correlation r () l = x( n) y( n l) xy n= = xny ( ) ( ( l n)) n= = xl () y( l) Delayed of y[n] Therefore, correlation can be implemented by a convolution algorithm providing one of the inputs is given time-inversed Digital Signal Processing. Slide 4.7 We can write Property of Correlation r () l = x( n) y( n l) xy n= = xn ( + l) yn ( ), l=, ±, ±... n= Similarly, r ( ) ( ) ( ) yx l = y nxn l n= = yn ( + lxn ) ( ), l=, ±, ±... n= From which, we can deduce that r () l = r ( l) xy For the autocorrelation function, we obtain an even function r () l = r ( l) xx yx xx Digital Signal Processing. Slide 4.8