tf.io.decode_jpeg——tf2.1 Document

參考自tf2.1官方文檔:
https://www.tensorflow.org/api_docs/python/tf/io/decode_jpeg


Decode a JPEG-encoded image to a uint8 tensor.
將JPEG編碼的圖像解碼爲uint8張量。

tf.io.decode_jpeg(
    contents, channels=0, ratio=1, fancy_upscaling=True,
    try_recover_truncated=False, acceptable_fraction=1, dct_method='', name=None
)

The attr channels indicates the desired number of color channels for the decoded image.
參數channels表示解碼圖像所需的顏色通道數

Accepted values are:
channels 可接受的值有:

  • 0: Use the number of channels in the JPEG-encoded image.
  • 0: 默認使用當前JPEG編碼圖像中的通道數
  • 1: output a grayscale image.
  • 1: 輸出一張灰度圖
  • 3: output an RGB image.
  • 3: 輸出一張RGB三通道的圖片

If needed, the JPEG-encoded image is transformed to match the requested number of color channels.
如果需要,可以對JPEG編碼的圖像進行轉換以匹配所需數量的顏色通道。

The attr ratio allows downscaling the image by an integer factor during decoding. Allowed values are: 1, 2, 4, and 8. This is much faster than downscaling the image later.
參數ratio允許在解碼期間將圖像按比例縮小整數倍。
允許的值有:1,2,4和8。這比之後再縮小圖像要快得多

This op also supports decoding PNGs and non-animated GIFs since the interface is the same, though it is cleaner to use tf.image.decode_image.
該函數還支持解碼PNG和非動畫GIF,因爲接口相同,不過不如使用tf.image.decode_image,這樣代碼可讀性更高。




Args:

  • contents: A Tensor of type string. 0-D. The JPEG-encoded image.

  • contents: 一個0維的string類型的張量。即JPEG編碼的圖像內容。

  • channels: An optional int. Defaults to 0. Number of color channels for the decoded image.

  • channels: 一個可選的整數。默認爲0。指定解碼圖像的顏色通道數。

  • ratio: An optional int. Defaults to 1. Downscaling ratio.

  • ratio: 指定縮圖比例,可選參數,默認爲1。

  • fancy_upscaling: An optional bool. Defaults to True. If true use a slower but nicer upscaling of the chroma planes (yuv420/422 only).

  • fancy_upscaling:布爾值,默認爲True,如果爲True,則使用較慢但更好的色度平面升頻(僅適用於yuv420 / 422)。

  • try_recover_truncated: An optional bool. Defaults to False. If true try to recover an image from truncated input.

  • try_recover_truncated:一個可選的布爾值,默認爲False,如果爲True,則嘗試從截斷的輸入中恢復圖像。

  • acceptable_fraction: An optional float. Defaults to 1. The minimum required fraction of lines before a truncated input is accepted.

  • acceptable_fraction:一個可選的float值,默認爲1。接受截斷的輸入之前需要的最小行分數。

  • dct_method: An optional string. Defaults to "" string specifying a hint about the algorithm used for decompression.
    Defaults to "" which maps to a system-specific default.
    Currently valid values are [“INTEGER_FAST”, “INTEGER_ACCURATE”].
    The hint may be ignored (e.g., the internal jpeg library changes to a version that does not have that specific option.)

  • dct_method:可選字符串參數,默認爲""字符串,用於指定解壓縮算法。
    默認爲"",將映射到系統指定的默認算法。
    一般的有效值是["INTEGER_FAST", "INTEGER_ACCURATE"].
    但是該參數也有可能被忽略(例如:若計算機內部的jpeg庫變更了版本,而該版本沒有指定的選項)

  • name: A name for the operation (optional).

  • name:(可選)爲操作指定一個名字。




Returns:

  • A Tensor of type uint8.
  • 類型爲uint8的張量
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章