Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Best fit ellipse given vertice and a few points

Subject: Best fit ellipse given vertice and a few points

From: Conrad Andrew

Date: 19 Oct, 2008 18:34:02

Message: 1 of 9

Hi,

Is it possible to obtain a best-fit ellipse given a few known points:
 . One of the vertices
 . several points (up to 5) located on one of the quadrants which is adjacent to the known vertex point

I tried using the FitEllipse function but it doesn't appear to work well with the data that I have. Is there another function that works similarly to FitEllipse using the points that I have?

Thanks

Subject: Best fit ellipse given vertice and a few points

From: Conrad Andrew

Date: 21 Oct, 2008 10:21:01

Message: 2 of 9

"Conrad Andrew" <conrad7@gmx.net> wrote in message <gdfuiq$det$1@fred.mathworks.com>...
> Hi,
>
> Is it possible to obtain a best-fit ellipse given a few known points:
> . One of the vertices
> . several points (up to 5) located on one of the quadrants which is adjacent to the known vertex point
>
> I tried using the FitEllipse function but it doesn't appear to work well with the data that I have. Is there another function that works similarly to FitEllipse using the points that I have?
>
> Thanks

If it's not possible to solve this problem the way it is, could someone please let me know?

Subject: Best fit ellipse given vertice and a few points

From: John D'Errico

Date: 21 Oct, 2008 11:07:01

Message: 3 of 9

"Conrad Andrew" <conrad7@gmx.net> wrote in message <gdkaed$bhd$1@fred.mathworks.com>...
> "Conrad Andrew" <conrad7@gmx.net> wrote in message <gdfuiq$det$1@fred.mathworks.com>...
> > Hi,
> >
> > Is it possible to obtain a best-fit ellipse given a few known points:
> > . One of the vertices
> > . several points (up to 5) located on one of the quadrants which is adjacent to the known vertex point
> >
> > I tried using the FitEllipse function but it doesn't appear to work well with the data that I have. Is there another function that works similarly to FitEllipse using the points that I have?
> >
> > Thanks
>
> If it's not possible to solve this problem the way it is, could someone please let me know?

Yes, it is possible to "fit an ellipse" to data.

It is also true that you have not provided
enough information about your definition of
what fitting an ellipse means to you. Do you
mean a fit with errors allowed in both x and y?
Will your ellipse be allowed to tilt? What was
inadequate about the fit with the code that
you tried? Does that data have a better fitting
ellipse known to you? Some people want to
achieve a degree of fit to some data that is
wildly better than the data merits. There are
many things we may want in this world that
cannot be achieved.

Finally, you say that you have UP to 5 points
to fit an ellipse. However, a fully general
ellipse will require AT LEAST 5 points. Any
less than that number and the fit will not
even be unique. More than 5 points and the
fit will not in general be exact, however there
will generally be an optimal choice for the
parameters, regardless of whether the
chosen fitting scheme succeeds in the task.

John

Subject: Best fit ellipse given vertice and a few points

From: Conrad Andrew

Date: 21 Oct, 2008 11:48:01

Message: 4 of 9

"John D'Errico" <woodchips@rochester.rr.com> wrote in message <gdkd4l$5on$1@fred.mathworks.com>...
> "Conrad Andrew" <conrad7@gmx.net> wrote in message <gdkaed$bhd$1@fred.mathworks.com>...
> > "Conrad Andrew" <conrad7@gmx.net> wrote in message <gdfuiq$det$1@fred.mathworks.com>...
> > > Hi,
> > >
> > > Is it possible to obtain a best-fit ellipse given a few known points:
> > > . One of the vertices
> > > . several points (up to 5) located on one of the quadrants which is adjacent to the known vertex point
> > >
> > > I tried using the FitEllipse function but it doesn't appear to work well with the data that I have. Is there another function that works similarly to FitEllipse using the points that I have?
> > >
> > > Thanks
> >
> > If it's not possible to solve this problem the way it is, could someone please let me know?
>
> Yes, it is possible to "fit an ellipse" to data.
>
> It is also true that you have not provided
> enough information about your definition of
> what fitting an ellipse means to you. Do you
> mean a fit with errors allowed in both x and y?
> Will your ellipse be allowed to tilt? What was
> inadequate about the fit with the code that
> you tried? Does that data have a better fitting
> ellipse known to you? Some people want to
> achieve a degree of fit to some data that is
> wildly better than the data merits. There are
> many things we may want in this world that
> cannot be achieved.
>
> Finally, you say that you have UP to 5 points
> to fit an ellipse. However, a fully general
> ellipse will require AT LEAST 5 points. Any
> less than that number and the fit will not
> even be unique. More than 5 points and the
> fit will not in general be exact, however there
> will generally be an optimal choice for the
> parameters, regardless of whether the
> chosen fitting scheme succeeds in the task.
>
> John

