Theory
Local features are small, distinctive image regions that can be found again in another image of the same scene, even after the camera moves, zooms or rotates. A feature pipeline has three steps: detect keypoints, describe the patch around each one with a vector, and match vectors between images.
SURF (Speeded-Up Robust Features, Bay, Tuytelaars and Van Gool, 2006) was designed as a faster alternative to SIFT with similar robustness.
Integral image
The integral image stores, at every pixel, the sum of all pixels above and to the left of it:
I_Σ(x, y) = Σ I(i, j) for i ≤ x and j ≤ y
With it, the sum over any rectangle takes four lookups, whatever its size. SURF's speed comes from this.
Fast-Hessian detector
Blob-like keypoints are found where the determinant of the Hessian matrix is a local maximum:
SURF approximates the Gaussian second derivatives with box filters (9×9 for σ = 1.2) evaluated on the integral image, and uses det(H) ≈ Dxx·Dyy − (0.9·Dxy)². Instead of shrinking the image, it builds scale space by growing the filter (9, 15, 21, 27, and so on), each at constant cost. A point is a keypoint if its response beats all 26 neighbours in a 3×3×3 neighbourhood across position and scale, and exceeds the Hessian threshold.
Orientation and descriptor
For rotation invariance, Haar wavelet responses in x and y are computed in a circle of radius 6s around the keypoint, and a 60° sliding window finds the dominant direction. The descriptor takes a 20s square aligned to that direction, splits it into 4×4 subregions, and stores Σdx, Σdy, Σ|dx| and Σ|dy| for each: 64 numbers, normalized to unit length for contrast invariance.
Matching
Descriptors are compared by Euclidean distance. Lowe's ratio test keeps a match only if the nearest neighbour is clearly closer than the second nearest (ratio below about 0.7 to 0.8). With at least four good matches, RANSAC estimates the homography that maps one view to the other while rejecting outliers.
SURF is patented and sits in OpenCV's non-free contrib module, so it is implemented here directly from the paper. ORB (FAST keypoints with rotated BRIEF binary descriptors, matched by Hamming distance) is a free, faster alternative and is shown for comparison.
Workbench
Detect keypoints on one image, or match an object between two views.
Input
Input preview
Parameters
Readout
- n/a
- n/a
Export
Procedure
- Load the Calibration board sample and compute its integral image. Verify a rectangle sum by hand from four lookups.
- Detect SURF keypoints with Hessian thresholds of 100, 400 and 1000. Record how many keypoints each produces.
- Display keypoints as circles sized by scale with a line showing orientation.
- Rotate and scale the image, detect again, and check whether the same keypoints are found.
- Match descriptors between the original and the transformed image with ratio thresholds of 0.6 and 0.8.
- Estimate the homography with RANSAC and draw the projected outline of the object.
- Repeat steps 2 to 6 with ORB and compare keypoint count, match quality and run time.
- Save figures of the keypoints and the matches.
Results and Discussion
To be completed
Add your figures and observations: how the Hessian threshold affected the keypoint count, how well matches survived rotation and scaling, how many were inliers after RANSAC, and how SURF compared with ORB.
Conclusion
To be completed
Summarize what makes SURF features scale and rotation invariant, in your own words.