Remove largest island functionality?

Hi there,

Currently I’ve been working on automating a work flow in python that goes like the following:

  1. Load CT scans (as .tiffs)
  2. Create a segmentation and threshold to identify air in the scans
  3. Automate a mouse click in a known location and use the “Remove selected island” feature
  4. Apply the “Keep largest island” feature
  5. Calculate and report statistics

This process is functional and working currently, but requires my scripts to run with the slicer gui open (as opposed to running with “–no-splash --no-main-window”) because step 3 mimics a mouse click.

I’m realizing now that step 3 is actually always removing the largest island, which leads to my question.

Is there a “Remove largest island” functionality to accompany the “Keep largest island” function? (I haven’t been able to find one unfortunately).

If there isn’t, is there a way to programmatically sort the islands in python and then delete the biggest manually?

Thanks in advance for any help!

Hello, have you found a solution for this? I also need it, if you know how to do it I would appreciate some help :sweat_smile:

Copy segment A to B → Keep largest in A → Subtract A from B ?

1 Like