VTK 7.0.0 ImageTracerWidget隐藏在imageactor后面

时间:2016-04-25 02:10:28

标签: python vtk

使用python,我试图在图像周围绘制ROI。为了测试,我有以下代码。但是,字形隐藏在图像后面。当我降低覆盖图像的透明度时,我也看不到绘制的ROI:

import vtk


imageSource = vtk.vtkImageCanvasSource2D()

imageSource.SetScalarTypeToUnsignedChar();
imageSource.SetNumberOfScalarComponents(3);
imageSource.SetExtent(0, 20, 0, 50, 0, 0);
imageSource.SetDrawColor(0, 0, 0);
imageSource.FillBox(0, 20, 0, 50);
imageSource.SetDrawColor(255, 0, 0);
imageSource.FillBox(0, 10, 0, 30);
imageSource.Update();

actor = vtk.vtkImageActor()
actor.GetMapper().SetInputConnection(imageSource.GetOutputPort())
actor.VisibilityOn()
actor.AddPosition(10,10,-13)
actor.InterpolateOff()

ip = vtk.vtkImageProperty()
ip.SetColorWindow(2000)
ip.SetColorLevel(1000)
ip.SetAmbient(0.0)
ip.SetDiffuse(1.0)
ip.SetOpacity(1.0)
ip.SetInterpolationTypeToLinear()

actor.SetProperty(ip)


renderer = vtk.vtkRenderer()

renderer.AddActor(actor)
renderer.ResetCamera()


renderWindow= vtk.vtkRenderWindow()
renderWindow.AddRenderer(renderer)

interactor = vtk.vtkRenderWindowInteractor()
interactor.SetRenderWindow(renderWindow)

style = vtk.vtkInteractorStyleImage()
interactor.SetInteractorStyle(style)



tracer = vtk.vtkImageTracerWidget()

tracer.SetInteractor(interactor)
tracer.SetViewProp(actor)
tracer.AutoCloseOn()

renderWindow.Render()
tracer.On()

vtk.vtkMapper.SetResolveCoincidentTopologyToPolygonOffset()  
vtk.vtkMapper.SetResolveCoincidentTopologyPolygonOffsetParameters(10,10)


interactor.Start()

在这里不知所措。我希望有人可以帮助我摆脱困境!

2 个答案:

答案 0 :(得分:1)

这个问题似乎是上一个VTK-7.0.0中的一个错误。我将我的设置恢复为VTK-6.1.0并解决了问题。现在VTKImageTracerWidget绘制得很好

答案 1 :(得分:0)

我发现它已在VTK8.0&#34中修复;它正在修改这些行而不调用它们上的修改"

更多细节: " https://github.com/Kitware/VTK/commit/35e42be7eb61ed5d0dbea6db468776080e900443#diff-4374799689b56389f1a2c2f6fc250110