- flood_func(im, labels, func)¶
Flood each isolated region in an image with a constant value calculated by the given function.
im (ndarray) – An image with the numerical values of interest in each voxel, and 0’s elsewhere.
labels (ndarray) – An array containing labels identify each individual region to be flooded. If not provided then
scipy.ndimage.labelis applied to
im > 0.
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
flooded – An image the same size as
imwith each isolated region flooded with a constant value based on the given
funcand the values in
- Return type
Many of the functions in
scipy.ndimagecan be applied to individual regions using the
indexargument. This function extend 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 return a list of values for each region.
Click here to view online example.