Question on "export segments to models"

Hi,

This is related to my earlier post: Filters and parameters used in "export visible segments to model".

I’m trying to do the following: I have a binary labelmap that I load into Slicer. Then I click on the segment and select “Export visible segments to models”. In the model node, on its color box, I right click and select the checkbox for 2D visibility. The application then shows the segment as a thin contour in the 2D views. It seems to be smoother than the binary labelmap by default (see attached picture).

I’m trying to replicate this workflow from python - given a labelmap, I would like to process it to be able to get these contours. Does anyone have some suggestions on how I might be able to do this? If the specific VTK filters, parameters and code are available somewhere, can that be linked here?

Any help would be appreciated.

Thanks,
Chaitanya

It is smoother because the closed surface conversion does some smoothing after the triangle creation (according to a parameter that is easy to change), so that the object approximate better the reality. The vertices in the closed surface representation have an infinite accuracy as opposed to the fixed sized voxels of the binary labelmap, so it makes sense to try to make it more realistic.

The visualization pipeline is in the displayable manager, and in that there is a cutter filter that creates the 2D contours from the 3D surface based on the slice plane:

1 Like

Thanks, this helps. Is this the function that does the binary labelmap to closed surface conversion? Are these the primary variables that control smoothing?

  • smoothingFactor
  • jointSmoothing
  • decimationFactor

What I posted is the displayable manager that creates the 2D contours for the slice. It has nothing to do with internal conversion within segmentations, which is 3D->3D.

I’m sorry, maybe I wasn’t clear. I was referring to the code snippet I posted in my response. I’m looking at this function.

bool vtkBinaryLabelmapToClosedSurfaceConversionRule::Convert(vtkSegment* segment)

Is that the place where the conversion from binary labelmap to closed surface happens? I see some variables there that seem to control smoothing (smoothingFactor, jointSmoothing, decimationFactor) - were those the parameters you were referring to? Are those parameters available to change from Slicer’s UI?

Found these parameters in Segmentations > Representations > Closed Surface > Advanced create…

Yes it is. Sorry if I misunderstood. This is the filter that internally converts the source (formerly master) labelmap into closed surface when requested for 3D visualization, as the conversion diagram shows here
https://slicer.readthedocs.io/en/latest/user_guide/image_segmentation.html#representations

The parameters you found are the parameters that these conversion “rules” expose. You can fine-tune the output using these.

The displayable managers on the other hand are classes that create the actors in the views (2D and 3D) to show the desired displayed representation. This is why the 2D displayable manager for the segmentation needs to do cutting if the representation to show is closed surface, because we need to show the contour that is the intersection of the surface with the slice plane.

1 Like