class
RandomBrightnessContrast
extends
PhotometricTransform[BCParams]RandomBrightnessContrast(brightness_limit: float | tuple[float, float] = 0.2, contrast_limit: float | tuple[float, float] = 0.2, p: float = 0.5)Randomly perturb brightness and contrast jointly (Albumentations RandomBrightnessContrast).
Samples a brightness offset and a contrast multiplier independently
from their limit ranges, then applies img * (1 + c) + b in one
pass and clips to [0, 1]. Equivalent to chaining
RandomBrightness and RandomContrast but cheaper
(one fused expression, one clip).
Parameters
brightness_limitfloat or (float, float)= 0.2Additive brightness offset range. A scalar
v is interpreted
as the symmetric range (-v, v).contrast_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.RandomBrightnessContrast(brightness_limit=0.2, contrast_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 RandomBrightnessContrast.
Parameters
imgTensorImage tensor; not inspected, carried through for dispatch.
Returns
BCParamsCarries brightness (additive offset) and contrast
(multiplier delta), each drawn uniformly from their
respective limit ranges.