tfm.vision.preprocess_ops.random_crop_image
Stay organized with collections
Save and categorize content based on your preferences.
Randomly crop an arbitrary shaped slice from the input image.
tfm.vision.preprocess_ops.random_crop_image(
image,
aspect_ratio_range=(3.0 / 4.0, 4.0 / 3.0),
area_range=(0.08, 1.0),
max_attempts=10,
seed=1
)
Args |
image
|
a Tensor of shape [height, width, 3] representing the input image.
|
aspect_ratio_range
|
a list of floats. The cropped area of the image must
have an aspect ratio = width / height within this range.
|
area_range
|
a list of floats. The cropped reas of the image must contain a
fraction of the input image within this range.
|
max_attempts
|
the number of attempts at generating a cropped region of the
image of the specified constraints. After max_attempts failures, return
the entire image.
|
seed
|
the seed of the random generator.
|
Returns |
cropped_image
|
a Tensor representing the random cropped image. Can be the
original image if max_attempts is exhausted.
|
[null,null,["Last updated 2026-11-06 UTC."],[],[]]