際際滷

際際滷Share a Scribd company logo
Filtering
Let¨s Take An Image
Let¨s Fix Things
際際滷 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
1D Case
1/3 1/3 1/3
Filter/
David
Signal/
Front Row
10 12 9 11 10 11 12
Output 10.33 10.66 10 10.66 11
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
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
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
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?
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
Painful Details C Edge Cases
f
g
g
g
g
f
g
g
g
g
f
g
g
g
g
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 C any part of g touches f. Same C same size as f;
Valid C only when filter doesn¨t fall off edge.
Painful Details C Edge Cases
What to about the ^? ̄ region?
Symm: fold sides over
pad/fill: add value, often 0
f
g
g
g
g
? ? ? ?
Circular/Wrap: wrap around
f/g Diagram Credit: D. Lowe
Painful Details C Does it Matter?
Input
Image
Box Filtered
???
Box Filtered
???
(I¨ve applied the filter per-color channel)
Which padding did I use and why?
Note C this is a zoom of the filtered, not a filter of the zoomed
Painful Details C Does it Matter?
Input
Image
Box Filtered
Symm Pad
Box Filtered
Zero Pad
(I¨ve applied the filter per-color channel)
Note C this is a zoom of the filtered, not a filter of the zoomed
Practice with Linear Filters
際際滷 Credit: D. Lowe
Original
?
0 0 0
0 1 0
0 0 0
Practice with Linear Filters
際際滷 Credit: D. Lowe
Original
0 0 0
0 1 0
0 0 0
The Same!
Practice with Linear Filters
際際滷 Credit: D. Lowe
Original
?
0 0 0
0 0 1
0 0 0
Practice with Linear Filters
際際滷 Credit: D. Lowe
Original
0 0 0
0 0 1
0 0 0
Shifted
LEFT
1 pixel
Practice with Linear Filters
際際滷 Credit: D. Lowe
Original
?
0 1 0
0 0 0
0 0 0
Practice with Linear Filters
際際滷 Credit: D. Lowe
Original
0 1 0
0 0 0
0 0 0
Shifted
DOWN
1 pixel
Practice with Linear Filters
?
際際滷 Credit: D. Lowe
Original
1/9 1/9 1/9
1/9 1/9 1/9
1/9 1/9 1/9
Practice with Linear Filters
際際滷 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)
Practice with Linear Filters
?
際際滷 Credit: D. Lowe
Original
1/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
-
Practice with Linear Filters
際際滷 Credit: D. Lowe
Original
1/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)
Sharpening
際際滷 Credit: D. Lowe
Properties C Linear
Assume: I image f1, f2 filters
Linear: apply(I,f1+f2) = apply(I,f1) + apply(I,f2)
I is a white box on black, and f1, f2 are rectangles
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( , , )
Properties C 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( , ) =
Painful Details C Signal Processing
Often called ^convolution ̄. Actually cross-
correlation.
Cross-Correlation
(Original Orientation)
Convolution
(Flipped in x and y)
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
=
*
Questions?
? Nearly everything onwards is a convolution.
? This is important to get right.
Smoothing With A Box
Intuition: if filter touches it, it gets a contribution.
Input Box Filter
Solution C Weighted Combination
Intuition: weight contributions according to
closeness to center.
???????? 『1
???????? 『exp ?
(?
?2
+ ?2
2 ?
2 )
What¨s this?
Recognize the Filter?
???????? 『
1
2? ?
2
exp?
(?
?
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
Smoothing With A Box & Gauss
Still have some speckles, but it¨s not a big box
Input Box Filter Gauss. Filter
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
Applying Gaussian Filters
Applying Gaussian Filters
Input Image
(no filter)
Applying Gaussian Filters
σ = 1
Applying Gaussian Filters
σ = 2
Applying Gaussian Filters
σ = 4
Applying Gaussian Filters
σ = 8
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!
Runtime Complexity
for ImageY in range(N):
for ImageX in range(N):
for FilterY in
range(M):
for FilterX in
range(M):
´
Time: O(N2
M2
)
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
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
Separability
???????? 『
1
2? ?
2
exp?
(?
?
2
+?
2
2 ?
2 )
???????? 『
1
〔2? ?
exp(?
?
2
2 ?
2 ) 1
〔2 ? ?
exp ?(?
?
2
2 ?
2 )
★
Separability
? =
1D Gaussian 1D Gaussian = 2D Gaussian
?
Image 2D Gauss = Image (1D Gauss 1D Gauss )
? ? ?
= (Image 1D Gauss) 1D Gauss
? ?
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):
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?
Why Gaussian?
Gaussian filtering removes parts of the signal
above a certain frequency. Often noise is high
frequency and signal is low frequency.
Where Gaussian Fails
Applying Gaussian Filters
σ = 1
Why Does This Fail?
0.1 0.8 0.1
Filter
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?
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
Applying Median Filter
Median
Filter
(size=3)
Applying Median Filter
Median
Filter
(size = 7)
Is Median Filtering Linear?
Example from (I believe): Kristen Grauman
[
1 1 1
1 1 2
2 2 2] [
0 0 0
0 1 0
0 0 0]
+
[
1 1 1
1 2 2
2 2 2]
=
Median Filter
1 0 2
+ =
Some Examples of Filtering
Filtering C Sharpening
-
Image Smoothed
=
Details
Filtering C Sharpening
+α
Image Details
=
^Sharpened ̄ α=1
Filtering C Sharpening
=
+α
Image Details
^Sharpened ̄ α=0
Filtering C Sharpening
=
+α
Image Details
^Sharpened ̄ α=2
Filtering C Sharpening
=
+α
Image Details
^Sharpened ̄ α=0
Filtering C Extreme Sharpening
=
+α
Image Details
^Sharpened ̄ α=10
Filtering
-1 0 1
Dx Dy
-1 0 1
T
What¨s this Filter?
Filtering C Derivatives
(Dx2
+ Dy2
)1/2
Filtering C Counting
? =
r=10
Pixels Disk ???
How many ^on ̄ pixels have
10+ neighbors within 10 pixels?
Filtering C Counting
How many ^on ̄ pixels have
10+ neighbors within 10 pixels?
x =
Pixels Answer
Density
Filtering C Missing Data
Oh no! Missing data!
(and we know where)
Common with many non-normal cameras (e.g., depth cameras)
Filtering C Missing Data
Binary
Mask
Image ?
?
Per-element /
Filtering C Missing Data
Binary
Mask
Image
Per-element /
Filtering C Missing Data
Before
Filtering C Missing Data
After
Filtering C Missing Data
After (without missing data)

