TensorFlow函数:tf.image.resize_image_with_crop_or_pad

2018-06-14 11:22 更新

tf.image.resize_image_with_crop_or_pad函数

tf.image.resize_image_with_crop_or_pad(
    image,
    target_height,
    target_width
)

定义在:tensorflow/python/ops/image_ops_impl.py.

请参阅指南:图像操作>裁剪

裁剪或将图像填充到目标宽度和高度.

通过集中修剪图像或用零均匀填充图像,将图像调整为目标宽度和高度.

如果width或height分别大于指定的target_width或target_height值,则此操作集中沿着该维度裁剪.如果width或者height分别小于指定的target_width或target_height值,则此op在该维度上集中填充0.

参数:

  • image:形状为[batch, height, width, channels]的4-D张量或形状为[height, width, channels]的3-D张量.
  • target_height:目标高度.
  • target_width:目标宽度.

可能引发的异常:

  • ValueError:如果target_height或者target_width为零或负数.

返回:

裁剪或填充图像;如果images是四维,则返回一个形状为[batch, new_height, new_width, channels]四维浮动张量;如果images是三维,则返回一个形状为[new_height, new_width, channels]的三维浮动张量.

以上内容是否对您有帮助:
在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号