TensorFlow函数:tf.image.pad_to_bounding_box

2018-06-05 11:03 更新

tf.image.pad_to_bounding_box函数

tf.image.pad_to_bounding_box(
    image,
    offset_height,
    offset_width,
    target_height,
    target_width
)

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

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

用零指定的height和width来填充image.

在顶部增加了零的offset_height行,在左侧添加零的offset_width列,然后用0填充底部和右侧的图像,直到它具有target_height,target_width等维度.

如果此操作offset_*为零且该图像已具有大小target_height x target_width,则此操作不会执行任何操作.

参数:

  • image:形状为[batch, height, width, channels]的4维张量,或形状为[height, width, channels]的3维张量.
  • offset_height:在顶部添加零的行数.
  • offset_width:在左侧添加的零的列数.
  • target_height:输出图像的高度.
  • target_width:输出图像的宽度.

返回:

如果image是四维,则返回形状为[batch, target_height, target_width, channels]的四维浮点型张量;如果image是三维的,则返回形状为[target_height, target_width, channels]的三维浮点型张量.

可能引发的异常:

  • ValueError:如果image的形状与offset_*或target_*参数不兼容,或者是offset_height和offset_width其中一个为负.
以上内容是否对您有帮助:
在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号