Foundations to Frontier
Tests
G. Computer Vision and Remote Sensing › G1 Image Fundamentals

Feature Descriptors: SIFT, HOG and Their Successors

A feature descriptor turns a small image patch into a vector so that the same physical point seen in two images gives nearby vectors. SIFT (Lowe, 2004) detects blobs across scales, assigns each a dominant orientation and describes it with a 4 × 4 grid of gradient-orientation histograms (128 numbers). HOG (Dalal and Triggs, 2005) applies the same histograms densely over a detection window. This page covers gradients and orientation binning, normalisation for lighting invariance, scale-space detection, orientation assignment for rotation invariance, Lowe's ratio test, binary descriptors such as ORB, and the learned descriptors and matchers (SuperPoint, LightGlue) that now often replace them. In the exercises you build cell histograms, L2-Hys normalisation and the ratio test. You then match 100 points of a texture across rotations and lighting changes. Upright descriptors tolerated 15° of rotation (0.99 nearest-neighbour accuracy) but collapsed at 30° (0.13–0.28). With orientation normalisation the SIFT-like descriptor kept 0.86 at 30° and 0.89 at 90°. The price was 0.93 accuracy instead of 1.0 when nothing changed, because orientation estimates at random points are unstable.

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

Fingerprints for image patches

To stitch two photos or track a robot’s motion, a computer must recognise the same spot in two images, even if the camera turned or the light changed. Raw pixel values change too much, so we summarise each patch by which way its edges point: a histogram of edge directions, like a small fingerprint. Measuring directions relative to the patch’s strongest direction makes the fingerprint survive rotation, and normalising it removes brightness changes. The demo builds such a histogram for a small patch with an edge.

Image lab
8 × 8 cell
10°30°50°70°90°110°130°150°170°
Peak bin centred at 130°: the gradient points across the edge (edge angle 30° + 90°, modulo 180°). The raw histogram norm is 7.61 and scales with contrast; after L2 normalisation the bars do not change, which is what makes HOG and SIFT robust to lighting.
Why engineers care

Visual odometry on Mars rovers, satellite image co-registration and drone mapping all match keypoint descriptors between images thousands of times per second.

📝 Quick check (Level 0)
0/3 answered
  1. 1. A descriptor summarises a patch by…
  2. 2. Rotation invariance comes from…
  3. 3. Normalising the histogram removes…

Level 1: Beginner

★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.

By hand

  • Gradients: central differences or Sobel give magnitude and orientation at each pixel. HOG uses unsigned orientations (0–180°, 9 bins) for objects whose contrast polarity varies; SIFT uses signed ones (0–360°, 8 bins).
  • HOG (Dalal and Triggs, 2005): 8 × 8-pixel cells, 9-bin histograms with interpolated votes, 2 × 2-cell blocks with L2-Hys normalisation, blocks overlapping by one cell; a 64 × 128 pedestrian window gives 3780 features for a linear SVM. Deformable part models (Felzenszwalb et al., 2010) built on HOG.
  • Keypoint detection: Harris corners (Harris and Stephens, 1988) use the structure tensor; SIFT finds extrema of the difference of Gaussians over position and scale (3 levels per octave, σ₀ = 1.6), rejects edges and low contrast, and refines positions.
  • SIFT descriptor (Lowe, 1999, 2004): dominant orientation from a 36-bin histogram (extra keypoints for peaks above 80%); the 16 × 16 neighbourhood, rotated and scaled to the keypoint, is pooled into 4 × 4 cells × 8 bins = 128 values, normalised, clipped at 0.2 and renormalised. RootSIFT (Arandjelović and Zisserman, 2012) takes square roots for a Hellinger distance.
  • Matching: nearest neighbour with Lowe’s ratio test (accept if d₁ / d₂ is below about 0.8), mutual nearest neighbours, then RANSAC on a geometric model; approximate search with FLANN or FAISS.
  • Faster and binary: SURF (Bay et al., 2006), FAST corners, BRIEF, ORB (Rublee et al., 2011; 256 bits, Hamming distance), used in ORB-SLAM3 (2021).
  • Learned (2018–2026): SuperPoint, D2-Net, DISK and ALIKED detectors and descriptors; SuperGlue, LoFTR and LightGlue matchers; dense DINOv2 features for semantic correspondence. SIFT remains the default in COLMAP and a strong baseline in benchmarks such as the Image Matching Challenge.
