calcCentroid: Calculate the centroid of a grayscale image
Description
Calculate the centroid of a grayscale image using geometric moments. The centroid is based on pixel intensity.
The centroid, located at pixel coordinates (x0,y0) is calculated using the following equation:
$$x0 = \frac{m_{10}}{m_{00}}$$
$$y0 = \frac{m_{10}}{m_{00}}$$
where
$$m_{pq} = \sum_{1}^{N} \sum_{1}^{M} (x^p)(y^q)f(x,y)$$
N is the horizontal dimensionality of the image and M is the vertical dimensionality of the image.
$$f(x,y)$$ is the pixel intensity of the pixel at location (x,y) in the image.
Usage
calcCentroid(I)
Arguments
I
An image represented as a 2-dimensional grayscale matrix.
Value
numeric: (x0, y0)
x0x-coordinate of centroid
y0y-coordinate of centroid
References
Flusser, J., Suk, T., Zitova, B. Moments and Moment Invariants in Pattern Recognition. 2009. John Wiley & Sons Ltd. ISBN: 978-0-470-69987-4