More Related Content

Similar to Filtering in digital signal and image processing (20)

DSP presentation_latest
DSP presentation_latestDSP presentation_latest
DSP presentation_latest
Haowei Jiang
?
Filtering.ppt
Filtering.pptFiltering.ppt
Filtering.ppt
Binish Raza
?
Notes on image processing
Notes on image processingNotes on image processing
Notes on image processing
Mohammed Kamel
?
03 image transformations_i
03 image transformations_i03 image transformations_i
03 image transformations_i
ankit_ppt
?
Lecture 4
Lecture 4Lecture 4
Lecture 4
Wael Sharba
?
Spatial filtering
Spatial filteringSpatial filtering
Spatial filtering
Sanyam Agarwal
?
Analysis of Non Linear Filters with Various Density of Impulse Noise for Diff...
Analysis of Non Linear Filters with Various Density of Impulse Noise for Diff...Analysis of Non Linear Filters with Various Density of Impulse Noise for Diff...
Analysis of Non Linear Filters with Various Density of Impulse Noise for Diff...
IJERA Editor
?
SPATIAL FILTER
SPATIAL FILTERSPATIAL FILTER
SPATIAL FILTER
shalet kochumuttath Shaji
?
2. filtering basics
2. filtering basics2. filtering basics
2. filtering basics
Atul Kumar Jha
?
Computer Vision - Image Filters
Computer Vision - Image FiltersComputer Vision - Image Filters
Computer Vision - Image Filters
Yoss Cohen
?
restoration_recon_chap5_GW.pdf
restoration_recon_chap5_GW.pdfrestoration_recon_chap5_GW.pdf
restoration_recon_chap5_GW.pdf
SUBHASHREEBASU5
?
Lec05 filter
Lec05 filterLec05 filter
Lec05 filter
BaliThorat1
?
PPT s04-machine vision-s2
PPT s04-machine vision-s2PPT s04-machine vision-s2
PPT s04-machine vision-s2
Binus Online Learning
?
Image enhancement techniques - Digital Image Processing
Image enhancement techniques - Digital Image ProcessingImage enhancement techniques - Digital Image Processing
Image enhancement techniques - Digital Image Processing
BharaniDharan195623
?
Edge detection
Edge detectionEdge detection
Edge detection
Edi Supriadi
?
DS-004-Robust Design
DS-004-Robust DesignDS-004-Robust Design
DS-004-Robust Design
handbook
?
Image_filtering (1).pptx
Image_filtering (1).pptxImage_filtering (1).pptx
Image_filtering (1).pptx
wdwd10
?
Module 31
Module 31Module 31
Module 31
UllasSS1
?
TEM workshop 2013: Electron diffraction
TEM workshop 2013: Electron diffractionTEM workshop 2013: Electron diffraction
TEM workshop 2013: Electron diffraction
Joke Hadermann
?
04 cie552 image_filtering_frequency
04 cie552 image_filtering_frequency04 cie552 image_filtering_frequency
04 cie552 image_filtering_frequency
Elsayed Hemayed
?
DSP presentation_latest
DSP presentation_latestDSP presentation_latest
DSP presentation_latest
Haowei Jiang
?
Notes on image processing
Notes on image processingNotes on image processing
Notes on image processing
Mohammed Kamel
?
03 image transformations_i
03 image transformations_i03 image transformations_i
03 image transformations_i
ankit_ppt
?
Analysis of Non Linear Filters with Various Density of Impulse Noise for Diff...
Analysis of Non Linear Filters with Various Density of Impulse Noise for Diff...Analysis of Non Linear Filters with Various Density of Impulse Noise for Diff...
Analysis of Non Linear Filters with Various Density of Impulse Noise for Diff...
IJERA Editor
?
Computer Vision - Image Filters
Computer Vision - Image FiltersComputer Vision - Image Filters
Computer Vision - Image Filters
Yoss Cohen
?
restoration_recon_chap5_GW.pdf
restoration_recon_chap5_GW.pdfrestoration_recon_chap5_GW.pdf
restoration_recon_chap5_GW.pdf
SUBHASHREEBASU5
?
Image enhancement techniques - Digital Image Processing
Image enhancement techniques - Digital Image ProcessingImage enhancement techniques - Digital Image Processing
Image enhancement techniques - Digital Image Processing
BharaniDharan195623
?
DS-004-Robust Design
DS-004-Robust DesignDS-004-Robust Design
DS-004-Robust Design
handbook
?
Image_filtering (1).pptx
Image_filtering (1).pptxImage_filtering (1).pptx
Image_filtering (1).pptx
wdwd10
?
TEM workshop 2013: Electron diffraction
TEM workshop 2013: Electron diffractionTEM workshop 2013: Electron diffraction
TEM workshop 2013: Electron diffraction
Joke Hadermann
?
04 cie552 image_filtering_frequency
04 cie552 image_filtering_frequency04 cie552 image_filtering_frequency
04 cie552 image_filtering_frequency
Elsayed Hemayed
?

