[Insight-users] itkVTKImageIO NAN FEVER

Pieter Vos pieterv@radiology.azn.nl
Wed, 20 Mar 2002 13:02:09 +0100 (CET)


Hi,

For a moment I thought my problems where solved, because I needed to read
a VTK structured point dataset in ITK and found
the example itkVTKImageIOTest.cxx as my salvation. However when I strip
the code as below I receive the error:

*** NAN FEVER **
inf 0
0 inf
Abort

The junk.vtk file was generated by the original example.
Could it be that the pointer to the object itk::VTKImageIO::New() stores
information about the image, when writing and uses when reading a VTK
image? Are there settings necessary before reading a VTK image? If so,
which?

Many thanks,

Pieter Vos

-------------------------------------------
#include <iostream>
#include "itkRandomImageSource.h"
#include "itkImageFileWriter.h"
#include "itkImageFileReader.h"
#include "itkVTKImageIO.h"

/* Taken from itkImageIOTest.cxx */

int main()
{
  typedef itk::Image<float,2> FloatImageType;

  // Create a mapper (in this case a writer). A mapper
  // is templated on the input type.
  //
  itk::VTKImageIO::Pointer vtkIO;
  vtkIO = itk::VTKImageIO::New();

  if ( !vtkIO->CanReadFile("junk.vtk") )
    {
    	cout <<"Can't read file"<<endl;
    	return 1;
    }

  // Create a source object (in this case a reader)
  itk::ImageFileReader<FloatImageType>::Pointer reader;
  reader = itk::ImageFileReader<FloatImageType>::New();
  reader->SetImageIO(vtkIO);
  reader->SetFileName("junk.vtk");
  reader->Update();

  itk::ImageFileWriter<FloatImageType>::Pointer writer;
  writer = itk::ImageFileWriter<FloatImageType>::New();

  if ( !vtkIO->CanWriteFile("junk2.vtk") )
    {
    	cout <<"Can't write file"<<endl;
    	return 1;
    }

//write out image
  writer->SetInput(reader->GetOutput());
  writer->SetFileName("junk2.vtk");
  writer->SetImageIO(vtkIO);
  writer->Write();

  return EXIT_SUCCESS;
}

------------------------------------------- 
Pieter Vos
Doddendaal 190 Nijmegen
Tel.: 06-18876433
mailto:pieterv@radiology.azn.nl