# In the "KEEP\_LARGEST\_ISLAND", is there a size limit for the largest island?

**URL:** <https://discourse.slicer.org/t/in-the-keep-largest-island-is-there-a-size-limit-for-the-largest-island/19780>\
**Category:** Development\
**Tags:** segmentation, python\
**Created:** [September 21, 2021, 11:29am UTC](https://discourse.slicer.org/t/in-the-keep-largest-island-is-there-a-size-limit-for-the-largest-island/19780 "2021-09-21T11:29:00Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![jumbojing](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jumbojing/32/10811_2.png) [@jumbojing](https://discourse.slicer.org/u/jumbojing)\
**Post date:** [September 21, 2021, 11:29am UTC](https://discourse.slicer.org/t/in-the-keep-largest-island-is-there-a-size-limit-for-the-largest-island/19780/1 "2021-09-21T11:29:00Z")

</div>

在应用`KEEP_LARGEST_ISLAND`时, 我得到了"0 island, 2 ignored", 可能是因为我"cropped volume"的太小了?

> When applying `KEEP_LARGEST_ISLAND`, I got “0 island, 2 ignored”. Maybe it is because my “cropped volume” is too small?

---

<div class="post-metadata">

**Author:** ![jumbojing](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jumbojing/32/10811_2.png) [@jumbojing](https://discourse.slicer.org/u/jumbojing)\
**Post date:** [September 21, 2021, 11:40am UTC](https://discourse.slicer.org/t/in-the-keep-largest-island-is-there-a-size-limit-for-the-largest-island/19780/2 "2021-09-21T11:40:53Z")

</div>

How to change the “MinimumSize” of island.  
既然是"the largest island", 为何还要限制尺寸呢?感觉逻辑有问题呀

> Since it is “the largest island”, why do we need to limit the size? I feel that there is a problem with the logic.

@lassoan@Juicy@jamesobutler @jcfr @pieper@RafaelPalomar

---

<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:** [September 21, 2021, 6:04pm UTC](https://discourse.slicer.org/t/in-the-keep-largest-island-is-there-a-size-limit-for-the-largest-island/19780/3 "2021-09-21T18:04:02Z")

</div>

Good catch. “Keep largest island” mode expects that the island you want to get is sufficiently big, but it is possible that you want to extract an island that is smaller than the currently set minimum size. We’ll keep the “Minimum size” option enabled for “Keep largest island” mode.

As a workaround, you can switch to “Remove small island” option, set the minimum size to a 1, then switch back to “Keep largest island” mode.

---

<div class="post-metadata">

**Author:** ![jumbojing](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jumbojing/32/10811_2.png) [@jumbojing](https://discourse.slicer.org/u/jumbojing)\
**Post date:** [September 25, 2021, 2:04am UTC](https://discourse.slicer.org/t/in-the-keep-largest-island-is-there-a-size-limit-for-the-largest-island/19780/4 "2021-09-25T02:04:44Z")

</div>

@lassoan How to get the only one largest island? How to set the number of islands?

---

<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:** [September 25, 2021, 2:05am UTC](https://discourse.slicer.org/t/in-the-keep-largest-island-is-there-a-size-limit-for-the-largest-island/19780/5 "2021-09-25T02:05:50Z")

</div>

Largest island option returns the largest island (one island).

---

<div class="post-metadata">

**Author:** ![jumbojing](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jumbojing/32/10811_2.png) [@jumbojing](https://discourse.slicer.org/u/jumbojing)\
**Post date:** [September 25, 2021, 2:10am UTC](https://discourse.slicer.org/t/in-the-keep-largest-island-is-there-a-size-limit-for-the-largest-island/19780/6 "2021-09-25T02:10:22Z")

</div>

```auto
    segmentEditorWidget.setActiveEffectByName("Islands")
    effect = segmentEditorWidget.activeEffect()
    effect.setParameter("Operation", "KEEP_LARGEST_ISLAND")
    minSize = 1
    effect.setParameter("MinimumSize", minSize)
    effect.setParameter("maxNumberOfSegments", 1)

    effect.self().onApply()

```

```auto
3 islands created (0 ignored)

```

what’s wrong? above

---

<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:** [September 25, 2021, 2:12am UTC](https://discourse.slicer.org/t/in-the-keep-largest-island-is-there-a-size-limit-for-the-largest-island/19780/7 "2021-09-25T02:12:50Z")

</div>

There is nothing wrong. Largest island option returns the largest island (one island). The debug message indicated that 3 islands were larger than the minimum size.

---

<div class="post-metadata">

**Author:** ![jumbojing](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jumbojing/32/10811_2.png) [@jumbojing](https://discourse.slicer.org/u/jumbojing)\
**Post date:** [September 25, 2021, 2:14am UTC](https://discourse.slicer.org/t/in-the-keep-largest-island-is-there-a-size-limit-for-the-largest-island/19780/8 "2021-09-25T02:14:15Z")

</div>

Thanks, I see… 👍 👍 👍 👍 👍
