calcCentroid: Calculate the centroid of a grayscale image

Description Usage Arguments Value Author(s) References See Also Examples

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

1

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

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

Example output

Loading required package: png
Loading required package: jpeg
Loading required package: bmp

IM documentation built on May 2, 2019, 8:55 a.m.