masking
Transforms that build or apply point masks.
Classes:
-
RemoveNearOriginβRemove points that are within a given radius of the origin from dictionary entries.
-
BoxMaskβCreate a boolean mask for points inside an axis-aligned bounding box (AABB).
-
ApplyMaskβApply a mask stored in a dictionary to other dictionary entries.
-
CubeMaskβCreate a boolean mask for points inside an axis-aligned cube (Lβ / Chebyshev ball).
-
SphereMaskβCreate a boolean mask for points inside an L2 (Euclidean) ball.
RemoveNearOrigin [source] ΒΆ
RemoveNearOrigin(
pos_key: str,
keys: Optional[KeyCollection] = None,
radius: float = 0.001,
dst_index_key: Optional[str] = None,
allow_missing_keys: bool = False,
)
Bases: DictTransform
Remove points that are within a given radius of the origin from dictionary entries.


See Also
torch_pointcloud.transforms.functional.remove_near_origin
Parameters:
-
pos_key(str) βThe key containing the positions / coordinates, used to compute the distance from the origin.
-
keys(Optional[KeyCollection], default:None) βExtra keys to filter with the same mask.
-
radius(float, default:0.001) βThe radius of the sphere.
-
dst_index_key(Optional[str], default:None) βKey for the output-to-input row map (see the module docs on sampling keys);
None(the default) disables it. -
allow_missing_keys(bool, default:False) βIf
True, the transform will not raise an error if the keys are not present in the data.
BoxMask [source] ΒΆ
BoxMask(
keys: KeyCollection,
bbox: tuple[float, ...],
dst_keys: Optional[KeyCollection] = None,
dim: int = -1,
strict: bool = False,
allow_missing_keys: bool = False,
)
Bases: DictTransform
Create a boolean mask for points inside an axis-aligned bounding box (AABB).
Membership condition along dim (default, boundary points included):
where bbox = (*bbmin, *bbmax) is the AABB. With strict=True the inequalities are strict, so boundary points are excluded.
Sibling masks:
CubeMask- Lβ ball (center + radius)SphereMask- L2 ball (center + radius)


See Also
torch_pointcloud.transforms.functional.box_mask
Parameters:
-
keys(KeyCollection) βThe keys to create the mask for.
-
bbox(tuple[float, ...]) βThe bounding box used to mask input tensors, as
(*bbmin, *bbmax). -
dst_keys(Optional[KeyCollection], default:None) βThe keys to store the mask in.
-
dim(int, default:-1) βThe dimension to create the mask over.
-
strict(bool, default:False) βIf
True, use strict inequalities (points exactly on the boundary are excluded). -
allow_missing_keys(bool, default:False) βIf
True, the transform will not raise an error if the keys are not present in the data.
ApplyMask [source] ΒΆ
ApplyMask(
keys: KeyCollection,
mask_key: str,
dst_keys: Optional[KeyCollection] = None,
dst_index_key: Optional[str] = None,
allow_missing_keys: bool = False,
)
Bases: DictTransform
Apply a mask stored in a dictionary to other dictionary entries.
See Also
torch_pointcloud.transforms.functional.apply_mask


Parameters:
-
keys(KeyCollection) βThe keys to apply the mask to.
-
mask_key(str) βThe key containing the mask.
-
dst_keys(Optional[KeyCollection], default:None) βThe keys to store the transformed data in.
-
dst_index_key(Optional[str], default:None) βKey for the output-to-input row map (see the module docs on sampling keys);
None(the default) disables it. Leave it unset whendst_keysdiffer fromkeys, since the map would describe thedst_keysrows. -
allow_missing_keys(bool, default:False) βIf
True, the transform will not raise an error if the keys are not present in the data.
CubeMask [source] ΒΆ
CubeMask(
keys: KeyCollection,
center: ValueCollection[float],
radius: float,
dim: int = -1,
dst_keys: Optional[KeyCollection] = None,
allow_missing_keys: bool = False,
)
Bases: DictTransform
Create a boolean mask for points inside an axis-aligned cube (Lβ / Chebyshev ball).
Membership condition along dim:
Geometrically, the Lβ ball of radius \(r\) centered at \(c\) is a hypercube with edge \(2r\) aligned to the axes. Pair with SphereMask (L2) and BoxMask (AABB) for the mask family.


See Also
torch_pointcloud.transforms.functional.cube_mask
Parameters:
-
keys(KeyCollection) βThe keys to create the mask for.
-
center(ValueCollection[float]) βThe center of the cube.
-
radius(float) βThe radius (half-edge) of the cube.
-
dim(int, default:-1) βThe dimension to create the mask over.
-
dst_keys(Optional[KeyCollection], default:None) βThe keys to store the mask in.
-
allow_missing_keys(bool, default:False) βIf
True, the transform will not raise an error if the keys are not present in the data.
SphereMask [source] ΒΆ
SphereMask(
keys: KeyCollection,
center: ValueCollection[float],
radius: float,
dim: int = -1,
dst_keys: Optional[KeyCollection] = None,
allow_missing_keys: bool = False,
)
Bases: DictTransform
Create a boolean mask for points inside an L2 (Euclidean) ball.
Membership condition along dim:
Pair with CubeMask (Lβ) and BoxMask (AABB) for the mask family. RemoveNearOrigin(radius=r) is equivalent to Compose([SphereMask(center=(0,0,0), radius=r, invert=True), ApplyMask(...)]).


