Everipedia Logo
Everipedia is now IQ.wiki - Join the IQ Brainlist and our Discord for early access to editing on the new platform and to participate in the beta testing.
Ramer–Douglas–Peucker algorithm

Ramer–Douglas–Peucker algorithm

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.

Idea

The purpose of the algorithm is, given a curve composed of line segments (which is also called a Polyline in some contexts), to find a similar curve with fewer points. The algorithm defines 'dissimilar' based on the maximum distance between the original curve and the simplified curve (i.e., the Hausdorff distance between the curves). The simplified curve consists of a subset of the points that defined the original curve.

Algorithm

The effect of varying epsilon in a parametric implementation of RDP

The effect of varying epsilon in a parametric implementation of RDP

The starting curve is an ordered set of points or lines and the distance dimension ε > 0.

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 furthest from the line segment with the first and last points as end points; this point is obviously furthest 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 furthest 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 furthest point and then with the furthest point and the last point, which includes the furthest 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 / dominant point detection methods, it can be made non-parametric by using the error bound due to digitization / quantization as a termination condition.[1]

Pseudocode

(Assumes the input is a one-based array)

link : https://karthaus.nl/rdp/ [18]

Application

The algorithm is used for the processing of vector graphics and cartographic generalization. It does not always preserve the property of non-self-intersection for curves which has led to the development of variant algorithms[2].

The algorithm is widely used in robotics[3] 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 and Hart.

Complexity

The expected complexity of this algorithm can be described by the linear recurrence T(n) = 2T(​n⁄2) + O(n), which has the well-known solution (via the master theorem for divide-and-conquer recurrences) of T(n) ∈ Θ(n log n). However, the worst-case complexity is Θ(n2).

Other line simplification algorithms

Alternative algorithms for line simplification include:

  • Visvalingam–Whyatt

  • Reumann–Witkam

  • Opheim simplification

  • Lang simplification

  • Zhao-Saalfeld

Further reading

  • Urs Ramer, "An iterative procedure for the polygonal approximation of plane curves", Computer Graphics and Image Processing, 1(3), 244–256 (1972) doi:10.1016/S0146-664X(72)80017-0 [19]

  • David Douglas & Thomas Peucker, "Algorithms for the reduction of the number of points required to represent a digitized line or its caricature", The Canadian Cartographer 10(2), 112–122 (1973) doi:10.3138/FM57-6770-U75U-7727 [20]

  • John Hershberger & Jack Snoeyink, "Speeding Up the Douglas–Peucker Line-Simplification Algorithm", Proc 5th Symp on Data Handling, 134–143 (1992). UBC Tech Report TR-92-07 available at http://www.cs.ubc.ca/cgi-bin/tr/1992/TR-92-07 [21]

  • R.O. Duda and P.E. Hart, "Pattern classification and scene analysis", (1973), Wiley, New York (https://web.archive.org/web/20110715184521/http://rii.ricoh.com/~stork/DHS.html [22] )

  • Visvalingam, M; Whyatt, JD (1992). Line Generalisation by Repeated Elimination of the Smallest Area [23] (Technical report). Discussion Paper. Cartographic Information Systems Research Group (CISRG), The University of Hull. 10.

References

[1]
Citation Link//doi.org/10.1016%2Fj.imavis.2012.06.010Prasad, Dilip K.; Leung, Maylor K.H.; Quek, Chai; Cho, Siu-Yeung (2012). "A novel framework for making dominant point detection methods non-parametric". Image and Vision Computing. 30 (11): 843–859. doi:10.1016/j.imavis.2012.06.010.
Sep 19, 2019, 10:40 AM
[2]
Citation Link//doi.org/10.1109%2FSIBGRA.2003.1240992Wu, Shin-Ting; Marquez, Mercedes (2003). "A non-self-intersection Douglas-Peucker algorithm". 16th Brazilian Symposium on Computer Graphics and Image Processing (SIBGRAPI 2003). Sao Carlos, Brazil: IEEE. pp. 60–66. CiteSeerX 10.1.1.73.5773. doi:10.1109/SIBGRA.2003.1240992. ISBN 978-0-7695-2032-2.
Sep 19, 2019, 10:40 AM
[3]
Citation Linkasl.epfl.chNguyen, Viet; Gächter, Stefan; Martinelli, Agostino; Tomatis, Nicola; Siegwart, Roland (2007). A comparison of line extraction algorithms using 2D range data for indoor mobile robotics (PDF). Autonomous Robots. 23 (2). p. 97. doi:10.1007/s10514-007-9034-y. Archived from the original (PDF) on 2010-09-17. Cite uses deprecated parameter |deadurl= (help)
Sep 19, 2019, 10:40 AM
[4]
Citation Linkdoi.org10.1016/S0146-664X(72)80017-0
Sep 19, 2019, 10:40 AM
[5]
Citation Linkdoi.org10.3138/FM57-6770-U75U-7727
Sep 19, 2019, 10:40 AM
[6]
Citation Linkwww.cs.ubc.cahttp://www.cs.ubc.ca/cgi-bin/tr/1992/TR-92-07
Sep 19, 2019, 10:40 AM
[7]
Citation Linkweb.archive.orghttps://web.archive.org/web/20110715184521/http://rii.ricoh.com/~stork/DHS.html
Sep 19, 2019, 10:40 AM
[8]
Citation Linkhydra.hull.ac.ukLine Generalisation by Repeated Elimination of the Smallest Area
Sep 19, 2019, 10:40 AM
[9]
Citation Linkwww.boost.orgBoost.Geometry support Douglas–Peucker simplification algorithm
Sep 19, 2019, 10:40 AM
[10]
Citation Linkwww.codeproject.comImplementation of Ramer–Douglas–Peucker and many other simplification algorithms with open source licence in C++
Sep 19, 2019, 10:40 AM
[11]
Citation Linkidea.ed.ac.ukXSLT implementation of the algorithm for use with KML data.
Sep 19, 2019, 10:40 AM
[12]
Citation Linkwww.bdcc.co.ukYou can see the algorithm applied to a GPS log from a bike ride at the bottom of this page
Sep 19, 2019, 10:40 AM
[13]
Citation Linkkarthaus.nlInteractive visualization of the algorithm
Sep 19, 2019, 10:40 AM
[14]
Citation Linkfssnip.netImplementation in F#
Sep 19, 2019, 10:40 AM
[15]
Citation Linkgithub.comRuby gem implementation
Sep 19, 2019, 10:40 AM
[16]
Citation Linkgithub.comJTS, Java Topology Suite
Sep 19, 2019, 10:40 AM
[17]
Citation Linklocationtech.github.ioDouglas-Peucker algorithm
Sep 19, 2019, 10:40 AM
[18]
Citation Linkkarthaus.nlhttps://karthaus.nl/rdp/
Sep 19, 2019, 10:40 AM
[19]
Citation Linkdoi.org10.1016/S0146-664X(72)80017-0
Sep 19, 2019, 10:40 AM
[20]
Citation Linkdoi.org10.3138/FM57-6770-U75U-7727
Sep 19, 2019, 10:40 AM