computer vision course lecture 04 template matching image...
TRANSCRIPT
![Page 1: Computer Vision Course Lecture 04 Template Matching Image ...cba-research.com/pdfs/Lecture04-TemplateMatching_CV.pdf · 1. Match template at current scale 2. Downsample image 3. Repeat](https://reader034.vdocument.in/reader034/viewer/2022042404/5f1a4a57fbb4845ffe234023/html5/thumbnails/1.jpg)
Template Matching Image Pyramids
Ceyhun Burak Akgül, PhD cba-research.com Spring 2015 Last updated 11/03/2015
Computer Vision Course Lecture 04
Photo credit: Olivier Teboul vision.mas.ecp.fr/Personnel/teboul
These slides have been adapted from James Hays’s 2014 Computer Vision course slides at Brown University.
![Page 2: Computer Vision Course Lecture 04 Template Matching Image ...cba-research.com/pdfs/Lecture04-TemplateMatching_CV.pdf · 1. Match template at current scale 2. Downsample image 3. Repeat](https://reader034.vdocument.in/reader034/viewer/2022042404/5f1a4a57fbb4845ffe234023/html5/thumbnails/2.jpg)
Course Outline Image Formation and Processing Light, Shape and Color
The Pin-hole Camera Model, The Digital Camera
Linear filtering, Template Matching, Image Pyramids
Feature Detection and Matching Edge Detection, Interest Points: Corners and Blobs
Local Image Descriptors
Feature Matching and Hough Transform
Multiple Views and Motion Geometric Transformations, Camera Calibration
Feature Tracking , Stereo Vision
Segmentation and Grouping Segmentation by Clustering, Region Merging and Growing
Advanced Methods Overview: Active Contours, Level-Sets, Graph-Theoretic Methods
Detection and Recognition Problems and Architectures Overview
Statistical Classifiers, Bag-of-Words Model, Detection by Sliding Windows
2 CBA Research Computer Vision
![Page 3: Computer Vision Course Lecture 04 Template Matching Image ...cba-research.com/pdfs/Lecture04-TemplateMatching_CV.pdf · 1. Match template at current scale 2. Downsample image 3. Repeat](https://reader034.vdocument.in/reader034/viewer/2022042404/5f1a4a57fbb4845ffe234023/html5/thumbnails/3.jpg)
Template Matching • Goal: find in image
• Main challenge: What is a good similarity or distance measure between two patches?
– Correlation
– Zero-mean correlation
– Sum Square Difference
– Normalized Cross Correlation
![Page 4: Computer Vision Course Lecture 04 Template Matching Image ...cba-research.com/pdfs/Lecture04-TemplateMatching_CV.pdf · 1. Match template at current scale 2. Downsample image 3. Repeat](https://reader034.vdocument.in/reader034/viewer/2022042404/5f1a4a57fbb4845ffe234023/html5/thumbnails/4.jpg)
Matching with Filters • Goal: find in image
• Method 0: filter the image with eye patch
Input Filtered Image
],[],[],[,
lnkmflkgnmhlk
What went wrong?
f = image
g = filter
![Page 5: Computer Vision Course Lecture 04 Template Matching Image ...cba-research.com/pdfs/Lecture04-TemplateMatching_CV.pdf · 1. Match template at current scale 2. Downsample image 3. Repeat](https://reader034.vdocument.in/reader034/viewer/2022042404/5f1a4a57fbb4845ffe234023/html5/thumbnails/5.jpg)
Matching with Filters • Goal: find in image
• Method 1: filter the image with zero-mean eye
Input Filtered Image (scaled) Thresholded Image
)],[()],[(],[,
lnkmgflkfnmhlk
True detections
False
detections
mean of f
![Page 6: Computer Vision Course Lecture 04 Template Matching Image ...cba-research.com/pdfs/Lecture04-TemplateMatching_CV.pdf · 1. Match template at current scale 2. Downsample image 3. Repeat](https://reader034.vdocument.in/reader034/viewer/2022042404/5f1a4a57fbb4845ffe234023/html5/thumbnails/6.jpg)
Matching with Filters • Goal: find in image
• Method 2: SSD
Input 1- sqrt(SSD) Thresholded Image
2
,
)],[],[(],[ lnkmflkgnmhlk
True detections
![Page 7: Computer Vision Course Lecture 04 Template Matching Image ...cba-research.com/pdfs/Lecture04-TemplateMatching_CV.pdf · 1. Match template at current scale 2. Downsample image 3. Repeat](https://reader034.vdocument.in/reader034/viewer/2022042404/5f1a4a57fbb4845ffe234023/html5/thumbnails/7.jpg)
Matching with Filters
Can SSD be implemented with linear filters?
2
,
)],[],[(],[ lnkmflkgnmhlk
![Page 8: Computer Vision Course Lecture 04 Template Matching Image ...cba-research.com/pdfs/Lecture04-TemplateMatching_CV.pdf · 1. Match template at current scale 2. Downsample image 3. Repeat](https://reader034.vdocument.in/reader034/viewer/2022042404/5f1a4a57fbb4845ffe234023/html5/thumbnails/8.jpg)
Matching with Filters • Goal: find in image
• Method 2: SSD
Input 1- sqrt(SSD)
2
,
)],[],[(],[ lnkmflkgnmhlk
What’s the potential
downside of SSD?
![Page 9: Computer Vision Course Lecture 04 Template Matching Image ...cba-research.com/pdfs/Lecture04-TemplateMatching_CV.pdf · 1. Match template at current scale 2. Downsample image 3. Repeat](https://reader034.vdocument.in/reader034/viewer/2022042404/5f1a4a57fbb4845ffe234023/html5/thumbnails/9.jpg)
Matching with Filters • Goal: find in image
• Method 3: Normalized cross-correlation
5.0
,
2
,
,
2
,
,
)],[()],[(
)],[)(],[(
],[
lk
nm
lk
nm
lk
flnkmfglkg
flnkmfglkg
nmh
Matlab: normxcorr2(template, im)
mean image patch mean template
![Page 10: Computer Vision Course Lecture 04 Template Matching Image ...cba-research.com/pdfs/Lecture04-TemplateMatching_CV.pdf · 1. Match template at current scale 2. Downsample image 3. Repeat](https://reader034.vdocument.in/reader034/viewer/2022042404/5f1a4a57fbb4845ffe234023/html5/thumbnails/10.jpg)
Matching with Filters • Goal: find in image
• Method 3: Normalized cross-correlation
Input Normalized X-Correlation Thresholded Image
True detections
![Page 11: Computer Vision Course Lecture 04 Template Matching Image ...cba-research.com/pdfs/Lecture04-TemplateMatching_CV.pdf · 1. Match template at current scale 2. Downsample image 3. Repeat](https://reader034.vdocument.in/reader034/viewer/2022042404/5f1a4a57fbb4845ffe234023/html5/thumbnails/11.jpg)
Matching with Filters • Goal: find in image
• Method 3: Normalized cross-correlation
Input Normalized X-Correlation Thresholded Image
True detections
![Page 12: Computer Vision Course Lecture 04 Template Matching Image ...cba-research.com/pdfs/Lecture04-TemplateMatching_CV.pdf · 1. Match template at current scale 2. Downsample image 3. Repeat](https://reader034.vdocument.in/reader034/viewer/2022042404/5f1a4a57fbb4845ffe234023/html5/thumbnails/12.jpg)
Q: What is the best method to use?
A: Depends
• SSD: faster, sensitive to overall intensity
• Normalized cross-correlation: slower, invariant to local average intensity and contrast
• But really, neither of these baselines are representative of modern recognition.
![Page 13: Computer Vision Course Lecture 04 Template Matching Image ...cba-research.com/pdfs/Lecture04-TemplateMatching_CV.pdf · 1. Match template at current scale 2. Downsample image 3. Repeat](https://reader034.vdocument.in/reader034/viewer/2022042404/5f1a4a57fbb4845ffe234023/html5/thumbnails/13.jpg)
Q: What if we want to find larger or smaller eyes?
A: Image Pyramid
![Page 14: Computer Vision Course Lecture 04 Template Matching Image ...cba-research.com/pdfs/Lecture04-TemplateMatching_CV.pdf · 1. Match template at current scale 2. Downsample image 3. Repeat](https://reader034.vdocument.in/reader034/viewer/2022042404/5f1a4a57fbb4845ffe234023/html5/thumbnails/14.jpg)
Review of Sampling
Low-Pass Filtered Image
Image
Gaussian
Filter Sample Low-Res Image
![Page 15: Computer Vision Course Lecture 04 Template Matching Image ...cba-research.com/pdfs/Lecture04-TemplateMatching_CV.pdf · 1. Match template at current scale 2. Downsample image 3. Repeat](https://reader034.vdocument.in/reader034/viewer/2022042404/5f1a4a57fbb4845ffe234023/html5/thumbnails/15.jpg)
Gaussian Pyramid
Source: Forsyth
![Page 16: Computer Vision Course Lecture 04 Template Matching Image ...cba-research.com/pdfs/Lecture04-TemplateMatching_CV.pdf · 1. Match template at current scale 2. Downsample image 3. Repeat](https://reader034.vdocument.in/reader034/viewer/2022042404/5f1a4a57fbb4845ffe234023/html5/thumbnails/16.jpg)
Template Matching with Image Pyramids
Input: Image, Template
1. Match template at current scale
2. Downsample image
3. Repeat 1-2 until image is very small
4. Take responses above some threshold, perhaps with non-maxima suppression
![Page 17: Computer Vision Course Lecture 04 Template Matching Image ...cba-research.com/pdfs/Lecture04-TemplateMatching_CV.pdf · 1. Match template at current scale 2. Downsample image 3. Repeat](https://reader034.vdocument.in/reader034/viewer/2022042404/5f1a4a57fbb4845ffe234023/html5/thumbnails/17.jpg)
Coarse-to-Fine Image Registration 1. Compute Gaussian pyramid
2. Align with coarse pyramid
3. Successively align with finer pyramids – Search smaller range
Why is this faster?
Are we guaranteed to get the same result?
![Page 18: Computer Vision Course Lecture 04 Template Matching Image ...cba-research.com/pdfs/Lecture04-TemplateMatching_CV.pdf · 1. Match template at current scale 2. Downsample image 3. Repeat](https://reader034.vdocument.in/reader034/viewer/2022042404/5f1a4a57fbb4845ffe234023/html5/thumbnails/18.jpg)
2D Edge Detection Filters
is the Laplacian operator:
Laplacian of Gaussian
Gaussian derivative of Gaussian
![Page 19: Computer Vision Course Lecture 04 Template Matching Image ...cba-research.com/pdfs/Lecture04-TemplateMatching_CV.pdf · 1. Match template at current scale 2. Downsample image 3. Repeat](https://reader034.vdocument.in/reader034/viewer/2022042404/5f1a4a57fbb4845ffe234023/html5/thumbnails/19.jpg)
Laplacian Filter
Gaussian unit impulse
Laplacian of Gaussian
Source: Lazebnik
![Page 20: Computer Vision Course Lecture 04 Template Matching Image ...cba-research.com/pdfs/Lecture04-TemplateMatching_CV.pdf · 1. Match template at current scale 2. Downsample image 3. Repeat](https://reader034.vdocument.in/reader034/viewer/2022042404/5f1a4a57fbb4845ffe234023/html5/thumbnails/20.jpg)
Computing Gaussian/Laplacian Pyramid
http://sepwww.stanford.edu/~morgan/texturematch/paper_html/node3.html
Can we reconstruct the original
from the laplacian pyramid?
![Page 21: Computer Vision Course Lecture 04 Template Matching Image ...cba-research.com/pdfs/Lecture04-TemplateMatching_CV.pdf · 1. Match template at current scale 2. Downsample image 3. Repeat](https://reader034.vdocument.in/reader034/viewer/2022042404/5f1a4a57fbb4845ffe234023/html5/thumbnails/21.jpg)
Laplacian pyramid
Source: Forsyth
![Page 22: Computer Vision Course Lecture 04 Template Matching Image ...cba-research.com/pdfs/Lecture04-TemplateMatching_CV.pdf · 1. Match template at current scale 2. Downsample image 3. Repeat](https://reader034.vdocument.in/reader034/viewer/2022042404/5f1a4a57fbb4845ffe234023/html5/thumbnails/22.jpg)
Major uses of image pyramids
• Compression
• Object detection – Scale search – Features
• Detecting stable interest points
• Registration – Course-to-fine
![Page 23: Computer Vision Course Lecture 04 Template Matching Image ...cba-research.com/pdfs/Lecture04-TemplateMatching_CV.pdf · 1. Match template at current scale 2. Downsample image 3. Repeat](https://reader034.vdocument.in/reader034/viewer/2022042404/5f1a4a57fbb4845ffe234023/html5/thumbnails/23.jpg)
Application: Representing Texture
Source: Forsyth
![Page 24: Computer Vision Course Lecture 04 Template Matching Image ...cba-research.com/pdfs/Lecture04-TemplateMatching_CV.pdf · 1. Match template at current scale 2. Downsample image 3. Repeat](https://reader034.vdocument.in/reader034/viewer/2022042404/5f1a4a57fbb4845ffe234023/html5/thumbnails/24.jpg)
Texture and Material
http://www-cvr.ai.uiuc.edu/ponce_grp/data/texture_database/samples/
![Page 25: Computer Vision Course Lecture 04 Template Matching Image ...cba-research.com/pdfs/Lecture04-TemplateMatching_CV.pdf · 1. Match template at current scale 2. Downsample image 3. Repeat](https://reader034.vdocument.in/reader034/viewer/2022042404/5f1a4a57fbb4845ffe234023/html5/thumbnails/25.jpg)
Texture and Orientation
http://www-cvr.ai.uiuc.edu/ponce_grp/data/texture_database/samples/
![Page 26: Computer Vision Course Lecture 04 Template Matching Image ...cba-research.com/pdfs/Lecture04-TemplateMatching_CV.pdf · 1. Match template at current scale 2. Downsample image 3. Repeat](https://reader034.vdocument.in/reader034/viewer/2022042404/5f1a4a57fbb4845ffe234023/html5/thumbnails/26.jpg)
Texture and Scale
http://www-cvr.ai.uiuc.edu/ponce_grp/data/texture_database/samples/
![Page 27: Computer Vision Course Lecture 04 Template Matching Image ...cba-research.com/pdfs/Lecture04-TemplateMatching_CV.pdf · 1. Match template at current scale 2. Downsample image 3. Repeat](https://reader034.vdocument.in/reader034/viewer/2022042404/5f1a4a57fbb4845ffe234023/html5/thumbnails/27.jpg)
What is texture?
Regular or stochastic patterns caused by bumps, grooves, and/or markings
![Page 28: Computer Vision Course Lecture 04 Template Matching Image ...cba-research.com/pdfs/Lecture04-TemplateMatching_CV.pdf · 1. Match template at current scale 2. Downsample image 3. Repeat](https://reader034.vdocument.in/reader034/viewer/2022042404/5f1a4a57fbb4845ffe234023/html5/thumbnails/28.jpg)
How can we represent texture?
• Compute responses of blobs and edges at various orientations and scales
![Page 29: Computer Vision Course Lecture 04 Template Matching Image ...cba-research.com/pdfs/Lecture04-TemplateMatching_CV.pdf · 1. Match template at current scale 2. Downsample image 3. Repeat](https://reader034.vdocument.in/reader034/viewer/2022042404/5f1a4a57fbb4845ffe234023/html5/thumbnails/29.jpg)
Overcomplete representation: filter banks
LM Filter Bank
Code for filter banks: www.robots.ox.ac.uk/~vgg/research/texclass/filters.html
![Page 30: Computer Vision Course Lecture 04 Template Matching Image ...cba-research.com/pdfs/Lecture04-TemplateMatching_CV.pdf · 1. Match template at current scale 2. Downsample image 3. Repeat](https://reader034.vdocument.in/reader034/viewer/2022042404/5f1a4a57fbb4845ffe234023/html5/thumbnails/30.jpg)
Filter banks
• Process image with each filter and keep responses (or squared/abs responses)
![Page 31: Computer Vision Course Lecture 04 Template Matching Image ...cba-research.com/pdfs/Lecture04-TemplateMatching_CV.pdf · 1. Match template at current scale 2. Downsample image 3. Repeat](https://reader034.vdocument.in/reader034/viewer/2022042404/5f1a4a57fbb4845ffe234023/html5/thumbnails/31.jpg)
How can we represent texture?
• Measure responses of blobs and edges at various orientations and scales
• Idea 1: Record simple statistics (e.g., mean, std.) of absolute filter responses
![Page 32: Computer Vision Course Lecture 04 Template Matching Image ...cba-research.com/pdfs/Lecture04-TemplateMatching_CV.pdf · 1. Match template at current scale 2. Downsample image 3. Repeat](https://reader034.vdocument.in/reader034/viewer/2022042404/5f1a4a57fbb4845ffe234023/html5/thumbnails/32.jpg)
Can you match the texture to the response?
Mean abs responses
Filters A
B
C
1
2
3
![Page 33: Computer Vision Course Lecture 04 Template Matching Image ...cba-research.com/pdfs/Lecture04-TemplateMatching_CV.pdf · 1. Match template at current scale 2. Downsample image 3. Repeat](https://reader034.vdocument.in/reader034/viewer/2022042404/5f1a4a57fbb4845ffe234023/html5/thumbnails/33.jpg)
Representing texture by mean abs response
Mean abs responses
Filters
![Page 34: Computer Vision Course Lecture 04 Template Matching Image ...cba-research.com/pdfs/Lecture04-TemplateMatching_CV.pdf · 1. Match template at current scale 2. Downsample image 3. Repeat](https://reader034.vdocument.in/reader034/viewer/2022042404/5f1a4a57fbb4845ffe234023/html5/thumbnails/34.jpg)
Representing texture
• Idea 2: take vectors of filter responses at each pixel and cluster them, then take histograms (more on in later weeks)
![Page 35: Computer Vision Course Lecture 04 Template Matching Image ...cba-research.com/pdfs/Lecture04-TemplateMatching_CV.pdf · 1. Match template at current scale 2. Downsample image 3. Repeat](https://reader034.vdocument.in/reader034/viewer/2022042404/5f1a4a57fbb4845ffe234023/html5/thumbnails/35.jpg)
Course Outline Image Formation and Processing Light, Shape and Color
The Pin-hole Camera Model, The Digital Camera
Linear filtering, Template Matching, Image Pyramids
Feature Detection and Matching Edge Detection, Interest Points: Corners and Blobs
Local Image Descriptors
Feature Matching and Hough Transform
Multiple Views and Motion Geometric Transformations, Camera Calibration
Feature Tracking , Stereo Vision
Segmentation and Grouping Segmentation by Clustering, Region Merging and Growing
Advanced Methods Overview: Active Contours, Level-Sets, Graph-Theoretic Methods
Detection and Recognition Problems and Architectures Overview
Statistical Classifiers, Bag-of-Words Model, Detection by Sliding Windows
49 CBA Research Computer Vision
![Page 36: Computer Vision Course Lecture 04 Template Matching Image ...cba-research.com/pdfs/Lecture04-TemplateMatching_CV.pdf · 1. Match template at current scale 2. Downsample image 3. Repeat](https://reader034.vdocument.in/reader034/viewer/2022042404/5f1a4a57fbb4845ffe234023/html5/thumbnails/36.jpg)
Resources
Books R. Szeliski, Computer Vision: Algorithms and Applications, 2010 – available online
D. A. Forsyth and J. Ponce, Computer Vision: A Modern Approach, 2003
L. G. Shapiro and G. C. Stockman, Computer Vision, 2001
Web CVonline: The Evolving, Distributed, Non-Proprietary, On-Line Compendium of Computer Vision
http://homepages.inf.ed.ac.uk/rbf/CVonline/
Dictionary of Computer Vision and Image Processing
http://homepages.inf.ed.ac.uk/rbf/CVDICT/
Computer Vision Online
http://www.computervisiononline.com/
Programming Development environments/languages: Matlab, Python and C/C++
Toolboxes and APIs: OpenCV, VLFeat Matlab Toolbox, Piotr's Computer Vision Matlab Toolbox, EasyCamCalib Software, FLANN, Point Cloud Library PCL, LibSVM, Camera Calibration Toolbox for Matlab
CBA Research Computer Vision 50