tf.io.decode_and_crop_jpeg
Stay organized with collections
Save and categorize content based on your preferences.
Decode and Crop a JPEG-encoded image to a uint8 tensor.
tf.io.decode_and_crop_jpeg(
contents: Annotated[Any, _atypes.String],
crop_window: Annotated[Any, _atypes.Int32],
channels: int = 0,
ratio: int = 1,
fancy_upscaling: bool = True,
try_recover_truncated: bool = False,
acceptable_fraction: float = 1,
dct_method: str = '',
name=None
) -> Annotated[Any, _atypes.UInt8]
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.
It is equivalent to a combination of decode and crop, but much faster by only
decoding partial jpeg image.
Args |
contents
|
A Tensor of type string . 0-D. The JPEG-encoded image.
|
crop_window
|
A Tensor of type int32 .
1-D. The crop window: [crop_y, crop_x, crop_height, crop_width].
|
channels
|
An optional int . Defaults to 0 .
Number of color channels for the decoded image.
|
ratio
|
An optional int . Defaults to 1 . Downscaling ratio.
|
fancy_upscaling
|
An optional bool . Defaults to True .
If true use a slower but nicer upscaling of the
chroma planes (yuv420/422 only).
|
try_recover_truncated
|
An optional bool . Defaults to False .
If true try to recover an image from truncated input.
|
acceptable_fraction
|
An optional float . Defaults to 1 .
The minimum required fraction of lines before a truncated
input is accepted.
|
dct_method
|
An optional string . 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 .
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates. Some content is licensed under the numpy license.
Last updated 2024-04-26 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-04-26 UTC."],[],[]]