Thanks for your reply John. To answer your questions, I want to fit the data with errors allowed for both x and y. The ellipse may be tilted if the data dictates it. The problem that I have is that Fitelllipse assumes (I think so anyway) that the data provided is spread around the ellipse to be approximated while what I have (5 points) belongs to only one of the quadrants. One additional point provided belongs to the vertex of the ellipse, adjacent to the 5 points provided. What I want is a best fit of an ellipse based on this data if it's possible.

Thanks for your time

Conrad

Subject: Best fit ellipse given vertice and a few points

From: John D'Errico

Date: 21 Oct, 2008 12:45:04

Message: 5 of 9

"Conrad Andrew" <conrad7@gmx.net> wrote in message <gdkfhh$s5q$1@fred.mathworks.com>...

> Thanks for your reply John. To answer your questions, I want to fit the data with errors allowed for both x and y. The ellipse may be tilted if the data dictates it. The problem that I have is that Fitelllipse assumes (I think so anyway) that the data provided is spread around the ellipse to be approximated while what I have (5 points) belongs to only one of the quadrants. One additional point provided belongs to the vertex of the ellipse, adjacent to the 5 points provided. What I want is a best fit of an ellipse based on this data if it's possible.
>

Fits to a curve with errors in both x and y
are quite difficult in general. The problem
is, given a point in the (x,y) plane, and a
general ellipse defined by a set of parameters,
what is the distance to that ellipse from the
point?

The fact that your data lies all in one quadrant
is a problem because the fitting scheme will
be a nonlinear one. So if I had to come up
with starting values for the ellipse parameters,
I would use either eig or svd to estimate the
ellipse orientation and size. But that would
indeed presume a set of points that were
scattered around the perimeter of the ellipse.

If you have additional information about a
vertex of the ellipse (do you mean that point
where the ellipse is most highly curved when
you say vertex?) I'm not sure that this provides
you with anything useful beyond the fact that
the ellipse passes through that point.

John

Subject: Best fit ellipse given vertice and a few points

From: Lorenzo Guerrasio

Date: 21 Oct, 2008 13:29:02

Message: 6 of 9


> Thanks for your reply John. To answer your questions, I want to fit the data with errors allowed for both x and y. The ellipse may be tilted if the data dictates it. The problem that I have is that Fitelllipse assumes (I think so anyway) that the data provided is spread around the ellipse to be approximated while what I have (5 points) belongs to only one of the quadrants. One additional point provided belongs to the vertex of the ellipse, adjacent to the 5 points provided. What I want is a best fit of an ellipse based on this data if it's possible.
>
> Thanks for your time
>
> Conrad


I'm not 100% sure,but I guess it would be licit, knowing that all the points belong only to one of the quadrant and knowing the vertex,to fit an ellipse with these points and the simmetrical rispect to the vertex. I think with this information you could fit the ellipse better. Use the information of the vertex to simplify the problem depends on which methods of fitting you are using.

REgards

Subject: Best fit ellipse given vertice and a few points

From: Conrad Andrew

Date: 23 Oct, 2008 11:43:01

Message: 7 of 9

"Lorenzo Guerrasio" <lorenzo.guerrasio@email.it> wrote in message <gdkleu$6bg$1@fred.mathworks.com>...
>
> > Thanks for your reply John. To answer your questions, I want to fit the data with errors allowed for both x and y. The ellipse may be tilted if the data dictates it. The problem that I have is that Fitelllipse assumes (I think so anyway) that the data provided is spread around the ellipse to be approximated while what I have (5 points) belongs to only one of the quadrants. One additional point provided belongs to the vertex of the ellipse, adjacent to the 5 points provided. What I want is a best fit of an ellipse based on this data if it's possible.
> >
> > Thanks for your time
> >
> > Conrad
>
>
> I'm not 100% sure,but I guess it would be licit, knowing that all the points belong only to one of the quadrant and knowing the vertex,to fit an ellipse with these points and the simmetrical rispect to the vertex. I think with this information you could fit the ellipse better. Use the information of the vertex to simplify the problem depends on which methods of fitting you are using.
>
> REgards

