Some things just go together well.


Mom and apple pie.

Motherhood and apple pie
Image source: Wikipedia


Bread and butter.

Bread and butter
Image source: Wikipedia


Cheese and wine.

Cheese and wine
Image source: flickr


And ITK and VTK.

Image source: Kitware Biomedical Visualization Contest


What is better than just ITK and VTK?

ITK / VTK and Python!

The recent release of VTK 7.0.0 and ITK 4.9.0 now makes it possible to connect ITK / VTK pipelines in Python 3. The snippet below demonstates how easy it is to avoid code duplication and use the “best of breed” from each toolkit: visualization with VTK and image analysis with ITK.

import sys
import itk
import vtk

if len(sys.argv) < 2:
    print('Usage: ' + sys.argv[0] + ' <InputFileName>')
imageFileName = sys.argv[1]

Dimension = 2
PixelType = itk.UC
ImageType = itk.Image[PixelType, Dimension]

reader = itk.ImageFileReader[ImageType].New()

itkToVtkFilter = itk.ImageToVTKImageFilter[ImageType].New()

myvtkImageData = itkToVtkFilter.GetOutput()

For more information, including a downloadable version with code and data, see the full example.


3 comments to How to Connect ITK and VTK Pipelines

  1. Great article ! Illustrated, simple, to the point 🙂
    I might have a preference for the third combination though.

Leave a Reply