Skip to main content

Module point_cloud_thin

Module point_cloud_thin 

Source
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 side cell_size and 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’s filters.sample and CloudCompare’s “subsample with octree”.
  • Random thinning (thin_random) uniformly draws target_count indices 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 no rand-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 within min_distance of it. The spatial hash uses cubic buckets of side min_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§

ThinPoint3
A 3D sample point used as input to point-cloud thinning operators.
ThinningStats
Summary statistics for a single thinning invocation.

Enums§

ThinningMethod
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_distance apart in 3D Euclidean distance.
thin_random
Random thinning: keep target_count points selected uniformly without replacement via a deterministic Fisher-Yates shuffle.
thin_with_stats
Dispatch ThinningMethod and return both the thinned point set and a ThinningStats summary.