HueSaturationTranslation#

class HueSaturationTranslation(hue_max=0.5, saturation_max=0.2)[source]#

Bases: object

Randomly translate hue and scale saturation of point colors.

When "color" is present, converts data_dict["color"][:, :3] to HSV, adds a random hue offset in +/- hue_max (wrapped modulo 1) and multiplies saturation by 1 + U(-saturation_max, saturation_max) (clipped to [0, 1]), then converts back to RGB and clips to [0, 255]; modifies the color in place. Registered as HueSaturationTranslation — use this string as the type in a transform=[...] config list.

Parameters:
  • hue_max (float) – Half-width of the random hue offset (HSV hue units in [0, 1]). Defaults to 0.5.

  • saturation_max (float) – Half-width of the random saturation scaling factor about 1. Defaults to 0.2.

Example

>>> import numpy as np
>>> np.random.seed(0)
>>> data = {"color": np.array([[200., 100., 50.]], dtype="f4")}
>>> HueSaturationTranslation(hue_max=0.5, saturation_max=0.2)(data)["color"]
array([[200., 139.,  37.]], dtype=float32)  # hue rotated, saturation rescaled
static hsv_to_rgb(hsv)[source]#
static rgb_to_hsv(rgb)[source]#