Skip to content

augmentation

Random geometric and color augmentations.

Classes:

  • RandomRotate –

    Rotate one or more keys (and optionally oriented boxes) by a uniformly random angle around an axis.

  • RandomScale –

    Scale one or more keys (and optionally oriented boxes) by a uniformly random factor.

  • RandomFlip –

    Flip listed axes (and optionally oriented boxes) with probability p each.

  • RandomJitter –

    Add Gaussian noise to listed keys, optionally clipped.

  • RandomTranslate –

    Translate listed keys (and optionally oriented boxes) by a uniformly random vector.

  • RandomColorJitter –

    Jitter colors by brightness, contrast, and saturation strengths.

  • RandomColorDrop –

    Replace colors with a constant gray value with probability p.

  • RandomColorGrayScale –

    Convert listed color keys to grayscale (BT.601 luminance) with probability p.

  • RandomColorAutoContrast –

    Stretch per-cloud color range to the full extent, then blend back, with probability p.

  • RandomRotateChoice –

    Rotate one or more keys by an angle chosen uniformly from a discrete list.

  • RandomColorShift –

    Additive per-channel color shift sampled uniformly per channel.

  • RandomElasticDistortion –

    Apply a smooth random displacement field (elastic distortion).

RandomRotate [source] ΒΆ

RandomRotate(
    keys: KeyCollection,
    angle_range: Tuple[float, float] = (-180.0, 180.0),
    axis: int = 2,
    p: float = 1.0,
    box_key: Optional[str] = None,
    center: Union[str, Sequence[float]] = "origin",
    vector_keys: Optional[KeyCollection] = None,
    dst_keys: Optional[KeyCollection] = None,
    dst_box_key: Optional[str] = None,
    seed: Optional[int] = None,
    allow_missing_keys: bool = False,
)

Bases: DictTransform, Randomizable

Rotate one or more keys (and optionally oriented boxes) by a uniformly random angle around an axis.

Sampling is done once per call: every listed key and the optional box get the same rotation. Each key is a \((\ldots, 3)\) field or a packed \((N, 3G)\) field of tiled 3D offsets (e.g. vote offsets). Pair keys=("pos", "normal") to keep positions and normals consistent, or pass box_key to also rotate a \((K, 7)\) oriented-box tensor (centers rotated, heading incremented). Box headings are counterclockwise yaw about the up axis, so box_key requires axis=2.

RandomRotate on an object

RandomRotate on a room

RandomRotate around each axis on an object

See Also

torch_pointcloud.transforms.functional.rotate_vectors, torch_pointcloud.transforms.functional.rotate_boxes, torch_pointcloud.transforms.functional.rotation_matrix

Parameters:

  • keys (KeyCollection) –

    Keys to rotate. Each must be a \((\ldots, 3)\) or \((N, 3G)\) vector field.

  • angle_range (Tuple[float, float], default: (-180.0, 180.0) ) –

    Min and max rotation angle, in degrees.

  • axis (int, default: 2 ) –

    Axis index to rotate around (0=X, 1=Y, 2=Z).

  • p (float, default: 1.0 ) –

    Probability of applying the transform.

  • box_key (Optional[str], default: None ) –

    Optional key of a \((K, 7)\) oriented-box tensor to rotate jointly (requires axis=2); a \((K, 9)\) tensor carries a planar velocity in its last two columns, rotated with the boxes.

  • center (Union[str, Sequence[float]], default: 'origin' ) –

    Point the rotation is about: "origin", "bbox" (the midrange of the first key), "centroid" (its mean) or an explicit \((x, y, z)\).

  • vector_keys (Optional[KeyCollection], default: None ) –

    Direction fields (normals) rotated without the recentering, whatever center is.

  • dst_keys (Optional[KeyCollection], default: None ) –

    Where to store the rotated tensors. Defaults to keys (in-place).

  • dst_box_key (Optional[str], default: None ) –

    Where to store the rotated boxes. Defaults to box_key (in-place).

  • seed (Optional[int], default: None ) –

    Seed of the transform's own random stream; None draws from the global generator (see Randomizable).

  • allow_missing_keys (bool, default: False ) –

    If True, silently skip absent keys.

RandomScale [source] ΒΆ

