TensorFlow函數(shù)教程:tf.io.decode_png

2019-02-22 16:13 更新

tf.io.decode_png函數(shù)

別名:

  • tf.image.decode_png
  • tf.io.decode_png
tf.io.decode_png(
    contents,
    channels=0,
    dtype=tf.dtypes.uint8,
    name=None
)

將PNG編碼的圖像解碼為uint8或uint16張量。

參數(shù)channels表示解碼圖像的所需數(shù)量的顏色通道。

可接受的值是:

  • 0:使用PNG編碼圖像中的通道數(shù)。
  • 1:輸出灰度圖像。
  • 3:輸出RGB圖像。
  • 4:輸出RGBA圖像。

如果需要,轉(zhuǎn)換PNG編碼的圖像以匹配所請(qǐng)求的顏色通道數(shù)。

此操作還支持解碼JPEG和非動(dòng)畫(huà)GIF,因?yàn)榻缑嫦嗤褂?a href="http://www.o2fo.com/tensorflow_python/tensorflow_python-ug6x2qa6.html" target="_blank">tf.image.decode_image更簡(jiǎn)潔。

參數(shù):

  • contents:string類(lèi)型的0-d Tensor。PNG編碼的圖像。
  • channels:可選的int。默認(rèn)為0。解碼圖像的顏色通道數(shù)。
  • dtype:可選的tf.DType,可以是:tf.uint8, tf.uint16。默認(rèn)為tf.uint8。
  • name:操作的名稱(chēng)(可選)。

返回:

dtype類(lèi)型的Tensor。

以上內(nèi)容是否對(duì)您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)