I have been scouting around the net for an algorithm that enables you to create level of detail (LOD) representations of 2D polygons, but am unable to find ANY decent reference. Maybe I am using the wrong search terms, but all search results are for 3D LOD algorithms, which, I guess, cannot(?) really be applied in 2D.
I am sure that before the onslaught of 3D graphics, many people would have worked on 2D LOD algorithms. Any clues or pointers to where I can get more information? Thanks!
Aside from the obvious dumbest algorithm which would be to take every Nth vertex from the polygon (reducing the number of vertices by N), here is an idea inspired by some 3D algorithms.
Usually, in 3D, what is required is to remove the faces that contribute less to the overall volume. To do this, we try to simplify the "flattest" areas of the model.
Now in 2D, you could translate this to "simplify the segments that have the smallest angle between them. A first naïve implementation could be:
Of course, this is not optimal but it should be a good trade of between quality and speed. Instead of the angle, you could take the minimal distance between the middle point of two segments (Pi+1) and the potentially simplified segment ([Pi, Pi+2])
Edit:
Another algorithm I would try if I did not need too much performance:
Finally, I found some source code for you on that link: http://motiondraw.com/md/as_samples/t/LineGeneralization/demo.html, as well as the associated algorithms: http://www.geom.unimelb.edu.au/gisweb/LGmodule/LGSimplification.htm
Search for Douglas-Peucker algorithm which is used to simplify polylines, but may be extended to support polygons. It is what I have used. There are also topologically stable extensions if you need that.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With