RandomScale(
    keys: KeyCollection,
    scale_range: Tuple[float, float] = (0.8, 1.25),
    anisotropic: bool = False,
    axes: Optional[Sequence[int]] = None,
    p: float = 1.0,
    box_key: Optional[str] = None,
    dst_keys: Optional[KeyCollection] = None,
    dst_box_key: Optional[str] = None,
    seed: Optional[int] = None,
    allow_missing_keys: bool = False,
)

Bases: DictTransform, Randomizable

Scale one or more keys (and optionally oriented boxes) by a uniformly random factor.

Sampling is done once per call: every listed key and the optional box are scaled by the same factor (or per-axis factor vector when anisotropic=True). Pass box_key to also scale a \((K, 7)\) oriented-box tensor (centers and sizes). An oriented box has no per-axis scale, so box_key is incompatible with anisotropic=True.

List only point-like keys. Do not list direction vectors such as normal: a scaled normal is no longer unit length, while a true surface normal is unchanged by an isotropic scale (and an anisotropic scale would require the inverse-transpose rule). Simply omit normal keys.

RandomScale on an object

RandomScale on a room

See Also

torch_pointcloud.transforms.functional.scale_boxes

Parameters:

  • keys (KeyCollection) –

    Keys to scale. Point-like keys only; do not list direction vectors such as normal.

  • scale_range (Tuple[float, float], default: (0.8, 1.25) ) –

    Min and max scaling factor.

  • anisotropic (bool, default: False ) –

    If True, sample a separate scale per axis of the last dim (incompatible with box_key).

  • axes (Optional[Sequence[int]], default: None ) –

    Channels of the last dim that receive the factor, the others keep their values; None scales them all (incompatible with anisotropic and box_key).

  • p (float, default: 1.0 ) –

    Probability of applying the transform.

  • box_key (Optional[str], default: None ) –

    Optional key of a \((K, 7)\) oriented-box tensor to scale jointly; a \((K, 9)\) tensor carries a planar velocity in its last two columns, scaled with the boxes.

  • dst_keys (Optional[KeyCollection], default: None ) –

    Where to store the scaled tensors.

  • dst_box_key (Optional[str], default: None ) –

    Where to store the scaled boxes. Defaults to box_key (in-place).

  • seed (Optional[int], default: None ) –

    Seed of the transform's own random stream; None draws from the global generator (see Randomizable).

  • allow_missing_keys (bool, default: False ) –

    If True, silently skip absent keys.

RandomFlip [source] ΒΆ

RandomFlip(
    keys: KeyCollection,
    axes: Sequence[int] = (0, 1),
    p: float = 0.5,
    box_key: Optional[str] = None,
    dst_keys: Optional[KeyCollection] = None,
    dst_box_key: Optional[str] = None,
    seed: Optional[int] = None,
    allow_missing_keys: bool = False,
)

Bases: DictTransform, Randomizable

Flip listed axes (and optionally oriented boxes) with probability p each.

Sampling is done once per call: every listed key and the optional box are flipped on the same axes. Each key is a \((\ldots, 3)\) field or a packed \((N, 3G)\) field of tiled 3D offsets (e.g. vote offsets). Pass box_key to also flip a \((K, 7)\) oriented-box tensor (centers negated, heading remapped).

RandomFlip on an object

RandomFlip on a room

RandomFlip across each axis on an object

See Also

torch_pointcloud.transforms.functional.flip_vectors, torch_pointcloud.transforms.functional.flip_boxes

Parameters:

  • keys (KeyCollection) –

    Keys to flip. Each must be a \((\ldots, 3)\) or \((N, 3G)\) vector field.

  • axes (Sequence[int], default: (0, 1) ) –

    Axis indices (into each 3D triple) to consider for flipping.

  • p (float, default: 0.5 ) –

    Per-axis flip probability.

  • box_key (Optional[str], default: None ) –

    Optional key of a \((K, 7)\) oriented-box tensor to flip jointly; a \((K, 9)\) tensor carries a planar velocity in its last two columns, flipped with the boxes.

  • dst_keys (Optional[KeyCollection], default: None ) –

    Where to store the flipped tensors.

  • dst_box_key (Optional[str], default: None ) –

    Where to store the flipped boxes. Defaults to box_key (in-place).

  • seed (Optional[int], default: None ) –

    Seed of the transform's own random stream; None draws from the global generator (see Randomizable).

  • allow_missing_keys (bool, default: False ) –

    If True, silently skip absent keys.

