tf.keras.ops.image.pad_images
Дополнить images нулями до заданных height и width.
tf.keras.ops.image.pad_images(
images,
top_padding=None,
left_padding=None,
target_height=None,
target_width=None,
bottom_padding=None,
right_padding=None
)
| Аргументы | |
|---|---|
images | 4D-тензор формы (batch, height, width, channels) или 3D-тензор формы (height, width, channels). |
top_padding | Количество строк нулей, добавляемых сверху. |
bottom_padding | Количество строк нулей, добавляемых снизу. |
left_padding | Количество столбцов нулей, добавляемых слева. |
right_padding | Количество столбцов нулей, добавляемых справа. |
target_height | Высота выходных изображений. |
target_width | Ширина выходных изображений. |
| Возвращает | |
|---|---|
Если images был 4D, возвращается 4D-тензор типа float формы (batch, target_height, target_width, channels) Если images был 3D, возвращается 3D-тензор типа float формы (target_height, target_width, channels) |
Пример:
images = np.random.random((15, 25, 3))
padded_images = keras.ops.image.pad_images(
images, 2, 3, target_height=20, target_width=30
)
padded_images.shape
(20, 30, 3)batch_images = np.random.random((2, 15, 25, 3))
padded_batch = keras.ops.image.pad_images(
batch_images, 2, 3, target_height=20, target_width=30
)
padded_batch.shape
(2, 20, 30, 3)
© 2022 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 4.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/api_docs/python/tf/keras/ops/image/pad_images