Lec01 Filter For Web
Lec01 Filter For Web
Noah Snavely
Digital Camera
255 255 255 255 255 255 255 255 255 255 255 255
255 255 255 20 0 255 255 255 255 255 255 255
=
255 255 255 75 75 75 255 255 255 255 255 255
255 255 96 127 145 175 255 255 255 255 255 255
255 255 127 145 175 175 175 255 255 255 255 255
255 255 127 145 200 200 175 175 95 255 255 255
255 255 127 145 200 200 175 175 95 47 255 255
255 255 127 145 145 175 127 127 95 47 255 255
255 255 255 255 255 255 255 255 255 255 255 255
255 255 255 255 255 255 255 255 255 255 255 255
f (x, y)
snoop
3D view
10 5 3 Some function
4 5 1 7
1 1 7
Local image data Modified image data
Source: L. Zhang
Linear filtering
• One simple version of filtering: linear filtering (cross-correlation,
convolution)
– Replace each pixel by a linear combination (a weighted sum) of its
neighbors
• The prescription for the linear combination is called the “kernel”
(or “mask”, “filter”)
10 5 3 0 0 0
4 6 1 0 0.5 0 8
1 1 8 0 1 0.5
Local image data kernel Modified image data
Source: L. Zhang
Cross-correlation
Let be the image, be the kernel (of size
2k+1 x 2k+1), and be the output image
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 10 20 30 30 30 20 10
=
0 0 0 90 90 90 90 90 0 0 0 20 40 60 60 60 40 20
*
1 1 1 0 0 0 90 90 90 90 90 0 0 0 30 60 90 90 90 60 30
0 0 0 90 90 90 90 90 0 0 0 30 50 80 80 90 60 30
1 1 1
0 0 0 90 0 90 90 90 0 0 0 30 50 80 80 90 60 30
1 1 1
0 0 0 90 90 90 90 90 0 0 0 20 30 50 50 60 40 20
0 0 0 0 0 0 0 0 0 0 10 20 30 30 30 30 20 10
0 0 90 0 0 0 0 0 0 0 10 10 10 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
Mean filtering/Moving
average
Mean filtering/Moving
average
Mean filtering/Moving
average
Mean filtering/Moving
average
Mean filtering/Moving
average
Mean filtering/Moving
average
Linear filters: examples
0 0 0
* 0
0
1
0
0
0
Original
Source: D. Lowe
What image operation does filtering with this
kernel perform?
([0 0 0; 0 1 0; 0 0 0])
=
0 0 0
* 0
0
1
0
0
0
Source: D. Lowe
Linear filters: examples
0 0 0
* 1
0
0
0
0
0
Original
Source: D. Lowe
What image operation does filtering with this
kernel perform? ([0 0 0; 1 0 0; 0 0 0])
=
0 0 0
* 1
0
0
0
0
0
Source: D. Lowe
Linear filters: examples
=
1 1 1
* 1
1
1
1
1
1
Source: D. Lowe
Linear filters: examples
=
0 0 0 1 1 1
-
* 0
0
2
0
0
0
1
1
1
1
1
1
Sharpening filter
Original
(accentuates edges)
Source: D. Lowe
Sharpening
Source: D. Lowe
Smoothing with box filter revisited
Source: D. Forsyth
Gaussian kernel
Source: C. Rasmussen
Gaussian filters
* =
– Convolving twice with Gaussian kernel of width
= convolving once with kernel of width
Source: K. Grauman
Sharpening revisited
• What does blurring take away?
– =
original smoothed (5x5) detail
(This “detail extraction” operation is also
Let’s add it back: called a high-pass filter)
+α =
original detail sharpened
Photo credit: https://www.flickr.com/photos/geezaweezer/16089096376/
Sharpen filter
+
blurred
image unit impulse
image
(identity kernel
with single 1 in
center, zeros
elsewhere)
unfiltered
filtered
“Optical” convolution
Camera shake
= *
Source: Fergus, et al. “Removing Camera Shake from a Single Photograph”, SIGGRAPH 2006
Source: https://www.diyphotography.net/diy_create_your_own_bokeh/
Filters: Thresholding
Linear filters
• Can thresholding be implemented with a linear filter?
Can thresholding be implemented
with a linear filter?