图像矩

本文探讨了图像处理和计算机视觉领域中影像矩的概念及其应用,包括原始矩、中心矩、尺度不变矩、旋转不变矩等,并介绍了如何通过影像矩来描述物体、提取属性,如面积、重心、方向等。此外,文章还讨论了影像矩在不同场景下的应用,如图像区域的大小、形状、位置和旋转角度的确定。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

In image processingcomputer vision and related fields, an image moment is a certain particular weighted average (moment) of the image pixels' intensities, or a function of such moments, usually chosen to have some attractive property or interpretation.

Image moments are useful to describe objects after segmentation. Simple properties of the image which are found via image moments include area (or total intensity), its centroid, and information about its orientation.

Raw moments[edit]

For a 2D continuous function f(x,y) the moment (sometimes called "raw moment") of order (p + q) is defined as

 M_{pq}=\int\limits_{-\infty}^{\infty} \int\limits_{-\infty}^{\infty} x^py^qf(x,y) \,dx\, dy

for p,q = 0,1,2,... Adapting this to scalar (greyscale) image with pixel intensities I(x,y), raw image moments Mij are calculated by

M_{ij} = \sum_x \sum_y x^i y^j I(x,y)\,\!

In some cases, this may be calculated by considering the image as a probability density functioni.e., by dividing the above by

\sum_x \sum_y I(x,y) \,\!

A uniqueness theorem (Hu [1962]) states that if f(x,y) is piecewise continuous and has nonzero values only in a finite part of the xy plane, moments of all orders exist, and the moment sequence (Mpq) is uniquely determined by f(x,y). Conversely, (Mpq) uniquely determines f(x,y). In practice, the image is summarized with functions of a few lower order moments.

Examples[edit]

Simple image properties derived via raw moments include:

  • Area (for binary images) or sum of grey level (for greytone images): M00
  • Centroid: { xy } = {M10/M00M01/M00 }

Central moments[edit]

Central moments are defined as

 \mu_{pq} = \int\limits_{-\infty}^{\infty} \int\limits_{-\infty}^{\infty} (x - \bar{x})^p(y - \bar{y})^q f(x,y) \, dx \, dy

where \bar{x}=\frac{M_{10}}{M_{00}} and \bar{y}=\frac{M_{01}}{M_{00}} are the components of the centroid.

If ƒ(xy) is a digital image, then the previous equation becomes

\mu_{pq} = \sum_{x} \sum_{y} (x - \bar{x})^p(y - \bar{y})^q f(x,y)

The central moments of order up to 3 are:

\mu_{00} = M_{00},\,\!
\mu_{01} = 0,\,\!
\mu_{10} = 0,\,\!
\mu_{11} = M_{11} - \bar{x} M_{01} = M_{11} - \bar{y} M_{10},
\mu_{20} = M_{20} - \bar{x} M_{10},
\mu_{02} = M_{02} - \bar{y} M_{01},
\mu_{21} = M_{21} - 2 \bar{x} M_{11} - \bar{y} M_{20} + 2 \bar{x}^2 M_{01},
\mu_{12} = M_{12} - 2 \bar{y} M_{11} - \bar{x} M_{02} + 2 \bar{y}^2 M_{10},
\mu_{30} = M_{30} - 3 \bar{x} M_{20} + 2 \bar{x}^2 M_{10},
\mu_{03} = M_{03} - 3 \bar{y} M_{02} + 2 \bar{y}^2 M_{01}.

It can be shown that:

\mu_{pq} = \sum_{m}^p \sum_{n}^q {p\choose m} {q\choose n}(-\bar{x})^{(p-m)}(-\bar{y})^{(q-n)}  M_{mn}

Central moments are translational invariant.

Examples[edit]

Information about image orientation can be derived by first using the second order central moments to construct a covariance matrix.

\mu'_{20} = \mu_{20} / \mu_{00} = M_{20}/M_{00} - \bar{x}^2
\mu'_{02} = \mu_{02} / \mu_{00} = M_{02}/M_{00} - \bar{y}^2
\mu'_{11} = \mu_{11} / \mu_{00} = M_{11}/M_{00} - \bar{x}\bar{y}

The covariance matrix of the image I(x,y) is now

\operatorname{cov}[I(x,y)] = \begin{bmatrix} \mu'_{20}  & \mu'_{11} \\ \mu'_{11} & \mu'_{02} \end{bmatrix}.

