Skip to main content

High-performance proportional sampling from point cloud clusters with geometric size measures and sampling measures.

Project description

GASP: Geometric Analysis and Sampling Package

High-performance proportional sampling from point cloud clusters with geometric size measures and sampling measures.

Installation

pip install gasp-python

Features

Proportional Cluster Sampling

Sample from multiple point cloud clusters with automatic proportional allocation based on geometric size measures:

from gasp import sample_from_clusters

# Sample 1000 points proportionally from clusters
# Each cluster gets samples proportional to its convex hull volume
sampled = sample_from_clusters(
    directory="./my_clusters",  # Directory with .npy files
    total_samples=1000,
    size_measure="hull_volume",
    sampling_method="centroid_fps",
    seed=42
)

# Returns: {cluster_name: sampled_points_array, ...}
for name, points in sampled.items():
    print(f"{name}: sampled {len(points)} points")

Geometric Size Measures

  • bbox_volume - Axis-aligned bounding box hypervolume
  • hull_volume - Convex hull hypervolume
  • covariance_volume - Covariance determinant (ellipsoid proxy)
  • mean_dispersion - Mean pairwise Euclidean distance

Sampling Methods

Multiple strategies for representative point selection within each cluster:

  • uniform - Pure random sampling
  • centroid_uniform - Guarantees centroid + random
  • centroid_fps - Farthest point sampling
  • centroid_kmedoids - K-medoids clustering
  • centroid_voxel - Voxel grid sampling
  • centroid_stratified - Stratified sampling

Grid Search

Test multiple configurations:

from gasp import grid_search_sample_from_clusters

results = grid_search_sample_from_clusters(
    directory="./my_clusters",
    total_samples=1000,
    size_measures=["bbox_volume", "hull_volume"],
    sampling_methods=["uniform", "centroid_fps"],
    seed=42
)

# Access specific configuration
best_result = results[("hull_volume", "centroid_fps")]

Direct Point Cloud Operations

You can also use the low-level functions directly:

import numpy as np
from gasp import bbox_volume, hull_volume, sample_centroid_fps

# Single point cloud
points = np.random.randn(1000, 3)

# Compute geometric measures
volume = bbox_volume(points)
hull_vol = hull_volume(points)

# Sample representative points
indices = sample_centroid_fps(points, count=100, seed=42)
sampled = points[indices]

How It Works

  1. Load clusters: Reads all .npy files from a directory
  2. Compute sizes: Measures each cluster using the specified size measure
  3. Proportional allocation: Distributes N samples across clusters proportionally (minimum 1 per cluster)
  4. Sample points: Uses the specified sampling method within each cluster

Performance

  • Fast: Rust core for high-performance computation
  • Flexible: Works with Python lists or NumPy arrays
  • N-Dimensional: Supports 2D and 3D. Work ongoing for N-dim support.
  • Robust: Handles edge cases (empty clusters, degenerate geometries)

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

gasp_python-0.0.3.tar.gz (26.1 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

gasp_python-0.0.3-cp39-abi3-win_amd64.whl (231.3 kB view details)

Uploaded CPython 3.9+Windows x86-64

gasp_python-0.0.3-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (409.6 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ x86-64

gasp_python-0.0.3-cp39-abi3-macosx_11_0_arm64.whl (333.1 kB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

gasp_python-0.0.3-cp39-abi3-macosx_10_12_x86_64.whl (351.4 kB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

Details for the file gasp_python-0.0.3.tar.gz.

File metadata

  • Download URL: gasp_python-0.0.3.tar.gz
  • Upload date:
  • Size: 26.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.11 {"installer":{"name":"uv","version":"0.9.11"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for gasp_python-0.0.3.tar.gz
Algorithm Hash digest
SHA256 33569d09a13c3a6b9d76de58083e0739a9a250d27f2e659cdfec610b37feb72d
MD5 5ae6b3e5a7c1cbdd2f3a69980e0fa6e4
BLAKE2b-256 85c491cdf1d54f0b9d74d350d812fadbd880393cecfe3a7790d9012d2fbf3824

See more details on using hashes here.

File details

Details for the file gasp_python-0.0.3-cp39-abi3-win_amd64.whl.

File metadata

  • Download URL: gasp_python-0.0.3-cp39-abi3-win_amd64.whl
  • Upload date:
  • Size: 231.3 kB
  • Tags: CPython 3.9+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.11 {"installer":{"name":"uv","version":"0.9.11"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for gasp_python-0.0.3-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 a720bd2a16b06a9144b84d79016e49fdc4d670729a0d5902c51b6a2a2e96f5a6
MD5 8712104168d6c722bed174b247a8ec42
BLAKE2b-256 8320dd51551b157c59f01a26e5a0e56e0c6d818d55bc39c5b20bbb16dfa7d587

See more details on using hashes here.

File details

Details for the file gasp_python-0.0.3-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

  • Download URL: gasp_python-0.0.3-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 409.6 kB
  • Tags: CPython 3.9+, manylinux: glibc 2.17+ x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.11 {"installer":{"name":"uv","version":"0.9.11"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for gasp_python-0.0.3-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 bed2d3ba84c3c8b379df85ab4d458b73146926b7393ef7cd7dc8a5dcdc972544
MD5 046d0e276ee31e1eef5b841546d9f9b8
BLAKE2b-256 40321c1f0db4a8f6a144e4f2e51e12c7969e10d58c64289fe74419d22722787d

See more details on using hashes here.

File details

Details for the file gasp_python-0.0.3-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

  • Download URL: gasp_python-0.0.3-cp39-abi3-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 333.1 kB
  • Tags: CPython 3.9+, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.11 {"installer":{"name":"uv","version":"0.9.11"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for gasp_python-0.0.3-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 35fddddfa29d22aeb17f7a8028fffac4048972622d8002f10c75cbbe13780c20
MD5 5ed9bbb9b5b78ba95d52f2e25a2b232c
BLAKE2b-256 1c8b98182781cfa3c09d1247202a6298dfc09771c79b908d2f63dddfca70ddbc

See more details on using hashes here.

File details

Details for the file gasp_python-0.0.3-cp39-abi3-macosx_10_12_x86_64.whl.

File metadata

  • Download URL: gasp_python-0.0.3-cp39-abi3-macosx_10_12_x86_64.whl
  • Upload date:
  • Size: 351.4 kB
  • Tags: CPython 3.9+, macOS 10.12+ x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.11 {"installer":{"name":"uv","version":"0.9.11"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for gasp_python-0.0.3-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 d4d230c73814fb94f43e583a4002abfb48d92faf5ab30494d41b4283b6a92e0c
MD5 8e83662b98861d82256de971fa2c3d67
BLAKE2b-256 ad0a1d800f4632280a215a8cf6e2e7555073458ea21853a97c1d054fba321222

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page