ChromaticTranslation#
- class ChromaticTranslation(p=0.95, ratio=0.05)[source]#
Bases:
objectRandomly shift all RGB channels by a shared offset.
With probability
pand when"color"is present, adds the same random per-channel offset (drawn in+/- 255 * ratio) to every point, then clips to[0, 255]; modifiesdata_dict["color"][:, :3]in place. Registered asChromaticTranslation— use this string as thetypein atransform=[...]config list.- Parameters:
p (float) – Probability of applying the transform. Defaults to
0.95.ratio (float) – Fraction of the full
255range bounding the random offset magnitude. Defaults to0.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