Morphological Filters Functional¶
- remove_small_objects(np_mask, min_size=3000, avoid_overmask=True, overmask_thresh=95)[source]¶
Remove connected components which size is less than min_size.
is True, this function can recursively call itself with progressively to avoid removing too many objects in the mask.
- Parameters
np_img (np.ndarray (arbitrary shape, int or bool type)) – Input mask
min_size (int, optional) – Minimum size of small object to remove. Default is 3000
avoid_overmask (bool, optional (default is True)) – If True, avoid masking above the overmask_thresh percentage.
overmask_thresh (int, optional (default is 95)) – If avoid_overmask is True, avoid masking above this threshold percentage value.
np_mask (numpy.ndarray) –
- Returns
Mask with small objects filtered out
- Return type
np.ndarray
- watershed_segmentation(np_mask, region_shape=6)[source]¶
Segment and label a binary mask with Watershed segmentation 1
The watershed algorithm treats pixels values as a local topography (elevation).
- Parameters
np_mask (np.ndarray) – Input mask
region_shape (int, optional) – The local region within which to search for image peaks is defined as a squared area region_shape x region_shape. Default is 6.
- Returns
Labelled segmentation mask
- Return type
np.ndarray
References
- 1
Watershed segmentation. https://scikit-image.org/docs/dev/auto_examples/segmentation/plot_watershed.html