ants.label.label_image_centroids

label_image_centroids(image, physical=False, convex=True, verbose=False)[source]

Converts a label image to coordinates summarizing their positions

ANTsR function: labelImageCentroids

Parameters:
  • image (ants.core.ANTsImage) – image of integer labels

  • physical (bool) – whether you want physical space coordinates or not

  • convex (bool) – if True, return centroid if False return point with min average distance to other points with same label

Returns:

labels1D-ndarray

array of label values

verticespd.DataFrame

coordinates of label centroids

Return type:

dictionary w/ following key-value pairs

Example

>>> import ants
>>> import numpy as np
>>> image = ants.from_numpy(np.asarray([[[0,2],[1,3]],[[4,6],[5,7]]]).astype('float32'))
>>> labels = ants.label_image_centroids(image)