# Option to disable smoothing of the segment surfaces in Segment Editor

**URL:** https://discourse.slicer.org/t/option-to-disable-smoothing-of-the-segment-surfaces-in-segment-editor/883
**Category:** Feature requests
**Tags:** segmentation
**Created:** [August 16, 2017, 7:33pm UTC](https://discourse.slicer.org/t/option-to-disable-smoothing-of-the-segment-surfaces-in-segment-editor/883 "2017-08-16T19:33:27Z")
**Posts on this page:** 17
**Page:** 1

<div class="post-metadata">

### Author: ![fedorov](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fedorov/32/14_2.png) [@fedorov](https://discourse.slicer.org/u/fedorov)
#### Post date: [August 16, 2017, 7:33pm UTC](https://discourse.slicer.org/t/option-to-disable-smoothing-of-the-segment-surfaces-in-segment-editor/883/1 "2017-08-16T19:33:27Z")

</div>

I think it might be helpful to add an option to Segment Editor to disable smoothing of the surface when generating it from the label map representation. When regions are small, smoothing can lead to significant under-estimation of the boundary, as shown in the screenshot below.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/a/3/a3826cc54a9f7b063ce79afb60fd4517bcdd72e5.jpeg)

Of note, the option to disable smoothing was available in the legacy editor.

