Can I extract the outline of a single closed segment?

Can I extract the outline/contour of each slice of closed segment and then draw a closed curve from it with code?

Yes, sure. You can retrieve the closed surface representation of the segment, get intersection by using VTK cut filter, sort the points using vtkContourTriangulator, then add the polygon points as curve control points. This code may help: https://github.com/Slicer/Slicer/pull/1075/files

I donnot know how to get intersection and create a closed curve from points after covert the segment to a polygon data with python(just learned python). Could you help me?
segmentationNode=getNode(‘Segmentation’)
segmentId = segmentationNode.GetSegmentation().GetNthSegmentID(0)
segmentPolyData=segmentationNode.GetClosedSurfaceRepresentation(segmentId)

Once you have the closed surface representation, use standard VTK filters, as they are used in the segmentation displayable manager (see relevant code in the pull request above). You can get learn about VTK by studying the VTK textbook and VTK examples website.

Hallo, Dr. Lassoan. I also want to get the outline from a reformat slice.
I tried the vtk cutter. The problem is that the polydata I get from the segment do not have the attribute of GetOutputPort().

n = getNode(nameSeg)
s = n.GetSegmentation()
ss = s.GetSegment(s.GetSegmentIdBySegmentName(nameRegion)).GetRepresentation(‘Closed surface’)
circleCutter = vtk.vtkCutter()

I cannot get the GetOutputPort from ss

circleCutter.SetInputConnection(ss.GetOutputPort())

To set input data in a VTK filter, use SetInputData method.

Dear Dr. Lassoan
Thank you so much!