📝 Quick check (Level 1)
0/3 answered
  1. 1. Standard SIFT descriptors have…
  2. 2. ORB descriptors are compared with…
  3. 3. Lowe's ratio test rejects a match when…

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 25 minUndergraduate students and practising engineers.

Computing and matching descriptors

Exercise 1.

  • Gradients and orientations.
  • A HOG cell histogram with interpolated votes.
  • L2-Hys normalisation.
  • Lowe’s ratio test.

Practice.

  • Use cv2.SIFT_create (patent expired in 2020) or ORB for speed; kornia.feature for differentiable and learned versions (DISK, LightGlue).
  • Always follow matching with a geometric check (RANSAC on a homography or fundamental matrix) and report inlier counts.
  • Use RootSIFT and mutual nearest neighbours as cheap improvements.
  • For detection with HOG, use scikit-image hog and a linear SVM, with hard negative mining.
  • For new projects, compare against a learned matcher (SuperPoint + LightGlue) on your own imagery; classical features still win on some domains and on tight compute.
import cv2, numpy as np
img1, img2 = (cv2.imread(f, cv2.IMREAD_GRAYSCALE) for f in ("pass_1.png", "pass_2.png"))
sift = cv2.SIFT_create(nfeatures=4000)
k1, d1 = sift.detectAndCompute(img1, None); k2, d2 = sift.detectAndCompute(img2, None)
pairs = cv2.BFMatcher(cv2.NORM_L2).knnMatch(d1, d2, k=2)
good = [m for m, n in pairs if m.distance < 0.8 * n.distance]        # Lowe's ratio test
src = np.float32([k1[m.queryIdx].pt for m in good]); dst = np.float32([k2[m.trainIdx].pt for m in good])
H, inliers = cv2.findHomography(src, dst, cv2.USAC_MAGSAC, 3.0)
print(len(good), int(inliers.sum()))
🐍 Exercise 1: histograms, normalisation and matching
Compute gradients and HOG cell histograms, implement L2-Hys and Lowe's ratio test.
📝 Quick check (Level 2)
0/3 answered
  1. 1. After ratio-test matching, always…
  2. 2. A cheap improvement to SIFT matching:
  3. 3. A modern learned matcher:

Level 3: Advanced

★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.

Theory

Why histograms of gradients. Gradient orientation is unchanged by adding a constant and by multiplying intensities, so normalised orientation histograms are invariant to affine lighting changes. Pooling over cells tolerates small shifts and deformations, and interpolated votes avoid jumps at bin boundaries. Clipping at 0.2 limits the influence of a few strong gradients, which change with non-linear lighting.

Rotation invariance. Rotating the image rotates every gradient and moves the patch content. If a reference orientation θ is measured in the patch and the descriptor is computed in a frame rotated by θ, the two effects cancel. The scheme is only as good as θ: when the orientation histogram has two similar peaks, noise can flip the choice and the descriptor changes completely, which is why SIFT duplicates keypoints with secondary peaks and why detectors favour well-structured points.

Scale. The scale-normalised Laplacian σ²∇²G has extrema at a scale proportional to the size of a blob (Lindeberg, 1998); the difference of Gaussians approximates it cheaply. Describing the patch at that scale gives scale invariance.

Ratio test. A correct match is usually much closer than the closest wrong candidate; for repeated texture several candidates are equally close, and the ratio d₁ / d₂ approaches 1. Thresholding it removes most false matches at a small loss of correct ones (Lowe reported eliminating 90% of false matches while discarding under 5% of correct ones at 0.8).

📝 Quick check (Level 3)
0/3 answered
  1. 1. Gradient orientation is unchanged by…
  2. 2. Orientation normalisation fails when…
  3. 3. The difference of Gaussians approximates…

Level 4: Expert

★★★★★ Expert⏱ 30 minResearchers: original papers and open problems.

What does each ingredient of a SIFT-like descriptor buy under rotation and lighting change, and what does invariance cost?

