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.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4cdf6eb05ee9c236899c5bce2c0fae99f539badfd063690a94d2e42a28ed5280 |
|
MD5 | 9e8840e53f0fbfa09d986c488a7c011a |
|
BLAKE2b-256 | f549739b98a22dc4cc47a3dd82bd6284a9d73bc63b665caa4d28eeda68b9a40c |
Hashes for pybind11_rdp-0.1.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a83dcd31156d13aab00141e57eaa0ed8efcff0e201676a9299bafc931e3a65a4 |
|
MD5 | f334e31c63192082ea1624c86d41f275 |
|
BLAKE2b-256 | 7822bcffee972580ff6c800df54c2133aef54b5f336b477f3f41cd5f9cc19803 |
Hashes for pybind11_rdp-0.1.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 324b7710d435f92bf181af3c008f918ebc056e03681df181160398e9857e2f8a |
|
MD5 | 09a66a9b81baac5b5b133db4d11f357a |
|
BLAKE2b-256 | 7a90fa18d3b60367e918f4f259975551558ca2911c4175932eb02360c04a1015 |
Hashes for pybind11_rdp-0.1.1-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3dc2c24b88b7e059865d2e844c9fcd9ba1dd8277e4c7c66201e41dc78021341e |
|
MD5 | 9047e8b258909c2c4b32997c2b55f490 |
|
BLAKE2b-256 | d017dea30d2dd3e5ca02ac4bef20a843310cb628dd4ef71a3b621921cbec3fbd |
Hashes for pybind11_rdp-0.1.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d9e747a999e9168483231614bb0ea65f6ba525052cac3545620e6147f46c2ce2 |
|
MD5 | 6c532899b4a30963671975f7f962483d |
|
BLAKE2b-256 | 775817f2c53b49e8b1ec27dd8c708d76d98e93b0223e41dc6d68cc3b6cc54f9f |
Hashes for pybind11_rdp-0.1.1-cp38-cp38-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0a4f196aceeaf77a6901be79a7aa1cc8c6e956753818da1d2ee0885201e57a8e |
|
MD5 | 189bd6318fe1f37560c8b995cac93444 |
|
BLAKE2b-256 | 4a6e5a7e1636a8181edec036adeb382bee3e6779dda288212cdf26ed56581263 |
Hashes for pybind11_rdp-0.1.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1bfeebdfc744aacb2c227f857c884b1052e9cd6be13a0f8c59c7ebc2104980ad |
|
MD5 | 748bc5bae4d38ac3b10f69b3423746a7 |
|
BLAKE2b-256 | b4fa3d0d3da5a462e5754c038e2b65cc4a0bf2753685ce28a7b09fdfe75d0473 |
Hashes for pybind11_rdp-0.1.1-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cc58566e29ea05b735e6f9fa61af9f06666248f7cfc66dc27586cbf0c48ee1a1 |
|
MD5 | 66463ff35031e59b4098d094a0594854 |
|
BLAKE2b-256 | a7086e29dfec5f1c5d8966caaa3e98c39fe8830caa3e5679b18205f1db28763d |