A very fast 2D concave hull algorithm
Project description
concave_hull
A very fast 2D concave hull algorithm.
Credits goes to:
Install
via pip
pip install concave_hull
from source
git clone --recursive https://github.com/cubao/concave_hull
pip install ./concave_hull
Or
pip install git+https://github.com/cubao/concave_hull.git
(you can build wheels for later reuse by pip wheel git+https://github.com/cubao/concave_hull.git
)
Usage
Signature:
concave_hull_indexes(
points: numpy.ndarray[numpy.float64[m, 2]],
*,
convex_hull_indexes: numpy.ndarray[numpy.int32[m, 1]],
concavity: float = 2.0,
length_threshold: float = 0.0,
) -> numpy.ndarray[numpy.int32[m, 1]]
concavity
is a relative measure of concavity. 1 results in a relatively detailed shape, Infinity results in a convex hull. You can use values lower than 1, but they can produce pretty crazy shapes.lengthThreshold
: when a segment length is under this threshold, it stops being considered for further detalization. Higher values result in simpler shapes.
(document from https://github.com/mapbox/concaveman)
Example (see full code in test.py
):
from concave_hull import concave_hull_indexes
idxes = concave_hull_indexes(
points[:, :2], # it's 2D concave hull, points should be N-by-2 numpy array
convex_hull_indexes=convex_hull.vertices.astype(np.int32), # can be calculated by scipy
length_threshold=50,
)
# you can get coordinates by `points[idxes]`
Tests
python3 test.py
python3 tests/test_basic.py
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
concave_hull-0.0.2.tar.gz
(2.9 MB
view hashes)
Built Distributions
Close
Hashes for concave_hull-0.0.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 124ae7b965a00656e649ef7294b134f4c6b04ffc947d17a0dae8648d205fd6a8 |
|
MD5 | 4a347e94e49b0e3647371fc3843a5b31 |
|
BLAKE2b-256 | 957c87297dff2b66dc3b44b68e46e5be098a1c9394bb94894d8c659e5e62f436 |
Close
Hashes for concave_hull-0.0.2-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 225ca52e118b0782a34d87b3b91792531faed53b507b6e4308e81c8f11b94598 |
|
MD5 | 04b6f5d11feaedee4ad78482e63a6253 |
|
BLAKE2b-256 | e64bcb9aa61ccfe6f1092580b23cfddc6b534347ae7505f53645e018dd7a8426 |
Close
Hashes for concave_hull-0.0.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7f97648d9362ebf03f994de89a4089bc0ee42b9c8b48477e20a9d785cb5e6ed1 |
|
MD5 | 930478fa938dea351bdbfddd43c8eb1d |
|
BLAKE2b-256 | b5a71c7623fea9bba606e8923be36e186b146d78824e51c49c627bdc8547220d |
Close
Hashes for concave_hull-0.0.2-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6a0d3c8f291716d16933fa6003015f5befcc66606b15cbe8d701057082a373ca |
|
MD5 | 7d29ca45c3bcc32f8fe8b36484c74eee |
|
BLAKE2b-256 | 4649e253287d1d6d8e40961c8910cae6304b95bb3c78f9c81e0e7398fc05e272 |
Close
Hashes for concave_hull-0.0.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dfb43049ef0d689b4d0894014b4969cf1a6c56a93cdb7409ae9fe1e719387169 |
|
MD5 | 68e38d15cf41335426003d34ad762577 |
|
BLAKE2b-256 | 6bcdcdba1625a9213dec0a51132abab2e11959788375db446028f6663ff993ae |
Close
Hashes for concave_hull-0.0.2-cp38-cp38-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6d1d8d060f8bae10f6c8519b5b055cd742bb1b56fc4d2569eda377daeef78b0e |
|
MD5 | 6cbb14ef19db74c9376beab2e90b0fb3 |
|
BLAKE2b-256 | 13327418af303f42141ab3f565a2b4da20eed7cf8f55c1d1865c78b6256fbc56 |
Close
Hashes for concave_hull-0.0.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 74453af529bb25306c85099dd522f6d099e47ee5ea7c442d06938bbb5155faab |
|
MD5 | 76d32815c952787d7e1e231832ecc181 |
|
BLAKE2b-256 | ea63bb3ceca6f65c8de325e5a701d406c8800ec1e2a1cbfa388e462aa9d7cb7d |
Close
Hashes for concave_hull-0.0.2-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 68b14f62c408614e63aceb7ef6b9e0c42915603a605a1e963cab8e926b4185ba |
|
MD5 | f51d2e3b7cb547381372c978d1efe50c |
|
BLAKE2b-256 | d9c8fdb0f3a6137d65ca72b86430f0c6772199fffab386d9bc149e47ba076d94 |