简体   繁体   中英

Send img VTK for ITK

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 ?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM