class
RGBShift
extends
PhotometricTransform[TripletParams]RGBShift(r_shift_limit: float | tuple[float, float] = 20, g_shift_limit: float | tuple[float, float] = 20, b_shift_limit: float | tuple[float, float] = 20, p: float = 0.5)Add per-channel additive shifts to an RGB image (Albumentations RGBShift).
Samples an independent offset for each of the R / G / B channels
from the corresponding limit, scales by 1/255 so the limits stay
on the familiar OpenCV 0-255 scale, then adds and clips to
[0, 1]. Channel-gated to 3-channel input via
PhotometricTransform._require_channels.
Parameters
r_shift_limitfloat or (float, float)= 20Red-channel shift range on the 0-255 scale; scalar
v expands
to (-v, v).g_shift_limitfloat or (float, float)= 20Green-channel shift range on the 0-255 scale.
b_shift_limitfloat or (float, float)= 20Blue-channel shift range on the 0-255 scale.
pfloat= 0.5Probability of applying the transform.
Raises
ValueErrorIf the input image does not have exactly 3 channels.
Examples
>>> import lucid
>>> import lucid.utils.transforms as T
>>> tf = T.RGBShift(r_shift_limit=15, g_shift_limit=15, b_shift_limit=15, 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 RGBShift.
Parameters
imgTensorImage tensor; not inspected, carried through for dispatch.
Returns
TripletParamsCarries the per-channel offsets a (red), b (green),
c (blue), each sampled from the constructor's 0-255
limit range and divided by 255 to land on the unit scale.