Skip to content
Snippets Groups Projects

Implemented 3D connected components as wrapper class for scipy.ndimage.label

2 files
+ 14
9
Compare changes
  • Side-by-side
  • Inline

Files

+ 6
1
@@ -30,7 +30,9 @@ class CC:
Get the connected component with the given index, if index is None selects a random component.
Args:
index (int): The index of the connected component. If none returns all components.
index (int): The index of the connected component.
If none returns all components.
If 'random' returns a random component.
crop (bool): If True, the volume is cropped to the bounding box of the connected component.
Returns:
@@ -38,6 +40,9 @@ class CC:
"""
if index is None:
volume = self._connected_components
if index == "random":
index = np.random.randint(1, self.cc_count + 1)
volume = self._connected_components == index
else:
assert 1 <= index <= self.cc_count, "Index out of range. Needs to be in range [1, cc_count]."
volume = self._connected_components == index
Loading