Compute the geometric features associated with each point's neighborhood:
Project description
📌 Description
Python wrapper around C++ helper to compute, for each point in a 3D point cloud, local geometric features in parallel on CPU:
️List of computed features️
- linearity
- planarity
- scattering
- verticality (two formulations)
- normal_x
- normal_y
- normal_z
- length
- surface
- volume
- curvature
- optimal neighborhood size
The wrapper allows to compute feature in multiple fashions (on the fly subset of features a la jakteristics, an array of features or multiscale features...). Moreover, it offers basic interfaces to compute fast K-NN or Radius search on point clouds. The overall code is not intended to be DRY nor generic, it aims at providing efficient as possible implementations for some limited scopes and usages.
🧱 Installation
python -m pip install pgeof
or
python -m pip install git+https://github.com/drprojects/point_geometric_features
building from sources
pgeof depends on Eigen library, Taskflow, nanoflann and nanobind.
pgeof adhere to PEP 517 and use scikit-build-core as build backend. Build dependencies (nanobind, scikit-build-core...) are fetched at build time. C++ third party libraries are embedded as submodules.
# clone project
git clone --recurse-submodules https://github.com/drprojects/point_geometric_features.git
cd point_geometric_features
# build and install the package
python -m pip install .
🚀 Using Point Geometric Features
Here we summarize the very basics of pgeof
usage.
Users are invited to use help(pgeof)
for further details on parameters.
At its core pgeof
provides three functions to compute a set of features given a 3D point cloud and
some precomputed neighborhoods.
import pgeof
# Compute a set of 11 predefined features per points.
pgeof.compute_features(
xyz, # The point cloud. A numpy array of shape (n, 3).
nn, # CSR data structure see below.
nn_ptr, # CSR data structure see below.
k_min = 1 # Minimum number of neighbors to consider for features computation.
verbose = false # Basic verbose output, for debug purposes.
)
# Sequence of n scales feature computation.
pgeof.compute_features_multiscale(
...
k_scale # array of neighborhood size
)
# Feature computation with optimal neighborhood selection as exposed in Weinmann et al., 2015.
# return a set of 12 features per points (11 + the optimal neighborhood size)
pgeof.compute_features_optimal(
...
k_min = 1, # Minimum number of neighbors to consider for features computation.
k_step = 1, # Step size to take when searching for the optimal neighborhood
k_min_search = 1, # Minimum neighborhood size at which to start when searching for the optimal neighborhood size for each point. it should be >= to k_min parameter.
)
⚠️ Please note that for theses three functions the neighbors are expected in CSR format. This allows expressing neighborhoods of varying sizes with dense arrays (eg the output of a radius search).
We provide very tiny and specialized k-NN / radius-NN search routines.
They rely on nanoflann
C++ library and they should be faster and lighter than scipy
and sklearn
alternatives.
Here are some examples of how to easily compute and convert typical k-NN or radius-NN neighborhoods to CSR format (nn
and nn_ptr
are two flat uint32
arrays):
import pgeof
import numpy as np
# Generate a random synthetic point cloud and k-nearest neighbors
num_points = 10000
k = 20
xyz = np.random.rand(num_points, 3).astype("float32")
knn, _ = pgeof.knn_search(xyz, xyz, k)
# Converting k-nearest neighbors to CSR format
nn_ptr = np.arange(num_points + 1) * k
nn = knn.flatten()
# You may need to convert nn/nn_ptr to uint32 arrays
nn_ptr = nn_ptr.astype("uint32")
nn = nn.astype("uint32")
features = pgeof.compute_features(xyz, nn, nn_ptr)
import pgeof
import numpy as np
# Generate a random synthetic point cloud and k-nearest neighbors
num_points = 10000
radius = 0.2
k = 20
xyz = np.random.rand(num_points, 3).astype("float32")
knn, _ = pgeof.radius_search(xyz, xyz, radius, k)
# Converting radius neighbors to CSR format
nn_ptr = np.r_[0, (knn >= 0).sum(axis=1).cumsum()]
nn = knn[knn >= 0]
# You may need to convert nn/nn_ptr to uint32 arrays
...
At last and as a by product we also provide a function to compute a subset of features on the fly.
it is inspired by the Jakteristics
python package (while being less complete but faster).
the list of feature to compute is given as an array of EFeatureID
import pgeof
from pgeof import EFeatureID
import numpy as np
# Generate a random synthetic point cloud and k-nearest neighbors
num_points = 10000
radius = 0.2
k = 20
xyz = np.random.rand(num_points, 3)
features = pgeof.compute_features_selected(xyz, radius, k, [EFeatureID.Verticality])
Known limitations
Some functions only accept float
scalar types and uint32
index types and we avoid implicit cast / conversions.
This could be a limitation in some situations (double
coordinates point clouds or need for a big indices).
Some C++ function could be templated / to accept other type without conversion. For now, this feature is not enabled everywhere to reduce compilation time or enhance code readability but please let us know if you need this feature !
Normal are forced to be oriented in the Z half space.
Testing
Some basic tests and benchmarks are provided in the tests directory. Test could be run in a clean and reproducible environments via tox
(tox run
and tox run -e bench
).
💳 Credits
This implementation was largely inspired from Superpoint Graph. The main modifications here allow:
- parallel computation on all points' local neighborhoods, with neighborhoods of varying sizes
- more geometric features
- optimal neighborhood search from this paper
- some corrections on geometric features computation
Some heavy refactoring (port to nanobind, test, benchmarks), packaging, speed optimization, feature addition (NN search, on the fly feature computation...) were funded by:
Centre of Wildfire Research of Swansea University (UK) in collaboration with the Research Institute of Biodiversity (CSIC, Spain) and the Department of Mining Exploitation of the University of Oviedo (Spain).
Funding provided by the UK NERC project (NE/T001194/1):
'Advancing 3D Fuel Mapping for Wildfire Behaviour and Risk Mitigation Modelling'
and by the Spanish Knowledge Generation project (PID2021-126790NB-I00):
‘Advancing carbon emission estimations from wildfires applying artificial intelligence to 3D terrestrial point clouds’.
License
Point Geometric Features is licensed under the MIT License.
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
File details
Details for the file pgeof-0.1.0.tar.gz
.
File metadata
- Download URL: pgeof-0.1.0.tar.gz
- Upload date:
- Size: 69.0 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e065181e59f31935dbc451eded9e04d6f5d2148f64e428a7d91afe23da00188b |
|
MD5 | 46790728c1d4d452db23f8b6507c6ad9 |
|
BLAKE2b-256 | ff04587a352960a65e526ebebc9347cd38fff14f56332850c93ebe9c6225d36a |
Provenance
File details
Details for the file pgeof-0.1.0-cp312-cp312-win_amd64.whl
.
File metadata
- Download URL: pgeof-0.1.0-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 229.0 kB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bc78e62808954a0f63a291e3c1a8852bb8c5019a88f38a4ebf28e3dfb4f9b3c1 |
|
MD5 | 6409da530cea68adeeb72abd0cc68988 |
|
BLAKE2b-256 | 366888468cbbf998d4a6e02894454163c89604376155b21889a952bfb917afac |
Provenance
File details
Details for the file pgeof-0.1.0-cp312-cp312-musllinux_1_1_x86_64.whl
.
File metadata
- Download URL: pgeof-0.1.0-cp312-cp312-musllinux_1_1_x86_64.whl
- Upload date:
- Size: 562.1 kB
- Tags: CPython 3.12, musllinux: musl 1.1+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 386f87c17bce890543712d9146671310bb6b32506ed22c5ff1680333045bfda9 |
|
MD5 | cccc9425552169b7b893d38b56aceb6e |
|
BLAKE2b-256 | 2287d78c4aaa31863c239fad7ef04afefbfaa4b989a86b28b3ed165db11536df |
Provenance
File details
Details for the file pgeof-0.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: pgeof-0.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 252.5 kB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 58b471de0d1ae21e6b7c3e5ac1441efbf4ebaafd04ecedfb54a104a89dfd78f3 |
|
MD5 | 707d839270bad26a06e5f69fe6189253 |
|
BLAKE2b-256 | 61937c5f80e34475e51709d55cc68d1d983d65e465dd36ae26f948d26f4d0045 |
Provenance
File details
Details for the file pgeof-0.1.0-cp312-cp312-macosx_10_14_x86_64.whl
.
File metadata
- Download URL: pgeof-0.1.0-cp312-cp312-macosx_10_14_x86_64.whl
- Upload date:
- Size: 195.0 kB
- Tags: CPython 3.12, macOS 10.14+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d3cc68b9c2e2d12e19ee561eb27eb6bb24d0d9cc14c628915f08ad7cee8ef78f |
|
MD5 | df51426abc959637137704eeedcbc82a |
|
BLAKE2b-256 | 91e2ac996296884f59c9f04f0663ffe6136817c0ebd5ac6d46849d92de3a1e01 |
Provenance
File details
Details for the file pgeof-0.1.0-cp311-cp311-win_amd64.whl
.
File metadata
- Download URL: pgeof-0.1.0-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 229.6 kB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ef48c45a0249da8fff2008afd506512cfd07d04ee8d5da1ba66524dad97bf5de |
|
MD5 | d9d1e3460a118ad6e085af7af8da8f47 |
|
BLAKE2b-256 | a5fccbb7cff4ee661b205dc58b81ff61a50fbca0b9924dad732f9d9061d17b5b |
Provenance
File details
Details for the file pgeof-0.1.0-cp311-cp311-musllinux_1_1_x86_64.whl
.
File metadata
- Download URL: pgeof-0.1.0-cp311-cp311-musllinux_1_1_x86_64.whl
- Upload date:
- Size: 563.7 kB
- Tags: CPython 3.11, musllinux: musl 1.1+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6e244c23e7277b6918a105c97240c9cbb5b64ebecc686f021f7c4efd9777d1f3 |
|
MD5 | 8e2dfaec66887a88af6fd469018f773e |
|
BLAKE2b-256 | a6b8aa260461d0c8c040f4d0ac42eb52fe70e0bab320bb0d412ad5f45b1b3bb4 |
Provenance
File details
Details for the file pgeof-0.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: pgeof-0.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 253.5 kB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6ab93230f4762d9a65d8d46123945f24166fd0c302d9886be0082be735eaef37 |
|
MD5 | c53b310819245dba2539cbbf74562e4f |
|
BLAKE2b-256 | fa11fe20ff962b4f546a295ef8cc81ac1cd0f1b48dc3ca06c4dc396559e1d9e1 |
Provenance
File details
Details for the file pgeof-0.1.0-cp311-cp311-macosx_10_14_x86_64.whl
.
File metadata
- Download URL: pgeof-0.1.0-cp311-cp311-macosx_10_14_x86_64.whl
- Upload date:
- Size: 195.6 kB
- Tags: CPython 3.11, macOS 10.14+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 408e30484777ddfedbf0c7846ef5d3b2e73338fcb11384a48431237b09dd7136 |
|
MD5 | 9764f762e252a066d9a2383dd69a1896 |
|
BLAKE2b-256 | ee6f7336d3f126160d94235d9938467b1024ac4c40e9e30ed490a8f341d6ea5d |
Provenance
File details
Details for the file pgeof-0.1.0-cp310-cp310-win_amd64.whl
.
File metadata
- Download URL: pgeof-0.1.0-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 229.8 kB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6c610dc5a16292d8047aa169971753c817489a0d93806d318abb818d70a87055 |
|
MD5 | eb739bdd8d1d88ac7b07996cccb2e063 |
|
BLAKE2b-256 | 6292511fd39dff813bf2a752b221bb20f303531c4f33341094602d775de5c2db |
Provenance
File details
Details for the file pgeof-0.1.0-cp310-cp310-musllinux_1_1_x86_64.whl
.
File metadata
- Download URL: pgeof-0.1.0-cp310-cp310-musllinux_1_1_x86_64.whl
- Upload date:
- Size: 563.8 kB
- Tags: CPython 3.10, musllinux: musl 1.1+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 839247cf0bccde25a26260911ecdcb8df27a4e2c9991548b2a2a5a82af30ee2a |
|
MD5 | 230e3004967653a2fb5921e78419a310 |
|
BLAKE2b-256 | 350923d407769338b1f0d6c82f8eb4d2aa846bf473f736469a234dfcb058a3ab |
Provenance
File details
Details for the file pgeof-0.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: pgeof-0.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 253.7 kB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 25b993affa3c83687dcbfa547fd29a0e3e245e60425a119792f813c368f9fef2 |
|
MD5 | 7032bcb262017ab31cd712e85885c015 |
|
BLAKE2b-256 | eb860e48b72f2060d5ad038d810eeb81142c1b4e9516cd6ef6003834e2b6f9af |
Provenance
File details
Details for the file pgeof-0.1.0-cp310-cp310-macosx_10_14_x86_64.whl
.
File metadata
- Download URL: pgeof-0.1.0-cp310-cp310-macosx_10_14_x86_64.whl
- Upload date:
- Size: 195.8 kB
- Tags: CPython 3.10, macOS 10.14+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f37f94866fa73dd1e7efe48ce2a847847c474209f0e4ed26e997519ed55a7d9b |
|
MD5 | baab37644cd737665817c795c0fbfed2 |
|
BLAKE2b-256 | a9bbac5d504f8acebcb35bb0f7216af8d24de50432f60234a96daaa92f7fdd86 |
Provenance
File details
Details for the file pgeof-0.1.0-cp39-cp39-win_amd64.whl
.
File metadata
- Download URL: pgeof-0.1.0-cp39-cp39-win_amd64.whl
- Upload date:
- Size: 230.2 kB
- Tags: CPython 3.9, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b1f86aec03fe9c6d1e057634483fc5e21476f634c7b274d2569e458562a4ae8f |
|
MD5 | 49e1d0f75c17a8ef7c5d2769604032b5 |
|
BLAKE2b-256 | afdc77d053f86722d040916d860881c3c83d7eec1b80c17d345db8197667cc6b |
Provenance
File details
Details for the file pgeof-0.1.0-cp39-cp39-musllinux_1_1_x86_64.whl
.
File metadata
- Download URL: pgeof-0.1.0-cp39-cp39-musllinux_1_1_x86_64.whl
- Upload date:
- Size: 564.1 kB
- Tags: CPython 3.9, musllinux: musl 1.1+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ade6a90b7811934653f5f862d41b9143565d814413d9b6ad352ba80870eac038 |
|
MD5 | 4f0acd87d255b3e859500134e341bd89 |
|
BLAKE2b-256 | 78ea31871a9ff57750f215d9392566606a62cf9d75311e65b91d62fc38f50c7f |
Provenance
File details
Details for the file pgeof-0.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: pgeof-0.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 253.9 kB
- Tags: CPython 3.9, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | afcd4bf0dee652a5bf29f4b8c4b1d976a273a15f2854f4eaf58fff53c0f5952e |
|
MD5 | 8f0add7848534bd797e077d2ecc4f62b |
|
BLAKE2b-256 | 2ca162116a1d8799fac7ec85bd549f5c060a5ec48384c07e59af96cc1a766b40 |
Provenance
File details
Details for the file pgeof-0.1.0-cp39-cp39-macosx_10_14_x86_64.whl
.
File metadata
- Download URL: pgeof-0.1.0-cp39-cp39-macosx_10_14_x86_64.whl
- Upload date:
- Size: 195.9 kB
- Tags: CPython 3.9, macOS 10.14+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5e57dd3bbac6a863ff005dcc2c91c2abdcdf584aa2f75719351911977297663a |
|
MD5 | 174bac64bbf0a081f626c4e244b9174f |
|
BLAKE2b-256 | 74c6834b01dedc7062f65e29ff9737421627982924dd044a414fea57cbefb40a |