5

I have a set of points in 2D ( coordinates for x and y ), now I need to discard all the points that are not meaningful to me, and what I mean by that is that I'm only interested in the area that this points are tracing.

In short, this

enter image description here

it's supposed to produce this

enter image description here

question: what algorithm can do this kind of filtering on this points ?

Ashwin Nanjappa
  • 76,204
  • 83
  • 211
  • 292
pgf
  • 65
  • 1
  • 6

2 Answers2

6

You can use Graham Scan to compute Convex hull of the given points. Once you have all the points on the convex hull you can eliminate the others.

There are other algorithms as well for computing convex hull, but Graham scan is easy to implement and is O(n logn).

vidit
  • 6,293
  • 3
  • 32
  • 50
  • 3
    just note that the /convex/ hull returns a **convex** hull : in your example, you'll likely be missing the point in the bottom which is not part of the convex hull (the shape you will obtain is hence convex and any point that would make this shape non-convex will not be returned) – nbonneel Mar 31 '13 at 23:00
  • 1
    To follow up WhitAngl's comment, you might also look into alpha hulls (a.k.a. alpha shapes) to get points that are close to but not quite part of the convex hull. http://cgm.cs.mcgill.ca/~godfried/teaching/projects97/belair/alpha.html – Rethunk Apr 07 '13 at 03:53
3

I believe you are looking for a convex hull algorithm. I personally use Graham Scan algorithm to implement convex hull as it has very good complexity O(n*log(n)) and is relatively easy to implement.

Ivaylo Strandjev
  • 69,226
  • 18
  • 123
  • 176