[Insight-users] itkVTKImageToImageFilter

Tubak.Zoltan at stud.u-szeged.hu Tubak.Zoltan at stud.u-szeged.hu
Thu Feb 17 10:32:11 EST 2005


Hi all,

  I would like to ask your help!

I always get the following exception, when I try to update my vtk->itk 
pipeline:


Exception caught !

itk::ExceptionObject (0x8295830)
Location: "Unknown"
File: /home/.../BasicFilters/itkVTKImageImport.txx
Line: 237
Description: itk::ERROR: VTKImageImport(0x8292db0): Input number of components 
is 3 but should be 1


My primitive code is the following:

#include "vtkPNGReader.h"

#include "itkImage.h"
#include "itkImageFileWriter.h"
#include "itkVTKImageToImageFilter.h"

int main( int argc, char **argv ) {

  vtkPNGReader * reader = vtkPNGReader::New();
  reader->SetFileName(argv[1]);

  typedef itk::Image<unsigned short, 2> ImageType;
  typedef itk::ImageFileWriter<ImageType> WriterType;
  typedef itk::VTKImageToImageFilter<ImageType> ConnectorType;

  WriterType::Pointer writer = WriterType::New();
  ConnectorType::Pointer connector = ConnectorType::New();

  connector->SetInput(reader->GetOutput() );
  writer->SetInput( connector->GetOutput() );
  writer->SetFileName(argv[2]);

  try{ writer->Update(); } 
  catch(itk::ExceptionObject & excep)
     {
      std::cerr << "Exception caught !" << std::endl;
      std::cerr << excep << std::endl;
     }

  return 0;
}


Thanks for your help!

Zoltan




-------------------------------------------------
This mail sent through IMP: http://horde.org/imp/


More information about the Insight-users mailing list