flood¶
- flood(im: ndarray[Any, dtype[_ScalarType_co]], labels: ndarray[Any, dtype[_ScalarType_co]], mode: Literal['maximum', 'minimum', 'median', 'mean', 'size', 'standard_deviations', 'variance'] = 'max')[source]¶
Floods/fills each region in an image with a single value based on the specific values in that region.
This function calls the various functions in scipy.ndimage.measurements but instead of returning a list of values, it fills each region with its value. This is useful for visualization and statistics.
- Parameters:
im (array_like) – An image with the numerical values of interest in each voxel, and 0’s elsewhere.
labels (array_like) – An array containing labels identifying each individual region to be flooded. If not provided then scipy.ndimage.label is applied to im > 0.
mode (string) –
Specifies how to determine the value to flood each region. Options taken from the scipy.ndimage.measurements function include:
Option
Description
maximum
Floods each region with the local max in that region. The keyword max is also accepted.
minimum
Floods each region the local minimum in that region. The keyword min is also accepted.
median
Floods each region the local median in that region
mean
Floods each region the local mean in that region
size
Floods each region with the size of that region. This is actually accomplished with scipy.ndimage.sum by converting im to a boolean image (im = im > 0).
standard_deviation
Floods each region with the value of the standard deviation of the voxels in im.
variance
Floods each region with the value of the variance of the voxels in im.
- Returns:
flooded – A copy of im with new values placed in each forground voxel based on the mode.
- Return type:
ndarray
See also
prop_to_image
,flood_func
,region_size
Examples
Click here to view online example.