This data augmentation option allows you to crop the images into a certain dimension, creating synthetic data. The cropping could yield any patch of the image and is therefore called "Random Crop".
Sets the height of the desired cropped image in pixels.
Sets the width of the desired cropped image in pixels.
import albumentations as albufrom PIL import Imagetransform =albu.RandomCrop(200,200)augmented_image = transform(image=figure)['image']# we have our required croppedimage in augmented_image.
The following code implementation crops by taking 4 specific corner points. However, the tool generates random points for each of the training images that needs to be cropped.