CenterShift#
- class CenterShift(apply_z=True, axes=('x', 'y', 'z'))[source]#
Bases:
objectCenter
coordon the midpoint of its bounding box per axis.For each requested axis, subtracts the bounding-box midpoint
(min + max) / 2from that coordinate column in place, centering the cloud about the origin axis-by-axis. The same per-axis shift is applied to v3vertexmetadata and to opt-inaux_position_keys. Requirescoord; a no-op ifcoordis absent. Registered asCenterShift– use this string as thetypein atransform=[...]config list.- Parameters:
apply_z (bool) – retained for backward compatibility; the axes actually centered are controlled by
axes. Defaults toTrue.axes (str | Sequence[str]) – which of
"x","y","z"to center. A bare string is wrapped into a single-element tuple. Defaults to("x", "y", "z").
Note
Each axis is centered independently using its own min/max, so the result is centered on the bounding-box center rather than the centroid.
Example
>>> import numpy as np >>> from pimm.datasets.transform import CenterShift >>> data = {"coord": np.array([[0., 0., 0.], [10., 4., 8.]], dtype="f4")} >>> out = CenterShift(axes=("x", "y"))(data) # center x,y on bbox midpoint; z untouched >>> out["coord"] array([[-5., -2., 0.], [ 5., 2., 8.]], dtype=float32)