skimage2.measure.centroid#

skimage2.measure.centroid(image, *, spacing=None)[source]#

Return the (weighted) centroid of an image.

Parameters:
imagearray

The input image.

spacingtuple of float, shape (ndim,)

The pixel spacing along each axis of the image.

Returns:
centertuple of float, length image.ndim

The centroid of the (nonzero) pixels in image.

Examples

>>> image = np.zeros((20, 20), dtype=np.float64)
>>> image[13:17, 13:17] = 0.5
>>> image[10:12, 10:12] = 1
>>> centroid(image)
array([13.16666667, 13.16666667])