How to fit largest ellipsoid for 3d data points such that it covers all points?

8 次查看(过去 30 天)
Hi, I have search a lot for ellipsoid fit to 3d data and come up with some answer but I want some improvement in my method such that it covers all the data points. My code is here.
Y=data; % data in non-principle coordinate
X = data;
oldmu =mean(X);
X= bsxfun(@minus,X,oldmu); % mean-centered data
[pc val] = eig(X'*X );
nC = X*pc; % data in principle coordinate
a2=(max(nC(:,1))-min(nC(:,1)))/2; %range of data in X
b2=(max(nC(:,2))-min(nC(:,2)))/2; %range of data in Y
c2=(max(nC(:,3))-min(nC(:,3)))/2; %range of data in Z
[x, y, z] = ellipsoid(0,0,0,a2,b2,c2,40);
% fit ellipsoid in principle coordinate
tt=[x(:) y(:) z(:)]*inv(pc);%ellipsoid in non-principle coordinate
nx=reshape(tt(:,1),size(x,1),size(x,2));
ny=reshape(tt(:,2),size(x,1),size(x,2));
nz=reshape(tt(:,3),size(x,1),size(x,2));
% plot ellipsoid in non-principle coordinate
hSurface=surf(nx+oldmu(1), ny+oldmu(2), nz+oldmu(3), 'FaceColor','r','EdgeColor','none','FaceAlpha',0.6);
hold on
%plot data in non-principle coordinate
plot3(Y(:,1),Y(:,2),Y(:,3),'k.-')
end
The data file is here.
  1 个评论
Baptiste Ottino
Baptiste Ottino 2017-8-7
What do you mean by "covers all the data points". Do you want an ellipsoid that encompasses all the data points? Or is all your data located on the surface of an ellipsoid for sure?

请先登录,再进行评论。

回答(1 个)

Image Analyst
Image Analyst 2017-8-8
I think it's pretty difficult. John did the same thing in 2-D here http://www.mathworks.com/matlabcentral/fileexchange/34767-a-suite-of-minimal-bounding-objects If it were easy he'd probably have done it already.
  1 个评论
ankit agrawal
ankit agrawal 2017-8-8
Thank you for answer. Someone told me about Khachiyan Algorithm and it is working very fine. https://github.com/minillinim/ellipsoid/blob/master/ellipsoid.py

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Surface and Mesh Plots 的更多信息

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by