Approximate a cloud of points (3D/2D) with the maximum volume inner and minimum volume outer ellipsoid. Also known as the inner and outer Löwner-John ellipses.
Using CVXPY package. Install the required packages into a separate virtual environment. I advise using Anaconda envinromment instead of pip, since CVXPY has all the necessary solvers compiled already there. Scikit image is needed to visualize your points.
I defined a set of random 3D points as a numpy
array as input data. Alternatively, a 2D numpy array can be given.
inner_ellipsoid.py
generates the maximum volume inscribed ellipsoid approximating a set of pointsouter_ellipsoid.py
generates the minimum volume enclosing ellipsoid around a set of points
Original points in blue, Outer Ellipsoid in Green Wireframe and Inner Ellipsoid as Orange Points
Solution in max_inner_ellipsoid_v2.py
was inspired by Hongkai-Dai