Skip to main content

Moments

Using the Blob Analysis module, you can also calculate the moments used to find the center of gravity, as well as other grayscale and binary moments. To calculate a moment of a specified order in X and Y (general moment), enable the M_MOMENT_GENERAL feature for calculation using MblobControl; then specify the X and Y order of the moment to calculate using MblobControl with M_MOMENT_GENERAL_ORDER_X and M_MOMENT_GENERAL_ORDER_Y, respectively. Select whether to calculate the ordinary or the central moment using MblobControl with M_MOMENT_GENERAL_MODE. Central moments use coordinates that are relative to the center of gravity of the blob, and therefore are independent of a blob's position within the image; whereas, ordinary moments are affected by the blob position because they use coordinates relative to the top-left corner of the image. Use MblobGetResult with M_MOMENT_GENERAL to retrieve the result.

You could alternatively enable the calculation of the M_MOMENT_FIRST_ORDER, M_MOMENT_SECOND_ORDER and/or M_MOMENT_THIRD_ORDER group of features for calculation using MblobControl. These groups of features include only the more common moments (for example, MblobGetResult with M_MOMENT_X0_Y1, M_MOMENT_X0_Y2 or M_MOMENT_X0_Y3). These common moments are calculated faster than the general moment.

You could also enable the calculation of hu moment invariants using MblobControl with M_MOMENT_THIRD_ORDER. Hu moments are a set of seven moments calculated using central moments. Hu moments are invariant to translation, rotation and scaling.

Copyright © 2026 Zebra Technologies.