spinning dancer
wikipedia ]


necker cube illusion

Fitting and Alignment

COS 351 - Computer Vision

[ slides: Derek Hoiem, Lana Lazebnik, Grauman and Leibe 2008 AAAI Tutorial ]

assign02

Any questions?

review: definitions

Fitting
find the parameters of a model that best fit the data
Alignment
find the parameters of the transformation that best align matched points

review: fitting and alignment

Design challenges

fitting and alignment: methods

review: hough transform

  1. Create a grid of parameter values
  2. Each point votes for a set of parameters, incrementing those values in grid
  3. Find maximum or local maxima in grid

review: hough transform

P.V.C. Hough, Machine Analysis of Bubble Chamber Pictures, Proc. Int. Conf. High Energy Accelerators and Instrumentation, 1959.

Given a set of points, find the curve or line that explains the data points best

\(y=mx+b\)
[ slides: S. Savarese ]

review: hough transform

[ slides: S. Savarese ]

Hough Transform

How would we find circles?

hough transform for circles

image space
hough parameter space

hough transform for circles

Conceptually equivalent procedure: for each \((x,y,r)\), draw the corresponding circle in the image and compute its "support"

hough parameter space
check support

Is this more or less efficient than voting with features?

hough transform conclusions

Good

Bad

hough transform conclusions

Common applications

RANSAC

RANdom SAmple Consensus (RANSAC)

  1. Sample (randomly) the number of points required to fit the model
  2. Solve for model parameters using samples
  3. Score by the fraction of inliers within a preset threshold of the model
  4. Repeat 1–3 until the best model is found with high confidence
[ Fischler and Bolles 1981 ]

RANSAC

Line fitting example

data
[ illustration: Savarese ]

RANSAC

Line fitting example

sample 2 data points (for line)
[ illustration: Savarese ]

RANSAC

Line fitting example

solve parameters
[ illustration: Savarese ]

RANSAC

Line fitting example

score model
[ illustration: Savarese ]

RANSAC

Line fitting example

best fit
[ illustration: Savarese ]

how to choose parameters?

\[N = \frac{\log(1-p)}{\log(1-(1-e)^s)}\]

[ modified from M. Pollefeys ]

how to choose parameters?

\[N = \frac{\log(1-p)}{\log(1-(1-e)^s)}\]

Proportion of outliers \(e\) for \(p = 0.99\)

s 5% 10% 20% 25% 30% 40% 50%
2 2 3 5 6 7 11 17
3 3 4 7 9 11 19 35
4 3 5 9 13 17 34 72
5 4 6 12 17 26 57 146
6 4 7 16 24 37 97 293
7 4 8 20 33 54 163 588
8 5 9 26 44 78 272 1177
[ modified from M. Pollefeys ]

ransac conclusions

Good

Bad

ransac conclusions

Common applications

how do we fit the best alignment?

alignment

Alignment
find parameters of model that maps one set of points to another


Typically want to solve for a global transformation that accounts for most true correspondences

Difficulties

parametric (global) warping

