776 Computer Vision Jan-Michael Frahm.

Slides:



Advertisements
Similar presentations
Fitting: The Hough transform. Voting schemes Let each feature vote for all the models that are compatible with it Hopefully the noise features will not.
Advertisements

Feature Matching and Robust Fitting Computer Vision CS 143, Brown James Hays Acknowledgment: Many slides from Derek Hoiem and Grauman&Leibe 2008 AAAI Tutorial.
776 Computer Vision Jan-Michael Frahm, Enrique Dunn Spring 2013.
Photo by Carl Warner.
776 Computer Vision Jared Heinly Spring 2014 (slides borrowed from Jan-Michael Frahm, Svetlana Lazebnik, and others)
Fitting: The Hough transform
CS 558 C OMPUTER V ISION Lecture VIII: Fitting, RANSAC, and Hough Transform Adapted from S. Lazebnik.
Fitting. We’ve learned how to detect edges, corners, blobs. Now what? We would like to form a higher-level, more compact representation of the features.
Fitting: Concepts and recipes. Review: The Hough transform What are the steps of a Hough transform? What line parametrization is best for the Hough transform?
Fitting a Model to Data Reading: 15.1,
Fitting. Choose a parametric object/some objects to represent a set of tokens Most interesting case is when criterion is not local –can’t tell whether.
Fitting: The Hough transform
Robust estimation Problem: we want to determine the displacement (u,v) between pairs of images. We are given 100 points with a correlation score computed.
Lecture 10: Robust fitting CS4670: Computer Vision Noah Snavely.
Fitting.
כמה מהתעשייה? מבנה הקורס השתנה Computer vision.
Fitting and Registration
Computer Vision Spring ,-685 Instructor: S. Narasimhan Wean Hall 5409 T-R 10:30am – 11:50am.
CSE 185 Introduction to Computer Vision
Computer Vision - Fitting and Alignment
Fitting and Registration Computer Vision CS 543 / ECE 549 University of Illinois Derek Hoiem 02/14/12.
Fitting: The Hough transform. Voting schemes Let each feature vote for all the models that are compatible with it Hopefully the noise features will not.
Fitting & Matching Lecture 4 – Prof. Bregler Slides from: S. Lazebnik, S. Seitz, M. Pollefeys, A. Effros.
Photo by Carl Warner. Feature Matching and Robust Fitting Computer Vision James Hays Acknowledgment: Many slides from Derek Hoiem and Grauman&Leibe.
CS 1699: Intro to Computer Vision Matching and Fitting Prof. Adriana Kovashka University of Pittsburgh September 29, 2015.
CS654: Digital Image Analysis Lecture 25: Hough Transform Slide credits: Guillermo Sapiro, Mubarak Shah, Derek Hoiem.
776 Computer Vision Jan-Michael Frahm, Enrique Dunn Spring 2013.
Fitting: The Hough transform
Model Fitting Computer Vision CS 143, Brown James Hays 10/03/11 Slides from Silvio Savarese, Svetlana Lazebnik, and Derek Hoiem.
Edge Detection and Geometric Primitive Extraction Jinxiang Chai.
EECS 274 Computer Vision Model Fitting. Fitting Choose a parametric object/some objects to represent a set of points Three main questions: –what object.
Computer Vision - Fitting and Alignment (Slides borrowed from various presentations)
CSE 185 Introduction to Computer Vision Feature Matching.
776 Computer Vision Jan-Michael Frahm Spring 2012.
CS 2750: Machine Learning Linear Regression Prof. Adriana Kovashka University of Pittsburgh February 10, 2016.
Robust Estimation Course web page: vision.cis.udel.edu/~cv April 23, 2003  Lecture 25.
Fitting.
Hough Transform CS 691 E Spring Outline Hough transform Homography Reading: FP Chapter 15.1 (text) Some slides from Lazebnik.
CS 558 C OMPUTER V ISION Fitting, RANSAC, and Hough Transfrom Adapted from S. Lazebnik.
776 Computer Vision Jan-Michael Frahm Spring 2012.
CS 2770: Computer Vision Fitting Models: Hough Transform & RANSAC
Segmentation by fitting a model: Hough transform and least squares
SIFT Scale-Invariant Feature Transform David Lowe
CS 4501: Introduction to Computer Vision Sparse Feature Descriptors: SIFT, Model Fitting, Panorama Stitching. Connelly Barnes Slides from Jason Lawrence,
Fitting a transformation: feature-based alignment
Fitting: Voting and the Hough Transform
Fitting.
Line Fitting James Hayes.
Fitting: The Hough transform
Exercise Class 11: Robust Tecuniques RANSAC, Hough Transform
Lecture 7: Image alignment
CS 2750: Machine Learning Linear Regression
A special case of calibration
Fitting Curve Models to Edges
Fitting.
Computer Vision - A Modern Approach
Photo by Carl Warner.
Prof. Adriana Kovashka University of Pittsburgh October 19, 2016
Photo by Carl Warner.
Segmentation by fitting a model: robust estimators and RANSAC
Fitting CS 678 Spring 2018.
SIFT.
Introduction to Sensor Interpretation
CSE 185 Introduction to Computer Vision
Introduction to Sensor Interpretation
Calibration and homographies
CS5760: Computer Vision Lecture 9: RANSAC Noah Snavely
CS5760: Computer Vision Lecture 9: RANSAC Noah Snavely
Image Stitching Linda Shapiro ECE/CSE 576.
Image Stitching Linda Shapiro ECE P 596.
Presentation transcript:

