Thank you Luis,<br>
<br>
I am getting answers, but something is not right. My code is as follows:<br>
<br>
(...)<br>
int i = 0;<br>
int j = 0;<br>
vnl_matrix<double> m(3,3);<br>
<br>
cout << "Enter the 3x3 rotation/scale matrix, across first." << endl;<br>
for (i = 0; i < 3; i++)<br>
for (j = 0; j < 3; j++)<br>
cin >> m[i][j];<br>
vnl_svd<double> svd(m);<br>
vnl_matrix<double> r(3,3);<br>
r = svd.U() * vnl_transpose(svd.V());<br>
<br>
typedef itk::Similarity3DTransform< double > TransformType;<br>
typedef TransformType::VersorType VersorType;<br>
VersorType myrot;<br>
typedef VersorType::MatrixType MatrixType;<br>
MatrixType mat;<br>
for (i = 0; i < 3; i++)<br>
for (j = 0; j < 3; j++)<br>
mat[i][j] = r[i][j];<br>
myrot.Set(mat);<br>
<br>
cout << "Scale factor:\t" << myrot.GetScalar() << endl;<br>
cout << "X versor:\t" << myrot.GetX() << endl;<br>
cout << "Y versor:\t" << myrot.GetY() << endl;<br>
cout << "Z versor:\t" << myrot.GetZ() << endl;<br>
(...)<br>
<br>
In a different program, I have:<br>
(...)<br>
typedef itk::Similarity3DTransform<double> TransformType;<br>
TransformType::Pointer transform = TransformType::New();<br>
(...) set parameters, perform registration (...)<br>
const itk::Matrix<double,3,3> matrix3x3 = transform->GetMatrix();<br>
cout << " - 3x3 transform matrix:" << endl;<br>
for (int i = 0; i < 3; i++) {<br>
cout << " ";<br>
for (int j = 0; j < 3; j++) {<br>
printf("%8.4f ",matrix3x3[i][j]);<br>
}<br>
cout << endl;<br>
}<br>
(...)<br><br>
When I take the 3x3 transform matrix, and put in in the SVD program, I
don't get my original 3 versors and scale. What am I doing wrong?<br>
<br>
Thank you for your help.<br>
<br>
Jan Owoc<br>
<br>
<br><div><span class="gmail_quote">2006/1/24, Luis Ibanez <<a href="mailto:luis.ibanez@kitware.com">luis.ibanez@kitware.com</a>>:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br><br>Hi Jan,<br><br><br>In order to convert your 4x4 transform in to an<br>ITK Similarity transform you can do the following<br><br><br>Your 4x4 matrix can be interpreted as:<br><br> R11 R12 R13 T1<br> R21 R22 R23 T2
<br> R31 R32 R33 T3<br> Sh1 Sh2 Sh3 SC<br><br><br>Where<br><br> T1,T2,T3 are Translations<br> SC is a Scalinig factor<br> Sh1,Sh2,Sh3 are Shearing factors<br> R11... R33 are the rotations
<br><br><br>If your 4x4 matrix is formed correctly<br>representing a Similarit transform, then<br>the following constrains may be maintained<br><br><br>1) Sh1, Sh2, Sh3 MUST be null<br>2) The 3x3 submatrix R11..R22 MUST be orthogonal
<br><br><br><br>It that holds true, then you can use SVD in order<br>to find the Versor that matches the 3x3 matrix.<br><br>You will find and example on how to do this on<br>the Registration example:<br><br> Insight/
<br> Examples/<br> Registration/<br>
ImageRegistration9.cxx<br><br><br>Then you can setup the ITK Similarity transform<br>by using:<br><br><br> A) an ITK Versor for the rotation<br> B) an ITK Vector for the translation<br> C) a scalar value for the Scaling
<br><br><br><br>Please let us know if you have further questions.<br><br><br><br> Thanks<br><br><br> Luis<br>
</blockquote></div>