History.

  • C. Harris and M. Stephens, “A combined corner and edge detector” (1988).
  • D. Lowe, “Distinctive image features from scale-invariant keypoints” (2004; first version 1999).
  • N. Dalal and B. Triggs, “Histograms of oriented gradients for human detection” (2005).
  • E. Rublee et al., “ORB: an efficient alternative to SIFT or SURF” (2011); P. Lindenberger et al., “LightGlue” (2023).

Exercise 2. A 160 × 160 smooth random texture and 100 random keypoints. The second view rotates the image about its centre and applies an intensity change 0.5 I + 0.3, plus noise of standard deviation 0.01.

  • Descriptors: raw 16 × 16 pixels; the same with zero mean and unit norm; an upright 4 × 4 × 8 gradient-histogram grid with L2-Hys; the same grid after SIFT orientation assignment (36-bin histogram, parabolic peak).
  • Measure: nearest-neighbour accuracy among the 100 candidates; share kept and precision under the 0.8 ratio test.
second view raw pixels normalised pixels upright grid SIFT-like
noise only 1.0 1.0 1.0 0.93
contrast and brightness 1.0 1.0 1.0 0.92
rotation 15° 0.99 0.99 0.99 0.90
rotation 30° 0.28 0.13 0.16 0.86
rotation 90° 0.02 0.0 0.01 0.89
rotation 30° and contrast 0.27 0.13 0.15 0.84
  • Pooling tolerates small rotations, not large ones: all upright descriptors handled 15° but collapsed at 30° (0.16 for the upright grid on all three seeds).
  • Orientation normalisation gave rotation invariance: 0.89, 0.91 and 0.89 at 90° on seeds 0, 1 and 2. Ratio-test precision stayed at or above 0.965 for the SIFT-like descriptor in every condition and seed.
  • A global contrast change did not break raw-pixel nearest neighbours here (accuracy 1.0), but made them far less distinctive: the ratio test kept only 0.91, 0.78 and 0.50 of raw-pixel matches on the three seeds against 1.0 for normalised descriptors.
  • Invariance has a cost: with no transformation the SIFT-like descriptor found 0.93 (seeds 1 and 2: 0.88 and 0.93) instead of 1.0, because at random points the orientation histogram often has competing peaks. SIFT reduces this with detected keypoints and duplicate orientations, which this exercise omits.
  • Caveat: synthetic texture, no scale change or perspective, random rather than detected keypoints.
🐍 Exercise 2 (research): what does each ingredient of a SIFT-like descriptor buy under rotation and lighting change, and what does invariance cost?
Match 100 keypoints across rotations and lighting changes with raw pixels, normalised pixels, an upright gradient-histogram grid and a SIFT-like oriented descriptor.

Feature descriptors in AI, robotics and aerospace

  • Planetary navigation: visual odometry on NASA’s Mars rovers tracks features between stereo frames; terrain-relative navigation matched landmarks to orbital maps during the Perseverance landing (2021).
  • Earth observation: co-registration of Sentinel-2 and Landsat scenes and of multi-date drone imagery uses SIFT or learned matches with RANSAC.
  • Robotics: ORB-SLAM3 and VINS-Fusion run binary features in real time; structure-from-motion pipelines such as COLMAP and GLOMAP default to SIFT, increasingly paired with learned matchers.

References

  1. D. G. Lowe (2004). “Distinctive image features from scale-invariant keypoints.” IJCV.
  2. N. Dalal and B. Triggs (2005). “Histograms of oriented gradients for human detection.” CVPR.
  3. C. Harris and M. Stephens (1988). “A combined corner and edge detector.” Alvey Vision Conference.
  4. E. Rublee, V. Rabaud, K. Konolige and G. Bradski (2011). “ORB: an efficient alternative to SIFT or SURF.” ICCV.
  5. D. DeTone, T. Malisiewicz and A. Rabinovich (2018). “SuperPoint: self-supervised interest point detection and description.” CVPR Workshops.
  6. P. Lindenberger, P.-E. Sarlin and M. Pollefeys (2023). “LightGlue: local feature matching at light speed.” ICCV.