More from Indra Hermawan (12)

Numerical Linear Algebra in digital image processing
Numerical Linear Algebra in digital image processingNumerical Linear Algebra in digital image processing
Numerical Linear Algebra in digital image processing
Indra Hermawan
?
Sistem Pengomposan Cerdas Berbasis IoT untuk Pengelolaan Sampah Organik Berke...
Sistem Pengomposan Cerdas Berbasis IoT untuk Pengelolaan Sampah Organik Berke...Sistem Pengomposan Cerdas Berbasis IoT untuk Pengelolaan Sampah Organik Berke...
Sistem Pengomposan Cerdas Berbasis IoT untuk Pengelolaan Sampah Organik Berke...
Indra Hermawan
?
introduction to camera, the operation of camera
introduction to camera, the operation of cameraintroduction to camera, the operation of camera
introduction to camera, the operation of camera
Indra Hermawan
?
lab_linear_regression_hy539 (1)_221109_035050.pdf
lab_linear_regression_hy539 (1)_221109_035050.pdflab_linear_regression_hy539 (1)_221109_035050.pdf
lab_linear_regression_hy539 (1)_221109_035050.pdf
Indra Hermawan
?
perancangan program kerja KBK perancangan program kerja KBK perancangan progr...
perancangan program kerja KBK perancangan program kerja KBK perancangan progr...perancangan program kerja KBK perancangan program kerja KBK perancangan progr...
perancangan program kerja KBK perancangan program kerja KBK perancangan progr...
Indra Hermawan
?
zigbee networks using xbee modules zigbee networks using xbee modules
zigbee networks using xbee modules zigbee networks using xbee moduleszigbee networks using xbee modules zigbee networks using xbee modules
zigbee networks using xbee modules zigbee networks using xbee modules
Indra Hermawan
?
lecture_8-wsn.pptx
lecture_8-wsn.pptxlecture_8-wsn.pptx
lecture_8-wsn.pptx
Indra Hermawan
?
Trik Pembuatan Surat Lamaran Pekerjaan.ppt
Trik Pembuatan Surat Lamaran Pekerjaan.pptTrik Pembuatan Surat Lamaran Pekerjaan.ppt
Trik Pembuatan Surat Lamaran Pekerjaan.ppt
Indra Hermawan
?
Matlab tutorial and Linear Algebra Review.ppt
Matlab tutorial and Linear Algebra Review.pptMatlab tutorial and Linear Algebra Review.ppt
Matlab tutorial and Linear Algebra Review.ppt
Indra Hermawan
?
OK08-klasifikasi-dgn-naive-bayes.ppt
OK08-klasifikasi-dgn-naive-bayes.pptOK08-klasifikasi-dgn-naive-bayes.ppt
OK08-klasifikasi-dgn-naive-bayes.ppt
Indra Hermawan
?
lecture15-supervised.ppt
lecture15-supervised.pptlecture15-supervised.ppt
lecture15-supervised.ppt
Indra Hermawan
?
Chapter 1.ppt
Chapter 1.pptChapter 1.ppt
Chapter 1.ppt
Indra Hermawan
?
Numerical Linear Algebra in digital image processing
Numerical Linear Algebra in digital image processingNumerical Linear Algebra in digital image processing
Numerical Linear Algebra in digital image processing
Indra Hermawan
?
Sistem Pengomposan Cerdas Berbasis IoT untuk Pengelolaan Sampah Organik Berke...
Sistem Pengomposan Cerdas Berbasis IoT untuk Pengelolaan Sampah Organik Berke...Sistem Pengomposan Cerdas Berbasis IoT untuk Pengelolaan Sampah Organik Berke...
Sistem Pengomposan Cerdas Berbasis IoT untuk Pengelolaan Sampah Organik Berke...
Indra Hermawan
?
introduction to camera, the operation of camera
introduction to camera, the operation of cameraintroduction to camera, the operation of camera
introduction to camera, the operation of camera
Indra Hermawan
?
lab_linear_regression_hy539 (1)_221109_035050.pdf
lab_linear_regression_hy539 (1)_221109_035050.pdflab_linear_regression_hy539 (1)_221109_035050.pdf
lab_linear_regression_hy539 (1)_221109_035050.pdf
Indra Hermawan
?
perancangan program kerja KBK perancangan program kerja KBK perancangan progr...
perancangan program kerja KBK perancangan program kerja KBK perancangan progr...perancangan program kerja KBK perancangan program kerja KBK perancangan progr...
perancangan program kerja KBK perancangan program kerja KBK perancangan progr...
Indra Hermawan
?
zigbee networks using xbee modules zigbee networks using xbee modules
zigbee networks using xbee modules zigbee networks using xbee moduleszigbee networks using xbee modules zigbee networks using xbee modules
zigbee networks using xbee modules zigbee networks using xbee modules
Indra Hermawan
?
Trik Pembuatan Surat Lamaran Pekerjaan.ppt
Trik Pembuatan Surat Lamaran Pekerjaan.pptTrik Pembuatan Surat Lamaran Pekerjaan.ppt
Trik Pembuatan Surat Lamaran Pekerjaan.ppt
Indra Hermawan
?
Matlab tutorial and Linear Algebra Review.ppt
Matlab tutorial and Linear Algebra Review.pptMatlab tutorial and Linear Algebra Review.ppt
Matlab tutorial and Linear Algebra Review.ppt
Indra Hermawan
?
OK08-klasifikasi-dgn-naive-bayes.ppt
OK08-klasifikasi-dgn-naive-bayes.pptOK08-klasifikasi-dgn-naive-bayes.ppt
OK08-klasifikasi-dgn-naive-bayes.ppt
Indra Hermawan
?

