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

Arunachalam Kana Kana.Arunachalam at fh-wels.at
Mon Feb 15 03:50:27 EST 2010


Hi Christian,

I think there are several possibilities to achieve vtk2itk2vtk. I will
tell you how i do it.
I use vtkedge to do this. The file in vtkedge you need is
"vtkKWEITKImage.cxx". This image object 
is capable of holding both itk and vtk image.

So if you are interested, have a look at the file code in VTKEdge and
write your code or use
the file directly.

Regards,
Kana 

-----Original Message-----
From: insight-users-bounces at itk.org
[mailto:insight-users-bounces at itk.org] On Behalf Of Christian Werner
Sent: 13 February 2010 22:00
To: insight-users at itk.org
Subject: [Insight-users] itk::VTKImageImport - How to get the ImageType

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
_____________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.html

Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ

Follow this link to subscribe/unsubscribe:
http://www.itk.org/mailman/listinfo/insight-users


More information about the Insight-users mailing list