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".
You should make sure that the original image size is larger than the requested crop size.
Sets the height of the desired cropped image in pixels.
Sets the width of the desired cropped image in pixels.
import albumentations as albu from PIL import Image transform =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.