Skip to content

Coordinate

Classes for point coordinates

NormalizeCoord

Normalizes the point cloud into a unit sphere, where the center is the mean of the point set.

This transform expects a dictionary containing:

  • "coord": NumPy array of shape (N, 3) with point coordinates.
Source code in src\augmentation_class.py
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
@TRANSFORMS.register()
class NormalizeCoord:
    """Normalizes the point cloud into a unit sphere, where the center is the mean of the point set.

    This transform expects a dictionary containing:

    * `"coord"`: NumPy array of shape (N, 3) with point coordinates.
    """
    def __call__(self, data_dict: dict) -> dict:
        """Normalizes point cloud coordinates into unit sphere.

        Args:
            data_dict (dict): Input dictionary that contains a "coord" key with a NumPy array of shape (N, 3) representing point coordinates.

        Returns:
            dict: The same dictionary with `"coord"` normalized into a unit sphere.
        """
        if "coord" in data_dict.keys():
            centroid = np.mean(data_dict["coord"], axis=0)
            data_dict["coord"] -= centroid
            # m = np.max(np.sqrt(np.sum(data_dict["coord"] ** 2, axis=1)))
            m = np.sqrt(np.max(np.sum(data_dict["coord"] ** 2, axis=1)))
            data_dict["coord"] = data_dict["coord"] / m

        return data_dict

__call__(data_dict)

Normalizes point cloud coordinates into unit sphere.

Parameters:

Name Type Description Default
data_dict dict

Input dictionary that contains a "coord" key with a NumPy array of shape (N, 3) representing point coordinates.

required

Returns:

Name Type Description
dict dict

The same dictionary with "coord" normalized into a unit sphere.

Source code in src\augmentation_class.py
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
def __call__(self, data_dict: dict) -> dict:
    """Normalizes point cloud coordinates into unit sphere.

    Args:
        data_dict (dict): Input dictionary that contains a "coord" key with a NumPy array of shape (N, 3) representing point coordinates.

    Returns:
        dict: The same dictionary with `"coord"` normalized into a unit sphere.
    """
    if "coord" in data_dict.keys():
        centroid = np.mean(data_dict["coord"], axis=0)
        data_dict["coord"] -= centroid
        # m = np.max(np.sqrt(np.sum(data_dict["coord"] ** 2, axis=1)))
        m = np.sqrt(np.max(np.sum(data_dict["coord"] ** 2, axis=1)))
        data_dict["coord"] = data_dict["coord"] / m

    return data_dict

Normalize PC into Unit Sphere Space

Before After

PositiveShift

Shift point coordinates so all values are non-negative.

This transform expects a dictionary containing:

  • "coord": NumPy array of shape (N, 3) with point coordinates.
Source code in src\augmentation_class.py
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
@TRANSFORMS.register()
class PositiveShift:
    """Shift point coordinates so all values are non-negative.

    This transform expects a dictionary containing:

    * `"coord"`: NumPy array of shape (N, 3) with point coordinates.
    """
    def __call__(self, data_dict: dict) -> dict:
        """Moves points so that all coordinate values become non-negative.

        Args:
            data_dict (dict): Input dictionary that must contain a "coord" key
                with a NumPy array of shape (N, 3) representing point
                coordinates.

        Returns:
            dict:
                The same dictionary with "coord" shifted so all values are greater than or equal to zero.
        """
        if "coord" in data_dict.keys():
            coord_min = np.min(data_dict["coord"], axis=0)
            data_dict["coord"] -= coord_min
        return data_dict

__call__(data_dict)

Moves points so that all coordinate values become non-negative.

Parameters:

Name Type Description Default
data_dict dict

Input dictionary that must contain a "coord" key with a NumPy array of shape (N, 3) representing point coordinates.

required

Returns:

Name Type Description
dict dict

The same dictionary with "coord" shifted so all values are greater than or equal to zero.

Source code in src\augmentation_class.py
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
def __call__(self, data_dict: dict) -> dict:
    """Moves points so that all coordinate values become non-negative.

    Args:
        data_dict (dict): Input dictionary that must contain a "coord" key
            with a NumPy array of shape (N, 3) representing point
            coordinates.

    Returns:
        dict:
            The same dictionary with "coord" shifted so all values are greater than or equal to zero.
    """
    if "coord" in data_dict.keys():
        coord_min = np.min(data_dict["coord"], axis=0)
        data_dict["coord"] -= coord_min
    return data_dict

Positive Shift PC

Before After

CenterShift

Translate point coordinates so they are centered around a reference point.

This transform expects a dictionary containing:

  • "coord": NumPy array of shape (N, 3) with point coordinates.

It computes a shift vector and subtracts it from all coordinates in place. There are two ways to define the shift:

  • Mean-based centering (mean=True):
  • The shift is the mean (centroid) of all points along each axis.
  • If apply_z is False, the z-component of the shift is replaced by the minimum z value of the points, so:

    • x and y are centered by their mean.
    • z is shifted so that the lowest point lies at z = 0.
  • Bounding-box centering (mean=False):

  • The shift is the center of the axis-aligned bounding box (AABB), i.e., the midpoint between min and max along each axis.
  • If apply_z is False, the z-component of the shift is set to the minimum z value of the points, so the bottom of the bounding box is at z = 0.

Parameters:

Name Type Description Default
mean bool

If True, use the mean of the coordinates as the shift (centroid). If False, use the center of the bounding box. Defaults to False.

False
apply_z bool

If True, apply the same centering logic to the z-axis as x and y. If False, the z shift is always set to the minimum z value, so the lowest point (or bottom of the bounding box) sits at z = 0. Defaults to True.

True
Source code in src\augmentation_class.py
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
@TRANSFORMS.register()
class CenterShift:
    """Translate point coordinates so they are centered around a reference point.

    This transform expects a dictionary containing:

    * `"coord"`: NumPy array of shape (N, 3) with point coordinates.

    It computes a shift vector and subtracts it from all coordinates in place.
    There are two ways to define the shift:

    * Mean-based centering (``mean=True``):
      - The shift is the mean (centroid) of all points along each axis.
      - If ``apply_z`` is False, the z-component of the shift is replaced by the minimum z value of the points, so:
        - x and y are centered by their mean.
        - z is shifted so that the lowest point lies at z = 0.

    * Bounding-box centering (``mean=False``):
      - The shift is the center of the axis-aligned bounding box (AABB), i.e., the midpoint between min and max along each axis.
      - If ``apply_z`` is False, the z-component of the shift is set to the minimum z value of the points, so the bottom of the bounding box is at z = 0.

    Args:
        mean (bool, optional): If True, use the mean of the coordinates as the
            shift (centroid). If False, use the center of the bounding box.
            Defaults to False.
        apply_z (bool, optional): If True, apply the same centering logic to
            the z-axis as x and y. If False, the z shift is always set to the
            minimum z value, so the lowest point (or bottom of the bounding
            box) sits at z = 0.
            Defaults to True.
    """
    def __init__(self, mean: bool = False, apply_z: bool = True):
        self.mean = mean
        self.apply_z = apply_z

    def __call__(self, data_dict: dict) -> dict:
        """Center the point cloud coordinates in place.

            Args:
                data_dict (dict): Input dictionary that must contain a `"coord"` key with a NumPy array of shape (N, 3) representing point coordinates.

            Returns:
                dict: The same dictionary with `"coord"` translated according to the centering strategy.
        """
        if "coord" in data_dict.keys():
            if self.mean:
                shift = np.mean(data_dict["coord"], axis=0)
                if not self.apply_z:
                    shift[2] = data_dict["coord"].min(axis=0)[2]
            else:
                x_min, y_min, z_min = data_dict["coord"].min(axis=0)
                x_max, y_max, z_max = data_dict["coord"].max(axis=0)
                if self.apply_z:
                    shift = [(x_min + x_max) / 2, (y_min + y_max) / 2, (z_min + z_max) / 2]
                else:
                    shift = [(x_min + x_max) / 2, (y_min + y_max) / 2, z_min]
            data_dict["coord"] -= shift
        return data_dict

__call__(data_dict)

Center the point cloud coordinates in place.

Parameters:

Name Type Description Default
data_dict dict

Input dictionary that must contain a "coord" key with a NumPy array of shape (N, 3) representing point coordinates.

required

Returns:

Name Type Description
dict dict

The same dictionary with "coord" translated according to the centering strategy.

