Signals, Instruments, and Systems – W5 Introduction to Signal Processing – Convolution, Sampling, Reconstruction 1 Motivation from Week 1 Lecture Processing Sensing Processing Communication Mobility In-situ instrument Visualization Storing Transportation channel Base station Highlighted blocks are those mainly leveraging the content of this lecture. 2 Convolution 3 Convolution f g (t ) f ( ) g (t )d • For each value of t: 1. Flip (reflect) g 2. Shift g by t 3. Multiply f and g 4. Integrate over 1) g ( ) g ( ) 2) g ( ) g (t ) 3) f ( ) g (t ) 4) f ( ) g (t )d • Note that the result does not depend on ! 4 [Matlab demo “cconvdemo”] http://users.ece.gatech.edu/mcclella/matlabGUIs/ 5 Examples 1.4 1 1 0.8 0.8 * 0.6 0.4 0.2 -2 -1.5 -1 -0.5 0 0.5 1 1.5 2 1.2 1 = 0.6 0.4 0.2 0.8 0.6 0.4 0.2 -2 -1.5 -1 -0.5 0 0.5 1 1.5 2 -2 -1.5 -1 -0.5 0 0.5 1 1.5 2 6 Examples 1 1 1 0.8 0.8 0.8 = * 0.6 0.6 0.4 0.4 0.2 0.2 -2 -1.5 -1 -0.5 0 0.5 1 1.5 2 0.6 0.4 0.2 -2 -1.5 -1 -0.5 0 0.5 1 1.5 2 -2 -1.5 -1 -0.5 0 0.5 1 1.5 2 7 Examples 1 1 1 0.8 0.8 0.8 = * 0.6 0.6 0.4 0.4 0.2 0.2 -2 -1.5 -1 -0.5 0 0.5 1 1.5 2 -2 -1.5 -1 -0.5 0 0.5 1 1.5 2 0.6 0.4 0.2 -2 -1.5 -1 -0.5 0 0.5 1 1.5 2 8 Examples 1 1 1 0.8 0.8 0.8 = * 0.6 0.6 0.4 0.4 0.2 0.2 -2 -1.5 -1 -0.5 0 0.5 1 1.5 2 -2 -1.5 -1 -0.5 0 0.5 1 1.5 2 0.6 0.4 0.2 -2 -1.5 -1 -0.5 0 0.5 1 1.5 2 9 Examples 1 1 0.8 0.8 * 0.6 0.4 0.2 -2 -1.5 -1 -0.5 0 0.5 1 1.5 2 1 = 0.6 0.4 0.2 -2 -1.5 -1 -0.5 0 0.5 1 1.5 2 0.8 0.6 0.4 0.2 -2 -1.5 -1 -0.5 0 0.5 1 1.5 2 10 Convolution in Time and Frequency Domains h(t ) ( f g )(t ) hˆ( ) fˆ ( ) gˆ ( ) h(t ) f (t ) g (t ) hˆ( ) ( fˆ gˆ )( ) Ordinary frequency Frequency domain h(t ) ( f g )(t ) H ( ) F ( ) G ( ) 1 h(t ) f (t ) g (t ) H ( ) ( F G )( ) 2 Angular frequency Time domain 11 Convolution Properties Commutativ ity f g g f Associativity f ( g h) ( f g ) h Distributivity f ( g h) ( f g ) ( f h) Associativity with scalar multiplica tion a ( f g ) (af ) g f (ag ) 12 Discrete Convolution f g (t ) f ( ) g (t )d f g [n ] f [m] g[n m] m Notes: • Similar to the continuous version • The integral becomes an infinite sum • Matlab, operating on a computer (i.e. a digital device) can only emulate continuity and therefore use the discrete version with an adjustable discretization level (in time and amplitude) and finite bounds of the convolution window 13 [Matlab demo “dconvdemo”] http://users.ece.gatech.edu/mcclella/matlabGUIs/ 14 Sampling 15 Analog – Digital 8 8 Signal Amplitude 10 Signal Amplitude 10 6 4 2 0 -2 -4 6 4 2 0 -2 0 100 200 300 400 500 600 700 Time • Analog – Continuous – Real world 800 900 1000 -4 0 100 200 300 400 500 600 700 800 900 1000 Time • Digital – Discrete – Digital world 16 Train of Dirac Impulses x(t ) (t nT ) n 17 Train of Dirac Impulses x (t ) (t nT ) n 1 x ( t ) ak T X ( ) T /2 x (t )e j0t dt T / 2 1 T 2 k 2 T T n Time domain Frequency domain F() 18 Sampling in Time Domain x(t ) p (t ) (t nT ) Train of Dirac pulses n x p (t ) x(t ) p (t ) n n x(t ) (t nT ) x(nT ) (t nT ) T = sampling period f = 1/T = sampling frequency 19 Sampling in Frequency Domain Time domain Frequency domain x p (t ) x (t ) p (t ) Convolution property 1 X p ( ) X ( ) * P ( ) 2 2 Sampling s 2 T frequency ( ) P( ) k S T k 1 X p ( ) X ( ) * ( kS ) T k 1 X ( kS ) T k 20 Sampling a Band-Limited Signal X(ω) → spectrum of signal x(t) with highest frequency < ωm 2 P( ) T ( k ) S k Sampling frequency ωs > 2 ωm 1 X ( ) * P ( ) 2 1 X ( kS ) T k X p ( ) 21 Sampling a Band-Limited Signal X(ξ) → spectrum of signal x(t) with highest frequency < 2 kHz Sampling frequency: 5 kHz > 2 * 2 kHz 22 Sampling a Band-Limited Signal X(ξ) → spectrum of signal x(t) with highest frequency < 3 kHz Sampling frequency: 5 kHz < 2 * 3 kHz 23 Original Signal 1.5 1 0.5 0 -0.5 -1 -1.5 -1 -0.8 -0.6 -0.4 -0.2 0 0.2 Time [s] 0.4 0.6 0.8 1 f (t ) sin( 2t ) 0.4 sin( 2 2t ) 0.2 sin( 2 5t ) 24 Too Few Samples (1Hz) 1.5 1 0.5 0 -0.5 -1 -1.5 -1 -0.8 -0.6 -0.4 -0.2 0 0.2 Time [s] 0.4 0.6 0.8 1 → Data is lost 25 Too Many Samples (100 Hz) 1.5 1 0.5 0 -0.5 -1 -1.5 -1 -0.8 -0.6 -0.4 -0.2 0 0.2 Time [s] →Redundant data →Increase of data size 0.4 0.6 0.8 1 26 Minimal Possible Sampling (> 10 Hz) 1.5 1 0.5 0 -0.5 -1 -1.5 -1 -0.8 -0.6 -0.4 -0.2 0 0.2 Time [s] 0.4 0.6 0.8 1 27 Nyquist–Shannon Theorem • If a function x(t) contains no frequencies higher than B Hz, it is completely determined by giving its coordinates at a series of points spaced 1/(2B) seconds apart. • Sampling frequency must be at least two times greater than the maximal signal frequency 28 Sampling in Practice • Sampling frequency two times greater than maximal frequency is the limit • If possible, try to use a sampling frequency 10 times greater than the maximal frequency • Audio CD, sampling at 44.1 kHz Maximal hearable frequency: 20 kHz 29 Signal Reconstruction 30 p (t ) t nT n x(t ) x x p (t ) H ( ) xr (t ) If there is no overlap between the shifted spectra the signal xr(t) can be perfectly reconstructed from x(t) spectrum of original signal spectrum of sampled signal sampling frequency ωs > 2 ωm filtering filter cut-off frequency ωm < ωc < (ωs –ωm) X r ( ) X p ( ) H ( ) spectrum of reconstructed signal 31 p (t ) t nT n x(t ) x x p (t ) H ( ) xr (t ) If there is overlap between the shifted spectra the signal xr(t) cannot be perfectly reconstructed from x(t) spectrum of original signal spectrum of sampled signal sampling frequency fs < 2 fm filtering filter cut-off frequency fc fm < fc < (fs –fm) X r ( ) X p ( ) H ( ) spectrum of reconstructed signal 32 Time Domain Interpretation of Signal Reconstruction p (t ) t nT n x x(t ) xr (t ) ωm < ωc < (ωs –ωm) xr (t ) x p (t ) * h(t ) xnT t nT * h(t ) n with h(t ) T sin c t t xnT ht nT n F-1() xnT n T sin c t nT t nT The lowpass filter interpolates the samples assuming x(t) contains no energy at frequencies > ωc (ωc =cutoff frequency) 33 From Prof. A. S. Willsky, Signals and Systems course 34 Signal Reconstruction Methods 1. Zero-order hold 2. First-order hold – linear interpolation 3. Whittaker-Shannon interpolation (bandlimited interpolation): x (t ) t nTs x ( nT ) sinc s T n s t x (t ) x ( nTs ) (t nTs ) sinc n Ts • • (Alternative equivalent formulation) Signal has to be band limited (i.e. Fourier transform for frequencies greater than B equal 0) The sampling rate must exceed twice the bandwidth, 2B 1 Ts 2B or f s 2B 35 From Prof. A. S. Willsky, Signals and Systems course 36 Aliasing 37 No Problems in Reconstruction 38 Reconstruction Problems Overlapping Alias 39 Harmonics Fundamental Frequency 40 Harmonics 1 0.5 0 -0.5 -1 -0.5 -0.4 -0.3 -0.2 -0.1 0 0.1 Time [s] 1Hz 2Hz 3Hz 4Hz 0.2 0.3 0.4 0.5 41 La-Tone (440 Hz) sampled at 44.1 kHz (CD standard) 42 La-Tone (440 Hz) sampled at 2 kHz without filtering 43 La-Tone (440Hz) sampled at 2 kHz filtered at 1 kHz 44 Aliasing Audio Examples Original sound Aliases 4 kHz Correct sampling 4 kHz 45 Moiré Pattern 46 Aliasing Video Examples https://www.youtube.com/watch?v=R-IVw8OKjvQ http://www.youtube.com/watch?v=jHS9JGkEOmA 47 Conclusion 48 Take Home Messages When you sample a signal … 1. Make sure you know what the maximum frequency fmax is or enforce it through a low-pass filter 2. Make sure you sample at fs > 2 fmax (Nyquist rule) 49 Additional Literature – Week 5 Books: • Ronald W. Schafer and James H. McClellan “DSP First: A Multimedia Approach”, 1998 • A. Oppenheim and A. S. Willsky with S. Hamid, “Signals and Systems”, Prentice Hall, 1996. 50