File Exchange

image thumbnail

image ellipsoid 3D

version (329 KB) by David Legland
Equivalent ellipsoid from 3D image


Updated 28 Aug 2019

View Version History

View License

The package allows to compute equivalent ellipse or ellipsoid from 2D/3D images. Both functions works for binary or label image (one result per label), or for intensity images (resulting ellipse / ellipsoid is weighted by image intensity).

The function "imEquivalentEllipsoid" computes moments of the 3D image or labels, and returns the associated equivalent 3D ellipsoid. The function is similar to that obtained with the "regionporps" function, but with slightly different scaling coefficients. The function "drawEllipsoid" can be used to display result.

The function "imEquivalentEllipse" computes moments of the 2D image or labels, and returns the associated equivalent ellipse. The function "drawEllipse" can be used to display result.

The package includes functions from the geom2d and geom3d contributions. This package is a subset of the matImage toolbox (available at )

Cite As

David Legland (2021). image ellipsoid 3D (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (5)

David Legland

I have submitted a new version that contains document explaining where the coefficient comes from. The coefficient was finally updated to sqrt(5). The name of the functions were also changed to "imEquivalentEllipse" and "imEquivalentEllipsoid", to avoid ambiguities with inertia ellipsoid.

David Legland

For Kim (small update to my previous comment):
actually the coefficient of 2 produces an ellipsoid that encloses most of the image voxels. This can be seen as an analogy to the computation of the interval containing 95% of the values of a random variable following gaussian distribution: the interval is given by +/-1.96 times the square root of the variance around the mean.


David Legland

Hi Kim,
well, actually I do not remember where does the factor 2 comes from... I suppose I have adjusted manually such that the size of the resulting ellipsoid better fit the original image.


I'm just wondering why you multiplied 2 by square root of eigenvalues (for covariance matrix of points) (i.e., singular values that means scaling factors in each dimension) when caculating lengths of semi-axes (radii) of an elllipsoid at the imInertiaEllipsoid.m

Muhammad Mhajna

MATLAB Release Compatibility
Created with R2009b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Inspired by: geom3d, geom2d

Inspired: BiofilmQ

Community Treasure Hunt

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

Start Hunting!