Lecture, Convolution and Filtering
Lecture, Convolution and Filtering
∞
𝑓 𝑥 ∗ 𝑔 𝑥 = � 𝑓 𝑡 𝑔 𝑥 − 𝑡 𝑑𝑑
−∞
• One-dimensional Gaussian
1 𝑥2
− 2
𝐺1 𝑥 = 𝑒 2𝜎
2𝜋𝜎2
• Two-dimensional Gaussian
1 𝑥2 +𝑦2
−
𝐺2 𝑥 = 𝑒 2𝜎2
2𝜋𝜎2
Gaussian Filters
Gaussian Filters
Gaussian Filters
𝑖𝑚𝑚𝑚 𝑗𝑚𝑚𝑚
Out 𝑥, 𝑦 = � � 𝑓 𝑖, 𝑗 In(𝑥 − 𝑖, 𝑦 − 𝑗)
𝑖=𝑖𝑚𝑚𝑚 𝑗=𝑗𝑚𝑚𝑚
𝑖𝑚𝑚𝑚 𝑗𝑚𝑚𝑚
Out 𝑥, 𝑦 = � � 𝑓 𝑖, 𝑗 In(𝑥 − 𝑖, 𝑦 − 𝑗)
𝑖=𝑖𝑚𝑚𝑚 𝑗=𝑗𝑚𝑚𝑚
Source: K. Grauman
Computing Discrete Convolutions
𝑖𝑚𝑚𝑚 𝑗𝑚𝑚𝑚
Out 𝑥, 𝑦 = � � 𝑓 𝑖, 𝑗 In(𝑥 − 𝑖, 𝑦 − 𝑗)
𝑖=𝑖𝑚𝑚𝑚 𝑗=𝑗𝑚𝑚𝑚
F 𝑓 𝑥 ∗𝑔 𝑥 =F 𝑓 𝑥 F 𝑔 𝑥
Fourier Transform and Convolution
Amplitude
Amplitude
× =
Credit: K. Grauman
Median Filter
Credit: M. Hebert
Gaussian vs. Median filtering
3x3 5x5 7x7
Gaussian
Median
Edge Detection
depth discontinuity
illumination discontinuity
Credit: D. Lowe
What is an Edge?
Texture discontinuity
Formalizing Edge Detection
• Smooth
• Find derivative
• Find maxima
• Threshold
Canny Edge Detector
𝜕𝜕 𝜕𝜕
∇𝑓 𝑥, 𝑦 = ,
𝜕𝜕 𝜕𝜕
Canny Edge Detector
𝑑𝑑 𝑑 𝑑𝑑
∗𝑔= 𝑓∗𝑔 =𝑓∗
𝑑𝑑 𝑑𝑑 𝑑𝑑
• Nonmaximum suppression
– Eliminate all but local maxima in gradient magnitude
(sqrt of sum of squares of x and y components)
– At each pixel p look along direction of gradient:
if either neighbor is bigger, set p to zero
– In practice, quantize direction to
horizontal, vertical, and two diagonals
– Result: “thinned edge image”
Canny Edge Detector
• Roberts:
1 0 0 −1
0 −1 1 0
Second-Derivative-Based Edge Detectors
∇2𝐺1(𝑥, 𝜎)
2 �𝐺1 𝑥, 𝜎 2 −
𝐺1 𝑥, 𝜎/ 2 �
Problems with Laplacian Edge Detectors
Input images
Ground truth
Training data
Output
P. Dollar and L. Zitnick, Structured forests for fast edge detection, ICCV 2013