OpenCV Q&A Forum - RSS feedhttp://answers.opencv.org/questions/OpenCV answersenCopyright <a href="http://www.opencv.org">OpenCV foundation</a>, 2012-2018.Tue, 26 Jul 2016 06:54:47 -0500how to fit an ellipse to 2D data with random three points and thire gradient?http://answers.opencv.org/question/44372/how-to-fit-an-ellipse-to-2d-data-with-random-three-points-and-thire-gradient/i need to fit an ellipse to 2D data with random three points and their gradient. and the points is the edge points of one image. i use the Opencv function to calculate the gradient of each point.
i konw the RANSAC algorithm can do this job. and this algorithm can find the inner points fitting the ellipse and reject the noise points. but this algorithm uses five random points and it increases the sample times. so i want to improve this algorithm.
now considering the ellipse property, i find the three random points and their gradient can fit an ellipse. i have done this job combining the RANSAC algorithm. i choose three random points, calculate the ellipse center with their gradient. when i choose the fourth point and add some constraint of the ellipse. lastly, i find the inner points. but it doesnot work well.
so i want to know how to make this job well, especially restraining the fourth point with the ellipse property.
thanks!
this is all the points
![enter image description here][1]
this is the result(the green points is the inner points, the red is the noise, the blue is the center)
![enter image description here][2]
[1]: http://i.stack.imgur.com/7ajsp.jpg
[2]: http://i.stack.imgur.com/FXhEh.jpgTue, 14 Oct 2014 21:54:21 -0500http://answers.opencv.org/question/44372/how-to-fit-an-ellipse-to-2d-data-with-random-three-points-and-thire-gradient/Answer by matman for <p>i need to fit an ellipse to 2D data with random three points and their gradient. and the points is the edge points of one image. i use the Opencv function to calculate the gradient of each point. </p>
<p>i konw the RANSAC algorithm can do this job. and this algorithm can find the inner points fitting the ellipse and reject the noise points. but this algorithm uses five random points and it increases the sample times. so i want to improve this algorithm.</p>
<p>now considering the ellipse property, i find the three random points and their gradient can fit an ellipse. i have done this job combining the RANSAC algorithm. i choose three random points, calculate the ellipse center with their gradient. when i choose the fourth point and add some constraint of the ellipse. lastly, i find the inner points. but it doesnot work well. </p>
<p>so i want to know how to make this job well, especially restraining the fourth point with the ellipse property.</p>
<p>thanks!
this is all the points
<img alt="enter image description here" src="http://i.stack.imgur.com/7ajsp.jpg"></p>
<p>this is the result(the green points is the inner points, the red is the noise, the blue is the center)
<img alt="enter image description here" src="http://i.stack.imgur.com/FXhEh.jpg"></p>
http://answers.opencv.org/question/44372/how-to-fit-an-ellipse-to-2d-data-with-random-three-points-and-thire-gradient/?answer=44586#post-id-44586I needed a robust ellipse fit out of contour points from OpenCV.
I found this paper:<br>
https://www.princeton.edu/~kulkarni/Papers/Journals/j074_2010_YuZhengKulPoor_EURASIP.pdf<br>
It uses a combined outlier detection. At first proximity is checked. In the second step a model based detection is used. It seems to be much faster and more robust than RAMSAC.
Because the findContour algorith from OpenCV gives me only points with direct proximity, I only had to programm the model based algoritm.
For 5000 points the calculation time is about 1ms for choosing inliners, with SSE Intrinsics its about 0,2ms on an Intel Q9300 processor.Thu, 16 Oct 2014 14:02:42 -0500http://answers.opencv.org/question/44372/how-to-fit-an-ellipse-to-2d-data-with-random-three-points-and-thire-gradient/?answer=44586#post-id-44586Comment by Chrizzy for <p>I needed a robust ellipse fit out of contour points from OpenCV.
I found this paper:<br>
<a href="https://www.princeton.edu/~kulkarni/Papers/Journals/j074_2010_YuZhengKulPoor_EURASIP.pdf">https://www.princeton.edu/~kulkarni/Papers/Journals/j074_2010_YuZhengKulPoor_EURASIP.pdf</a><br></p>
<p>It uses a combined outlier detection. At first proximity is checked. In the second step a model based detection is used. It seems to be much faster and more robust than RAMSAC.</p>
<p>Because the findContour algorith from OpenCV gives me only points with direct proximity, I only had to programm the model based algoritm.
For 5000 points the calculation time is about 1ms for choosing inliners, with SSE Intrinsics its about 0,2ms on an Intel Q9300 processor.</p>
http://answers.opencv.org/question/44372/how-to-fit-an-ellipse-to-2d-data-with-random-three-points-and-thire-gradient/?comment=98995#post-id-98995May you want to share your implementation of that algorithm?
That would be awesome! I'm looking for the exact same thing, and it would be very nice to save the time for implementing this.
Greetings from Leipzig!Tue, 26 Jul 2016 06:54:47 -0500http://answers.opencv.org/question/44372/how-to-fit-an-ellipse-to-2d-data-with-random-three-points-and-thire-gradient/?comment=98995#post-id-98995