Fitting a transformation featurebased alignment Disclaimer Many slides
Fitting a transformation: feature-based alignment Disclaimer: Many slides have been borrowed from Kristen Grauman, who may have borrowed some of them from others. Any time a slide did not already have a credit on it, I have credited it to Kristen. So there is a chance some of these credits are inaccurate. Slide credit: Kristen Grauman 1
Announcements PS 0 due last night imshow/imagesc can show a heatmap Warmup assignment If canvas marks an assignment as late, it will be considered to be late (No “buffer”! That’s the whole point of free late days!) • Will consider the latest submission (to grade, to assess late vs. not, etc. ) • Piazza – Sign up to get 1% of the grade – Keep an eye out on the forum – Check if a question has been asked answered already • Look things up a bit yourself first • • Slide credit: Kristen Grauman 2
Topics overview • Class Intro – Color – Alignment and 2 D image transformations • • • Multiple views and motion Features & filters Grouping & fitting Recognition Video processing Slide credit: Kristen Grauman 3
Topics overview • Class Intro – Color – Alignment and 2 D image transformations • • • Multiple views and motion Features & filters Grouping & fitting Recognition Video processing Slide credit: Kristen Grauman 4
Today • Feature-based alignment – 2 D transformations – Affine fit – RANSAC 5 Slide credit: Kristen Grauman
Motivation: Recognition 6 Slide credit: Kristen Grauman Figures from David Lowe
Motivation: medical image registration 7 Slide credit: Kristen Grauman
Motivation: mosaics (In detail next week) 8 Slide credit: Kristen Grauman Image from http: //graphics. cmu. edu/courses/15 -463/2010_fall/
Alignment problem • In alignment, we will fit the parameters of some transformation according to a set of matching feature pairs (“correspondences”). xi xi ' T Slide credit: Kristen Grauman 10
Parametric (global) warping Examples of parametric warps: aspect rotation translation affine perspective 11 Source: Alyosha Efros
Parametric (global) warping T p = (x, y) p’ = (x’, y’) Transformation T is a coordinate-changing machine: p’ = T(p) What does it mean that T is global? • Is the same for any point p • can be described by just a few numbers (parameters) Let’s represent T as a matrix: p’ = Mp 12 Source: Alyosha Efros
Scaling a coordinate means multiplying each of its components by a scalar Uniform scaling means this scalar is the same for all components: 2 13 Source: Alyosha Efros
Scaling Non-uniform scaling: different scalars per component: X 2, Y 0. 5 14 Source: Alyosha Efros
Scaling operation: Or, in matrix form: scaling matrix S 15 Source: Alyosha Efros
What transformations can be represented with a 2 x 2 matrix? 2 D Scaling? 2 D Rotate around (0, 0)? 2 D Shear? 16 Source: Alyosha Efros
What transformations can be represented with a 2 x 2 matrix? 2 D Mirror about Y axis? 2 D Mirror over (0, 0)? 2 D Translation? NO! 17 Source: Alyosha Efros
2 D Linear Transformations Only linear 2 D transformations can be represented with a 2 x 2 matrix. Linear transformations are combinations of … • Scale, • Rotation, • Shear, and • Mirror 18 Source: Alyosha Efros
Homogeneous coordinates To convert to homogeneous coordinates: homogeneous image coordinates Converting from homogeneous coordinates 19 Slide credit: Kristen Grauman
Homogeneous Coordinates Q: How can we represent 2 d translation as a 3 x 3 matrix using homogeneous coordinates? A: Using the rightmost column: 20 Source: Alyosha Efros
Translation Homogeneous Coordinates tx = 2 ty = 1 21 Source: Alyosha Efros
Basic 2 D Transformations Basic 2 D transformations as 3 x 3 matrices Translate Scale Rotate Shear 22 Source: Alyosha Efros
2 D Affine Transformations Affine transformations are combinations of … • Linear transformations, and • Translations Parallel lines remain parallel 23 Slide credit: Kristen Grauman
Today • Feature-based alignment – 2 D transformations – Affine fit – RANSAC 24 Slide credit: Kristen Grauman
Alignment problem • In alignment, we will fit the parameters of some transformation according to a set of matching feature pairs (“correspondences”). xi xi ' T 26 Kristen Grauman
Image alignment • Two broad approaches: – Direct (pixel-based) alignment • Search for alignment where most pixels agree – Feature-based alignment • Search for alignment where extracted features agree • Can be verified using pixel-based alignment Slide credit: Kristen Grauman 27
Fitting an affine transformation • Assuming we know the correspondences, how do we get the transformation? 28 Slide credit: Kristen Grauman
An aside: Least Squares Example Say we have a set of data points (X 1, X 1’), (X 2, X 2’), (X 3, X 3’), etc. (e. g. person’s height vs. weight) We want a nice compact formula (a line) to predict X’s from Xs: Xa + b = X’ We want to find a and b How many (X, X’) pairs do we need? Ax=B What if the data is noisy? overconstrained 29 Source: Alyosha Efros
Fitting an affine transformation • Assuming we know the correspondences, how do we get the transformation? 30 Slide credit: Kristen Grauman
Fitting an affine transformation • How many matches (correspondence pairs) do we need to solve for the transformation parameters? • Once we have solved for the parameters, how do we compute the coordinates of the corresponding point for ? • Where do the matches come from? 31 Kristen Grauman
What are the correspondences? ? • Compare content in local patches, find best matches. e. g. , simplest approach: scan with template, and compute SSD or correlation between list of pixel intensities in the patch • Later in the course: how to select regions according to the geometric changes, and more robust descriptors. 32 Kristen Grauman
Fitting an affine transformation Affine model approximates perspective projection of planar objects. 33 Slide credit: Kristen Grauman Figures from David Lowe, ICCV 1999
Today • Feature-based alignment – 2 D transformations – Affine fit – RANSAC 34 Slide credit: Kristen Grauman
Outliers • Outliers can hurt the quality of our parameter estimates, e. g. , – an erroneous pair of matching points from two images – an edge point that is noise, or doesn’t belong to the line we are fitting. 35 Kristen Grauman
Outliers affect least squares fit 36 Slide credit: Kristen Grauman
Outliers affect least squares fit 37 Slide credit: Kristen Grauman
RANSAC • RANdom Sample Consensus • Approach: we want to avoid the impact of outliers, so let’s look for “inliers”, and use those only. • Intuition: if an outlier is chosen to compute the current fit, then the resulting line won’t have much support from rest of the points. 38 Slide credit: Kristen Grauman
RANSAC: General form • RANSAC loop: 1. Randomly select a seed group of points on which to base transformation estimate (e. g. , a group of matches) 2. Compute transformation from seed group 3. Find inliers to this transformation 4. If the number of inliers is sufficiently large, re-compute estimate of transformation on all of the inliers • Keep the transformation with the largest number of inliers 39 Slide credit: Kristen Grauman
RANSAC for line fitting example 40 Source: R. Raguram Lana Lazebnik
RANSAC for line fitting example Least-squares fit 41 Source: R. Raguram Lana Lazebnik
RANSAC for line fitting example 1. Randomly select minimal subset of points 42 Source: R. Raguram Lana Lazebnik
RANSAC for line fitting example 1. Randomly select minimal subset of points 2. Hypothesize a model 43 Source: R. Raguram Lana Lazebnik
RANSAC for line fitting example 1. Randomly select minimal subset of points 2. Hypothesize a model 3. Compute error function 44 Source: R. Raguram Lana Lazebnik
RANSAC for line fitting example 1. Randomly select minimal subset of points 2. Hypothesize a model 3. Compute error function 4. Select points consistent with model 45 Source: R. Raguram Lana Lazebnik
RANSAC for line fitting example 1. Randomly select minimal subset of points 2. Hypothesize a model 3. Compute error function 4. Select points consistent with model 5. Repeat hypothesize-andverify loop 46 Source: R. Raguram Lana Lazebnik
RANSAC for line fitting example 1. Randomly select minimal subset of points 2. Hypothesize a model 3. Compute error function 4. Select points consistent with model 5. Repeat hypothesize-andverify loop 47 Source: R. Raguram Lana Lazebnik
RANSAC for line fitting example Uncontaminated sample 1. Randomly select minimal subset of points 2. Hypothesize a model 3. Compute error function 4. Select points consistent with model 5. Repeat hypothesize-andverify loop 48 Source: R. Raguram Lana Lazebnik
RANSAC for line fitting example 1. Randomly select minimal subset of points 2. Hypothesize a model 3. Compute error function 4. Select points consistent with model 5. Repeat hypothesize-andverify loop 49 Source: R. Raguram Lana Lazebnik
RANSAC for line fitting Repeat N times: • Draw s points uniformly at random • Fit line to these s points • Find inliers to this line among the remaining points (i. e. , points whose distance from the line is less than t) • If there are d or more inliers, accept the line and refit using all inliers 50 Lana Lazebnik
RANSAC pros and cons • Pros • Simple and general • Applicable to many different problems • Often works well in practice • Cons • Lots of parameters to tune • Doesn’t work well for low inlier ratios (too many iterations, or can fail completely) • Can’t always get a good initialization of the model based on the minimum number of samples 51 Lana Lazebnik
Today • Feature-based alignment – 2 D transformations – Affine fit – RANSAC 52 Slide credit: Kristen Grauman
Coming up: alignment and image stitching Slide credit: Kristen Grauman 53
Questions? See you Thursday! 54 Slide credit: Devi Parikh
- Slides: 52