[Insight-users] error when reading a vtk image file
Luis Ibanez
luis.ibanez at kitware.com
Sun Apr 15 16:25:41 EDT 2007
Hi qf1234546
Please post to the list the first 10 lines of
your .vtk file "sphere.vtk".
It is very likely that the content of this file
is not an actual vtkImageData.
BTW: In ITK you don't need to specify the itk::VTKImageIO object.
The IO factory will do that for you. It is enough to
provide a filename with extension .vtk, that contains
an structured dataset.
You may want to read the ITK Software Guide
http://www.itk.org/ItkSoftwareGuide.pdf
in particular the chapter on
"Reading and Writing Images"
Regards,
Luis
-------------------
qf1234546 wrote:
>
>
> 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!
>
>
> ------------------------------------------------------------------------
> Ô¶ÀëÀ¬»øÓʼþ£¿Ãâ·Ñ°ïÄã¹ýÂË98£¥µÄÀ¬»øÓʼþ£¡>> <http://www.126.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