iaf.morph.watershed¶
Watershed-based operations.
- iaf.morph.watershed.estimate_object_sizes(bw: ndarray)[source]¶
Estimate area, min axis length, major axis length and equivalent diameter of all objects in a mask as their median values.
- Parameters:
bw (numpy array) – Black and white mask.
- Returns:
results – Tuple containing (area, min_axis, max_axis, equiv_diam) as the median values of the corresponding measurements for all objects.
- Return type:
- iaf.morph.watershed.filter_labels_by_area(label_image: ndarray, min_area: int, max_area: int | None = None) tuple[source]¶
Remove objects that have areas outside the specified range.
- Parameters:
- Returns:
results – The tuple contains the label image filtered by size, and the updated number of objects.
- Return type:
Tuple
- iaf.morph.watershed.get_label_areas(label_image: ndarray) tuple[source]¶
Return a list of label areas from the label image.
- Parameters:
label_image (numpy array) – Image labeled by scipy.ndimage.label
- Returns:
results – Tuple with a list of label areas (as a NumPy array), the median area, and the median absolute deviation of areas.
- Return type:
- iaf.morph.watershed.label_to_eroded_bw_mask(nuclei_labels: ndarray, sel: array = array([[1., 1., 1.], [1., 1., 1.], [1., 1., 1.]]))[source]¶
Create a black-and-white mask from a label image. To keep the label separate in the back-and-white mask, they are individually eroded.
- Parameters:
nuclei_labels (np.ndarray) – Label image.
sel (np.ndarray) – Structuring element for erosion.
- Returns:
bw – Black-and-white mask.
- Return type:
np.ndarray
- iaf.morph.watershed.separate_neighboring_objects(bw_image: ndarray, label_image: ndarray, filter_size: int | None = None, maxima_suppression_size: int | None = None, unclump_method: str | None = 'shape', watershed_method: str | None = 'shape', fill_holes: str = 'both', min_size: int = 20, max_size: int = 100, low_res_maxima: bool = True, exclude_border_objects: bool = False) tuple[source]¶
Separate touching objects using distance-transform or intensity maxima.
Extracted, simplified and adapted from CellProfiler’s (https://github.com/CellProfiler)
IdentifyPrimaryObjectsmodule using pure numpy, scipy and scikit-image dependencies only.- Parameters:
bw_image – Binary mask (black = background, white = foreground).
label_image – Integer label image produced by
scipy.ndimage.label.filter_size – Gaussian blur kernel size. Auto-calculated from min_size when None.
maxima_suppression_size – Neighbourhood radius for local-maximum suppression. Auto-estimated when None.
unclump_method –
"shape"(distance transform) or"intensity".watershed_method –
"shape","intensity", or"propagate".fill_holes –
"never","both"(before and after), or"after".min_size – Minimum expected object diameter in pixels.
max_size – Maximum expected object diameter in pixels.
low_res_maxima – Downsample before finding maxima when
min_size > 10.exclude_border_objects – Remove objects touching the image border.
- Return type:
(label_image, object_count, reported_maxima_suppression_size)