tf.keras.ops.image.crop_images
Обрезает images до указанного height и width.
tf.keras.ops.image.crop_images(
images,
top_cropping=None,
left_cropping=None,
target_height=None,
target_width=None,
bottom_cropping=None,
right_cropping=None
)
| Args | |
|---|---|
images | 4-мерная партия изображений формы (batch, height, width, channels) или 3-мерное одиночное изображение формы (height, width, channels). |
top_cropping | Количество столбцов для обрезки сверху. |
bottom_cropping | Количество столбцов для обрезки снизу. |
left_cropping | Количество столбцов для обрезки слева. |
right_cropping | Количество столбцов для обрезки справа. |
target_height | Высота выходных изображений. |
target_width | Ширина выходных изображений. |
| Returns | |
|---|---|
Если images было 4D, то 4D float тензор формы (batch, target_height, target_width, channels). Если images было 3D, то 3D float тензор формы (target_height, target_width, channels). |
Пример:
images = np.reshape(np.arange(1, 28, dtype="float32"), [3, 3, 3])
images[:,:,0] # print the first channel of the images
array([[ 1., 4., 7.],
[10., 13., 16.],
[19., 22., 25.]], dtype=float32)
cropped_images = keras.image.crop_images(images, 0, 0, 2, 2)
cropped_images[:,:,0] # print the first channel of the cropped images
array([[ 1., 4.],
[10., 13.]], dtype=float32)
© 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/crop_images