pypose.nbr_filter¶
- class pypose.nbr_filter(points, nbr, radius, pdim=None, ord=2, return_mask=False)[source]¶
Filter point outliers by checking if a point has less than n neighbors (nbr) within a radius.
- Parameters:
points (
torch.Tensor
) – the input point cloud. It is possible that the last dimension (D) is larger thanpdim
, with point’s coordinates using firstpdim
values. Subsequent values may contain additional information like intensity, RGB channels, etc. The shape has to be (N, D).nbr (
int
) – the minimum number of neighbors (nbr) within a certain radius.ord (
int
, optional) – the order of norm to use for distance calculation. Default:2
(Euclidean distance).radius (
float
) – the radius of the sphere for counting the neighbors.pdim (
int
, optional) – the dimsion of points, where \(\text{pdim} \le D\). Default to the last dimension of points, ifNone
.return_mask (
bool
, optional) – return the mask of inliers of not.
- Returns:
The point clouds removed outliers.
torch.BoolTensor
: The mask of point clouds removed outliers, where the inlier is True and the outlier is False. The shape is (…, N).- Return type:
torch.Tensor
Warning
Note that this operation does not support batch operations, since the number of output voxels can be different on different batches.
Example
>>> import torch, pypose as pp >>> points = torch.tensor([[0., 0., 0.], ... [1., 0., 0.], ... [0., 1., 0.], ... [0., 1., 1.], ... [10., 1., 1.], ... [10., 1., 10.]]) >>> pp.nbr_filter(points, nbr=2, radius=5) tensor([[0., 0., 0.], [1., 0., 0.], [0., 1., 0.], [0., 1., 1.]]) >>> pp.nbr_filter(points, nbr=2, radius=12, return_mask=True) (tensor([[ 0., 0., 0.], [ 1., 0., 0.], [ 0., 1., 0.], [ 0., 1., 1.], [10., 1., 1.]]), tensor([ True, True, True, True, True, False]))