区域的第二时刻是什么? [英] What are the second-moments of a region?

查看:9
本文介绍了区域的第二时刻是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正致力于在 Octave 中复制 Matlab 的 regionprops 函数的一些功能.但是,我对功能的一个子集有点犹豫.偏心"、MajorAxisLength"、MinorAxisLength"和Orientation"属性是我的症结所在.在文档中,它们都源自...与区域具有相同秒矩的椭圆".

I'm currently working on replicating some of the functionality of Matlab's regionprops function in Octave. However, I have a bit of a hangup on a subset of the functionality. The 'Eccentricity', 'MajorAxisLength', 'MinorAxisLength' and 'Orientation' properties are my sticking point. In the documentation, they all derive from "...the ellipse that has the same second-moments as the region."

所以我的问题是,这些第二时刻是什么,我如何找到它们?

So my question is, what are these second-moments, and how do I find them?

我在看这个链接:http://en.wikipedia.org/wiki/Image_moments

老实说,这让我更加困惑.谁能指出我对初学者更友好的东西?谢谢.

Honestly, it's just left me more confused. Can anyone point me towards something a little more beginner friendly? Thanks.

推荐答案

文档中的second moment"指的是第二个中心时刻.

By "second moments", the documentation means the second central moment.

对于一维数据,这将是 方差(或平方标准差).

In the case of one-dimensional data, this would be the variance (or square of the standard deviation).

在您的情况下,您有二维数据,第二个中心矩是 协方差矩阵.

In your case, where you have two-dimensional data, the second central moment is the covariance matrix.

如果 X 是您所在区域的点的 n×2 矩阵,您可以在 MATLAB 中计算协方差矩阵 Sigma,如下所示(未经测试):

If X is an n-by-2 matrix of the points in your region, you can compute the covariance matrix Sigma in MATLAB like this (untested):

mu=mean(X,1);
X_minus_mu=X-repmat(mu, size(X,1), 1);
Sigma=(X_minus_mu'*X_minus_mu)/size(X,1);

现在,这与省略号有什么关系?好吧,实际上,您在这里所做的是将 多元正态分布 拟合到您的数据.协方差矩阵决定了该分布的形状,以及多元正态分布的等高线——等待它——是省略号

Now, what does this have to do with ellipses? Well, what you're doing here is, in effect, fitting a multivariate normal distribution to your data. The covariance matrix determines the shape of that distribution, and the contour lines of a multivariate normal distribution -- wait for it -- are ellipses!

椭圆轴的方向和长度由协方差矩阵的特征向量和特征值给出:

The directions and lengths of the ellipse's axes are given by the eigenvectors and eigenvalues of the covariance matrix:

[V, D]=eig(Sigma);

V 的列现在是特征向量(即轴的方向),而 D 对角线上的值是特征值(即长度轴).所以你已经有了MajorAxisLength"和MinorAxisLength".方向可能只是主轴和水平之间的角度(提示:使用 atan2 从指向主轴的向量计算它).最后,偏心度

The columns of V are now the eigenvectors (i.e. the directions of the axes), and values on the diagonal of D are the eigenvalues (i.e. the lengths of the axes). So you already have the 'MajorAxisLength' and 'MinorAxisLength'. The orientation is probably just the angle between the major axis and the horizontal (hint: use atan2 to compute this from the vector pointing along the major axis). Finally, the eccentricity is

sqrt(1-(b/a)^2)

其中 a 是长轴的长度,b 是短轴的长度.

where a is the length of the major axis and b is the length of the minor axis.

这篇关于区域的第二时刻是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