File Exchange

## Ellipsoid Fitting

version 1.0.0.0 (1.17 KB) by
Two matlab files to demonstrate how to fit an ellipsoid directly to a set of 3D points.

7 Downloads

Updated 20 Mar 2009

No License

The code implemented a special case of the ellipsoid fitting technique proposed in the paper Least Squares Ellipsoid Specific Fitting, corresponding to case k= 4. Just put the two files in the same directory and run "testFit4". You can change the noise level to observe the fitting accuracy and efficiency of the algorithm. It works well when the underlying shape characterized by the data points is quite spherical. However, if this is not the case, some modification is required. For the technical detail of the fitting method, please refer to the above mentioned paper, which can be found from the following webpage:
http://www2.computer.org/portal/web/csdl/doi?doc=abs/proceedings/gmp/2004/2078/00/20780335abs.htm

### Cite As

Q LI (2021). Ellipsoid Fitting (https://www.mathworks.com/matlabcentral/fileexchange/23377-ellipsoid-fitting), MATLAB Central File Exchange. Retrieved .

### Comments and Ratings (9)

ZHI LUO

thanks a lot

Neel Mehta

This code works really well. I am supprised. I don't understand why people have voted it so low. Therefore I have given it 5 stars.

Marek Dostal

Hi,
I would like to calculate eigenvalues and eigenvectors from fitting ellipsoid.
Could you help me how?

Thanks

Hartmut Bauer

Hi,
How can I get the semiaxis from matlab?

Q Li

The above link to the paper is broken. The paper for the algorithm can be found from ResearchGate at
https://www.researchgate.net/publication/4070857_Least_squares_ellipsoid_specific_fitting
or from IEEE Xplore at https://ieeexplore.ieee.org/stamp/stamp.jsp?arnumber=1290055
Compared with the algorithm presented by Yury at https://uk.mathworks.com/matlabcentral/fileexchange/24693-ellipsoid-fit?s_tid=FX_rc1_behav, it is all about fitting accuracy. To compare the two algorithms, you have to use the same set of datasets.

If you find the fitted ellipsoid cannot be displayed properly, please change the line of code for creating the mesh grid in testFit4.m from
[x, y, z]=meshgrid(-a:stepA:a, -b:stepB:b, -c:stepC:c);
to:
[x, y, z]=meshgrid(minX-stepA:stepA:maxX+stepA, minY-stepB:stepB:maxY+stepB, minZ-stepC:stepC:maxZ+stepC);

Jean-Yves Tinevez

The code cannot be used in a general manner.

Toni

Why is the size of the points in the testfit (11,6)?

Should it not be 11,3 for xyz?

what is the meaning here?

Vladimir

chuk Zhu

where I check your test, I find the values of the major, medium and short radius from the equation u^3 - I*u^2 + J * u - K = 0 have some problems...

Here I = a + b + c
J = ab+bc+ac-f^2 - g^2 - h^2
K = |a h g; h b f; g f c|;

from "least squares ellipsoid specific fitting" GMP-04

##### MATLAB Release Compatibility
Created with R13
Compatible with any release
##### Platform Compatibility
Windows macOS Linux
##### Acknowledgements

Inspired: RADIOMICS, hyperellipsoidfit

### Community Treasure Hunt

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

Start Hunting!