HOME

TheInfoList



OR:

The Ramer–Douglas–Peucker algorithm, also known as the Douglas–Peucker algorithm and iterative end-point fit algorithm, is an algorithm that decimates a curve composed of line segments to a similar curve with fewer points. It was one of the earliest successful algorithms developed for
cartographic generalization Cartographic generalization, or map generalization, includes all changes in a map that are made when one derives a scale (map), smaller-scale map from a larger-scale map or map data. It is a core part of cartographic design. Whether done manually b ...
. It produces the most accurate generalization, but it is also more time-consuming.


Algorithm

The starting curve is an ordered set of points or lines and the distance dimension . The algorithm recursively divides the line. Initially it is given all the points between the first and last point. It automatically marks the first and last point to be kept. It then finds the point that is farthest from the line segment with the first and last points as end points; this point is always farthest on the curve from the approximating line segment between the end points. If the point is closer than to the line segment, then any points not currently marked to be kept can be discarded without the simplified curve being worse than . If the point farthest from the line segment is greater than from the approximation then that point must be kept. The algorithm recursively calls itself with the first point and the farthest point and then with the farthest point and the last point, which includes the farthest point being marked as kept. When the recursion is completed a new output curve can be generated consisting of all and only those points that have been marked as kept.


Non-parametric Ramer–Douglas–Peucker

The choice of is usually user-defined. Like most line fitting, polygonal approximation or dominant point detection methods, it can be made non-parametric by using the error bound due to digitization and quantization as a termination condition.


Pseudocode

Assuming the input is a one-based array: # source: https://karthaus.nl/rdp/ function DouglasPeucker(PointList[], epsilon) # Find the point with the maximum distance dmax = 0 index = 0 end = length(PointList) for i = 2 to (end - 1) ResultList[] = empty; # If max distance is greater than epsilon, recursively simplify if (dmax > epsilon) else # Return the result return ResultList[]


Application

The algorithm is used for the processing of vector graphics and
cartographic generalization Cartographic generalization, or map generalization, includes all changes in a map that are made when one derives a scale (map), smaller-scale map from a larger-scale map or map data. It is a core part of cartographic design. Whether done manually b ...
. It is recognized as the one that delivers the best perceptual representations of the original lines. But a self-intersection could occur if the accepted approximation is not sufficiently fine which led to the development of variant algorithms. The algorithm is widely used in robotics to perform simplification and denoising of range data acquired by a rotating range scanner; in this field it is known as the split-and-merge algorithm and is attributed to
Duda The Hungary, Hungarian duda (also known as ''tömlősíp'' and ''bőrduda'') is the traditional bagpipe of Hungary. It is an example of a group of bagpipes called Medio-Carparthian bagpipes. Accounts are conflicting regarding the exact form of ...
and Hart.


Complexity

The running time of this algorithm when run on a polyline consisting of segments and vertices is given by the recurrence where is the value of index in the pseudocode. In the worst case, or at each recursive invocation yields a running time of . In the best case, or at each recursive invocation yields a running time of . Using (fully or semi-) dynamic convex hull data structures, the simplification performed by the algorithm can be accomplished in time. Given specific conditions related to the bounding metric, it is possible to decrease the computational complexity to a range between and through the application of an iterative method. The running time for
digital elevation model A digital elevation model (DEM) or digital surface model (DSM) is a 3D computer graphics representation of elevation data to represent terrain or overlaying objects, commonly of a planet, Natural satellite, moon, or asteroid. A "global DEM" refer ...
generalization using the three-dimensional variant of the algorithm is , but techniques have been developed to reduce the running time for larger data in practice.


Similar algorithms

Alternative algorithms for line simplification include: * Visvalingam–Whyatt * Reumann–Witkam * Opheim simplification * Lang simplification * Zhao–Saalfeld * Imai-Iri


See also

*
Curve fitting Curve fitting is the process of constructing a curve, or mathematical function, that has the best fit to a series of data points, possibly subject to constraints. Curve fitting can involve either interpolation, where an exact fit to the data is ...


Further reading

* * * UBC Tech Report TR-92-07 available a
Speeding Up the Douglas-Peucker Line-Simplification Algorithm , Computer Science at UBC
* *


References


External links



* ttp://www.codeproject.com/Articles/114797/Polyline-Simplification Implementation of Ramer–Douglas–Peucker and many other simplification algorithms with open source licence in C++
XSLT implementation of the algorithm for use with KML data.


* ttp://karthaus.nl/rdp/ Interactive visualization of the algorithm
Implementation in F#

Ruby gem implementation

JTS, Java Topology Suite
contains Java implementation of many algorithms, including th


Rosetta Code (Implementations in many languages)
{{DEFAULTSORT:Ramer-Douglas-Peucker algorithm Computer graphics algorithms Geometric algorithms Digital signal processing Articles with example pseudocode