How it works...

For binary or grayscale images, image moments are computed using the OpenCV function cv2.moments. It returns a dict of the calculated moments, with their respective names.

The following output is expected for the moments:

nu11     -2.809466679966455e-13
mu12     -422443285.20703125
mu21     -420182048.71875
m11      1237939564800.0
mu20     161575917357.31616
m10      5158101240.0
nu03     1.013174855849065e-10
nu12     -4.049505150683136e-10
nu21     -4.0278291313762605e-10
mu03     105694127.71875
nu30     1.618061841335058e-09
m30      683285449618080.0
nu02     0.00015660970937729079
m20      1812142855350.0
m00      16119315.0
mu02     40692263506.42969
nu20     0.0006218468887998859
m02      969157708320.0
m21      434912202354750.0
m01      3868620810.0
m03      252129278267070.0
mu11     -72.9990234375
mu30     1687957749.125
m12      310125260718570.0

The estimated center of mass is as follows:

Center X estimated: 319.9950643063927
Center Y estimated: 239.999082467214
The definitions of different image moment types can be found at
https://en.wikipedia.org/wiki/Image_moment.