# Masking: "Overwrite visible" allowing overlap instead of overwriting

**URL:** <https://discourse.slicer.org/t/masking-overwrite-visible-allowing-overlap-instead-of-overwriting/14857>\
**Category:** Support\
**Tags:** segmentation\
**Created:** [December 2, 2020, 11:49pm UTC](https://discourse.slicer.org/t/masking-overwrite-visible-allowing-overlap-instead-of-overwriting/14857 "2020-12-02T23:49:18Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![sioussou](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/sioussou/32/9045_2.png) [@sioussou](https://discourse.slicer.org/u/sioussou)\
**Post date:** [December 2, 2020, 11:49pm UTC](https://discourse.slicer.org/t/masking-overwrite-visible-allowing-overlap-instead-of-overwriting/14857/1 "2020-12-02T23:49:18Z")

</div>

Problem report for Slicer 4.11.20200930 win-amd64: in segment editor, I’ve set the masking option “Modify other segments” to “Overwrite visible” before applying smoothing [closing (fill holes) - 1.00mm]. If any of my segments is then hidden before applying the effect, the visible segments end up overlapping instead of one overwriting the other as expected.

Confirmed that performing the analogous operation in Slicer 4.10.2 (same volume, segmentation, “Overwrite other segments” set to “Visible segments”) results in expected overwriting behavior.

Is this a bug or did the functionality of this masking option change? If it changed, is there still a way to cause an effect to overwrite visible segments as in 4.10.2?

Thanks!

---

<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:** [December 3, 2020, 12:07am UTC](https://discourse.slicer.org/t/masking-overwrite-visible-allowing-overlap-instead-of-overwriting/14857/2 "2020-12-03T00:07:57Z")

</div>

I can’t reproduce this:  
This is what I did: created yellow and green segments, and then hid the yellow and create the brown segment using the overwrite to visible segments. As expect it overwrote the green but, overlapped with yellow since it was hidden at the time.

Is this not the behavior you expect?

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/f/a/fa5297458391a90606b50eca695d647e37605c45.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:** [December 3, 2020, 5:05am UTC](https://discourse.slicer.org/t/masking-overwrite-visible-allowing-overlap-instead-of-overwriting/14857/3 "2020-12-03T05:05:59Z")

</div>

> [@sioussou](#):
>
> Problem report for Slicer 4.11.20200930 win-amd64: in segment editor, I’ve set the masking option “Modify other segments” to “Overwrite visible” before applying smoothing [closing (fill holes) - 1.00mm]. If any of my segments is then hidden before applying the effect, the visible segments end up overlapping instead of one overwriting the other as expected

This is the correct behavior. “Overwrite visible” means that only visible segments are overwritten.

---

<div class="post-metadata">

**Author:** ![sioussou](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/sioussou/32/9045_2.png) [@sioussou](https://discourse.slicer.org/u/sioussou)\
**Post date:** [December 3, 2020, 6:15pm UTC](https://discourse.slicer.org/t/masking-overwrite-visible-allowing-overlap-instead-of-overwriting/14857/4 "2020-12-03T18:15:24Z")

</div>

> [@muratmaga](#):
>
> This is what I did: created yellow and green segments, and then hid the yellow and create the brown segment using the overwrite to visible segments. As expect it overwrote the green but, overlapped with yellow since it was hidden at the time.

Confirming that if I follow the procedure you’ve described I reproduce the same results and this is the behavior I expect.

However, the problem I’m seeing occurs under slightly different circumstances:

1. Create green, yellow, and brown segments  
 ![step-1](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/9/9/999192f6526d19f55c739de1a2cddad0b051bd54.jpeg)
2. Hide brown segment
3. Switch “Modify other segments” to Overwrite visible
4. Apply smoothing [closing (fill holes) - 3.0mm] to yellow  
 ![step-4](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/4/8/48abbe2ad0f5d2cc27d706526f773458f892e9c6.png)

Since yellow and green are visible, I’m expecting the smoothing effect on yellow to overwrite parts of green; instead they end up overlapping, which can be further confirmed by hiding the yellow layer.

 ![step-4-confirm](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/6/a/6a47d12308b91d0e0a60749a2f2711e55a0efd13.png)

---

<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:** [December 3, 2020, 6:21pm UTC](https://discourse.slicer.org/t/masking-overwrite-visible-allowing-overlap-instead-of-overwriting/14857/5 "2020-12-03T18:21:45Z")

</div>

Himm, this looks like a bug, perhaps @lassoan can comment. Meanwhile if you need to make progress, you can subtract yellow from green using `logical operators` to get what you need.

---

<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:** [December 4, 2020, 1:31am UTC](https://discourse.slicer.org/t/masking-overwrite-visible-allowing-overlap-instead-of-overwriting/14857/6 "2020-12-04T01:31:52Z")

</div>

@Sunderlandkyl has fixed this recently. The problem is not reproducible in Slicer Preview Release.

---

<div class="post-metadata">

**Author:** ![sioussou](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/sioussou/32/9045_2.png) [@sioussou](https://discourse.slicer.org/u/sioussou)\
**Post date:** [December 8, 2020, 1:28pm UTC](https://discourse.slicer.org/t/masking-overwrite-visible-allowing-overlap-instead-of-overwriting/14857/7 "2020-12-08T13:28:38Z")

</div>

> [@lassoan](#):
>
> @Sunderlandkyl has fixed this recently. The problem is not reproducible in Slicer Preview Release.

Conducted the test from my previous post in the most recent Slicer Preview Release (Slicer 4.13.0-2020-12-07 win-amd64) and the issue is still present 😕

---

<div class="post-metadata">

**Author:** ![jamesobutler](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jamesobutler/32/7511_2.png) [@jamesobutler](https://discourse.slicer.org/u/jamesobutler)\
**Post date:** [December 8, 2020, 2:03pm UTC](https://discourse.slicer.org/t/masking-overwrite-visible-allowing-overlap-instead-of-overwriting/14857/8 "2020-12-08T14:03:21Z")

</div>

I was able to replicate using Slicer 4.13.0-2020-12-07 as well. There is different behavior if Segment\_3 is hidden or shown when applying “Closing (fill holes)” smoothing to the selected visible Segment\_2.

1. My 3 segments originally applied with default “Overwrite all”.  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/a/b/ab91db7a779d38da84bb5a2d4e79f03d410ab27f.jpeg)
2. Segment\_3 remains visible and applying “Closing (fill holes)” for Segment\_2 with “Overwrite visible”. Segment\_2 is filled in correctly and also correctly overwrites Segment\_1. ✅  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/0/3/0316596c1ead14c6c2bd94e16725082b1262108a.jpeg)
3. Undo that last action and instead hide Segment\_3 and then select Segment\_2 again and applying “Closing (fill holes)” for Segment\_2 with “Overwrite visible”. Segment\_2 new area from smoothing is overlapping Segment\_1 instead of overwriting. ❌  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/5/a/5a8901d3adc2732c5f6f1e02ba9c03a1e89e3bb0.jpeg)

---

<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:** [December 9, 2020, 6:08am UTC](https://discourse.slicer.org/t/masking-overwrite-visible-allowing-overlap-instead-of-overwriting/14857/9 "2020-12-09T06:08:36Z")

</div>

Thanks a lot, based on your description I was able to reproduce this behavior and it is indeed incorrect. I’ve filed a bug report for it:

> <https://github.com/Slicer/Slicer/issues/5338>
>
> If "Overwrite visible" mode is enabled and there is a hidden segment then visible segments are not overwritten (which would be...
