morphological_grow_shrink
Note
This page is a reference documentation. It only explains the function signature, and not how to use it. Please refer to the Habitat Guide and Python API guide (v2.0) for usage.
- morphological_grow_shrink(mask: ndarray, grow_mm: float, spacing_xyz: Sequence[float] = (1.0, 1.0, 1.0), connectivity: int = 1) ndarray[source]
Uniformly dilate (
grow_mm > 0) or erode (grow_mm < 0) a mask.This is MIRP
perturbation_roi_adapt_size: the systematic component of inter-rater contour variability, where one observer consistently traces slightly larger or smaller than another. Only the mask changes; image intensities are untouched. Applied per foreground label so a multi-label ROI grows each region instead of merging them.- Parameters:
mask – Integer / boolean label array in
(z, y, x)order;0is background.grow_mm – Physical radius in millimetres. Positive dilates, negative erodes, zero returns an unchanged copy.
spacing_xyz – Voxel spacing in SimpleITK
(x, y, z)order, used to convert millimetres to an iteration count.connectivity – Structuring-element connectivity in
{1, 2, 3};1is the 6-connected face neighbourhood (the conservative, MIRP-like default).
- Returns:
A new label array, same shape and dtype as
mask.- Raises:
ValueError – If erosion removes every foreground voxel (the ROI would vanish), or
connectivityis outside{1, 2, 3}.