HueSaturationValue

Targets:
image
volume
Image Types:uint8, float32

Randomly change hue, saturation and value of the input image.

This transform adjusts the HSV (Hue, Saturation, Value) channels of an input RGB image. It allows for independent control over each channel, providing a wide range of color and brightness modifications.

Arguments
hue_shift_limit
tuple[float, float] | float
[-20,20]

Range for changing hue. If a single float value is provided, the range will be (-hue_shift_limit, hue_shift_limit). Values should be in the range [-180, 180]. Default: (-20, 20).

sat_shift_limit
tuple[float, float] | float
[-30,30]

Range for changing saturation. If a single float value is provided, the range will be (-sat_shift_limit, sat_shift_limit). Values should be in the range [-255, 255]. Default: (-30, 30).

val_shift_limit
tuple[float, float] | float
[-20,20]

Range for changing value (brightness). If a single float value is provided, the range will be (-val_shift_limit, val_shift_limit). Values should be in the range [-255, 255]. Default: (-20, 20).

p
float
0.5

Probability of applying the transform. Default: 0.5.

Examples
>>> import numpy as np
>>> import albumentations as A
>>> image = np.random.randint(0, 256, (100, 100, 3), dtype=np.uint8)
>>> transform = A.HueSaturationValue(
...     hue_shift_limit=20,
...     sat_shift_limit=30,
...     val_shift_limit=20,
...     p=0.7
... )
>>> result = transform(image=image)
>>> augmented_image = result["image"]
Notes
  • The transform first converts the input RGB image to the HSV color space.
  • Each channel (Hue, Saturation, Value) is adjusted independently.
  • Hue is circular, so it wraps around at 180 degrees.
  • For float32 images, the shift values are applied as percentages of the full range.
  • This transform is particularly useful for color augmentation and simulating different lighting conditions.