I’m trying to calculate external contour and then transform it into markups curve node.Here is a VTK example with such case. Position and orientation of camera are known. Segment polydata is white, background is black.
Can the same VTK filter be used in 3D Slicer, or the program has builtin methods for that?
Code below gives an empty polydata:
view = slicer.app.layoutManager().threeDWidget(0).threeDView()
renderWindow = view.renderWindow()
renderers = renderWindow.GetRenderers()
renderer = renderers.GetItemAsObject(0)
winToImageFilter = vtk.vtkWindowToImageFilter()
winToImageFilter.SetInput(renderWindow)
winToImageFilter.SetScale(2) #image quality
winToImageFilter.Update()
contFilter = vtk.vtkContourFilter()
contFilter.SetInputConnection(winToImageFilter.GetOutputPort())
contFilter.SetValue(0, 255)
contFilter.Update()
# Make the contour coincide with the data.
contour = contFilter.GetOutput()
Data example