一个地区的第二瞬间是什么? [英] What are the second-moments of a region?

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

问题描述

我目前正在复制Matlab的regionprops函数在Octave的一些功能。但是,我有一个功能的一个子集的挂起。 偏心度,MajorAxisLength,MinorAxisLength和方向属性是我的要点。在文档中,它们都衍生自...与区域具有相同第二矩的椭圆。



所以我的问题是,这些第二 - 我如何找到他们?



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



老实说,更困惑。任何人都可以指点我的东西多一点初学者友好?感谢。

解决方案

由第二时刻,文档意味着第二个中心时刻



在一维数据的情况下, a href =http://en.wikipedia.org/wiki/Variance =nofollow noreferrer>方差(或标准差的平方)。



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



如果 X 是您所在地区的点的n乘2矩阵,您可以在MATLAB中计算协方差矩阵 Sigma 这样(未测试):

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

现在,这与省略号有什么关系?那么,你在这里做的是,实际上,适合一个多变量正态分布到你的数据。协方差矩阵确定该分布的形状和多变量正态分布的轮廓线 - 等待它 -

  [V,D] = eig(Sigma); 

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

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

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


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?

I was looking at this link: 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.

解决方案

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.

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);

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)

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

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

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