[Insight-users] How to convert SimpleITK image to VTK data

Bradley Lowekamp blowekamp at mail.nih.gov
Tue Dec 13 09:35:17 EST 2011


Hello,

I have not tried this, but you should be able to convert the sitkImage into a numpy array and them import that into VTK. To get a numpy ndarray from simpleITK try the following:

import SimpleITK as sitk
import numpy as np

sizeX, sizeY, sizeZ = 100,100,100

image = sitk.Image( sizeX, sizeY, sizeZ, sitk.sitkFloat32 )

nparray = sitk.GetArrayFromImage( image )

Then on the VTK side the following example looks like it should do the trick, using vtkImageImport and numpy arrays:
http://www.vtk.org/Wiki/VTK/Examples/Python/vtkWithNumpy


As I said I have not tried this my self so please let us know if this work for you. Additionally, this approach will create a couple of copies during the transition.

Brad

On Dec 13, 2011, at 8:22 AM, 张宁 wrote:

> Hello, I am using SimpleITK with python. I want to know how to convert the image generated with simpleitk to vtk data and display it. Thank you. _____________________________________
> 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