RandomJitter [source] ΒΆ

RandomJitter(
    keys: KeyCollection,
    sigma: float = 0.01,
    clip: Optional[float] = 0.05,
    p: float = 1.0,
    dst_keys: Optional[KeyCollection] = None,
    seed: Optional[int] = None,
    allow_missing_keys: bool = False,
)

Bases: DictTransform, Randomizable

Add Gaussian noise to listed keys, optionally clipped.

Each key gets its own independent noise tensor (because the noise shape matches the key shape). Pair-rotation-style consistency does not apply here.

RandomJitter on an object

RandomJitter on a room

See Also

torch_pointcloud.transforms.functional.random_jitter

Parameters:

  • keys (KeyCollection) –

    Keys to jitter.

  • sigma (float, default: 0.01 ) –

    Standard deviation of the Gaussian noise.

  • clip (Optional[float], default: 0.05 ) –

    If not None, clip the noise to [-clip, clip].

  • p (float, default: 1.0 ) –

    Probability of applying the transform.

  • dst_keys (Optional[KeyCollection], default: None ) –

    Where to store the jittered tensors.

  • seed (Optional[int], default: None ) –

    Seed of the transform's own random stream; None draws from the global generator (see Randomizable).

  • allow_missing_keys (bool, default: False ) –

    If True, silently skip absent keys.

RandomTranslate [source] ΒΆ

RandomTranslate(
    keys: KeyCollection,
    translation_range: Tuple[float, float] = (-0.2, 0.2),
    p: float = 1.0,
    box_key: Optional[str] = None,
    dst_keys: Optional[KeyCollection] = None,
    dst_box_key: Optional[str] = None,
    seed: Optional[int] = None,
    allow_missing_keys: bool = False,
)

Bases: DictTransform, Randomizable

Translate listed keys (and optionally oriented boxes) by a uniformly random vector.

Sampling is done once per call: all listed keys and the optional box are shifted by the same translation vector. Pass box_key to also translate a \((K, 7)\) oriented-box tensor (centers only; sizes and heading unchanged).

List only point-like keys. Do not list direction vectors such as normal: directions are translation-invariant, so a shifted normal is wrong. Simply omit normal keys.

RandomTranslate on an object

RandomTranslate on a room

See Also

torch_pointcloud.transforms.functional.translate_boxes

Parameters:

  • keys (KeyCollection) –

    Keys to translate. Point-like keys only; do not list direction vectors such as normal.

  • translation_range (Tuple[float, float], default: (-0.2, 0.2) ) –

    Min and max per-axis translation.

  • p (float, default: 1.0 ) –

    Probability of applying the transform.

  • box_key (Optional[str], default: None ) –

    Optional key of a \((K, 7)\) oriented-box tensor to translate jointly.

  • dst_keys (Optional[KeyCollection], default: None ) –

    Where to store the shifted tensors.

  • dst_box_key (Optional[str], default: None ) –

    Where to store the shifted boxes. Defaults to box_key (in-place).

  • seed (Optional[int], default: None ) –

    Seed of the transform's own random stream; None draws from the global generator (see Randomizable).

  • allow_missing_keys (bool, default: False ) –

    If True, silently skip absent keys.

RandomColorJitter [source] ΒΆ

RandomColorJitter(
    keys: KeyCollection,
    brightness: float = 0.4,
    contrast: float = 0.4,
    saturation: float = 0.2,
    int_color: bool = False,
    p: float = 1.0,
    dst_keys: Optional[KeyCollection] = None,
    seed: Optional[int] = None,
    allow_missing_keys: bool = False,
)

Bases: DictTransform, Randomizable

Jitter colors by brightness, contrast, and saturation strengths.

Each strength is a relative delta uniformly sampled from [-x, x]. Sampling is once per call, so the same factors are applied to every listed key.

RandomColorJitter before / after

See Also

torch_pointcloud.transforms.functional.color_jitter

