# Image moment

An image moment is a weighted average of pixel intensities in an image, providing a compact numerical descriptor of shape, position, orientation, and other geometric properties. These moments are widely used in computer vision for object recognition, image analysis, and pattern matching.

An image moment is a statistical measure computed from the pixel intensities of a digital image. It represents a weighted average of the pixel values, yielding a set of scalar numbers that describe the image's geometric properties, such as area, centroid, orientation, and shape complexity. Moments are invariant to certain transformations (e.g., translation, rotation, scaling) when properly normalized, making them valuable for robust image analysis. They serve as a foundational tool in computer vision, enabling efficient representation and comparison of visual patterns without requiring pixel-by-pixel matching.

Image moments are typically calculated from binary or grayscale images, where each pixel has an intensity value. For a digital image with intensity function \(I(x, y)\), the raw moment of order \((p+q)\) is defined as the sum over all pixels of \(x^p y^q I(x, y)\). These raw moments capture the distribution of intensity across the image. However, raw moments depend on the image's position, so central moments are often used instead; they are computed relative to the image's centroid, providing translation invariance. Further normalization yields scale-invariant moments, and combinations of central moments can produce rotation-invariant descriptors, such as Hu's seven invariant moments introduced in 1962.

The concept of image moments has roots in probability theory and mechanics, where moments describe mass distributions. In image processing, they were popularized in the 1960s and 1970s for shape analysis. Since then, they have become a standard technique in fields like object detection, character recognition, and medical imaging. Their computational simplicity and low dimensionality make them suitable for real-time applications, although they may lose fine details compared to more complex features like those from deep learning.

## Applications in Computer Vision

Image moments are used extensively in computer vision for tasks that require shape description and matching. For example, in optical character recognition (OCR), moments help identify letters and digits by their geometric properties. In industrial inspection, they verify the presence or absence of defects by comparing moments of a manufactured part against a reference. Moments also enable object tracking in video sequences, where the centroid (derived from first-order moments) provides a stable point to follow. Additionally, they are used in image registration, where aligning images of the same scene requires estimating translation and rotation, which can be derived from moments.

## Moment Types and Properties

Several types of moments exist, each with distinct properties. Raw moments are the simplest but are not invariant to transformations. Central moments, defined relative to the centroid, are translation-invariant. Normalized central moments, scaled by the area (zeroth moment), provide scale invariance. Hu's moments, seven nonlinear combinations of normalized central moments, are invariant to translation, scale, and rotation, making them popular for shape recognition. Zernike moments, introduced in 1980, use orthogonal polynomials over a unit disk, offering better noise resilience and lower information redundancy. Legendre moments, based on Legendre polynomials, also provide orthogonal descriptors. These advanced moments capture higher-order details, enabling more discriminative shape analysis.

## Computation and Implementation

Computing image moments is straightforward and efficient. For a discrete image, the raw moment of order \((p+q)\) is calculated by iterating over all pixels and summing \(x^p y^q\) times the intensity. The centroid is obtained from the first-order moments: \(\bar{x} = m_{10}/m_{00}\) and \(\bar{y} = m_{01}/m_{00}\), where \(m_{00}\) is the total intensity (area for binary images). Central moments are then computed relative to this centroid. In practice, moments are often calculated using integral images (summed-area tables) to achieve constant-time computation for any rectangular region, which is beneficial for real-time processing. Libraries such as OpenCV provide built-in functions for moment computation, simplifying their use in applications.

## Relationship to Modern Machine Learning

While image moments are classical techniques, they remain relevant in the era of [machine-learning](https://www.wikiprompt.org/wiki/machine-learning) and [deep-learning](https://www.wikiprompt.org/wiki/deep-learning). They are sometimes used as handcrafted features in traditional classifiers or as preprocessing steps to normalize images before feeding into [neural-network](https://www.wikiprompt.org/wiki/neural-network) models. For instance, moments can help align or crop images to a standard orientation, improving the performance of [convolutional-neural-network](https://www.wikiprompt.org/wiki/convolutional-neural-network) (CNN) based systems. However, deep learning models like [residual-network](https://www.wikiprompt.org/wiki/residual-network) and [u-net](https://www.wikiprompt.org/wiki/u-net) typically learn features directly from raw pixels, reducing the need for explicit moment computation. Nevertheless, moments are still valuable for interpretability, as they provide intuitive geometric summaries that can complement learned representations. In hybrid approaches, moments may be combined with learned features to enhance robustness, particularly in scenarios with limited training data.

## Limitations and Extensions

Image moments have limitations. They are global descriptors, meaning they summarize the entire image, which can obscure local variations. For complex scenes with multiple objects, moments of the whole image are not meaningful; instead, moments are computed per connected component after segmentation. Additionally, moments are sensitive to noise, especially higher-order ones, which amplify intensity fluctuations. To mitigate this, orthogonal moments like Zernike are preferred in noisy environments. Extensions include color moments, which compute moments across color channels, and wavelet moments, which combine moments with multi-resolution analysis. These variants expand the applicability of moments to color images and multi-scale analysis.

In summary, image moments provide a compact, mathematically grounded way to describe image shapes and distributions. Their invariance properties and computational efficiency have ensured their continued use in computer vision, even as modern [artificial-intelligence](https://www.wikiprompt.org/wiki/artificial-intelligence) methods evolve. They serve as a bridge between classical image analysis and contemporary learning-based approaches, offering a simple yet powerful tool for geometric understanding.

---
Source: https://www.wikiprompt.org/wiki/image-moment
License: CC BY-SA 4.0 (https://creativecommons.org/licenses/by-sa/4.0/)
Last updated: 2026-09-14T06:31:07.509176+00:00
