codecamp

TensorFlow函数教程:tf.io.encode_jpeg

tf.io.encode_jpeg函数

别名:

  • tf.image.encode_jpeg
  • tf.io.encode_jpeg
tf.io.encode_jpeg(
    image,
    format='',
    quality=95,
    progressive=False,
    optimize_size=False,
    chroma_downsampling=True,
    density_unit='in',
    x_density=300,
    y_density=300,
    xmp_metadata='',
    name=None
)

JPEG编码图像。

image是一个3-D uint8 Tensor,其shape为[height, width, channels]。

参数format可用于覆盖编码输出的颜色格式。值可以是:

  • '':根据图像中的通道数使用默认格式。
  • grayscale:输出灰度JPEG图像。image的channels维度必须是1。
  • rgb:输出RGB JPEG图像。image的channels维度必须是3。

如果未指定format或为空字符串,则会根据image中的通道数选择默认格式:

  • 1:输出灰度图像。
  • 3:输出RGB图像。

参数:

  • image:uint8类型的3-D Tensor,其shape为[height, width, channels]。
  • format:可选的string,可以是:"", "grayscale", "rgb"。默认为""。每像素图像格式。
  • quality:可选的int。默认为95。压缩质量从0到100(越高越好)。
  • progressive:可选的bool。默认为False。如果为True,则创建一个逐步加载的JPEG(粗到细)。
  • optimize_size:可选的bool。默认为False。如果为True,则花费CPU/RAM来减小大小而不改变质量。
  • chroma_downsampling:可选的bool。默认为True。参见http://en.wikipedia.org/wiki/Chroma_subsampling。
  • density_unit:可选的string,可以是:"in", "cm"。默认为"in"。用于指定x_density和y_density的单位:每英寸像素数('in')或厘米('cm')。
  • x_density:可选的int。默认为300。每密度单位的水平像素。
  • y_density:可选的int。默认为300。每密度单位的垂直像素。
  • xmp_metadata:可选的string。默认为空。如果不为空,则将此XMP元数据嵌入图像标头中。
  • name:操作的名称(可选)。

返回:

string类型的Tensor。

TensorFlow函数教程:tf.io.encode_base64
TensorFlow函数教程:tf.io.extract_jpeg_shape
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

TensorFlow 函数介绍

TensorFlow 函数模块:tf

TensorFlow的image模块

TensorFlow使用之tf.io

TensorFlow使用之tf.keras

TensorFlow函数教程:tf.keras.applications

TensorFlow函数教程:tf.keras.backend

TensorFlow使用之tf.metrics

TensorFlow使用之tf.nn

TensorFlow使用之tf.python_io

TensorFlow 功能函数

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }