Compute Rotation Angle from Procrustes Rotation Matrix

Hi!
I'm experimenting with procrustes matlab funcion for image alignment. My problem is that I need to compute the actual rotation angle and not just the transform. Could someonde give me some tip in computing the angle from the rotation matrix.
Thanks!

 Accepted Answer

To do that you need to receive the third output from 'procrustes' which is a structure. Its 'T' component gives the rotational component of the transformation from the input Y to the output Z:
Z = b*Y*T + c;
Assuming it is not a reflection, the matrix T should be of the form
T = [cos(a),sin(a);-sin(a),cos(a)]
where a is the rotation angle from Y to the rotated Y*T. Therefore you can find the angle with
a = atan2(T(1,2),T(1,1));
which gives an angle in the range -pi < a <= pi. (A reflection would have T(1,1) and T(2,2) of opposite sign.)

More Answers (2)

Matt J
Matt J on 20 Jun 2013
Edited: Matt J on 20 Jun 2013
Instead of using procrustes and doing extra processing on its output, you could use this FEX file which, in addition to performing the registration, will compute the rotation angle for you (for 2D data)
Matt, Thanks for the url, I'll try it!
Roger and Alan, I'm still puzzled by the transform matrix. Matlab returns a 512x512 matrix (my input images are 384x512). I guess it could be considered a 512D rotation matrix. But how do I compute the angle from that? What am I missing here? I've google for computing rotation angles from arbitrary big matrices, but haven't found anything yet.
Thanks again!

3 Comments

There's something amiss here, Maryana. Here is a quote from Mathworks' documentation for 'procrustes': "X and Y must have the same number of points (rows), and procrustes matches Y(i) to X(i). Points in Y can have smaller dimension (number of columns) than those in X. In this case, procrustes adds columns of zeros to Y as necessary." That would imply that your X and Y inputs for the two images should have just two columns corresponding to coordinates in the respective images and as many rows as in the set of matching points you have chosen between the two images. Presumably the T matrix returned would then be 2-by-2.
I recommend a very careful reading of the 'procrustes' documentation to be sure you understand how it works and what information you should present to it.
This is to add to my previous comment. In the Mathworks' site
http://www.mathworks.com/help/stats/procrustes.html
look carefully at the example given there at the end. They have selected a set of ten corresponding points in X and Y in which the one set is rotated (and otherwise altered) with respect to the other. That is what you must do in your two images. Find sets of points in the respective images that correspond to each other and give their respective coordinates in the X and Y arrays.
The figures you gave suggest that you simply input the two images as your X and Y arrays, and this would not be right at all. The 'procrustes' function is not capable of performing pattern recognition to find points that match. You have to do that yourself.
Thanks for enlightening me Roger! I was just misusing the function. Now everything works!

Sign in to comment.

Categories

Find more on Read, Write, and Modify Image in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!