SSD, SAD, and NCC all answer "does this window match the template" — but only one of them survives a lighting change. Watch all three fight the exact same illumination shock at once, then find out why every industrial camera trusts NCC and nothing else.
Same shock, three different survivors
SSD and SAD dissolve into noise the instant brightness shifts. NCC barely notices — it was never measuring brightness in the first place.
All three metrics tested against the exact same template and scene, side by side.
Drag the cyan template anywhere over the scene. Hover the heatmap for exact score math.
Similarity map (brighter = better match)
Scale
1.00×
Rotation
0°
📋 Live OpenCV codeTM_CCOEFF_NORMED
Match thresh.
80%
Without NMS, every near-duplicate high-scoring position around a real match gets drawn too.
Why industrial cameras trust only NCC▾
SSD / SAD — raw pixel arithmetic
Σ(I−T)² and Σ|I−T| both measure raw brightness difference directly. Darken the whole scene and every single term in that sum changes — the "best" window can shift to somewhere that used to be a worse match.
NCC — shape, not brightness
Subtracting each region's own mean before correlating removes overall brightness entirely from the equation. A uniformly darker window is still a shape match after mean-subtraction — that is the whole trick.
The industrial reason
Factory lighting flickers, shadows move, exposure auto-adjusts — brightness is never perfectly controlled on a real line. A metric that only works under constant lighting is not a metric a production camera can rely on.
Predict, then verify
In Metric Showdown, you hit Illumination Shock. What happens to the SSD heatmap specifically?