这里有这样的代码。
import vtk
file_name = "1.vtk"
reader = vtk.vtkUnstructuredGridReader()
reader.SetFileName(file_name)
reader.Update() # Needed because of GetScalarRange
output = reader.GetOutput()
scalar_range = output.GetScalarRange()
lut = vtk.vtkLookupTable()
mapper = vtk.vtkDataSetMapper()
if vtk.VTK_MAJOR_VERSION <= 5:
mapper.SetInput(output)
else:
mapper.SetInputData(output)
mapper.SetScalarRange(scalar_range )
mapper.SetLookupTable(lut)
print(mapper)
actor = vtk.vtkActor()
actor.SetMapper(mapper)
scalar_bar = vtk.vtkScalarBarActor()
scalar_bar.SetLookupTable(lut)
scalar_bar.SetTitle(u'AS1_X\nARM')
renderer = vtk.vtkRenderer()
renderer.AddActor(actor)
renderer.SetBackground(0.1, 0.2, 0.4)
renderer.AddActor2D(scalar_bar)
render_window = vtk.vtkRenderWindow()
render_window.AddRenderer(renderer)
render_window.SetSize(800, 600)
interactor = vtk.vtkRenderWindowInteractor()
interactor.SetRenderWindow(render_window)
interactor.Initialize()
render_window.Render()
interactor.Start()
他给这张照片 https://i.stack.imgur.com/jgsWP.png 但是我不喜欢这样的地图,我需要拿这张卡... https://i.stack.imgur.com/Nochv.png 我也想在标量栏中签名这些值。 原则上,我会在Paraview的帮助下完成所有这些工作,但是必须有相当多的经验,我想自动创建所有内容。