Skip to content
class

RandomToneCurve

extendsPhotometricTransform[ScalarParams]
RandomToneCurve(scale: float = 0.1, p: float = 0.5)

Apply a random S-shaped tone curve around midtones (Albumentations RandomToneCurve).

Samples an amount a uniformly from (-scale, scale) and adds a * sin(2 * pi * x) to the clipped image. The sine wave biases midtones up (if a > 0) or down (if a < 0) while leaving the deep shadows and bright highlights near identity, producing a classic photographic S-curve.

Parameters

scalefloat= 0.1
Half-width of the symmetric range from which the tone-curve amount is sampled (uniform (-scale, scale)).
pfloat= 0.5
Probability of applying the transform.

Examples

>>> import lucid
>>> import lucid.utils.transforms as T
>>> tf = T.RandomToneCurve(scale=0.1, p=1.0)
>>> out = tf(T.Image(lucid.rand(3, 32, 32))).data
>>> tuple(out.shape)
(3, 32, 32)

Used by 1

Constructors

1
dunder

__init__

→None
__init__(scale: float = 0.1, p: float = 0.5)

Instance methods

1
fn

make_params

→ScalarParams
make_params(img: Tensor)

Sample per-call random parameters for RandomToneCurve.

Parameters

Image tensor; not inspected, carried through for dispatch.

Returns

ScalarParams

Carries value — the S-curve amount drawn uniformly from (-scale, scale); positive values brighten midtones, negative values darken them.

Dunder methods

1