776 Computer Vision Jan-Michael Frahm

Stopped here!!!

Fitting

Fitting

9300 Harris Corners Pkwy, Charlotte, NC Fitting We’ve learned how to detect edges, corners. Now what? We would like to form a higher-level, more compact representation of the features in the image by grouping multiple features according to a simple model 9300 Harris Corners Pkwy, Charlotte, NC

Fitting Choose a parametric model to represent a set of features simple model: lines simple model: circles complicated model: car

Case study: Line detection Fitting: Issues Case study: Line detection Noise in the measured feature locations Extraneous data: clutter (outliers), multiple lines Missing data: occlusions

Last Class: Correspondence There are two principled ways for finding correspondences: Matching Independent detection of features in each frame Correspondence search over detected features Extends to large transformations between images High error rate for correspondences Tracking Detect features in one frame Retrieve same features in the next frame by searching for equivalent feature (tracking) Very precise correspondences High percentage of correct correspondences Only works for small changes in between frames

Fitting: Overview If we know which points belong to the line, how do we find the “optimal” line parameters? Least squares What if there are outliers? Robust fitting, RANSAC What if there are many lines? Voting methods: RANSAC, Hough transform What if we’re not even sure it’s a line? Model selection

Least squares line fitting Data: (x1, y1), …, (xn, yn) Line equation: yi = m xi + b Find (m, b) to minimize y=mx+b (xi, yi) Normal equations: least squares solution to XB=Y

Problem with “vertical” least squares Not rotation-invariant Fails completely for vertical lines

Total least squares ax+by=d (xi, yi) Distance between point (xi, yi) and line ax+by=d (a2+b2=1): |axi + byi – d| Find (a, b, d) to minimize the sum of squared perpendicular distances ax+by=d Unit normal: N=(a, b) (xi, yi) Total least squares: observational errors on both dependent and independent variables are taken into account. Solution to (UTU)N = 0, subject to ||N||2 = 1: eigenvector of UTU associated with the smallest eigenvalue (least squares solution to homogeneous linear system UN = 0)

Total least squares second moment matrix

Total least squares second moment matrix N = (a, b)

Least squares as likelihood maximization Generative model: line points are sampled independently and corrupted by Gaussian noise in the direction perpendicular to the line ax+by=d (u, v) ε (x, y) point on the line normal direction noise: sampled from zero-mean Gaussian with std. dev. σ

