calcCentroid {IM}R Documentation

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} = ∑_{1}^{N} ∑_{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)

x0

x-coordinate of centroid

y0

y-coordinate of centroid

Author(s)

Allison Irvine, Tan Dang

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

See Also

Image,CmplxIm,OrthIm,polarXY

Examples

data(pirate)
I=rowSums(img,dims=2);
center= calcCentroid(I);

[Package IM version 1.0 Index]