[Insight-users] itk::VTKImageImport - How to get the ImageType

Christian Werner christian.werner at rwth-aachen.de
Sat Feb 13 16:00:16 EST 2010


Hello!

I am writing a little vtk2itk2vtk converter which should be fully 
automated. I found a header file vtk2itk2vtk.h in the web which connects 
a vtkImageExporter and a itk:VTKImageImporter and the other way round ( 
ConnectPipelines(in, out) ), but this does only half the job.

This way, I still have to provide the kind of data when setting up the 
itkImporter:

typedef itk::Image<short,3>                        InputType;
typedef itk::VTKImageImport<InputType> ImageImportType;

vtkImageImport*   vtkImporter = ImageImportType::New();

That's bad, because I do not know what I get from vtk, it could be any 
combination of 1-3 dimensions, long/int/char/float ...

What I finally want to set up is a pipeline like:    
VTKReader=>ConvertToITK-Filter=>ITKNiftyComplexFilter=>ConvertToVTK=> 
... that works with all Image types without me having to inform the 
Importer. This is what I did for the exporter which should work fine:

template <typename ITK_ImageData>
vtkImageData* itk2vtk(ITK_ImageData* itkOutImage)
{
    vtkImageImport* vtkImporter = vtkImageImport::New();
   
    typedef itk::VTKImageExport<ITK_ImageData> ImageExportType;
    ImageExportType* itkExporter;
    itkExporter = ImageExportType::New();
    itkExporter->SetInput( itkOutImage->GetOutput() );
    ConnectPipelines( itkExporter, vtkImporter );
   
    return vtkImporter->GetOutput();
}

Does anyone have any idea how I could implement the counterpart?


Best regards,
Christian


More information about the Insight-users mailing list