Skip to content
Snippets Groups Projects

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

2 files
+ 46
10
Compare changes
  • Side-by-side
  • Inline

Files

+ 3
3
@@ -64,15 +64,15 @@ class CC:
return find_objects(self._connected_components)
def get_3d_cc(image: np.ndarray | torch.Tensor):
"""Get the connected components of a 3D binary image.
def get_3d_cc(image: np.ndarray | torch.Tensor) -> CC:
""" Get the connected components of a 3D volume.
Args:
image (np.ndarray | torch.Tensor): An array-like object to be labeled. Any non-zero values in `input` are
counted as features and zero values are considered the background.
Returns:
class: Returns class object of the connected components.
CC: A ConnectedComponents object containing the connected components and the number of connected components.
"""
connected_components, num_connected_components = label(image)
log.info(f"Total number of connected components found: {num_connected_components}")
Loading