Source code in src\augmentation_class.py
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
def __call__(self, data_dict: dict) -> dict:
    """Center the point cloud coordinates in place.

        Args:
            data_dict (dict): Input dictionary that must contain a `"coord"` key with a NumPy array of shape (N, 3) representing point coordinates.

        Returns:
            dict: The same dictionary with `"coord"` translated according to the centering strategy.
    """
    if "coord" in data_dict.keys():
        if self.mean:
            shift = np.mean(data_dict["coord"], axis=0)
            if not self.apply_z:
                shift[2] = data_dict["coord"].min(axis=0)[2]
        else:
            x_min, y_min, z_min = data_dict["coord"].min(axis=0)
            x_max, y_max, z_max = data_dict["coord"].max(axis=0)
            if self.apply_z:
                shift = [(x_min + x_max) / 2, (y_min + y_max) / 2, (z_min + z_max) / 2]
            else:
                shift = [(x_min + x_max) / 2, (y_min + y_max) / 2, z_min]
        data_dict["coord"] -= shift
    return data_dict

Center Shift PC

Before After

RandomShift

Randomly translate point coordinates along the x, y, and z axes.

This transform expects a dictionary containing:

  • "coord": NumPy array of shape (N, 3) with point coordinates.

It samples a random shift for each axis from the corresponding interval in shift and adds it to all points in place.

Parameters:

Name Type Description Default
shift tuple[tuple[float, float], tuple[float, float], tuple[float, float]]

A tuple of three (min, max) pairs controlling the uniform sampling range of the shift per axis:

  • shift[0] → (x_min, x_max) for the x-axis shift.
  • shift[1] → (y_min, y_max) for the y-axis shift.
  • shift[2] → (z_min, z_max) for the z-axis shift.

Each shift value is sampled from a uniform distribution: np.random.uniform(min, max).

With the default configuration:

  • x ~ U(-0.02, 0.02)
  • y ~ U(-0.02, 0.02)
  • z ~ U( 0.02, 0.02)

Defaults to ((-0.02, 0.02), (-0.02, 0.02), (0.02, 0.02)).

((-0.02, 0.02), (-0.02, 0.02), (0.02, 0.02))
apply_p float

Probability of applying the random shift. Defaults to 1.0.

1.0
Source code in src\augmentation_class.py
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
@TRANSFORMS.register()
class RandomShift:
    """Randomly translate point coordinates along the x, y, and z axes.

    This transform expects a dictionary containing:

    * `"coord"`: NumPy array of shape (N, 3) with point coordinates.

    It samples a random shift for each axis from the corresponding interval in `shift` and adds it to all points in place.

    Args:
        shift (tuple[tuple[float, float], tuple[float, float], tuple[float, float]], optional):
            A tuple of three `(min, max)` pairs controlling the uniform sampling
            range of the shift per axis:

            * `shift[0]` → (x_min, x_max) for the x-axis shift.
            * `shift[1]` → (y_min, y_max) for the y-axis shift.
            * `shift[2]` → (z_min, z_max) for the z-axis shift.

            Each shift value is sampled from a uniform distribution:
            `np.random.uniform(min, max)`.

            With the default configuration:

            * x ~ U(-0.02, 0.02)
            * y ~ U(-0.02, 0.02)
            * z ~ U( 0.02, 0.02)

            Defaults to `((-0.02, 0.02), (-0.02, 0.02), (0.02, 0.02))`.
        apply_p (float, optional): Probability of applying the random shift.
            Defaults to 1.0.
    """
    def __init__(self, shift: tuple[tuple[float, float]] = ((-0.02, 0.02), (-0.02, 0.02), (0.02, 0.02)), apply_p: float = 1.0):
        self.shift = shift
        self.apply_p = apply_p

    def __call__(self, data_dict: dict) -> dict:
        """Apply a random global shift to the point coordinates.

        Args:
            data_dict (dict): Input dictionary that must contain a `"coord"` key
                with a NumPy array of shape (N, 3) representing point
                coordinates.

        Returns:
            dict: The same dictionary with `"coord"` translated by a random shift vector, if applied.
        """
        if random.random() > self.apply_p:
            return data_dict

        if "coord" in data_dict.keys():
            shift_x = np.random.uniform(self.shift[0][0], self.shift[0][1])
            shift_y = np.random.uniform(self.shift[1][0], self.shift[1][1])
            shift_z = np.random.uniform(self.shift[2][0], self.shift[2][1])
            data_dict["coord"] += [shift_x, shift_y, shift_z]
        return data_dict

__call__(data_dict)

Apply a random global shift to the point coordinates.

Parameters:

Name Type Description Default
data_dict dict

Input dictionary that must contain a "coord" key with a NumPy array of shape (N, 3) representing point coordinates.

required

Returns:

Name Type Description
dict dict

The same dictionary with "coord" translated by a random shift vector, if applied.

Source code in src\augmentation_class.py
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
def __call__(self, data_dict: dict) -> dict:
    """Apply a random global shift to the point coordinates.

    Args:
        data_dict (dict): Input dictionary that must contain a `"coord"` key
            with a NumPy array of shape (N, 3) representing point
            coordinates.

    Returns:
        dict: The same dictionary with `"coord"` translated by a random shift vector, if applied.
    """
    if random.random() > self.apply_p:
        return data_dict

    if "coord" in data_dict.keys():
        shift_x = np.random.uniform(self.shift[0][0], self.shift[0][1])
        shift_y = np.random.uniform(self.shift[1][0], self.shift[1][1])
        shift_z = np.random.uniform(self.shift[2][0], self.shift[2][1])
        data_dict["coord"] += [shift_x, shift_y, shift_z]
    return data_dict

Random Shift PC

Before After

RandomRotate

Randomly rotate 3D points (and optionally normals) around a given axis.

This transform expects a dictionary containing:

  • "coord": NumPy array of shape (N, 3) with point coordinates.
  • Optionally "norm": NumPy array of shape (N, 3) with normals associated with each point.

The transform samples a rotation angle (in degrees) from angle, builds a rotation matrix around the specified axis, and applies it to the coordinates (and normals, if present). The rotation is applied around a center point:

  • If center is None, the rotation center is taken as the center of the axis-aligned bounding box (AABB) of the coordinates.
  • If center is provided, it is used directly as the rotation center.

Parameters:

Name Type Description Default
angle tuple[float, float] | None

A (min_deg, max_deg) pair specifying the range of rotation angles in degrees. The actual angle is sampled uniformly from this interval and converted to radians internally. If None (default), it is set to (-180, 180). For example, angle=(-10, 10) means a random rotation between -10° and +10°. Defaults to None.

None
center tuple[float, float, float] | ndarray | None

Rotation center in 3D, given as a 3-element tuple or NumPy array (cx, cy, cz). If None (default), the center of the bounding box of data_dict["coord"] is used: center = ((x_min+x_max)/2, (y_min+y_max)/2, (z_min+z_max)/2). Defaults to None.

None
axis str

Axis (or axes) around which the rotation is applied. One of "x", "y", "z", or "xyz".

  • "x": single rotation around the x-axis.
  • "y": single rotation around the y-axis.
  • "z": single rotation around the z-axis.
  • "xyz": three independent random rotations are sampled (one for x, one for y, one for z), and the final rotation matrix is computed as R = R_z @ R_y @ R_x.

In all cases, angles are sampled (in degrees) from the same angle range. Defaults to "y".

'y'
apply_p float

Probability of applying the rotation. Defaults to 1.0.

