PV-WAVE Extreme Advantage > Image Processing Toolkit User Guide > Reference A–I > CENTROID Function (PV-WAVE Extreme Advantage)
CENTROID Function (PV-WAVE Extreme Advantage)
Calculates the centroid of a binary region in an image.
Usage
result = CENTROID(image, pixels)
Input Parameters
image—A 2D array containing a region.
pixels—A long array containing the element numbers of the pixels that compose the region pixels in image. These pixels compose the region for which the centroid is calculated.
Returned Value
result—A long scalar value that is the element number in image of the centroid of the region.
Keywords
None.
Discussion
The centroid of a binary region, also known as the center of gravity, is a measure of the region’s center. The centroid is expressed in pixel-coordinate values and is calculated as the ratio of the first-order to the zeroth-order spatial moments:
centroidx = M(1, 0)/M(0, 0)
centroidy = M(0, 1)/M(0, 0)
The returned value, result is the element number (n, m) in the image array, such that:
centroid = centroidx + centroidy*n
Example
Get pixels for a region in image, where the region has an amplitude of 100.
region_pixels = WHERE(image EQ 100)
result = CENTROID(image, region_pixels)
See Also