NEW
All annotation is now free in Hasty.

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.

Parameters

Height

It defines the height of the newly cropped image.

Width

It defines the width of the newly cropped image.

Probability

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(Image.open('/some/image/file/path'))
image = transform(image=image)['image']

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

Further Resources**

Last updated on Jun 01, 2022

Removing the risk from vision AI.

Only 13% of vision AI projects make it to production, with Hasty we boost that number to 100%.