lec10 features2 web - Cornell UniversityFinding Corners • Key property: in the region around a...
Transcript of lec10 features2 web - Cornell UniversityFinding Corners • Key property: in the region around a...
Lecture 10: Harris Corner Detector
CS4670/5670: Computer Vision Kavita Bala
Announcements
• HW 1 will be out early next week
• Quiz 1 graded
Finding Corners
• Key property: in the region around a corner, image gradient has two or more dominant directions
• Corners are repeatable and distinctive C.Harris and M.Stephens, 1988. "A Combined Corner and Edge Detector.“ Proceedings of the 4th Alvey Vision Conference: pages 147-‐-‐151.
Feature extraction: Corners 9300 Harris Corners Pkwy, Charlotte, NC
Slides from Rick Szeliski, Svetlana Lazebnik, and Kristin Grauman
Local measures of uniqueness
Suppose we only consider a small window of pixels – What defines whether a feature is a good or bad candidate?
Credit: S. Seitz, D. Frolova, D. Simakov
Corner Detection: Basic Idea • We should easily recognize the point by looking
through a small window • Shifting a window in any direction should give a
large change in intensity
“edge”:no change along the edge direction
“corner”:significant change in all directions
“flat” region:no change in all directions
Source: A. Efros
Consider shiZing the window W by (u,v) • how do the pixels in W change? • compare each pixel before and aZer by summing up the squared differences (SSD)
• this defines an SSD “error” E(u,v):
Harris corner detec`on: the math
W
Corner Detection: Mathematics
[ ]2,
( , ) ( , ) ( , ) ( , )x y
E u v w x y I x u y v I x y= + + −∑
We want to find out how this function behaves for small shifts
Change in appearance of window for the shift [u,v]:
E(u, v)
Taylor Series expansion of I: If the mo`on (u,v) is small, then first order approxima`on is good Plugging this into the formula on the previous slide…
Small mo`on assump`on
Corner detec`on: the math
Consider shiZing the window W by (u,v) • define an SSD “error” E(u,v):
W
Corner detec`on: the math
Consider shiZing the window W by (u,v) • define an SSD “error” E(u,v):
W
• Thus, E(u,v) is locally approximated as a quadra`c error func`on
The surface E(u,v) is locally approximated by a quadratic form. Let’s try to understand its shape.
Interpreting the second moment matrix
⎥⎦
⎤⎢⎣
⎡≈
vu
MvuvuE ][),(
∑⎥⎥⎦
⎤
⎢⎢⎣
⎡=
yx yyx
yxx
IIIIII
yxwM,
2
2
),(
The surface E(u,v) is locally approximated by a quadra`c form.
The second moment matrix
Let’s try to understand its shape.
Horizontal edge:
u v
E(u,v)
M M
M
Ver`cal edge:
u v
E(u,v)
M
M
Consider a horizontal “slice” of E(u, v):
Interpreting the second moment matrix
This is the equation of an ellipse.
const][ =⎥⎦
⎤⎢⎣
⎡
vu
Mvu
Quick eigenvalue/eigenvector review The eigenvectors of a matrix A are the vectors x that sa`sfy:
The scalar λ is the eigenvalue corresponding to x
– The eigenvalues are found by solving:
– Say, A = H is a 2x2 matrix, so we have
– The solu`on:
Once you know λ, you find x by solving
Consider a horizontal “slice” of E(u, v):
Interpreting the second moment matrix
This is the equation of an ellipse.
RRM ⎥⎦
⎤⎢⎣
⎡= −
2
11
00λ
λ
The axis lengths of the ellipse are determined by the eigenvalues and the orientation is determined by R
direction of the slowest change
direction of the fastest change
(λmax) -1/2
(λmin)-1/2
const][ =⎥⎦
⎤⎢⎣
⎡
vu
Mvu
Diagonalization of M:
Corner detec`on: the math
Eigenvalues and eigenvectors of M • Define shiZ direc`ons with the smallest and largest change in error • xmax = direc`on of largest increase in E • λmax = amount of increase in direc`on xmax
• xmin = direc`on of smallest increase in E • λmin = amount of increase in direc`on xmin
xmin
xmax
M
M
Interpreting the eigenvalues
λ1
λ2
“Corner” λ1 and λ2 are large, λ1 ~ λ2; E increases in all directions
λ1 and λ2 are small; E is almost constant in all directions
“Edge” λ1 >> λ2
“Edge” λ2 >> λ1
“Flat” region
Classification of image points using eigenvalues of M:
Corner detec`on: the math How are λmax, xmax, λmin, and xmin relevant for feature detec`on?
• Need a feature scoring func`on
Corner detec`on: the math How are λmax, xmax, λmin, and xmin relevant for feature detec`on?
• Need a feature scoring func`on Want E(u,v) to be large for small shiZs in all direc`ons
• the minimum of E(u,v) should be large, over all unit vectors [u v] • this minimum is given by the smaller eigenvalue (λmin) of M
Corner detec`on summary Here’s what you do
• Compute the gradient at each point in the image • Create the M matrix from the entries in the gradient • Compute the eigenvalues • Find points with large response (λmin > threshold) • Choose those points where λmin is a local maximum as features
Corner detec`on summary Here’s what you do
• Compute the gradient at each point in the image • Create the H matrix from the entries in the gradient • Compute the eigenvalues. • Find points with large response (λmin > threshold) • Choose those points where λmin is a local maximum as features
The Harris operator
λmin is a variant of the “Harris operator” for feature detec`on
• The trace is the sum of the diagonals, i.e., trace(H) = h11 + h22 • Very similar to λmin but less expensive (no square root) • Called the “Harris Corner Detector” or “Harris Operator”
• Actually the Noble variant of the Harris Corner Detector • Lots of other detectors, this is one of the most popular
Corner response function
“Corner” R > 0
“Edge” R < 0
“Edge” R < 0
“Flat” region
|R| small
22121
2 )()(trace)det( λλαλλα +−=−= MMR
α: constant (0.04 to 0.15)
The Harris operator
Harris operator
Harris Detector [Harris88]
• Second moment matrix
⎥⎥⎦
⎤
⎢⎢⎣
⎡∗=
)()()()(
)(),( 2
2
DyDyx
DyxDxIDI III
IIIg
σσ
σσσσσµ
28
1. Image derivatives
2. Square of derivatives
3. Gaussian filter g(σI)
Ix Iy
Ix2 Iy2 IxIy
g(Ix2) g(Iy2) g(IxIy)
222222 )]()([)]([)()( yxyxyx IgIgIIgIgIg +−− α
=−= ])),([trace()],(det[ 2DIDIhar σσµασσµ
4. Cornerness function – both eigenvalues are strong
har 5. Non-maxima suppression
1 2
1 2
dettrace
MM
λ λ
λ λ
=
= +
(optionally, blur first)
Weigh`ng the deriva`ves
• In prac`ce, using a simple window W doesn’t work too well
• Instead, we’ll weight each deriva`ve value based on its distance from the center pixel
Harris detector example
f value (red high, blue low)
Threshold (f > value)
Find local maxima of f
Harris features (in red)