flood

flood(im, regions=None, mode='max')[source]

Floods/fills each region in an image with a single value based on the specific values in that region.

The mode argument is used to determine how the value is calculated.

Parameters
  • im (array_like) – An image with isolated regions with numerical values in each voxel, and 0’s elsewhere.

  • regions (array_like) – An array the same shape as im with each region labeled. If None is supplied (default) then scipy.ndimage.label is used with its default arguments.

  • mode (string) –

    Specifies how to determine which value should be used to flood each region. Options are:

    ’maximum’

    Floods each region with the local max in that region

    ’minimum’

    Floods each region the local minimum in that region

    ’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

Returns

image – A copy of im with new values placed in each forground voxel based on the mode.

Return type

ND-array

See also

prop_to_image

Examples

Click here to view online example.