Code covered by the BSD License

### Highlights from Absolute Orientation - Horn's method

5.0

5.0 | 4 ratings Rate this file 81 Downloads (last 30 days) File Size: 18.7 KB File ID: #26186

# Absolute Orientation - Horn's method

by

23 Dec 2009 (Updated )

Solves weighted absolute orientation problem using Horn's quaternion-based method.

File Information
Description

ABSOR - a tool for solving the absolute orientation problem using Horn's
quaternion-based method, that is, for finding the rotation, translation, and
optionally also the scaling, that best maps one collection of point coordinates
to another in a least squares sense. The function works for both 2D and 3D
coordinates, and also gives the option of weighting the coordinates non-uniformly.
The code avoids for-loops to maximize speed.

DESCRIPTION:

As input data, one has

A: a 2xN or 3xN matrix whos columns are the coordinates of N source points.
B: a 2xN or 3xN matrix whos columns are the coordinates of N target points.

The syntax

[regParams,Bfit,ErrorStats]=absor(A,B)

solves the unweighted/unscaled registration problem

min. sum_i ||R*A(:,i) + t - B(:,i)||^2

for unknown rotation matrix R and unknown translation vector t.

This is a special case of the more general problem

min. sum_i w(i)*||s*R*A(:,i) + t - B(:,i)||^2

where s>=0 is an unknown global scale factor, to be estimated along with R and t,
and w is a user-supplied length N vector of weights. One can include either
s or w or both in the problem formulation using the syntax,

[regParams,Bfit,ErrorStats]=absor(A,B,'param1',value1,'param2',value2,...)

with parameter/value pair options

'doScale' - Boolean flag. If TRUE, the global scale factor, s, is included.
Default=FALSE.

'weights' - the length N vector of weights, w. Default, no weighting.

OUTPUT:

regParams: structure output with estimated registration parameters,

regParams.R: The estimated rotation matrix, R
regParams.t: The estimated translation vector, t
regParams.s: The estimated scale factor (set to 1 if doScale=false).
regParams.M: Homogenous coordinate transform matrix [s*R,t;[0 0 ... 1]].

For 3D problems, the structure includes

regParams.q: A unit quaternion [q0 qx qy qz] corresponding to R and
signed to satisfy max(q)=max(abs(q))>0

For 2D problems, it includes

regParams.theta: the counter-clockwise rotation angle about the
2D origin

Bfit: The rotation, translation, and scaling (as applicable) of A that
best matches B.

ErrorStats: structure output with error statistics. In particular,
defining err(i)=sqrt(w(i))*norm( Bfit(:,i)-B(:,i) ),
it contains

ErrorStats.errlsq = norm(err)
ErrorStats.errmax = max(err)

Acknowledgements

Absolute Orientation inspired this file.

MATLAB release MATLAB 7.9 (R2009b)
14 Nov 2013
14 Nov 2013

Hi Cong,

If you're asking how to apply the rotation matrix R to rotate a point P=[x;y;z], you would just use matrix multiplication Pnew=R*P.

Note, however, that ABSOR calculates a translation vector, t, as well (and sometimes also a scaling if you select the doScale option). The full transformation would be Pnew=R*P+t.

Finally, if you are working in homogeneous coordinates P=[x;y;z;1], ABSOR also returns a 4x4 total transformation matrix M. In that case, the transformation can then be done Pnew=M*P.

14 Nov 2013

Thank you to provide this very useful toolbox. I have a question: if I obtain the rotation matrix from your method, then how can I get the coordinates of any point in the new coordinate system (target).

18 Apr 2013

Thank you very much.

16 Apr 2013

Hi Monica. You can find the derivation of the scaling factor in the original paper by Horn, Section 2D

http://people.csail.mit.edu/bkph/papers/Absolute_Orientation.pdf

16 Apr 2013

Thank you Matt for this submission. I want to know how you got scaling factor sss=summ(right.*(R*left))/summ(left.*left). I know t+RSp-q=0 but i am not able to figure out the formula you have used for getting scaling factor. Could you please elaborate.

06 Jun 2012

Very nice work!

10 May 2012

Thanks for the feedback, Georg. I'm not entirely sure why the case of 3 points has been giving you trouble, though. It is true that alternative SVD-based methods and orthogonal matrix methods had to be modified to handle coplanar point data, but I always understood that to be a fairly stable solution.

10 May 2012

great work! (seems to work fine and also allows matching of three points)

25 Dec 2009

1. Important typo fix in help doc. Model is s*R*A+t not s*R*A-t
2. Added version for earlier MATLAB versions lacking bsxfun

22 Jan 2010

09 Apr 2010

Added tools for purely 2D registration

29 Sep 2010

*The many previous files in the distribution have been consolidated into a single file absor.m.

*New capability:weighted least squares registration.

*Fixed minor bug in the 2D registration routines, occurring when rotation angle was 0.