filtering - electrical engineering and computer science · gaussian filtering removes parts of the...
TRANSCRIPT
![Page 1: Filtering - Electrical Engineering and Computer Science · Gaussian filtering removes parts of the signal above a certain frequency. Often noise is high frequency and signal is low](https://reader033.vdocuments.net/reader033/viewer/2022050123/5f531b6dc7717c6c726d9383/html5/thumbnails/1.jpg)
FilteringEECS 442 – Prof. David Fouhey
Winter 2019, University of Michiganhttp://web.eecs.umich.edu/~fouhey/teaching/EECS442_W19/
Note: I’ll ask the front row on the right to participate in a
demo. All you have to do is say a number that I’ll give to
you. If you don’t want to, it’s fine, but don’t sit in the front.
![Page 2: Filtering - Electrical Engineering and Computer Science · Gaussian filtering removes parts of the signal above a certain frequency. Often noise is high frequency and signal is low](https://reader033.vdocuments.net/reader033/viewer/2022050123/5f531b6dc7717c6c726d9383/html5/thumbnails/2.jpg)
Let’s Take An Image
![Page 3: Filtering - Electrical Engineering and Computer Science · Gaussian filtering removes parts of the signal above a certain frequency. Often noise is high frequency and signal is low](https://reader033.vdocuments.net/reader033/viewer/2022050123/5f531b6dc7717c6c726d9383/html5/thumbnails/3.jpg)
Let’s Fix Things
Slide Credit: D. Lowe
• We have noise in our image
• Let’s replace each pixel with a weighted
average of its neighborhood
• Weights are filter kernel
1/9 1/9 1/9
1/9 1/9 1/9
1/9 1/9 1/9
Out
![Page 4: Filtering - Electrical Engineering and Computer Science · Gaussian filtering removes parts of the signal above a certain frequency. Often noise is high frequency and signal is low](https://reader033.vdocuments.net/reader033/viewer/2022050123/5f531b6dc7717c6c726d9383/html5/thumbnails/4.jpg)
1D Case
1/3 1/3 1/3Filter/
David
Signal/
Front Row10 12 9 11 10 11 12
Output 10.33 10.66 10 10.66 11
![Page 5: Filtering - Electrical Engineering and Computer Science · Gaussian filtering removes parts of the signal above a certain frequency. Often noise is high frequency and signal is low](https://reader033.vdocuments.net/reader033/viewer/2022050123/5f531b6dc7717c6c726d9383/html5/thumbnails/5.jpg)
Applying a Linear Filter
I11 I12 I13
I21 I22 I23
I31 I32 I33
I14 I15 I16
I24 I25 I26
I34 I35 I36
I41 I42 I43
I51 I52 I53
I44 I45 I46
I54 I55 I56
Input
F11 F12 F13
F21 F22 F23
F31 F32 F33
Filter
O11 O12 O13
O21 O22 O23
O31 O32 O33
O14
O24
O34
Output
![Page 6: Filtering - Electrical Engineering and Computer Science · Gaussian filtering removes parts of the signal above a certain frequency. Often noise is high frequency and signal is low](https://reader033.vdocuments.net/reader033/viewer/2022050123/5f531b6dc7717c6c726d9383/html5/thumbnails/6.jpg)
Applying a Linear Filter
I11 I12 I13
I21 I22 I23
I31 I32 I33
I14 I15 I16
I24 I25 I26
I34 I35 I36
I41 I42 I43
I51 I52 I53
I44 I45 I46
I54 I55 I56
Input & Filter
F11 F12 F13
F21 F22 F23
F31 F32 F33
Output
O11
O11 = I11*F11 + I12*F12 + … + I33*F33
![Page 7: Filtering - Electrical Engineering and Computer Science · Gaussian filtering removes parts of the signal above a certain frequency. Often noise is high frequency and signal is low](https://reader033.vdocuments.net/reader033/viewer/2022050123/5f531b6dc7717c6c726d9383/html5/thumbnails/7.jpg)
Applying a Linear Filter
I11 I12 I13
I21 I22 I23
I31 I32 I33
I14 I15 I16
I24 I25 I26
I34 I35 I36
I41 I42 I43
I51 I52 I53
I44 I45 I46
I54 I55 I56
Input & Filter
F11 F12 F13
F21 F22 F23
F31 F32 F33
Output
O11
O12 = I12*F11 + I13*F12 + … + I34*F33
O12
![Page 8: Filtering - Electrical Engineering and Computer Science · Gaussian filtering removes parts of the signal above a certain frequency. Often noise is high frequency and signal is low](https://reader033.vdocuments.net/reader033/viewer/2022050123/5f531b6dc7717c6c726d9383/html5/thumbnails/8.jpg)
Applying a Linear Filter
I11 I12 I13
I21 I22 I23
I31 I32 I33
I14 I15 I16
I24 I25 I26
I34 I35 I36
I41 I42 I43
I51 I52 I53
I44 I45 I46
I54 I55 I56
Input
F11 F12 F13
F21 F22 F23
F31 F32 F33
Filter Output
How many times can we apply a
3x3 filter to a 5x6 image?
![Page 9: Filtering - Electrical Engineering and Computer Science · Gaussian filtering removes parts of the signal above a certain frequency. Often noise is high frequency and signal is low](https://reader033.vdocuments.net/reader033/viewer/2022050123/5f531b6dc7717c6c726d9383/html5/thumbnails/9.jpg)
Applying a Linear Filter
I11 I12 I13
I21 I22 I23
I31 I32 I33
I14 I15 I16
I24 I25 I26
I34 I35 I36
I41 I42 I43
I51 I52 I53
I44 I45 I46
I54 I55 I56
Input Output
Oij = Iij*F11 + Ii(j+1)*F12 + … + I(i+2)(j+2)*F33
O11 O12 O13
O21 O22 O23
O31 O32 O33
O14
O24
O34
F11 F12 F13
F21 F22 F23
F31 F32 F33
Filter
![Page 10: Filtering - Electrical Engineering and Computer Science · Gaussian filtering removes parts of the signal above a certain frequency. Often noise is high frequency and signal is low](https://reader033.vdocuments.net/reader033/viewer/2022050123/5f531b6dc7717c6c726d9383/html5/thumbnails/10.jpg)
Painful Details – Edge Cases
f
gg
gg
f
gg
gg
f
gg
gg
full same valid
Convolution doesn’t keep the whole image.
Suppose f is the image and g the filter.
f/g Diagram Credit: D. Lowe
Full – any part of g touches f. Same – same size as f;
Valid – only when filter doesn’t fall off edge.
![Page 11: Filtering - Electrical Engineering and Computer Science · Gaussian filtering removes parts of the signal above a certain frequency. Often noise is high frequency and signal is low](https://reader033.vdocuments.net/reader033/viewer/2022050123/5f531b6dc7717c6c726d9383/html5/thumbnails/11.jpg)
Painful Details – Edge Cases
What to about the “?” region?
Symm: fold sides over
pad/fill: add value, often 0
f
gg
gg
? ? ? ?
Circular/Wrap: wrap around
f/g Diagram Credit: D. Lowe
![Page 12: Filtering - Electrical Engineering and Computer Science · Gaussian filtering removes parts of the signal above a certain frequency. Often noise is high frequency and signal is low](https://reader033.vdocuments.net/reader033/viewer/2022050123/5f531b6dc7717c6c726d9383/html5/thumbnails/12.jpg)
Painful Details – Does it Matter?
Input
Image
Box Filtered
???
Box Filtered
???
(I’ve applied the filter per-color channel)
Which padding did I use and why?
![Page 13: Filtering - Electrical Engineering and Computer Science · Gaussian filtering removes parts of the signal above a certain frequency. Often noise is high frequency and signal is low](https://reader033.vdocuments.net/reader033/viewer/2022050123/5f531b6dc7717c6c726d9383/html5/thumbnails/13.jpg)
Painful Details – Does it Matter?
Input
Image
Box Filtered
Symm Pad
Box Filtered
Zero Pad
(I’ve applied the filter per-color channel)
![Page 14: Filtering - Electrical Engineering and Computer Science · Gaussian filtering removes parts of the signal above a certain frequency. Often noise is high frequency and signal is low](https://reader033.vdocuments.net/reader033/viewer/2022050123/5f531b6dc7717c6c726d9383/html5/thumbnails/14.jpg)
Practice with Linear Filters
Slide Credit: D. Lowe
Original
?0 0 0
0 1 0
0 0 0
![Page 15: Filtering - Electrical Engineering and Computer Science · Gaussian filtering removes parts of the signal above a certain frequency. Often noise is high frequency and signal is low](https://reader033.vdocuments.net/reader033/viewer/2022050123/5f531b6dc7717c6c726d9383/html5/thumbnails/15.jpg)
Practice with Linear Filters
Slide Credit: D. Lowe
Original
0 0 0
0 1 0
0 0 0
The Same!
![Page 16: Filtering - Electrical Engineering and Computer Science · Gaussian filtering removes parts of the signal above a certain frequency. Often noise is high frequency and signal is low](https://reader033.vdocuments.net/reader033/viewer/2022050123/5f531b6dc7717c6c726d9383/html5/thumbnails/16.jpg)
Practice with Linear Filters
Slide Credit: D. Lowe
Original
?0 0 0
0 0 1
0 0 0
![Page 17: Filtering - Electrical Engineering and Computer Science · Gaussian filtering removes parts of the signal above a certain frequency. Often noise is high frequency and signal is low](https://reader033.vdocuments.net/reader033/viewer/2022050123/5f531b6dc7717c6c726d9383/html5/thumbnails/17.jpg)
Practice with Linear Filters
Slide Credit: D. Lowe
Original
0 0 0
0 0 1
0 0 0
Shifted
LEFT
1 pixel
![Page 18: Filtering - Electrical Engineering and Computer Science · Gaussian filtering removes parts of the signal above a certain frequency. Often noise is high frequency and signal is low](https://reader033.vdocuments.net/reader033/viewer/2022050123/5f531b6dc7717c6c726d9383/html5/thumbnails/18.jpg)
Practice with Linear Filters
Slide Credit: D. Lowe
Original
?0 1 0
0 0 0
0 0 0
![Page 19: Filtering - Electrical Engineering and Computer Science · Gaussian filtering removes parts of the signal above a certain frequency. Often noise is high frequency and signal is low](https://reader033.vdocuments.net/reader033/viewer/2022050123/5f531b6dc7717c6c726d9383/html5/thumbnails/19.jpg)
Practice with Linear Filters
Slide Credit: D. Lowe
Original
0 1 0
0 0 0
0 0 0
Shifted
DOWN
1 pixel
![Page 20: Filtering - Electrical Engineering and Computer Science · Gaussian filtering removes parts of the signal above a certain frequency. Often noise is high frequency and signal is low](https://reader033.vdocuments.net/reader033/viewer/2022050123/5f531b6dc7717c6c726d9383/html5/thumbnails/20.jpg)
Practice with Linear Filters
?
Slide Credit: D. Lowe
Original
1/9 1/9 1/9
1/9 1/9 1/9
1/9 1/9 1/9
![Page 21: Filtering - Electrical Engineering and Computer Science · Gaussian filtering removes parts of the signal above a certain frequency. Often noise is high frequency and signal is low](https://reader033.vdocuments.net/reader033/viewer/2022050123/5f531b6dc7717c6c726d9383/html5/thumbnails/21.jpg)
Practice with Linear Filters
Slide Credit: D. Lowe
Original
1/9 1/9 1/9
1/9 1/9 1/9
1/9 1/9 1/9
Blur
(Box Filter)
![Page 22: Filtering - Electrical Engineering and Computer Science · Gaussian filtering removes parts of the signal above a certain frequency. Often noise is high frequency and signal is low](https://reader033.vdocuments.net/reader033/viewer/2022050123/5f531b6dc7717c6c726d9383/html5/thumbnails/22.jpg)
Practice with Linear Filters
?
Slide Credit: D. Lowe
Original1/9 1/9 1/9
1/9 1/9 1/9
1/9 1/9 1/9
0 0 0
0 2 0
0 0 0
-
![Page 23: Filtering - Electrical Engineering and Computer Science · Gaussian filtering removes parts of the signal above a certain frequency. Often noise is high frequency and signal is low](https://reader033.vdocuments.net/reader033/viewer/2022050123/5f531b6dc7717c6c726d9383/html5/thumbnails/23.jpg)
Practice with Linear Filters
Slide Credit: D. Lowe
Original1/9 1/9 1/9
1/9 1/9 1/9
1/9 1/9 1/9
0 0 0
0 2 0
0 0 0
-
Sharpened(Acccentuates
difference from
local average)
![Page 24: Filtering - Electrical Engineering and Computer Science · Gaussian filtering removes parts of the signal above a certain frequency. Often noise is high frequency and signal is low](https://reader033.vdocuments.net/reader033/viewer/2022050123/5f531b6dc7717c6c726d9383/html5/thumbnails/24.jpg)
Sharpening
Slide Credit: D. Lowe
![Page 25: Filtering - Electrical Engineering and Computer Science · Gaussian filtering removes parts of the signal above a certain frequency. Often noise is high frequency and signal is low](https://reader033.vdocuments.net/reader033/viewer/2022050123/5f531b6dc7717c6c726d9383/html5/thumbnails/25.jpg)
Properties – Linear
Assume: I image f1, f2 filters
Linear: apply(I,f1+f2) = apply(I,f1) + apply(I,f2)
I is a box on black, and and f1, f2 are boxes
Note: I am showing filters un-normalized and blown up. They’re a
smaller box filter (i.e., each entry is 1/(size^2))
== +
=A( , )+A( , ) =
)+A(A( , , )
![Page 26: Filtering - Electrical Engineering and Computer Science · Gaussian filtering removes parts of the signal above a certain frequency. Often noise is high frequency and signal is low](https://reader033.vdocuments.net/reader033/viewer/2022050123/5f531b6dc7717c6c726d9383/html5/thumbnails/26.jpg)
Properties – Shift-Invariant
Assume: I image, f filter
Shift-invariant: shift(apply(I,f)) = apply(shift(I,f))
Intuitively: only depends on filter neighborhood
A( , ) =
A( , ) =
![Page 27: Filtering - Electrical Engineering and Computer Science · Gaussian filtering removes parts of the signal above a certain frequency. Often noise is high frequency and signal is low](https://reader033.vdocuments.net/reader033/viewer/2022050123/5f531b6dc7717c6c726d9383/html5/thumbnails/27.jpg)
Painful Details – Signal Processing
Often called “convolution”. Actually cross-correlation.
Cross-Correlation
(Original Orientation)
Convolution
(Flipped in x and y)
![Page 28: Filtering - Electrical Engineering and Computer Science · Gaussian filtering removes parts of the signal above a certain frequency. Often noise is high frequency and signal is low](https://reader033.vdocuments.net/reader033/viewer/2022050123/5f531b6dc7717c6c726d9383/html5/thumbnails/28.jpg)
Properties of Convolution
• Any shift-invariant, linear operation is a convolution
• Commutative: f ⁎ g = g ⁎ f
• Associative: (f ⁎ g) ⁎ h = f ⁎ (g ⁎ h)
• Distributes over +: f ⁎ (g + h) = f ⁎ g + f ⁎ h
• Scalars factor out: kf ⁎ g = f ⁎ kg = k (f ⁎ g)
• Identity (a single one with all zeros):
Property List: K. Grauman
=*
![Page 29: Filtering - Electrical Engineering and Computer Science · Gaussian filtering removes parts of the signal above a certain frequency. Often noise is high frequency and signal is low](https://reader033.vdocuments.net/reader033/viewer/2022050123/5f531b6dc7717c6c726d9383/html5/thumbnails/29.jpg)
Questions?
• Nearly everything onwards is a convolution.
• This is important to get right.
![Page 30: Filtering - Electrical Engineering and Computer Science · Gaussian filtering removes parts of the signal above a certain frequency. Often noise is high frequency and signal is low](https://reader033.vdocuments.net/reader033/viewer/2022050123/5f531b6dc7717c6c726d9383/html5/thumbnails/30.jpg)
Smoothing With A Box
Intuition: if filter touches it, it gets a contribution.
Input Box Filter
![Page 31: Filtering - Electrical Engineering and Computer Science · Gaussian filtering removes parts of the signal above a certain frequency. Often noise is high frequency and signal is low](https://reader033.vdocuments.net/reader033/viewer/2022050123/5f531b6dc7717c6c726d9383/html5/thumbnails/31.jpg)
Solution – Weighted Combination
Intuition: weight contributions according to closeness to center.
𝐹𝑖𝑙𝑡𝑒𝑟𝑖𝑗 ∝ 1
𝐹𝑖𝑙𝑡𝑒𝑟𝑖𝑗 ∝ exp −𝑥2 + 𝑦2
2𝜎2
![Page 32: Filtering - Electrical Engineering and Computer Science · Gaussian filtering removes parts of the signal above a certain frequency. Often noise is high frequency and signal is low](https://reader033.vdocuments.net/reader033/viewer/2022050123/5f531b6dc7717c6c726d9383/html5/thumbnails/32.jpg)
Recognize the Filter?
𝐹𝑖𝑙𝑡𝑒𝑟𝑖𝑗 ∝1
2𝜋𝜎2exp −
𝑥2 + 𝑦2
2𝜎2
It’s a Gaussian!
0.003 0.013 0.022 0.013 0.003
0.013 0.060 0.098 0.060 0.013
0.022 0.098 0.162 0.098 0.022
0.013 0.060 0.098 0.060 0.013
0.003 0.013 0.022 0.013 0.003
![Page 33: Filtering - Electrical Engineering and Computer Science · Gaussian filtering removes parts of the signal above a certain frequency. Often noise is high frequency and signal is low](https://reader033.vdocuments.net/reader033/viewer/2022050123/5f531b6dc7717c6c726d9383/html5/thumbnails/33.jpg)
Smoothing With A Box & Gauss
Still have some speckles, but it’s not a big box
Input Box Filter Gauss. Filter
![Page 34: Filtering - Electrical Engineering and Computer Science · Gaussian filtering removes parts of the signal above a certain frequency. Often noise is high frequency and signal is low](https://reader033.vdocuments.net/reader033/viewer/2022050123/5f531b6dc7717c6c726d9383/html5/thumbnails/34.jpg)
Gaussian Filters
σ = 1
filter = 21x21
σ = 2
filter = 21x21
σ = 4
filter = 21x21
σ = 8
filter = 21x21
Note: filter visualizations are independently normalized throughout
the slides so you can see them better
![Page 35: Filtering - Electrical Engineering and Computer Science · Gaussian filtering removes parts of the signal above a certain frequency. Often noise is high frequency and signal is low](https://reader033.vdocuments.net/reader033/viewer/2022050123/5f531b6dc7717c6c726d9383/html5/thumbnails/35.jpg)
Applying Gaussian Filters
![Page 36: Filtering - Electrical Engineering and Computer Science · Gaussian filtering removes parts of the signal above a certain frequency. Often noise is high frequency and signal is low](https://reader033.vdocuments.net/reader033/viewer/2022050123/5f531b6dc7717c6c726d9383/html5/thumbnails/36.jpg)
Applying Gaussian Filters
Input Image
(no filter)
![Page 37: Filtering - Electrical Engineering and Computer Science · Gaussian filtering removes parts of the signal above a certain frequency. Often noise is high frequency and signal is low](https://reader033.vdocuments.net/reader033/viewer/2022050123/5f531b6dc7717c6c726d9383/html5/thumbnails/37.jpg)
Applying Gaussian Filters
σ = 1
![Page 38: Filtering - Electrical Engineering and Computer Science · Gaussian filtering removes parts of the signal above a certain frequency. Often noise is high frequency and signal is low](https://reader033.vdocuments.net/reader033/viewer/2022050123/5f531b6dc7717c6c726d9383/html5/thumbnails/38.jpg)
Applying Gaussian Filters
σ = 2
![Page 39: Filtering - Electrical Engineering and Computer Science · Gaussian filtering removes parts of the signal above a certain frequency. Often noise is high frequency and signal is low](https://reader033.vdocuments.net/reader033/viewer/2022050123/5f531b6dc7717c6c726d9383/html5/thumbnails/39.jpg)
Applying Gaussian Filters
σ = 4
![Page 40: Filtering - Electrical Engineering and Computer Science · Gaussian filtering removes parts of the signal above a certain frequency. Often noise is high frequency and signal is low](https://reader033.vdocuments.net/reader033/viewer/2022050123/5f531b6dc7717c6c726d9383/html5/thumbnails/40.jpg)
Applying Gaussian Filters
σ = 8
![Page 41: Filtering - Electrical Engineering and Computer Science · Gaussian filtering removes parts of the signal above a certain frequency. Often noise is high frequency and signal is low](https://reader033.vdocuments.net/reader033/viewer/2022050123/5f531b6dc7717c6c726d9383/html5/thumbnails/41.jpg)
Picking a Filter Size
σ = 8, size = 21 σ = 8, size = 43
Too small filter → bad approximation
Want size ≈ 6σ (99.7% of energy)
Left far too small; right slightly too small!
![Page 42: Filtering - Electrical Engineering and Computer Science · Gaussian filtering removes parts of the signal above a certain frequency. Often noise is high frequency and signal is low](https://reader033.vdocuments.net/reader033/viewer/2022050123/5f531b6dc7717c6c726d9383/html5/thumbnails/42.jpg)
Runtime Complexity
for ImageY in range(N):
for ImageX in range(N):
for FilterY in range(M):
for FilterX in range(M):
…
Time: O(N2M2)
I11 I12 I13
I21 I22 I23
I31 I32 I33
I14 I15 I16
I24 I25 I26
I34 I35 I36
I41 I42 I43 I44 I45 I46
I51 I52 I53 I54 I55 I56
F11 F12 F13
F21 F22 F23
F31 F32 F33
I61 I62 I63 I64 I65 I66
Image size = NxN = 6x6
Filter size = MxM = 3x3
![Page 43: Filtering - Electrical Engineering and Computer Science · Gaussian filtering removes parts of the signal above a certain frequency. Often noise is high frequency and signal is low](https://reader033.vdocuments.net/reader033/viewer/2022050123/5f531b6dc7717c6c726d9383/html5/thumbnails/43.jpg)
Separability
Fy1
Fy2
Fy3
Fx1 Fx2 Fx3⁎ =
Fx1 *
Fy1
Fx1 *
Fy2
Fx1 *
Fy3
Fx2 *
Fy1
Fx2 *
Fy2
Fx2 *
Fy3
Fx3 *
Fy1
Fx3 *
Fy2
Fx3 *
Fy3
Conv(vector, transposed vector) → outer product
![Page 44: Filtering - Electrical Engineering and Computer Science · Gaussian filtering removes parts of the signal above a certain frequency. Often noise is high frequency and signal is low](https://reader033.vdocuments.net/reader033/viewer/2022050123/5f531b6dc7717c6c726d9383/html5/thumbnails/44.jpg)
Separability
𝐹𝑖𝑙𝑡𝑒𝑟𝑖𝑗 ∝1
2𝜋𝜎2exp −
𝑥2 + 𝑦2
2𝜎2
𝐹𝑖𝑙𝑡𝑒𝑟𝑖𝑗 ∝1
2𝜋𝜎exp −
𝑥2
2𝜎2
1
2𝜋𝜎exp −
𝑦2
2𝜎2
→
![Page 45: Filtering - Electrical Engineering and Computer Science · Gaussian filtering removes parts of the signal above a certain frequency. Often noise is high frequency and signal is low](https://reader033.vdocuments.net/reader033/viewer/2022050123/5f531b6dc7717c6c726d9383/html5/thumbnails/45.jpg)
Separability
⁎ =
1D Gaussian ⁎ 1D Gaussian = 2D Gaussian
Image ⁎ 2D Gauss = Image ⁎ (1D Gauss ⁎ 1D Gauss )
= (Image ⁎ 1D Gauss) ⁎ 1D Gauss
![Page 46: Filtering - Electrical Engineering and Computer Science · Gaussian filtering removes parts of the signal above a certain frequency. Often noise is high frequency and signal is low](https://reader033.vdocuments.net/reader033/viewer/2022050123/5f531b6dc7717c6c726d9383/html5/thumbnails/46.jpg)
Runtime Complexity
for ImageY in range(N):
for ImageX in range(N):
for FilterY in range(M):
…
for ImageY in range(N):
for ImageX in range(N):
for FilterX in range(M):
…
Time: O(N2M)
I11 I12 I13
I21 I22 I23
I31 I32 I33
I14 I15 I16
I24 I25 I26
I34 I35 I36
I41 I42 I43 I44 I45 I46
I51 I52 I53 I54 I55 I56
I61 I62 I63 I64 I65 I66
Image size = NxN = 6x6
Filter size = Mx1 = 3x1
F1
F2
F3
What are my compute
savings for a 13x13 filter?
![Page 47: Filtering - Electrical Engineering and Computer Science · Gaussian filtering removes parts of the signal above a certain frequency. Often noise is high frequency and signal is low](https://reader033.vdocuments.net/reader033/viewer/2022050123/5f531b6dc7717c6c726d9383/html5/thumbnails/47.jpg)
Why Gaussian?
Gaussian filtering removes parts of the signal above a certain frequency. Often noise is high
frequency and signal is low frequency.
![Page 48: Filtering - Electrical Engineering and Computer Science · Gaussian filtering removes parts of the signal above a certain frequency. Often noise is high frequency and signal is low](https://reader033.vdocuments.net/reader033/viewer/2022050123/5f531b6dc7717c6c726d9383/html5/thumbnails/48.jpg)
Where Gaussian Fails
![Page 49: Filtering - Electrical Engineering and Computer Science · Gaussian filtering removes parts of the signal above a certain frequency. Often noise is high frequency and signal is low](https://reader033.vdocuments.net/reader033/viewer/2022050123/5f531b6dc7717c6c726d9383/html5/thumbnails/49.jpg)
Applying Gaussian Filters
σ = 1
![Page 50: Filtering - Electrical Engineering and Computer Science · Gaussian filtering removes parts of the signal above a certain frequency. Often noise is high frequency and signal is low](https://reader033.vdocuments.net/reader033/viewer/2022050123/5f531b6dc7717c6c726d9383/html5/thumbnails/50.jpg)
Why Does This Fail?
0.1 0.8 0.1Filter
Signal 10 12 9 8 1000 11 10 12
Output 11.5 9.2 107.3 801.9 109.8 10.3
Means can be arbitrarily distorted by outliers
What else is an “average” other than a mean?
![Page 51: Filtering - Electrical Engineering and Computer Science · Gaussian filtering removes parts of the signal above a certain frequency. Often noise is high frequency and signal is low](https://reader033.vdocuments.net/reader033/viewer/2022050123/5f531b6dc7717c6c726d9383/html5/thumbnails/51.jpg)
Non-linear Filters (2D)
[040, 081, 013, 125, 830, 076, 144, 092, 108]
92
Sort
[013, 040, 076, 081, 092, 108, 125, 144, 830]
[830, 076, 080, 092, 108, 095, 102, 106, 087]
[076, 080, 087, 092, 095, 102, 106, 108, 830]
Sort
95
40 81
125 830
144 92
13
76
108
22
80
95
132 102 106 87
![Page 52: Filtering - Electrical Engineering and Computer Science · Gaussian filtering removes parts of the signal above a certain frequency. Often noise is high frequency and signal is low](https://reader033.vdocuments.net/reader033/viewer/2022050123/5f531b6dc7717c6c726d9383/html5/thumbnails/52.jpg)
Applying Median Filter
Median
Filter
(size=3)
![Page 53: Filtering - Electrical Engineering and Computer Science · Gaussian filtering removes parts of the signal above a certain frequency. Often noise is high frequency and signal is low](https://reader033.vdocuments.net/reader033/viewer/2022050123/5f531b6dc7717c6c726d9383/html5/thumbnails/53.jpg)
Applying Median Filter
Median
Filter
(size = 7)
![Page 54: Filtering - Electrical Engineering and Computer Science · Gaussian filtering removes parts of the signal above a certain frequency. Often noise is high frequency and signal is low](https://reader033.vdocuments.net/reader033/viewer/2022050123/5f531b6dc7717c6c726d9383/html5/thumbnails/54.jpg)
Is Median Filtering Linear?
Example from (I believe): Kristen Grauman
1 1 11 1 22 2 2
0 0 00 1 00 0 0
+1 1 11 2 22 2 2
=
Median Filter
1 0 2+ =
![Page 55: Filtering - Electrical Engineering and Computer Science · Gaussian filtering removes parts of the signal above a certain frequency. Often noise is high frequency and signal is low](https://reader033.vdocuments.net/reader033/viewer/2022050123/5f531b6dc7717c6c726d9383/html5/thumbnails/55.jpg)
Some Examples of Filtering
![Page 56: Filtering - Electrical Engineering and Computer Science · Gaussian filtering removes parts of the signal above a certain frequency. Often noise is high frequency and signal is low](https://reader033.vdocuments.net/reader033/viewer/2022050123/5f531b6dc7717c6c726d9383/html5/thumbnails/56.jpg)
Filtering – Sharpening
-
Image Smoothed
=
Details
![Page 57: Filtering - Electrical Engineering and Computer Science · Gaussian filtering removes parts of the signal above a certain frequency. Often noise is high frequency and signal is low](https://reader033.vdocuments.net/reader033/viewer/2022050123/5f531b6dc7717c6c726d9383/html5/thumbnails/57.jpg)
Filtering – Sharpening
+α
Image Details
=
“Sharpened” α=1
![Page 58: Filtering - Electrical Engineering and Computer Science · Gaussian filtering removes parts of the signal above a certain frequency. Often noise is high frequency and signal is low](https://reader033.vdocuments.net/reader033/viewer/2022050123/5f531b6dc7717c6c726d9383/html5/thumbnails/58.jpg)
Filtering – Sharpening
=
+α
Image Details
“Sharpened” α=0
![Page 59: Filtering - Electrical Engineering and Computer Science · Gaussian filtering removes parts of the signal above a certain frequency. Often noise is high frequency and signal is low](https://reader033.vdocuments.net/reader033/viewer/2022050123/5f531b6dc7717c6c726d9383/html5/thumbnails/59.jpg)
Filtering – Sharpening
=
+α
Image Details
“Sharpened” α=2
![Page 60: Filtering - Electrical Engineering and Computer Science · Gaussian filtering removes parts of the signal above a certain frequency. Often noise is high frequency and signal is low](https://reader033.vdocuments.net/reader033/viewer/2022050123/5f531b6dc7717c6c726d9383/html5/thumbnails/60.jpg)
Filtering – Sharpening
=
+α
Image Details
“Sharpened” α=0
![Page 61: Filtering - Electrical Engineering and Computer Science · Gaussian filtering removes parts of the signal above a certain frequency. Often noise is high frequency and signal is low](https://reader033.vdocuments.net/reader033/viewer/2022050123/5f531b6dc7717c6c726d9383/html5/thumbnails/61.jpg)
Filtering – Extreme Sharpening
=
+α
Image Details
“Sharpened” α=10
![Page 62: Filtering - Electrical Engineering and Computer Science · Gaussian filtering removes parts of the signal above a certain frequency. Often noise is high frequency and signal is low](https://reader033.vdocuments.net/reader033/viewer/2022050123/5f531b6dc7717c6c726d9383/html5/thumbnails/62.jpg)
Filtering
-1 0 1
Dx Dy
-1 0 1T
What’s this Filter?
![Page 63: Filtering - Electrical Engineering and Computer Science · Gaussian filtering removes parts of the signal above a certain frequency. Often noise is high frequency and signal is low](https://reader033.vdocuments.net/reader033/viewer/2022050123/5f531b6dc7717c6c726d9383/html5/thumbnails/63.jpg)
Filtering – Derivatives
(Dx2 + Dy2 )1/2
![Page 64: Filtering - Electrical Engineering and Computer Science · Gaussian filtering removes parts of the signal above a certain frequency. Often noise is high frequency and signal is low](https://reader033.vdocuments.net/reader033/viewer/2022050123/5f531b6dc7717c6c726d9383/html5/thumbnails/64.jpg)
Filtering – Counting
⁎ =r=10
Pixels Disk ???
How many “on” pixels have
10+ neighbors within 10 pixels?
![Page 65: Filtering - Electrical Engineering and Computer Science · Gaussian filtering removes parts of the signal above a certain frequency. Often noise is high frequency and signal is low](https://reader033.vdocuments.net/reader033/viewer/2022050123/5f531b6dc7717c6c726d9383/html5/thumbnails/65.jpg)
Filtering – Counting
How many “on” pixels have
10+ neighbors within 10 pixels?
x =
Pixels AnswerDensity
![Page 66: Filtering - Electrical Engineering and Computer Science · Gaussian filtering removes parts of the signal above a certain frequency. Often noise is high frequency and signal is low](https://reader033.vdocuments.net/reader033/viewer/2022050123/5f531b6dc7717c6c726d9383/html5/thumbnails/66.jpg)
Filtering – Missing Data
Oh no! Missing data!
(and we know where)
Common with many non-normal cameras (e.g., depth cameras)
![Page 67: Filtering - Electrical Engineering and Computer Science · Gaussian filtering removes parts of the signal above a certain frequency. Often noise is high frequency and signal is low](https://reader033.vdocuments.net/reader033/viewer/2022050123/5f531b6dc7717c6c726d9383/html5/thumbnails/67.jpg)
Aside (Added after class)
• Element-wise operations on matrices A,B:
• Addition (same as normal): • Outij = Aij + Bij
• Division: • Outij = Aij / Bij
• Multiplication (aka Hadamard Product):• Outij = Aij * Bij
Not typically taught in entry-level linear algebra. Common when working with real matrix data.
![Page 68: Filtering - Electrical Engineering and Computer Science · Gaussian filtering removes parts of the signal above a certain frequency. Often noise is high frequency and signal is low](https://reader033.vdocuments.net/reader033/viewer/2022050123/5f531b6dc7717c6c726d9383/html5/thumbnails/68.jpg)
Filtering – Missing Data
Binary
Mask
Image ⁎
⁎
Per-element /
![Page 69: Filtering - Electrical Engineering and Computer Science · Gaussian filtering removes parts of the signal above a certain frequency. Often noise is high frequency and signal is low](https://reader033.vdocuments.net/reader033/viewer/2022050123/5f531b6dc7717c6c726d9383/html5/thumbnails/69.jpg)
Filtering – Missing Data
Binary
Mask
Image
Per-element /
![Page 70: Filtering - Electrical Engineering and Computer Science · Gaussian filtering removes parts of the signal above a certain frequency. Often noise is high frequency and signal is low](https://reader033.vdocuments.net/reader033/viewer/2022050123/5f531b6dc7717c6c726d9383/html5/thumbnails/70.jpg)
Filtering – Missing Data
Before
![Page 71: Filtering - Electrical Engineering and Computer Science · Gaussian filtering removes parts of the signal above a certain frequency. Often noise is high frequency and signal is low](https://reader033.vdocuments.net/reader033/viewer/2022050123/5f531b6dc7717c6c726d9383/html5/thumbnails/71.jpg)
Filtering – Missing Data
After
![Page 72: Filtering - Electrical Engineering and Computer Science · Gaussian filtering removes parts of the signal above a certain frequency. Often noise is high frequency and signal is low](https://reader033.vdocuments.net/reader033/viewer/2022050123/5f531b6dc7717c6c726d9383/html5/thumbnails/72.jpg)
Filtering – Missing Data
After (without missing data)