Parameters:

  • keys (KeyCollection) –

    Color keys to jitter, shape \((N, 3)\).

  • brightness (float, default: 0.4 ) –

    Max relative brightness change in \([0, 1]\).

  • contrast (float, default: 0.4 ) –

    Max relative contrast change in \([0, 1]\).

  • saturation (float, default: 0.2 ) –

    Max relative saturation change in \([0, 1]\).

  • int_color (bool, default: False ) –

    If True, treat float colors as [0, 255] values; otherwise [0, 1]. uint8 colors are always treated as [0, 255] regardless of the flag; float colors above 1 with int_color=False raise a ValueError.

  • p (float, default: 1.0 ) –

    Probability of applying the transform.

  • dst_keys (Optional[KeyCollection], default: None ) –

    Where to store the jittered tensors.

  • seed (Optional[int], default: None ) –

    Seed of the transform's own random stream; None draws from the global generator (see Randomizable).

  • allow_missing_keys (bool, default: False ) –

    If True, silently skip absent keys.

RandomColorDrop [source] ΒΆ

RandomColorDrop(
    keys: KeyCollection,
    fill: float = 0.5,
    int_color: bool = False,
    p: float = 0.2,
    dst_keys: Optional[KeyCollection] = None,
    seed: Optional[int] = None,
    allow_missing_keys: bool = False,
)

Bases: DictTransform, Randomizable

Replace colors with a constant gray value with probability p.

RandomColorDrop before / after

See Also

torch_pointcloud.transforms.functional.color_drop

Parameters:

  • keys (KeyCollection) –

    Color keys to drop.

  • fill (float, default: 0.5 ) –

    Replacement value in the range implied by int_color ([0, 1] when False, [0, 255] when True); rescaled to the input's actual range when that differs, so the default 0.5 fills 127 on uint8 colors.

  • int_color (bool, default: False ) –

    If True, treat float colors as [0, 255] values; otherwise [0, 1]. uint8 colors are always treated as [0, 255] regardless of the flag; float colors above 1 with int_color=False raise a ValueError.

  • p (float, default: 0.2 ) –

    Probability of dropping colors.

  • dst_keys (Optional[KeyCollection], default: None ) –

    Where to store the result.

  • seed (Optional[int], default: None ) –

    Seed of the transform's own random stream; None draws from the global generator (see Randomizable).

  • allow_missing_keys (bool, default: False ) –

    If True, silently skip absent keys.

RandomColorGrayScale [source] ΒΆ

RandomColorGrayScale(
    keys: KeyCollection,
    int_color: bool = False,
    p: float = 0.2,
    dst_keys: Optional[KeyCollection] = None,
    seed: Optional[int] = None,
    allow_missing_keys: bool = False,
)

Bases: DictTransform, Randomizable

Convert listed color keys to grayscale (BT.601 luminance) with probability p.

RandomColorGrayScale before / after

See Also

torch_pointcloud.transforms.functional.color_grayscale

Parameters:

  • keys (KeyCollection) –

    Color keys, shape \((N, 3)\).

  • int_color (bool, default: False ) –

    If True, treat colors as [0, 255] ints; otherwise [0, 1] floats.

  • p (float, default: 0.2 ) –

    Probability of converting to grayscale.

  • dst_keys (Optional[KeyCollection], default: None ) –

    Where to store the result.

  • seed (Optional[int], default: None ) –

    Seed of the transform's own random stream; None draws from the global generator (see Randomizable).

  • allow_missing_keys (bool, default: False ) –

    If True, silently skip absent keys.

RandomColorAutoContrast [source] ΒΆ

RandomColorAutoContrast(
    keys: KeyCollection,
    blend: Optional[float] = 0.5,
    int_color: bool = False,
    p: float = 0.2,
    dst_keys: Optional[KeyCollection] = None,
    seed: Optional[int] = None,
    allow_missing_keys: bool = False,
)

Bases: DictTransform, Randomizable

Stretch per-cloud color range to the full extent, then blend back, with probability p.

RandomColorAutoContrast before / after

See Also

torch_pointcloud.transforms.functional.color_auto_contrast

