High-precision 3D geometric centroid computation through voxelization
Project description
Voxel Centroid
High-precision 3D geometric centroid computation through voxelization
Compute the geometric centroid (center of mass) of 3D objects from point clouds with subpixel accuracy. Works with concave shapes, cavities, and noisy data.
Features
- 🎯 Subpixel accuracy - Error < 0.01% on test shapes
- ⚡ High performance - 50,000 points in 0.05 seconds
- 📦 Multi-format support - PLY, STL, OBJ, XYZ, PCD, LAS, NPY
- 🛡️ Noise robust - Stable with up to 10% noise
- 🔧 5 operation modes - Balance accuracy vs speed
- 🚀 Production ready - Thoroughly tested
Installation
pip install voxel-centroid
For full format support:
pip install voxel-centroid[full]
Quick Start
from voxel_centroid import VoxelCentroid, VoxelConfig
import numpy as np
# Load or generate point cloud
points = np.random.randn(10000, 3)
# Configure algorithm
config = VoxelConfig(resolution=150, mode='standard')
# Compute centroid
centroid = VoxelCentroid(config).fit(points)
print(f"Centroid: {centroid}")
Operation Modes
| Mode | Accuracy | Speed | Use Case |
|---|---|---|---|
standard |
0.7% | 0.08s | General purpose |
subpixel |
0.01% | 0.31s | Medical, aerospace |
adaptive |
0.7% | 0.14s | Non-uniform data |
ensemble |
0.3% | 0.50s | Critical calculations |
iterative |
0.7% | 1.92s | Multi-component objects |
Supported Formats
| Format | Extension | Requires |
|---|---|---|
| NumPy | .npy, .npz | None |
| Text | .xyz, .txt, .csv | None |
| PLY/STL/OBJ | .ply, .stl, .obj | trimesh or open3d |
| PCD | .pcd | open3d |
| LiDAR | .las, .laz | laspy |
Advanced Usage
Loading External Data
from voxel_centroid import DataLoader
points = DataLoader.load_from_file("model.ply")
points = DataLoader.load_from_url("https://example.com/cloud.xyz")
High-Precision Mode
config = VoxelConfig(
resolution=150,
mode='subpixel',
fill_holes=True,
subpixel_sigma=0.5
)
centroid = VoxelCentroid(config).fit(points)
Custom Configuration
config = VoxelConfig(
resolution=200,
mode='ensemble',
ensemble_resolutions=[150, 175, 200],
fill_holes=True,
verbose=True
)
Performance Benchmarks
| Points | Standard | Subpixel | Adaptive |
|---|---|---|---|
| 1,000 | 0.033s | 0.180s | 0.085s |
| 10,000 | 0.059s | 0.154s | 0.083s |
| 50,000 | 0.056s | 0.171s | 0.102s |
Accuracy Results
| Shape | Standard | Subpixel |
|---|---|---|
| Cube | 0.68% | 0.01% |
| Sphere | 0.34% | 0.01% |
| Complex Drop | 0.42% | 0.01% |
Use Cases
- 🏭 Industrial Quality Control - Centroid verification for castings
- 🏥 Medical Imaging - Tumor center detection in CT/MRI
- 🗺️ Geology - LiDAR data analysis for mineral deposits
- 🤖 Robotics - Object grasping and manipulation
- 🖨️ 3D Printing - Model positioning optimization
Testing
Run the test suite:
pytest tests/
Run benchmark:
python -m voxel_centroid.benchmark
License
MIT License - see LICENSE file.
Citation
If you use this library in academic work, please cite:
@software{voxel_centroid_2026,
author = {SkyGliderus},
title = {Voxel Centroid: High-Precision 3D Geometric Centroid Computation},
year = {2026},
url = {https://github.com/SkyGliderus/voxel-centroid}
}
Contributing
Contributions welcome! Please:
- Fork the repository
- Create a feature branch
- Add tests for new features
- Submit a pull request
Contact
- Author: SkyGliderus
- Email: skygliderus@gmail.com
- GitHub: @SkyGliderus
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file voxel_centroid-1.0.0-py3-none-any.whl.
File metadata
- Download URL: voxel_centroid-1.0.0-py3-none-any.whl
- Upload date:
- Size: 12.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d37959eb403ec098247d996e8795e9e1ed8545f990ee40a4ad355193a7fadc0f
|
|
| MD5 |
46075d0f4a50c97796520fe02a7a8d47
|
|
| BLAKE2b-256 |
0bc7b7bcbb30bfe3eca44a460d499e757fb74de7700c0c3cacb95f1a5c289590
|