I am writing a program im Matlab to find ellipses in noisy XY data using a Random Sampling Consensus (RANSAC) algorithm. It basically samples enough points to define an ellipse and then determines the consensus as the number of points within a certain distance to this ellipse. After X trials, the ellipse with the most inliers is chosen.
Right now, I compute the distance of the points to the ellipse by generating 500 points on the ellipse boundary, compute the distance of every one of these ellipse points to the points to be fit, and select the least distance as the distance between the point and the ellipse. For the 1000 - 10000 points I want to fit to, this distance calculation is the bottleneck of the computation.
The algorithms I found for distance point to ellipse usually need to solve rather complex equations. Ideally, I am looking for an algorithm that can be vectorised, so the calculations can be done for every point I want to fit at the same time. If that isn't possible, fast methods that can be done in a loop for every point are also ok. Approximate solutions (maybe using an interpolation of the ellipse or something) are welcome. Thanks!