Digital Filters
-
Upload
ishmael-tyson -
Category
Documents
-
view
18 -
download
3
description
Transcript of Digital Filters
Digital FiltersDigital Filters
Part A characterization and Part A characterization and analysisanalysis
““As soon as we started programming, we found As soon as we started programming, we found out to our surprise that it wasn't as easy to get out to our surprise that it wasn't as easy to get programs right as we had thought. Debugging programs right as we had thought. Debugging had to be discovered. I can remember the exact had to be discovered. I can remember the exact instant when I realized that a large part of my life instant when I realized that a large part of my life from then on was going to be spent in finding from then on was going to be spent in finding mistakes in my own programs.”mistakes in my own programs.”
Maurice Wilkes (a pioneering British computer scientist, winner of Maurice Wilkes (a pioneering British computer scientist, winner of the 1967 Turing Award, developed the first stored-program the 1967 Turing Award, developed the first stored-program computer in 1949, invented the concept of microprogramming in computer in 1949, invented the concept of microprogramming in 1951, credited with originating the fundamental software concepts 1951, credited with originating the fundamental software concepts of symbolic labels, macros, and subroutine libraries; from of symbolic labels, macros, and subroutine libraries; from wikipedia)wikipedia)
What have we seen so far?What have we seen so far?
So far we have seen…So far we have seen…• Box filterBox filter
Moving average filterMoving average filter Example of a lowpassExample of a lowpass
• passes low frequenciespasses low frequencies small, gradual changes in the signal are small, gradual changes in the signal are
passedpassed higher frequencies are attenuated higher frequencies are attenuated
(reduced/removed/suppressed)(reduced/removed/suppressed)
Applied by cross correlation (sum Applied by cross correlation (sum of products) of image f and mask hof products) of image f and mask h
If mask is centered about origin, (x,y) If mask is centered about origin, (x,y) in image:in image:
If origin, (x,y), in image is aligned with If origin, (x,y), in image is aligned with (0,0) in mask:(0,0) in mask:
2/
2/
2/
2/
, ,,,,w
wi
h
hj
jihjyixfyxhyxfyxg
1
0
1
0
, ,,,,w
i
h
j
jihjyixfyxhyxfyxg
But how do we know what the But how do we know what the application of an arbitrary mask application of an arbitrary mask
actually does to the image?actually does to the image?
For simplicity, let us just consider 1D signals (e.g., For simplicity, let us just consider 1D signals (e.g., mono audio)mono audio)
Our moving average (box) filterOur moving average (box) filter
Example of a lowpass filter (passes low Example of a lowpass filter (passes low frequencies, attenuates high frequencies, attenuates high frequencies)frequencies)
y[n] = 1/3 x[n-1] + 1/3 x[n]y[n] = 1/3 x[n-1] + 1/3 x[n]
+ 1/3 x[n+1]+ 1/3 x[n+1]
More generally,More generally,
y[n] = h[-1] x[n-1] + h[0] x[n]y[n] = h[-1] x[n-1] + h[0] x[n]
+ h[1] x[n+1]+ h[1] x[n+1]
But what exactly do we mean by But what exactly do we mean by “frequency?”“frequency?”
...sinsin
..
sin
222111 ttty
offsetCD
phase
frequency
amplitude
where
tty
0 5 10 15 20 25 30
-10
-5
0
5
10
sin(x) & 2sin(x)
amplitude (loudness)amplitude (loudness)
0 5 10 15 20 25 30
-10
-5
0
5
10
sin(x) & sin(x+pi/2)
phase (time/space) shiftphase (time/space) shift
0 5 10 15 20 25 30
-10
-5
0
5
10
sin(x) & sin(2x)
frequency (speed)frequency (speed)
0 5 10 15 20 25 30
-10
-5
0
5
10
0.5*sin(x)+sin(3*x+pi/3)+sin(5*x+pi/8)
Input: (Input: (beforebefore)) x(t) = 0.5*sin(t) + sin(3*t+pi/3) + sin(5*t+pi/8)x(t) = 0.5*sin(t) + sin(3*t+pi/3) + sin(5*t+pi/8)Output: (Output: (afterafter)) y(t) = 0.5*sin(t) + sin(3*t+pi/3)y(t) = 0.5*sin(t) + sin(3*t+pi/3)
XLowpass filtersLowpass filters
So how can we determine how our So how can we determine how our moving average filter behaves?moving average filter behaves?
11 point and 51 point moving 11 point and 51 point moving average filters (on the previous slide) average filters (on the previous slide) obviously produce different outputs obviously produce different outputs even when given the same input!even when given the same input!
Answer: By determining how a Answer: By determining how a particular filter responds to an particular filter responds to an impulse (their impulse response impulse (their impulse response function).function).
So given …,h[-1],h[0],h[1],… how So given …,h[-1],h[0],h[1],… how can we plot the impulse response?can we plot the impulse response?
1.1. Perform the z-transform (the discrete Perform the z-transform (the discrete version of the Laplace transform) of h version of the Laplace transform) of h resulting H.resulting H.
2.2. Plot H on the unit circle. The magnitude Plot H on the unit circle. The magnitude of H (abs(H) or |H|) is amplitude and the of H (abs(H) or |H|) is amplitude and the angle of H (arg(H)) is the phase.angle of H (arg(H)) is the phase.
Say we have a 3 point box filter:Say we have a 3 point box filter:
h[-1] = h[0] = h[1] = 1/3.h[-1] = h[0] = h[1] = 1/3.
jjj eeeH 101
3
1
3
1
3
1
So given …,h[-1],h[0],h[1],… how So given …,h[-1],h[0],h[1],… how can we plot the impulse response?can we plot the impulse response?
Say we have an 11 point box filter:Say we have an 11 point box filter:h[-5]=h[-4]=h[-3] =h[-3] =h[-2] =h[-1] =h[0] h[-5]=h[-4]=h[-3] =h[-3] =h[-2] =h[-1] =h[0]
=h[1] =h[2] =h[3] =h[4] =h[5]=1/11.=h[1] =h[2] =h[3] =h[4] =h[5]=1/11.
jj
jjj
jjj
jjj
ee
eee
eee
eeeH
54
321
012
345
11
1
11
111
1
11
1
11
111
1
11
1
11
111
1
11
1
11
1
Frequency response of 3 and 11 Frequency response of 3 and 11 point box filterspoint box filters
0 0.5 1 1.5 2 2.5 3 3.50
0.2
0.4
0.6
0.8
1
1.2
0 0.5 1 1.5 2 2.5 3 3.50
0.2
0.4
0.6
0.8
1
1.2
0 0.5 1 1.5 2 2.5 3 3.5-40
-35
-30
-25
-20
-15
-10
-5
0
5
Frequency response in dB of 3 and Frequency response in dB of 3 and 11 point box filters11 point box filters
dBdB(from http://www.animations.physics.unsw.edu.au/jw/dB.htm)(from http://www.animations.physics.unsw.edu.au/jw/dB.htm)
““The decibel (dB) is used to measure sound The decibel (dB) is used to measure sound level, but it is also widely used in electronics, level, but it is also widely used in electronics, signals and communication. The dB is a signals and communication. The dB is a logarithmic way of describing a ratio. The logarithmic way of describing a ratio. The ratio may be power, sound pressure, voltage ratio may be power, sound pressure, voltage or intensity or several other things.”or intensity or several other things.”
““One decibel is close to the Just Noticeable One decibel is close to the Just Noticeable Difference (JND) for sound level.Difference (JND) for sound level.
Experimentally it was found that a 10 dB Experimentally it was found that a 10 dB increase in sound level corresponds increase in sound level corresponds approximately to a perceived doubling of approximately to a perceived doubling of loudness.”loudness.”
Frequency Frequency response (dB) and response (dB) and phase of 3 and 11 phase of 3 and 11 point box filters.point box filters.
0 0.5 1 1.5 2 2.5 3 3.5-40
-35
-30
-25
-20
-15
-10
-5
0
5
0 0.5 1 1.5 2 2.5 3 3.5-35
-30
-25
-20
-15
-10
-5
0
5
3 point box filter 3 point box filter (blue) vs. 3 point (blue) vs. 3 point gaussian (green)gaussian (green)(normal – left, dB – below)(normal – left, dB – below)
0 0.5 1 1.5 2 2.5 3 3.5-60
-50
-40
-30
-20
-10
0
0 0.5 1 1.5 2 2.5 3 3.50
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
Frequency response (dB) and Frequency response (dB) and phase of 3 point gaussianphase of 3 point gaussian
0 0.5 1 1.5 2 2.5 3 3.5-60
-50
-40
-30
-20
-10
0
OTHER FILTERSOTHER FILTERS(OTHER THAN LOWPASS)(OTHER THAN LOWPASS)
How can we make these other How can we make these other filters?filters?
Spectral inversion:Spectral inversion:How to make a highpass filter the How to make a highpass filter the
easy way.easy way.
1.1. Change the sign of each sample in Change the sign of each sample in the filter kernel.the filter kernel.
2.2. Add 1 to the sample at the center of Add 1 to the sample at the center of symmetry.symmetry.
• highpasshighpass lowpass lowpass• lowpasslowpass highpass highpass• bandpassbandpass bandreject (stopband) bandreject (stopband)• bandrejectbandreject bandpass bandpass
Spectral inversion:Spectral inversion:How to make a highpass filter the How to make a highpass filter the
easy way.easy way.
1.1. Change the sign of each sample in Change the sign of each sample in the filter kernel.the filter kernel.
2.2. Add 1 to the sample at the center of Add 1 to the sample at the center of symmetry.symmetry.
Ex. lowpass box Ex. lowpass box highpass highpass
9/19/19/1
9/19/19/1
9/19/19/1
9/19/19/1
9/19/89/1
9/19/19/1
Lowpass Lowpass to to
highpasshighpass
Lowpass followed by highpass = Lowpass followed by highpass = bandpassbandpass
(more efficient implementation)
Bandreject (stopband) = lowpass + Bandreject (stopband) = lowpass + highpass (lowpass or highpass)highpass (lowpass or highpass)
(more efficient implementation)