tf.compat.v1.image.resize
Stay organized with collections Save and categorize content based on your preferences.
Resize images
to size
using the specified method
.
tf.compat.v1.image.resize(
images,
size,
method=ResizeMethodV1.BILINEAR,
align_corners=False,
preserve_aspect_ratio=False,
name=None
)
Used in the notebooks
Resized images will be distorted if their original aspect ratio is not the same as size
. To avoid distortions see tf.image.resize_with_pad
or tf.image.resize_with_crop_or_pad
.
The method
can be one of:
The return value has the same type as images
if method
is tf.image.ResizeMethod.NEAREST_NEIGR
. It will also have the same type as images
if the size of images
can be statically determined to be the same as size
, because images
is returned in this case. Otherwise, the return value has type float32
.
Args |
---|
images | 4-D Tensor of shape [batch, height, width, channels] or 3-D Tensor of shape [height, width, channels] . |
size | A 1-D int32 Tensor of 2 elements: new_height, new_width . The new size for the images. |
method | ResizeMethod. Defaults to tf.image.ResizeMethod.BILINEAR . |
align_corners | bool. If True, the centers of the 4 corner pixels of the input and output tensors are aligned, preserving the values at the corner pixels. Defaults to False . |
preserve_aspect_ratio | Whether to preserve the aspect ratio. If this is set, then images will be resized to a size that fits in size while preserving the aspect ratio of the original image. Scales up the image if size is bigger than the current size of the image . Defaults to False. |
name | A name for this operation (optional). |
Raises |
---|
ValueError | if the shape of images is incompatible with the shape arguments to this function |
ValueError | if size has invalid shape or type. |
ValueError | if an unsupported resize method is specified. |
Returns |
---|
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. Some content is licensed under the numpy license.
Last updated 2024-04-26 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 2024-04-26 UTC."],[],[]]