tf.image.resize_with_pad
Stay organized with collections
Save and categorize content based on your preferences.
Resizes and pads an image to a target width and height.
tf.image.resize_with_pad(
image, target_height, target_width, method=ResizeMethod.BILINEAR,
antialias=False
)
Resizes an image to a target width and height by keeping
the aspect ratio the same without distortion. If the target
dimensions don't match the image dimensions, the image
is resized and then padded with zeroes to match requested
dimensions.
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.
|
method
|
Method to use for resizing image. See image.resize()
|
antialias
|
Whether to use anti-aliasing when resizing. See 'image.resize()'.
|
Raises |
ValueError
|
if target_height or target_width are zero or negative.
|
Returns |
Resized and 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.
[null,null,["Last updated 2020-10-01 UTC."],[],[],null,["# tf.image.resize_with_pad\n\n\u003cbr /\u003e\n\n|-----------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.0.0/tensorflow/python/ops/image_ops_impl.py#L1437-L1474) |\n\nResizes and pads an image to a target width and height. \n\n tf.image.resize_with_pad(\n image, target_height, target_width, method=ResizeMethod.BILINEAR,\n antialias=False\n )\n\nResizes an image to a target width and height by keeping\nthe aspect ratio the same without distortion. If the target\ndimensions don't match the image dimensions, the image\nis resized and then padded with zeroes to match requested\ndimensions.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|-----------------|------------------------------------------------------------------------------------------------------------|\n| `image` | 4-D Tensor of shape `[batch, height, width, channels]` or 3-D Tensor of shape `[height, width, channels]`. |\n| `target_height` | Target height. |\n| `target_width` | Target width. |\n| `method` | Method to use for resizing image. See [`image.resize()`](../../tf/image/resize) |\n| `antialias` | Whether to use anti-aliasing when resizing. See 'image.resize()'. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ------ ||\n|--------------|------------------------------------------------------------|\n| `ValueError` | if `target_height` or `target_width` are zero or negative. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| Resized and 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]`. ||\n\n\u003cbr /\u003e"]]