ChromaticTranslation#

class ChromaticTranslation(p=0.95, ratio=0.05)[source]#

Bases: object

Randomly shift all RGB channels by a shared offset.

With probability p and when "color" is present, adds the same random per-channel offset (drawn in +/- 255 * ratio) to every point, then clips to [0, 255]; modifies data_dict["color"][:, :3] in place. Registered as ChromaticTranslation — use this string as the type in a transform=[...] config list.

Parameters:
  • p (float) – Probability of applying the transform. Defaults to 0.95.

  • ratio (float) – Fraction of the full 255 range bounding the random offset magnitude. Defaults to 0.05.

Example

>>> import numpy as np
>>> np.random.seed(0)
>>> data = {"color": np.array([[100., 100., 100.]], dtype="f4")}
>>> ChromaticTranslation(p=1.0, ratio=0.1)(data)["color"].round(2)
array([[110.97, 105.24, 102.29]], dtype=float32)  # shared per-channel offset added