##### Tools

This site is devoted to mathematics and its applications. Created and run by Peter Saveliev.

# Center of mass

For an object in a gray scale image, its center of mass is the point around which the gray of the object is equally distributed.

The object can be balanced on a single support if it located at the center of mass.

Since we treat pixels as tiles (see Cell decomposition of images), this point isn't meant to be a pixel. For example, the center of mass of a pixel lies in the middle of the pixel. The center of mass of two adjacent pixels, however, lies in the middle of the edge they share (or the vertex if they share only a vertex). For more examples of this kind, see Centroid. The presence of gray makes this more complicated...

What does "center of mass" have to do with the "center"? If the center for a given object makes sense in the first place (like circle, rectangle, star, anything with a central symmetry) and the gray values are distributed symmetrically with respect to this center, then

 center of mass = center.


But:

 centroid != center of mass in gray scale images, generally.


However:

 centroid = center of mass, for a binary image.


The general formula is very simple:

 center of mass = sum of the pixels in the region each multiplied by its value, divided by the sum of these values.


In other words, this is a "weighted average" of the pixels treated as vectors.

If you treat images as functions of two variables, the center of mass of a region is the same center of mass you learn about in calculus. It is computed via area integrals over the region.

Instead of the center of mass, the centroid is shown in the output of Pixcavator under "Location" (see Pixcavator's output table).

To see how this can be applied, browse our numerous image analysis examples.

"Center of mass" is also known as "center of gravity".