Presentation is loading. Please wait.

Presentation is loading. Please wait.

Signal Filters Purposes Separate Signals Eliminate interference distortions Remove unwanted data Restore to its original form (after transmission) Model.

Similar presentations


Presentation on theme: "Signal Filters Purposes Separate Signals Eliminate interference distortions Remove unwanted data Restore to its original form (after transmission) Model."— Presentation transcript:

1 Signal Filters Purposes Separate Signals Eliminate interference distortions Remove unwanted data Restore to its original form (after transmission) Model a physical system (stock market behavior) Enhance desired components (speech recognition ) Examples Breathing interference on heartbeat sound Poor quality recordings Background Noise Categories Analog: electronic circuits with resistors and capacitors Digital: Numerical calculations on signal samples

2 Filter Characteristics

3 Analog Filter Characteristics Ripple: wave in the pass frequencies Roll off: transition from pass to fail Step response: response to quick signal changes Overshoot: increased amplitude at the point of roll off Ringing: decreasing oscillations The analog filter determines what frequencies we see in the computer Flat Frequency Response Sharp Roll-off

4 Filter Jargon Rise time: Time for step response to go from 10% to 90% Linear phase: Rising edges match falling edges. Constant phase change in the frequency response. Overshoot: amount amplitude exceeds the desired value Pass band: the allowed frequencies Stop band: the blocked frequencies Transition band: frequencies between pass or stop bands Cutoff frequency: point between pass and transition bands Roll off: slope of the transition area Pass band ripple: oscillations in the pass band Stop band attenuation: reduction of stop band amplitude

5 Filter Performance

6 Analyzing a unknown filter Impulse response: Feed a delta function and see what comes out. Reverse engineer what the filter does. (δ(t) = 1 if t = 0; 0 otherwise) Step response: Feed in a step function and see what comes out. Good for determining change points in the signal. (µ(t) = { 1 if t>=0; 0 otherwise}) Frequency response: Perform a spectral analysis. Separate a signal into its component sinusoids. Example: separate light frequencies in a signal.

7 Understanding Digital Signal Processing, Third Edition, Richard Lyons (0-13-261480-4) © Pearson Education, 2011.

8 Digital Filters in Electronics 1.Sample and digitize a signal of voltages or current fluctuations with an analog to digital converter resulting in an array of numbers 2.Perform an algorithm that performs linear numerical calculations on the signal 3.Output the resulting array of filtered samples through digital to analog converter Original analog Original digitized Filtered digital Filtered analog Implementation Steps

9 Time Domain Filters Finite Impulse Response – Filter only affects the data samples, hence the filter only effects a fixed number of data points – y[n] = b 0 s n + b 1 s n-1 + …+ b M-1 s n-M+1 =∑ k=0,M-1 b k s n-k Infinite Impulse Response (also called recursive) – Filter affects the data samples and previous filtered output, hence the effect can be infinite – t[n] = ∑ k=0,M-1 b k s n-k + ∑ k=0,M-1 a k t n-k If a signal was linear, so is the filtered signal – Why? Because we summed samples multiplied by constants, we did not multiply different samples or raise samples to a power

10 Convolution The Convolution algorithm generates output by applying a convolution kernel to a signal –Input is a set of samples –Output from each sample is scaled and shifted according to the convolution kernel –Outputs add together to get the overall output Convolution implementations –The shift and scaling operations preserve linearity for signals that we deal with –The number of calculations per input sample can be prohibitive The heart of designing and implementing digital filters

11 Convolution Example Apply h to each index (i) of the input signal Sample calculation when i=4 y[4] = x[4]*h[0] + x[3]*h[1] + x[2]*h[2] + x[1]*h[3] = (1.4*1.0) + (2*-.5) + (-1.4 *-.35) + (-1*-.1) = +1.4 -1.0 +0.49 +0.1 = 0.99 Assume x = {0, -1, -1.4, 2, 1.4, 1.4,.8, 0, -.6} h = {1, -0.5, -0.35, -0.1} Filter Kernel Traditional convolution symbol

12 The Convolution Machine

13 The Convolution Machine (cont.)

14 Convolution Properties Distributive Commutative Associative

15 Properties of Convolution (cont.) Shift Identity

16 Convolution Examples

17 Identity and Amplify Top Figure –The signal remains unchanged Bottom Figure –The signal’s amplitude is multiplied by 1.6 –Attenuation can occur by picking a magnitude that is less than one y[n] = k δ[n]

18 Shift and Echo Top Figure –Delay the output by four samples –An advance is possible using the negative indices Bottom Figure –Produce an echo that has an amplitude of 60% of the original signal y[n] = x[n] * δ [n-s]

