Estimation of Transformations
簡韶逸 Shao-Yi Chien Department of Electrical Engineering National Taiwan University Fall 2018
1
Estimation of Transformations Shao-Yi Chien Department of - - PowerPoint PPT Presentation
Estimation of Transformations Shao-Yi Chien Department of Electrical Engineering National Taiwan University Fall 2018 1 Outline Estimation 2D Projective Transformation [Slides credit: Marc Pollefeys] 2 Parameter Estimation
簡韶逸 Shao-Yi Chien Department of Electrical Engineering National Taiwan University Fall 2018
1
2
[Slides credit: Marc Pollefeys]
Given a set of (Xi,xi), compute P (xi=PXi)
Given a set of (xi,xi’), compute F (xi’TFxi=0)
Given a set of (xi,xi’,xi”), compute T
33 32 31 23 22 21 13 12 11
2 independent equations / point 8 degrees of freedom 4x2≥8
(“noise”)
i i
i i
i i i i
x h x h x h Hx
3 2 1 T T T
i i i i i i i i i i i i i i
1 2 3 1 2 3 T T T T T T
3 2 1
T T T T T T T T T i i i i i i i i i i i i
T i i i i
i
3 2 1
T T T T T T T T T i i i i i i i i i i i i
i
i
3 2 1
T T T T T T i i i i i i i i
4 3 2 1
size A is 8x9 or 12x9, but rank 8 Trivial solution is h=09
T is not interesting
No exact solution because of inexact measurement i.e. “noise”
n 2 1
Find approximate solution
Objective Given n≥4 2D to 2D point correspondences {xi↔xi’}, determine the 2D homography matrix H such that xi’=Hxi Algorithm (i) For each correspondence xi ↔xi’ compute Ai. Usually
(ii) Assemble n 2x9 matrices Ai into a single 2nx9 matrix A (iii) Obtain SVD of A. Solution for h is last column of V (iv) Determine H from h
' ' h ~ ' ' ' ' ' ' ' ' ' '
i i i i i i i i i i i i i i i i i i i i i i i i
x w y w x y x x w w w y w x y y y x w w w y w x
Solve using Gaussian elimination (4 points) or using linear least-squares (more than 4 points) However, if h9=0 this approach fails also poor results if h9 close to zero Therefore, not recommended Note h9=H33=0 if origin is mapped to infinity
1 H 1 Hx l
T
x4 x1 x3 x2 x4 x1 x3 x2 H? H’? x1 x3 x2 x4
Hx x
i i
Constraints: i=1,2,3,4
T
l x H
4 *
Define:
4 4 4 4 *
x x l x x H k
T
3 , 2 , 1 , x l x x H
4 *
i
i i T
Then, H* is rank-1 matrix and thus not a homography (case A) (case B) If H* is unique solution, then no homography mapping xi→xi’(case B) If further solution H exist, then also αH*+βH (case A) (2-D null-space in stead of 1-D null-space)
i i
T
2D homographies from 2D lines Minimum of 4 lines Minimum of 5 points or 5 planes 3D Homographies (15 dof) 2D affinities (6 dof) Minimum of 3 points or lines Conic provides 5 constraints
correspondence of 2 points and 2 line
16
DLT minimizes
i
partial vector for each (xi↔xi’) algebraic error vector
2 2 2 alg
T T T T T T i i i i i i i i i i i
2 2 2 1 2 2 1 alg
2 1 T 3 2 1
2 2 2 2 alg
i i i i i
Not geometrically/statistically meaningfull, but given good normalization it works fine and is very fast (use for initialization for non-linear minimization)
measured coordinates estimated coordinates true coordinates
2 H
i i i
Error in one image
e.g. calibration pattern
2 2 1
i i i i i
Symmetric transfer error d(.,.) Euclidean distance (in image)
i i i i i i i i i
i i
2 2 x ˆ , x ˆ H,
Reprojection error
2 2 1
2 2
Symmetric Transfer Error Reprojection Error
i i i i i i i i i i
T i i i i
T i i i i
3 2 1
h h h x x x x
T T T T T T i i i i i i i i
x w y w
2 2 2 i i alg
i i i i i i i i
i i i i i i i i i i
w w d w x w x w y w y d ˆ / x ˆ , x / ˆ / ˆ ˆ / ˆ / x ˆ , x
i i alg 2 / 1 2 2 2 i i
typical, but not , except for affinities
i
i 3x
i
For affinities, DLT can minimize geometric distance
these two distance metrics are related, but not identical
represents 2 quadrics in 4 (quadratic in X)
Estimating homography ~ fit surface to points X=(x,y,x’,y’)T in 4
i i
H
ν
2 2 2 2 2 2 2 i i
x ˆ , x x ˆ , x ˆ ˆ ˆ ˆ X ˆ X
i i i i i i i i i i i i
d d y y x x y y x x
2 H 2 2
, X x ˆ , x x ˆ , x
i i i i i
d d d
Analog to conic fitting
Cx x C , x
T 2 alg
d
2
C , x
d
2
X ˆ X
H
Vector that minimizes the geometric error is the closest point on the variety to the measurement
X ˆ
X
between algebraic and geometric error
X ˆ
Sampson error: 1st order approximation of
X Ah
H
C
X H H X H
δ X X δ X C C C X X ˆ δX
X ˆ
H
C
δ X X
X H H
C C e
X
Jδ
Find the vector that minimizes subject to
X
δ e
X
Jδ
X
δ X J
H
with
C
Find the vector that minimizes subject to
X
δ e
X
Jδ
X
δ
Use Lagrange multipliers: minimize derivatives
Jδ 2λ
δ
X X X
e
T T T
J 2λ
2
X
Jδ 2
X
e
λ J δ X
T
λ JJ
T
e
1 T
JJ λ
1 T T X
JJ J δ
X
δ X X ˆ
e
1 T T X T X 2 X
JJ δ δ δ
2
X ˆ X
H
Vector that minimizes the geometric error is the closest point on the variety to the measurement
X ˆ
X
between algebraic and geometric error
X ˆ
Sampson error: 1st order approximation of
X Ah
H
C
X H H X H
δ X X δ X C C C X X ˆ δX
X ˆ
H
C
δ X X
X H H
C C e
X
Jδ
Find the vector that minimizes subject to
X
δ e
X
Jδ
X
δ X J
H
with
C
e
1 T T X T X 2 X
JJ δ δ δ
(Sampson error)
A few points (i) For a 2D homography X=(x,y,x’,y’) (ii) is the algebraic error vector (iii) is a 2x4 matrix, e.g. (iv) Similar to algebraic error in fact, same as Mahalanobis distance (v) Sampson error independent of linear reparametrization (cancels out in between e and J) (vi) Must be summed for all points (vii) Close to geometric error, but much fewer unknowns
1 T T 2 X
e e e
T 2
2 JJT
e
31 21 3 T 2 T 11
/ h x h x h y h w x y w J
i i i i i i
X J
H
C
X
H
C e
e
e
1 T T JJ
removed)
2 2
2 / x x, 2
πσ 2 1
d
2 2 i
2 x H , x
/ 2 i
πσ 2 1
i
d
i
2 i 2 i
σ 2 1
i
Error in one image Maximum Likelihood Estimate
2 i
i
Equivalent to minimizing the geometric error function
removed)
2 2
2 / x x, 2
πσ 2 1
d
2 2 i 2 i
2 x H , x x , x
/ 2 i
πσ 2 1
i i
d d
i
Error in both images Maximum Likelihood Estimate
2 i 2 i
i i
Equivalent to minimizing the reprojection error function
1 T 2
2 2
Error in two images (independent)
2 2
i i
i i i i i
Varying covariances
1
will result change? for which algorithms? for which transformations?
Given and H computed by DLT, and Does the DLT algorithm applied to yield ?
i i i i
i i
i i
i i i i i
i i i
* *
i 2 1 2 1 i
T T
s s R t
T
T *
for similarities so
i i i i
alg alg
(T*: cofactor matrix)
i i i i
i i
i i
2 alg 2 alg 2 alg
i i i i i i i i i
i i i i i i i i
sd d d d Hx , x Hx T , x T Tx HT T , x T x ~ H ~ , x ~
Given and H, and Assume T’ is a similarity transformations
i i i i
i i
i i
e.g. Isotropic scaling
1 norm
Or
h h h 1 1
3 2 1
i i i i i i i i i i i i i i
x y x x x y x y y y x y y x
~102 ~102 ~102 ~102 ~104 ~104 ~102 1 1
Without normalization With normalization
Objective Given n≥4 2D to 2D point correspondences {xi↔xi’}, determine the 2D homography matrix H such that xi’=Hxi Algorithm (i) Normalize points (ii) Apply DLT algorithm to (iii) Denormalize solution
i i
i norm i i norm i
norm
norm
Employ this algorithm instead of the original DLT algorithm!
Normalization is also called pre-conditioning
Required to minimize geometric error (i) Often slower than DLT (ii) Require initialization (iii) No guaranteed convergence, local minima (iv) Stopping criterion required Therefore, careful implementation required: (i) Cost function (ii) Parameterization (minimal or not) (iii) Cost function ( parameters ) (iv) Initialization (v) Iterations
(minimal often more complex, also cost surface) (good algorithms can deal with over-parameterization) (sometimes also local parameterization)
transformation to particular class, e.g. affine
(i) Measurement vector XN with covariance Σ (ii) Set of parameters represented by vector P N (iii) Mapping f : M →N. Range of mapping is surface S representing allowable measurements (iv) Cost function: squared Mahalanobis distance Goal is to achieve , or get as close as possible in terms of Mahalanobis distance
1 T 2
Error in one image
2 i
i
n
2 1
2 2 1
i i i i i
Symmetric transfer error
n n
2 1
2
1
Reprojection error
2 i 2 i
i i
X composed of 2n inhomogeneous coordinates of the points 𝑦𝑗
′
X composed of 4n-vector inhomogeneous coordinates of the points𝑦𝑗 and 𝑦𝑗
′
X composed of 4n-vector
For a mapping function f with parameter vector To an estimated measurement vector We want to find p that can minimize , where f(p) can be approximated as with small and J= Find to minimize
44
Find to minimize The least-square solution: Augmented normal equation (with damping term ):
45
Hessian
Objective Given n≥4 2D to 2D point correspondences {xi↔xi’}, determine the Maximum Likelyhood Estimation of H (this also implies computing optimal xi’=Hxi) Algorithm (i) Initialization: compute an initial estimate using normalized DLT
(ii) Geometric minimization of -Either Sampson error:
2 i 2 i
x ˆ , x x ˆ , x
i i
d d
Objective Robust fit of model to data set S which contains outliers Algorithm (i) Randomly select a sample of s data points from S and instantiate the model from this subset. (ii) Determine the set of data points Si which are within a distance threshold t of the model. The set Si is the consensus set of samples and defines the inliers of S. (iii) If the subset of Si is greater than some threshold T, re- estimate the model using all the points in Si and terminate (iv) If the size of Si is less than T, select a new subset and repeat the above. (v) After N trials the largest consensus set Si is selected, and the model is re-estimated using all the points in the subset Si
Choose t so probability for inlier is α (e.g. 0.95)
distribution with m=codimension of model
2
d
2 m
(dimension+codimension=dimension space)
Codimension Model t 2 1 Line (l), Fundamental matrix (F) 3.84σ2 2 Homography (H), Camera Matrix (P) 5.99σ2 3 Trifocal tensor (T) 7.81σ2
Choose N so that, with probability p, at least one random sample is free from outliers. e.g. p=0.99
s
N s
proportion of outliers e
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
s
e p N 1 1 log / 1 log
Previous MLE algorithm considers fixed set of inliers Better, robust cost function (reclassifies)
inlier ρ with ρ
2 2 2 2 2 2 i
t e t t e e e d i R
Objective Compute homography between two images Algorithm (i) Interest points: Compute interest points in each image (ii) Putative correspondences: Compute a set of interest point matches based on some similarity measure (iii) RANSAC robust estimation: Repeat for N samples (a) Select 4 correspondences and compute H (b) Calculate the distance d for each putative match (c) Compute the number of inliers consistent with H (d<t) Choose H with most inliers (iv) Optimal estimation: re-estimate H from all inliers by minimizing ML cost function with Levenberg-Marquardt (v) Guided matching: Determine more matches using prediction by computed H Optionally iterate last two steps until convergence
similar coordinates
Interest points (500/image) Putative correspondences (268) Outliers (117) Inliers (151) Final inliers (262)