Skip to content
class

RandomGamma

extendsPhotometricTransform[ScalarParams]
RandomGamma(gamma_limit: tuple[int, int] = (80, 120), p: float = 0.5)

Random gamma correction (Albumentations RandomGamma).

Samples a gamma value uniformly from gamma_limit / 100 and applies img ** gamma after clipping the input to [0, 1]. Gamma < 1 brightens midtones; gamma > 1 darkens them.

Parameters

gamma_limit(int, int)= (80, 120)
Inclusive range of the gamma exponent expressed in percent (matches Albumentations' integer-percent convention). Sampled gamma is randint(gamma_limit[0], gamma_limit[1]) / 100.
pfloat= 0.5
Probability of applying the transform.

Examples

>>> import lucid
>>> import lucid.utils.transforms as T
>>> tf = T.RandomGamma(gamma_limit=(80, 120), 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__(gamma_limit: tuple[int, int] = (80, 120), p: float = 0.5)

Instance methods

1
fn

make_params

→ScalarParams
make_params(img: Tensor)

Sample per-call random parameters for RandomGamma.

Parameters

Image tensor; not inspected, carried through for dispatch.

Returns

ScalarParams

Carries value — the gamma exponent, drawn uniformly from gamma_limit and divided by 100 to convert the integer-percent input to a real exponent.

Dunder methods

1