# Conditional island removal?

**URL:** https://discourse.slicer.org/t/conditional-island-removal/16570
**Category:** Development
**Created:** [March 16, 2021, 1:02pm UTC](https://discourse.slicer.org/t/conditional-island-removal/16570 "2021-03-16T13:02:04Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![hherhold](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/hherhold/32/12199_2.png) [@hherhold](https://discourse.slicer.org/u/hherhold)
#### Post date: [March 16, 2021, 1:02pm UTC](https://discourse.slicer.org/t/conditional-island-removal/16570/1 "2021-03-16T13:02:04Z")

</div>

I would like to be able to remove small islands (under a certain threshold) _if_ they are a certain distance away from other islands. I have segmentations of some very thin insect tracheae that are basically “archipelagoes”, long stretches of very small islands, but also in the background there are single small islands that are far away from everything else (noise, basically). I’d like to remove the isolated islands but keep the archipelagoes, so I’m thinking I could check for island size, then see if anything is nearby, and if not, delete it.

Does this sound doable? I’ve taken a brief look at vtkITKIslandMath and it seems like there are a lot of possibilities with ITK filters, but I’m not sure how feasible this would be.

Thanks!

-Hollister

---

<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: [March 16, 2021, 4:07pm UTC](https://discourse.slicer.org/t/conditional-island-removal/16570/2 "2021-03-16T16:07:32Z")

</div>

You can create a mask segment that prevents deleting your archipelagoes. The mask segment can be created by applying Margin effect → Grow to a segment that contains all the segments, followed by Island effect → Keep selected island.

---

<div class="post-metadata">

### Author: ![hherhold](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/hherhold/32/12199_2.png) [@hherhold](https://discourse.slicer.org/u/hherhold)
#### Post date: [March 16, 2021, 9:32pm UTC](https://discourse.slicer.org/t/conditional-island-removal/16570/3 "2021-03-16T21:32:14Z")

</div>

I’ll give this a try. Thanks!!!
