TL;DR
A local image feature is a small, distinctive patch of an image, described by a vector of numbers. An image is reduced to a few hundred or thousand such features, and two images are compared by matching their feature vectors rather than their pixels. The description is built so that it barely changes when the camera moves, zooms or rotates a little.
Where you'll see it: panorama stitching, 3D reconstruction from photo collections, and visual localisation, where a robot matches what it sees against a stored map.
Intuition
Imagine trying to find the same building in two holiday photos taken from different spots. Comparing pixel by pixel fails at once, because the building moved in the frame. A human does it by looking for landmarks: a particular window corner, the top of a tower. Those landmarks are easy to recognise again because they look different from their surroundings in every direction.
That is the whole idea. A good feature point is one you can find again. A flat patch of sky is useless, because it looks the same everywhere and you cannot say where you are inside it. A straight edge is only half useful, because you can slide along it and it looks the same. A corner, a blob or a dot is distinctive, since moving in any direction changes what you see. Once you have a point you can describe its neighbourhood with a vector, and the description is what you compare.
The pipeline has four stages. Detection finds candidate points that are stable under change. Localisation fixes their position and scale. Orientation assigns a direction so the description can be rotated into a standard frame. Description turns the neighbourhood into a vector.
flowchart LR I[Image] --> S[Scale space<br/>blur at many scales] S --> D[Detect extrema<br/>in differences of Gaussians] D --> O[Assign orientation<br/>from local gradients] O --> V[Descriptor vector<br/>histogram of gradients] V --> M[Match between images]
The math
Gradients and the structure tensor
Let be the image intensity. Its gradient is , where and are the Partial Derivatives along the two image axes, usually estimated by Convolution with small difference kernels. A corner is a place where the gradient points in at least two clearly different directions within a small window.
Harris and Stephens (1988) made this precise. For a window around a point, form the structure tensor, where the window is weighted by a Gaussian (Normal) Distribution so that pixels near the centre count more:
is a symmetric matrix, so it has two eigenvalues . They describe the gradient structure in the window. If both are small, the patch is flat. If one is large and the other is small, the patch is an edge, since all gradients point the same way. If both are large, the gradients point in many directions and the patch is a corner. The corner response avoids computing eigenvalues directly:
with a constant, commonly around 0.04 to 0.06. Points with large positive are corners. Negative marks an edge.
Scale space and difference of Gaussians
A corner in one image may be a blob at a different size in another, so a single window size is not enough. Lowe (2004) builds a stack of blurred images , where is a Gaussian of width , and subtracts neighbouring levels:
This difference of Gaussians is close to the scale-normalised Laplacian of Gaussian, which responds strongly to blobs whose size matches . A feature is a point that is a local maximum or minimum of across its 26 neighbours: 8 in its own level and 9 each in the levels above and below. Its scale is the at which it was found. That is what makes the detector scale-covariant.
Orientation and descriptor
Around each keypoint, compute gradient magnitudes and directions at its scale. Build a histogram of directions, weighted by magnitude and by a Gaussian centred on the keypoint, and take the peak as the feature's orientation. Rotate the neighbourhood so that orientation is zero. Then split the neighbourhood into a grid of cells, and in each cell build an 8-bin histogram of gradient directions. The result is numbers, normalised to unit length so that uniform changes in brightness and contrast have less effect.
Worked examples
Take two windows with structure tensor eigenvalues that are chosen to make the arithmetic easy. These numbers are illustrative, not from a real image. Use .
- Edge patch: , .
- Compute and .
- Compute , then .
- . Negative, so this is an edge.
Corner patch: , .
- and , so .
- .
- . Large and positive, so this is a corner.
Interpretation: the same threshold on separates corners from edges, and only the corner is a point you can find again after the camera moves along the edge.
Two images each give a set of descriptors. For one descriptor in image A, its distances to the two nearest descriptors in image B are and . (Illustrative numbers.)
- Ratio .
- Lowe's rule accepts a match when the ratio is below 0.8. , so accept.
Now a second descriptor with and .
- Ratio .
- , so reject.
Interpretation: the first descriptor has one clearly best partner. The second has two candidates that are almost equally good, so the match is ambiguous and is discarded. The test asks for a margin, not just a nearest neighbour.
Tradeoffs and failure modes
| Situation | Problem | Better choice |
|---|---|---|
| Plain textures, sky, water | Few stable keypoints | Dense features or learned descriptors |
| Large viewpoint change | Descriptors drift, match ratio fails | Affine-invariant detectors, or learned matchers |
| Thousands of descriptors to match | Brute-force nearest neighbour is slow | Approximate Nearest Neighbor Search |
| Repetitive structure (tiles, windows) | Many descriptors look alike, false matches | Geometric verification such as RANSAC on the matches |
| Real-time on weak hardware | 128-dimensional float descriptors are heavy | Binary descriptors, which trade accuracy for speed |
The detector is a fixed rule, so it is only as good as the assumptions behind it. Corners disappear under heavy blur, and the descriptor assumes that local geometry is roughly planar. Lighting changes that are not linear, such as strong shadows, reduce the match rate even after normalisation.
History
Harris and Stephens published their combined corner and edge detector in 1988, aimed at motion analysis. It is still used, but it is not scale-invariant. Lowe's scale-invariant feature transform (SIFT), presented first at a conference in 1999 and described in full in his 2004 journal paper, combined the scale-space idea with an orientation histogram and a 128-number descriptor. The combination was designed to be robust to rotation and scaling. Learned descriptors have since been proposed as alternatives, and many of them keep the same detect, describe and match structure.
Check yourself
QuestionWhy does the corner response R use the determinant and trace of M rather than computing the eigenvalues directly?Show answer
Eigenvalues of a 2 by 2 symmetric matrix need a square root, and the detector runs at every pixel. The determinant is the product of the eigenvalues and the trace is their sum, so separates corners, edges and flat patches using only a few multiplications. The threshold on therefore plays the role of a threshold on the two eigenvalues, without computing them.
QuestionUsing the edge and corner eigenvalues from the first worked example, what happens to R if k is raised from 0.04 to 0.06?Show answer
For the corner, and , so . It stays large and positive. For the edge, . Still negative. Raising makes the detector stricter about what counts as a corner, but it does not change which class each patch falls into here. A reader should check how far the values move before concluding that does not matter in general.
QuestionWhy does SIFT build a difference of Gaussians across several blur levels rather than running a single detector at one scale?Show answer
A corner or blob has a characteristic size, and at a single scale the detector only sees structures close to that size. Building at several values and taking extrema over neighbouring levels finds each structure at the scale that matches it. That gives each keypoint a scale, which is used to make the descriptor scale-invariant. Without it, two images of the same object taken from different distances would produce features that cannot be matched.
QuestionTwo descriptors in image A have nearest-neighbour distances 0.25 and 0.35 in image B. Does the ratio test accept the match? What would you change if many correct matches were being rejected?Show answer
The ratio is , which is below 0.8, so the match is accepted. If many correct matches are rejected, the threshold is too strict for the data. Raising it to something like 0.9 accepts more matches but also more false ones, so the usual fix is to keep the threshold and add geometric verification such as RANSAC, which removes wrong matches after the fact.
QuestionA stereo camera pair gives two images of a textured wall. Which stages of the pipeline would you expect to matter most, and why?Show answer
Detection and description matter most, because the two views differ by a small translation and a modest change in viewpoint, so the detector has to find the same points in both and the descriptor has to be stable under that change. Orientation matters less because the views are nearly parallel. Matches would be filtered with the ratio test and then with the epipolar constraint. See Feature Matching for how matches are used after they are found.
Sources
- Harris and Stephens (1988). A Combined Corner and Edge Detector. Harris corner detector
- Lowe (2004). Distinctive Image Features from Scale-Invariant Keypoints. DOI
- Scale-invariant feature transform