Shift R, G, B with separate ranges. Specialized AdditiveNoise with constant uniform shifts. Params: r_shift_range, g_shift_range, b_shift_range.
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_rangeRange (min, max) for shifting the red channel, sampled per image. For uint8 images values are absolute shifts in [0, 255]; for float images they are relative shifts in [0, 1]. Default: (-20, 20)
g_shift_rangeRange (min, max) for shifting the green channel, sampled per image. Same units as r_shift_range. Default: (-20, 20)
b_shift_rangeRange (min, max) for shifting the blue channel, sampled per image. Same units as r_shift_range. Default: (-20, 20)
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_range=(-30, 30), # Will sample red shift from [-30, 30]
... g_shift_range=(-20, 20), # Will sample green shift from [-20, 20]
... b_shift_range=(-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
... )