[Insight-users] vtk image reader

Pieter Vos pieterv@radiology.azn.nl
Thu, 4 Apr 2002 10:59:49 +0200 (CEST)


Hello,

I have a problem with the usage of itkVTKImageIO.cxx
The test file provided (itkVTKImageIOTest.cxx) works excelent, however I'm
interested in just reading a vtk file, not first writing and then reading
the written file.
But I retrieve an exception when excecuting reader->update():

exception in file reader
Number of dimensions in file (2) does not match number of dimensions in
output (3)
Unknown

The header looks like:

# vtk DataFile Version 3.0
vtk output
ASCII
DATASET STRUCTURED_POINTS
DIMENSIONS 20 20 20
SPACING 1.05263 1.05263 1.05263
ORIGIN 0 0 0
POINT_DATA 8000
COLOR_SCALARS scalars float 1

So the number of dimensions should be set correct by the reader, but it
does not so. The code looks like:


  itk::VTKImageIO::Pointer vtkIO;
  vtkIO = itk::VTKImageIO::New();
  itk::ImageFileReader<FloatImageType>::Pointer reader;
  reader = itk::ImageFileReader<FloatImageType>::New();
  reader->SetImageIO(vtkIO);
  reader->SetFileName("sphere.vtk");
    try
    {
    reader->Update();
    }
  catch (itk::ExceptionObject & e)
    {
    std::cerr << "exception in file reader " << std::endl;
    std::cerr << e.GetDescription() << std::endl;
    std::cerr << e.GetLocation() << std::endl;
    return EXIT_FAILURE;
    }

Do I need to do some presettings? Which one?

Many thanks,

-- 
Pieter Vos
AZN Radboud The Netherlands
Tel.: 06-18876433
mailto:pieterv@radiology.azn.nl