tf.image.resize_with_crop_or_pad
Stay organized with collections
Save and categorize content based on your preferences.
Crops and/or pads an image to a target width and height.
tf.image.resize_with_crop_or_pad(
image, target_height, target_width
)
Resizes an image to a target width and height by either centrally
cropping the image or padding it evenly with zeros.
If width
or height
is greater than the specified target_width
or
target_height
respectively, this op centrally crops along that dimension.
If width
or height
is smaller than the specified target_width
or
target_height
respectively, this op centrally pads with 0 along that
dimension.
Args |
image
|
4-D Tensor of shape [batch, height, width, channels] or 3-D Tensor
of shape [height, width, channels] .
|
target_height
|
Target height.
|
target_width
|
Target width.
|
Raises |
ValueError
|
if target_height or target_width are zero or negative.
|
Returns |
Cropped and/or padded image.
If images was 4-D, a 4-D float Tensor of shape
[batch, new_height, new_width, channels] .
If images was 3-D, a 3-D float Tensor of shape
[new_height, new_width, channels] .
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2020-10-01 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2020-10-01 UTC."],[],[]]