Skip to content
class

Solarize

extendsPhotometricTransform[ScalarParams]
Solarize(threshold: float | tuple[float, float] = 128, p: float = 0.5)

Invert pixel intensities above a threshold (Albumentations Solarize).

Samples a threshold uniformly from threshold (on the 0-255 scale, divided by 255 internally), then replaces every pixel x >= t with 1 - x, leaving pixels below the threshold untouched. Classic photographic posterisation effect, also used by AutoAugment / RandAugment.

Parameters

thresholdfloat or (float, float)= 128
Threshold (0-255 scale) for the inversion cutoff. Scalar v is interpreted as the constant range (v, v); a tuple samples the threshold uniformly per call.
pfloat= 0.5
Probability of applying the transform.

Examples

>>> import lucid
>>> import lucid.utils.transforms as T
>>> tf = T.Solarize(threshold=128, 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__(threshold: float | tuple[float, float] = 128, p: float = 0.5)

Instance methods

1
fn

make_params

→ScalarParams
make_params(img: Tensor)

Sample per-call random parameters for Solarize.

Parameters

Image tensor; not inspected, carried through for dispatch.

Returns

ScalarParams

Carries value — the inversion threshold on the unit scale (sampled from threshold on the 0-255 scale, then divided by 255).

Dunder methods

1