The segmentation dataset used in this example is publicly available in the [TCIA QIN-HEADNECK collection](https://wiki.cancerimagingarchive.net/display/Public/QIN-HEADNECK), and can be downloaded using the [TCIABrowser extension](https://www.slicer.org/wiki/Documentation/Nightly/Extensions/TCIABrowser). You will need to install [Quantitative Reporting extension](https://qiicr.gitbooks.io/quantitativereporting-guide/) first to be able to load DICOM SEG series. The details on patient/study/series are shown below.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/4/8/480d4d0fda5f4dca7f84768fd30110d4d376e0d3.png)

---

<div class="post-metadata">

### Author: ![Lorensen](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lorensen/32/31_2.png) [@Lorensen](https://discourse.slicer.org/u/Lorensen)
#### Post date: [August 16, 2017, 8:25pm UTC](https://discourse.slicer.org/t/option-to-disable-smoothing-of-the-segment-surfaces-in-segment-editor/883/2 "2017-08-16T20:25:21Z")

</div>

What smoothing is used?

---

<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: [August 16, 2017, 8:31pm UTC](https://discourse.slicer.org/t/option-to-disable-smoothing-of-the-segment-surfaces-in-segment-editor/883/3 "2017-08-16T20:31:02Z")

</div>

It’s true that smoothing parameter requires a lot of clicks. I’ve added a ticket to the issue tracker to address it: [https://issues.slicer.org/view.php?id=4415](https://issues.slicer.org/view.php?id=4415)

---

<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: [August 16, 2017, 8:34pm UTC](https://discourse.slicer.org/t/option-to-disable-smoothing-of-the-segment-surfaces-in-segment-editor/883/4 "2017-08-16T20:34:38Z")

</div>

vtkWindowedSincPolyDataFilter is used, see the filter setup code here: [https://github.com/Slicer/Slicer/blob/481873378dfbbdbe2b17db8feedf11496280b9ba/Libs/vtkSegmentationCore/vtkBinaryLabelmapToClosedSurfaceConversionRule.cxx#L197-L212](https://github.com/Slicer/Slicer/blob/481873378dfbbdbe2b17db8feedf11496280b9ba/Libs/vtkSegmentationCore/vtkBinaryLabelmapToClosedSurfaceConversionRule.cxx#L197-L212)

Maybe we could normalize default PassBand cutoff frequency by the spacing of the input binary labelmap to not require any tuning based on the voxel size.

---

<div class="post-metadata">

### Author: ![Lorensen](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lorensen/32/31_2.png) [@Lorensen](https://discourse.slicer.org/u/Lorensen)
#### Post date: [August 16, 2017, 8:36pm UTC](https://discourse.slicer.org/t/option-to-disable-smoothing-of-the-segment-surfaces-in-segment-editor/883/5 "2017-08-16T20:36:16Z")

</div>

Have you considered a “cubes” display. It shows each vowel on the surface of the segmentation. Here is an example from the BWH Brain Atlas.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/e/9/e9d274166378c5be803e4f8aa8510c37f7100f36.png)

The left image is smoothed, the right image shows cubes.

---

<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: [August 16, 2017, 8:41pm UTC](https://discourse.slicer.org/t/option-to-disable-smoothing-of-the-segment-surfaces-in-segment-editor/883/6 "2017-08-16T20:41:22Z")

</div>

I can imagine that for certain applications cube may be acceptable but it often provides very poor results (you cannot even make out the shape of a segment).

If smoothing is done right, it just removes artifacts due to finite resolution. If relevant details are lost as a result of smoothing (there is no smoothing factor that removes staircase artifacts without removing relevant details) then it means that a supersampled binary labelmap or a fractional labelmap has to be used.

---

<div class="post-metadata">

### Author: ![Lorensen](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lorensen/32/31_2.png) [@Lorensen](https://discourse.slicer.org/u/Lorensen)
#### Post date: [August 16, 2017, 8:43pm UTC](https://discourse.slicer.org/t/option-to-disable-smoothing-of-the-segment-surfaces-in-segment-editor/883/7 "2017-08-16T20:43:05Z")

</div>

Cubes are useful when editing, not as a final rep. You can see each vowel.

---

<div class="post-metadata">

### Author: ![Lorensen](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lorensen/32/31_2.png) [@Lorensen](https://discourse.slicer.org/u/Lorensen)
#### Post date: [August 16, 2017, 8:44pm UTC](https://discourse.slicer.org/t/option-to-disable-smoothing-of-the-segment-surfaces-in-segment-editor/883/8 "2017-08-16T20:44:02Z")

</div>

Not sure of the units. I always use .001 for bandpass

---

<div class="post-metadata">

### Author: ![Lorensen](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lorensen/32/31_2.png) [@Lorensen](https://discourse.slicer.org/u/Lorensen)
#### Post date: [August 16, 2017, 8:49pm UTC](https://discourse.slicer.org/t/option-to-disable-smoothing-of-the-segment-surfaces-in-segment-editor/883/9 "2017-08-16T20:49:30Z")

</div>

To produce the final smoothed models, you should process all labels at once. Segments that touch will remain touching after smoothing. If the entire volume is segmented, this will reduce the shrinkage.

This example does that.  
[https://lorensen.github.io/VTKExamples/site//Cxx/Medical/GenerateModelsFromLabels/](https://lorensen.github.io/VTKExamples/site//Cxx/Medical/GenerateModelsFromLabels/)

---

<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: [August 16, 2017, 9:00pm UTC](https://discourse.slicer.org/t/option-to-disable-smoothing-of-the-segment-surfaces-in-segment-editor/883/10 "2017-08-16T21:00:23Z")

</div>

Segments are independent volumes that may even overlap each other, but we do use this joint smoothing technique when we apply smoothing to _modify_ segments (to remove noise or segmentation errors). For _display_, we only apply just as much smoothing to remove staircase artifacts.

Do you think it would make a difference if we didn’t just smooth a structure as is but we add a “negative” structure around it and smooth together? (other than of course that the structure’s surface will not be treated as a boundary anymore, so BoundarySmoothing flag will have no effect)

---

<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: [August 16, 2017, 9:05pm UTC](https://discourse.slicer.org/t/option-to-disable-smoothing-of-the-segment-surfaces-in-segment-editor/883/11 "2017-08-16T21:05:15Z")

</div>

What filter do you use to generate the cubes display? Is it faster than marching cubes?

---

<div class="post-metadata">

### Author: ![fedorov](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fedorov/32/14_2.png) [@fedorov](https://discourse.slicer.org/u/fedorov)
#### Post date: [August 16, 2017, 9:05pm UTC](https://discourse.slicer.org/t/option-to-disable-smoothing-of-the-segment-surfaces-in-segment-editor/883/12 "2017-08-16T21:05:54Z")

</div>

Setting smoothing factor to 0 in the “Advanced segmentation conversion” setting produces the result I wanted to see in this example. I think adding a checkbox somewhere in Segment Editor that would effectively reset this parameter to 0 would be helpful, and would provide functionality equivalent to what was available in the old Editor.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/f/1/f1fef2c7ba29420ff961a48ae94a7f5897a841f7.png)

---

<div class="post-metadata">

### Author: ![Lorensen](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lorensen/32/31_2.png) [@Lorensen](https://discourse.slicer.org/u/Lorensen)
#### Post date: [August 16, 2017, 9:19pm UTC](https://discourse.slicer.org/t/option-to-disable-smoothing-of-the-segment-surfaces-in-segment-editor/883/13 "2017-08-16T21:19:01Z")

</div>

It’s fast. It does not use a filter. It converts point data to cell data.

See:  
[https://lorensen.github.io/VTKExamples/site/Cxx/Medical/GenerateCubesFromLabels/](https://lorensen.github.io/VTKExamples/site/Cxx/Medical/GenerateCubesFromLabels/)

---

<div class="post-metadata">

### Author: ![Lorensen](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lorensen/32/31_2.png) [@Lorensen](https://discourse.slicer.org/u/Lorensen)
#### Post date: [August 16, 2017, 9:53pm UTC](https://discourse.slicer.org/t/option-to-disable-smoothing-of-the-segment-surfaces-in-segment-editor/883/14 "2017-08-16T21:53:04Z")

</div>

This version saves each model in a file. If could be convetted into a  
command line module.

> <https://github.com/lorensen/OpenAtlas/blob/master/Tools/GenerateCubesFromLabels.cxx>

---

<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: [August 16, 2017, 10:55pm UTC](https://discourse.slicer.org/t/option-to-disable-smoothing-of-the-segment-surfaces-in-segment-editor/883/15 "2017-08-16T22:55:08Z")

</div>

Thank you, I’ll have a look at this.

---

<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: [November 12, 2018, 6:05pm UTC](https://discourse.slicer.org/t/option-to-disable-smoothing-of-the-segment-surfaces-in-segment-editor/883/16 "2018-11-12T18:05:21Z")

</div>

> [@fedorov](#):
>
> I think adding a checkbox somewhere in Segment Editor that would effectively reset this parameter to 0 would be helpful

This is implemented now in Slicer [master branch](https://github.com/Slicer/Slicer/commit/06ae9980af2c01a8f38ee2e7cfd930375f729b6d) and should be available in tomorrow’s nightly build. A checkbox is available directly in the “Show 3D” button’s menu:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/f/d/fda2d861929e110207db1646ae654258ca05c099.png)

---

<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 7, 2021, 2:29pm UTC](https://discourse.slicer.org/t/option-to-disable-smoothing-of-the-segment-surfaces-in-segment-editor/883/17 "2021-10-07T14:29:07Z")

</div>

A post was merged into an existing topic: [Surface smoothing and exporting model](https://discourse.slicer.org/t/surface-smoothing-and-exporting-model/1144/6)
