TensorFlow函數(shù):tf.image.pad_to_bounding_box

2018-06-05 11:03 更新

tf.image.pad_to_bounding_box函數(shù)

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行,在左側(cè)添加零的offset_width列,然后用0填充底部和右側(cè)的圖像,直到它具有target_height,target_width等維度.

如果此操作offset_*為零且該圖像已具有大小target_height x target_width,則此操作不會執(zhí)行任何操作.

參數(shù):

  • image:形狀為[batch, height, width, channels]的4維張量,或形狀為[height, width, channels]的3維張量.
  • offset_height:在頂部添加零的行數(shù).
  • offset_width:在左側(cè)添加的零的列數(shù).
  • target_height:輸出圖像的高度.
  • target_width:輸出圖像的寬度.

返回:

如果image是四維,則返回形狀為[batch, target_height, target_width, channels]的四維浮點(diǎn)型張量;如果image是三維的,則返回形狀為[target_height, target_width, channels]的三維浮點(diǎn)型張量.

可能引發(fā)的異常:

  • ValueError:如果image的形狀與offset_*或target_*參數(shù)不兼容,或者是offset_height和offset_width其中一個為負(fù).
以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號