Skip to contentScholarGate
LibraryBookshelfDeskReview StudioAssistant
Sign in
On this page
IntuitionHow it worksWhen to use itStrengths & limitationsCommon pitfallsApplicationsFrequently asked🔒 Read the full methodSourcesRelated methods
Cite this pageSpotted an issue on this page? Report or suggest a fix →
Home›Computer Vision›Template Matching
Machine learningObject detection

Template Matching

Template Matching for Object Detection · Also known as: Correlation-based matching, Similarity matching

Template matching is a straightforward technique for locating a known pattern (template) within a larger image. By sliding a template image across the target image and computing a similarity measure at each position, template matching identifies locations where the template appears. It is effective for simple object detection when templates are well-defined and appearance variation is limited.

ScholarGate
  1. Machine learning
  2. v1
  3. 2 Sources
  4. PUBLISHED
Cite this page →
Tools & resources
Download slides
Learn & explore

Read the full method

Members only

Sign in with a free account to read this section.

Sign in

Method map

The neighbourhood of related methods — select a node to explore.

Template Matching
Blob DetectionContour AnalysisHarris Corner DetectionHough TransformSIFT Feature DetectionCanny Edge DetectionHistogram EqualizationLucas-Kanade Optical FlowORB Feature DescriptorStereo Matching

When to use it

Use template matching when objects are relatively rigid (appearance does not change much), the template is well-defined, and appearance variation is limited. Template matching is suitable for finding a specific object instance in controlled environments (e.g., locating a component on an assembly line, finding a logo in a document). Avoid template matching for objects with large appearance variation due to rotation, scale, or lighting changes; feature-based methods (SIFT, ORB) or deep learning approaches are more robust.

Strengths & limitations

Strengths
  • Conceptually simple and easy to implement
  • Fast computation, especially for small templates and images
  • No training required; detects a template directly without learning
  • Works well when template is representative and target region is similar
  • Can detect multiple instances of the same template in an image
Limitations
  • Not invariant to scale, rotation, or perspective change; template must match target appearance closely
  • Sensitive to lighting and contrast variations; illumination changes reduce match quality
  • Requires high-quality, representative templates; poor template choice leads to many false positives
  • Computationally expensive for large images or templates; naive sliding-window approach has O(n*m) complexity

Frequently asked

What is normalized cross-correlation and why is it better than simple correlation?

Normalized cross-correlation accounts for local intensity variations by dividing by the standard deviation of both template and image region. This makes matches robust to global intensity changes (e.g., brightness increase). Simple correlation gives higher values for bright regions regardless of pattern similarity, whereas normalized cross-correlation isolates the pattern structure.

How does template matching handle multiple instances?

Template matching produces a similarity map with multiple peaks, each representing a potential match. By thresholding the similarity map and finding local maxima, multiple instances can be detected. Non-maximum suppression can be applied to eliminate overlapping detections from nearby peaks.

Can template matching detect rotated or scaled versions of the template?

Standard template matching cannot detect rotations or scale changes. However, multi-scale or multi-orientation variants exist: compute similarity at multiple template scales and rotations, then find the best match across all variants. This approach is slower but handles some variation. For large transformations, feature-based or deep learning methods are more efficient.

Why is template matching sensitive to lighting changes?

Template matching relies on intensity patterns. If the template is created under different lighting than the target image, intensity values differ even if the object is in the same position. Normalized cross-correlation partially mitigates this by normalizing local statistics, but it cannot handle extreme lighting variation. Preprocessing (histogram equalization) or learning-based methods are more robust.

Sources

  1. Lewis, J. P. (2004). Fast normalized cross-correlation. Vision Interface, 120–123. link ↗
  2. Briechle, K., & Hanebeck, U. D. (2001). Template matching using fast normalized cross correlation. SPIE Proceedings, 4387, 95–102. DOI: 10.1117/12.421129 ↗

How to cite this page

ScholarGate. (2026, June 3). Template Matching for Object Detection. ScholarGate. https://scholargate.app/en/computer-vision/template-matching

Related methods

Blob DetectionContour AnalysisHarris Corner DetectionHough TransformSIFT Feature Detection

Which method?

Set this method beside its closest kin and read them side by side — the library lays the books on the table; the choice is yours.

  • Blob DetectionComputer Vision↔ compare
  • Contour AnalysisComputer Vision↔ compare
  • Harris Corner DetectionComputer Vision↔ compare
  • Hough TransformComputer Vision↔ compare
  • SIFT Feature DetectionComputer Vision↔ compare
Compare side by side →

Referenced by

Canny Edge DetectionHistogram EqualizationHough TransformLucas-Kanade Optical FlowORB Feature DescriptorSIFT Feature DetectionStereo Matching

Similar methods

SIFT Feature DetectionObject DetectionSelf-supervised Object DetectionHarris Corner DetectionStereo MatchingImage ClassificationMultimodal Object DetectionTransfer Learning with Object Detection

Related reference concepts

Feature Detection and DescriptionObject Recognition and DetectionEdge and Contour DetectionImage SegmentationMotion and Optical FlowComputer Vision

Spotted an issue on this page? Report or suggest a fix →

ScholarGate — Template Matching (Template Matching for Object Detection). Retrieved 2026-07-21 from https://scholargate.app/en/computer-vision/template-matching · Dataset: https://doi.org/10.5281/zenodo.20539026
Quick facts
Originator
Computer vision community
Subfamily
Object detection
Year
1980s
Type
Pattern matching and detection
Related methods
Blob DetectionContour AnalysisHarris Corner DetectionHough TransformSIFT Feature Detection
ScholarGate

A content-first reference library for research methods — what each one is, how it works, and where it comes from.

Open data (CC-BY)

Explore

  • Library
  • Search the library…
  • Browse by field
  • Fields
  • Journey
  • Compare
  • Which method?

Reference

  • Subjects
  • Atlas
  • Glossary
  • Methodology
  • Philosophy

Your tools

  • Bookshelf
  • Desk
  • Chat

Company

  • About
  • Pricing
  • Contact
  • Suggest a method

Entries are compiled from published sources for reference. Verifying the accuracy and suitability of any information for your own use remains your responsibility.

© 2026 ScholarGate · A research-method reference library
  • Privacy
  • Cookies
  • Terms
  • Delete account