[Insight-users] vtk/itk connection problem in python
John Hunter
jdhunter at ace.bsd.uchicago.edu
Tue Feb 22 18:30:05 EST 2005
I am writing some sample scripts to test the vtk/itk connection
pipeline using ConnectVTKITK from the InsightApplications directory.
I'm not yet trying to do anything with the images in ITK, just
exercising the mechanics of cross-talk.
My first script, which uses an itk reader and a vtk viewer, worked as expected
import ConnectVTKITK as connect
reader = connect.itkImageFileReaderF2_New()
reader.SetFileName('/home/jdhunter/media/images/leo_ratner.jpg')
itkExport = connect.itkVTKImageExportF2_New()
itkExport.SetInput(reader.GetOutput())
vtkImport = connect.vtkImageImport()
connect.ConnectITKF2ToVTK(itkExport.GetPointer(), vtkImport)
viewer = connect.vtkImageViewer()
viewer.SetInput(vtkImport.GetOutput())
viewer.Render()
In my second script, I'm trying to use a vtk reader, pass this off to
itk for some processing, and then back to vtk for visualizing. I'm
not actually doing any itk processing as this is just a test script,
but basically I do
vtkread -> vtk2itk -> itk2vtk - >vtk visualize
but I get an abort when I call the vtk image viewer Render method.
Can someone point me to the light?
import ConnectVTKITK as connect
reader = connect.vtkImageReader()
reader.SetFileName('/home/jdhunter/media/images/leo_ratner.jpg')
vtkExport = connect.vtkImageExport()
vtkExport.SetInput(reader.GetOutput())
itkImport = connect.itkVTKImageImportF2_New() # import into itk
connect.ConnectVTKToITKF2(vtkExport, itkImport.GetPointer())
print 'VTK->ITK complete'
# In this example we simply pass the image back to vtk w/o doing
# anything to exercise the syntax. In real life we would run some itk
# filters.
itkExport = connect.itkVTKImageExportF2_New() # export from itk
itkExport.SetInput(itkImport.GetOutput())
vtkImport = connect.vtkImageImport()
connect.ConnectITKF2ToVTK(itkExport.GetPointer(), vtkImport)
print 'ITK->VTK complete'
viewer = connect.vtkImageViewer()
viewer.SetInput(vtkImport.GetOutput())
print 'Render, man!'
viewer.Render()
Thanks! ITK 2.0.0, VTK 4.4
JDH
More information about the Insight-users
mailing list