flood¶
- flood(im, labels, 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 the same shape as
im
with each region labeled.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 convertingim
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 themode
.- Return type:
ndarray
See also
prop_to_image
,flood_func
,region_size
Examples
Click here to view online example.