Michael_Ef
(Michael Ef)
March 17, 2019, 11:00am
#1
Hello,
I reconstructed a 3d model of prostate glands from histological slides by marching cubes algorithm. In my model I have a lot of small contours that i do not want to have in the model. Is there a way (e.g. a vtk filter) to extract these contours by setting a minimum size for these contours? Similar to the vtkConnectivityFilter where you can extract the largest region!?
Thanks a lot in advance.
Regards Michael
cpinter
(Csaba Pinter)
March 17, 2019, 12:40pm
#2
The Islands effect in Segment Editor can do this, here’s the code:
def splitSegments(self, minimumSize = 0, maxNumberOfSegments = 0, split = True):
"""
minimumSize: if 0 then it means that all islands are kept, regardless of size
maxNumberOfSegments: if 0 then it means that all islands are kept, regardless of how many
"""
# This can be a long operation - indicate it to the user
qt.QApplication.setOverrideCursor(qt.Qt.WaitCursor)
self.scriptedEffect.saveStateForUndo()
# Get modifier labelmap
selectedSegmentLabelmap = self.scriptedEffect.selectedSegmentLabelmap()
castIn = vtk.vtkImageCast()
castIn.SetInputData(selectedSegmentLabelmap)
castIn.SetOutputScalarTypeToUnsignedInt()
# Identify the islands in the inverted volume and
# find the pixel that corresponds to the background
islandMath = vtkITK.vtkITKIslandMath()
This file has been truncated. show original
Is there a good reason for using low-level VTK functions instead of Segment Editor? You’re using Slicer I assume so why not use its features?