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
python3 test.py
Links
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.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 040fd1636c38bedefda4d5e4b08267ad61e7f87b7c54bf8406b84d8aef7bd84b |
|
MD5 | f68a5cfb28156c09c7ffbb1db12759b8 |
|
BLAKE2b-256 | 0d9de5dd8c64f38ba40fd91bd97e59c6f2fcddadade8a070e49371147332bdf5 |
Hashes for pybind11_rdp-0.1.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3b317ba86d07a2f887597cc9607be4364e41c6463d0fbaa8f46692b89fa06eb4 |
|
MD5 | 42afefe77847894bcafd95c06dbbda3e |
|
BLAKE2b-256 | 4320fcbc1420aab85cb3088e821989fddf97af76965ee83892fbc45706f38c06 |
Hashes for pybind11_rdp-0.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 05de946ebb3ea1524f1cf76437576b567f9af103b0ab913333e94d5e5a6e2895 |
|
MD5 | a58e2bef9f5a42df5c59cf1d32e4b31e |
|
BLAKE2b-256 | 8dca1d241382cf8bd951895b3f60a14d92c4ffcc84b999d03028bb5af3c130fb |
Hashes for pybind11_rdp-0.1.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2237b61edf293dbd8618f90c0c8ef34204bb8e64337df4066073c80834214165 |
|
MD5 | b577023fccf5eab280b7663da0e8c95c |
|
BLAKE2b-256 | 3a71d8bb5d22f0781f61bd37648a9a56c07a2589089719313d17f55d5de8e704 |
Hashes for pybind11_rdp-0.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2671d4c2355184b64b8ffbc3dd3df6f70242b67486a755d69b8988c031a5a674 |
|
MD5 | 67752bb9e85dd1af8ffa130e9ad5bfef |
|
BLAKE2b-256 | cb60a260187dbc17fa1a50884ebf8bf0a7c21eb77c9e9882cda181471d80d3a1 |
Hashes for pybind11_rdp-0.1.0-cp38-cp38-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7cc333a4108c6aec4a34dcaf9be844517e13a187057c6d35f53b9ee0e8cf9b62 |
|
MD5 | c247534f37ecbd1cab20e52b48720822 |
|
BLAKE2b-256 | 5db67daaba3a9f50a5835dfd023eaf7aa23c1c70668962461dfb2a375a5a01ce |
Hashes for pybind11_rdp-0.1.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0390aa53d5988dfde0eefcddc809500389ab966fe1ca9bd0e7c66d46fd7f89f5 |
|
MD5 | 74311557eb66c85271a4be7e44570bbc |
|
BLAKE2b-256 | c3d46ce4358210b19eff098efa089e7ac21c68e48b022ee507c9cb5746977098 |
Hashes for pybind11_rdp-0.1.0-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3c1ff9780aa6a30ab6d33007a77af6845ce74f6362f779ac72c297f3f0e35c39 |
|
MD5 | ae02bbfc598469b5e4df7f93108f9fb2 |
|
BLAKE2b-256 | 699bc293ec60b418479c70017b314b7f44adae2f68b8ed8e54fedf85cf199485 |