Least squares as likelihood maximization Generative model: line points are sampled independently and corrupted by Gaussian noise in the direction perpendicular to the line ax+by=d (u, v) ε (x, y) Likelihood of points given line parameters (a, b, d): Log-likelihood:

Least squares: Robustness to noise Least squares fit to the red points:

Least squares: Robustness to noise Least squares fit with an outlier: Problem: squared error heavily penalizes outliers

Robust estimators General approach: find model parameters θ that minimize ri (xi, θ) – residual of i-th point w.r.t. model parameters θ ρ – robust function with scale parameter σ The robust function ρ behaves like squared distance for small values of the residual u but saturates for larger values of u

Choosing the scale: Just right Fit to earlier data with an appropriate choice of s The effect of the outlier is minimized

Choosing the scale: Too small The error value is almost the same for every point and the fit is very poor

Choosing the scale: Too large Behaves much the same as least squares

Robust estimation: Details Robust fitting is a nonlinear optimization problem that must be solved iteratively Least squares solution can be used for initialization Adaptive choice of scale: approx. 1.5 times median residual (F&P, Sec. 15.5.1)

RANSAC Robust fitting can deal with a few outliers – what if we have very many? Random sample consensus (RANSAC): Very general framework for model fitting in the presence of outliers Outline Choose a small subset of points uniformly at random Fit a model to that subset Find all remaining points that are “close” to the model and reject the rest as outliers Do this many times and choose the best model This algorithm contains concepts that are hugely useful; in my experience, everyone with some experience of applied problems who doesn’t yet know RANSAC is almost immediately able to use it to simplify some problem they’ve seen. M. A. Fischler, R. C. Bolles. Random Sample Consensus: A Paradigm for Model Fitting with Applications to Image Analysis and Automated Cartography. Comm. of the ACM, Vol 24, pp 381-395, 1981.

RANSAC for line fitting example

RANSAC for line fitting example Least-squares fit

RANSAC for line fitting example Randomly select minimal subset of points

RANSAC for line fitting example Randomly select minimal subset of points Hypothesize a model

RANSAC for line fitting example Randomly select minimal subset of points Hypothesize a model Compute error function Source: R. Raguram

RANSAC for line fitting example Randomly select minimal subset of points Hypothesize a model Compute error function Select points consistent with model

RANSAC for line fitting example Randomly select minimal subset of points Hypothesize a model Compute error function Select points consistent with model Repeat hypothesize-and-verify loop

RANSAC for line fitting example Randomly select minimal subset of points Hypothesize a model Compute error function Select points consistent with model Repeat hypothesize-and-verify loop

RANSAC for line fitting example Uncontaminated sample Randomly select minimal subset of points Hypothesize a model Compute error function Select points consistent with model Repeat hypothesize-and-verify loop

RANSAC for line fitting example Randomly select minimal subset of points Hypothesize a model Compute error function Select points consistent with model Repeat hypothesize-and-verify loop 35

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 this estimate has the most inliers so far, accept the line and refit using all inliers

Choosing the parameters Initial number of points s Typically minimum number needed to fit the model Distance threshold t Choose t so probability for inlier is p (e.g. 0.95) Zero-mean Gaussian noise with std. dev. σ: t2=3.84σ2 Number of samples N Choose N so that, with probability p, at least one random sample is free from outliers (e.g. p=0.99) (outlier ratio: e)

Choosing the parameters Initial number of points s Typically minimum number needed to fit the model Distance threshold t Choose t so probability for inlier is p (e.g. 0.95) Zero-mean Gaussian noise with std. dev. σ: t2=3.84σ2 Number of samples N Choose N so that, with probability p, at least one random sample is free from outliers (e.g. p=0.99) (outlier ratio: e) proportion of outliers e s 5% 10% 20% 25% 30% 40% 50% 2 3 5 6 7 11 17 4 9 19 35 13 34 72 12 26 57 146 16 24 37 97 293 8 20 33 54 163 588 44 78 272 1177

