我想在灰色图像上绘制一个点,我使用vtkImageViewer进行显示,但是在绘制一个点并将其渲染后我发现该点将不会显示,该怎么做? 我使用的是vtk 8.1.0,python 3.6.4,我的代码是这样的:
self.points = vtk.vtkPoints()
self.points.SetNumberOfPoints(1)
self.cells = vtk.vtkCellArray()
self.cells.SetNumberOfCells(1)
self.mapper = vtk.vtkPolyDataMapper2D()
self.pd = vtk.vtkPolyData()
self.actor = vtk.vtkActor2D()
clickpos = self.iren.GetEventPosition()
self.points.SetPoint(0, [clickpos[0], clickpos[1], 0])
self.cells.InsertCellPoint(0)
self.pd.SetPoints(self.points)
self.pd.SetPolys(self.cells)
elf.mapper.SetInputData(self.pd)
self.actor.SetMapper(self.mapper)
self.actor.GetProperty().SetColor(vtk.vtkNamedColors().GetColor3d('Black'))
self.actor.GetProperty().SetPointSize(1)
self.imageviewer.GetRenderer().AddViewProp(self.actor)
self.iren.Initialize()
self.imageviewer.Render()
self.iren.Start()