Download presentation
Presentation is loading. Please wait.
Published byArthur Gallagher Modified over 9 years ago
1
Original signal Median of seven Moving average Non-Linear Filter Median of five or seven
2
Median Filter Definition: –The middle value of an ordered list –If there is no middle value, average the two middle values Median filter: Y n = median m=0,M-1 {x n-m } Advantages –Good edge preserving properties –Preserves sharp discontinuities of significant length –Eliminates outliers, without blurring the signal Applications –The most effective algorithm to removes sudden impulse noise –Remove outliers when smoothing a pitch contour
3
Characteristics: Median Filter Linearity Fails: a n * M n + b n * M n ≠ (an + bn) * M n Succeeds: α (a n )*M n = (α a n )*M n Succeeds: A n * M n = b n, then A n+k * M n+k = b n+k Every output will match one of the inputs (if the filter length is odd) Frequency response There is not a well-defined mathematical formula Must be determined experimentally
4
Double Smoothing 1.Apply a median filter (ex: five point) 2.Apply a linear filter (Ex: Hanning with values 0, ¼, ½, ¼, 0) 3.Recursively apply steps 1 and 2 to the filtered signal 4.Add the result of the recursive application back Single Smoothing Double Smoothing
5
Left: Moving Average, Right: Median Compare Median to Moving Average Filter
6
Correlation How identify similar signal? If signal is aligned, we sum the values squared and y[n] will contain a spike. Result will not resemble original, but we are testing the presence, not recreating or altering. Purpose: identify noisy, scaled, shifted target signal Application: pitch, radar, edge detection, MRI Implementation: reversed convolution Sometimes called a “Matched Filter”
7
Auto-correlation public double autoCorrelate(double[] signal, int i, int j) {double sum = 0; int N = signal.length; for (int n=0; n<N; n++) { try { sum += signal[n-i] * signal[n-j]; } catch (ArrayIndexOutOfBoundsException e) {} } return sum; Test if signal delayed i samples correlates with signal delayed j samples
8
All-pass filter Pole of an all-phase filter lies inside the unit circle and the matching zero is an equal distance outside. The Z-domain magnitudes of the matching poles and zeros cancel along the unit circle They lie on the same radius line, but with reciprocal magnitudes Example: Assume Pole at p 0 = ½+½j The pole magnitude = (¼+¼) 1/2 = 1/2 ½ The zero magnitude = 2 ½ Zero z 0 = 2 ½ cos 45 + j(2 ½ sin 45) = 1 + j p0p0 z0z0 Φ s r Definition: Passes all frequencies Note: magnitudes remains constant, but the phase and frequencies warped
9
All-Pass Transfer Function First order all pass filter transfer function: H(z) = B(z)/A(z) = (z -1 -me -jφ )/(1-1/me -jφ z -1 ) = (z -1 -λ)/(1-λz -1 ) where m is the magnitude and φ the angle Higher order all pass transfer function The FIR and IIR coefficients are the same
10
All pass Filter Visualization
11
All-pass Filter Phase Response H(z) = B(z)/A(z) = (z -1 -λ)/(1-λz -1 ) λ, controls the location of the pole (p) and the zero (1/p) Notes: Figure to the right – No phase shift at w = 0, π, 2π – Phase response: w+2arctan(λsin(w)/(1- λcos(w)) – π is the cross over point w 2π2π 2π2π λ= 0.8
12
Frequency Warping Group delay – Definition: change of phase with respect to change of frequency – Interpretation: Different frequencies pass through a filter at different speeds. Therefore, a frequency warping operation occurs – Formula: Where w is angle of original frequency, w’ is the angle of the warped frequency, λ is the all-pass coefficient (1- λ 2 )sin(w) (1- λ 2 ) cos(w) - 2λ w’ = arctan
13
Illustration
14
Frequency Warped Mel Scale Hearing sensitivity corresponds to a non-linear scale
15
Differentiators Application: Variations in a adjacent frames of a speech signal helps to identifies phonemes and syllable changes Simple Naïve filter: y[n] = x[n]-x[n-1] Central difference filter: y[n] = x[n+1] – x[n-1] Higher order differences: using 2M+1 filter coefficients h(k) = -3k / (M(M+1)(2M+1) –Example: M=2, then M*(M+1)*(2M+1) = 30 if k = -2, h(k) = -3(-2) / (30) = 0.2 if k = -1, h(k) = -3(-1) / (30) = 0.1 if k = 0, h(k) = -3(0) / (30) = 0 if k = 1, h(k) = -3(1) / (30) = -0.1 if k = 2, h(k) = -3(2) / (30) = -0.2 –Filter: h = { 0.2, 0.1, 0, -0.1, -0.2}; Estimate slope of signal features
16
Understanding Digital Signal Processing, Third Edition, Richard Lyons (0-13-261480-4) © Pearson Education, 2011.
17
For some applications, the frequency response is not important
18
Understanding Digital Signal Processing, Third Edition, Richard Lyons (0-13-261480-4) © Pearson Education, 2011.
19
IFIR Filters FIR Filter Disadvantage: too many calculations Goal: Reduce the number of taps Process –Create two filters (shaping, image reject) with less taps –Apply the shaping filter, and then the mage reject filter Result: The number of total calculations are greatly reduced Interpolated Finite Response Filters
20
Understanding Digital Signal Processing, Third Edition, Richard Lyons (0-13-261480-4) © Pearson Education, 2011. The Shaping Filter Prototype filter: N p = 9 coefficients Expanded prototype filter: M = 3 and M(Np-1)+1 coefficients
21
Original signal Prototype filter creates aliases Low pass image reject filter attenuates aliases Resulting signal F pass is the end of the pass band f stop is the end of the stop band F ir = 1/M – f stop is the end of the stop band of the image reject filter Frequencies measured in percentage of sampling rate
22
Understanding Digital Signal Processing, Third Edition, Richard Lyons (0-13-261480-4) © Pearson Education, 2011.
23
Designing an IFIR Filter General formula: number of taps N taps = Attenuation in decibels 22(M)(f stop – f pass ) Example: Attenuation 50 db, M = 7, f pass = 0.02, f stop = 0.03 Taps for shaping filter (33) N shape = 50 / {22 (7)(0.03 – 0.02)} ≈ 32.4 Taps for image reject filter (25) N ir = 50 / {22 (1/7 – 0.03 – 0.02)} ≈ 24.5 Taps for original filter (228) N filter = 50 / (22)(.03 -.02) ≈ 227.3 An FIR filter of any length by truncating the window-sync at any length
24
Understanding Digital Signal Processing, Third Edition, Richard Lyons (0-13-261480-4) © Pearson Education, 2011.
25
Sample Rate Conversion Application: Process speech in audio files that were recorded at different rates Algorithm: 1.Find the greatest common denominator (GCD) of both source and destination sample rates 2.Use the GCD to interpolate the source signal 3.Apply an appropriate low pass filter 4.Use the GCD to decimate the interpolated signal
26
Understanding Digital Signal Processing, Third Edition, Richard Lyons (0-13-261480-4) © Pearson Education, 2011.
28
Two stage decimation is useful to reduce the taps and number of calculations
29
Understanding Digital Signal Processing, Third Edition, Richard Lyons (0-13-261480-4) © Pearson Education, 2011.
32
Example Description –Source signal sample rate = 22,050 hz –Destination signal rate = 10000 hz Compute the Greatest Common Denominator gcd(x,y) = gcd(x%y,y) = 50 // x>=y Compute resampling factors 10000/50 = 200 and 22050/50 = 441 Interpolate source signal by destination factor 22,050 * 200 = 4,410,000 Apply an appropriate FIR filter Decimate expanded signal by source factor 4,410,000 / 441 = 10,000
33
Understanding Digital Signal Processing, Third Edition, Richard Lyons (0-13-261480-4) © Pearson Education, 2011.
34
Resampling Comments An filter with too wide of a transition band or with too much pass band ripple will lead to bad results The decimation step causes aliases and needs to be low pass filtered if the frequency band is too small Inserting lower tap filters in series are useful to reduce the number of required steps We don’t need to create a huge array in the interpolation step, but can apply a poly-phase filter to the original signal, in combination with a ring buffer (circular queue), and automatically extract the appropriate outputs.
35
Understanding Digital Signal Processing, Third Edition, Richard Lyons (0-13-261480-4) © Pearson Education, 2011. For each iteration, many of the calculations are zero, so those can be skipped in the calculations
36
Understanding Digital Signal Processing, Third Edition, Richard Lyons (0-13-261480-4) © Pearson Education, 2011.
37
If m is an even multiple of the destination signal, append to the output array. Ring Buffer Insert all outputs into a ring buffer, length of the filter taps, for future filter calculations. A huge array is not necessary.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.