# Speed issues during segmentation

**URL:** <https://discourse.slicer.org/t/speed-issues-during-segmentation/37207>\
**Category:** Support\
**Created:** [July 5, 2024, 8:50am UTC](https://discourse.slicer.org/t/speed-issues-during-segmentation/37207 "2024-07-05T08:50:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Istvan](https://avatars.discourse-cdn.com/v4/letter/i/3da27b/32.png) [@Istvan](https://discourse.slicer.org/u/Istvan)\
**Post date:** [July 5, 2024, 8:50am UTC](https://discourse.slicer.org/t/speed-issues-during-segmentation/37207/1 "2024-07-05T08:50:09Z")

</div>

_Windows version:_ 10.0.22631 Build 22631  
_Slicer Version:_ 4.11.20200930 r29402 / 002be18  
_Expected behavior:_ similar slicing speed in case of a geometry and also in case of its inverse  
_Actual behavior:_ significant difference in slicing speed

Hello,  
we are using Slicer to slice geometries stored in .stl files. The output is stored in black&white .bmp-s.  
For each geometry we process two .stl files. If there is volume at a certain coordinate in the first file, there is no volume at the same coordinate in the second file, and vice versa. In other words, the first geometry is the inverse of the second geometry.  
Interestingly the processing of the first file is done in a couple of minutes, however, for the second file it can take up to an hour. As I measured the processing time of each phase, it turned out, that the most time consuming step is the  
_seg.GetSegmentation().CreateRepresentation(‘Binary labelmap’, True)_ for each slice.  
Since we have quite a few .stl-s each day, it would be a huge gain if we could reduce the processing time also for the second, inverse geometry.  
What do you think, what could cause the significant time difference in the processing of the two files? Do you have perhaps a recommendation how to accelerate the process?

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [July 5, 2024, 11:06am UTC](https://discourse.slicer.org/t/speed-issues-during-segmentation/37207/2 "2024-07-05T11:06:52Z")

</div>

Such significant speed decrease reminds me of the exponentially increasing processing time as the number of segments increase.

If it is not implemented like that already, make sure you always start with an empty segmentation for each of your STLs.
