Calculation of the centre of mass of an image

Example of calculation of the centre of mass of an image. (a) The original square image; (b)
A 12 x 12 (pixellated) version of the image so that the calculations are simpler to see (although for
the images proper in the study all pixels are used from the entire image); (c) The calculations. The
12 x 12 matrix shows the darkness or weight of each pixel (ie, 255 = black = heavy; 0 = white = light).
The table at the bottom show ri, the arbitrary horizontal distance of each pixel from the left-hand
side, expressed as pixel number, the summed mass of each column of pixels, mi, and the product of
mi and ri (mi.ri). At the end of each row are the sums of ri and mi.ri, which are used to calculate R,
the position of the centre of mass, which is at 6.1 pixels from the left-hand side. The table at the
right shows the equivalent calculations for the rows, with ri arbitrarily being the vertical distance from
the top row of pixels. The centre of mass for the image as a whole is 7.4 pixels from the top and 6.1
pixels from the left, and those positions are shown by the red and green dashed lines in (b), with the
intersection, shown by the white circle, being the centre of mass of the image.

Updated: —