Imregtform - how can I separate the rotation and translation?
5 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
Matt J
2014 年 12 月 21 日
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.
採用された回答
Matt J
2014 年 12 月 20 日
編集済み: Matt J
2014 年 12 月 21 日
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 件)
John
2014 年 12 月 20 日
編集済み: John
2014 年 12 月 20 日
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:
- 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
- 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
- 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.
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!