I would have thought that if one quadrant of an ellipse can be approximated, then it must be possible to get the coordonates of the whole ellipse. Does any of you experts out there have a solution that I could use?

Cheers

Subject: Best fit ellipse given vertice and a few points

From: John D'Errico

Date: 23 Oct, 2008 11:57:01

Message: 8 of 9

"Conrad Andrew" <conrad7@gmx.net> wrote in message <gdpo05$gn3$1@fred.mathworks.com>...

>
> I would have thought that if one quadrant of an ellipse can be approximated, then it must be possible to get the coordonates of the whole ellipse. Does any of you experts out there have a solution that I could use?
>

The problem is that you there is no assurance that
the part of an ellipse that falls in the first quadrant
will actually be only one quadrant of an ellipse.
You may find that fully half the ellipse falls in the
first quadrant, or you may find the entire ellipse
does so, depending on the orientation and the
center of the ellipse.

You ask for an expert who will give you a magic
solution. While I might qualify as an expert, the
solution is probably just hard work. To be solved,
this will require an optimization with 5 unknowns.
You need reasonably good starting values, since
it is easy to get trapped in a spurious local
minimum of the sum of squares objective (as
you have clearly found.) And, since you want to
find a solution that solves for a total least squares
solution (allowing errors in both variables) you
will not find any easy way out.

Sorry, but merely wanting something badly
enough only works if you are wearing a pair of
ruby slippers. Close your eyes, click your heels
together three times, ... ;-)

John

Subject: Best fit ellipse given vertice and a few points

From: Richard Brown

Date: 31 Oct, 2008 07:56:57

Message: 9 of 9

On Oct 22, 12:48=A0am, "Conrad Andrew" <conr...@gmx.net> wrote:
> "John D'Errico" <woodch...@rochester.rr.com> wrote in message <gdkd4l$5o.=
..@fred.mathworks.com>...
> > "Conrad Andrew" <conr...@gmx.net> wrote in message <gdkaed$bh...@fred.m=
athworks.com>...
> > > "Conrad Andrew" <conr...@gmx.net> wrote in message <gdfuiq$de...@fred=
.mathworks.com>...
> > > > Hi,
>
> > > > Is it possible to obtain a best-fit ellipse given a few known point=
s:
> > > > =A0. One of the vertices
> > > > =A0. several points (up to 5) located on one of the quadrants which=
 is adjacent to the known vertex point
>
> > > > I tried using theFitEllipsefunction but it doesn't appear to work w=
ell with the data that I have. Is there another function that works similar=
ly toFitEllipseusing the points that I have?
>
> > > > Thanks
>
> > > If it's not possible to solve this problem the way it is, could someo=
ne please let me know?
>
> > Yes, it is possible to "fit an ellipse" to data.
>
> > It is also true that you have not provided
> > enough information about your definition of
> > what fitting an ellipse means to you. Do you
> > mean a fit with errors allowed in both x and y?
> > Will your ellipse be allowed to tilt? What was
> > inadequate about the fit with the code that
> > you tried? Does that data have a better fitting
> > ellipse known to you? Some people want to
> > achieve a degree of fit to some data that is
> > wildly better than the data merits. There are
> > many things we may want in this world that
> > cannot be achieved.
>
> > Finally, you say that you have UP to 5 points
> > to fit an ellipse. However, a fully general
> > ellipse will require AT LEAST 5 points. Any
> > less than that number and the fit will not
> > even be unique. More than 5 points and the
> > fit will not in general be exact, however there
> > will generally be an optimal choice for the
> > parameters, regardless of whether the
> > chosen fitting scheme succeeds in the task.
>
> > John
>
> Thanks for your reply John. To answer your questions, I want to fit the d=
ata with errors allowed for both x and y. The ellipse may be tilted if the =
data dictates it. The problem that I have is that Fitelllipse assumes (I th=
ink so anyway) that the data provided is spread around the ellipse to be ap=
proximated while what I have (5 points) belongs to only one of the quadrant=
s. One additional point provided belongs to the vertex of the ellipse, adja=
cent to the 5 points provided. What I want is a best fit of an ellipse base=
d on this data if it's possible.
>
> Thanks for your time
>
> Conrad

Is it my fitellipse that you are using? ( http://www.mathworks.com/matlabce=
ntral/fileexchange/15125
)
This uses nonlinear least squares and might work for your data - it
doesn't *assume* that your data is spread around the whole ellipse per
se.

Can you post a sample of your data?

cheers,

Richard

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us