ChromaticAutoContrast#

class ChromaticAutoContrast(p=0.2, blend_factor=None)[source]#

Bases: object

Randomly auto-contrast the per-point RGB color.

With probability p and when "color" is present, rescales each RGB channel to span [0, 255] (per-channel min/max stretch) and blends the result with the original color by blend_factor; modifies data_dict["color"][:, :3] in place. Registered as ChromaticAutoContrast — use this string as the type in a transform=[...] config list.

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

  • blend_factor (float, optional) – Blend weight toward the contrasted color; if None a fresh U(0, 1) value is drawn per call. Defaults to None.

Example

>>> import numpy as np
>>> np.random.seed(0)
>>> data = {"color": np.array([[50., 100., 150.],
...                            [100., 150., 200.]], dtype="f4")}
>>> ChromaticAutoContrast(p=1.0)(data)["color"].round(2)
array([[ 14.24,  28.48,  42.72],
       [210.85, 225.09, 239.34]], dtype=float32)  # stretched toward [0, 255]