Choosing the parameters Initial number of points s Typically minimum number needed to fit the model Distance threshold t Choose t so probability for inlier is p (e.g. 0.95) Zero-mean Gaussian noise with std. dev. σ: t2=3.84σ2 Number of samples N Choose N so that, with probability p, at least one random sample is free from outliers (e.g. p=0.99) (outlier ratio: e) N outlier ratio e

Choosing the parameters Initial number of points s Typically minimum number needed to fit the model Distance threshold t Choose t so probability for inlier is p (e.g. 0.95) Zero-mean Gaussian noise with std. dev. σ: t2=3.84σ2 Number of samples N Choose N so that, with probability p, at least one random sample is free from outliers (e.g. p=0.99) (outlier ratio: e) Consensus set size d Should match expected inlier ratio

Adaptively determining the number of samples Inlier ratio (1-e) is often unknown a priori, so pick worst case, e.g. 10%, and adapt if more inliers are found, e.g. 80% would yield e=0.2 Adaptive procedure: N=∞, sample_count =0 While N >sample_count Choose a sample and count the number of inliers Set e = 1 – (number of inliers)/(total number of points) Recompute N from e: Increment the sample count by 1

RANSAC pros and cons Pros Cons 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

Threshold free Robust Estimation Problem: Robust Estimation Estimation of model parameters in the presence of noise and outliers Homography Match points Run RANSAC, threshold ≈ 1 - 2 pixels Common approach:

Motivation 3D similarity Match points Run RANSAC , threshold = ?

Motivation t = 0.001 t = 0.01 t = 0.5 t = 5.0 Robust estimation algorithms often require data and/or model specific threshold settings Performance degrades when parameter settings deviate from the “true” values (Torr and Zisserman 2000, Choi and Medioni 2009)

RECON Instead of per-model or point-based residual analysis Inspect pairs of models Sort points by distance to model Inlier Outlier “Inlier” models

RECON Instead of per-model or point-based residual analysis Inspect pairs of models Sort points by distance to model Inlier Outlier “Outlier” models

RECON Instead of per-model or point-based residual analysis Inspect pairs of models Inlier models Outlier models “Consistent” behaviour Random permutations of data points

RECON Instead of per-model or point-based residual analysis Inspect pairs of models Inlier models Outlier models “Consistent” behaviour Random permutations of data points “Happy families are all alike; every unhappy family is unhappy in its own way” - Leo Tolstoy, Anna Karenina

RECON Instead of per-model or point-based residual analysis Inspect pairs of models Inlier models Outlier models “Consistent” behaviour Random permutations of data points “Happy families are all alike; every unhappy family is unhappy in its own way” - Leo Tolstoy, Anna Karenina

RECON Instead of per-model or point-based residual analysis Inspect pairs of models Inlier models Outlier models “Consistent” behaviour Random permutations of data points “Happy families are all alike; every unhappy family is unhappy in its own way” - Leo Tolstoy, Anna Karenina

RECON How can we characterize this behaviour? Assuming that measurement error is Gaussian Inlier residuals are distributed If σ is known, can compute threshold t that finds some fraction α of all inliers Typically set to 0.95 or 0.99 αI t Large overlap At the “true” threshold, inlier models capture a stable set of points

RECON How can we characterize this behaviour? What if σ is unknown? Hypothesize values of noise scale σ t = ? t1 t2 t3 t4 ... tT

RECON How can we characterize this behaviour? What if σ is unknown? Hypothesize values of noise scale σ θt : fraction of common points θt t t

RECON How can we characterize this behaviour? What if σ is unknown? Hypothesize values of noise scale σ θt θt θt θt θt θt θt θt θt θt θt θt θt t

RECON At the “true” value of the threshold 1. A fraction ≈ α2 of the inliers will be common to inlier models θt θt θt θt θt θt θt θt θt θt θt θt θt α2 t

