Extract segment labelmap as 2D slices

Hi there,

I intend to use 3D slicer to create annotations for training a Detectron2 model. I have found the examples for converting segmentations (labelmaps) into numpy arrays using the Python API. My data is 3D, and the example scripts generate labelmaps that are 3D arrays.

My problem now is that Detectron2 is a 2D CNN, so I need to provide 2D masks and their bounding boxes. Since I painted the segmentations through the “axial slice view”, I was wondering if there is a built-in way to retrieve the 2D strokes that I used to paint the segmentations for each segment.

Below, you can see that I am annotating spherical structures. Each segment contains multiple annotated slices, and I would like to export each slice as a 2D Mask.

Thank you in advance,
Marc