[Insight-users] Convert vnl_matrix<T> to itk::Matrix<T, NRows, NColumns>

Luis Ibanez luis.ibanez at kitware.com
Sun Mar 25 18:15:28 EST 2007



Hi Yonas,


This may actually be a bug related to the parallel evolution
of ITK and VXL.

It used to be the case that vnl_matrix_fixed derived from vnl_matrix.
At that time, the assignment operator in itk::Matrix:


    operator=( const vnl_matrix<T> & matrix )

was useful for assigning a vnl_matrix to an itkMatrix.



Now that vnl_matrix_fixed is independent from the vnl_matrix,
the operator=() in the itkMatrix is useless.


You are welcome edit your local copy of itk in order to add a method:


inline const Self & operator=( const InternalMatrixType & matrix )
   {
   this->m_Matrix = matrix;
   }



Please give it a try and let us know how that works for you.



We may want to fix that in the CVS repository too, and add a
test for it to the itkMatrixText.cxx file.



The lack of a test for that assignment is what had made possible
this Evolutionary gap.



     Regards,


         Luis

------------------------------------
Yonas Tesfazghi Weldeselassie wrote:
> Hello,
> 
> Can someone assist please on how to convert const vnl_matrix<T> to 
> itk::Matrix<T, NRows, NColumns>?
> 
> I suppose itk::Matrix is a wrapper around vnl_matrix and thus there 
> should not be any problem but I am finding an error message "can not 
> convert from const vnl_matrix<T> to itk::Matrix<T, NRows, NColumns>"
> 
> Detail:
> 
> //I have a
> DiffusionTensor3D<float> T;
> 
> //Compute its eigenvectors
> itk::DiffusionTensor3D<float>::EigenVectorsMatrixType V;
> itk::DiffusionTensor3D<float>::EigenValuesArrayType e;
> V.ComputeEigenAnalysis(e, V);
> 
> //Compute the transpose of the eigenvector and assign it to 
> itk::DiffusionTensor3D<float>::EigenVectorsMatrixType
> itk::DiffusionTensor3D<float>::EigenVectorsMatrixType Vt = V.GetTranspose();
> 
> ERROR: "can not convert from vnl_matrix_fixed<T, num_rows, num_cols> to 
> itk::Matrix<T, NRows, NColumns>"
> 
> I tried,
> itk::DiffusionTensor3D<float>::EigenVectorsMatrixType Vt = 
> V.GetTranspose().as_matrix();
> 
> Still ERROR: "can not convert from vnl_matrix<T> to itk::Matrix<T, 
> NRows, NColumns>"
> 
> Any suggestion will be appreciated.
> 
> P.S.:- I hope one will not say why not declaring Vt as vnl_matrix or 
> vnl_matrix_fixed. Of course that is the simplest solution but I need to 
> declare it as itk::Matrix as subsequent steps will need operations of Vt 
> and V like multiplication will bring the same error.
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users


More information about the Insight-users mailing list