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.
centroid != center of mass in gray scale images, generally.
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.
To see how this can be applied, browse our numerous image analysis examples.
"Center of mass" is also known as "center of gravity".