If you have ever worked on a Computer Vision project, you might know that using augmentations to diversify the dataset is the best practice. On this page, we will:
Сover the Equalize augmentation;
Check out its parameters;
See how Equalize affects an image;
And check out how to work with Equalize using Python through the Albumentations library.
Let’s jump in.
To define the term, Equalize is an augmentation that equalizes the image histogram. In other words, this augmentation enhances image contrast. Let’s dive a bit deeper into how it works.
If you are unfamiliar with the topic, each image can be represented in the form of a histogram featuring the intensity distribution of an image.
In the picture above, you can see a simple example of such a representation. In this case, the x-axis is the brightness scale (from black on the left to white on the right). On the other hand, the y-axis features the number of pixels of a certain intensity on an image. So, in a sense, the histogram represents the number of pixels for each brightness value.
As mentioned above, Equalize performs the Histogram Equalization image processing technique, enhancing the image contrast. To do so, the algorithm spreads the most frequent intensity values, enhancing an image's overall contrast.
Probability of applying transform - defines the likelihood of applying Equalize to an image;
Equalize by channel - when toggled on, each channel of an image will be equalized separately. When toggled off, a picture is converted to YCbCr representation and equalized by the Y channel.
import albumentations as albu from PIL import Image import numpy as np transform =albu.augmentations.transforms.Equalize() image = np.array(Image.open('/some/random/image.png')) augmented_image = transform(image=image)['image'] # We have the equalized image in augmented_image.
Only 13% of vision AI projects make it to production, with Hasty we boost that number to 100%.