Re: Regarding the Fit_Ellipse Program [message #59004 is a reply to message #58903] |
Thu, 28 February 2008 09:10   |
pgrigis
Messages: 436 Registered: September 2007
|
Senior Member |
|
|
plim.dream...@gmail.com wrote:
[skip]
> I certainly don't understand why there isn't a fit_ellipse program
> that works with the x,y array of the contour vertices instead of the
> pixel indices of the image of a contour (I wish I knew how to make one
> myself).
In general, if you have a number of x and y coordinates for the
boundary
of the ellipse it is not possible to directly use the method used
in fit_ellipse, beacuse if there are, say, twice as many points in
the left side of the ellipse than in the right side, the center of
mass
and moment of inertia will be shifted to the left.
One could then try to "fill out" a two dimensional shape.
Using polyfillv is not a good idea because the results depend in
general on the ordering of the x and y vector (if I swap two
points, the polygon will be different, but the best fit ellipse should
not depend on ordering or labeling of the points).
One could try and use a convex hull insetad, but this may lead to
overestimation of the size of the ellipse and would be really badly
sensitive to outliers.
In such a situation (given unsorted x,y coordinates)
I think that it would probably better to use a minimization function,
with the weight being minimized as the sum of the squares of the
distances of each point to the ellipse. This should not be too hard
to implement.
Paolo
> B
|
|
|