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()


[((77, 104), 'vtk.vtkXMLImageDataReader', 'vtk.vtkXMLImageDataReader', ([], {}), '()\n', (102, 104), False, 'import vtk\n'), ((252, 284), 'vtk.vtkImageDataGeometryFilter', 'vtk.vtkImageDataGeometryFilter', ([], {}), '()\n', (282, 284), False, 'import vtk\n'), ((477, 499), 'vtk.vtkContourFilter', 'vtk.vtkContourFilter', ([], {}), '()\n', (497, 499), False, 'import vtk\n'), ((640, 663), 'vtk.vtkPolyDataMapper', 'vtk.vtkPolyDataMapper', ([], {}), '()\n', (661, 663), False, 'import vtk\n'), ((913, 927), 'vtk.vtkActor', 'vtk.vtkActor', ([], {}), '()\n', (925, 927), False, 'import vtk\n'), ((977, 991), 'vtk.vtkActor', 'vtk.vtkActor', ([], {}), '()\n', (989, 991), False, 'import vtk\n'), ((1055, 1072), 'vtk.vtkRenderer', 'vtk.vtkRenderer', ([], {}), '()\n', (1070, 1072), False, 'import vtk\n'), ((1168, 1189), 'vtk.vtkRenderWindow', 'vtk.vtkRenderWindow', ([], {}), '()\n', (1187, 1189), False, 'import vtk\n'), ((1252, 1283), 'vtk.vtkRenderWindowInteractor', 'vtk.vtkRenderWindowInteractor', ([], {}), '()\n', (1281, 1283), False, 'import vtk\n')]