[Insight-users] Using ITK in combination with vtkImageData

Luis Ibanez luis.ibanez@kitware.com
Fri, 07 Feb 2003 23:38:14 -0500


Hi Christof

For you convinience a couple of classes are available
under

        Insight/Auxiliary/vtk

These classes connect an itk::VTKImageImport with
a vtkImageExport and an itk::VTKImageExport with
a vtkImageImport. They also take care of connecting
the callbacks of both pipelines making possible to
update VTK filters with Update() calls of ITK filter
and viceversa.

The classes in questions are

1)  itkVTKImageToImageFilter
2)  itkImageToVTKImageFilter

the use of (1) will look like:

typedef itk::Image<char,3> ImageType;
typedef itk::ImageToVTKImageFilter< ImageType > AdaptorType;

AdaptorType::Pointer adaptorFilter = AdaptorType::New();

adaptorFilter->SetInput( someITKfilter->GetOutput() );
someVTKfilter->SetInput( adaptorFilter->GetOutput() );

someVTKfilter->Update();

The use of (2) will look like:

typedef itk::VTKImageToImage< ImageType > Adaptor2Type;

Adaptor2Type::Pointer adaptorFilter2 = Adaptor2Type::New();

adaptorFilter2->SetInput( someOtherVTKfilter->GetOutput() );
someOtherITKfilter->SetInput( adaptorFilter2->GetOutput() );


Note that VTK images has a dynamic mechanism for defininig
pixels type. It is you responsibility to make sure that
the pixel type selected for the ITK filter is compatible
with the pixel type selected at run type in the ITK filter.
E.g. Make sure that you don't send a float VTK image to a
unsigned char ITK image....

Note also that this classes are not really part of the
toolkit, they are there just to help you write applications
using ITK and VTK. The core of ITK does not depend on VTK.



Please let us know if you find any problems


    Thank


----------------------------------------
karmonik wrote:
> Hi there,
> 
> I would like to use the itk::VTKImageImport and itk::VTKImageExport templates 
> in connection with a vtkImageData object.
> 
>>From the software guide I understand I have to use vtkImageExport to export 
> the info of my vtkImageData object and interface with itk::VTKImageImport. 
> This would allow me to interface itk with the vtk pipeline.
> 
> However, the documentation does not seem to be suffcient for me to get it to 
> work. I do not know what member functions to use and what pointer to pass as 
> arguments.
> 
> I was therefore wondering if someone could draft a C++ code snippet as an 
> example how to use vtkImageExport with itk::VTKImageImport and 
> itk::VTKImageExport with vtkImageImport.
> 
> Thanks a lot in advance !!
> 
> Christof
> 
> Christof Karmonik, PhD
> Baylor College of Medicine/The Methodist Hospital
> Mailstation M217
> 6565 Fannin
> Houston, TX 77030
> Pager: (713) 708-2232
> Fax: (713) 790-4688
> 
> _______________________________________________
> Insight-users mailing list
> Insight-users@public.kitware.com
> http://public.kitware.com/mailman/listinfo/insight-users
>