Describe a shape by the histogram of its edge directions — and make it survive a change of light. Per cell, gradient orientations (0–180°, unsigned) are binned weighted by magnitude; overlapping blocks are L2-normalized so a contrast change cancels; the block vectors concatenate into one descriptor. Down the center, data flows: pixels go in, the engine bins and normalizes, the descriptor comes out. The blue team builds and defends it; the red team tries to break it.
source Dalal & Triggs, Histograms of Oriented Gradients for Human Detection, CVPR 2005, pp.886–893 — DOI 10.1109/CVPR.2005.177 (INRIA Rhône-Alpes). Rendered, not quoted.
Correctness is not memorized; it falls out of four operations:
G1 gradient at each pixel by centered differences → magnitude m and orientation θ. G2 orientation folded to unsigned [0,180°): direction and its reverse are the same edge. G3 per cell, deposit each pixel's m into the bin of its θ — a magnitude-weighted histogram. G4 group cells into a block and L2-normalize: the descriptor now ignores absolute contrast.
Live histogram of the panel's centre cell (9 bins × 20°):
| bin | range | weight |
|---|
A shape as a histogram of edge directions — Dalal & Triggs, 2005. The gradients are exactly the the-sobel operator's gx, gy, only now binned by angle and pooled per cell instead of thresholded into an edge map.
This descriptor — fed to a linear SVM — was the state of the art in pedestrian detection for the decade before deep nets. Each sphere is the next one's premise: edges become orientation statistics, statistics become a detector.
The blue team's live check: re-run the descriptor on a fixed seeded image and its contrast-scaled copy, and confirm the normalized vectors are identical to 1e-9. If red skips normalization, this badge is where it shows.
An intensity image goes in. At each pixel the engine takes a centered difference — gx across, gy down — giving a gradient vector. From it: magnitude m = √(gx²+gy²) (how sharp the edge) and orientation θ = atan2(gy,gx) mod 180° (which way it runs).
A flat region gives m=0 and votes for nothing. Only edges speak — and each speaks in proportion to its strength. That vector field is what the panel below pools into histograms.
Move contrast: the raw histograms scale, but the block-normalized descriptor holds still. Move angle: the histogram peak walks across the bins.
Everything shown is computed live from the four operations — no bin is looked up, no descriptor cached.
What the machine produces, proven: a 144-dim descriptor for a 32×32 image (16 cells × 9 bins), where every cell histogram sums exactly to that cell's total gradient magnitude, a known-angle edge lands in the correct bin, and the block-normalized vector is invariant to any positive contrast scale to 1e-9. The current form is above; the totals are the output.
The blue team's witness (left) confirms the invariance live; the red team (right) tries to make it drift.
Folding to unsigned 0–180° also throws away gradient sign — dark-to-light and light-to-dark edges become the same — which helped pedestrians but loses information other classes need. HOG is not the descriptor; it is the proof that a shape can be written as an orientation histogram and searched.
"HOG is rotation-invariant." Cut. Rotating the image shifts every orientation bin. HOG is invariant to illumination / contrast (via block normalization), not to rotation.
"HOG is scale-invariant by itself." Cut. The descriptor is computed at a fixed cell size; scale is handled outside, by scanning an image pyramid.
"Gradients are binned signed, 0–360°." Kept, corrected. Dalal & Triggs found unsigned 0–180° with 9 bins best for people; signed bins helped some vehicle classes.
"Block normalization is a nicety." Cut. It is the whole robustness — drop it and contrast rescales the descriptor. The tamper below proves it.
The red team's move: skip block normalization — concatenate the raw cell histograms and ship those. Then a contrast change sails straight through into the descriptor. The blue team's witness (window 7) is watching.
Skip the L2 step and multiplying the image contrast by a constant now scales the descriptor — the witness recomputes, sees the two copies disagree, and turns red. Nothing is faked; the attack is real and it is caught.