Harris Corners
16-385 Computer Vision (Kris Kitani)
Carnegie Mellon University
Harris Corners 16-385 Computer Vision (Kris Kitani) Carnegie Mellon - - PowerPoint PPT Presentation
Harris Corners 16-385 Computer Vision (Kris Kitani) Carnegie Mellon University How do you find a corner? [Moravec 1980] Easily recognized by looking through a small window Shifting the window should give large change in intensity Easily
16-385 Computer Vision (Kris Kitani)
Carnegie Mellon University
Easily recognized by looking through a small window Shifting the window should give large change in intensity
[Moravec 1980]
“edge”: no change along the edge direction “corner”: significant change in all directions “flat” region: no change in all directions
Easily recognized by looking through a small window Shifting the window should give large change in intensity
[Moravec 1980]
Design a program to detect corners
(hint: use image gradients)
1.Compute image gradients over small region 2.Subtract mean from each image gradient 3.Compute the covariance matrix 4.Compute eigenvectors and eigenvalues 5.Use threshold on eigenvalues to detect corners
Ix = ∂I ∂x
Iy = ∂I ∂y
2 4 P
p∈P
IxIx P
p∈P
IxIy P
p∈P
IyIx P
p∈P
IyIy 3 5
(not just a single pixel)
(not just a single pixel)
Ix = ∂I ∂x
Iy = ∂I ∂y
array of x gradients array of y gradients
image X derivative Y derivative
Ix = ∂I ∂x Ix = ∂I ∂x Ix = ∂I ∂x
Iy = ∂I ∂y Iy = ∂I ∂y Iy = ∂I ∂y
What does the distribution tell you about the region?
Ix = ∂I ∂x Ix = ∂I ∂x Ix = ∂I ∂x
Iy = ∂I ∂y Iy = ∂I ∂y Iy = ∂I ∂y
distribution reveals edge orientation and magnitude
Ix = ∂I ∂x Ix = ∂I ∂x Ix = ∂I ∂x
Iy = ∂I ∂y Iy = ∂I ∂y Iy = ∂I ∂y
How do you quantify orientation and magnitude?
plot intensities constant intensity gradient intensities along the line
plot intensities constant intensity gradient
Ix = ∂I ∂x
Iy = ∂I ∂y
intensities along the line plot of image gradients subtract mean
plot intensities constant intensity gradient
Ix = ∂I ∂x
Iy = ∂I ∂y
intensities along the line plot of image gradients
Ix = ∂I ∂x
Iy = ∂I ∂y
data is centered (‘DC’ offset is removed) subtract mean
Where does this covariance matrix come from?
2 4 P
p∈P
IxIx P
p∈P
IxIy P
p∈P
IyIx P
p∈P
IyIy 3 5
Ix = ∂I ∂x Iy = ∂I ∂y
array of x gradients array of y gradients
P
p∈P
IxIy P
Change of intensity for the shift [u,v]:
Intensity Shifted intensity Window function
Window function w(x,y) = Gaussian 1 in window, 0 outside
Error function Some mathematical background…
Change of intensity for the shift [u,v]:
Second-order Taylor expansion of E(u,v) about (0,0) (bilinear approximation for small shifts):
first derivative second derivative
For small shifts [u,v] we have a ‘bilinear approximation’: where M is a 2×2 matrix computed from image derivatives:
Change in appearance for a shift [u,v]
M
‘second moment’ matrix ‘structure tensor’
2 4 P
p∈P
IxIx P
p∈P
IxIy P
p∈P
IyIx P
p∈P
IyIy 3 5
By computing the gradient covariance matrix… we are fitting a quadratic to the gradients over a small image region
The surface E(u,v) is locally approximated by a quadratic form
Which error surface indicates a good image feature? What kind of image patch do these surfaces represent?
flat edge ‘line’ corner ‘dot’
eigenvector eigenvalue
Me = λe
(M − λI)e = 0
(returns a polynomial)
eigenvector eigenvalue
Me = λe
(M − λI)e = 0
(returns a polynomial)
eigenvector eigenvalue
(returns eigenvalues) det(M − λI) = 0
Me = λe
(M − λI)e = 0
(returns a polynomial)
eigenvector eigenvalue
(returns eigenvalues) det(M − λI) = 0
Me = λe
(M − λI)e = 0
(returns eigenvectors)
(M − λI)e = 0
Since M is symmetric, we have
We can visualize M as an ellipse with axis lengths determined by the eigenvalues and orientation determined by R
direction of the slowest change direction of the fastest change
(λmax)-1/2 (λmin)-1/2
Ellipse equation:
λ1 λ2 λ2 >> λ1 λ1 >> λ2
λ1 ∼ 0 λ2 ∼ 0
What kind of image patch does each region represent?
‘horizontal’ edge ‘vertical’ edge flat corner
λ1 λ2 λ2 >> λ1 λ1 >> λ2
λ1 ~ λ2
‘horizontal’ edge ‘vertical’ edge flat corner
λ1 λ2 λ2 >> λ1 λ1 >> λ2
λ1 ~ λ2
flat
λ1 λ2
Think of a function to score ‘cornerness’
flat
λ1 λ2
Think of a function to score ‘cornerness’
strong corner
flat corner
λ1 λ2
R = min(λ1, λ2)
Use the smallest eigenvalue as the response function
flat corner
λ1 λ2
R = λ1λ2 − κ(λ1 + λ2)2
Eigenvalues need to be bigger than one.
Can compute this more efficiently…
flat corner
λ1 λ2 R < 0 R > 0 R < 0
R ⌧ 0
R = det(M) − κtrace2(M)
R = det(M) − κtrace2(M)
R = det(M) trace(M) +
Harris & Stephens (1988) Kanade & Tomasi (1994) Nobel (1998)
each pixel
C.Harris and M.Stephens. “A Combined Corner and Edge Detector.”1988.
I G I
x x
∗ =
σ
I G I
y y
∗ =
σ x x x
I I I ⋅ =
2
y y y
I I I ⋅ =
2
y x xy
I I I ⋅ =
2 2
' x x
I G S ∗ =
σ
2 2
' y y
I G S ∗ =
σ xy xy
I G S ∗ =
' σ
C.Harris and M.Stephens. “A Combined Corner and Edge Detector.”1988.
4. Define the matrix at each pixel 5. Compute the response of the detector at each pixel 6. Threshold on value of R; compute non-max suppression.
! ! " # $ $ % & = ) , ( ) , ( ) , ( ) , ( ) , (
2 2
y x S y x S y x S y x S y x M
y xy xy x
2
trace det M k M R − =
Corner response
Thresholded corner response
Non-maximal suppression
Ellipse rotates but its shape (eigenvalues) remains the same Corner response R is invariant to image rotation
Partial invariance to affine intensity change
ü Only derivatives are used => invariance to intensity shift I → I + b ü Intensity scale: I → a I R
x (image coordinate) threshold
R
x (image coordinate)
The Harris detector not invariant to changes in …