椭圆的协方差矩阵

Oma*_*r14 7 matlab image-processing matrix ellipse covariance

我一直在努力解决问题.我很惊讶我在网上找不到任何真正有用的东西.

我知道,从椭圆的协方差矩阵的特征值,可以计算椭圆的长轴和短轴.如下:

a1 = 2*sqrt(e1)
a2 = 2*sqrt(e2)
Run Code Online (Sandbox Code Playgroud)

其中a1a2是主轴和短轴,e1并且e2是协方差矩阵的特征值.

我的问题是:给定(xi,yi)图像椭圆的边缘点,如何找到该椭圆的2×2协方差矩阵?

Rod*_*uis 5

仅通过纯粹的逆向工程(我对这种材料不再熟悉),我可以做到这一点:

%// Generate circle
R = 189;
t = linspace(0, 2*pi, 1000).';
x = R*cos(t);
y = R*sin(t);

%// Find the radius?
[~,L] = eig( cov([x,y]) );

%// ...hmm, seems off by a factor of sqrt(2)
2*sqrt( diag(L) )        

%// so it would come out right when I'd include a factor of 1/2 in the sqrt():
2*sqrt( diag(L)/2 )        
Run Code Online (Sandbox Code Playgroud)

那么,让我们测试一下一般椭圆的理论:

%// Random radii
a1 = 1000*rand;
a2 = 1000*rand;

%// Random rotation matrix
R = @(a)[
    +cos(a) +sin(a); 
    -sin(a) +cos(a)];

%// Generate pionts on the ellipse 
t = linspace(0, 2*pi, 1000).';
xy = [a1*cos(t)  a2*sin(t);] * R(rand);

%// Find the deviation from the known radii
%// (taking care of that the ordering may be different)
[~,L] = eig(cov(xy));
min(abs(1-bsxfun(@rdivide, 2*sqrt( diag(L)/2 ), [a1 a2; a2 a1])),[],2)
Run Code Online (Sandbox Code Playgroud)

它总是返回一些可接受的小值。

所以,似乎可行:)任何人都可以验证这确实是正确的吗?