See Also
torch_pointcloud.transforms.functional.sphere_mask
Parameters:
-
keys(KeyCollection) βThe keys to create the mask for.
-
center(ValueCollection[float]) βThe center of the sphere.
-
radius(float) βThe radius of the sphere.
-
dim(int, default:-1) βThe dimension to compute the Euclidean norm over.
-
dst_keys(Optional[KeyCollection], default:None) βThe keys to store the mask in.
-
allow_missing_keys(bool, default:False) βIf
True, the transform will not raise an error if the keys are not present in the data.
sphere_mask [source] ΒΆ
sphere_mask(
x: Tensor,
center: Union[Tensor, Sequence[float], float],
radius: float,
dim: int = -1,
) -> Tensor
Create a boolean mask for points inside an L2 (Euclidean) ball.
Membership condition along dim:
Pair with cube_mask (Lβ) and box_mask (explicit AABB).
Parameters:
-
x(Tensor) βThe input tensor of shape \((\ldots, D)\) along
dim. -
center(Union[Tensor, Sequence[float], float]) βThe center of the sphere, shape \((D,)\) or broadcastable.
-
radius(float) βThe radius of the sphere.
-
dim(int, default:-1) βThe dimension to compute the Euclidean norm over.
Returns:
-
TensorβThe boolean mask, with
dimreduced.
remove_near_origin [source] ΒΆ
Remove points that are within a given radius (L2) of the origin.
Equivalent to inverting sphere_mask(pos, center=0, radius=r) and indexing.
Parameters:
-
pos(Tensor) βThe input tensor of shape \((N, D)\).
-
radius(float, default:0.001) βThe L2 radius (Euclidean distance) below which points are removed.
-
return_mask(bool, default:False) βIf
True, also return the keep-mask.
Returns:
-
AnyβThe filtered tensor; or
(filtered, mask)ifreturn_mask=True.
bounding_box [source] ΒΆ
Returns the min and max values along a given dimension.
Parameters:
-
x(Tensor) βThe input tensor of shape (..., D, ...).
-
dim(int, default:0) βThe dimension to compute bounds over.
Returns:
-
tuple[float, ...]βA tuple of (*min, *max) values.
box_mask [source] ΒΆ
Create a boolean mask for points inside an axis-aligned bounding box (AABB).
Membership condition along dim (default, boundary points included):
With strict=True the inequalities are strict, so boundary points are excluded.
Parameters:
-
x(Tensor) βThe input tensor of shape \((\ldots, D)\) along
dim. -
bbox(tuple[float, ...]) βAABB as a flat tuple
(*bbmin, *bbmax)of length \(2 \cdot D\); a row longer than \(D\) is tested by its first \(D\) coordinates, so a box row \((c_x, c_y, c_z, \ldots)\) is tested by its center. -
dim(int, default:-1) βThe dimension to compute the mask over.
-
strict(bool, default:False) βIf
True, use strict inequalities (points exactly on the boundary are excluded).
Returns:
-
TensorβThe boolean mask, with
dimreduced.
Raises:
-
ValueErrorβIf
len(bbox)is odd or larger than2 * x.shape[dim].
apply_mask [source] ΒΆ
Apply a mask to a tensor.
Parameters:
-
x(Tensor) βThe input tensor.
-
mask(Tensor) βThe mask.
Returns:
-
TensorβThe tensor with the mask applied.
Examples:
cube_mask [source] ΒΆ
cube_mask(
x: Tensor,
center: Union[Tensor, Sequence[float], float],
radius: float,
dim: int = -1,
) -> Tensor
Create a boolean mask for points inside an axis-aligned cube (Lβ / Chebyshev ball).
Membership condition along dim:
Geometrically, the Lβ ball of radius \(r\) centered at \(c\) is a hypercube with edge \(2r\) aligned to the axes. Pair with sphere_mask (L2) and box_mask (explicit AABB).
Parameters:
-
x(Tensor) βThe input tensor of shape \((\ldots, D)\) along
dim. -
center(Union[Tensor, Sequence[float], float]) βThe center of the cube, shape \((D,)\) or broadcastable.
-
radius(float) βThe half-edge (radius) of the cube.
-
dim(int, default:-1) βThe dimension to reduce the per-axis comparison over.
Returns:
-
TensorβThe boolean mask, with
dimreduced.