RECON At the “true” value of the threshold 1. A fraction ≈ α2 of the inliers will be common to inlier models 2. The inlier residuals correspond to the same underlying distribution θt θt θt θt θt θt θt θt θt θt θt θt θt t

RECON At the “true” value of the threshold 1. A fraction ≈ α2 of the inliers will be common to inlier models 2. The inlier residuals correspond to the same underlying distribution Outlier models θt Overlap is low at the true threshold Overlap can be high for a large overestimate of the noise scale Residuals are unlikely to correspond to the same underlying distribution t

RECON At the “true” value of the threshold 1. A fraction ≈ α2 of the inliers will be common to inlier models 2. The inlier residuals correspond to the same underlying distribution 𝜶 -consistency

Residual Consensus: Algorithm 1. Hypothesis generation - Generate model Mi from random minimal sample 2. Model evaluation - Compute and store residuals of Mi to all data points 3. Test α – consistency - For a pair of models Mi and Mj Check if overlap ≈ α2 for some t Check if residuals come from the same distribution Similar to RANSAC

Residual Consensus: Algorithm 1. Hypothesis generation - Generate model Mi from random minimal sample 2. Model evaluation - Compute and store residuals of Mi to all data points 3. Test α – consistency - For a pair of models Mi and Mj Check if overlap ≈ α2 for some t Check if residuals come from the same distribution Find consistent pairs of models Efficient implementation: use residual ordering Single pass over sorted residuals

Residual Consensus: Algorithm 1. Hypothesis generation - Generate model Mi from random minimal sample 2. Model evaluation - Compute and store residuals of Mi to all data points 3. Test α – consistency - For a pair of models Mi and Mj Check if overlap ≈ α2 for some t Check if residuals come from the same distribution Find consistent pairs of models Two-sample Kolmogorov-Smirnov test Reject null hypothesis at level β if

Residual Consensus: Algorithm 1. Hypothesis generation - Generate model Mi from random minimal sample 2. Model evaluation - Compute and store residuals of Mi to all data points 3. Test α – consistency - For a pair of models Mi and Mj Check if overlap ≈ α2 for some t Check if residuals come from the same distribution Repeat until K pairwise-consistent models are found

Residual Consensus: Algorithm 1. Hypothesis generation - Generate model Mi from random minimal sample 2. Model evaluation - Compute and store residuals of Mi to all data points 3. Test α – consistency - For a pair of models Mi and Mj Check if overlap ≈ α2 for some t Check if residuals come from the same distribution 4. Refine solution - Recompute final model and inliers Repeat until K pairwise-consistent models are found

Experiments Real data

RECON Conclusion RECON is Flexible: no data/model dependent threshold settings Inlier threshold Inlier ratio Accurate: achieves results of the same quality as RANSAC without apriori knowledge of the noise parameters Efficient: adapts to the inlier ratio in the data Extensible: Can be combined with other RANSAC optimizations (non-uniform sampling, degeneracy handling, etc.) Code: http://cs.unc.edu/~rraguram/recon

Fitting: The Hough transform

Voting schemes Let each feature vote for all the models that are compatible with it Hopefully noisy features will not vote consistently for any single model Missing data doesn’t matter as long as there are enough features remaining to agree on a good model

Hough transform An early type of voting scheme General outline: Discretize parameter space into bins For each feature point in the image, put a vote in every bin in the parameter space that could have generated this point Find bins that have the most votes Image space Hough parameter space P.V.C. Hough, Machine Analysis of Bubble Chamber Pictures, Proc. Int. Conf. High Energy Accelerators and Instrumentation, 1959

Parameter space representation A line in the image corresponds to a point in Hough space Image space Hough parameter space

Parameter space representation What does a point (x0, y0) in the image space map to in the Hough space? Image space Hough parameter space

Parameter space representation What does a point (x0, y0) in the image space map to in the Hough space? Answer: the solutions of b = –x0m + y0 This is a line in Hough space Image space Hough parameter space

