This data augmentation feature allows you to crop an image to any size within a certain specified bound. Like all other augmentation, this creates synthetic data for training.
Sets the height of the desired cropped image in pixels.
Sets the width of the desired cropped image in pixels.
Sets the range of size to which the image is cropped.
import albumentations as albufrom PIL import Imagetransform =albu.RandomSizedCrop([1500,2000],100,100,1.0,cv2.INTER_NEAREST,1)augmented_image = transform(image=figure)['image']# we have our required cropped image in augmented_image.# the first argument defines the crop size limits.# second and third are the height and width of the image after crop and resize# fourth is the aspect ratio of crop# fifth is the interpolation technique, and the last is the probability of thetransform.