How to determine path from noisy X, Y data

后端 未结 10 1968
星月不相逢
星月不相逢 2021-02-08 21:54

I have an unsorted list of noisy X, Y points. They do, however, form a path through the world. I would like an algorithm to draw an approximation of this data using line segment

10条回答
  •  梦毁少年i
    2021-02-08 22:21

    Here is a heuristic hack that might address the ordering problem for the data, if

    • you have enough points
    • the mean distance between points is small compared to the smallest radius of curvature expected of the path
    • the mean distance between points is not large compared to the std. dev. of the noise
    • the path is not self-crossing (you might get lucky, but no guarantees)

    Proceed like this:

    1. Pick (hopefully by a meaningful rather than random means) a starting point, p1.
    2. Find all the points that lie within some clustering distance, r_c of p1. Choose r_c small compared to the expected turning radius, but large compared to the scatter.
    3. Call this cluster C1.
    4. Find point q1 the mean of positions in C1.
    5. Fit a line to the points in C1 and project to (or just beyond) the edge of the cluster, and find the nearest point in your original data. Label that point p2.
    6. Iterate steps 2-5 until you run out of data.

    Now you have a new list of points q1..qn that are ordered.

    Off the top of my head, very rough, and only works under pretty good conditions...


    Self-crossing behavior can probably be improved by requiring in step (5) that the new projected line lie within some maximum angle of the previous one.

提交回复
热议问题