Parameters:

  • keys (KeyCollection) –

    Color keys, shape \((N, 3)\).

  • blend (Optional[float], default: 0.5 ) –

    Blend weight in [0, 1]. 1.0 is fully auto-contrasted; 0.0 is the input; None draws a uniform weight on every application.

  • int_color (bool, default: False ) –

    If True, treat float colors as [0, 255] values; otherwise [0, 1]. uint8 colors are always treated as [0, 255] regardless of the flag; float colors above 1 with int_color=False raise a ValueError.

  • p (float, default: 0.2 ) –

    Probability of applying the transform.

  • dst_keys (Optional[KeyCollection], default: None ) –

    Where to store the result.

  • seed (Optional[int], default: None ) –

    Seed of the transform's own random stream; None draws from the global generator (see Randomizable).

  • allow_missing_keys (bool, default: False ) –

    If True, silently skip absent keys.

RandomRotateChoice [source] ΒΆ

RandomRotateChoice(
    keys: KeyCollection,
    angles: Sequence[float],
    axis: int = 2,
    p: float = 1.0,
    dst_keys: Optional[KeyCollection] = None,
    seed: Optional[int] = None,
    allow_missing_keys: bool = False,
)

Bases: DictTransform, Randomizable

Rotate one or more keys by an angle chosen uniformly from a discrete list.

Common use: ModelNet / ScanObjectNN augmentation with angles=[0, 90, 180, 270] around the z-axis. Sampling is done once per call: every listed key gets the same rotation matrix.

See Also

torch_pointcloud.transforms.functional.rotation_matrix, torch_pointcloud.transforms.functional.rotate_vectors

RandomRotateChoice on an object

RandomRotateChoice on a room

Parameters:

  • keys (KeyCollection) –

    Keys to rotate. Each must have shape (..., 3).

  • angles (Sequence[float]) –

    Candidate rotation angles, in degrees. Must be non-empty.

  • axis (int, default: 2 ) –

    Axis index to rotate around (0=X, 1=Y, 2=Z).

  • p (float, default: 1.0 ) –

    Probability of applying the transform.

  • dst_keys (Optional[KeyCollection], default: None ) –

    Where to store the rotated tensors. Defaults to keys (in-place).

  • seed (Optional[int], default: None ) –

    Seed of the transform's own random stream; None draws from the global generator (see Randomizable).

  • allow_missing_keys (bool, default: False ) –

    If True, silently skip absent keys.

RandomColorShift [source] ΒΆ

RandomColorShift(
    keys: KeyCollection,
    shift_range: Tuple[float, float] = (-0.05, 0.05),
    int_color: bool = False,
    p: float = 1.0,
    dst_keys: Optional[KeyCollection] = None,
    seed: Optional[int] = None,
    allow_missing_keys: bool = False,
)

Bases: DictTransform, Randomizable

Additive per-channel color shift sampled uniformly per channel.

For each of the 3 channels, sample one offset uniformly from shift_range and add it to every point's value. Sampling is once per call (same shift across all listed keys). Result is clamped to the valid color range.

RandomColorShift before / after

See Also

torch_pointcloud.transforms.functional.color_shift

Parameters:

  • keys (KeyCollection) –

    Color keys to shift, shape \((N, 3)\).

  • shift_range (Tuple[float, float], default: (-0.05, 0.05) ) –

    Min and max per-channel offset (in the same range as the colors).

  • int_color (bool, default: False ) –

    If True, treat float colors as [0, 255] values; otherwise [0, 1]. uint8 colors are always treated as [0, 255] regardless of the flag; float colors above 1 with int_color=False raise a ValueError.

  • p (float, default: 1.0 ) –

    Probability of applying the transform.

  • dst_keys (Optional[KeyCollection], default: None ) –

    Where to store the shifted tensors.

  • seed (Optional[int], default: None ) –

    Seed of the transform's own random stream; None draws from the global generator (see Randomizable).

  • allow_missing_keys (bool, default: False ) –

    If True, silently skip absent keys.

RandomElasticDistortion [source] ΒΆ

RandomElasticDistortion(
    keys: KeyCollection,
    granularity: Union[float, Sequence[float]] = 0.2,
    magnitude: Union[float, Sequence[float]] = 0.4,
    p: float = 1.0,
    dst_keys: Optional[KeyCollection] = None,
    seed: Optional[int] = None,
    allow_missing_keys: bool = False,
)

Bases: DictTransform, Randomizable

Apply a smooth random displacement field (elastic distortion).

Used in sparse-voxel indoor segmentation recipes. Sampling is done once per call so multi-key consistency is preserved (the same displacement field is applied to every listed key).

For multi-scale distortion (the common default), compose two RandomElasticDistortion calls with different granularity / magnitude.

