C++/pybind11/NumPy implementation of the Ramer-Douglas-Peucker algorithm (Ramer 1972; Douglas and Peucker 1973) for 2D and 3D data.
Project description
Ramer-Douglas-Peucker Algorithm (c++ binding for python via pybind11)
A speed up (~8000x) version of python version of rdp.
C++/pybind11/NumPy implementation of the Ramer-Douglas-Peucker algorithm (Ramer 1972; Douglas and Peucker 1973) for 2D and 3D data.
The Ramer-Douglas-Peucker algorithm is an algorithm for reducing the number of points in a curve that is approximated by a series of points.
Installation
via pip
pip install pybind11-rdp
from source
git clone --recursive https://github.com/cubao/pybind11-rdp
pip install ./pybind11-rdp
Or
pip install git+https://github.com/cubao/pybind11-rdp.git
(you can build wheels for later reuse by pip wheel git+https://github.com/cubao/pybind11-rdp.git
)
Usage
Test installation: python -c 'from pybind11_rdp import rdp; print(rdp([[1, 1], [2, 2], [3, 3], [4, 4]]))'
Simple pythonic interface:
from pybind11_rdp import rdp
rdp([[1, 1], [2, 2], [3, 3], [4, 4]])
[[1, 1], [4, 4]]
With epsilon=0.5:
rdp([[1, 1], [1, 1.1], [2, 2]], epsilon=0.5)
[[1.0, 1.0], [2.0, 2.0]]
Numpy interface:
import numpy as np
from pybind11_rdp import rdp
rdp(np.array([1, 1, 2, 2, 3, 3, 4, 4]).reshape(4, 2))
array([[1, 1],
[4, 4]])
Tests
make python_install
make python_test
Notice
As https://github.com/fhirschmann/rdp/issues/13 points out, pdist
in rdp
is WRONGLY Point-to-Line distance.
We use Point-to-LineSegment distance.
from rdp import rdp
print(rdp([[0, 0], [10, 0.1], [1, 0]], epsilon=1.0)) # wrong
# [[0.0, 0.0],
# [1.0, 0.0]]
from pybind11_rdp import rdp
print(rdp([[0, 0], [10, 0.1], [1, 0]], epsilon=1.0)) # correct
# [[ 0. 0. ]
# [10. 0.1]
# [ 1. 0. ]]
References
Douglas, David H, and Thomas K Peucker. 1973. “Algorithms for the Reduction of the Number of Points Required to Represent a Digitized Line or Its Caricature.” Cartographica: The International Journal for Geographic Information and Geovisualization 10 (2): 112–122.
Ramer, Urs. 1972. “An Iterative Procedure for the Polygonal Approximation of Plane Curves.” Computer Graphics and Image Processing 1 (3): 244–256.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for pybind11_rdp-0.1.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 64058eac214e63cb1b73ba45ff0a24f2bf50abf2bcaef6e931617ee2e2efb7e4 |
|
MD5 | f86bbd2ee4dcec66613411174c37c12c |
|
BLAKE2b-256 | 8b354242f04db47df2fb736657745934e7a8de3ebf4878adb3e9a5d358565935 |
Hashes for pybind11_rdp-0.1.2-cp310-cp310-macosx_12_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 16757815c738b63f4e0a512448bd91ad73b988572c5af3f444a9f3a084dbabdc |
|
MD5 | 741286be0ad54225c6d1c0aa28e76ca2 |
|
BLAKE2b-256 | 691ce2915d8e21620fa27d152fa8099670d6e7f979a30e13a3846677279e27f2 |
Hashes for pybind11_rdp-0.1.2-cp310-cp310-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 35796ab860abaca116ab11d5f04bcb1f881d7217e9a85be2e8301304b75b174b |
|
MD5 | d2e8648b04737b3ff781eb0d4abc19cb |
|
BLAKE2b-256 | e1659106ecbcfe556f04d51fed3707f5c83291bf47812c0641c0d97216c7d431 |
Hashes for pybind11_rdp-0.1.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9dec58313e107a16748dcdbdf1334763768208d52893e6e5f09817b4698e76ba |
|
MD5 | 10e08faff7c70536ad117896fe146d3f |
|
BLAKE2b-256 | 362db0ae20379f74c791057b952678c160e5533f53142d7a86680c55279eaa81 |
Hashes for pybind11_rdp-0.1.2-cp39-cp39-macosx_12_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3d68cb25582df52f4d6ee45e2820a3f03b8408c45dd07ceff3b85d2eb031f1e9 |
|
MD5 | aed5e1e663f86de7db459f8d54ba5045 |
|
BLAKE2b-256 | 454e3f0c5c4d1732b4cc0fa6d1a57500b26d68413806f047f4f27f0d08f50f05 |
Hashes for pybind11_rdp-0.1.2-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4252937f6e6d0474e07050d1c0f1ec30c6dfa7d648a74c3ed8c489b296a45325 |
|
MD5 | eaa634a3cbfc27698f59341ad4ac55fe |
|
BLAKE2b-256 | 19cdcbdd1ed319769b546f318e000fe8000cb25beee98b404978e4434d1b2c53 |
Hashes for pybind11_rdp-0.1.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1d7999315cfe7eb8b4d2c3beb287519f29c470c80ebfa2d92acd465e2d07c0e1 |
|
MD5 | dcf791d337914ef4b3f30c59dec6761e |
|
BLAKE2b-256 | 590c3ed4841e3886802778d30d74d0abac61a6ec007e2aac90a0d4b17b2d3efc |
Hashes for pybind11_rdp-0.1.2-cp38-cp38-macosx_12_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 16cf473a96bb53fbf8e60f6e788f84295b95906700c4f1bc7caa7fb73a495a7d |
|
MD5 | 8a6b4ce533a3691da9a4391a6468cc5c |
|
BLAKE2b-256 | d921accf1f87c3e51b89f655d97525ecadd42b16c202310fd1286a5c58b4cc17 |
Hashes for pybind11_rdp-0.1.2-cp38-cp38-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 065301b2a25c12c9c741178abbcf42a21c8157cbc6203a5a548a7ce1eaaf4deb |
|
MD5 | b210429538a60b524da98aaad87c1d5d |
|
BLAKE2b-256 | 48422d3a92d911c4d699a5ed2bb0eb8fd9ca7e14a3df1b2d36449e3887c55b92 |
Hashes for pybind11_rdp-0.1.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a2c6f9e1982e405e4b5e998db6f684f1d1abe124c0db76bc54a7e50bc392a182 |
|
MD5 | 52e2f2681abfdda14cca97babbf10935 |
|
BLAKE2b-256 | c19e04a15dd1d261a2093513ee60281643116ac35f26c173eede09437bbff213 |
Hashes for pybind11_rdp-0.1.2-cp37-cp37m-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | de13670b5a770998f9288bdbbd318826910e651428bcc421a815bb7dc40a90e1 |
|
MD5 | acf9415bd047aa5d5a51465cff3efcf4 |
|
BLAKE2b-256 | b9255c88b1777be006a443b20f638020003f7dd6a0c19de644bccad3b622638a |
Hashes for pybind11_rdp-0.1.2-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f8f02cc21628523c51537f77c2c4e1e4cb26d75f24c5884f477e187e51f52322 |
|
MD5 | 55d67337697a09dcf28a4c626e93112e |
|
BLAKE2b-256 | 123003e158c4fcdc2b7f532da1035b75d2374a01319c0e5b773cfd9b5dec02df |
Hashes for pybind11_rdp-0.1.2-cp36-cp36m-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9577092a14e373a8e897959ffbd32e248b6161ad7e7922a8cf635f5115e4a985 |
|
MD5 | c08626a2b1a35118009a7c34ffb2e802 |
|
BLAKE2b-256 | d8844f466ebcf1c0861b6e902173d72fac9aae5c34488bd387dccdb527fd66c1 |