Skip to content
class

HueSaturationValue

extendsPhotometricTransform[TripletParams]
HueSaturationValue(hue_shift_limit: float | tuple[float, float] = 20, sat_shift_limit: float | tuple[float, float] = 30, val_shift_limit: float | tuple[float, float] = 20, p: float = 0.5)

Random hue / saturation / value shift (Albumentations HueSaturationValue).

Samples each shift uniformly from its limit range, then applies a single functional.adjust_hsv round-trip — additive in HSV, hue wraps, saturation and value clip to [0, 1]. Channel-gated to RGB (PhotometricTransform._require_channels rejects non-3-channel input).

Parameters

hue_shift_limitfloat or (float, float)= 20
Hue offset range on the OpenCV scale [0, 179]. Scalar v is interpreted as (-v, v).
sat_shift_limitfloat or (float, float)= 30
Saturation offset range on the OpenCV scale [0, 255].
val_shift_limitfloat or (float, float)= 20
Value (brightness) offset range on the OpenCV scale [0, 255].
pfloat= 0.5
Probability of applying the transform.

Raises

ValueError
If the image has anything other than 3 channels.

Notes

Lucid stays in float for the full HSV round-trip; Albumentations quantises through uint8 + cv2 HSV, so the two match to ~0.02 (G3 parity "ballpark" tier). Lucid's path is the more precise of the two.

Examples

>>> import lucid
>>> import lucid.utils.transforms as T
>>> tf = T.HueSaturationValue(hue_shift_limit=10, 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__(hue_shift_limit: float | tuple[float, float] = 20, sat_shift_limit: float | tuple[float, float] = 30, val_shift_limit: float | tuple[float, float] = 20, p: float = 0.5)

Instance methods

1
fn

make_params

→TripletParams
make_params(img: Tensor)

Sample per-call random parameters for HueSaturationValue.

Parameters

Image tensor; not inspected, carried through for dispatch.

Returns

TripletParams

Carries the hue shift (a, OpenCV [0, 179] scale), saturation shift (b, [0, 255]), and value shift (c, [0, 255]), each drawn uniformly from its limit range.

Dunder methods

1