Center Crop

Data augmentation tool that allows you to crop your samples to a specified height and width with certain probability.

Since it is center crop, the central part of the image is cropped.



It defines the height of the newly cropped image.


It defines the width of the newly cropped image.


It is the probability of the application of this transform.

Original image.
Image after center crop

Code Implementation

import albumentations as albu
from PIL import Image
import numpy as np

transform =albu.CenterCrop(200,200,p=0.5)#set height, width, and probability

image = np.array('/some/image/file/path'))
image = transform(image=image)['image']

\# Now the image is cropped and ready to be accepted by the model

Further Resources**

Get AI confident. Start using Hasty today.

Our platform is completely free to try. Sign up today to start your two-month trial.