[Insight-users] error when reading a vtk image file

qf1234546 qf1234546 at 163.com
Sun Apr 15 11:16:10 EDT 2007


  Hi every: When I read a vtk image file,an error was gotten:ExceptionObject caught !itk::ExceptionObject (011DF248)
Location: "unknown"
File: D:\ITK\ITK1\Code\IO\itkVTKImageIO.cxx
Line: 193
Description: itk::ERROR: VTKImageIO(01735440): Not structured points, can't read Here is my programme:
#if defined(_MSC_VER)
#pragma warning ( disable : 4786 )
#endif#ifdef __BORLANDC__
#define ITK_LEAN_AND_MEAN
#endif
#include "itkImageFileReader.h"
#include "itkImageFileWriter.h"
#include "itkVTKImageIO.h"
#include "itkImage.h"
const unsigned int myDimension = 3;
typedef itk::Image<float, myDimension> FloatImageType;
int main()
{
  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 & err )
    {
    std::cerr << "ExceptionObject caught !" << std::endl;
    std::cerr << err << std::endl;
    return EXIT_FAILURE;
    }
  itk::VTKImageIO::Pointer vtkIO2;
  vtkIO2 = itk::VTKImageIO::New();  itk::ImageFileWriter<FloatImageType>::Pointer writer;
  writer = itk::ImageFileWriter<FloatImageType>::New();
  writer->SetInput(reader->GetOutput());
  writer->SetFileName("sphere2.vtk");
  writer->SetImageIO(vtkIO2);
 try
    {
    writer->Update();
    }
  catch( itk::ExceptionObject & err )
    {
    std::cerr << "ExceptionObject caught !" << std::endl;
    std::cerr << err << std::endl;
    return EXIT_FAILURE;
    }
  return EXIT_SUCCESS;
} Thank you for your help!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20070415/e41bab2e/attachment.htm


More information about the Insight-users mailing list