Recently uploaded (20)

Unit-2 Velocity and Acceleration Analysis (Relative Velocity Method).pptx
Unit-2 Velocity and Acceleration Analysis (Relative Velocity Method).pptxUnit-2 Velocity and Acceleration Analysis (Relative Velocity Method).pptx
Unit-2 Velocity and Acceleration Analysis (Relative Velocity Method).pptx
Kirankumar Jagtap
?
Introduction-to-Robotics-PowerPoint-Presentation-on-Robotics.ppt
Introduction-to-Robotics-PowerPoint-Presentation-on-Robotics.pptIntroduction-to-Robotics-PowerPoint-Presentation-on-Robotics.ppt
Introduction-to-Robotics-PowerPoint-Presentation-on-Robotics.ppt
tobopol221
?
METAL OXIDE FIELD EFFECT SEMICONDUCTOR-MOSFET
METAL OXIDE FIELD EFFECT SEMICONDUCTOR-MOSFETMETAL OXIDE FIELD EFFECT SEMICONDUCTOR-MOSFET
METAL OXIDE FIELD EFFECT SEMICONDUCTOR-MOSFET
punithaece
?
b29e51b5-c830-4877-a978-a6b308ea8c5f.ppt
b29e51b5-c830-4877-a978-a6b308ea8c5f.pptb29e51b5-c830-4877-a978-a6b308ea8c5f.ppt
b29e51b5-c830-4877-a978-a6b308ea8c5f.ppt
dashrimi0
?
芙坪茶氏Y創_Data-Centric AI in The Age of Large Language Models
芙坪茶氏Y創_Data-Centric AI in The Age of Large Language Models芙坪茶氏Y創_Data-Centric AI in The Age of Large Language Models
芙坪茶氏Y創_Data-Centric AI in The Age of Large Language Models
鰻粥京晦粥皆幄塀氏芙
?
optical fibres ppt on its full details.pptx
optical fibres ppt on its full details.pptxoptical fibres ppt on its full details.pptx
optical fibres ppt on its full details.pptx
sashiP
?
Application of Artificial Neural Network.pptx
Application of Artificial Neural Network.pptxApplication of Artificial Neural Network.pptx
Application of Artificial Neural Network.pptx
JeveshMagnani
?
lecture 4MORTAR for construction works(2).ppt
lecture 4MORTAR for construction works(2).pptlecture 4MORTAR for construction works(2).ppt
lecture 4MORTAR for construction works(2).ppt
SimeonWoyesa
?
move curriculum guidennnnnnnnnnnnnnnnnnnnnnnoriginal.pptx
move curriculum guidennnnnnnnnnnnnnnnnnnnnnnoriginal.pptxmove curriculum guidennnnnnnnnnnnnnnnnnnnnnnoriginal.pptx
move curriculum guidennnnnnnnnnnnnnnnnnnnnnnoriginal.pptx
CarlosFernandez289274
?
22PCOAM16_UNIT 2_Session 10 Multi Layer Perceptrons.pptx
22PCOAM16_UNIT 2_Session 10 Multi Layer Perceptrons.pptx22PCOAM16_UNIT 2_Session 10 Multi Layer Perceptrons.pptx
22PCOAM16_UNIT 2_Session 10 Multi Layer Perceptrons.pptx
Guru Nanak Technical Institutions
?
Development of Economical Dye Sensitized Solar Cell by Characterizing Polymer...
Development of Economical Dye Sensitized Solar Cell by Characterizing Polymer...Development of Economical Dye Sensitized Solar Cell by Characterizing Polymer...
Development of Economical Dye Sensitized Solar Cell by Characterizing Polymer...
OsamaButt23
?
Stack Applications : Infix to postfix conversion, Evaluation of postfix expre...
Stack Applications : Infix to postfix conversion, Evaluation of postfix expre...Stack Applications : Infix to postfix conversion, Evaluation of postfix expre...
Stack Applications : Infix to postfix conversion, Evaluation of postfix expre...
Dr. Madhuri Jawale
?
J111111111111111111111111111111111111111query.pptx
J111111111111111111111111111111111111111query.pptxJ111111111111111111111111111111111111111query.pptx
J111111111111111111111111111111111111111query.pptx
dkmishra2407
?
study of impact behaviour of dual material for energy absorption
study of impact behaviour of dual material for energy absorptionstudy of impact behaviour of dual material for energy absorption
study of impact behaviour of dual material for energy absorption
AmitChauhan352669
?
UNIT-2 - Concurrency & Interprocess Communicatio.pptx
UNIT-2 - Concurrency & Interprocess Communicatio.pptxUNIT-2 - Concurrency & Interprocess Communicatio.pptx
UNIT-2 - Concurrency & Interprocess Communicatio.pptx
kishanchauhan10888
?
How to start and then move forward in IT
How to start and then move forward in ITHow to start and then move forward in IT
How to start and then move forward in IT
Marian Marinov
?
Standard-Representation-for-Logic-Functions (1).pptx
Standard-Representation-for-Logic-Functions (1).pptxStandard-Representation-for-Logic-Functions (1).pptx
Standard-Representation-for-Logic-Functions (1).pptx
sashiP
?
CE324-Module-6-Linear Equations-Week.pptx
CE324-Module-6-Linear Equations-Week.pptxCE324-Module-6-Linear Equations-Week.pptx
CE324-Module-6-Linear Equations-Week.pptx
HannahPil2
?
Application of Artificial Neural Networks.pdf
Application of Artificial Neural Networks.pdfApplication of Artificial Neural Networks.pdf
Application of Artificial Neural Networks.pdf
JeveshMagnani
?
Aerodynamic Stability Tests for Cable-Stayed Bridges.pdf
Aerodynamic Stability Tests for Cable-Stayed Bridges.pdfAerodynamic Stability Tests for Cable-Stayed Bridges.pdf
Aerodynamic Stability Tests for Cable-Stayed Bridges.pdf
Kamel Farid
?
Unit-2 Velocity and Acceleration Analysis (Relative Velocity Method).pptx
Unit-2 Velocity and Acceleration Analysis (Relative Velocity Method).pptxUnit-2 Velocity and Acceleration Analysis (Relative Velocity Method).pptx
Unit-2 Velocity and Acceleration Analysis (Relative Velocity Method).pptx
Kirankumar Jagtap
?
Introduction-to-Robotics-PowerPoint-Presentation-on-Robotics.ppt
Introduction-to-Robotics-PowerPoint-Presentation-on-Robotics.pptIntroduction-to-Robotics-PowerPoint-Presentation-on-Robotics.ppt
Introduction-to-Robotics-PowerPoint-Presentation-on-Robotics.ppt
tobopol221
?
METAL OXIDE FIELD EFFECT SEMICONDUCTOR-MOSFET
METAL OXIDE FIELD EFFECT SEMICONDUCTOR-MOSFETMETAL OXIDE FIELD EFFECT SEMICONDUCTOR-MOSFET
METAL OXIDE FIELD EFFECT SEMICONDUCTOR-MOSFET
punithaece
?
b29e51b5-c830-4877-a978-a6b308ea8c5f.ppt
b29e51b5-c830-4877-a978-a6b308ea8c5f.pptb29e51b5-c830-4877-a978-a6b308ea8c5f.ppt
b29e51b5-c830-4877-a978-a6b308ea8c5f.ppt
dashrimi0
?
芙坪茶氏Y創_Data-Centric AI in The Age of Large Language Models
芙坪茶氏Y創_Data-Centric AI in The Age of Large Language Models芙坪茶氏Y創_Data-Centric AI in The Age of Large Language Models
芙坪茶氏Y創_Data-Centric AI in The Age of Large Language Models
鰻粥京晦粥皆幄塀氏芙
?
optical fibres ppt on its full details.pptx
optical fibres ppt on its full details.pptxoptical fibres ppt on its full details.pptx
optical fibres ppt on its full details.pptx
sashiP
?
Application of Artificial Neural Network.pptx
Application of Artificial Neural Network.pptxApplication of Artificial Neural Network.pptx
Application of Artificial Neural Network.pptx
JeveshMagnani
?
lecture 4MORTAR for construction works(2).ppt
lecture 4MORTAR for construction works(2).pptlecture 4MORTAR for construction works(2).ppt
lecture 4MORTAR for construction works(2).ppt
SimeonWoyesa
?
move curriculum guidennnnnnnnnnnnnnnnnnnnnnnoriginal.pptx
move curriculum guidennnnnnnnnnnnnnnnnnnnnnnoriginal.pptxmove curriculum guidennnnnnnnnnnnnnnnnnnnnnnoriginal.pptx
move curriculum guidennnnnnnnnnnnnnnnnnnnnnnoriginal.pptx
CarlosFernandez289274
?
Development of Economical Dye Sensitized Solar Cell by Characterizing Polymer...
Development of Economical Dye Sensitized Solar Cell by Characterizing Polymer...Development of Economical Dye Sensitized Solar Cell by Characterizing Polymer...
Development of Economical Dye Sensitized Solar Cell by Characterizing Polymer...
OsamaButt23
?
Stack Applications : Infix to postfix conversion, Evaluation of postfix expre...
Stack Applications : Infix to postfix conversion, Evaluation of postfix expre...Stack Applications : Infix to postfix conversion, Evaluation of postfix expre...
Stack Applications : Infix to postfix conversion, Evaluation of postfix expre...
Dr. Madhuri Jawale
?
J111111111111111111111111111111111111111query.pptx
J111111111111111111111111111111111111111query.pptxJ111111111111111111111111111111111111111query.pptx
J111111111111111111111111111111111111111query.pptx
dkmishra2407
?
study of impact behaviour of dual material for energy absorption
study of impact behaviour of dual material for energy absorptionstudy of impact behaviour of dual material for energy absorption
study of impact behaviour of dual material for energy absorption
AmitChauhan352669
?
UNIT-2 - Concurrency & Interprocess Communicatio.pptx
UNIT-2 - Concurrency & Interprocess Communicatio.pptxUNIT-2 - Concurrency & Interprocess Communicatio.pptx
UNIT-2 - Concurrency & Interprocess Communicatio.pptx
kishanchauhan10888
?
How to start and then move forward in IT
How to start and then move forward in ITHow to start and then move forward in IT
How to start and then move forward in IT
Marian Marinov
?
Standard-Representation-for-Logic-Functions (1).pptx
Standard-Representation-for-Logic-Functions (1).pptxStandard-Representation-for-Logic-Functions (1).pptx
Standard-Representation-for-Logic-Functions (1).pptx
sashiP
?
CE324-Module-6-Linear Equations-Week.pptx
CE324-Module-6-Linear Equations-Week.pptxCE324-Module-6-Linear Equations-Week.pptx
CE324-Module-6-Linear Equations-Week.pptx
HannahPil2
?
Application of Artificial Neural Networks.pdf
Application of Artificial Neural Networks.pdfApplication of Artificial Neural Networks.pdf
Application of Artificial Neural Networks.pdf
JeveshMagnani
?
Aerodynamic Stability Tests for Cable-Stayed Bridges.pdf
Aerodynamic Stability Tests for Cable-Stayed Bridges.pdfAerodynamic Stability Tests for Cable-Stayed Bridges.pdf
Aerodynamic Stability Tests for Cable-Stayed Bridges.pdf
Kamel Farid
?

