The whole idea.
A detector has to answer two questions: is there a cat? and where, exactly? The
oldest way to do it is the one on this page. Take a small picture of a cat — the
template — and slide it over the image exactly like the filter on the edge-detection
page, one position at a time. At every position, score how well the window under it matches. Any
window that scores above the cut-off becomes a box.
The score here is normalized correlation: subtract the average brightness from the window
and from the template, then measure how closely the two patterns agree. It runs from +1 (identical
pattern) through 0 (unrelated) to −1 (the exact negative), and it does not care whether the
window is brighter or darker overall.
The problem the sweep leaves behind.
A window one or two pixels away from a cat still mostly covers the cat, so it scores almost as
high. Every cat ends up wrapped in a pile of nearly identical boxes. Non-max suppression
cleans that up with one rule, repeated: keep the highest-scoring box left, then delete every box
that overlaps it by more than a set amount. The overlap is measured as
IoU — the area the two boxes share, divided by the area they cover together.
Identical boxes have IoU 1; boxes that do not touch have IoU 0.
How a modern detector differs.
YOLO, Faster R-CNN and the rest replace the hand-made template with a CNN that has learned what cats
look like, and they predict box sizes instead of using one fixed window. But they still produce a
pile of overlapping boxes, and most of them still clean it up with exactly this NMS step.