1.0
Source code in src\augmentation_class.py
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
@TRANSFORMS.register()
class RandomRotate:
    """Randomly rotate 3D points (and optionally normals) around a given axis.

    This transform expects a dictionary containing:

    * `"coord"`: NumPy array of shape (N, 3) with point coordinates.
    * Optionally `"norm"`: NumPy array of shape (N, 3) with normals associated with each point.

    The transform samples a rotation angle (in degrees) from `angle`, builds a rotation matrix around the specified axis,
    and applies it to the coordinates (and normals, if present). The rotation is applied around a center point:

    * If `center` is ``None``, the rotation center is taken as the center of the axis-aligned bounding box (AABB) of the coordinates.
    * If `center` is provided, it is used directly as the rotation center.

    Args:
        angle (tuple[float, float] | None, optional):
            A `(min_deg, max_deg)` pair specifying the range of rotation angles in degrees. The actual angle is sampled
            uniformly from this interval and converted to radians internally. If ``None`` (default), it is set to
            `(-180, 180)`. For example, `angle=(-10, 10)` means a random
            rotation between -10° and +10°.
            Defaults to None.
        center (tuple[float, float, float] | np.ndarray | None, optional):
            Rotation center in 3D, given as a 3-element tuple or NumPy array
            `(cx, cy, cz)`. If ``None`` (default), the center of the bounding
            box of `data_dict["coord"]` is used:
            `center = ((x_min+x_max)/2, (y_min+y_max)/2, (z_min+z_max)/2)`.
            Defaults to None.
        axis (str, optional):
            Axis (or axes) around which the rotation is applied. One of `"x"`, `"y"`, `"z"`, or `"xyz"`.

            * `"x"`: single rotation around the x-axis.
            * `"y"`: single rotation around the y-axis.
            * `"z"`: single rotation around the z-axis.
            * `"xyz"`: three independent random rotations are sampled
              (one for x, one for y, one for z), and the final rotation
              matrix is computed as `R = R_z @ R_y @ R_x`.

            In all cases, angles are sampled (in degrees) from the same
            `angle` range.
            Defaults to `"y"`.
        apply_p (float, optional): Probability of applying the rotation.
            Defaults to 1.0.
        """
    def __init__(self,
                 angle: tuple = None,
                 center: tuple | np.ndarray = None,
                 axis: str = 'y',
                 apply_p: float = 1.0,
                 ) -> None:

        self.angle = (-180, 180) if angle is None else angle
        self.center = np.array(center) if center is not None else center
        self.axis = axis
        self.apply_p = apply_p

    def __call__(self, data_dict: dict) -> dict:
        """Apply a random rotation to coordinates (and normals, if present).

        Args:
            data_dict (dict): Input dictionary that must contain a `"coord"` key with a NumPy array of shape (N, 3)
                representing point coordinates. Optionally may contain `"norm"` with a NumPy array of shape (N, 3)
                representing normal vectors.

        Returns:
            dict: The same dictionary with `"coord"` rotated around the chosen center, and `"norm"` rotated if present.
        """
        if random.random() > self.apply_p:
            return data_dict

        # angle = np.random.uniform(self.angle[0], self.angle[1]) * np.pi
        angle = np.random.uniform(self.angle[0], self.angle[1])
        angle = np.deg2rad(angle)
        rot_cos, rot_sin = np.cos(angle), np.sin(angle)
        if self.axis == 'x':
            rot_t = np.array([[1, 0, 0], [0, rot_cos, -rot_sin], [0, rot_sin, rot_cos]])
        elif self.axis == 'y':
            rot_t = np.array([[rot_cos, 0, rot_sin], [0, 1, 0], [-rot_sin, 0, rot_cos]])
        elif self.axis == 'z':
            rot_t = np.array([[rot_cos, -rot_sin, 0], [rot_sin, rot_cos, 0], [0, 0, 1]])
        elif self.axis == "xyz":
            angle = np.random.uniform(self.angle[0], self.angle[1])
            angle = np.deg2rad(angle)
            rot_cos, rot_sin = np.cos(angle), np.sin(angle)
            rot_x = np.array([[1, 0, 0], [0, rot_cos, -rot_sin], [0, rot_sin, rot_cos]])

            angle = np.random.uniform(self.angle[0], self.angle[1])
            angle = np.deg2rad(angle)
            rot_cos, rot_sin = np.cos(angle), np.sin(angle)
            rot_y = np.array([[rot_cos, 0, rot_sin], [0, 1, 0], [-rot_sin, 0, rot_cos]])

            angle = np.random.uniform(self.angle[0], self.angle[1])
            angle = np.deg2rad(angle)
            rot_cos, rot_sin = np.cos(angle), np.sin(angle)
            rot_z = np.array([[rot_cos, -rot_sin, 0], [rot_sin, rot_cos, 0], [0, 0, 1]])
            rot_t = rot_z @ rot_y @ rot_x
        else:
            raise NotImplementedError

        if "coord" in data_dict.keys():
            if self.center is None:
                # rotate by the center point
                x_min, y_min, z_min = data_dict["coord"].min(axis=0)
                x_max, y_max, z_max = data_dict["coord"].max(axis=0)
                center = [(x_min + x_max) / 2, (y_min + y_max) / 2, (z_min + z_max) / 2]
            else:
                center = self.center
            data_dict["coord"] -= center
            data_dict["coord"] = np.dot(data_dict["coord"], np.transpose(rot_t))
            data_dict["coord"] += center

        if "norm" in data_dict.keys():
            data_dict["norm"] = np.dot(data_dict["norm"], np.transpose(rot_t))

        return data_dict

__call__(data_dict)

Apply a random rotation to coordinates (and normals, if present).

Parameters:

Name Type Description Default
data_dict dict

Input dictionary that must contain a "coord" key with a NumPy array of shape (N, 3) representing point coordinates. Optionally may contain "norm" with a NumPy array of shape (N, 3) representing normal vectors.

required

Returns:

Name Type Description
dict dict

The same dictionary with "coord" rotated around the chosen center, and "norm" rotated if present.

Source code in src\augmentation_class.py
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
def __call__(self, data_dict: dict) -> dict:
    """Apply a random rotation to coordinates (and normals, if present).

    Args:
        data_dict (dict): Input dictionary that must contain a `"coord"` key with a NumPy array of shape (N, 3)
            representing point coordinates. Optionally may contain `"norm"` with a NumPy array of shape (N, 3)
            representing normal vectors.

    Returns:
        dict: The same dictionary with `"coord"` rotated around the chosen center, and `"norm"` rotated if present.
    """
    if random.random() > self.apply_p:
        return data_dict

    # angle = np.random.uniform(self.angle[0], self.angle[1]) * np.pi
    angle = np.random.uniform(self.angle[0], self.angle[1])
    angle = np.deg2rad(angle)
    rot_cos, rot_sin = np.cos(angle), np.sin(angle)
    if self.axis == 'x':
        rot_t = np.array([[1, 0, 0], [0, rot_cos, -rot_sin], [0, rot_sin, rot_cos]])
    elif self.axis == 'y':
        rot_t = np.array([[rot_cos, 0, rot_sin], [0, 1, 0], [-rot_sin, 0, rot_cos]])
    elif self.axis == 'z':
        rot_t = np.array([[rot_cos, -rot_sin, 0], [rot_sin, rot_cos, 0], [0, 0, 1]])
    elif self.axis == "xyz":
        angle = np.random.uniform(self.angle[0], self.angle[1])
        angle = np.deg2rad(angle)
        rot_cos, rot_sin = np.cos(angle), np.sin(angle)
        rot_x = np.array([[1, 0, 0], [0, rot_cos, -rot_sin], [0, rot_sin, rot_cos]])

        angle = np.random.uniform(self.angle[0], self.angle[1])
        angle = np.deg2rad(angle)
        rot_cos, rot_sin = np.cos(angle), np.sin(angle)
        rot_y = np.array([[rot_cos, 0, rot_sin], [0, 1, 0], [-rot_sin, 0, rot_cos]])

        angle = np.random.uniform(self.angle[0], self.angle[1])
        angle = np.deg2rad(angle)
        rot_cos, rot_sin = np.cos(angle), np.sin(angle)
        rot_z = np.array([[rot_cos, -rot_sin, 0], [rot_sin, rot_cos, 0], [0, 0, 1]])
        rot_t = rot_z @ rot_y @ rot_x
    else:
        raise NotImplementedError

    if "coord" in data_dict.keys():
        if self.center is None:
            # rotate by the center point
            x_min, y_min, z_min = data_dict["coord"].min(axis=0)
            x_max, y_max, z_max = data_dict["coord"].max(axis=0)
            center = [(x_min + x_max) / 2, (y_min + y_max) / 2, (z_min + z_max) / 2]
        else:
            center = self.center
        data_dict["coord"] -= center
        data_dict["coord"] = np.dot(data_dict["coord"], np.transpose(rot_t))
        data_dict["coord"] += center

    if "norm" in data_dict.keys():
        data_dict["norm"] = np.dot(data_dict["norm"], np.transpose(rot_t))

    return data_dict

Random Rotate PC

Before After

RandomScale

Randomly scale 3D coordinates uniformly or per-axis.

This transform expects a dictionary containing:

  • "coord": NumPy array of shape (N, 3) with point coordinates.

It samples a scale factor (or factors) from scale and multiplies the coordinates in place.

Parameters:

Name Type Description Default
scale list[float, float] | tuple[float, float]

A (min_scale, max_scale) pair used as the uniform sampling range for the scale factor(s). Values are drawn from np.random.uniform(min_scale, max_scale, size=...).

Examples: * scale=(0.95, 1.05) → small random resize around 1.0. * scale=(0.5, 1.5) → more aggressive zoom in/out.

Defaults to (0.95, 1.05).

(0.95, 1.05)
anisotropic bool

Controls whether scaling is uniform or per-axis.

  • False: Sample a single scalar s and apply coord *= s.
  • True: Sample a 3D vector [sx, sy, sz] and apply coord *= [sx, sy, sz].

