[Insight-users] extending itkImageToVTKImageFilter to work on Matrices?

Lawrence M. Lifshitz Lawrence.Lifshitz at umassmed.edu
Mon Jul 8 09:48:01 EDT 2013


I am trying to use the itkImageToVTKImageFilter on a itk::Matrix<double,3,3>  3D image type
(as produced when calculating Hessians using itk::HessianRecursiveGaussianImageFilter).
It is failing at compile time (I use ITK 4.3 on fedora 16).

In the past I have written this 3d image type out as a metaimage.mhd file, then read it back into a
vtk based display program which uses vtkTensorGlyphFilter to display a representation of the matrices.
I have templated some types in the itk program as:
   typedef itk::Matrix< double, 3, 3> MatrixType;
   typedef itk::Image< MatrixType, 3 > EigenMatrixImageType;
   typedef itk::ImageFileWriter< EigenMatrixImageType > EigenMatrixWriterType;
And in the vtk display program I use:
   vtkMetaImageReader *reader;
   vtkTensorGlyphFilter *GlyphFilter;
This all works correctly, the image is read as an image of doubles with 9
components (3x3 matrix) for each pixel and is then rendered fine.

I am now trying to combine the itk and vtk programs so that I can
have interactive control of the itk based production of the hessian matrices
and see the glyphs change as that happens.  So I have tried doing
   typedef itk::ImageToVTKImageFilter<EigenMatrixImageType> TensorConnectorType;
   TensorConnectorType::Pointer tensorConnector = TensorConnectorType::New();
But upon an attempt to compile this code the TensorConnectorType::New() line
produces a compile time error message, the guts of which is:
   /usr/local/include/ITK-4.3/itkPixelTraits.h: In instantiation of 'itk::PixelTraits<itk::Matrix<double, 3u, 3u> >':
   /usr/local/include/ITK-4.3/itkPixelTraits.h:49:3: error: 'Length' is not a member of 'itk::Matrix<double, 3u, 3u>'
The offending code seems to be the line in itkPixelTraits.h:
          /** Dimension of the pixel (range). */
         itkStaticConstMacro(Dimension, unsigned int, TPixelType::Length);
         [note itkMacro.h:  #define itkStaticConstMacro(name, type, value) enum { name = value }
               so this is: enum {Dimension = TPixelType::Length}; or  enum {Dimension = itk::Matrix<double, 3u, 
3u>::Length}; ? ]
         ]

I am thinking that ImageToVTKImageFilter can't handle an image templated with a Matrix for the pixel type.
Am I correct about this?
If so, what is the easiest way around it?
Can I somehow derive a new class from ImageToVTKImageFilter which wouldn't have this problem?
Or can I create easily create a new class via another method which would work?

Thanks.

-- 
Lawrence M. Lifshitz, Ph. D., Associate Professor
Biomedical Imaging Group (http://big.umassmed.edu)
Program in Molecular Medicine
University of Massachusetts Medical School (http://www.umassmed.edu)
Phone: (508) 856-3392   email: Lawrence.Lifshitz at umassmed.edu
Fax:   (508) 856-1840     web: http://big.umassmed.edu/lml



More information about the Insight-users mailing list