Template Matching

If we already know what a pattern looks like, we can search for it in a larger picture. Template matching compares that known pattern with each possible location in the image.

15 sections · 15 questions · 4 coding challenges

1 / 15

Where Does This Particular Pattern Appear Again?

BOTIE

Suppose we already have a small image of the thing we want to locate. We are not yet trying to recognise every member of a broad category. We are looking for another occurrence of this particular appearance within a larger image.

Template matching has a long signal-processing and computer-vision lineage. Lewis' 1995 work on fast template matching addressed a practical bottleneck: computing normalised cross-correlation efficiently across candidate locations. The normalisation matters when illumination changes would make raw brightness comparisons misleading.

We move the reference patch over the image and score each position. Normalised correlation compares the pattern of variation after accounting for local mean and scale. A high score points to similar appearance under those assumptions. Rotation, size changes, and deformation can still disrupt the match, which explains why later methods often search using more adaptable local features.

Sources for this history