Resize
Resize your training data to bring diversity to your dataset
The data augmentation tool allows you to resize your training images. This transformation yields a synthetic image which is helpful in creating diverse training sets.

Parameters

Height

Adjusts the height of the image in pixels.

Width

Adjusts the width of the image in pixels.

Probability

This gives you the probability of each of the training images to be resized. For example, if there are 100 training images and the probability is set to 0.5, then the expected number (not exactly, but expected) of resized images is 50.

Resizing Algorithms

    Linear Interpolation
    Cubic Interpolation
    Nearest Pixel
    Area
    Lanczos algorithm
Using the Nearest Pixel or the Area option for enlarging the images can produce pixelated borders. To obtain smooth borders after enlarging the image, one can use any of the remaining three. If choosing linear interpolation still produces pixelated borders, which can happen in cases where the image is drastically enlarged, then you can opt for the Cubic or Lanczos algorithm.

Code Implementation

1
import albumentations as albu
2
from PIL import Image
3
import numpy as np
4
5
transform =albu.Resize(224, 224)
6
7
8
image = np.array(Image.open('/some/image/file/path'))
9
image = transform(image=image)['image']
10
11
# Now the image is preprocessed and ready to be accepted by the model
Copied!

Further Resources

Last modified 2mo ago