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, 'vtk.vtkXMLImageDataReader', 'vtk.vtkXMLImageDataReader', False, 'import vtk\n'), (9, 'vtk.vtkImageDataGeometryFilter', 'vtk.vtkImageDataGeometryFilter', False, 'import vtk\n'), (14, 'vtk.vtkContourFilter', 'vtk.vtkContourFilter', False, 'import vtk\n'), (18, 'vtk.vtkPolyDataMapper', 'vtk.vtkPolyDataMapper', False, 'import vtk\n'), (25, 'vtk.vtkActor', 'vtk.vtkActor', False, 'import vtk\n'), (28, 'vtk.vtkActor', 'vtk.vtkActor', False, 'import vtk\n'), (32, 'vtk.vtkRenderer', 'vtk.vtkRenderer', False, 'import vtk\n'), (37, 'vtk.vtkRenderWindow', 'vtk.vtkRenderWindow', False, 'import vtk\n'), (40, 'vtk.vtkRenderWindowInteractor', 'vtk.vtkRenderWindowInteractor', False, 'import vtk\n')]