Fitting an ellipse to a cloud of points

Is there a simple way in Igor to fit an ellipse to a cloud of points to arrive at an estimate of ellipse area, length of the major axis, and minor axis? I have attached sample data as a example.

Sample data

In reply to by tony

Ah, I replied before looking at your data. You want to estimate an ellipse that surrounds, or nearly surrounds, a cloud of data. That's a different problem to fitting an ellipse through the data. You might be able to get away with fitting an implicit function to the convex hull of the data, but the data you supplied may not be well-behaved enough for that to work.

It won't be of much help to you, but what you're doing is a bit like what I did with the encircle project.

Hi Joseph, there are a few ways to approach this.

Very simple: you could fit a convex hull to the data and use this to estimate the area. The points of the hull could then be used for fitting an ellipse?

More involved (but worth it IMO): do a PCA on the data, the eigenvectors will be the major and minor axes of your point cloud. A walkthrough with an example is described by A.G. in this thread…

Hey Joseph,

I realize I'm probably too late, but here is a little function to do what you were looking for. It plots a Bivariate Contour Ellipse and calculates its area (BCEA).

I excised this bit from a much larger function that I wrote for a paper a couple years ago. It takes three inputs, two waves (x and y data) and a decimal percentage between 0 and 1 (representing the intended confidence interval).

The function outputs a graph of the data surrounded by an ellipse of the appropriate size and reports the ellipse area in arbitrary units to the command line.

Hope it helps if you're still interested in the topic. May help others as well.




John R. Economides, PhD

Beckman Vision Center

University of California, San Francisco


In reply to by tony

Thanks Tony. I wish I had seen this a couple months ago, might have been of some help to the original poster.

BTW, if anyone downloaded this function within a few minutes of when I initially posted it, please download it again. There was a bug in the area calculation that I have since fixed.



Thanks John for the post and the function.  It was exactly what I was looking for. I had fooled around with the code from other analysis software but was struggling to port it over to the world of Igor which I prefer to use for all of our analyses and generating figures.  I had gone through the tedious manual process and was incorporating that into a macro when I received word regarding your post.  Just got around to trying it and it's great and I will be using that to sort out our data.  I am really grateful for your help as well as all the others just trying to lend a hand.  This discussion forum really works.

I also see we have an overlap in our academic travels.  I held my first faculty appointment in otolaryngology at UTMB from 2005-2008 before moving to Rochester, NY.  Small world I suppose.  Again thanks for all the help.

Happy to be of help Joseph. Guessing you got chased out of Galveston by Ike. Nasty business that. But from what I can tell UTMB is bouncing back fairly well.






Igor Pro 8

Learn More

Igor XOP Toolkit

Learn More

Igor NIDAQ Tools MX

Learn More