Filtering in digital signal and image processing

  • 3. Let¨s Fix Things 際際滷 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
  • 4. 1D Case 1/3 1/3 1/3 Filter/ David Signal/ Front Row 10 12 9 11 10 11 12 Output 10.33 10.66 10 10.66 11
  • 5. 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
  • 6. 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
  • 7. 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
  • 8. 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?
  • 9. 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
  • 10. Painful Details C Edge Cases f g g g g f g g g g f g g g g 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 C any part of g touches f. Same C same size as f; Valid C only when filter doesn¨t fall off edge.
  • 11. Painful Details C Edge Cases What to about the ^? ̄ region? Symm: fold sides over pad/fill: add value, often 0 f g g g g ? ? ? ? Circular/Wrap: wrap around f/g Diagram Credit: D. Lowe
  • 12. Painful Details C Does it Matter? Input Image Box Filtered ??? Box Filtered ??? (I¨ve applied the filter per-color channel) Which padding did I use and why? Note C this is a zoom of the filtered, not a filter of the zoomed
  • 13. Painful Details C Does it Matter? Input Image Box Filtered Symm Pad Box Filtered Zero Pad (I¨ve applied the filter per-color channel) Note C this is a zoom of the filtered, not a filter of the zoomed
  • 14. Practice with Linear Filters 際際滷 Credit: D. Lowe Original ? 0 0 0 0 1 0 0 0 0
  • 15. Practice with Linear Filters 際際滷 Credit: D. Lowe Original 0 0 0 0 1 0 0 0 0 The Same!
  • 16. Practice with Linear Filters 際際滷 Credit: D. Lowe Original ? 0 0 0 0 0 1 0 0 0
  • 17. Practice with Linear Filters 際際滷 Credit: D. Lowe Original 0 0 0 0 0 1 0 0 0 Shifted LEFT 1 pixel
  • 18. Practice with Linear Filters 際際滷 Credit: D. Lowe Original ? 0 1 0 0 0 0 0 0 0
  • 19. Practice with Linear Filters 際際滷 Credit: D. Lowe Original 0 1 0 0 0 0 0 0 0 Shifted DOWN 1 pixel
  • 20. Practice with Linear Filters ? 際際滷 Credit: D. Lowe Original 1/9 1/9 1/9 1/9 1/9 1/9 1/9 1/9 1/9
  • 21. Practice with Linear Filters 際際滷 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)
  • 22. Practice with Linear Filters ? 際際滷 Credit: D. Lowe Original 1/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 -
  • 23. Practice with Linear Filters 際際滷 Credit: D. Lowe Original 1/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)
  • 25. Properties C Linear Assume: I image f1, f2 filters Linear: apply(I,f1+f2) = apply(I,f1) + apply(I,f2) I is a white box on black, and f1, f2 are rectangles 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( , , )
  • 26. Properties C 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( , ) =
  • 27. Painful Details C Signal Processing Often called ^convolution ̄. Actually cross- correlation. Cross-Correlation (Original Orientation) Convolution (Flipped in x and y)
  • 28. 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 = *
  • 29. Questions? ? Nearly everything onwards is a convolution. ? This is important to get right.
  • 30. Smoothing With A Box Intuition: if filter touches it, it gets a contribution. Input Box Filter
  • 31. Solution C Weighted Combination Intuition: weight contributions according to closeness to center. ???????? 『1 ???????? 『exp ? (? ?2 + ?2 2 ? 2 ) What¨s this?
  • 32. Recognize the Filter? ???????? 『 1 2? ? 2 exp? (? ? 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
  • 33. Smoothing With A Box & Gauss Still have some speckles, but it¨s not a big box Input Box Filter Gauss. Filter
  • 34. 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
  • 36. Applying Gaussian Filters Input Image (no filter)
  • 41. 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!
  • 42. Runtime Complexity for ImageY in range(N): for ImageX in range(N): for FilterY in range(M): for FilterX in range(M): ´ Time: O(N2 M2 ) 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
  • 43. 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
  • 44. Separability ???????? 『 1 2? ? 2 exp? (? ? 2 +? 2 2 ? 2 ) ???????? 『 1 〔2? ? exp(? ? 2 2 ? 2 ) 1 〔2 ? ? exp ?(? ? 2 2 ? 2 ) ★
  • 45. Separability ? = 1D Gaussian 1D Gaussian = 2D Gaussian ? Image 2D Gauss = Image (1D Gauss 1D Gauss ) ? ? ? = (Image 1D Gauss) 1D Gauss ? ?
  • 46. 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): 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?
  • 47. Why Gaussian? Gaussian filtering removes parts of the signal above a certain frequency. Often noise is high frequency and signal is low frequency.
  • 50. Why Does This Fail? 0.1 0.8 0.1 Filter 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?
  • 51. 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
  • 54. Is Median Filtering Linear? Example from (I believe): Kristen Grauman [ 1 1 1 1 1 2 2 2 2] [ 0 0 0 0 1 0 0 0 0] + [ 1 1 1 1 2 2 2 2 2] = Median Filter 1 0 2 + =
  • 55. Some Examples of Filtering
  • 56. Filtering C Sharpening - Image Smoothed = Details
  • 57. Filtering C Sharpening +α Image Details = ^Sharpened ̄ α=1
  • 58. Filtering C Sharpening = +α Image Details ^Sharpened ̄ α=0
  • 59. Filtering C Sharpening = +α Image Details ^Sharpened ̄ α=2
  • 60. Filtering C Sharpening = +α Image Details ^Sharpened ̄ α=0
  • 61. Filtering C Extreme Sharpening = +α Image Details ^Sharpened ̄ α=10
  • 62. Filtering -1 0 1 Dx Dy -1 0 1 T What¨s this Filter?
  • 64. Filtering C Counting ? = r=10 Pixels Disk ??? How many ^on ̄ pixels have 10+ neighbors within 10 pixels?
  • 65. Filtering C Counting How many ^on ̄ pixels have 10+ neighbors within 10 pixels? x = Pixels Answer Density
  • 66. Filtering C Missing Data Oh no! Missing data! (and we know where) Common with many non-normal cameras (e.g., depth cameras)
  • 67. Filtering C Missing Data Binary Mask Image ? ? Per-element /
  • 68. Filtering C Missing Data Binary Mask Image Per-element /
  • 69. Filtering C Missing Data Before
  • 70. Filtering C Missing Data After
  • 71. Filtering C Missing Data After (without missing data)