# Imregtform - how can I separate the rotation and translation?

10 vues (au cours des 30 derniers jours)
Inbal le 20 Déc 2014
Commenté : Inbal le 21 Déc 2014
I use imregtform with 'rigid', so that the registration is limited to rotation and translation. I get the tform matrix which looks like:
a; b; 0
c; d; 0
e; f; 1
(I would expect a different form for translation & rotation only - with two non-zero values in the third column and 2 zeros in the third row).
The images show a cell, and I need to estimate its motion between the frames. How can I calculate the angle of rotation and amount of transformation from the tform matrix? Thanks!
##### 1 commentaireAfficher -1 commentaires plus anciensMasquer -1 commentaires plus anciens
Matt J le 21 Déc 2014
with two non-zero values in the third column and 2 zeros in the third row).
It's not entirely clear which entries your 6 variables a,b,c,d,e,f refer to. If you are looking at a matrix with 3 rows and columns, there should 9 entries, not 6.

Connectez-vous pour commenter.

### Réponse acceptée

Matt J le 20 Déc 2014
Modifié(e) : Matt J le 21 Déc 2014
I think there must be a typo in your post. The 'rigid' option cannot return a,b,c,d all equal to 0, assuming these are the entries of the leftmost 3x2 matrix of the imregtform output.
The rotation angle would be atan2d(b,a). The translation vector would be [e,f].
##### 1 commentaireAfficher -1 commentaires plus anciensMasquer -1 commentaires plus anciens
Inbal le 21 Déc 2014
I meant that from linear algebra I would expect the third column to be the translation terms, so that the 2 zeros in the matrix i got should be non-zero for the translation. I now understand that in Matlab the third row represents the translation. Thanks!

Connectez-vous pour commenter.

### Plus de réponses (1)

John le 20 Déc 2014
Modifié(e) : John le 20 Déc 2014
I have dabbled with this before just to try out MATLAB's capabilities and am no expert in the area of linear transformations, so take my suggestion with a grain of salt as I am not sure about my "answer." But I think the following resource should help:
1. On spatial transformations in MATLAB (keep in mind MATLAB transformation matrices look a little different than those you would find in literature because of the "rows and columns" way MATLAB sees images): http://www.mathworks.com/help/images/performing-general-2-d-spatial-transformations.html
2. affine2d class which returns a tform when you give it the "desired txform" transformation matrix: http://www.mathworks.com/help/images/ref/affine2d-class.html
3. A tutorial that shows translation and rotation are not commutative operations: http://www.cs.mtu.edu/~shene/COURSES/cs3621/NOTES/geometry/geo-tran.html
By "desired txform" matrix I am referring to: [a b 0; c d 0; e f 1]
I looked into the source code for imregtform and looked at the way it constructs the "desired txform" matrix before it passes it over to affine2d and returns you the tform. It appears to be constructing the "desired txform" matrix such that for rigid transformations, the first two rows of "desired txform" contain the rotation component [a b 0; c d 0] contain the rotation components of the rigid transformation and the last row [e f 1] contains the translational component.
So if my barnyard math is right, MATLAB returns a tform that represents a transformation in which rotation is applied first and then translation (keep this ordering in mind), so in "desired txform", a = cos(theta) where theta is the angle of rotation about the origin, and then you can find theta by using the inverse cosine function. e and f then represent the translational components.
Hopefully that helps. But take my suggestion with a grain of salt.
##### 1 commentaireAfficher -1 commentaires plus anciensMasquer -1 commentaires plus anciens
Inbal le 21 Déc 2014
Thanks!

Connectez-vous pour commenter.

### Catégories

En savoir plus sur Image Registration dans Help Center et File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by