tf.image.stateless_random_jpeg_quality
Stay organized with collections
Save and categorize content based on your preferences.
Deterministically radomize jpeg encoding quality for inducing jpeg noise.
tf.image.stateless_random_jpeg_quality(
image, min_jpeg_quality, max_jpeg_quality, seed
)
Guarantees the same results given the same seed
independent of how many
times the function is called, and independent of global seed settings (e.g.
tf.random.set_seed
).
min_jpeg_quality
must be in the interval [0, 100]
and less than
max_jpeg_quality
.
max_jpeg_quality
must be in the interval [0, 100]
.
Usage Example:
x = tf.constant([[[1, 2, 3],
[4, 5, 6]],
[[7, 8, 9],
[10, 11, 12]]], dtype=tf.uint8)
seed = (1, 2)
tf.image.stateless_random_jpeg_quality(x, 75, 95, seed)
<tf.Tensor: shape=(2, 2, 3), dtype=uint8, numpy=
array([[[ 0, 4, 5],
[ 1, 5, 6]],
[[ 5, 9, 10],
[ 5, 9, 10]]], dtype=uint8)>
Args |
image
|
3D image. Size of the last dimension must be 1 or 3.
|
min_jpeg_quality
|
Minimum jpeg encoding quality to use.
|
max_jpeg_quality
|
Maximum jpeg encoding quality to use.
|
seed
|
A shape [2] Tensor, the seed to the random number generator. Must have
dtype int32 or int64 . (When using XLA, only int32 is allowed.)
|
Returns |
Adjusted image(s), same shape and DType as image .
|
Raises |
ValueError
|
if min_jpeg_quality or max_jpeg_quality is invalid.
|
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."],[],[],null,["# tf.image.stateless_random_jpeg_quality\n\n\u003cbr /\u003e\n\n|------------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.16.1/tensorflow/python/ops/image_ops_impl.py#L2866-L2919) |\n\nDeterministically radomize jpeg encoding quality for inducing jpeg noise. \n\n tf.image.stateless_random_jpeg_quality(\n image, min_jpeg_quality, max_jpeg_quality, seed\n )\n\nGuarantees the same results given the same `seed` independent of how many\ntimes the function is called, and independent of global seed settings (e.g.\n[`tf.random.set_seed`](../../tf/random/set_seed)).\n\n`min_jpeg_quality` must be in the interval `[0, 100]` and less than\n`max_jpeg_quality`.\n`max_jpeg_quality` must be in the interval `[0, 100]`.\n\n#### Usage Example:\n\n x = tf.constant([[[1, 2, 3],\n [4, 5, 6]],\n [[7, 8, 9],\n [10, 11, 12]]], dtype=tf.uint8)\n seed = (1, 2)\n tf.image.stateless_random_jpeg_quality(x, 75, 95, seed)\n \u003ctf.Tensor: shape=(2, 2, 3), dtype=uint8, numpy=\n array([[[ 0, 4, 5],\n [ 1, 5, 6]],\n [[ 5, 9, 10],\n [ 5, 9, 10]]], dtype=uint8)\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|--------------------|-----------------------------------------------------------------------------------------------------------------------------------------------|\n| `image` | 3D image. Size of the last dimension must be 1 or 3. |\n| `min_jpeg_quality` | Minimum jpeg encoding quality to use. |\n| `max_jpeg_quality` | Maximum jpeg encoding quality to use. |\n| `seed` | A shape \\[2\\] Tensor, the seed to the random number generator. Must have dtype `int32` or `int64`. (When using XLA, only `int32` is allowed.) |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| Adjusted image(s), same shape and DType as `image`. ||\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ------ ||\n|--------------|---------------------------------------------------------|\n| `ValueError` | if `min_jpeg_quality` or `max_jpeg_quality` is invalid. |\n\n\u003cbr /\u003e"]]