region_size

region_size(im: ndarray[Any, dtype[_ScalarType_co]], conn: Literal['max', 'min'] = 'min')[source]

Replace each voxel with the size of the region to which it belongs

Parameters:
  • im (ndarray) – Either a boolean image wtih True indicating the features of interest, in which case scipy.ndimage.label will be applied to find regions, or a greyscale image with integer values indicating regions.

  • conn (str) – Can be either ‘min’ or ‘max’ and controls the shape of the structuring element used to determine voxel connectivity. The default if ‘min’ which imposes the strictest criteria, so that voxels must share a face to be considered connected.

Returns:

image – A copy of im with each voxel value indicating the size of the region to which it belongs. This is particularly useful for finding chord sizes on the image produced by apply_chords.

Return type:

ndarray

See also

flood

Notes

This function provides the same result as flood with mode=’size’, although does the computation in a different way.

Examples

Click here to view online example.