voxel_grid_pool
Voxel grid subsampling of packed point clouds.
Classes:
-
VoxelGridPoolβVoxel grid subsampling: the points falling in the same
grid_sizecell are reduced to a single point.
VoxelGridPool [source] ΒΆ
Bases: Module
Voxel grid subsampling: the points falling in the same grid_size cell are reduced to a single point.
Positions are averaged within a cell and features are reduced with reduce. The grid origin is either aligned to multiples of grid_size (origin="grid", so cell boundaries do not depend on the cloud's extent) or placed at each cloud's minimum corner (origin="min"). Passing return_inverse=True also returns the point-to-cell map.
Parameters:
-
grid_size(float) βCell edge length.
-
reduce(str, default:'max') βFeature reduction over a cell:
"max","mean","sum"or"min". -
origin(Literal['grid', 'min'], default:'grid') βWhere the grid starts,
"grid"or"min".
Shape
- Input: \((N, C)\) features, \((N, 3)\) positions and \((N,)\) batch index.
- Output: \((M, C)\) features, \((M, 3)\) positions, \((M,)\) batch index and, with
return_inverse, the \((N,)\) cell index of every input point.
Example
>>> import torch
>>> from torch_pointcloud.layers import VoxelGridPool
>>> pool = VoxelGridPool(grid_size=0.5)
>>> x, pos, batch = torch.randn(100, 8), torch.rand(100, 3), torch.zeros(100, dtype=torch.long)
>>> x_pooled, pos_pooled, batch_pooled = pool(x, pos, batch) # doctest: +SKIP
>>> x_pooled.shape[1], pos_pooled.shape[1] # doctest: +SKIP
(8, 3)