You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When we were working on a satellite image of one of the local area of Nepal, we had to simplify the obtained mask to feed into the GIS system. In order to simplify, we ended up using a very interesting yet simple algorithm, **Ramer-Douglas-Peucker algorithm** (also called **Douglas-Peucker algorithm**).
17
17
@@ -29,7 +29,7 @@ Here is a sample image and it's corresponding masks:
29
29
<figcaption>Fig 2. Masks of houses (left) and result after simplifying using RDP algorithm (right).</figcaption>
30
30
</figure>
31
31
32
-
# The Algorithm
32
+
##The Algorithm
33
33
In 1973, David H. Douglas and Thomas K. Peucker introduced an algorithm that produced a simplified polyline than the original in their paper: *“Algorithms for the reduction of the number of points required to represent a digitized line or its caricature”.* The algorithm generates a new curve similar to the original curve, but with fewer points.
34
34
35
35
The original paper defines the first point as ***anchor*** and last point as ***floater***. All the remaining points are examined to find the one with the greatest perpendicular distance between the point and the line joining anchor and floater. If the distance is less than the tolerance defined, then all points are terminated and the straight line segment represents the whole line. Otherwise, the point with greatest distance is set as a new floater. The algorithm recursively calls itself with anchor and floaters and finally merges it to give the simplified polyline.
@@ -40,7 +40,7 @@ There is this simple gif from [Mysid](https://en.wikipedia.org/wiki/User:Mysid)
40
40
41
41
In the worst case, this algorithm has a running time of $O(n^2)$ and in the best case, it has running time of $O(nlog n)$. [2](https://en.wikipedia.org/wiki/Ramer%E2%80%93Douglas%E2%80%93Peucker_algorithm)
42
42
43
-
# Code
43
+
##Code
44
44
45
45
```
46
46
def perpendicular_distance(line, point):
@@ -126,7 +126,7 @@ Co-Authors: [Shital Adhikari](https://shitaladhikari.github.io/) and [Anil Kumar
126
126
127
127
128
128
129
-
# Resources
129
+
##Resources
130
130
1. Douglas, D. H., & Peucker, T. K. (1973). Algorithms for the reduction of the number of points required to represent a digitized line or its caricature.
0 commit comments