0
votes

In VTK and ITK it is possible to pass images between them. But, it's only possible to send image from ITK to VTK using itk::ImageToVTKImageFilter.

Is it possible to send an image from vtk to itk ?

2
Have you seen this?siavashk
Great! I got here!user4876067

2 Answers

0
votes

There is a filter, itk::ImportImageFilter, that takes the image buffer (that array returned by vtkImageData.GetScalarPointer()) and image properties like size, origin and spacing, and creates an itk::Image.

https://itk.org/Wiki/ITK/Examples/IO/ImportImageFilter shows how to import a C array to ITK as an image. Importing a vtkImageData is very similar.

Basically you will get the vtkImageData's spacing, origin, dimensions and use it as an input to the itk filter mentioned above. Pay attention to data type: if the vtkImageData's scalars are shorts the itk::image should be an itk::Image (3 if it's a 3d image, 2 if it's a 2d image).

Of course, syncronization between the vtk part of your pipeline and the itk part of your pipeline will have to be done manually, unless you can garantee that the imageData from which you get the pointer is always the same.