# How can I avoid holes in the output when converting a model to segmentation?

**URL:** <https://discourse.slicer.org/t/how-can-i-avoid-holes-in-the-output-when-converting-a-model-to-segmentation/32388>\
**Category:** Support\
**Tags:** segmentation\
**Created:** [October 23, 2023, 6:23pm UTC](https://discourse.slicer.org/t/how-can-i-avoid-holes-in-the-output-when-converting-a-model-to-segmentation/32388 "2023-10-23T18:23:37Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yu.Mingzhong\_Michael](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/yu.mingzhong_michael/32/65929_2.png) [@Yu.Mingzhong\_Michael](https://discourse.slicer.org/u/Yu.Mingzhong_Michael)\
**Post date:** [October 23, 2023, 6:23pm UTC](https://discourse.slicer.org/t/how-can-i-avoid-holes-in-the-output-when-converting-a-model-to-segmentation/32388/1 "2023-10-23T18:23:37Z")

</div>

Hi,  
I am using Slicer 5.0.2 to convert a model file (.ply) to segmentation mask image, with the following functions : 1. convert model to segmentation node; 2. export visible segmentation to binary label map.

But when I view the volume rending image of the binary label map, I find that there several holes in the surface. I want to know how to get a segmentation mask image without the annoying holes, and why the holes are generated?

Thanks!

* * *

Operating system:Windows  
Slicer version:5.0.2  
Expected behavior:  
Actual behavior:

---

<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:** [October 23, 2023, 6:35pm UTC](https://discourse.slicer.org/t/how-can-i-avoid-holes-in-the-output-when-converting-a-model-to-segmentation/32388/2 "2023-10-23T18:35:03Z")

</div>

My first guess is that you are not sampling the surface models with high enough resolution to capture the shape of your model well. Try a higher sampling grid. If you’re not sure how we can explain.

To give better answers you could post some screenshots so we know what you are describing.

---

<div class="post-metadata">

**Author:** ![Yu.Mingzhong\_Michael](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/yu.mingzhong_michael/32/65929_2.png) [@Yu.Mingzhong\_Michael](https://discourse.slicer.org/u/Yu.Mingzhong_Michael)\
**Post date:** [October 24, 2023, 3:29am UTC](https://discourse.slicer.org/t/how-can-i-avoid-holes-in-the-output-when-converting-a-model-to-segmentation/32388/3 "2023-10-24T03:29:14Z")

</div>

maybe low resolution of the model is the reason of the holes generated,  
this is the original model

 ![original_model](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/8/a/8a95a80b2ed9dd881763b52b2f2d2696868d7bb9.png)  
and the labelmap (volume rendering) after conversion is  
 ![binary_labelmap](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/0/4/04b77e1ef479e5704a3743143bd6bad6be15f091.png)  
several holes can be seen on it.  
I tried to upload the the original model file (.ply), but not authorized to do so.

I’m wondering, if any chance that something in the program is not good enough converting the segmentation node to binary labelmap.

thanks for your help.

---

<div class="post-metadata">

**Author:** ![Yu.Mingzhong\_Michael](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/yu.mingzhong_michael/32/65929_2.png) [@Yu.Mingzhong\_Michael](https://discourse.slicer.org/u/Yu.Mingzhong_Michael)\
**Post date:** [October 24, 2023, 3:36am UTC](https://discourse.slicer.org/t/how-can-i-avoid-holes-in-the-output-when-converting-a-model-to-segmentation/32388/4 "2023-10-24T03:36:58Z")

</div>

would you please give me some ideas on how to sampling the surface model with higher sampling grid. I tried to look for some parameter settings on it in Slicer, but found nothing.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [October 24, 2023, 1:13pm UTC](https://discourse.slicer.org/t/how-can-i-avoid-holes-in-the-output-when-converting-a-model-to-segmentation/32388/5 "2023-10-24T13:13:43Z")

</div>

See these [step-by-step instructions for importing a model into a segmentation](https://slicer.readthedocs.io/en/latest/user_guide/modules/segmentations.html#import-an-existing-segmentation-from-model-surface-mesh-file) with as high accuracy as you need.

---

<div class="post-metadata">

**Author:** ![Yu.Mingzhong\_Michael](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/yu.mingzhong_michael/32/65929_2.png) [@Yu.Mingzhong\_Michael](https://discourse.slicer.org/u/Yu.Mingzhong_Michael)\
**Post date:** [October 26, 2023, 1:22am UTC](https://discourse.slicer.org/t/how-can-i-avoid-holes-in-the-output-when-converting-a-model-to-segmentation/32388/6 "2023-10-26T01:22:44Z")

</div>

Thanks a lot! I finally get binary labelmap without holes with the instructions. But the labelmap image file saved becomes so large, from original 400K to nearly 21M.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [October 26, 2023, 1:32am UTC](https://discourse.slicer.org/t/how-can-i-avoid-holes-in-the-output-when-converting-a-model-to-segmentation/32388/7 "2023-10-26T01:32:25Z")

</div>

This is normal. Labelmap representation of an object can be infinitely larger than its closed surface representation. The size of the labelmap representation depends on the chosen resolution.

If you only need to segment anatomical structures then you usually don’t need to go below the original CT image resolution, which is not that big (usually less than 512 x 512 x 512 voxels). However, if you also want to represent CAD models with high accuracy in the segmentation then you may need to increase the resolution a lot. Therefore, it can make sense to design your workflow so that you finish all your anatomical segmentations, export to model (closed surface), and combine that with CAD models (e.g., using “Combine Models” module in Sandbox extension).

If you export the segmentation to a model again then you can reduce the file size dramatically (e.g., by 99%) with barely visible change in appearance, by using the `Surface Toolbox` module’s `Decimate` option.
