class
RandomContrast
extends
PhotometricTransform[ScalarParams]RandomContrast(limit: float | tuple[float, float] = 0.2, p: float = 0.5)Randomly perturb contrast only (Albumentations RandomContrast).
Samples a contrast factor uniformly from limit, multiplies the
image by 1 + factor, and clips to [0, 1]. Equivalent to
the contrast leg of RandomBrightnessContrast — included as
a standalone class for parity with the Albumentations API.
Parameters
limitfloat or (float, float)= 0.2Multiplicative contrast offset range (multiplier is
1 + sampled_value). Scalar v expands to (-v, v).pfloat= 0.5Probability of applying the transform.
Examples
>>> import lucid
>>> import lucid.utils.transforms as T
>>> tf = T.RandomContrast(limit=0.2, p=1.0)
>>> out = tf(T.Image(lucid.rand(3, 32, 32))).data
>>> tuple(out.shape)
(3, 32, 32)Used by 1
Constructors
1Instance methods
1Sample per-call random parameters for RandomContrast.
Parameters
imgTensorImage tensor; not inspected, carried through for dispatch.
Returns
ScalarParamsCarries value — the contrast delta drawn uniformly
from limit; the effective multiplier is 1 + value.