19 Band Limiting Filters Goal: Attenuate undesired frequencies Low-pass: Attenuate high frequencies High-pass: Attenuate low frequencies Band-pass: Attenuate “out of band” frequencies Design Considerations –Number taps (length of the filter kernel array) –Transition band width –Pass band ripple and stop band attenuation

20 Filter Examples 31 taps

21 Convolution Code /** @param x input signal @param h convolution kernel @result convolved signal */ int[] convolve(int[] x, int[] h) { int[] y = new int[x.length+h.length-1]; for (int k=0; k<y.length; k++) { for (int j=0; j<h.length; j++) { try { y[k] += x[k-j]*h[j]; } catch (Exception e) {} } } return y; }

22 Moving Average Filter Usage – smooth a signal and reduce noise – curves sharp angles in the time domain Disadvantages – It overreacts to outlier samples – Slow roll-off destroys frequency resolution – Horrible stop band attenuation Evaluation – An exceptionally good smoothing filter – An exceptionally bad low-pass filter

23 Moving Average Filter Formula: Y n = 1/L ∑ i=0, M-1 x n-I Filter Kernel: {1/4, 1/4, 1/4, 1/4} if L = 4 Notes – All of the kernel coefficients are equal – The divide by 4 eliminates the gain Example: {1,2,3,4,5,4,3,2,1,2,3,4,5}; M = 4 – Starting filtered values up to index 3: {¼, ¾, 1 ½, 2 ½, … } – Next value: Y 4 = (5/4+4/4+3/4+2/4) = 3 ½ Speech Applications – Disadvantages Blurs transitions between voiced/unvoiced sounds Negatively impacts the frequency domain – Advantage: Useful to smooth the pitch contour

