![Page 1: CSSE463: Image Recognition Day 25 Today: introduction to object recognition: template matching Today: introduction to object recognition: template matching](https://reader036.vdocuments.us/reader036/viewer/2022081807/5a4d1b757f8b9ab0599b6c0a/html5/thumbnails/1.jpg)
CSSE463: Image Recognition CSSE463: Image Recognition Day 25Day 25 Today: introduction to object recognition: Today: introduction to object recognition:
template matchingtemplate matching
Template matching: a simple method for object Template matching: a simple method for object detectiondetection
Questions?Questions?
![Page 2: CSSE463: Image Recognition Day 25 Today: introduction to object recognition: template matching Today: introduction to object recognition: template matching](https://reader036.vdocuments.us/reader036/viewer/2022081807/5a4d1b757f8b9ab0599b6c0a/html5/thumbnails/2.jpg)
Template matching (Sonka, 6.4)Template matching (Sonka, 6.4) Idea: you are looking for an exact match of Idea: you are looking for an exact match of
an object (described by a sub-image, a an object (described by a sub-image, a templatetemplate) in an image) in an image
Ideal world: it matches exactlyIdeal world: it matches exactly
![Page 3: CSSE463: Image Recognition Day 25 Today: introduction to object recognition: template matching Today: introduction to object recognition: template matching](https://reader036.vdocuments.us/reader036/viewer/2022081807/5a4d1b757f8b9ab0599b6c0a/html5/thumbnails/3.jpg)
Template matching (Sonka, 6.4)Template matching (Sonka, 6.4) Algorithm:Algorithm:
Evaluate a match Evaluate a match criterion at every image criterion at every image location (and size, location (and size, reflection, and rotation, if reflection, and rotation, if those variations are those variations are expected)expected)
A “match” is a local A “match” is a local maximum of the criterion maximum of the criterion above a thresholdabove a threshold
Q1
![Page 4: CSSE463: Image Recognition Day 25 Today: introduction to object recognition: template matching Today: introduction to object recognition: template matching](https://reader036.vdocuments.us/reader036/viewer/2022081807/5a4d1b757f8b9ab0599b6c0a/html5/thumbnails/4.jpg)
Template matching (Sonka, 6.4)Template matching (Sonka, 6.4)One match criterion:One match criterion:
Correlation between the template and the Correlation between the template and the image.image.
We are just using the template as a filter!We are just using the template as a filter!Simplistic implementationSimplistic implementationSmarter implementationSmarter implementation
![Page 5: CSSE463: Image Recognition Day 25 Today: introduction to object recognition: template matching Today: introduction to object recognition: template matching](https://reader036.vdocuments.us/reader036/viewer/2022081807/5a4d1b757f8b9ab0599b6c0a/html5/thumbnails/5.jpg)
CorrelationCorrelation Just the dot product between Just the dot product between
the template and a the template and a neighborhood in the image. neighborhood in the image.
Idea: high correlation when Idea: high correlation when the template matches.the template matches.
Demo Demo
![Page 6: CSSE463: Image Recognition Day 25 Today: introduction to object recognition: template matching Today: introduction to object recognition: template matching](https://reader036.vdocuments.us/reader036/viewer/2022081807/5a4d1b757f8b9ab0599b6c0a/html5/thumbnails/6.jpg)
CorrelationCorrelation Just the dot product between Just the dot product between
the template and a the template and a neighborhood in the image. neighborhood in the image.
Idea: high correlation when Idea: high correlation when the template matches. the template matches.
Problem: Problem: alwaysalways high high correlation when matching correlation when matching with a plain bright regionwith a plain bright region
Q2-3
![Page 7: CSSE463: Image Recognition Day 25 Today: introduction to object recognition: template matching Today: introduction to object recognition: template matching](https://reader036.vdocuments.us/reader036/viewer/2022081807/5a4d1b757f8b9ab0599b6c0a/html5/thumbnails/7.jpg)
CorrelationCorrelation Just the dot product between Just the dot product between
the template and a the template and a neighborhood in the image. neighborhood in the image.
Idea: high correlation when Idea: high correlation when the template matches. the template matches.
Problem: Problem: alwaysalways high high correlation when matching correlation when matching with a plain bright regionwith a plain bright region
Solution: Normalize the Solution: Normalize the template and each region by template and each region by subtracting each’s mean from subtracting each’s mean from itself itself before before taking dot producttaking dot product
Q4-5
![Page 8: CSSE463: Image Recognition Day 25 Today: introduction to object recognition: template matching Today: introduction to object recognition: template matching](https://reader036.vdocuments.us/reader036/viewer/2022081807/5a4d1b757f8b9ab0599b6c0a/html5/thumbnails/8.jpg)
Other matching algorithmsOther matching algorithmsChamfering (Hausdorff distance):Chamfering (Hausdorff distance):
http://www.cs.cornell.edu/~dph/hausdorff/hausdorff1.htmlhttp://www.cs.cornell.edu/~dph/hausdorff/hausdorff1.html
Springs and templates (Crandall and Springs and templates (Crandall and Huttenlocher)Huttenlocher) http://www.cs.cornell.edu/~dph/papers/cvpr07.pdfhttp://www.cs.cornell.edu/~dph/papers/cvpr07.pdf
Watershed segmentation (Sonka 6.3.4)Watershed segmentation (Sonka 6.3.4)