RandomElasticDistortion on an object

RandomElasticDistortion on a room

See Also

torch_pointcloud.transforms.functional.random_elastic_distortion

Parameters:

  • keys (KeyCollection) –

    Position keys to distort, shape \((N, 3)\). All listed keys must share the same leading dimension \(N\): the per-point displacement is computed once from the first present key and added to every key.

  • granularity (Union[float, Sequence[float]], default: 0.2 ) –

    Size of the displacement-field grid cells. Smaller values give higher-frequency distortion. Several values (paired with magnitude) run one pass each, under the same probability gate.

  • magnitude (Union[float, Sequence[float]], default: 0.4 ) –

    Standard deviation of the per-cell Gaussian noise. Larger values give stronger deformation.

  • p (float, default: 1.0 ) –

    Probability of applying the transform.

  • dst_keys (Optional[KeyCollection], default: None ) –

    Where to store the distorted tensors.

  • seed (Optional[int], default: None ) –

    Seed of the transform's own random stream; None draws from the global generator (see Randomizable).

  • allow_missing_keys (bool, default: False ) –

    If True, silently skip absent keys.

rotate_boxes [source] ΒΆ

rotate_boxes(
    boxes: Tensor, rotation: Tensor, angle: float
) -> Tensor

Rotate oriented 3D boxes about the up axis.

Box centers are rotated by rotation (centers @ rotation.transpose(-1, -2)) and the heading is incremented by angle, so a counterclockwise rotation about \(+z\) keeps the counterclockwise heading aligned with the jointly rotated points. Sizes are unchanged. Boxes with a planar velocity \((v_x, v_y)\) in columns \(7{:}9\) have it rotated in the plane; further columns are kept as they are.

Parameters:

  • boxes (Tensor) –

    Box tensor of shape \((K, 7)\) as \([c_x, c_y, c_z, d_x, d_y, d_z, \theta]\), or \((K, 7 + C)\).

  • rotation (Tensor) –

    A \(3 \times 3\) rotation matrix rotating by angle counterclockwise about the \(z\) axis.

  • angle (float) –

    Rotation angle in radians, added to the heading.

Returns:

  • Tensor –

    The rotated box tensor, same shape as boxes.

scale_boxes [source] ΒΆ

scale_boxes(
    boxes: Tensor, scale: Union[float, Tensor]
) -> Tensor

Scale oriented 3D boxes by an isotropic factor.

Both centers and extents (columns \(0\) to \(6\)) are multiplied by scale, and so is a planar velocity \((v_x, v_y)\) in columns \(7{:}9\). Heading and further columns are unchanged.

Parameters:

  • boxes (Tensor) –

    Box tensor of shape \((K, 7)\) or \((K, 7 + C)\).

  • scale (Union[float, Tensor]) –

    Isotropic scalar factor applied to centers, sizes and velocity.

Returns:

  • Tensor –

    The scaled box tensor, same shape as boxes.

flip_boxes [source] ΒΆ

flip_boxes(boxes: Tensor, axis: int) -> Tensor

Flip oriented 3D boxes along a spatial axis.

Boxes are stored as \((K, 7)\) rows \([c_x, c_y, c_z, d_x, d_y, d_z, \theta]\) with full extents and heading in radians counterclockwise about \(+z\) from \(+x\). A flip negates the center component along axis. A flip along axis \(0\) (the \(yz\) plane) maps the heading to \(\pi - \theta\); a flip along axis \(1\) (the \(xz\) plane) maps the heading to \(-\theta\). Sizes are unchanged. Boxes with a planar velocity \((v_x, v_y)\) in columns \(7{:}9\) have its axis component negated too; further columns are kept as they are.

Parameters:

  • boxes (Tensor) –

    Box tensor of shape \((K, 7)\) or \((K, 7 + C)\).

  • axis (int) –

    Center axis index to negate (0=X, 1=Y).

Returns:

  • Tensor –

    The flipped box tensor, same shape as boxes.

flip_vectors [source] ΒΆ

flip_vectors(x: Tensor, axis: int) -> Tensor

Flip a packed field of 3D vectors along a spatial axis.

