Expand description
Point-cloud thinning algorithms: grid (voxel), random (LCG), Poisson disk.
Point-cloud thinning is the task of reducing the cardinality of a 3D point set while preserving some structural property of the cloud. Three classical strategies are provided here:
- Grid (voxel) thinning (
thin_grid) partitions space into cubic voxels of sidecell_sizeand keeps the first point that falls into each voxel (in input order). This produces a roughly uniform sub-sample at the resolution of the voxel grid and is the standard approach used by PDAL’sfilters.sampleand CloudCompare’s “subsample with octree”. - Random thinning (
thin_random) uniformly drawstarget_countindices without replacement via a deterministic Fisher-Yates shuffle. The shuffle is driven by a linear congruential generator (LCG) using Knuth’s MMIX constants — this satisfies the project policy of norand-crate dependency while remaining reproducible across runs and platforms. - Poisson-disk thinning (
thin_poisson_disk) implements Bridson’s spatial-hash dart-throwing in 3D: every candidate point is accepted only if no previously kept point lies withinmin_distanceof it. The spatial hash uses cubic buckets of sidemin_distance, so each acceptance test examines at most the 27 neighbouring buckets — giving expected O(N) runtime, an order of magnitude faster than a naive O(N^2) sweep.
All three operators are deterministic functions of their inputs (the random
and Poisson-disk variants additionally take a seed), preserve input order
in their output and return owned Vec<ThinPoint3> so the caller may freely
mutate the result. Thinning statistics (ThinningStats) can be obtained
in one call via thin_with_stats.
§Examples
use oxigdal_algorithms::raster::{ThinPoint3, ThinningMethod, thin_with_stats};
let points = vec![
ThinPoint3::new(0.0, 0.0, 0.0),
ThinPoint3::new(0.1, 0.2, 0.3),
ThinPoint3::new(5.0, 5.0, 5.0),
];
let (kept, stats) = thin_with_stats(
&points,
ThinningMethod::Grid { cell_size: 1.0 },
);
assert_eq!(stats.input_count, 3);
assert_eq!(stats.kept_count, kept.len());Structs§
- Thin
Point3 - A 3D sample point used as input to point-cloud thinning operators.
- Thinning
Stats - Summary statistics for a single thinning invocation.
Enums§
- Thinning
Method - Selection of thinning algorithm and its parameters.
Functions§
- thin_
grid - Grid (voxel) thinning: keep one point per cubic voxel of side
cell_size. - thin_
poisson_ disk - Poisson-disk thinning: keep a maximal greedy subset such that every pair
of kept points is at least
min_distanceapart in 3D Euclidean distance. - thin_
random - Random thinning: keep
target_countpoints selected uniformly without replacement via a deterministic Fisher-Yates shuffle. - thin_
with_ stats - Dispatch
ThinningMethodand return both the thinned point set and aThinningStatssummary.