Removing islands in a given range

Greetings Slicers,

I’m trying to remove some islands in a given size range (100 voxels to 1000 voxels, for example) using some python code similar to that in SegmentEditorIslandsEffect.py. I can see where vtkITKIslandMath() is used to do the actual work, but how do I get the islandsMath for the segment in question? Is it in the segmentations module logic? Right now, I get zero for GetNumberOfIslands(), which I’m assuming is because it’s not “connected” to the segmentation. (I think…?)

I could modify SegmentEditorIslandsEffect to do this, I suppose, and just reload that, but I’d like to try my logic just on the python console for starters.

Hope this makes sense… Thanks in advance!!

-Hollister

You can easily get islands of a given size range by removing islands below 100 and below 1000 (Islands effect) and then computing the difference (Logical operators effect). You can run Segment editor effects from your scripts as shown here.

Wow, that’s about 100 times easier than what I had in mind…

Thanks, Andras!!!

-Hollister

Here’s a gist of what I threw together to do this, if it’s useful for anyone.

Thanks for the tip!

3 Likes