\(\mathbf{p}=(x,y)\)
\(\mathbf{p}'=(x',y')\)

Transformation \(T\) is a coordinate-changing machine:

\[\mathbf{p}' = T(\mathbf{p})\]


What does it mean that \(T\) is global?

parametric (global) warping

\(\mathbf{p}=(x,y)\)
\(\mathbf{p}'=(x',y')\)

For linear transformations, we can represent \(T\) as a matrix

\[\mathbf{p}' = \mathbf{T}(\mathbf{p})\]

\[\left[\begin{array}{c} x' \\ y' \end{array}\right] = \mathbf{T}\ \left[\begin{array}{c} x \\ y \end{array}\right]\]

common transformations

original
translation
rotation
aspect
affine
perspective
[ slide credit (next few slides): A. Efros and/or S. Seitz ]

scaling

Scaling a coordinate means multiplying each of its components by a scalar

Uniform scaling means this scalar is the same for all components

uniform scaling

scaling

Scaling a coordinate means multiplying each of its components by a scalar

Non-uniform scaling means different scalars per component

non-uniform scaling

scaling

Scaling operation

\[x' = ax,\quad y' = by\]

or in matrix form

\[\left[\begin{array}{c} x' \\ y' \end{array}\right] = \mathbf{S}\ \left[\begin{array}{c} x \\ y \end{array}\right] = \left[\begin{array}{cc} a & 0 \\ 0 & b \end{array}\right] \left[\begin{array}{c} x \\ y \end{array}\right]\]

2D rotation

\[x' = x \cos(\theta) - y \sin(\theta)\] \[y' = x \sin(\theta) - y \cos(\theta)\]

2D rotation

This is easy to capture in matrix form:

\[\left[\begin{array}{c} x' \\ y' \end{array}\right] = \mathbf{R}\ \left[\begin{array}{c} x \\ y \end{array}\right] = \left[\begin{array}{cc} \cos(\theta) & -\sin(\theta) \\ \sin(\theta) & \cos(\theta) \end{array}\right] \left[\begin{array}{c} x \\ y \end{array}\right]\]

Even though \(\sin(\theta)\) and \(\cos(\theta)\) are nonlinear functions of \(\theta\),

What is the inverse transformation?

basic 2d transformations

Scale: \[\left[\begin{array}{c} x' \\ y' \end{array}\right] = \left[\begin{array}{cc} s_x & 0 \\ 0 & s_y \end{array}\right] \left[\begin{array}{c} x \\ y \end{array}\right]\]

Shear: \[\left[\begin{array}{c} x' \\ y' \end{array}\right] = \left[\begin{array}{cc} 1 & \alpha_x \\ \alpha_y & 1 \end{array}\right] \left[\begin{array}{c} x \\ y \end{array}\right]\]

Rotate: \[\left[\begin{array}{c} x' \\ y' \end{array}\right] = \left[\begin{array}{cc} \cos(\theta) & -\sin(\theta) \\ \sin(\theta) & \cos(\theta) \end{array}\right] \left[\begin{array}{c} x \\ y \end{array}\right]\]

Translate: \[\left[\begin{array}{c} x' \\ y' \end{array}\right] = \left[\begin{array}{ccc} 1 & 0 & t_x \\ 0 & 1 & t_y \end{array}\right] \left[\begin{array}{c} x \\ y \\ 1 \end{array}\right]\]

basic 2d transformations

Affine is any combination of:

\[\left[\begin{array}{c} x' \\ y' \end{array}\right] = \left[\begin{array}{ccc} a & b & c \\ d & e & f \end{array}\right] \left[\begin{array}{c} x \\ y \\ 1 \end{array}\right], \textrm{ or } \left[\begin{array}{c} x' \\ y' \\ 1 \end{array}\right] = \left[\begin{array}{ccc} a & b & c \\ d & e & f \\ 0 & 0 & 1 \end{array}\right] \left[\begin{array}{c} x \\ y \\ 1 \end{array}\right]\]

Properties of affine transformations:

projective transformations

Projective transformations are combinations of:

\[\left[\begin{array}{c} x' \\ y' \\ w' \end{array}\right] = \left[\begin{array}{ccc} a & b & c \\ d & e & f \\ g & h & i \end{array}\right] \left[\begin{array}{c} x \\ y \\ w \end{array}\right]\]

Properties of projective transformations:

  • Lines map to lines
  • Parallel lines do not necessarily remain parellel
  • Rations are not preserved
  • Closed under composition
  • Models change of basis
  • Projective matrix is defined up to a scale (8 DoF)

2d image transformations (ref table)

[ Szeliski 2.1 ]

example: solving for translation

Given matched points in \(\{A\}\) and \(\{B\}\), estimate the translation of the object

\[\left[\begin{array}{c} x_i^B \\ y_i^B \end{array}\right] = \left[\begin{array}{c} x_i^A \\ y_i^A \end{array}\right] + \left[\begin{array}{c} t_x \\ t_y \end{array}\right]\]

example: solving for translation

Least squares solution

  1. Write down objective function
  2. Derived solution
    1. Compute derivation
    2. Compute solution
  3. Computational solution
    1. Write in form \(\mathbf{A}\mathbf{x} = \mathbf{b}\)
    2. Solve using pseudo-inverse or eigenvalue decomposition

\[\left[\begin{array}{c} x_i^B \\ y_i^B \end{array}\right] = \left[\begin{array}{c} x_i^A \\ y_i^A \end{array}\right] + \left[\begin{array}{c} t_x \\ t_y \end{array}\right]\]

\[\left[\begin{array}{cc} 1 & 0 \\ 0 & 1 \\ \vdots & \vdots \\ 1 & 0 \\ 0 & 1 \end{array}\right] \left[\begin{array}{c} t_x \\ t_y \end{array}\right] = \left[\begin{array}{c} x_1^B - x_1^A \\ y_1^B - y_1^A \\ \vdots \\ x_n^B - x_n^A \\ y_n^B - y_n^A \end{array}\right]\]

example: solving for translation

RANSAC solution

  1. Sample a set of matching points (1 pair)
  2. Solve for transformation parameters
  3. Score parameters with number of inliers
  4. Repeat steps 1–3 \(N\) times

\[\left[\begin{array}{c} x_i^B \\ y_i^B \end{array}\right] = \left[\begin{array}{c} x_i^A \\ y_i^A \end{array}\right] + \left[\begin{array}{c} t_x \\ t_y \end{array}\right]\]

example: solving for translation

RANSAC solution problem: outliers

example: solving for translation

Hough transform solution

  1. Initialize a grid of parameter values
  2. Each matched pair casts a vote for consistent values
  3. Find the parameters with the most votes
  4. Solve using least squares with inliers

\[\left[\begin{array}{c} x_i^B \\ y_i^B \end{array}\right] = \left[\begin{array}{c} x_i^A \\ y_i^A \end{array}\right] + \left[\begin{array}{c} t_x \\ t_y \end{array}\right]\]

example: solving for translation

Hough transform solution problem: outliers, multiple objects, and/or many-to-one matches

example: solving for translation

Problem: no initial guesses for correspondences

\[\left[\begin{array}{c} x_i^B \\ y_i^B \end{array}\right] = \left[\begin{array}{c} x_i^A \\ y_i^A \end{array}\right] + \left[\begin{array}{c} t_x \\ t_y \end{array}\right]\]

alignment without prior matched pairs

What if you want to align but have no prior matched pairs?


Medical imaging: match brain scans or contours
Robotics: match point clouds

iterative closest points (ICP) algorithm

Goal: estimate transform between two dense sets of points

  1. Initialize transformation (e.g., compute differences in means and scales)
  2. Assign each point in \(\{A\}\) to its nearest neighbor in \(\{B\}\)
  3. Estimate transformation parameters
    • e.g., least squares or robust least squares
  4. Transform the points in \(\{A\}\) using estimated parameters
  5. Repeat steps 2–4 until change is very small

example: aligning boundaries

  1. Extract edge pixels \(p_1, \ldots, p_n\) and \(q_1, \ldots, q_m\)
  2. Compute initial transformation (e.g., compute translation and scaling by center of mass, variance within each image)
  3. Get nearest neighbors: for each point \(p_i\) find corresponding \(\textrm{match}(i) = \argmin{j} \textrm{dist}(p_i, q_j)\)
  4. Compute transformation \(\mathbf{T}\) based on matches
  5. Warp points \(\mathbf{p}\) according to \(\mathbf{T}\)
  6. Repeat 3–5 until convergence

example: aligning boundaries

example: aligning boundaries

example: solving for translation

ICP solution

  1. Find nearest neighbors for each point
  2. Compute transform using matches
  3. Move points using transform
  4. Repeat steps 1–3 until convergence

example: solving for translation

Problem: no initial guesses for correspondences

\[\left[\begin{array}{c} x_i^B \\ y_i^B \end{array}\right] = \left[\begin{array}{c} x_i^A \\ y_i^A \end{array}\right] + \left[\begin{array}{c} t_x \\ t_y \end{array}\right]\]

Sparse ICP

Sparse Iterative Closest Point. Sofien Bouaziz, Andrea Tagliasacchi, Mark Pauly. site

algorithm summaries

algorithm summaries

loading...