Code covered by the BSD License  

Highlights from
Absolute Orientation

5.0

5.0 | 5 ratings Rate this file 21 Downloads (last 30 days) File Size: 2.38 KB File ID: #22422

Absolute Orientation

by Christian Wengert

 

12 Dec 2008 (Updated 09 Jun 2010)

Computes the transformation to register two corresponding 3D point sets.

| Watch this File

File Information
Description

[s R T error] = absoluteOrientationQuaternion( A, B, doScale)

Computes the orientation and position (and optionally the uniform scale factor) for the transformation between two corresponding 3D point sets Ai and Bi such as they are related by:

    Bi = sR*Ai+T

Implementation is based on the paper by Berthold K.P. Horn:
"Closed-from solution of absolute orientation using unit quaternions"
The paper can be downloaded here:
http://people.csail.mit.edu/bkph/papers/Absolute_Orientation.pdf

Authors:
Dr. Christian Wengert, Dr. Gerald Bianchi

Copyright:
ETH Zurich, Computer Vision Laboratory, Switzerland

Parameters:
A 3xN matrix representing the N 3D points
B 3xN matrix representing the N 3D points
doScale Flag indicating whether to estimate the uniform scale factor as well [default=0]

Return:
s The scale factor
R The 3x3 rotation matrix
T The 3x1 translation vector
err Residual error (optional)

Notes: Minimum 3D point number is N > 4

The residual error is being computed as the sum of the residuals:

for i=1:Npts
   d = (B(:,i) - (s*R*A(:,i) + T));
   err = err + norm(d);
 end

Example:

s=0.7;
R = [0.36 0.48 -0.8 ; -0.8 0.6 0 ; 0.48 0.64 0.6];
T= [45 -78 98]';
X = [ 0.272132 0.538001 0.755920 0.582317;
        0.728957 0.089360 0.507490 0.100513;
        0.578818 0.779569 0.136677 0.785203];
Y = s*R*X+repmat(T,1,4);

%Compute
[s2 R2 T2 error] = absoluteOrientationQuaternion( X, Y, 1);

error = 0;

%Add noise
Noise = [
-0.23 -0.01 0.03 -0.06;
0.07 -0.09 -0.037 -0.08;
0.009 0.09 -0.056 0.012];

Y = Y+Noise;
%Compute
[s2 R2 T2 error] = absoluteOrientationQuaternion( X, Y, 1);

error = 0.33

Acknowledgements
This submission has inspired the following:
Absolute Orientation - Horn's method
MATLAB release MATLAB 6.5 (R13)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (9)
15 Dec 2008 Thomas Pieper

Very good implementation of Horn's paper, but the functions crossprodquaternion and crossprodquaternion2 are still missing.

15 Dec 2008 Christian Wengert

I am sorry for the inconvenience caused by the missing crossprod function files. I uploaded the new version and it should be online soon.
Cheers

06 Mar 2009 Dave Ligthart

Great implementation!

29 May 2010 Bryan Murawski

Great work, but I believe that there is a mistake in your error metric computation. If you want to compute the sum of the squared error like you're doing (I assume for performance reasons) you should divide by Na to compute the average squared error and then sqrt that quantity (ie. sqrt(err/Na)).

19 Jun 2010 Dirk-Jan Kroon

What is the advantage of this absolute orientation method?

If I want the least-squares transformation matrix, with your coordinates it is simple :
s=0.7;
R = [0.36 0.48 -0.8 ; -0.8 0.6 0 ; 0.48 0.64 0.6];
T= [45 -78 98]';
X = [ 0.272132 0.538001 0.755920 0.582317;
        0.728957 0.089360 0.507490 0.100513;
        0.578818 0.779569 0.136677 0.785203];
Y = s*R*X+repmat(T,1,4);

>> X(4,:)=1; Y(4,:)=1;
>> Y/X

ans =

    0.2520 0.3360 -0.5600 45.0000
   -0.5600 0.4200 0.0000 -78.0000
    0.3360 0.4480 0.4200 98.0000
         0 0 0 1.0000

23 Jun 2010 Christian Wengert

Here is an interesting paper to the topic:

A Comparison of Four Algorithm s for Estimating tD Rigid Transformations

http://www.homepages.inf.ed.ac.uk/rbf/MY_DAI_OLD_FTP/rp765.pdf

Actually the Horn approach (unit quaternions) and the above mentioned (SVD?) are pretty much equivalent

05 Feb 2011 Matt J

@Dirk-Jan, the method that you've shown is not a constrained least squares estimation. The transformation matrix that it produces is therefore not gauranteed to be of the form
[sR,T;zeros(1,3), 1].

If you add noise to X and Y, you will see that your method does not produce the same results as the absolute orientation solver, nor will it be in the desired family of transformations.

03 Nov 2011 Peter

In your result, you compute the residual error as:
err =0;
for i=1:Na
   d = (B(:,i) - (s*R*A(:,i) + T));
   err = err + norm(d);
end

Wouldn't it be more appropriate to compute the sum of squared errors, because this is what you actually minimize? (so just use norm(d).^2 instead)

A nice addition would be to add the symmetric scale computation as mentioned later in the paper as a third option.

13 Dec 2011 Georg Stillfried

Just what I was looking for

Please login to add a comment or rating.
Updates
15 Dec 2008

Update, included the missing function crossprodQuaternion.
Sorry for that

15 Dec 2008

Missing functions added

09 Jun 2010

Based on Bryan Murawski's comments, I reviewed the computation of the residual error. Indeed, it seemed a bit strange, I thus changed the computation a bit so that it reflects the overall error of the transformation.

Tag Activity for this File
Tag Applied By Date/Time
image processing Cristina McIntire 12 Dec 2008 15:17:42
registration Cristina McIntire 12 Dec 2008 15:17:42
3d Cristina McIntire 12 Dec 2008 15:17:52
registration Christian Wengert 12 Dec 2008 15:17:55
image processing Christian Wengert 12 Dec 2008 15:17:55
image processing Marion Jaud 16 Mar 2012 08:48:27

Contact us at files@mathworks.com