flood_func

flood_func(im, labels, func)[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.

  • labels (ndarray) – An array containing labels identify each individual region to be flooded. If not provided then scipy.ndimage.label is 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 amin, amax, sum, mean, median, etc.

Returns

flooded – An image the same size as im with each isolated region flooded with a constant value based on the given func and the values in im.

Return type

ndarray

See also

flood, region_size

Notes

Many of the functions in scipy.ndimage can be applied to individual regions using the index argument. 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.

Examples

Click here to view online example.