24 Moving Average FIR Filter int[] average(int x[]) { int[] y[x.length]; for (int i=50; i<x.length-50; i++) { for (int j=-50; j<=50; j++) { y[i] += x[i + j]; } y[i] /= 101; } Convolution using a simple filter kernel Formula: Example Point: Example Point (Centered):

25 Understanding Digital Signal Processing, Third Edition, Richard Lyons (0-13-261480-4) © Pearson Education, 2011. Effective smoothing and elimination of outliers

26 Understanding Digital Signal Processing, Third Edition, Richard Lyons (0-13-261480-4) © Pearson Education, 2011.

27 Note: the newest values show on the left side, which is opposite to what we might expect when viewing data as an array

28 Understanding Digital Signal Processing, Third Edition, Richard Lyons (0-13-261480-4) © Pearson Education, 2011.

29

30 Characteristics of Moving Average Filters Longer filters gets rid of more noise Long filters lose edge sharpness Terrible frequency resolution Frequency response is the sync function we’ve seen before (sin(x)/x)

31 Median Filter

32 Multiple Pass Moving Average Pass the signal through the filter more than once to improve stop band attenuation Convolve the filter kernel together to provide the combined filter in one step

33 Understanding Digital Signal Processing, Third Edition, Richard Lyons (0-13-261480-4) © Pearson Education, 2011. Note: Moving average attenuates the maximum value; amplifies the others

34 Understanding Digital Signal Processing, Third Edition, Richard Lyons (0-13-261480-4) © Pearson Education, 2011. Note DFT of a moving average filter is the sync function (sin(x)/x). We saw this before when discussing the rectangular window

35 Convolution Theorem Multiplication in the time domain is equivalent to convolution in the frequency domain Multiplication in the frequency domain equivalent to convolution in the time domain Application: We can design a filter by creating its desired frequency response and then perform an inverse FFT to derive the filter kernel Theoretically, we can create an ideal (“perfect”) low pass filter with this approach

36 Understanding Digital Signal Processing, Third Edition, Richard Lyons (0-13-261480-4) © Pearson Education, 2011.

37

38

39 Time/Frequency Domain Duality Rectangular window multiplies time domain elements by 1, resulting in sin(x)/x in the frequency domain Proof with calculus ∫ -∞,∞ x(t)e -jtkw 0 dt = ∫ -1/2,1/2 x(t)e -jtkw 0 dt = ∫ -1/2,1/2 e -jtkw 0 dt = (1/jw)e -jwt | -1/2,1/2 = (1/jw)(e -jw½ –e -jw(-½) ) = (1/jw)(e jw/2 –e -jw/2 ) = sin(jw/2)/(jw/2) -1/21/2

40 The Perfect Frequency Filter Window-Sync Filter: h[k] = sin(2f c π k) / kπ Convolving with this filter provides a perfect low pass filter Requires infinite length, abrupt transition edge, excessive ripple

41 Window-sync Filter Performance

42 Custom Filters 1.Create the desired frequency response 2.Perform an inverse Fast Fourier Transform a.Can't use this directly because of the abrupt edges b.A perfect filter requires infinite impulse response 3.Shift to center the filter about time=0, truncate, and apply a window function to the result 4.Use the result as the filter kernel 5. Application: Remove undesired frequency patterns For any frequency response

43 Example of a Custom Filter

44 The Ideal Frequency Filter Inverse Fourier transform on a square wave: h[k] = sin(2f c π k) / kπ Convolving with this filter provides a perfect low pass filter Problems (infinite length, abrupt edge, excessive ripple

45 Understanding Digital Signal Processing, Third Edition, Richard Lyons (0-13-261480-4) © Pearson Education, 2011.

46 A low pass filter kernel coefficients can vary The values chosen affect the transition band, ripple, and roll off -0.04 0.04 -0.1

47 Understanding Digital Signal Processing, Third Edition, Richard Lyons (0-13-261480-4) © Pearson Education, 2011.

48 Compute ideal filter Apply window Final filter kernel

49 Understanding Digital Signal Processing, Third Edition, Richard Lyons (0-13-261480-4) © Pearson Education, 2011. Create low pass filter using Blackman window

50 Understanding Digital Signal Processing, Third Edition, Richard Lyons (0-13-261480-4) © Pearson Education, 2011. Low pass filter comparisons using different window functions

51 Understanding Digital Signal Processing, Third Edition, Richard Lyons (0-13-261480-4) © Pearson Education, 2011. Compare various Chebyshev window alternatives

52 Understanding Digital Signal Processing, Third Edition, Richard Lyons (0-13-261480-4) © Pearson Education, 2011. Compare various Kaiser window alternatives

53 Understanding Digital Signal Processing, Third Edition, Richard Lyons (0-13-261480-4) © Pearson Education, 2011. Control filter parameter tradeoffs using the Parks- McClellan design

54 Understanding Digital Signal Processing, Third Edition, Richard Lyons (0-13-261480-4) © Pearson Education, 2011.

55 Compare Parks-McClellan, Chebyshev, and Kaiser

56 Understanding Digital Signal Processing, Third Edition, Richard Lyons (0-13-261480-4) © Pearson Education, 2011. Shifting a low pass filter

57 Understanding Digital Signal Processing, Third Edition, Richard Lyons (0-13-261480-4) © Pearson Education, 2011. Note Shifting a low pass filter affects roll off and ripples

58 High Pass Spectral Inversion Filter Two step solution –Filter the signal –Subtract the low pass signal from the original One step solution –Requires: A point of symmetry (N/2), the center of an odd number of points The filter kernel must be symmetric –Flip the sign of every filter kernel point; add one at index N/2 Why does it work? –A filter with unity at the point of symmetry is the identity function (an all pass filter) which passes the entire signal –1 - h[n] applied to the signal is all pass minus the low pass system, resulting in passing only the high frequency components First create a low pass filter

59 High Pass Filter Example Time Domain Low PassHigh Pass Frequency Domain

60 High Pass Spectral Reversal Filter Change the sign of every other sample. Why does it work? –This has the effect of multiplying every other sample by sin(2πfs/2), the Nyquist frequency –Aliasing then shifts the frequencies where the top frequencies wrap around to the start creating a mirror image –Example: suppose the Nyquist frequency is 4000. frequency 0 becomes 4000, frequency 50 becomes (50+4050) which aliases 3950 First create a low pass filter

61 Understanding Digital Signal Processing, Third Edition, Richard Lyons (0-13-261480-4) © Pearson Education, 2011.

62 Band Pass Filters 1.Create a low pass filter 2.Create a high pass filter 3.Convolve the filters together to get a band pass filter 4.Use spectral inversion or reversal for a band reject filter

63 Understanding Digital Signal Processing, Third Edition, Richard Lyons (0-13-261480-4) © Pearson Education, 2011. Convolve low pass and high pass to derive band pass

64 Group Delay Definition: The negative slope of phase angle with respect to frequency FIR filters have a linear group delay (the slope is a straight line. In the pass band, there are also no discontinuities. A non linear delay can distort output (e.g. music audio). IIR filters introduce degrees of non-linear group delay. The tradeoff is much faster computation, and sometimes better filter quality, versus the degree of non-linearity

65 The transition from -180 0 to +180 0 is not really a discontinuity Still linear between the discontinuities

66 Understanding Digital Signal Processing, Third Edition, Richard Lyons (0-13-261480-4) © Pearson Education, 2011.

67 Implementation Create a convolution method Create an array with appropriate filter kernel coefficients Call the convolution method with the signal frame, and filter kernel array as calling arguments Conclusion: Lots of mathematical theory, very little code needed


Download ppt "Signal Filters Purposes Separate Signals Eliminate interference distortions Remove unwanted data Restore to its original form (after transmission) Model."

Similar presentations


Ads by Google