RandomToneCurve
Randomly change the relationship between bright and dark areas of the image by manipulating its tone curve.
This transform applies a random S-curve to the image's tone curve, adjusting the brightness and contrast in a non-linear manner. It can be applied to the entire image or to each channel separately.
scaleStandard deviation of the normal distribution used to sample random distances to move two control points that modify the image's curve. Values should be in range [0, 1]. Higher values will result in more dramatic changes to the image. Default: 0.1
per_channelIf True, the tone curve will be applied to each channel of the input image separately, which can lead to color distortion. If False, the same curve is applied to all channels, preserving the original color relationships. Default: False
pProbability of applying the transform. Default: 0.5
>>> import numpy as np
>>> import albumentations as A
>>> image = np.random.randint(0, 256, (100, 100, 3), dtype=np.uint8)
# Apply a random tone curve to all channels together
>>> transform = A.RandomToneCurve(scale=0.1, per_channel=False, p=1.0)
>>> augmented_image = transform(image=image)['image']
# Apply random tone curves to each channel separately
>>> transform = A.RandomToneCurve(scale=0.2, per_channel=True, p=1.0)
>>> augmented_image = transform(image=image)['image']- This transform modifies the image's histogram by applying a smooth, S-shaped curve to it.
- The S-curve is defined by moving two control points of a quadratic Bézier curve.
- When per_channel is False, the same curve is applied to all channels, maintaining color balance.
- When per_channel is True, different curves are applied to each channel, which can create color shifts.
- This transform can be used to adjust image contrast and brightness in a more natural way than linear transforms.
- The effect can range from subtle contrast adjustments to more dramatic "vintage" or "faded" looks.
- [{'description': '"What Else Can Fool Deep Learning? Addressing Color Constancy Errors on Deep Neural Network Performance"', 'source': 'https://arxiv.org/abs/1912.06960'}, {'description': 'Bézier curve', 'source': 'https://en.wikipedia.org/wiki/B%C3%A9zier_curve#Quadratic_B%C3%A9zier_curves'}, {'description': 'Tone mapping', 'source': 'https://en.wikipedia.org/wiki/Tone_mapping'}]