Lecture 4: Intro to local features and
Harris corner detection
CSCI 455: Intro to Computer Vision
Acknowledgement
Many of the following slides are modified from the
excellent class notes of similar courses offered in
other schools by Prof Yung-Yu Chuang, Fredo
Durand, Alexei Efros, William Freeman, James Hays,
Svetlana Lazebnik, Andrej Karpathy, Fei-Fei Li,
Srinivasa Narasimhan, Silvio Savarese, Steve Seitz,
Richard Szeliski, Noah Snavely and Li Zhang. The
instructor is extremely thankful to the researchers
for making their notes available online. Please feel
free to use and modify any of the slides, but
acknowledge the original sources where
appropriate.
Reading
• Szeliski: 4.1
Last time
• Sampling & interpolation
• Key points:
– Downsampling an image can cause aliasing.
Better is to blur (“pre-filter”) to remote high
frequencies then downsample
– If you repeatedly blur and downsample by 2x, you
get a Gaussian pyramid
– Upsampling an image requires interpolation. This
can be posed as convolution with a
“reconstruction kernel”
Image interpolation
Nearest-neighbor interpolation Bilinear interpolation Bicubic interpolation
Original image: x 10
Image interpolation
Also used for resampling
Raster-to-vector graphics
Depixelating Pixel Art
Modern methods
From Romano, et al: RAISR: Rapid and Accurate Image Super Resolution,
https://arxiv.org/abs/1606.01299
Questions?
Feature extraction: Corners and blobs
Motivation: Automatic panoramas
Credit: Matt Brown
http://gigapan.com/
GigaPan
Also see Google Zoom Views:
https://www.google.com/culturalinstitute/beta/project/gigapixels
Motivation: Automatic panoramas
“Planet Detroit” by paulhitz
Polar panoramas
“Like a Butterfly” by Manu
Why extract features?
• Motivation: panorama stitching
– We have two images – how do we combine them?
Why extract features?
• Motivation: panorama stitching
– We have two images – how do we combine them?
Step 1: extract features
Step 2: match features
Why extract features?
• Motivation: panorama stitching
– We have two images – how do we combine them?
Step 1: extract features
Step 2: match features
Step 3: align images
Application: Visual SLAM
• (aka Simultaneous Localization and Mapping)
Image matching
by Diva Sian
by swashford
Harder case
by Diva Sian by scgbt
Harder still?
NASA Mars Rover images
with SIFT feature matches
Answer below (look for tiny colored squares…)
Feature Matching
Feature Matching
Invariant local features
Find features that are invariant to transformations
– geometric invariance: translation, rotation, scale
– photometric invariance: brightness, exposure, …
Feature Descriptors
Advantages of local features
Locality
– features are local, so robust to occlusion and clutter
Quantity
– hundreds or thousands in a single image
Distinctiveness:
– can differentiate a large database of objects
Efficiency
– real-time performance achievable
More motivation…
Feature points are used for:
– Image alignment
• (e.g., mosaics)
– 3D reconstruction
– Motion tracking
• (e.g. for AR)
– Object recognition
– Image retrieval
– Robot navigation
– … other
What makes a good feature?
Snoop demo
Approach
1. Feature detection: find it
2. Feature descriptor: represent it
3. Feature matching: match it
Feature tracking: track it, when motion
Local features: main components
1) Detection: Identify the interest
points
2) Description: Extract vector
feature descriptor surrounding
each interest point.
3) Matching: Determine
correspondence between
descriptors in two views
],,[ )1()1(
11 dxx x
],,[ )2()2(
12 dxx x
Kristen Grauman
Snoop demo
What makes a good feature?
Want uniqueness
Look for image regions that are unusual
– Lead to unambiguous matches in other images
How to define “unusual”?
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
Local measures of uniqueness
“flat” region:
no change in all
directions
“edge”:
no change along the
edge direction
“corner”:
significant change in
all directions
• How does the window change when you shift it?
• Shifting the window in any direction causes a big
change
Credit: S. Seitz, D. Frolova, D. Simakov
Consider shifting the window W by (u,v)
• how do the pixels in W change?
• compare each pixel before and after by
summing up the squared differences (SSD)
• this defines an SSD “error” E(u,v):
• We are happy if this error is high
• Slow to compute exactly for each pixel
and each offset (u,v)
Harris corner detection: the math
W
(u,v)
Taylor Series expansion of I:
If the motion (u,v) is small, then first order approximation is good
Plugging this into the formula on the previous slide…
Small motion assumption
Feature detection: the math
Consider shifting the window W by (u,v)
• define an SSD “error” E(u,v):
W
Corner detection: the math
Consider shifting the window W by (u,v)
• define an SSD “error” E(u,v):
W
(u,v)
Corner detection: the math
Consider shifting the window W by (u,v)
• define an SSD “error” E(u,v):
• Thus, E(u,v) is locally approximated as a quadratic error function
W
(u,v)
The surface E(u,v) is locally approximated by a quadratic form.
The second moment matrix
Let’s try to understand its shape.
Horizontal edge:
u
v
E(u,v)
Vertical edge:
u
v
E(u,v)
General case
We can visualize H as an ellipse with axis lengths
determined by the eigenvalues of H and orientation
determined by the eigenvectors of H
direction of the
slowest change
direction of the
fastest change
(max)-1/2
(min)-1/2
const][ 





v
u
Hvu
Ellipse equation:
max, min : eigenvalues of H
The surface E(u,v) is locally approximated by a quadratic form.
The second moment matrix







v
u
MvuvuE ][),(








  2
2
yyx
yxx
III
III
M
Feature detection: the math
This can be rewritten:
For the example above
• You can move the center of the green window to anywhere on the blue
unit circle
• Which directions will result in the largest and smallest E values?
• We can find these directions by looking at the eigenvectors of H
Feature detection: the math
This can be rewritten:
The surface E(u,v) is locally approximated by a quadratic form. Let’s try to
understand its shape.
Interpreting the second moment matrix







v
u
HvuvuE ][),(








  2
2
yyx
yxx
III
III
H
Quick eigenvalue/eigenvector review
The eigenvectors of a matrix A are the vectors x that satisfy:
The scalar  is the eigenvalue corresponding to x
– The eigenvalues are found by solving:
– In our case, A = H is a 2x2 matrix, so we have
– The solution:
Once you know , you find x by solving
Corner detection: the math
Eigenvalues and eigenvectors of H
• Define shift directions with the smallest and largest change in error
• xmax = direction of largest increase in E
• max = amount of increase in direction xmax
• xmin = direction of smallest increase in E
• min = amount of increase in direction xmin
xmin
xmax
Corner detection: the math
How are max, xmax, min, and xmin relevant for feature detection?
• What’s our feature scoring function?
Corner detection: the math
How are max, xmax, min, and xmin relevant for feature detection?
• What’s our feature scoring function?
Want E(u,v) to be large for small shifts in all directions
• 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 H
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 detection 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
Corner detection 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 detection
• 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”
• Lots of other detectors, this is one of the most popular
The Harris operator
Harris
operator
Harris detector example
f value (red high, blue low)
Threshold (f > value)
Find local maxima of f
Harris features (in red)
Weighting the derivatives
• In practice, using a simple window W doesn’t
work too well
• Instead, we’ll weight each derivative value
based on its distance from the center pixel
Harris Detector [Harris88]
• Second moment matrix









)()(
)()(
)(),( 2
2
DyDyx
DyxDx
IDI
III
III
g



63
1. Image
derivatives
2. Square of
derivatives
3. Gaussian
filter g(I)
Ix Iy
Ix
2 Iy
2 IxIy
g(Ix
2) g(Iy
2) g(IxIy)
4. Cornerness function – both eigenvalues are strong
har5. Non-maxima suppression
1 2
1 2
det
trace
M
M
 
 

 
(optionally, blur first)
Harris Corners – Why so complicated?
• Can’t we just check for regions with lots of
gradients in the x and y directions?
– No! A diagonal line would satisfy that criteria
Current
Window
Questions?

Computer Vision harris

  • 1.
    Lecture 4: Introto local features and Harris corner detection CSCI 455: Intro to Computer Vision
  • 2.
    Acknowledgement Many of thefollowing slides are modified from the excellent class notes of similar courses offered in other schools by Prof Yung-Yu Chuang, Fredo Durand, Alexei Efros, William Freeman, James Hays, Svetlana Lazebnik, Andrej Karpathy, Fei-Fei Li, Srinivasa Narasimhan, Silvio Savarese, Steve Seitz, Richard Szeliski, Noah Snavely and Li Zhang. The instructor is extremely thankful to the researchers for making their notes available online. Please feel free to use and modify any of the slides, but acknowledge the original sources where appropriate.
  • 3.
  • 4.
    Last time • Sampling& interpolation • Key points: – Downsampling an image can cause aliasing. Better is to blur (“pre-filter”) to remote high frequencies then downsample – If you repeatedly blur and downsample by 2x, you get a Gaussian pyramid – Upsampling an image requires interpolation. This can be posed as convolution with a “reconstruction kernel”
  • 5.
    Image interpolation Nearest-neighbor interpolationBilinear interpolation Bicubic interpolation Original image: x 10
  • 6.
  • 7.
  • 8.
  • 9.
    Modern methods From Romano,et al: RAISR: Rapid and Accurate Image Super Resolution, https://arxiv.org/abs/1606.01299
  • 10.
  • 11.
  • 12.
  • 13.
    http://gigapan.com/ GigaPan Also see GoogleZoom Views: https://www.google.com/culturalinstitute/beta/project/gigapixels Motivation: Automatic panoramas
  • 14.
    “Planet Detroit” bypaulhitz Polar panoramas “Like a Butterfly” by Manu
  • 15.
    Why extract features? •Motivation: panorama stitching – We have two images – how do we combine them?
  • 16.
    Why extract features? •Motivation: panorama stitching – We have two images – how do we combine them? Step 1: extract features Step 2: match features
  • 17.
    Why extract features? •Motivation: panorama stitching – We have two images – how do we combine them? Step 1: extract features Step 2: match features Step 3: align images
  • 18.
    Application: Visual SLAM •(aka Simultaneous Localization and Mapping)
  • 19.
    Image matching by DivaSian by swashford
  • 20.
    Harder case by DivaSian by scgbt
  • 21.
  • 22.
    NASA Mars Roverimages with SIFT feature matches Answer below (look for tiny colored squares…)
  • 23.
  • 24.
  • 25.
    Invariant local features Findfeatures that are invariant to transformations – geometric invariance: translation, rotation, scale – photometric invariance: brightness, exposure, … Feature Descriptors
  • 26.
    Advantages of localfeatures Locality – features are local, so robust to occlusion and clutter Quantity – hundreds or thousands in a single image Distinctiveness: – can differentiate a large database of objects Efficiency – real-time performance achievable
  • 27.
    More motivation… Feature pointsare used for: – Image alignment • (e.g., mosaics) – 3D reconstruction – Motion tracking • (e.g. for AR) – Object recognition – Image retrieval – Robot navigation – … other
  • 28.
    What makes agood feature? Snoop demo
  • 29.
    Approach 1. Feature detection:find it 2. Feature descriptor: represent it 3. Feature matching: match it Feature tracking: track it, when motion
  • 30.
    Local features: maincomponents 1) Detection: Identify the interest points 2) Description: Extract vector feature descriptor surrounding each interest point. 3) Matching: Determine correspondence between descriptors in two views ],,[ )1()1( 11 dxx x ],,[ )2()2( 12 dxx x Kristen Grauman
  • 31.
    Snoop demo What makesa good feature?
  • 32.
    Want uniqueness Look forimage regions that are unusual – Lead to unambiguous matches in other images How to define “unusual”?
  • 33.
    Local measures ofuniqueness 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
  • 34.
    Local measures ofuniqueness “flat” region: no change in all directions “edge”: no change along the edge direction “corner”: significant change in all directions • How does the window change when you shift it? • Shifting the window in any direction causes a big change Credit: S. Seitz, D. Frolova, D. Simakov
  • 35.
    Consider shifting thewindow W by (u,v) • how do the pixels in W change? • compare each pixel before and after by summing up the squared differences (SSD) • this defines an SSD “error” E(u,v): • We are happy if this error is high • Slow to compute exactly for each pixel and each offset (u,v) Harris corner detection: the math W (u,v)
  • 36.
    Taylor Series expansionof I: If the motion (u,v) is small, then first order approximation is good Plugging this into the formula on the previous slide… Small motion assumption
  • 37.
    Feature detection: themath Consider shifting the window W by (u,v) • define an SSD “error” E(u,v): W
  • 38.
    Corner detection: themath Consider shifting the window W by (u,v) • define an SSD “error” E(u,v): W (u,v)
  • 39.
    Corner detection: themath Consider shifting the window W by (u,v) • define an SSD “error” E(u,v): • Thus, E(u,v) is locally approximated as a quadratic error function W (u,v)
  • 40.
    The surface E(u,v)is locally approximated by a quadratic form. The second moment matrix Let’s try to understand its shape.
  • 41.
  • 42.
  • 43.
    General case We canvisualize H as an ellipse with axis lengths determined by the eigenvalues of H and orientation determined by the eigenvectors of H direction of the slowest change direction of the fastest change (max)-1/2 (min)-1/2 const][       v u Hvu Ellipse equation: max, min : eigenvalues of H
  • 44.
    The surface E(u,v)is locally approximated by a quadratic form. The second moment matrix        v u MvuvuE ][),(           2 2 yyx yxx III III M
  • 45.
    Feature detection: themath This can be rewritten: For the example above • You can move the center of the green window to anywhere on the blue unit circle • Which directions will result in the largest and smallest E values? • We can find these directions by looking at the eigenvectors of H
  • 46.
    Feature detection: themath This can be rewritten:
  • 47.
    The surface E(u,v)is locally approximated by a quadratic form. Let’s try to understand its shape. Interpreting the second moment matrix        v u HvuvuE ][),(           2 2 yyx yxx III III H
  • 48.
    Quick eigenvalue/eigenvector review Theeigenvectors of a matrix A are the vectors x that satisfy: The scalar  is the eigenvalue corresponding to x – The eigenvalues are found by solving: – In our case, A = H is a 2x2 matrix, so we have – The solution: Once you know , you find x by solving
  • 49.
    Corner detection: themath Eigenvalues and eigenvectors of H • Define shift directions with the smallest and largest change in error • xmax = direction of largest increase in E • max = amount of increase in direction xmax • xmin = direction of smallest increase in E • min = amount of increase in direction xmin xmin xmax
  • 50.
    Corner detection: themath How are max, xmax, min, and xmin relevant for feature detection? • What’s our feature scoring function?
  • 51.
    Corner detection: themath How are max, xmax, min, and xmin relevant for feature detection? • What’s our feature scoring function? Want E(u,v) to be large for small shifts in all directions • 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 H
  • 52.
    Interpreting the eigenvalues 1 2 “Corner” 1and 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:
  • 53.
    Corner detection summary Here’swhat 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
  • 54.
    Corner detection summary Here’swhat 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
  • 55.
    The Harris operator minis a variant of the “Harris operator” for feature detection • 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” • Lots of other detectors, this is one of the most popular
  • 56.
  • 57.
  • 58.
    f value (redhigh, blue low)
  • 59.
  • 60.
  • 61.
  • 62.
    Weighting the derivatives •In practice, using a simple window W doesn’t work too well • Instead, we’ll weight each derivative value based on its distance from the center pixel
  • 63.
    Harris Detector [Harris88] •Second moment matrix          )()( )()( )(),( 2 2 DyDyx DyxDx IDI III III g    63 1. Image derivatives 2. Square of derivatives 3. Gaussian filter g(I) Ix Iy Ix 2 Iy 2 IxIy g(Ix 2) g(Iy 2) g(IxIy) 4. Cornerness function – both eigenvalues are strong har5. Non-maxima suppression 1 2 1 2 det trace M M        (optionally, blur first)
  • 64.
    Harris Corners –Why so complicated? • Can’t we just check for regions with lots of gradients in the x and y directions? – No! A diagonal line would satisfy that criteria Current Window
  • 65.