240 likes | 481 Views
Lowpass Filter and Highpass Filter. 指導老師 : 黃貞瑛老師 報 告 : 林 文 彬. Outline. Filter Lowpass Filter = Moving Average Lowpass Filter - Frequency Response Highpass Filter = Moving Difference Highpass Filter - Frequency Response
E N D
Lowpass Filter and Highpass Filter 指導老師:黃貞瑛老師報 告:林 文 彬
Outline • Filter • Lowpass Filter = Moving Average • Lowpass Filter - Frequency Response • Highpass Filter = Moving Difference • Highpass Filter - Frequency Response • Reference Book
Filter • Linear time-invariant operator • x : input vector • y : output vector • Output vector y is the convolution of xwith a fixed vector h • Vector h: filter coefficients • Ex: h(0), h(1), h(2), h(3), h(4), ….. • Filters are digital, not analog • h(n) come at discrete times t = nT, n=0, ±1, ±2, … • Sampling period T is assumed to be 1 => t=0, ±1, ±2, …
Filter • Input x(n) and output y(n) come at all times • t = 0, ±1, ±2, ….. • y(n) = = convolution h * x in time domain • Unite Impulse at time zero • Input x = (…., 0, 1, 0, ….) • x(n-k) = 0 at n ≠ k • x(n-k) = x(k-k) = x(0) = 1 at n = k • Output y(n) = = h(n)x(0) = h(n) • Impulse response h(0), h(1), h(2), ….
Filter • Every linear operator acting on the signal vector x can be represented by a matrix • Infinitely many components in x and y mean infinitely many entries in the filter matrix H Constant-diagonal matrix
Lowpass Filter = Moving Average • The simplest lowpass filter :y(n) = ½ x(n) + ½ x(n-1) • Its output at time t=n is the average of input x(n) at that time and the input x(n-1) at previous time • The filter coefficients :h(0) = ½ h(1)= ½ • Standard form :Σh(k)x(n-k) with only two terms k=0 and k=1
Lowpass Filter = Moving Average • Suppose the input is the unit impulsex = (…,0,0,1,0,0,…) • Output vector has y(0)=1/2 and y(1)=1/2Only two nonzero components in the output • The impulse response is the vectory = (…,0,0,1/2,1/2,0,…)
Lowpass Filter = Moving Average • Averaging filter = ½ (identity) + ½ (delay) • y=Hx H: filter matrix • The main diagonal comes from ½(identity) • The subdiagonal comes from ½ (delay)
Lowpass Filter = Moving Average • y(n) = Σk h(k)x(n-k) = …+ h(-2)x(n+2) + h(-1)x(n+1) +h(0)x(n) + h(1)x(n-1) + h(2)x(n-2) + … • To see a filter as a constant-diagonal matrix • The coefficient h(0) in the main diagonal • It represents h(0) times the identity matrix [ h(0)x(n) ] • The coefficient h(1) in the first subdiagonal • It represents h(1) times a delay [ h(1)x(n-1) ] • The coefficient h(2) in the next subdiagonal • It represents h(2) times a two-step delay [ h(2)x(n-2) ]
Lowpass Filter = Moving Average • When we deal with causal filters • h(n) = 0 for negative n • The filter matrix is lower triangular • Our simple lowpass filter is a causal filter • Our example has only a finite number(two) of nonzero filter coefficient h(n) • We call the filter has a Finite impulse response (FIR filter) • In other words, a causal FIR filter • h(n) = 0 for all negative n and for large positive n • The filter matrix is banded and lower triangular
Lowpass Filter - Frequency Response • x(n) = einw have pure frequency w • The output vector y is a multiple (depending on w) of the input vector x • y(n) = ½ x(n) + ½ x(n-1) = ½ einw + ½ ei(n-1)w = ( ½ + ½ e-iw) einw = H(w) einw = H(w)x(n) • H(w) = ½ + ½ e-iw is frequency response function
Lowpass Filter - Frequency Response • x(n) = einw • y(n) = h(0)einw + h(1)ei(n-1)w + … • H(w) = h(0) + h(1)e-iw + h(2) e-2iw + … = Σh(n) e-inw • H(w+2π) = H(w) • H(w+2π) = Σh(n) e-in(w+2π) • When we add 2π to the freqency w, we add 2πn to the angle nw • The e-inw = cos nw – i sin nw are not changed
Lowpass Filter - Frequency Response • Some formula:
Lowpass Filter - Frequency Response • H(w) = |H(w)|eiψ(w) • |H(w)| : magnitude • ψ(w) : phase angle • Ex: H(w)= ½ + ½ e-iw • So |H(w)| = cos(w/2) , ψ(w)= -w/2 • Because of ψ(w)= -w/2 the filter is linear in the phase
Lowpass Filter - Frequency Response • y(n) = ½ x(n) + ½ x(n-1) • H(w) = ½ + ½ e-iw • H = ½ + ½ = 1 when w = 0 • At zero frequency(direct current) the signal x = (…,1,1,1,…)output is y = (…,1,1,1,…) • Thus the name “lowpass filter” • When w=π,input vector x(n)=eiπn =(-1)n • x = (…,1,-1,1,-1,1,…) • H(π)=0 and y = Hx • So y = (…,0,0,0,0,0,…)
Highpass Filter = Moving Difference • A lowpass filter takes “averages” • Outputs the moving average • For example: ½ ( x(n)+x(n-1) ) • A highpass filter takes “differences” • Outputs the moving difference • For example: ½ ( x(n)-x(n-1) ) • The filter coefficients h(0)= ½ and h(1) = - 1/2 • h = (…,0,0,1/2,-1/2,0,…) • y(n) = ½ x(n) – ½ x(n-1)
Highpass Filter = Moving Difference • y(n) = ½ ( x(n)-x(n-1) ) • We can rewrited to the matrix form : y = Hx • Highpass filter = ½ (identity) – ½ (delay) • This is also a causal FIR filter
Highpass Filter –Frequency Response • The input vector is x(n) = einw • The highpass output isy(n) = ½ einw – ½ ei(n-1)w = ( ½ - ½ e-iw) einw = H1(w) einw • Recall that the lowpass frequency response function is • H0(w) = ½ (1+ e-iw) • The highpass frequency response function is • H1(w) = ½ (1- e-iw)
Highpass Filter –Frequency Response • H1(w)= ½ (eiw/2 - e-iw/2 ) e-iw/2 = sin(w/2)i e-iw/2 • The magnitude is |H1(w)| = |sin(w/2)| • Since the sine function can be negative, we must take its absolute value • The zero response at direct current [sin0 =0 ] • The unit response at the highest frequency w = π [sin π/2 =1 ]
Highpass Filter –Frequency Response • We see a discontinuity in the phase • At other point the graph is linear, so we turn a blind eye to this discontinuity and say that the filter is still linear phase • It’s the zero at w=0 that causes this discontinuity in phase
Reference Book • G. Strang and T. Nguyen, Wavelets and Filter Banks, Wellesley-Cambridge Press, 1997. • Chapter 1.2 Lowpass Filter • Chapter 1.3 Highpass Filter