Color Jitter

This data augmentation tool adds brightness, contrast, saturation, and hue to your sample images.

Parameters

Brightness

It sets the brightness of the transformed image.

Contrast

In visual perception, contrast refers to the difference of color and brightness of objects in the same field of view.

The left part of the image has lower contrast than the right part.

Saturation

Color saturation refers to the intensity and the purity of a color as displayed in the image. If the image is highly saturated then the colors are more intense and vivid.

Original image
Saturated image

Hue

Hue is one of the main indication of the appearance of the color itself. It refers to the attribute of the visible light due to which it is differentiated from or similar to primary colors: red, green, and blue. Usually, colors with the same hue are distinguished with adjectives referring to their lightness or colorfulness, such as with "light blue", "pastel blue", etc.

The augmentation randomly picks a different "shift" to change the hue of the sample images.

Original image shifted in different colors.

Code Implementation

import albumentations as albu
from PIL import Image
import numpy as np

transform =albu.ColorJitter(brightness=0.2, contrast=0.2, saturation=0.2, hue=0.2, p=0.5)

image = np.array(Image.open('/some/image/file/path'))
image = transform(image=image)['image']

\# Now the image is transformed and ready to be accepted by the model

Further Resources

Get AI confident. Start using Hasty today.

Our platform is completely free to try. Sign up today to start your two-month trial.