Shift R, G, B with separate ranges. Specialized AdditiveNoise with constant uniform shifts. Params: r_shift_limit, g_shift_limit, b_shift_limit.
A specialized version of AdditiveNoise that applies constant uniform shifts to RGB channels. Each channel (R,G,B) can have its own shift range specified.
r_shift_limitRange for shifting the red channel. Options:
g_shift_limitRange for shifting the green channel. Options:
b_shift_limitRange for shifting the blue channel. Options:
pProbability of applying the transform. Default: 0.5.
>>> import numpy as np
>>> import albumentations as A
# Shift RGB channels of uint8 image
>>> transform = A.RGBShift(
... r_shift_limit=30, # Will sample red shift from [-30, 30]
... g_shift_limit=(-20, 20), # Will sample green shift from [-20, 20]
... b_shift_limit=(-10, 10), # Will sample blue shift from [-10, 10]
... p=1.0
... )
>>> image = np.random.randint(0, 256, (100, 100, 3), dtype=np.uint8)
>>> shifted = transform(image=image)["image"]
# Same effect using AdditiveNoise
>>> transform = A.AdditiveNoise(
... noise_type="uniform",
... spatial_mode="constant", # One value per channel
... noise_params={
... "ranges": [(-30/255, 30/255), (-20/255, 20/255), (-10/255, 10/255)]
... },
... p=1.0
... )