Negates component axis of every contiguous triple of the last dimension, so it handles both a plain \((N, 3)\) field (e.g. coordinates or normals) and a \((N, 3 G)\) field of \(G\) tiled offsets (e.g. vote offsets \((\text{center} - \text{point})\)) alike.

Parameters:

  • x (Tensor) –

    Vector field of shape \((N, 3)\) or \((N, 3 G)\).

  • axis (int) –

    Axis index within each triple to negate.

Returns:

  • Tensor –

    The flipped tensor with the same shape as x.

random_jitter [source] ΒΆ

random_jitter(
    x: Tensor,
    sigma: float = 0.01,
    clip: Optional[float] = 0.05,
    generator: Optional[Generator] = None,
) -> Tensor

Add Gaussian noise to x, optionally clipped.

Parameters:

  • x (Tensor) –

    Input tensor.

  • sigma (float, default: 0.01 ) –

    Standard deviation of the Gaussian noise.

  • clip (Optional[float], default: 0.05 ) –

    If not None, clip the noise to [-clip, clip].

  • generator (Optional[Generator], default: None ) –

    Random generator for reproducibility.

Returns:

  • Tensor –

    Jittered tensor with the same shape as x.

translate_boxes [source] ΒΆ

translate_boxes(
    boxes: Tensor, translation: Tensor
) -> Tensor

Translate oriented 3D boxes by a fixed offset.

Centers (columns \(0\) to \(3\)) are offset by translation. Sizes, heading and any further column (such as a velocity) are unchanged.

Parameters:

  • boxes (Tensor) –

    Box tensor of shape \((K, 7)\) as \([c_x, c_y, c_z, d_x, d_y, d_z, \theta]\), or \((K, 7 + C)\).

  • translation (Tensor) –

    Translation vector of shape \((3,)\).

Returns:

  • Tensor –

    The shifted box tensor, same shape as boxes.

color_jitter [source] ΒΆ

color_jitter(
    color: Tensor,
    brightness: Optional[float] = None,
    contrast: Optional[float] = None,
    saturation: Optional[float] = None,
    int_color: bool = False,
) -> Tensor

Apply brightness, contrast, and saturation factors to colors, in that order.

Each factor multiplies its component directly (1.0 is identity); None skips the component entirely.

Parameters:

  • color (Tensor) –

    Color tensor of shape \((N, 3)\).

  • brightness (Optional[float], default: None ) –

    Multiplicative brightness factor (e.g. 1.2 brightens by 20%).

  • contrast (Optional[float], default: None ) –

    Contrast factor, scaling the deviation from the per-channel mean.

  • saturation (Optional[float], default: None ) –

    Saturation factor, scaling the deviation from the per-point grayscale luminance.

  • int_color (bool, default: False ) –

    If True, treat float colors as [0, 255] values; otherwise [0, 1]. uint8 colors are always treated as [0, 255] regardless of the flag.

Returns:

  • Tensor –

    Jittered colors with the same shape and dtype as color.

Raises:

  • ValueError –

    If color is a float tensor with values above 1 while int_color=False.

random_color_jitter [source] ΒΆ

random_color_jitter(
    color: Tensor,
    brightness: float = 0.0,
    contrast: float = 0.0,
    saturation: float = 0.0,
    int_color: bool = False,
    generator: Optional[Generator] = None,
) -> Tensor

Jitter colors by brightness, contrast, and saturation, in that order.

Each strength is a relative delta sampled uniformly from [-x, x] and applied multiplicatively (out = x * factor) via color_jitter.

Parameters:

  • color (Tensor) –

    Color tensor of shape \((N, 3)\).

  • brightness (float, default: 0.0 ) –

    Max relative brightness change. 0.2 means Β±20%.

  • contrast (float, default: 0.0 ) –

    Max relative contrast change.

  • saturation (float, default: 0.0 ) –

    Max relative saturation change. Saturation moves toward (or away from) the per-channel grayscale luminance.

  • int_color (bool, default: False ) –

    If True, treat float colors as [0, 255] values; otherwise [0, 1]. uint8 colors are always treated as [0, 255] regardless of the flag.

  • generator (Optional[Generator], default: None ) –

    Random generator for reproducibility.

Returns:

  • Tensor –

    Jittered colors with the same shape and dtype as color.

Raises:

  • ValueError –

    If color is a float tensor with values above 1 while int_color=False.

color_drop [source] ΒΆ

