Random Crop
Crop your training sets into a given dimension
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.

Parameters

Height

Sets the height of the desired cropped image in pixels.

Width

Sets the width of the desired cropped image in pixels.

Code Implementation

1
import albumentations as albu
2
from PIL import Image
3
โ€‹
4
โ€‹
5
transform =albu.RandomCrop(200,200)
6
augmented_image = transform(image=figure)['image']
7
โ€‹
8
# we have our required croppedimage in augmented_image.
Copied!
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.

Further Resources

Last modified 2mo ago