codecamp

TensorFlow函数:tf.image.encode_jpeg

tf.image.encode_jpeg函数

tf.image.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是一个三维uint8张量的形状[height, width, channels].

attr format可以用来覆盖编码输出的颜色格式.值可以是:

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

如果format未指定或者为空字符串,则在image中通道数的函数中选取默认格式:

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

参数:

  • image:uint8类型的Tensor,三维形状[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.image.draw_bounding_boxes
TensorFlow函数:tf.image.encode_png
温馨提示
下载编程狮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; }