color_drop(
    color: Tensor,
    fill: float = 0.5,
    int_color: bool = False,
) -> Tensor

Replace colors with a constant gray value (drops chromatic information).

Parameters:

  • color (Tensor) –

    Color tensor of shape \((N, 3)\).

  • fill (float, default: 0.5 ) –

    Replacement value, expressed in the range implied by int_color ([0, 1] when False, [0, 255] when True). It is rescaled to the input's actual range when that differs, so the default 0.5 fills 127 on uint8 colors.

  • int_color (bool, default: False ) –

    If True, treat float colors as [0, 255] values; otherwise [0, 1]. uint8 colors are always treated as [0, 255] regardless of the flag.

Returns:

  • Tensor –

    Tensor of the same shape and dtype as color, filled with the rescaled fill.

Raises:

  • ValueError –

    If color is a float tensor with values above 1 while int_color=False.

color_grayscale [source] ΒΆ

color_grayscale(
    color: Tensor, int_color: bool = False
) -> Tensor

Convert RGB colors to grayscale using the BT.601 luminance weights.

Parameters:

  • color (Tensor) –

    Color tensor of shape \((N, 3)\).

  • int_color (bool, default: False ) –

    If True, treat colors as [0, 255] ints; otherwise [0, 1] floats.

Returns:

  • Tensor –

    Tensor with the same shape and dtype as color, with R=G=B = luminance.

color_auto_contrast [source] ΒΆ

color_auto_contrast(
    color: Tensor,
    blend: float = 0.5,
    int_color: bool = False,
) -> Tensor

Stretch per-cloud color range to the full [0, max] interval, then blend.

For each channel, the min becomes 0 and the max becomes max_val. The output is then linearly blended with the original by blend (blend=1.0 is the fully stretched version, blend=0.0 is the input).

Parameters:

  • color (Tensor) –

    Color tensor of shape \((N, 3)\).

  • blend (float, default: 0.5 ) –

    Blend weight in [0, 1].

  • int_color (bool, default: False ) –

    If True, treat float colors as [0, 255] values; otherwise [0, 1]. uint8 colors are always treated as [0, 255] regardless of the flag.

Returns:

  • Tensor –

    Auto-contrast tensor with the same shape and dtype as color.

Raises:

  • ValueError –

    If color is a float tensor with values above 1 while int_color=False.

color_shift [source] ΒΆ

color_shift(
    color: Tensor, shift: Tensor, int_color: bool = False
) -> Tensor

Add a per-channel offset to colors, clamped to the valid color range.

Parameters:

  • color (Tensor) –

    Color tensor of shape \((N, 3)\).

  • shift (Tensor) –

    Per-channel offset of shape \((3,)\), in the same range as the colors.

  • int_color (bool, default: False ) –

    If True, treat float colors as [0, 255] values; otherwise [0, 1]. uint8 colors are always treated as [0, 255] regardless of the flag.

Returns:

  • Tensor –

    Shifted colors with the same shape and dtype as color.

Raises:

  • ValueError –

    If color is a float tensor with values above 1 while int_color=False.

random_elastic_distortion [source] ΒΆ

random_elastic_distortion(
    pos: Tensor,
    granularity: float = 0.2,
    magnitude: float = 0.4,
    generator: Optional[Generator] = None,
) -> Tensor

Apply a smooth random displacement field to pos.

Implements the elastic distortion recipe common in sparse-voxel indoor segmentation pipelines: sample Gaussian noise on a coarse 3D grid (cells of side granularity), smooth it with two passes of a \(3 \times 3 \times 3\) mean filter, trilinear-interpolate the smoothed displacement at each point, and add it to the position. Net effect is a locally-coherent, low-frequency deformation that preserves nearby-point relationships.

Parameters:

  • pos (Tensor) –

    Input positions of shape \((N, 3)\).

  • granularity (float, default: 0.2 ) –

    Size of the noise grid cells (in the same units as pos). Smaller values give higher-frequency distortion.

  • magnitude (float, default: 0.4 ) –

    Standard deviation of the per-cell Gaussian noise (in the same units as pos). Larger values give stronger deformation.

  • generator (Optional[Generator], default: None ) –

    Random generator for reproducibility.

Returns:

  • Tensor –

    Distorted positions of shape \((N, 3)\).