flood_func#
- flood_func(im, func, labels=None)[source]#
Flood each isolated region in an image with a constant value calculated by the given function.
- Parameters:
im (ndarray) – An image with the numerical values of interest in each voxel, and 0’s elsewhere.
func (Numpy function handle) – The function to be applied to each region in the image. Any Numpy function that returns a scalar value can be passed, such as
amin
,amax
,sum
,mean
,median
, etc.labels (ndarray) – An array containing labels identifying each individual region to be flooded. If not provided then
scipy.ndimage.label
is applied toim > 0
.
- Returns:
flooded – An image the same size as
im
with each isolated region flooded with a constant value based on the givenfunc
and the values inim
.- Return type:
ndarray
See also
Notes
Many of the functions in
scipy.ndimage
can be applied to individual regions using theindex
argument. This function extends that behavior to all numpy function, in the event you wanted to compute the cosine of the values in each region for some reason. This function also floods the original image instead of returning a list of values for each region.Examples
Click here to view online example.