Defaults to False.

False
apply_p float

Probability of applying the random scaling. Defaults to 1.0.

1.0
Source code in src\augmentation_class.py
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
@TRANSFORMS.register()
class RandomScale:
    """Randomly scale 3D coordinates uniformly or per-axis.

    This transform expects a dictionary containing:

    * `"coord"`: NumPy array of shape (N, 3) with point coordinates.

    It samples a scale factor (or factors) from `scale` and multiplies the coordinates in place.

    Args:
        scale (list[float, float] | tuple[float, float], optional):
            A `(min_scale, max_scale)` pair used as the uniform sampling range for the scale factor(s). Values are drawn from
            `np.random.uniform(min_scale, max_scale, size=...)`.

            Examples:
                * `scale=(0.95, 1.05)` → small random resize around 1.0.
                * `scale=(0.5, 1.5)` → more aggressive zoom in/out.

            Defaults to `(0.95, 1.05)`.
        anisotropic (bool, optional): Controls whether scaling is uniform or
            per-axis.

            * `False`: Sample a single scalar `s` and apply `coord *= s`.
            * `True`: Sample a 3D vector `[sx, sy, sz]` and apply
              `coord *= [sx, sy, sz]`.

            Defaults to `False`.
        apply_p (float, optional):
            Probability of applying the random scaling.
            Defaults to 1.0.
        """
    def __init__(self, scale: list | tuple = (0.95, 1.05), anisotropic: bool = False, apply_p: float = 1.0) -> None:
        self.scale = scale
        self.anisotropic = anisotropic  # create separate scale parameters or only one parameter
        self.apply_p = apply_p

    def __call__(self, data_dict: dict) -> dict:
        """Apply a random scaling to the point coordinates.

        Args:
            data_dict (dict): Input dictionary that must contain a `"coord"` key with a NumPy array of shape (N, 3)
                representing point coordinates.

        Returns:
            dict: The same dictionary with `"coord"` scaled by a random factor (uniform or per-axis), if applied.
        """
        if random.random() > self.apply_p:
            return data_dict
        if "coord" in data_dict.keys():
            scale = np.random.uniform(self.scale[0], self.scale[1], size=3 if self.anisotropic else 1)
            # print(scale)
            data_dict["coord"] *= scale
        return data_dict

__call__(data_dict)

Apply a random scaling to the point coordinates.

Parameters:

Name Type Description Default
data_dict dict

Input dictionary that must contain a "coord" key with a NumPy array of shape (N, 3) representing point coordinates.

required

Returns:

Name Type Description
dict dict

The same dictionary with "coord" scaled by a random factor (uniform or per-axis), if applied.

Source code in src\augmentation_class.py
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
def __call__(self, data_dict: dict) -> dict:
    """Apply a random scaling to the point coordinates.

    Args:
        data_dict (dict): Input dictionary that must contain a `"coord"` key with a NumPy array of shape (N, 3)
            representing point coordinates.

    Returns:
        dict: The same dictionary with `"coord"` scaled by a random factor (uniform or per-axis), if applied.
    """
    if random.random() > self.apply_p:
        return data_dict
    if "coord" in data_dict.keys():
        scale = np.random.uniform(self.scale[0], self.scale[1], size=3 if self.anisotropic else 1)
        # print(scale)
        data_dict["coord"] *= scale
    return data_dict

Random Scale PC

Before After

RandomTranslate

Randomly translate 3D coordinates by the same offset vector along x, y, z.

This transform expects a dictionary containing:

  • "coord": NumPy array of shape (N, 3) with point coordinates.

It samples a translation vector [tx, ty, tz] from the given range and adds it to all coordinates in place.

Parameters:

Name Type Description Default
translate_range tuple[float, float]

A (min_translate, max_translate) pair specifying the uniform sampling range for each axis. The translation vector is drawn as::

translate = np.random.uniform(min_translate, max_translate, size=3)

That is:

  • tx ~ U(min_translate, max_translate)
  • ty ~ U(min_translate, max_translate)
  • tz ~ U(min_translate, max_translate)

Defaults to (-0.2, 0.2).

(-0.2, 0.2)
apply_p float

Probability of applying the translation. Defaults to 1.0.

1.0
Source code in src\augmentation_class.py
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
@TRANSFORMS.register()
class RandomTranslate:
    """Randomly translate 3D coordinates by the same offset vector along x, y, z.

    This transform expects a dictionary containing:

    * `"coord"`: NumPy array of shape (N, 3) with point coordinates.

    It samples a translation vector `[tx, ty, tz]` from the given range and adds it to all coordinates in place.

    Args:
        translate_range (tuple[float, float], optional):
            A `(min_translate, max_translate)` pair specifying the uniform sampling range for each axis.
            The translation vector is drawn as::

            translate = np.random.uniform(min_translate, max_translate, size=3)

            That is:

            * `tx ~ U(min_translate, max_translate)`
            * `ty ~ U(min_translate, max_translate)`
            * `tz ~ U(min_translate, max_translate)`

            Defaults to `(-0.2, 0.2)`.
        apply_p (float, optional):
            Probability of applying the translation.
            Defaults to 1.0.
    """
    def __init__(self, translate_range: tuple = (-0.2, 0.2), apply_p: float = 1.0):
        self.translate_range = translate_range
        self.apply_p = apply_p

    def __call__(self, data_dict: dict) -> dict:
        """Apply a random global translation to the point coordinates.

        Args:
            data_dict (dict): Input dictionary that must contain a `"coord"` key with a NumPy array of shape (N, 3)
                representing point coordinates.

        Returns:
            dict: The same dictionary with `"coord"` translated by a random offset vector, if applied.
        """
        if random.random() > self.apply_p:
            return data_dict

        if "coord" in data_dict.keys():
            translate = np.random.uniform(self.translate_range[0], self.translate_range[1], size=3)
            data_dict["coord"] += translate
        return data_dict

__call__(data_dict)

Apply a random global translation to the point coordinates.

Parameters:

Name Type Description Default
data_dict dict

Input dictionary that must contain a "coord" key with a NumPy array of shape (N, 3) representing point coordinates.

required

Returns:

Name Type Description
dict dict

The same dictionary with "coord" translated by a random offset vector, if applied.

Source code in src\augmentation_class.py
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
def __call__(self, data_dict: dict) -> dict:
    """Apply a random global translation to the point coordinates.

    Args:
        data_dict (dict): Input dictionary that must contain a `"coord"` key with a NumPy array of shape (N, 3)
            representing point coordinates.

    Returns:
        dict: The same dictionary with `"coord"` translated by a random offset vector, if applied.
    """
    if random.random() > self.apply_p:
        return data_dict

    if "coord" in data_dict.keys():
        translate = np.random.uniform(self.translate_range[0], self.translate_range[1], size=3)
        data_dict["coord"] += translate
    return data_dict

Random Translate PC

Before After

RandomJitter

Add small Gaussian noise to 3D coordinates (point-wise jitter).

This transform expects a dictionary containing:

  • "coord": NumPy array of shape (N, 3) with point coordinates.

It samples Gaussian noise for each point and each axis, scales it by sigma, clips it to [-clip, clip], and adds it to the coordinates in place.

Parameters:

Name Type Description Default
sigma float

Standard deviation of the Gaussian noise before clipping. Noise is drawn as:

jitter_raw ~ N(0, sigma^2)

per coordinate. Defaults to 0.01.

0.01
clip float

Maximum absolute value for the jitter. After sampling, the noise is clipped to the range [-clip, clip]:

jitter = np.clip(jitter_raw, -clip, clip)

Must be positive. Defaults to 0.05.

0.05
apply_p float

Probability of applying the jitter. Defaults to 1.0.

1.0
Source code in src\augmentation_class.py
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
@TRANSFORMS.register()
class RandomJitter:
    """Add small Gaussian noise to 3D coordinates (point-wise jitter).

    This transform expects a dictionary containing:

    * `"coord"`: NumPy array of shape (N, 3) with point coordinates.

    It samples Gaussian noise for each point and each axis, scales it by `sigma`, clips it to `[-clip, clip]`, and
    adds it to the coordinates in place.

    Args:
        sigma (float, optional):
            Standard deviation of the Gaussian noise before clipping. Noise is drawn as:

                jitter_raw ~ N(0, sigma^2)

            per coordinate.
            Defaults to 0.01.
        clip (float, optional):
            Maximum absolute value for the jitter. After sampling, the noise is clipped to the range `[-clip, clip]`:

                jitter = np.clip(jitter_raw, -clip, clip)

            Must be positive.
            Defaults to 0.05.
        apply_p (float, optional):
            Probability of applying the jitter.
            Defaults to 1.0.
    """
    def __init__(self, sigma: float = 0.01, clip: float = 0.05, apply_p: float = 1.0):
        assert (clip > 0)
        self.sigma = sigma
        self.clip = clip
        self.apply_p = apply_p

    def __call__(self, data_dict: dict) -> dict:
        """Apply point-wise Gaussian jitter to the point coordinates.

        Args:
            data_dict (dict): Input dictionary that must contain a `"coord"` key with a NumPy array of shape (N, 3)
                representing point coordinates.

        Returns:
            dict: The same dictionary with `"coord"` perturbed by clipped Gaussian noise, if applied.
        """
        if random.random() > self.apply_p:
            return data_dict

        if "coord" in data_dict.keys():
            jitter = np.clip(self.sigma * np.random.randn(data_dict["coord"].shape[0], 3), -self.clip, self.clip)
            data_dict["coord"] += jitter
        return data_dict

