# Recreating segmentation from 3D models

**URL:** <https://discourse.slicer.org/t/recreating-segmentation-from-3d-models/44922>\
**Category:** Support\
**Created:** [October 30, 2025, 7:42pm UTC](https://discourse.slicer.org/t/recreating-segmentation-from-3d-models/44922 "2025-10-30T19:42:55Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![muratmaga](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/muratmaga/32/3622_2.png) [@muratmaga](https://discourse.slicer.org/u/muratmaga)\
**Post date:** [October 30, 2025, 7:42pm UTC](https://discourse.slicer.org/t/recreating-segmentation-from-3d-models/44922/1 "2025-10-30T19:42:55Z")

</div>

Let’s say I have the original volume, and the segmentation object saved as a 3D model (like ply) on the disk, but not the actual seg.nrrd file.

What is the suggested operation to reconstitute the segmentation map close to the original detail for further edits?

---

<div class="post-metadata">

**Author:** ![mau\_igna\_06](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/mau_igna_06/32/9056_2.png) [@mau\_igna\_06](https://discourse.slicer.org/u/mau_igna_06)\
**Post date:** [November 1, 2025, 1:19am UTC](https://discourse.slicer.org/t/recreating-segmentation-from-3d-models/44922/2 "2025-11-01T01:19:08Z")

</div>

According to this [document](https://github.com/PerkLab/PerkLabBootcamp/blob/master/Doc/day1_4_SegmentationBasics.pptx) (slide N° 5), you should be able to convert back and forward from labelmap representation to surface representation without any information loss

---

<div class="post-metadata">

**Author:** ![muratmaga](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/muratmaga/32/3622_2.png) [@muratmaga](https://discourse.slicer.org/u/muratmaga)\
**Post date:** [November 1, 2025, 1:37am UTC](https://discourse.slicer.org/t/recreating-segmentation-from-3d-models/44922/3 "2025-11-01T01:37:03Z")

</div>

That’s what I thought, but wasn’t able to discover a way to do so. I tried creating a empty segment from the source volume I used to generate the model, and then use the import/export feature of the segmentations module to import the model into that blank segment use a labelmap.

Unfortunately, that’s not the same resolution at all, it ended up being fairly low res.

---

<div class="post-metadata">

**Author:** ![mau\_igna\_06](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/mau_igna_06/32/9056_2.png) [@mau\_igna\_06](https://discourse.slicer.org/u/mau_igna_06)\
**Post date:** [November 1, 2025, 1:42am UTC](https://discourse.slicer.org/t/recreating-segmentation-from-3d-models/44922/4 "2025-11-01T01:42:42Z")

</div>

According to this [example](https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#rasterize-a-model-and-save-it-to-a-series-of-image-files), it may be compulsory to set the geometry information for the segmentation

---

<div class="post-metadata">

**Author:** ![muratmaga](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/muratmaga/32/3622_2.png) [@muratmaga](https://discourse.slicer.org/u/muratmaga)\
**Post date:** [November 1, 2025, 1:44am UTC](https://discourse.slicer.org/t/recreating-segmentation-from-3d-models/44922/5 "2025-11-01T01:44:59Z")

</div>

That’s the part I am confused about. By creating a blank segmentation from the source volume, I assumed that the imported segmentation will inherit that geometry, but that’s not what I am seeing in experience.

Also for 3D models import/export feature of the Segmentations does not have a setting where you can put a reference volume to get the geometry from.

I must be overlooking something…

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [November 1, 2025, 12:03pm UTC](https://discourse.slicer.org/t/recreating-segmentation-from-3d-models/44922/6 "2025-11-01T12:03:09Z")

</div>

@muratmaga can you share a concrete example (a volume and model) and describe the steps you take? At first I thought you were asking about registering the model to the volume, but I guess you are more concerned about the resolution of the rasterized model?

---

<div class="post-metadata">

**Author:** ![muratmaga](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/muratmaga/32/3622_2.png) [@muratmaga](https://discourse.slicer.org/u/muratmaga)\
**Post date:** [November 1, 2025, 6:00pm UTC](https://discourse.slicer.org/t/recreating-segmentation-from-3d-models/44922/7 "2025-11-01T18:00:03Z")

</div>

It boiled down from which stage the models were exported. If you kept the smoothing option on when you enabled the Show 3D button, and then export the model, you irrecoverably lost detail.

1. Download the CTChest sample data, and segment bones (threshold 165-Max, closing filter 5, island tool to keep the largest island). Save the segmentation as seg.nrrd
2. Turn off smoothing in Show 3D button, then right-click on the segment in SH and export this segmentation as a model, export the model as ply.
3. Repeat the #2 but smoothing enabled (with default 0.5)
4. Reset the scene, reload the model the and the CT volume into the scene and try to create a high-resolution segmentation out these models.

When import #3 it is lower resolution than the labelmap generated from #2. In fact for me the import step #2 is 3-4 times longer than the one with smoothing enabled. You will see the difference in the labelmaps, not much for this low resolution sample data, but enough for us to make a difference for landmarking certain faint structures on dry bones such cranial sutures or small protuberances.

Unfortunately for this data, I think they were all exported with smoothing enabled, so I can’t find a way to generate higher detailed labelmaps version from them.

---

<div class="post-metadata">

**Author:** ![chir.set](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/chir.set/32/66982_2.png) [@chir.set](https://discourse.slicer.org/u/chir.set)\
**Post date:** [November 1, 2025, 8:20pm UTC](https://discourse.slicer.org/t/recreating-segmentation-from-3d-models/44922/8 "2025-11-01T20:20:00Z")

</div>

The code below creates a new segmentation, updates its geometry sampling with the volume node and imports a model. There are more details with the test CT-chest volume, following the steps you described. The difference appears when the Show 3D button is deactivated/activated in the segment editor, whether the code is run or the model is imported in the Data module. The difference is even more important if the model has been saved without 3D smoothing.

I have no idea how far it may be helpful to you.

```auto
def createSegmentationWithGeometryAndImportModel():
  volume = getNode("CT-chest")
  segmentation = slicer.mrmlScene.AddNewNodeByClass("vtkMRMLSegmentationNode")
  segmentation.CreateDefaultDisplayNodes()
  segmentation.SetReferenceImageGeometryParameterFromVolumeNode(volume)

  segGeomLogic = slicer.vtkSlicerSegmentationGeometryLogic()
  segGeomLogic.SetInputSegmentationNode(segmentation)
  segGeomLogic.SetSourceGeometryNode(volume)
  segGeomLogic.CalculateOutputGeometry()
  segGeomLogic.ResampleLabelmapsInSegmentationNode()
  segGeomLogic.SetReferenceImageGeometryInSegmentationNode()
  
  model = getNode("SmoothedPLY") # NoSmoothedPLY afterwards.
  segLogic = slicer.modules.segmentations.logic()
  segLogic.ImportModelToSegmentationNode(model, segmentation)

```

![ImportModel](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/6/9/69587e2cb1a29420ffbb75049ac3ace69b1d99b2.gif)