Parameter space representation Where is the line that contains both (x0, y0) and (x1, y1)? Image space Hough parameter space (x1, y1) (x0, y0) b = –x1m + y1 Slide credit: S. Lazebnik

Parameter space representation Where is the line that contains both (x0, y0) and (x1, y1)? It is the intersection of the lines b = –x0m + y0 and b = –x1m + y1 Image space Hough parameter space (x1, y1) (x0, y0) b = –x1m + y1

Parameter space representation Problems with the (m,b) space: Unbounded parameter domain Vertical lines require infinite m

Parameter space representation Problems with the (m,b) space: Unbounded parameter domain Vertical lines require infinite m Alternative: polar representation Each point will add a sinusoid in the (,) parameter space

Algorithm outline Initialize accumulator H to all zeros For each edge point (x,y) in the image For θ = 0 to 180 ρ = x cos θ + y sin θ H(θ, ρ) = H(θ, ρ) + 1 end end Find the value(s) of (θ, ρ) where H(θ, ρ) is a local maximum The detected line in the image is given by ρ = x cos θ + y sin θ ρ θ

Basic illustration features votes Slide credit: S. Lazebnik Figure 15.1, top half. Note that most points in the vote array are very dark, because they get only one vote. features votes Slide credit: S. Lazebnik

Other shapes Square

Other shapes Circle

Several lines Slide credit: S. Lazebnik

A more complicated image http://ostatic.com/files/images/ss_hough.jpg

Effect of noise features votes Slide credit: S. Lazebnik This is 15.1 lower half features votes Slide credit: S. Lazebnik

Effect of noise Peak gets fuzzy and hard to locate features votes This is 15.1 lower half features votes Peak gets fuzzy and hard to locate Slide credit: S. Lazebnik

Effect of noise Number of votes for a line of 20 points with increasing noise: This is the number of votes that the real line of 20 points gets with increasing noise (figure15.3) Slide credit: S. Lazebnik

Uniform noise can lead to spurious peaks in the array Random points 15.2; main point is that lots of noise can lead to large peaks in the array features votes Uniform noise can lead to spurious peaks in the array Slide credit: S. Lazebnik

Random points As the level of uniform noise increases, the maximum number of votes increases too: Figure 15.4; as the noise increases in a picture without a line, the number of points in the max cell goes up, too Slide credit: S. Lazebnik

Last Class RANSAC RECON Hough Transform Assignment: Line estimation

Dealing with noise Choose a good grid / discretization Too coarse: large votes obtained when too many different lines correspond to a single bucket Too fine: miss lines because some points that are not exactly collinear cast votes for different buckets Increment neighboring bins (smoothing in accumulator array) Try to get rid of irrelevant features Take only edge points with significant gradient magnitude Slide credit: S. Lazebnik

Incorporating image gradients Recall: when we detect an edge point, we also know its gradient direction But this means that the line is uniquely determined! Modified Hough transform: For each edge point (x,y) θ = gradient orientation at (x,y) ρ = x cos θ + y sin θ H(θ, ρ) = H(θ, ρ) + 1 end Slide credit: S. Lazebnik

Hough transform for circles How many dimensions will the parameter space have? Given an oriented edge point, what are all possible bins that it can vote for? 3 dim = 2 position + radius Slide credit: S. Lazebnik

Hough transform for circles image space Hough parameter space r y (x,y) x x y Slide credit: S. Lazebnik

Hough transform for circles Conceptually equivalent procedure: for each (x,y,r), draw the corresponding circle in the image and compute its “support” x y r Is this more or less efficient than voting with features? Slide credit: S. Lazebnik

Hough transform: Discussion Pros Can deal with non-locality and occlusion Can detect multiple instances of a model Some robustness to noise: noise points unlikely to contribute consistently to any single bin Cons Complexity of search time increases exponentially with the number of model parameters Non-target shapes can produce spurious peaks in parameter space It’s hard to pick a good grid size Hough transform vs. RANSAC Slide credit: S. Lazebnik