__call__(data_dict)

Apply point-wise Gaussian jitter to the point coordinates.

Parameters:

Name Type Description Default
data_dict dict

Input dictionary that must contain a "coord" key with a NumPy array of shape (N, 3) representing point coordinates.

required

Returns:

Name Type Description
dict dict

The same dictionary with "coord" perturbed by clipped Gaussian noise, if applied.

Source code in src\augmentation_class.py
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
def __call__(self, data_dict: dict) -> dict:
    """Apply point-wise Gaussian jitter to the point coordinates.

    Args:
        data_dict (dict): Input dictionary that must contain a `"coord"` key with a NumPy array of shape (N, 3)
            representing point coordinates.

    Returns:
        dict: The same dictionary with `"coord"` perturbed by clipped Gaussian noise, if applied.
    """
    if random.random() > self.apply_p:
        return data_dict

    if "coord" in data_dict.keys():
        jitter = np.clip(self.sigma * np.random.randn(data_dict["coord"].shape[0], 3), -self.clip, self.clip)
        data_dict["coord"] += jitter
    return data_dict

Random Jitter PC

Before After

RandomFlip

Randomly flip point coordinates (and normals) by sign along selected axes.

This transform expects a dictionary containing:

  • "coord": NumPy array of shape (N, 3) with point coordinates.
  • Optionally "norm": NumPy array of shape (N, 3) with normals associated with each point.

Given the axes in flip_axis, each axis may be flipped by multiplying the corresponding coordinate (and normal, if present) by -1.

Parameters:

Name Type Description Default
flip_axis tuple[int, ...]

Indices of axes to consider for flipping. Each element must be in {0, 1, 2}:

  • 0 → x-axis
  • 1 → y-axis
  • 2 → z-axis

For each axis in this tuple, a random decision is made (with probability apply_p) whether to flip that axis.

Examples: * flip_axis=(0,) → only possible flip is x-axis. * flip_axis=(1, 2) → y and z axes may be flipped independently.

Defaults to (0, 2).

(0, 2)
apply_p float

Probability of flipping each axis. Defaults to 1.0.

1.0
Source code in src\augmentation_class.py
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
@TRANSFORMS.register()
class RandomFlip:
    """Randomly flip point coordinates (and normals) by sign along selected axes.

    This transform expects a dictionary containing:

    * `"coord"`: NumPy array of shape (N, 3) with point coordinates.
    * Optionally `"norm"`: NumPy array of shape (N, 3) with normals
      associated with each point.

    Given the axes in `flip_axis`, each axis may be flipped by multiplying
    the corresponding coordinate (and normal, if present) by -1.

    Args:
        flip_axis (tuple[int, ...], optional):
            Indices of axes to consider for flipping. Each element must be in `{0, 1, 2}`:

            * `0` → x-axis
            * `1` → y-axis
            * `2` → z-axis

            For each axis in this tuple, a random decision is made (with
            probability `apply_p`) whether to flip that axis.

            Examples:
                * `flip_axis=(0,)` → only possible flip is x-axis.
                * `flip_axis=(1, 2)` → y and z axes may be flipped
                  independently.

            Defaults to `(0, 2)`.
        apply_p (float, optional):
            Probability of flipping **each** axis.
            Defaults to 1.0.
    """
    def __init__(self, flip_axis: tuple = (0, 2), apply_p: float = 1.0) -> None:
        self.flip_axis = flip_axis
        self.apply_p = apply_p

    def __call__(self, data_dict: dict) -> dict:
        """Apply random sign flips along selected axes to coords (and normals).

        Args:
            data_dict (dict): Input dictionary that should contain a `"coord"` key with a NumPy array of shape (N, 3)
                representing point coordinates. Optionally may contain a `"norm"` key with a NumPy array of shape (N, 3)
                representing normal vectors.

        Returns:
            dict: The same dictionary with `"coord"` (and `"norm"` if present) potentially flipped by sign along the
                specified axes.
        """
        for axis in self.flip_axis:
            if np.random.rand() < self.apply_p:
                if "coord" in data_dict.keys():
                    data_dict["coord"][:, axis] = -data_dict["coord"][:, axis]
                if "norm" in data_dict.keys():
                    data_dict["norm"][:, axis] = -data_dict["norm"][:, axis]

        return data_dict

__call__(data_dict)

Apply random sign flips along selected axes to coords (and normals).

Parameters:

Name Type Description Default
data_dict dict

Input dictionary that should contain a "coord" key with a NumPy array of shape (N, 3) representing point coordinates. Optionally may contain a "norm" key with a NumPy array of shape (N, 3) representing normal vectors.

required

Returns:

Name Type Description
dict dict

The same dictionary with "coord" (and "norm" if present) potentially flipped by sign along the specified axes.

Source code in src\augmentation_class.py
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
def __call__(self, data_dict: dict) -> dict:
    """Apply random sign flips along selected axes to coords (and normals).

    Args:
        data_dict (dict): Input dictionary that should contain a `"coord"` key with a NumPy array of shape (N, 3)
            representing point coordinates. Optionally may contain a `"norm"` key with a NumPy array of shape (N, 3)
            representing normal vectors.

    Returns:
        dict: The same dictionary with `"coord"` (and `"norm"` if present) potentially flipped by sign along the
            specified axes.
    """
    for axis in self.flip_axis:
        if np.random.rand() < self.apply_p:
            if "coord" in data_dict.keys():
                data_dict["coord"][:, axis] = -data_dict["coord"][:, axis]
            if "norm" in data_dict.keys():
                data_dict["norm"][:, axis] = -data_dict["norm"][:, axis]

    return data_dict

Random Flip PC

Before After

RandomDropout

Randomly drop a subset of points (and aligned per-point attributes).

This transform expects a dictionary containing:

  • "coord": NumPy array of shape (N, 3) with point coordinates.
  • Optionally other per-point arrays (e.g., "norm", "color", "label") that have length N along the first dimension.

Parameters:

Name Type Description Default
max_dropout_ratio float

Maximum fraction of points that may be dropped. The actual dropout ratio is drawn from:

ratio ~ U(0, max_dropout_ratio)

For example, if max_dropout_ratio = 0.2, then up to 20% of points can be removed in any application of this transform. Defaults to 0.2.

0.2
apply_p float

Probability of applying the dropout. Defaults to 1.0.

1.0
Source code in src\augmentation_class.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
@TRANSFORMS.register()
class RandomDropout:
    """Randomly drop a subset of points (and aligned per-point attributes).

    This transform expects a dictionary containing:

    * `"coord"`: NumPy array of shape (N, 3) with point coordinates.
    * Optionally other per-point arrays (e.g., `"norm"`, `"color"`, `"label"`)
      that have length N along the first dimension.

    Args:
        max_dropout_ratio (float, optional):
            Maximum fraction of points that may be dropped. The actual dropout ratio is drawn from:

                ratio ~ U(0, max_dropout_ratio)

            For example, if `max_dropout_ratio = 0.2`, then up to 20% of
            points can be removed in any application of this transform.
            Defaults to 0.2.
        apply_p (float, optional):
            Probability of applying the dropout.
            Defaults to 1.0.
    """
    def __init__(self, max_dropout_ratio: float = 0.2, apply_p: float = 1.0):
        self.max_dropout_ratio = max_dropout_ratio
        self.apply_p = apply_p

    def __call__(self, data_dict: dict) -> dict:
        """Apply random point dropout to coords and aligned attributes.

        Args:
            data_dict (dict): Input dictionary that must contain a `"coord"` key with a NumPy array of shape (N, 3).
                Any other entry whose value is a NumPy array or `Sequence` of length N and whose key does not contain
                `"origin"` will also be subsampled.

        Returns:
            dict: The same dictionary with a subset of points (and aligned per-point attributes) kept, if dropout is applied.
        """
        if random.random() > self.apply_p:
            return data_dict

        if "coord" in data_dict.keys():
            n = len(data_dict["coord"])
            ratio = np.random.uniform(0, self.max_dropout_ratio)
            size = int(n * (1 - ratio))
            assert size > 0
            idx = np.random.choice(n, size, replace=False)
            for key, value in data_dict.items():
                if isinstance(value, (np.ndarray, Sequence)) and len(value) == n and "origin" not in key:
                    data_dict[key] = value[idx]

        return data_dict

