filters¶
occulus.filters
¶
Point cloud filtering and downsampling operations.
All filters operate on :class:~occulus.types.PointCloud instances and return
new clouds — they never mutate the input.
Available filters
- :func:
voxel_downsample— grid-based spatial downsampling - :func:
random_downsample— uniform random point selection - :func:
statistical_outlier_removal— remove points with unusual neighbourhood distances - :func:
radius_outlier_removal— remove points with too few neighbours within a radius - :func:
crop— axis-aligned bounding box crop
All implementations use pure NumPy and SciPy. No optional dependencies required.
crop(cloud, bbox)
¶
Crop a point cloud to an axis-aligned bounding box.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cloud
|
PointCloud
|
Input point cloud. |
required |
bbox
|
tuple[float, float, float, float, float, float]
|
Bounding box as |
required |
Returns:
| Type | Description |
|---|---|
PointCloud
|
Points that fall within (inclusive of) the bounding box. |
Raises:
| Type | Description |
|---|---|
OcculusValidationError
|
If |
Source code in src/occulus/filters/__init__.py
radius_outlier_removal(cloud, radius, min_neighbors=2)
¶
Remove points that have fewer than min_neighbors within radius.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cloud
|
PointCloud
|
Input point cloud. |
required |
radius
|
float
|
Search radius in the same units as the cloud coordinates. Must be strictly positive. |
required |
min_neighbors
|
int
|
Minimum number of neighbours (excluding self) required to keep a point, by default 2. |
2
|
Returns:
| Type | Description |
|---|---|
PointCloud
|
Cloud with isolated points removed. |
NDArray[bool_]
|
Boolean inlier mask of length |
Raises:
| Type | Description |
|---|---|
OcculusValidationError
|
If |
Source code in src/occulus/filters/__init__.py
random_downsample(cloud, fraction, *, seed=None)
¶
Randomly downsample a point cloud to a fraction of its points.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cloud
|
PointCloud
|
Input point cloud. |
required |
fraction
|
float
|
Fraction of points to retain, in (0.0, 1.0]. |
required |
seed
|
int | None
|
Random seed for reproducibility, by default None. |
None
|
Returns:
| Type | Description |
|---|---|
PointCloud
|
Downsampled cloud of the same concrete subtype as the input. |
Raises:
| Type | Description |
|---|---|
OcculusValidationError
|
If |
Source code in src/occulus/filters/__init__.py
statistical_outlier_removal(cloud, nb_neighbors=20, std_ratio=2.0)
¶
Remove statistical outliers based on nearest-neighbour distances.
For each point the mean distance to its nb_neighbors nearest
neighbours is computed. Points whose mean distance exceeds
global_mean + std_ratio * global_std are classified as outliers
and removed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cloud
|
PointCloud
|
Input point cloud. |
required |
nb_neighbors
|
int
|
Number of nearest neighbours to consider (excluding self), by default 20. |
20
|
std_ratio
|
float
|
Standard deviation multiplier for the removal threshold, by default 2.0. Lower values remove points more aggressively. |
2.0
|
Returns:
| Type | Description |
|---|---|
PointCloud
|
Cloud with outliers removed. |
NDArray[bool_]
|
Boolean inlier mask of length |
Raises:
| Type | Description |
|---|---|
OcculusValidationError
|
If |
Source code in src/occulus/filters/__init__.py
voxel_downsample(cloud, voxel_size)
¶
Downsample a point cloud by retaining one point per voxel cell.
Points are grouped into a regular 3D grid of cubes with side length
voxel_size. For each occupied voxel the first point (after lexicographic
sort on voxel index) is retained, preserving all per-point attributes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cloud
|
PointCloud
|
Input point cloud. Must have at least one point. |
required |
voxel_size
|
float
|
Edge length of each voxel cube, in the same units as the cloud coordinates. Must be strictly positive. |
required |
Returns:
| Type | Description |
|---|---|
PointCloud
|
Downsampled cloud of the same concrete subtype as the input. |
Raises:
| Type | Description |
|---|---|
OcculusValidationError
|
If |