W3cubDocs

/TensorFlow Python

tf.image.decode_image

tf.image.decode_image(
    contents,
    channels=None,
    name=None
)

Defined in tensorflow/python/ops/image_ops_impl.py.

See the guide: Images > Encoding and Decoding

Convenience function for decode_bmp, decode_gif, decode_jpeg, and decode_png.

Detects whether an image is a BMP, GIF, JPEG, or PNG, and performs the appropriate operation to convert the input bytes string into a Tensor of type uint8.

Note: decode_gif returns a 4-D array [num_frames, height, width, 3], as opposed to decode_bmp, decode_jpeg and decode_png, which return 3-D arrays [height, width, num_channels]. Make sure to take this into account when constructing your graph if you are intermixing GIF files with BMP, JPEG, and/or PNG files.

Args:

  • contents: 0-D string. The encoded image bytes.
  • channels: An optional int. Defaults to 0. Number of color channels for the decoded image.
  • name: A name for the operation (optional)

Returns:

Tensor with type uint8 with shape [height, width, num_channels] for BMP, JPEG, and PNG images and shape [num_frames, height, width, 3] for GIF images.

Raises:

  • ValueError: On incorrect number of channels.

© 2018 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_image