Task 2 of 5
Now break it. brightScene is the same scene photographed in brighter
light: every value 0.28 higher, nothing moved, nothing changed shape. The patch is still
exactly where it was. Run the same kernel over it — the kernel is not what is wrong here —
and the best match walks off to a completely different place.
Here is why, in one line of algebra. Add δ to every scene value and the score at a window becomes
SSD(w + δ, t) = SSD(w, t)
+ 2δ · sum(wᵢ − tᵢ)
+ n · δ²
At the true match the pixels agree, so sum(wᵢ − tᵢ) is zero and there is
nothing to offset the last term: a perfect match now scores
64 × 0.28² = 5.02. Meanwhile any window that is darker than
the template has a negative sum(wᵢ − tᵢ), and the middle term pays it a
discount. Somewhere in this scene sits a patch that is dark and matches badly; brighten
the picture and its discount beats a perfect match outright.
That is the whole lesson of this module, and it is not really about vision. SSD is not a measure of similarity — it is a measure of distance in absolute value, and every camera, every light, every exposure, every gain setting moves absolute values around. A score that cannot tell "brighter" from "different" will confidently point at the wrong thing.
scene and brightScene with the same kernelconsole.log the best position on each map — they disagreeconsole.log the score at the true position and the score the winner got — the winner's is smallerSame kernel, called twice. brightScene has exactly the same shape
as scene, so the second call costs you one line.
The map is indexed map[y][x], so the score the bright map gives
the true position is brightMap[TRUE_Y][TRUE_X]. Compare it against
bestMatch(brightMap).score.
TM_CCOEFF_NORMED alongside TM_SQDIFF, why stereo matchers use
census transforms or rank filters instead of raw differences, and why "we normalised the
inputs and the model started working" is the most common debugging story in machine
learning. A raw difference is a distance in whatever units the sensor happened to
produce.
This page is an interactive exercise — the editor, the GPU runner and your saved progress need JavaScript. The text above is the full brief.