import vtk

# Read the file (to test that it was written correctly)
reader = vtk.vtkXMLImageDataReader()
reader.SetFileName("../data/wind_image.vti")
reader.Update()
print(reader.GetOutput())
# Convert the image to a polydata
imageDataGeometryFilter = vtk.vtkImageDataGeometryFilter()
imageDataGeometryFilter.SetInputConnection(reader.GetOutputPort())
imageDataGeometryFilter.Update()

scalarRange = reader.GetOutput().GetPointData().GetScalars().GetRange(-1)
contoursFilter = vtk.vtkContourFilter()
contoursFilter.SetInputConnection(imageDataGeometryFilter.GetOutputPort())
contoursFilter.GenerateValues(60, scalarRange)

contoursMapper = vtk.vtkPolyDataMapper()
contoursMapper.SetInputConnection(contoursFilter.GetOutputPort())
contoursMapper.SetColorModeToMapScalars()
contoursMapper.ScalarVisibilityOn()
contoursMapper.SelectColorArray("JPEGImage")
contoursMapper.SetScalarRange(scalarRange)

contoursActor = vtk.vtkActor()
contoursActor.SetMapper(contoursMapper)

actor = vtk.vtkActor()
actor.SetMapper(contoursMapper)
 
# Setup rendering
renderer = vtk.vtkRenderer()
renderer.AddActor(actor)
renderer.SetBackground(1,1,1)
renderer.ResetCamera()
 
renderWindow = vtk.vtkRenderWindow()
renderWindow.AddRenderer(renderer)
 
renderWindowInteractor = vtk.vtkRenderWindowInteractor()
 
renderWindowInteractor.SetRenderWindow(renderWindow)
renderWindowInteractor.Start()


[((4, 9, 4, 36), 'vtk.vtkXMLImageDataReader', 'vtk.vtkXMLImageDataReader', ({}, {}), '()', False, 'import vtk\n'), ((9, 26, 9, 58), 'vtk.vtkImageDataGeometryFilter', 'vtk.vtkImageDataGeometryFilter', ({}, {}), '()', False, 'import vtk\n'), ((14, 17, 14, 39), 'vtk.vtkContourFilter', 'vtk.vtkContourFilter', ({}, {}), '()', False, 'import vtk\n'), ((18, 17, 18, 40), 'vtk.vtkPolyDataMapper', 'vtk.vtkPolyDataMapper', ({}, {}), '()', False, 'import vtk\n'), ((25, 16, 25, 30), 'vtk.vtkActor', 'vtk.vtkActor', ({}, {}), '()', False, 'import vtk\n'), ((28, 8, 28, 22), 'vtk.vtkActor', 'vtk.vtkActor', ({}, {}), '()', False, 'import vtk\n'), ((32, 11, 32, 28), 'vtk.vtkRenderer', 'vtk.vtkRenderer', ({}, {}), '()', False, 'import vtk\n'), ((37, 15, 37, 36), 'vtk.vtkRenderWindow', 'vtk.vtkRenderWindow', ({}, {}), '()', False, 'import vtk\n'), ((40, 25, 40, 56), 'vtk.vtkRenderWindowInteractor', 'vtk.vtkRenderWindowInteractor', ({}, {}), '()', False, 'import vtk\n')]