__call__(data_dict)

Apply random point dropout to coords and aligned attributes.

Parameters:

Name Type Description Default
data_dict dict

Input dictionary that must contain a "coord" key with a NumPy array of shape (N, 3). Any other entry whose value is a NumPy array or Sequence of length N and whose key does not contain "origin" will also be subsampled.

required

Returns:

Name Type Description
dict dict

The same dictionary with a subset of points (and aligned per-point attributes) kept, if dropout is applied.

Source code in src\augmentation_class.py
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
def __call__(self, data_dict: dict) -> dict:
    """Apply random point dropout to coords and aligned attributes.

    Args:
        data_dict (dict): Input dictionary that must contain a `"coord"` key with a NumPy array of shape (N, 3).
            Any other entry whose value is a NumPy array or `Sequence` of length N and whose key does not contain
            `"origin"` will also be subsampled.

    Returns:
        dict: The same dictionary with a subset of points (and aligned per-point attributes) kept, if dropout is applied.
    """
    if random.random() > self.apply_p:
        return data_dict

    if "coord" in data_dict.keys():
        n = len(data_dict["coord"])
        ratio = np.random.uniform(0, self.max_dropout_ratio)
        size = int(n * (1 - ratio))
        assert size > 0
        idx = np.random.choice(n, size, replace=False)
        for key, value in data_dict.items():
            if isinstance(value, (np.ndarray, Sequence)) and len(value) == n and "origin" not in key:
                data_dict[key] = value[idx]

    return data_dict

Random Dropout PC

Before After

ShufflePoint

Randomly permute the order of points (and aligned per-point attributes).

This transform expects a dictionary containing:

  • "coord": NumPy array of shape (N, 3) with point coordinates.
  • Optionally other per-point arrays (e.g., "norm", "color", "label") that have length N along the first dimension.

All per-point arrays of matching length are shuffled with the same permutation, preserving correspondence between them.

Parameters:

Name Type Description Default
apply_p float

Probability of applying the shuffling. Defaults to 1.0.

1.0
Source code in src\augmentation_class.py
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
@TRANSFORMS.register()
class ShufflePoint:
    """Randomly permute the order of points (and aligned per-point attributes).

    This transform expects a dictionary containing:

    * `"coord"`: NumPy array of shape (N, 3) with point coordinates.
    * Optionally other per-point arrays (e.g., `"norm"`, `"color"`, `"label"`) that have length N along the first dimension.

    All per-point arrays of matching length are shuffled with the same
    permutation, preserving correspondence between them.

    Args:
        apply_p (float, optional):
            Probability of applying the shuffling.
            Defaults to 1.0.
    """
    def __init__(self, apply_p: float = 1.0):
        self.apply_p = apply_p

    def __call__(self, data_dict: dict) -> dict:
        """Shuffle the order of points and aligned per-point attributes.

        Args:
            data_dict (dict): Input dictionary that must contain a `"coord"` key with a NumPy array of shape (N, 3).
                Any other entry whose value is a NumPy array or `Sequence` of length N and whose key does not contain
                `"origin"` will be permuted with the same shuffle indices.

        Returns:
            dict: The same dictionary with `"coord"` and aligned per-point attributes shuffled in order, if applied.
        """
        if random.random() > self.apply_p:
            return data_dict

        if "coord" in data_dict.keys():
            shuffle_index = np.arange(data_dict["coord"].shape[0])
            np.random.shuffle(shuffle_index)
            n_pts = len(shuffle_index)
            # print(data_dict["noise_index"])
            for key, val in data_dict.items():
                if isinstance(val, (np.ndarray, Sequence)) and len(val) == n_pts and "origin" not in key:
                    data_dict[key] = val[shuffle_index]
            # print(data_dict["noise_index"])
        return data_dict

__call__(data_dict)

Shuffle the order of points and aligned per-point attributes.

Parameters:

Name Type Description Default
data_dict dict

Input dictionary that must contain a "coord" key with a NumPy array of shape (N, 3). Any other entry whose value is a NumPy array or Sequence of length N and whose key does not contain "origin" will be permuted with the same shuffle indices.

required

Returns:

Name Type Description
dict dict

The same dictionary with "coord" and aligned per-point attributes shuffled in order, if applied.

Source code in src\augmentation_class.py
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
def __call__(self, data_dict: dict) -> dict:
    """Shuffle the order of points and aligned per-point attributes.

    Args:
        data_dict (dict): Input dictionary that must contain a `"coord"` key with a NumPy array of shape (N, 3).
            Any other entry whose value is a NumPy array or `Sequence` of length N and whose key does not contain
            `"origin"` will be permuted with the same shuffle indices.

    Returns:
        dict: The same dictionary with `"coord"` and aligned per-point attributes shuffled in order, if applied.
    """
    if random.random() > self.apply_p:
        return data_dict

    if "coord" in data_dict.keys():
        shuffle_index = np.arange(data_dict["coord"].shape[0])
        np.random.shuffle(shuffle_index)
        n_pts = len(shuffle_index)
        # print(data_dict["noise_index"])
        for key, val in data_dict.items():
            if isinstance(val, (np.ndarray, Sequence)) and len(val) == n_pts and "origin" not in key:
                data_dict[key] = val[shuffle_index]
        # print(data_dict["noise_index"])
    return data_dict

PointClip

Randomly clip a local region around a randomly chosen point.

This transform expects a dictionary containing:

  • "coord": NumPy array of shape (N, 3) with point coordinates.
  • Optionally other per-point arrays (e.g., "norm", "color", "label") that have length N along the first dimension.

A random point index is selected and its coordinate is used as the center:

center = coord[center_idx]

Then it builds either:

  • a spherical region of radius radius around center if use_sphere=True, or
  • an axis-aligned box centered at center with half-extent box_range if use_sphere=False.

Only points inside this region are kept; all others are dropped. All aligned per-point attributes are filtered with the same mask.

Parameters:

Name Type Description Default
use_sphere bool

If True, use a spherical region. For each point p, compute squared distance:

dist2 = ||p - center||^2

and keep points with dist2 <= radius^2. If False, use an axis-aligned box instead. Defaults to True.

True
radius float

Radius of the sphere used when use_sphere=True. The clipped region is:

{ p : ||p - center|| <= radius }

Defaults to 1.0.

1.0
box_range tuple[float, float, float]

Half-extent of the axis-aligned box along each axis, used when use_sphere=False. Interpreted as (rx, ry, rz). The box is defined as:

  • x_min, y_min, z_min = center - box_range
  • x_max, y_max, z_max = center + box_range

A point p = (x, y, z) is kept if:

x_min <= x <= x_max
y_min <= y <= y_max
z_min <= z <= z_max

Defaults to (0.0, 0.0, 0.0).

(0.0, 0.0, 0.0)
apply_p float

Probability of applying the clipping. Defaults to 1.0.

