Template Matching

Learn to detect image features with template matching.

We assume we operate in a manufacturing environment where the objects to inspect or the camera can move. The images won’t always show the features of interest from the same angle, but their size in pixels should be reasonably constant. It is essential to locate the object features in the image and link these locations to the object’s physical layout.

Template matching is a powerful location tool. It takes as inputs an image of an object and a smaller image that we call a template. The template represents the feature that we want to find in the image. The output of template matching is an image that has floating-point values, reflecting how much the original image locally looks like the template.

Creating a template for matching

Consider the image below. Our task will be to precisely register the electronic board through the location of the four golden rings in the corners.

Get hands-on with 1200+ tech skills courses.