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