tf.image.decode_jpeg
tf.image.decode_jpeg
tf.image.decode_jpeg
decode_jpeg( contents, channels=None, ratio=None, fancy_upscaling=None, try_recover_truncated=None, acceptable_fraction=None, dct_method=None, name=None )
Defined in tensorflow/python/ops/gen_image_ops.py
.
See the guide: Images > Encoding and Decoding
Decode a JPEG-encoded image to a uint8 tensor.
The attr channels
indicates the desired number of color channels for the decoded image.
Accepted values are:
- 0: Use the number of channels in the JPEG-encoded image.
- 1: output a grayscale image.
- 3: output an RGB image.
If needed, the JPEG-encoded image is transformed to match the requested number of color channels.
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.
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
.
Args:
-
contents
: ATensor
of typestring
. 0-D. The JPEG-encoded image. -
channels
: An optionalint
. Defaults to0
. Number of color channels for the decoded image. -
ratio
: An optionalint
. Defaults to1
. Downscaling ratio. -
fancy_upscaling
: An optionalbool
. Defaults toTrue
. If true use a slower but nicer upscaling of the chroma planes (yuv420/422 only). -
try_recover_truncated
: An optionalbool
. Defaults toFalse
. If true try to recover an image from truncated input. -
acceptable_fraction
: An optionalfloat
. Defaults to1
. The minimum required fraction of lines before a truncated input is accepted. -
dct_method
: An optionalstring
. 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.) -
name
: A name for the operation (optional).
Returns:
A Tensor
of type uint8
. 3-D with shape [height, width, channels]
..
© 2017 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 3.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/api_docs/python/tf/image/decode_jpeg