RandomFlip#
- class RandomFlip(p=0.5, axes=('x', 'y'))[source]#
Bases:
objectRandomly mirror the cloud across one or more axes.
For each requested axis, with probability
pnegates that coordinate column ofcoordin place (a reflection through the origin plane). The same sign flip is applied to v3vertexmetadata,aux_position_keys,aux_direction_keys, andnormal. Requirescoord. Registered asRandomFlip– use this string as thetypein atransform=[...]config list.- Parameters:
p (float) – per-axis probability of flipping. Defaults to
0.5.axes (str | Sequence[str]) – which of
"x","y","z"may be flipped. A bare string is wrapped into a single-element tuple. Defaults to("x", "y").
Note
Each listed axis is tested independently, so multiple axes can flip in a single call.
Example
>>> import numpy as np >>> from pimm.datasets.transform import RandomFlip >>> data = {"coord": np.array([[1., 2., 3.], [4., 5., 6.]], dtype="f4")} >>> out = RandomFlip(p=1.0, axes=("x",))(data) # p=1 forces an x reflection >>> out["coord"] # x column negated, y and z untouched array([[-1., 2., 3.], [-4., 5., 6.]], dtype=float32)