The eigenvectors of this matrix correspond to the major and minor axes of the image intensity, so the orientation can thus be extracted from the angle of the eigenvector associated with the largest eigenvalue. It can be shown that this angle Θ is given by the following formula:

\Theta = \frac{1}{2} \arctan \left( \frac{2\mu'_{11}}{\mu'_{20} - \mu'_{02}} \right)

The above formula holds as long as:

\mu'_{20} - \mu'_{02} \ne 0

The eigenvalues of the covariance matrix can easily be shown to be

 \lambda_i = \frac{\mu'_{20} + \mu'_{02}}{2}  \pm \frac{\sqrt{4{\mu'}_{11}^2 + ({\mu'}_{20}-{\mu'}_{02})^2  }}{2},

and are proportional to the squared length of the eigenvector axes. The relative difference in magnitude of the eigenvalues are thus an indication of the eccentricity of the image, or how elongated it is. The eccentricity is

 \sqrt{1 - \frac{\lambda_2}{\lambda_1}}.

Scale invariant moments[edit]

Moments ηi j where i + j ≥ 2 can be constructed to be invariant to both translation and changes in scale by dividing the corresponding central moment by the properly scaled (00)th moment, using the following formula.

\eta_{ij} = \frac{\mu_{ij}}                         {\mu_{00}^{\left(1 + \frac{i+j}{2}\right)}}\,\!

Rotation invariant moments[edit]

It is possible to calculate moments which are invariant under translation, changes in scale, and also rotation. Most frequently used are the Hu set of invariant moments:[1][2]

   I_1 = \eta_{20} + \eta_{02}

   I_2 = (\eta_{20} - \eta_{02})^2 + 4\eta_{11}^2

   I_3 = (\eta_{30} - 3\eta_{12})^2 + (3\eta_{21} - \eta_{03})^2

   I_4 = (\eta_{30} + \eta_{12})^2 + (\eta_{21} + \eta_{03})^2

   I_5 = (\eta_{30} - 3\eta_{12}) (\eta_{30} + \eta_{12})[ (\eta_{30} + \eta_{12})^2 - 3 (\eta_{21} + \eta_{03})^2] + (3 \eta_{21} - \eta_{03}) (\eta_{21} + \eta_{03})[ 3(\eta_{30} + \eta_{12})^2 -  (\eta_{21} + \eta_{03})^2]

   I_6 =  (\eta_{20} - \eta_{02})[(\eta_{30} + \eta_{12})^2 - (\eta_{21} + \eta_{03})^2] + 4\eta_{11}(\eta_{30} + \eta_{12})(\eta_{21} + \eta_{03})

   I_7 = (3 \eta_{21} - \eta_{03})(\eta_{30} + \eta_{12})[(\eta_{30} + \eta_{12})^2 - 3(\eta_{21} + \eta_{03})^2] - (\eta_{30} - 3\eta_{12})(\eta_{21} + \eta_{03})[3(\eta_{30} + \eta_{12})^2 - (\eta_{21} + \eta_{03})^2].

The first one, I1, is analogous to the moment of inertia around the image's centroid, where the pixels' intensities are analogous to physical density. The last one, I7, is skew invariant, which enables it to distinguish mirror images of otherwise identical images.

A general theory on deriving complete and independent sets of rotation invariant moments was proposed by J. Flusser[3] and T. Suk.[4] They showed that the traditional Hu's invariant set is not independent nor complete. I3 is not very useful as it is dependent on the others. In the original Hu's set there is a missing third order independent moment invariant:

I_8 = \eta_{11}[ ( \eta_{30} + \eta_{12})^2 - (\eta_{03} + \eta_{21})^2  ] - (\eta_{20}-\eta_{02}) (\eta_{30}+\eta_{12}) (\eta_{03}+\eta_{21})

External links[edit]

References[edit]

  1. Jump up^ M. K. Hu, "Visual Pattern Recognition by Moment Invariants", IRE Trans. Info. Theory, vol. IT-8, pp.179–187, 1962
  2. Jump up^ http://docs.opencv.org/modules/imgproc/doc/structural_analysis_and_shape_descriptors.html?highlight=cvmatchshapes#humoments Hu Moments' OpenCV method
  3. Jump up^ J. Flusser: "On the Independence of Rotation Moment Invariants", Pattern Recognition, vol. 33, pp. 1405–1410, 2000.
  4. Jump up^ J. Flusser and T. Suk, "Rotation Moment Invariants for Recognition of Symmetric Objects", IEEE Trans. Image Proc., vol. 15, pp. 3784–3790, 2006.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值