machinevisiontoolbox.Image.moments

Image.moments(binary=False)

Image moments

Parameters:

binary (bool) – if True, all non-zero pixels are treated as 1’s

Returns:

image moments

Type:

dict

Compute multiple moments of the image and return them as a dict

Moment type

dict keys

moments

m00 m10 m01 m20 m11 m02 m30 m21 m12 m03

central moments

mu20 mu11 mu02 mu30 mu21 mu12 mu03 |

normalized central moments

nu20 nu11 nu02 nu30 nu21 nu12 nu03 |

Example:

>>> from machinevisiontoolbox import Image
>>> img = Image.Read('shark1.png')
>>> img.moments()
{'m00': 1995885.0, 'm10': 341888955.0, 'm01': 309659505.0, 'm20': 60967635585.0, 'm11': 52708208790.0, 'm02': 48962122365.0, 'm30': 11284951722945.0, 'm21': 9337817849640.0, 'm12': 8282294696220.0, 'm03': 7879402188375.0, 'mu20': 2403110298.7274823, 'mu11': -335510948.49559176, 'mu02': 918768646.3012627, 'mu30': 18092682198.754948, 'mu21': -6304121879.9286995, 'mu12': -657749179.1717323, 'mu03': -2112760503.1506472, 'nu20': 0.0006032574252131944, 'nu11': -8.422396218245323e-05, 'nu02': 0.00023064026991512026, 'nu30': 3.214875575229422e-06, 'nu21': -1.1201748437524005e-06, 'nu12': -1.1687497450720262e-07, 'nu03': -3.7541488118084844e-07}
Note:
  • Converts a color image to greyscale.

References:
  • Robotics, Vision & Control for Python, Section 12.1.3.4, P. Corke, Springer 2023.

Seealso:

mpq npq upq opencv.moments