1.0
Source code in src\augmentation_class.py
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
@TRANSFORMS.register()
class PointClip:
    """Randomly clip a local region around a randomly chosen point.

    This transform expects a dictionary containing:

    * `"coord"`: NumPy array of shape (N, 3) with point coordinates.
    * Optionally other per-point arrays (e.g., `"norm"`, `"color"`, `"label"`)
      that have length N along the first dimension.

    A random point index is selected and its coordinate is used as the center:

        center = coord[center_idx]

    Then it builds either:

    * a spherical region of radius `radius` around `center` if `use_sphere=True`, or
    * an axis-aligned box centered at `center` with half-extent `box_range`
      if `use_sphere=False`.

    Only points inside this region are kept; all others are dropped. All aligned per-point attributes are filtered with
    the same mask.

    Args:
        use_sphere (bool, optional):
            If True, use a spherical region. For each point `p`, compute squared distance:

                dist2 = ||p - center||^2

            and keep points with `dist2 <= radius^2`. If False, use an axis-aligned box instead.
            Defaults to True.
        radius (float, optional): Radius of the sphere used when `use_sphere=True`. The clipped region is:

                { p : ||p - center|| <= radius }

            Defaults to 1.0.
        box_range (tuple[float, float, float], optional): Half-extent of the axis-aligned box along each axis,
            used when `use_sphere=False`. Interpreted as `(rx, ry, rz)`. The box is defined as:

            * `x_min, y_min, z_min = center - box_range`
            * `x_max, y_max, z_max = center + box_range`

            A point `p = (x, y, z)` is kept if:

                x_min <= x <= x_max
                y_min <= y <= y_max
                z_min <= z <= z_max

            Defaults to `(0.0, 0.0, 0.0)`.
        apply_p (float, optional):
            Probability of applying the clipping.
            Defaults to 1.0.
    """
    def __init__(self, use_sphere: bool = True, radius: float = 1.0, box_range: tuple = (0.0, 0.0, 0.0),
                 apply_p: float = 1.0):
        self.use_sphere = use_sphere
        self.radius = radius
        self.box_range = np.array(box_range)
        self.apply_p = apply_p

    def __call__(self, data_dict: dict) -> dict:
        """Apply a local region crop (sphere or box) around a random center.

        Args:
            data_dict (dict): Input dictionary that must contain a `"coord"` key with a NumPy array of shape (N, 3).
                Any other entry whose value is a NumPy array or `Sequence` of length N and whose key does not contain
                `"origin"` will also be masked.

        Returns:
            dict: The same dictionary with `"coord"` and aligned per-point attributes cropped to a local region, if applied.
        """
        if random.random() > self.apply_p:
            return data_dict

        if "coord" in data_dict.keys():
            coord = data_dict["coord"]
            n = len(coord)
            center_idx = np.random.randint(low=0, high=n)
            center = coord[center_idx]
            if self.use_sphere:
                diff = coord - center[np.newaxis, :]
                dist2 = np.sum(diff * diff, axis=1)
                mask = dist2 <= self.radius ** 2
            else:
                x, y, z = coord[:, 0], coord[:, 1], coord[:, 2]
                # x_min, x_max, y_min, y_max, z_min, z_max = self.box_range + np.repeat(center, 2)
                x_min, y_min, z_min = -self.box_range + center
                x_max, y_max, z_max = self.box_range + center
                # print(x_min, x_max, y_min, y_max, z_min, z_max)
                mask = (x >= x_min) & (x <= x_max) & (y >= y_min) & (y <= y_max) & (z >= z_min) & (z <= z_max)

            for key, value in data_dict.items():
                if isinstance(value, (np.ndarray, Sequence)) and len(value) == n and "origin" not in key:
                    data_dict[key] = value[mask]
        return data_dict

__call__(data_dict)

Apply a local region crop (sphere or box) around a random center.

Parameters:

Name Type Description Default
data_dict dict

Input dictionary that must contain a "coord" key with a NumPy array of shape (N, 3). Any other entry whose value is a NumPy array or Sequence of length N and whose key does not contain "origin" will also be masked.

required

Returns:

Name Type Description
dict dict

The same dictionary with "coord" and aligned per-point attributes cropped to a local region, if applied.

Source code in src\augmentation_class.py
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
def __call__(self, data_dict: dict) -> dict:
    """Apply a local region crop (sphere or box) around a random center.

    Args:
        data_dict (dict): Input dictionary that must contain a `"coord"` key with a NumPy array of shape (N, 3).
            Any other entry whose value is a NumPy array or `Sequence` of length N and whose key does not contain
            `"origin"` will also be masked.

    Returns:
        dict: The same dictionary with `"coord"` and aligned per-point attributes cropped to a local region, if applied.
    """
    if random.random() > self.apply_p:
        return data_dict

    if "coord" in data_dict.keys():
        coord = data_dict["coord"]
        n = len(coord)
        center_idx = np.random.randint(low=0, high=n)
        center = coord[center_idx]
        if self.use_sphere:
            diff = coord - center[np.newaxis, :]
            dist2 = np.sum(diff * diff, axis=1)
            mask = dist2 <= self.radius ** 2
        else:
            x, y, z = coord[:, 0], coord[:, 1], coord[:, 2]
            # x_min, x_max, y_min, y_max, z_min, z_max = self.box_range + np.repeat(center, 2)
            x_min, y_min, z_min = -self.box_range + center
            x_max, y_max, z_max = self.box_range + center
            # print(x_min, x_max, y_min, y_max, z_min, z_max)
            mask = (x >= x_min) & (x <= x_max) & (y >= y_min) & (y <= y_max) & (z >= z_min) & (z <= z_max)

        for key, value in data_dict.items():
            if isinstance(value, (np.ndarray, Sequence)) and len(value) == n and "origin" not in key:
                data_dict[key] = value[mask]
    return data_dict

Clip PC

Before After

ClipGaussianJitter

Add clipped multivariate Gaussian noise to 3D coordinates.

This transform expects a dictionary containing: * "coord": NumPy array of shape (N, 3) with point coordinates.

Unlike a simple per-axis jitter (RandomJitter) with independent 1D Gaussians, this transform uses a multivariate normal distribution, allowing you to encode correlations between axes via the covariance matrix. It samples 3D Gaussian noise from a multivariate normal, normalizes and clips it using a quantile parameter, scales it by scalar, and adds it to the coordinates in place.

In the default setting:

  • mean = [0.0, 0.0, 0.0]
  • cov = I_3 (3×3 identity matrix → isotropic Gaussian)

A raw sample is drawn as:

jitter_raw ~ N(mean, cov)

Then it is transformed as:

jitter = scalar * clip(jitter_raw / quantile, -1, 1)

Intuition:

  • For a standard normal, most values lie within ±quantile (e.g., 1.96 ≈ 97.5% quantile).
  • Dividing by quantile and clipping to [-1, 1] effectively bounds each component before scaling, so typical magnitudes are on the order of ±scalar.

Parameters:

Name Type Description Default
quantile float

Normalization factor used before clipping. Noise is divided by quantile and then clipped to [-1, 1]. For quantile=1.96, about 95–97.5% of standard normal samples fall in [-1.96, 1.96], so after dividing most samples lie in [-1, 1] before clipping. Increasing quantile makes the effective jitter slightly smaller; decreasing it makes it larger (and more aggressively clipped). Defaults to 1.96.

1.96
scalar float

Overall scale factor for the jitter after clipping. Roughly controls the maximum perturbation per coordinate (since final values are typically in approximately[-scalar, scalar]). Defaults to 0.02.

0.02
apply_p float

Probability of applying the jitter. Defaults to 1.0.

1.0
Source code in src\augmentation_class.py
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
@TRANSFORMS.register()
class ClipGaussianJitter:
    """Add clipped multivariate Gaussian noise to 3D coordinates.

    This transform expects a dictionary containing:
    * `"coord"`: NumPy array of shape (N, 3) with point coordinates.

    Unlike a simple per-axis jitter (RandomJitter) with independent 1D Gaussians, this transform uses a
    **multivariate normal distribution**, allowing you to encode correlations between axes via the covariance matrix.
    It samples 3D Gaussian noise from a multivariate normal, normalizes and clips it using a `quantile` parameter, scales
    it by `scalar`, and adds it to the coordinates in place.

    In the default setting:

    * `mean = [0.0, 0.0, 0.0]`
    * `cov = I_3` (3×3 identity matrix → isotropic Gaussian)

    A raw sample is drawn as:

        jitter_raw ~ N(mean, cov)

    Then it is transformed as:

        jitter = scalar * clip(jitter_raw / quantile, -1, 1)

    Intuition:

    * For a standard normal, most values lie within ±`quantile`
      (e.g., 1.96 ≈ 97.5% quantile).
    * Dividing by `quantile` and clipping to [-1, 1] effectively bounds
      each component before scaling, so typical magnitudes are on the
      order of `±scalar`.

    Args:
        quantile (float, optional):
            Normalization factor used before clipping. Noise is divided by `quantile` and then clipped to [-1, 1].
            For `quantile=1.96`, about 95–97.5% of standard normal samples fall in [-1.96, 1.96], so after dividing most
            samples lie in [-1, 1] before clipping.
            Increasing `quantile` makes the effective jitter slightly smaller; decreasing it makes it larger (and more aggressively clipped).
            Defaults to 1.96.
        scalar (float, optional):
            Overall scale factor for the jitter after clipping. Roughly controls the maximum perturbation per coordinate
            (since final values are typically in approximately`[-scalar, scalar]`).
            Defaults to 0.02.
        apply_p (float, optional):
            Probability of applying the jitter.
            Defaults to 1.0.
    """
    def __init__(self, quantile: float = 1.96, scalar: float = 0.02, apply_p: float = 1.0):
        self.mean = [0.0, 0.0, 0.0]
        self.conv = np.identity(3)
        self.quantile = quantile
        self.scalar = scalar
        self.apply_p = apply_p

    def __call__(self, data_dict: dict) -> dict:
        """Apply clipped multivariate Gaussian jitter to the point coordinates.

        Args:
            data_dict (dict): Input dictionary that must contain a `"coord"` key with a NumPy array of shape (N, 3)
                representing point coordinates.

        Returns:
            dict: The same dictionary with `"coord"` perturbed by clipped multivariate Gaussian noise, if applied.
        """
        if random.random() > self.apply_p:
            return data_dict

        if "coord" in data_dict.keys():
            # [data_dict["coord"].shape[0], len(self.mean)]
            jitter = np.random.multivariate_normal(self.mean, self.conv, data_dict["coord"].shape[0])
            jitter = self.scalar * np.clip(jitter / self.quantile, -1, 1)
            data_dict["coord"] += jitter

        return data_dict

