DecodeJpeg

Stay organized with collections Save and categorize content based on your preferences.
public final class DecodeJpeg

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.io.decode_image.

Nested Classes

class DecodeJpeg.Options Optional attributes for DecodeJpeg  

Constants

String OP_NAME The name of this op, as known by TensorFlow core engine

Public Methods

static DecodeJpeg.Options
acceptableFraction(Float acceptableFraction)
Output<TUint8>
asOutput()
Returns the symbolic handle of the tensor.
static DecodeJpeg.Options
channels(Long channels)
static DecodeJpeg
create(Scope scope, Operand<TString> contents, Options... options)
Factory method to create a class wrapping a new DecodeJpeg operation.
static DecodeJpeg.Options
dctMethod(String dctMethod)
static DecodeJpeg.Options
fancyUpscaling(Boolean fancyUpscaling)
Output<TUint8>
image()
3-D with shape `[height, width, channels]`..
static DecodeJpeg.Options
ratio(Long ratio)
static DecodeJpeg.Options
tryRecoverTruncated(Boolean tryRecoverTruncated)

Inherited Methods

Constants

public static final String OP_NAME

The name of this op, as known by TensorFlow core engine

Constant Value: "DecodeJpeg"

Public Methods

public static DecodeJpeg.Options acceptableFraction (Float acceptableFraction)

Parameters
acceptableFraction The minimum required fraction of lines before a truncated input is accepted.

public Output<TUint8> asOutput ()

Returns the symbolic handle of the tensor.

Inputs to TensorFlow operations are outputs of another TensorFlow operation. This method is used to obtain a symbolic handle that represents the computation of the input.

public static DecodeJpeg.Options channels (Long channels)

Parameters
channels Number of color channels for the decoded image.

public static DecodeJpeg create (Scope scope, Operand<TString> contents, Options... options)

Factory method to create a class wrapping a new DecodeJpeg operation.

Parameters
scope current scope
contents 0-D. The JPEG-encoded image.
options carries optional attributes values
Returns
  • a new instance of DecodeJpeg

public static DecodeJpeg.Options dctMethod (String dctMethod)

Parameters
dctMethod 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.)

public static DecodeJpeg.Options fancyUpscaling (Boolean fancyUpscaling)

Parameters
fancyUpscaling If true use a slower but nicer upscaling of the chroma planes (yuv420/422 only).

public Output<TUint8> image ()

3-D with shape `[height, width, channels]`..

public static DecodeJpeg.Options ratio (Long ratio)

Parameters
ratio Downscaling ratio.

public static DecodeJpeg.Options tryRecoverTruncated (Boolean tryRecoverTruncated)

Parameters
tryRecoverTruncated If true try to recover an image from truncated input.