porespy.filters.trim_small_clusters#
- porespy.filters.trim_small_clusters(im: numpy.typing.NDArray, min_size: int = 1, conn: Literal['min', 'max'] = 'min')#
Removes clusters of the given size or smaller
- Parameters:
im (ndarray) – The binary image from which voxels are to be removed.
min_size (scalar) – The threshold size of clusters to trim. As clusters with this many voxels or fewer will be trimmed. The default is 1 so only single voxels are removed.
conn (str) – Controls which neighboring voxels belong to the same cluster. The default is ‘min’, giving face connectivity (4 neighbors in 2D and 6 in 3D). ‘max’ includes diagonal contacts (8 neighbors in 2D and 26 in 3D).
- Returns:
im – A copy of im with clusters containing min_size voxels or fewer removed.
- Return type:
ndarray
Examples
Click here to view online example.