简体   繁体   English

发送ITK的img VTK

[英]Send img VTK for ITK

In VTK and ITK it is possible to pass images between them. 在VTK和ITK中,可以在它们之间传递图像。 But, it's only possible to send image from ITK to VTK using itk::ImageToVTKImageFilter . 但是,只能使用itk::ImageToVTKImageFilter将图像从ITK发送到VTK。

Is it possible to send an image from vtk to itk ? 是否可以将图像从vtk发送到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. 有一个过滤器itk :: ImportImageFilter,它使用图像缓冲区(由vtkImageData.GetScalarPointer()返回的数组)和图像属性(如大小,原点和间距)创建一个itk :: Image。

https://itk.org/Wiki/ITK/Examples/IO/ImportImageFilter shows how to import a C array to ITK as an image. https://itk.org/Wiki/ITK/Examples/IO/ImportImageFilter展示了如何将C数组作为图像导入到ITK。 Importing a vtkImageData is very similar. 导入vtkImageData非常相似。

Basically you will get the vtkImageData's spacing, origin, dimensions and use it as an input to the itk filter mentioned above. 基本上,您将获得vtkImageData的间距,原点,尺寸,并将其用作上述itk过滤器的输入。 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). 注意数据类型:如果vtkImageData的标量短,则itk :: image应该是itk :: Image(如果是3d图像,则为3;如果是2d图像,则为2)。

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. 当然,管道的vtk部分和管道的itk部分之间的同步将必须手动完成,除非您可以保证从中获取指针的imageData始终相同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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