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

Xiaoxiao Liu xiaoxiao.liu at kitware.com
Tue Jul 9 11:17:48 EDT 2013


I think you are right. The itkImageToVTKImageFilter does not support the
matrix pixel type yet.

According to:
http://www.itk.org/Doxygen/html/classitk_1_1VTKImageExport.html,
"Currently VTKImageExport<http://www.itk.org/Doxygen/html/classitk_1_1VTKImageExport.html>
 does not support pixel types with multiple components (like
RGBPixel<http://www.itk.org/Doxygen/html/classitk_1_1RGBPixel.html>
)."
and http://www.itk.org/Doxygen/html/classitk_1_1VTKImageImport.html:
"The images must have pixel types with one component."

I am reading this thread:
http://www.itk.org/pipermail/insight-users/2005-November/015553.html
It is not entirely clear, but it looks like it is worth trying with the itk
vector image first.




On Mon, Jul 8, 2013 at 9:48 AM, Lawrence M. Lifshitz <
Lawrence.Lifshitz at umassmed.edu> wrote:

> I am trying to use the itkImageToVTKImageFilter on a
> itk::Matrix<double,3,3>  3D image type
> (as produced when calculating Hessians using itk::**
> HessianRecursiveGaussianImageF**ilter).
> 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
>
> ______________________________**_______
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/**opensource/opensource.html<http://www.kitware.com/opensource/opensource.html>
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/**products/protraining.php<http://www.kitware.com/products/protraining.php>
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_**FAQ <http://www.itk.org/Wiki/ITK_FAQ>
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/**listinfo/insight-users<http://www.itk.org/mailman/listinfo/insight-users>
>



-- 


---------------------------------------------
*Xiaoxiao Liu*, Ph.D.
R & D Engineer
Kitware Inc <http://www.kitware.com/>.
Clifton Park, NY
Phone: (518) 881-4924  or  (518) 371-3971 x124
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20130709/b1465f81/attachment.htm>


More information about the Insight-users mailing list