Engineering Research Center for Computer Integrated Surgical Systems and Technology
1
600.445 Fall 2000-2014 Copyright © R. H. TaylorPoint cloud to point cloud rigid
transformations
Russell Taylor
600.445
Minimizing Rigid Registration Errors
Typically, given a set of points {a
i
} in one coordinate system
and another set of points {b
i
} in a second coordinate system
Goal is to find [R,p] that minimizes
η
=
e
i
•
e
i
i
∑
where
e
i
=
(R
•
a
i
+
p)
−b
i
This is tricky, because of R.
Engineering Research Center for Computer Integrated Surgical Systems and Technology
3
600.445 Fall 2000-2014 Copyright © R. H. TaylorPoint cloud to point cloud registration
ki
a
!
ki
b
!
R
i
a
!
k
+
p
!
=
b
!
k
Engineering Research Center for Computer Integrated Surgical Systems and Technology
4
600.445 Fall 2000-2014 Copyright © R. H. TaylorMinimizing Rigid Registration Errors
1
1
2
1
1
(
)
( , )
N
N
i
i
i
i
i
i
i
i
i
i
i
N
N
Frame
=
=
=
=
=
−
=
−
⋅ −
=
− ⋅
=
∑
∑
∑
a
a
b
b
a
a
a
b
b
b
R
R a
b
p
p b R a
F
R p
!
!
!
!
"
"
"
"
!
!
!
Step 1: Compute
Step 2: Find that minimizes
Step 3: Find
Engineering Research Center for Computer Integrated Surgical Systems and Technology
5
600.445 Fall 2000-2014 Copyright © R. H. TaylorPoint cloud to point cloud registration
R
i
a
!
k
+
p
!
=
b
!
k
a
b
ki
a
!
ki
b
!
Point cloud to point cloud registration
!
Engineering Research Center for Computer Integrated Surgical Systems and Technology
7
600.445 Fall 2000-2014 Copyright © R. H. TaylorRotation Estimation
Engineering Research Center for Computer Integrated Surgical Systems and Technology
8
600.445 Fall 2000-2014 Copyright © R. H. Taylor?
Engineering Research Center for Computer Integrated Surgical Systems and Technology
9
600.445 Fall 2000-2014 Copyright © R. H. TaylorRotation Estimation
Engineering Research Center for Computer Integrated Surgical Systems and Technology
11
600.445 Fall 2000-2014 Copyright © R. H. TaylorPoint cloud to point cloud registration
Engineering Research Center for Computer Integrated Surgical Systems and Technology
12
600.445 Fall 2000-2014 Copyright © R. H. TaylorSolving for R: iteration method
Given
{
!
,
( )
a
"
i
,
b
"
i
,
!
}
,
want to find
R
=
arg min
R
a
"
i
−
b
"
i
2
i
∑
Step 0: Make an initial guess
R
0
Step 1: Given
R
k
,
compute
b
⌣
i
=
R
−1
k
b
"
i
Step 2: Compute
Δ
R
that minimizes
(
Δ
R
i
∑
a
"
i
−
b
⌣
i
)
2
Step 3: Set
R
k
+
1
=
R
k
Δ
R
Step 4: Iterate Steps 1-3 until residual error is sufficiently small
(or other termination condition)
Engineering Research Center for Computer Integrated Surgical Systems and Technology
13
600.445 Fall 2000-2014 Copyright © R. H. TaylorIterative method: Getting Initial Guess
We want to find an approximate solution
R
0
to
R
0
i
⎡⎣
! "
a
i
!
⎤⎦ ≈
⎡⎣
! "
b
i
!
⎤⎦
One way to do this is as follows. Form matrices
A
=
⎡⎣
! "
a
i
!
⎤⎦
B
=
⎡⎣
! "
b
i
!
⎤⎦
Solve least-squares problem
M
3
x
3
A
3
xN
≈
B
3
xN
Note
: You may find it easier to solve
A
T
3
xN
M
3
x
3
T
≈
B
3
xN
T
Set
R
0
=
orthogonalize
(
M
3
x
3
). Verify that
R
is a rotation
Our problem is now to solve
R
0
ΔRA
≈
B
. I.e.,
ΔRA
≈
R
0
−1
B
Iterative method: Solving for
Δ
R
2
2
( )).
.
(
)
min
(
)
.
i
i
i
i
i
i
i
skew
Δ
α
Δ
+
α
Δ
•
≈
+
α×
Δ
•
−
≈
−
+
α×
α
∑
∑
R
R
I
R v v
v
v
R a
"
b
⌣
a
"
b
⌣
a
"
Approximate
as (
I.e.,
for any vector Then, our least squares problem becomes
min
This is linear least squares problem in
Then com
pute
Δ α
R
( )
.
Engineering Research Center for Computer Integrated Surgical Systems and Technology
15
600.445 Fall 2000-2014 Copyright © R. H. TaylorDirect Iterative approach for Rigid Frame
Given
{
!
,
( )
a
"
i,
b
"
i,
!
}
, want to find F
=
argmin
F
a
"
−
b
"
2i
∑
Step 0: Make an initial guess F
0Step 1: Given F
k, compute
a
"
ik=
F
k"
a
iStep 2: Compute
Δ
F that minimizes
Δ
F
a
"
ki−
b
"
i 2 i∑
Step 3: Set F
k+1=
Δ
FF
kStep 4: Iterate Steps 1-3 until residual error is sufficiently small
(or other termination condition)
Engineering Research Center for Computer Integrated Surgical Systems and Technology
16
600.445 Fall 2000-2014 Copyright © R. H. TaylorDirect Iterative approach for Rigid Frame
To solve for
ΔF
=
argmin
ΔF
a
!
ik−
b
!
i 2 i∑
ΔF
a
!
ki−
b
!
i≈
!
α
×
a
!
ik+
ε
!
+
a
!
i k−
b
!
i!
α
×
a
!
ik+
ε
!
≈
b
!
i−
!
a
iksk
(
−
a
!
ki)
α
!
+
ε
!
≈
b
!
i−
!
a
ikSolve the least-squares problem
"
"
sk
(
−
a
!
ik)
I
"
"
⎡
⎣
⎢
⎢
⎢
⎢
⎢
⎤
⎦
⎥
⎥
⎥
⎥
⎥
!
α
!
ε
⎡
⎣
⎢
⎢
⎢
⎢
⎤
⎦
⎥
⎥
⎥
⎥
≈
"
!
b
i−
a
!
ik"
⎡
⎣
⎢
⎢
⎢
⎢
⎢
⎤
⎦
⎥
⎥
⎥
⎥
⎥
Now set
ΔF
=[
ΔR
(
α
!
),
ε
!
]
Engineering Research Center for Computer Integrated Surgical Systems and Technology
17
600.445 Fall 2000-2014 Copyright © R. H. TaylorDirect Techniques to solve for R
Step 1: Compute
H
=
!
a
i,x
b
!
i,x
a
!
i,x
b
!
i,y
a
!
i,x
b
!
i,z
!
a
i,y
b
!
i,x
a
!
i,y
b
!
i,y
a
!
i,y
b
!
i,z
!
a
i,z
b
!
i,x
a
!
i,z
b
!
i,y
a
!
i,z
b
!
i,z
⎡
⎣
⎢
⎢
⎢
⎢
⎤
⎦
⎥
⎥
⎥
⎥
i
∑
Step 2: Compute the SVD of
H
=
USV
t
Step 3:
R
=
VU
t
Step 4: Verify
Det
(
R
)
=
1. If not, then algorithm may fail.
•
Method due to K. Arun, et. al., IEEE PAMI, Vol 9, no
5, pp 698-700, Sept 1987
•
Failure is rare, and mostly fixable. The paper has details.
Quarternion Technique to solve for R
•
B.K.P. Horn, “Closed form solution of absolute
orientation using unit quaternions”,
J. Opt. Soc.
America
, A vol. 4, no. 4, pp 629-642, Apr. 1987
.
•
Method described as reported in Besl and McKay,
“A method for registration of 3D shapes”,
IEEE
Trans. on Pattern Analysis and Machine
Intelligence, vol. 14, no. 2, February 1992.
•
Solves a 4x4 eigenvalue problem to find a unit
quaternion corresponding to the rotation
•
This quaternion may be converted in closed form to
Engineering Research Center for Computer Integrated Surgical Systems and Technology
19
600.445 Fall 2000-2014 Copyright © R. H. TaylorDigression: quaternions
Invented by Hamilton in 1843. Can be thought of as
4 elements:
q
=
⎡⎣
q
0
,
q
1
,
q
2
,
q
3
⎤⎦
scalar & vector:
q
=
s
+
v
!
=
⎡⎣ ⎤⎦
s
,
v
!
Complex number:
q
=
q
0
+
q
1
i
+
q
2
j
+
q
3
k
where
i
2
=
j
2
=
k
2
=
i j k
=
−
1
Properties:
Linearity:
λ
q
1
+ µ
q
!
2
=
⎡⎣
λ
s
1
+ µ
s
2
,
λ
v
!
1
+ µ
!
v
2
⎤⎦
Conjugate:
q
*
=
s
−
v
!
=
s
,
−
!
v
⎡⎣
⎤⎦
Product:
q
1
"
q
2
=
⎡⎣
s
1
s
2
−
!
v
1
i
!
v
2
,
s
1
!
v
2
+
s
2
!
v
1
+
!
v
1
×
v
!
2
⎤⎦
Transform vector:
q
"
p
!
=
q
"
⎡⎣ ⎤⎦
0,
p
!
"
q
*
Norm:
q
=
s
2
+
v
!
•
v
!
=
q
0
2
+
q
1
2
+
q
2
2
+
q
3
2
Engineering Research Center for Computer Integrated Surgical Systems and Technology
20
600.445 Fall 2000-2014 Copyright © R. H. TaylorDigression continued: unit quaternions
( ,
cos , sin
2
(( ,
cos , sin
0
2
Rot
Rot
θ
θ
θ
⎡
⎤
θ ⇔ ⎢
⎣
⎥
⎦
θ
θ
⎡
⎤
θ
=
⎢
⎥
⎣
⎦
n
n
n
n
p
n
!
!
!
!
i
!
!
"
We can associate a rotation by angle about an
axis with the unit quaternion:
)
2
Exercise: Demonstrate this relationship. I.e., show
)
2
[ ]
,
cos ,
2
sin
θ
θ
⎡
−
⎤
⎢
⎥
⎣
⎦
p
!
"
n
!
2
Engineering Research Center for Computer Integrated Surgical Systems and Technology
21
600.445 Fall 2000-2014 Copyright © R. H. TaylorA bit more on quaternions
Exercise:
show by substitution that the various formulations for
quaternions are equivalent
A few web references:
http://mathworld.wolfram.com/Quaternion.html
http://en.wikipedia.org/wiki/Quaternion
http://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation
http://www.euclideanspace.com/maths/algebra/
realNormedAlgebra/quaternions/index.htm
Rotation matrix from unit quaternion
q
=
⎡
⎣
q
0,
q
1,
q
2,
q
3⎤
⎦
;
q
=
1
R
(
q
)
=
q
02+
q
1 2−
q
2 2−
q
3 22(
q
1q
2−
q
0q
3)
2(
q
1q
3+
q
0q
2)
2(
q
1q
2+
q
0q
3)
q
02−
q
1 2+
q
2 2−
q
3 22(
q
2q
3−
q
0q
1)
2(
q
1q
3−
q
0q
2)
2(
q
2q
3+
q
0q
1)
q
02−
q
1 2−
q
2 2+
q
3 2⎡
⎣
⎢
⎢
⎢
⎢
⎢
⎢
⎤
⎦
⎥
⎥
⎥
⎥
⎥
⎥
Engineering Research Center for Computer Integrated Surgical Systems and Technology
23
600.445 Fall 2000-2014 Copyright © R. H. TaylorUnit quaternion from rotation matrix
R
(
q
)
=
r
xxr
yxr
zxr
xyr
yyr
zyr
xzr
yzr
zz⎡
⎣
⎢
⎢
⎢
⎢
⎤
⎦
⎥
⎥
⎥
⎥
;
a
0=
1
+
r
xx+
r
yy+
r
zz;
a
1=
1
+
r
xx−
r
yy−
r
zza
2=
1
−
r
xx+
r
yy−
r
zz;
a
3=
1
−
r
xx−
r
yy+
r
zza
0=
max{
a
k}
a
1=
max{
a
k}
a
2=
max{
a
k}
a
3=
max{
a
k}
q
0=
a
02
q
0=
r
yz−
r
zy4
q
1q
0=
r
zx−
r
xz4
q
2q
0=
r
xy−
r
yx4
q
3q
1=
r
xy−
r
yx4
q
0q
1=
a
12
q
1=
r
xy+
r
yx4
q
2q
1=
r
xz+
r
zx4
q
3q
2=
r
zx−
r
xz4
q
0q
2=
r
xy+
r
yx4
q
1q
2=
a
22
q
2=
r
yz+
r
zy4
q
3q
3=
r
yz−
r
zy4
q
0q
3=
r
xz+
r
zx4
q
1q
3=
r
yz+
r
zy4
q
2q
3=
a
32
Engineering Research Center for Computer Integrated Surgical Systems and Technology
24
600.445 Fall 2000-2014 Copyright © R. H. TaylorRotation axis and angle from rotation matrix
Many options, including direct trigonemetric solution.
But this works:
[
n
!
,
θ
]
←
ExtractAxisAngle
(
R
)
{
[
s
,
v
!
]
←
ConvertToQuaternion
(
R
)
return
([
v
!
/
v
!
,2atan(
s
/
v
!
)
}
Engineering Research Center for Computer Integrated Surgical Systems and Technology
25
600.445 Fall 2000-2014 Copyright © R. H. TaylorQuaternion method for R
Step 1: Compute
H
=
!
a
i,xb
!
i,xa
!
i,xb
!
i,ya
!
i,xb
!
i,z!
a
i,yb
!
i,xa
!
i,yb
!
i,ya
!
i,yb
!
i,z!
a
i,zb
!
i,xa
!
i,zb
!
i,ya
!
i,zb
!
i,z⎡
⎣
⎢
⎢
⎢
⎢
⎤
⎦
⎥
⎥
⎥
⎥
i∑
Step 2: Compute
G
=
trace
(
H
)
Δ
TΔ
H
+
H
T−
trace
(
H
)
I
⎡
⎣
⎢
⎢
⎤
⎦
⎥
⎥
where
Δ
T=
H
2,3−
H
3,2H
3,1−
H
1,3H
1,2−
H
2,1⎡
⎣
⎤
⎦
Step 3: Compute eigen value decomposition of
G
diag(
λ
)=
Q
TGQ
Step 4: The eigenvector
Q
k=
⎡⎣
q
0,
q
1,
q
2,
q
3⎤⎦
corresponding to
the largest eigenvalue
λ
kis a unit quaternion corresponding
to the rotation.
Another Quaternion Method for R
Let
q
=
s
+
v
!
be the unit quaternion corresponding
to
R
. Let
a
!
and
b
!
be vectors with
b
!
=
R
i
a
!
then we have
the quaternion equation
(
s
+
v
!
)
i
(0
+
a
)(
s
−
v
)
=
0
+
b
!
(
s
+
v
!
)
i
(0
+
a
)
=
(0
+
b
!
)
i
(
s
+
v
!
) since (
s
−
v
!
)(
s
+
v
!
)
=
1
+
0
!
Expanding the scalar and vector parts gives
−
v
!
i
a
!
=
−
v
!
i
b
!
s
a
!
+
v
!
×
a
!
=
s
b
!
+
b
!
×
v
!
Rearranging ...
(
b
!
−
a
!
)
i
v
!
=
0
!
!
!
!
!
!
Engineering Research Center for Computer Integrated Surgical Systems and Technology
27
600.445 Fall 2000-2014 Copyright © R. H. TaylorAnother Quaternion Method for R
Expressing this as a matrix equation
0
( )
b
!
−
a
!
T
!
b
−
a
!
( )
sk
( )
b
!
+
a
!
⎡
⎣
⎢
⎢
⎢
⎤
⎦
⎥
⎥
⎥
s
!
v
⎡
⎣
⎢
⎤
⎦
⎥
=
0
!
0
3
⎡
⎣
⎢
⎢
⎤
⎦
⎥
⎥
If we now express the quaternion
q
as a 4-vector
q
!
=
⎡⎣ ⎤⎦
s
,
v
!
T
,
we can express the rotation problem as the constrained linear
system
M
(
a
!
,
b
!
)
q
!
=
0
!
4
!
q
=
1
Engineering Research Center for Computer Integrated Surgical Systems and Technology
28
600.445 Fall 2000-2014 Copyright © R. H. TaylorAnother Quaternion Method for R
In general, we have many observations, and we want to
solve the problem in a least squares sense:
min
M
q
!
subject to
q
!
=
1
where
M
=
M(
a
!
1
,
b
!
1
)
"
M(
a
!
n
,
b
!
n
)
⎡
⎣
⎢
⎢
⎢
⎢
⎤
⎦
⎥
⎥
⎥
⎥
and
n
is the number of observations
Taking the singular value decomposition of M=U
Σ
V
T
reduces
this to the easier problem
min
U
Σ
V
T
q
!
X
=
U
Σ
!
y
Engineering Research Center for Computer Integrated Surgical Systems and Technology
29
600.445 Fall 2000-2014 Copyright © R. H. TaylorAnother Quaternion Method for R
This problem is just
min
Σ
y
!
=
σ
1
0
0
0
0
σ
2
0
0
0
0
σ
3
0
0
0
0
σ
4
⎡
⎣
⎢
⎢
⎢
⎢
⎢
⎢
⎤
⎦
⎥
⎥
⎥
⎥
⎥
⎥
!
y
subject to
y
!
=
1
where
σ
i
are the singular values. Recall that SVD routines typically
return the
σ
i
≥
0 and sorted in decreasing magnitude. So
σ
4
is the smallest singular value and the value of
y with
!
y
!
=
1
that minimizes
Σ
y
!
is
y= 0,0,0,1
!
⎡⎣
⎤⎦
T
. The corresponding value
of
q is given by
!
q
!
=
V
y
!
=
V
4
. Where V
4
is the 4th column of V.
Non-reflective spatial similarity (rigid+scale)
ki
a
!
ki
b
!
Engineering Research Center for Computer Integrated Surgical Systems and Technology