MantisBT - ITK
View Issue Details
0005665ITKpublic2007-09-06 18:432010-10-21 13:09
Luis Ibanez 
Andinet 
highmajorhave not tried
closedfixed 
 
 
backlog
0005665: Similarity3DTransform bug in SetMatrix () and ComputeMatrixParameters()
Using only two terms of the matrix for computing the scale
Reported in the users list by
http://public.kitware.com/pipermail/insight-users/2007-September/023560.html [^]
No tags attached.
Issue History
2007-09-06 18:43Luis IbanezNew Issue
2007-09-06 18:46Luis IbanezNote Added: 0008874
2007-09-06 18:52Luis IbanezNote Edited: 0008874
2007-09-06 19:14Luis IbanezNote Added: 0008875
2007-09-06 19:15Luis IbanezNote Added: 0008876
2007-09-07 08:24Luis IbanezNote Added: 0008878
2007-09-07 08:24Luis IbanezNote Edited: 0008878
2007-09-07 08:25Luis IbanezNote Edited: 0008878
2007-09-07 08:26Luis IbanezNote Edited: 0008878
2008-01-23 15:21Luis IbanezNote Added: 0010249
2008-01-23 15:21Luis IbanezStatusnew => assigned
2008-01-23 15:21Luis IbanezAssigned To => Andinet
2008-01-23 15:23Luis IbanezNote Added: 0010250
2008-01-23 15:24Luis IbanezNote Edited: 0010250
2010-10-21 13:09Hans JohnsonSprint Status => backlog
2010-10-21 13:09Hans JohnsonNote Added: 0022620
2010-10-21 13:09Hans JohnsonStatusassigned => closed
2010-10-21 13:09Hans JohnsonResolutionopen => fixed

Notes
(0008874)
Luis Ibanez   
2007-09-06 18:46   
(edited on: 2007-09-06 18:52)
The Isotropic scaling of the matrix is being computed as

 double s = vnl_math_sqr( matrix[0][0] ) +
            vnl_math_sqr( matrix[0][1] );

Which doesn't take into account the 3D nature of the Transform.

Since the Matrix is expected to be an Orthogonal matrix multiplied by an isotropic scaling, the scaling value can be recovered as:

A) The trace of the matrix divided by the dimension (3 in this case)
B) The cubic root of the matrix determinant

(0008875)
Luis Ibanez   
2007-09-06 19:14   
A fix has been committed to the CVS repository:
http://www.itk.org/cgi-bin/viewcvs.cgi/Code/Common/itkSimilarity3DTransform.txx?root=Insight&sortby=date&r2=1.8&r1=1.7 [^]
(0008876)
Luis Ibanez   
2007-09-06 19:15   
The cubic root of the determinant turned out to be a more precise way of computing the scale than taking the trace divided by three.
(0008878)
Luis Ibanez   
2007-09-07 08:24   
(edited on: 2007-09-07 08:26)
The rationale is the the Similarity3D Transform
has a matrix composed of:


      | M00 M01 M02 |
      | M10 M11 M12 | =
      | M20 M21 M22 |

            | S 0 0 | | T00 T01 T02 |
            | 0 S 0 | | T10 T11 T12 |
            | 0 0 S | | T20 T21 T22 |

Where [T] is an orthogonal Matrix, and S is the Scaling
factor. The determinant of the resulting matrix M is
equal to

           Det([M]) = S^3 * Det([T])

and [T] being Orthogonal, should have a unit determinant.

Therefore:

           S = CubeRoot( Det([M] )

(0010249)
Luis Ibanez   
2008-01-23 15:21   
Andinet will add a test to verify that the fix it is working.
(0010250)
Luis Ibanez   
2008-01-23 15:23   
(edited on: 2008-01-23 15:24)
The test should do: (pseudocode)

TransformType t1;
t1.SetScale( value );

TransformType t2;

t2.SetMatrix( t1.GetMatrix() );

t2.ComputeMatrixParameters();

if( t1.GetScale() != t2.GetScale() )
{
   return EXIT_FAILURE;
}

(0022620)
Hans Johnson   
2010-10-21 13:09   
Assumed fixed.