Lecture 5 Template matching Slides by: Clark F. Olson.
-
date post
19-Dec-2015 -
Category
Documents
-
view
219 -
download
3
Transcript of Lecture 5 Template matching Slides by: Clark F. Olson.
![Page 1: Lecture 5 Template matching Slides by: Clark F. Olson.](https://reader035.fdocuments.us/reader035/viewer/2022062421/56649d2d5503460f94a0490f/html5/thumbnails/1.jpg)
Lecture 5Template matching
Slides by:Clark F. Olson
![Page 2: Lecture 5 Template matching Slides by: Clark F. Olson.](https://reader035.fdocuments.us/reader035/viewer/2022062421/56649d2d5503460f94a0490f/html5/thumbnails/2.jpg)
2
Comparing images
The simplest form of image comparison is a pixel-by-pixel comparison of some rectangular region.
In template matching, all of a smaller image (the template) is compared to all possible subregions of a larger image.
This is a form of appearance-based matching.
![Page 3: Lecture 5 Template matching Slides by: Clark F. Olson.](https://reader035.fdocuments.us/reader035/viewer/2022062421/56649d2d5503460f94a0490f/html5/thumbnails/3.jpg)
3
Template matching
Can find objects by comparing pixels (and aggregating)For example, sum of differences between corresponding pixels
Face recognition often uses a variation of this technique
In general, this requires an example image of the object you are looking for.Sometimes called a template or exemplar
General strategy:Consider all possible positions of template in search image
If match is close enough, save/output
![Page 4: Lecture 5 Template matching Slides by: Clark F. Olson.](https://reader035.fdocuments.us/reader035/viewer/2022062421/56649d2d5503460f94a0490f/html5/thumbnails/4.jpg)
4
Comparing pixels
How should the images be compared?• Sum of absolute differences• Sum of squared differences• Correlation (similar to convolution, but kernel is not flipped) • Unfortunately, these will fail if there is significant difference in:
Illumination
Sensor
Object color
Viewpoint
Etc.
![Page 5: Lecture 5 Template matching Slides by: Clark F. Olson.](https://reader035.fdocuments.us/reader035/viewer/2022062421/56649d2d5503460f94a0490f/html5/thumbnails/5.jpg)
5
Face finding
• Finding faces is an important special case
• The basic idea is very similar to filtering:– Filters tend to have strong
responses at locations that look similar to them.
– Use a face filter!
• Good implementations must be able to handle:– different lighting– different sizes– different orientations
![Page 6: Lecture 5 Template matching Slides by: Clark F. Olson.](https://reader035.fdocuments.us/reader035/viewer/2022062421/56649d2d5503460f94a0490f/html5/thumbnails/6.jpg)
6
Face finding
H. Rowley, S. Baluja, T. Kanade, “Neural network-based face detection”, IEEE Conf. on Computer Vision and Pattern Recognition. © 1996 IEEE.
![Page 7: Lecture 5 Template matching Slides by: Clark F. Olson.](https://reader035.fdocuments.us/reader035/viewer/2022062421/56649d2d5503460f94a0490f/html5/thumbnails/7.jpg)
77
H. Rowley, S. Baluja, T. Kanade, “Neural network-based face detection”, IEEE Conf. on Computer Vision and Pattern Recognition. © 1996 IEEE.
![Page 8: Lecture 5 Template matching Slides by: Clark F. Olson.](https://reader035.fdocuments.us/reader035/viewer/2022062421/56649d2d5503460f94a0490f/html5/thumbnails/8.jpg)
• If we know exactly what something looks like then it is easy to find.
• Objects look different under varying conditions:– Changes in lighting or color– Changes in viewing direction– Changes in size / shape
• A single exemplar is unlikely to succeed reliably!– However, it is impossible to represent all appearances of an object.
8
Recognition by finding patterns
![Page 9: Lecture 5 Template matching Slides by: Clark F. Olson.](https://reader035.fdocuments.us/reader035/viewer/2022062421/56649d2d5503460f94a0490f/html5/thumbnails/9.jpg)
9
Appearance-based matching
Appearance-based techniques use example images (templates or exemplars) of the objects to perform recognition (as opposed to extracted features).
I include edge images in this definition, although this is considered feature-based by some.
![Page 10: Lecture 5 Template matching Slides by: Clark F. Olson.](https://reader035.fdocuments.us/reader035/viewer/2022062421/56649d2d5503460f94a0490f/html5/thumbnails/10.jpg)
10
Example
?=
?=
Frontal faces are fairly easy to find (and sometimes classify)
However, changes to lighting and background cause problems.
![Page 11: Lecture 5 Template matching Slides by: Clark F. Olson.](https://reader035.fdocuments.us/reader035/viewer/2022062421/56649d2d5503460f94a0490f/html5/thumbnails/11.jpg)
11
Edge matching
Changes in lighting and color usually don’t have much effect on image edges.
![Page 12: Lecture 5 Template matching Slides by: Clark F. Olson.](https://reader035.fdocuments.us/reader035/viewer/2022062421/56649d2d5503460f94a0490f/html5/thumbnails/12.jpg)
12
Strategy:Detect edges in template and image
Compare edge images to find the template
Must consider range of possible template positions
Edge matching
![Page 13: Lecture 5 Template matching Slides by: Clark F. Olson.](https://reader035.fdocuments.us/reader035/viewer/2022062421/56649d2d5503460f94a0490f/html5/thumbnails/13.jpg)
13
Edge matching measures
What measure should we use to compare edge images?
Can count number of overlapping edges.Not robust to changes in shape
Better: count number of template edge pixels with some distance of an edge in the search image.
Best: • Determine probability distribution of distance to nearest edge in search
image (if template at correct position)• Estimate likelihood of each template position generating image
![Page 14: Lecture 5 Template matching Slides by: Clark F. Olson.](https://reader035.fdocuments.us/reader035/viewer/2022062421/56649d2d5503460f94a0490f/html5/thumbnails/14.jpg)
14
Matching gradientsOne way to be robust to illumination changes, but not throw away as much information is to compare image gradients.Matching is performed like matching greyscale images.
Simple alternative: use (normalized) correlation.
![Page 15: Lecture 5 Template matching Slides by: Clark F. Olson.](https://reader035.fdocuments.us/reader035/viewer/2022062421/56649d2d5503460f94a0490f/html5/thumbnails/15.jpg)
15
Different viewpoints
What if we don’t know the viewpoint?• Non-frontal faces• Objects in arbitrary orientation
A partial solution: linear transformations model small changes in viewpoint.
A better solution: use templates that model all possible view directions.• Computationally expensive
![Page 16: Lecture 5 Template matching Slides by: Clark F. Olson.](https://reader035.fdocuments.us/reader035/viewer/2022062421/56649d2d5503460f94a0490f/html5/thumbnails/16.jpg)
16
Large modelbases
If we have many potential templates that we are looking can we search efficiently?
One approach is based on eigenvectors of the templates.eigenfaces
http://www-white.media.mit.edu/vismod/demos/facerec/basic.html
![Page 17: Lecture 5 Template matching Slides by: Clark F. Olson.](https://reader035.fdocuments.us/reader035/viewer/2022062421/56649d2d5503460f94a0490f/html5/thumbnails/17.jpg)
• If we want to be insensitive to changes in illumination, sensor, and object color, we must use a robust measure.
• One option is to change the image to make them comparable:– Gradients– Entropy
Original image Local entropy
17
Robust measures
![Page 18: Lecture 5 Template matching Slides by: Clark F. Olson.](https://reader035.fdocuments.us/reader035/viewer/2022062421/56649d2d5503460f94a0490f/html5/thumbnails/18.jpg)
18
Different sensors
infrared image
CCD image