pypose.voxel_filter¶
- class pypose.voxel_filter(points, voxel, random=False)[source]¶
Perform voxel filtering on a point cloud to reduce the number of points by grouping them into voxels and selecting a representative point for each voxel.
- Parameters:
points (
torch.Tensor
) – The input point cloud. It is possible that the last dimension (D) is larger than dimension of voxel \(v\) (vdim), with the point’s coordinates as the first \(v\) values. Subsequent values are additional information such as intensity, RGB channels. The shape has to be (N, D), where \(D \geq v\).voxel (list of
float
) – The sizes of the voxel in each dimension, provided as \(\left[v_1, v_2, \cdots, v_{\text{dim}}\right]\).random (
bool
, optional) – IfTrue
, a random point within each voxel is chosen as the representative, othewise the centroid of the points is used. Default:False
.
- Returns:
- The sampled point cloud, with each point representing a
voxel. The shape is (M, D), where M (\(M\le N\)) is the number of voxels.
- Return type:
output (
torch.Tensor
)
Warning
Note that this operation does not support batch operations, since the number of output voxels can be differeent on each batch.
Example
>>> import torch, pypose as pp >>> points = torch.tensor([[ 1., 2., 3.], ... [ 4., 5., 6.], ... [ 7., 8., 9.], ... [10., 11., 12.], ... [13., 14., 15.]]) >>> pp.voxel_filter(points, [5., 5., 5.]) tensor([[ 2.5000, 3.5000, 4.5000], [ 8.5000, 9.5000, 10.5000], [13.0000, 14.0000, 15.0000]]) >>> pp.voxel_filter(points, [5., 5., 5.], random=True) tensor([[ 4., 5., 6.], [10., 11., 12.], [13., 14., 15.]])