__call__(data_dict)

Apply clipped multivariate Gaussian jitter to the point coordinates.

Parameters:

Name Type Description Default
data_dict dict

Input dictionary that must contain a "coord" key with a NumPy array of shape (N, 3) representing point coordinates.

required

Returns:

Name Type Description
dict dict

The same dictionary with "coord" perturbed by clipped multivariate Gaussian noise, if applied.

Source code in src\augmentation_class.py
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
def __call__(self, data_dict: dict) -> dict:
    """Apply clipped multivariate Gaussian jitter to the point coordinates.

    Args:
        data_dict (dict): Input dictionary that must contain a `"coord"` key with a NumPy array of shape (N, 3)
            representing point coordinates.

    Returns:
        dict: The same dictionary with `"coord"` perturbed by clipped multivariate Gaussian noise, if applied.
    """
    if random.random() > self.apply_p:
        return data_dict

    if "coord" in data_dict.keys():
        # [data_dict["coord"].shape[0], len(self.mean)]
        jitter = np.random.multivariate_normal(self.mean, self.conv, data_dict["coord"].shape[0])
        jitter = self.scalar * np.clip(jitter / self.quantile, -1, 1)
        data_dict["coord"] += jitter

    return data_dict

Clip Gaussian Jitter on PC

Before After

ElasticDistortion

Apply elastic distortion to 3D point coordinates.

This transform expects a dictionary containing:

  • "coord": NumPy array of shape (N, 3) with point coordinates.

The distortion is implemented by:

  1. Creating a coarse 3D grid of Gaussian noise with resolution determined by granularity.
  2. Smoothing the noise with separable 3D convolutions.
  3. Trilinearly interpolating the smoothed noise at each input coordinate.
  4. Adding the interpolated noise (scaled by magnitude) to the original coordinates.

Multiple (granularity, magnitude) pairs can be applied sequentially to produce multi-scale elastic deformations.

Parameters:

Name Type Description Default
distortion_params list[list[float]] | list[tuple[float, float]] | None

List of (granularity, magnitude) pairs controlling the elastic fields to apply. Each pair is:

  • granularity (float): Size of the noise grid in the same units as the coordinates (e.g., meters or centimeters). Larger values → smoother, more global distortions.
  • magnitude (float): Amplitude of the noise displacement added to the coordinates.

If None, a default two-scale configuration is used: [[0.2, 0.4], [0.8, 1.6]]. Defaults to None.

None
apply_p float

Probability of applying the elastic Defaults to 1.0.

1.0
Source code in src\augmentation_class.py
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
@TRANSFORMS.register()
class ElasticDistortion:
    """Apply elastic distortion to 3D point coordinates.

    This transform expects a dictionary containing:

    * `"coord"`: NumPy array of shape (N, 3) with point coordinates.

    The distortion is implemented by:

    1. Creating a coarse 3D grid of Gaussian noise with resolution determined
       by `granularity`.
    2. Smoothing the noise with separable 3D convolutions.
    3. Trilinearly interpolating the smoothed noise at each input coordinate.
    4. Adding the interpolated noise (scaled by `magnitude`) to the original
       coordinates.

    Multiple `(granularity, magnitude)` pairs can be applied sequentially to
    produce multi-scale elastic deformations.

    Args:
        distortion_params (list[list[float]] | list[tuple[float, float]] | None, optional):
            List of `(granularity, magnitude)` pairs controlling the elastic fields to apply. Each pair is:

            * `granularity` (float):
                Size of the noise grid in the same units as the coordinates (e.g., meters or centimeters).
                Larger values → smoother, more global distortions.
            * `magnitude` (float):
                Amplitude of the noise displacement added to the coordinates.

            If ``None``, a default two-scale configuration is used: ``[[0.2, 0.4], [0.8, 1.6]]``.
            Defaults to ``None``.
        apply_p (float, optional):
            Probability of applying the elastic
            Defaults to 1.0.
    """
    def __init__(self, distortion_params=None, apply_p: float = 1.0):
        self.distortion_params = [[0.2, 0.4], [0.8, 1.6]] if distortion_params is None else distortion_params
        self.apply_p = apply_p

    @staticmethod
    def elastic_distortion(coord, granularity, magnitude):
        """
        Apply a single elastic distortion field to coordinates.

        Args:
            coord (np.ndarray):
                Array of shape (N, D) with point coordinates. The first 3 dimensions are treated as spatial coordinates.
            granularity (float):
                Size of the noise grid in the same units as `coord` (e.g., meters or centimeters).Controls the spatial
                smoothness of the distortion.
            magnitude (float):
                Noise multiplier that scales the interpolated noise displacement added to `coord`.

        Returns:
            np.ndarray:
            The same coordinate array, distorted in place and also returned for convenience.
        """
        blurx = np.ones((3, 1, 1, 1)).astype("float32") / 3
        blury = np.ones((1, 3, 1, 1)).astype("float32") / 3
        blurz = np.ones((1, 1, 3, 1)).astype("float32") / 3
        coords_min = coord.min(0)

        # Create Gaussian noise tensor of the size given by granularity.
        noise_dim = ((coord - coords_min).max(0) // granularity).astype(int) + 3
        noise = np.random.randn(*noise_dim, 3).astype(np.float32)

        # Smoothing.
        for _ in range(2):
            noise = scipy.ndimage.filters.convolve(noise, blurx, mode="constant", cval=0)
            noise = scipy.ndimage.filters.convolve(noise, blury, mode="constant", cval=0)
            noise = scipy.ndimage.filters.convolve(noise, blurz, mode="constant", cval=0)

        # Trilinear interpolate noise filters for each spatial dimensions.
        ax = [np.linspace(d_min, d_max, d) for d_min, d_max, d in zip(coords_min - granularity,
                                                                      coords_min + granularity * (noise_dim - 2),
                                                                      noise_dim)
              ]
        interp = scipy.interpolate.RegularGridInterpolator(
            ax, noise, bounds_error=False, fill_value=0
        )
        coord += interp(coord) * magnitude
        return coord

    def __call__(self, data_dict: dict) -> dict:
        """Apply elastic distortion(s) to `"coord"` in `data_dict`.

        Args:
            data_dict (dict): Input dictionary that must contain a `"coord"` key with a NumPy array of shape (N, 3)
                representing point coordinates.

        Returns:
            dict: The same dictionary with `"coord"` distorted in place, if applied.
        """
        if random.random() > self.apply_p:
            return data_dict

        if "coord" in data_dict.keys() and self.distortion_params is not None:
            for granularity, magnitude in self.distortion_params:
                data_dict["coord"] = self.elastic_distortion(data_dict["coord"], granularity, magnitude)
        return data_dict

__call__(data_dict)

Apply elastic distortion(s) to "coord" in data_dict.

Parameters:

Name Type Description Default
data_dict dict

Input dictionary that must contain a "coord" key with a NumPy array of shape (N, 3) representing point coordinates.

required

Returns:

Name Type Description
dict dict

The same dictionary with "coord" distorted in place, if applied.

Source code in src\augmentation_class.py
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
def __call__(self, data_dict: dict) -> dict:
    """Apply elastic distortion(s) to `"coord"` in `data_dict`.

    Args:
        data_dict (dict): Input dictionary that must contain a `"coord"` key with a NumPy array of shape (N, 3)
            representing point coordinates.

    Returns:
        dict: The same dictionary with `"coord"` distorted in place, if applied.
    """
    if random.random() > self.apply_p:
        return data_dict

    if "coord" in data_dict.keys() and self.distortion_params is not None:
        for granularity, magnitude in self.distortion_params:
            data_dict["coord"] = self.elastic_distortion(data_dict["coord"], granularity, magnitude)
    return data_dict

Elastic Distortion on PC

Before After