[Insight-users] How do I read a 3D .VTK Image

Luis Ibanez luis.ibanez at kitware.com
Fri Nov 9 18:12:35 EST 2007


Hi Matt,

You may want to look at the CVS log of the itkVTKImageIO.cxx file
http://www.itk.org/cgi-bin/viewcvs.cgi/Code/IO/itkVTKImageIO.cxx?rev=1.42&root=Insight&view=log

This problem is due to the following changes

A)
http://www.itk.org/cgi-bin/viewcvs.cgi/Code/IO/itkVTKImageIO.cxx?root=Insight&r1=1.38&r2=1.39

B)
http://www.itk.org/cgi-bin/viewcvs.cgi/Code/IO/itkVTKImageIO.cxx?root=Insight&r1=1.40&r2=1.41


Code change (A) was made first, on Jan 15th 2007, under the assumption
that an image with multiple components should be described as an image
of vectors.

We discovered later that the VECTORS keywords prevented the image from
being read, so we revert change (A) by committing the change (B).


Thu May 17 14:21:23 2007 UTC (5 months, 3 weeks ago) by ibanez
Branch: MAIN

BUG: When reading structured data sets, the vtk Reader:
vtkStructuredPointReader does not support the tag "VECTORS"
as a valid descriptor of point data. We are therefore reverting
this itkVTKImageIO writer to use simply "SCALARS" even when the
actual image type in ITK is of Vector pixel type.



It may seem that one of your files was created with a version
of the code in between changes (A) and (B). That is anytime
between Jan 15th and May 7th 2007.



One solution is to open the VTK file in you favorite text editor,
(emacs or vi) and to replace:


                   VECTORS vectors double

with

                   SCALARS scalars double 3


That will make the file readable by the vtkStructuredPointReader
again.



  Regards,


      Luis



----------------
Matt wrote:
> 
> The 3D deformation field (.vtk image) I am creating has gotten written 
> to file
> with two different header files with the exact same code. The first time 
> I ran
> my code my OS was Red Hat Linux. I can read this image. I am now using Cent
> Linux and am having a problem reading the second image (.vtk image).
> 
> Header file that will read:
> 
> # vtk DataFile Version 3.0
> VTK File Generated by Insight Segmentation and Registration Toolkit (ITK)
> BINARY
> DATASET STRUCTURED_POINTS
> DIMENSIONS 82 56 41
> SPACING 3.9443597793579102e+00 4.1964287757873535e+00 3.9157774448394775e+00
> ORIGIN 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00
> POINT_DATA 188272
> SCALARS scalars double 3
> LOOKUP_TABLE default
> 
> Header file that will not read:
> 
> # vtk DataFile Version 3.0
> VTK File Generated by Insight Segmentation and Registration Toolkit (ITK)
> BINARY
> DATASET STRUCTURED_POINTS
> DIMENSIONS 82 56 41
> SPACING 3.9443597793579102e+00 4.1964287757873535e+00 3.9157774448394775e+00
> ORIGIN 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00
> POINT_DATA 188272
> VECTORS vectors double
> LOOKUP_TABLE default
> 
> Code I use to read in the deformation field (.vtk image):
> 
> 
>  typedef itk::Vector< double, 3 > VectorType;
>  typedef itk::Image< VectorType, 3 > DeformationFieldType;
>  typedef itk::ImageFileReader< DeformationFieldType > FieldReaderType;
>  typedef itk::WarpImageFilter< ImageType, ImageType, 
> DeformationFieldType  > FilterType;
> 
>  // read in deformation field
>  FieldReaderType::Pointer fieldReader = FieldReaderType::New();
>  DeformationFieldType::ConstPointer deformationField;
> 
>  fieldReader->SetFileName( deformationFieldFile ); std::endl;
> 
>  try
>    {
>      fieldReader->Update();
>    }
>  catch( itk::ExceptionObject & excp )
>    {
>      std::cerr << "Exception thrown" << std::endl;
>      std::cerr << excp << std::endl;
>    }
> 
>  deformationField = fieldReader->GetOutput();
> 
> 
> I am using ITK version 3.2.0. The program never finishes executing the 
> command
> "fieldReader->Update();". I don't get an error, it just seems as if the code
> encounters an infinite For Loop. The code runs fine for the .vtk image 
> with the
> first header listed above, but I encounter the described problem for the 
> .vtk
> image with the second header listed above.
> 
> Thanks,
> 
> Matt
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> 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