From 5cac87ab5a0e355a708a1ac8193ae7d2aa76aa92 Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Mon, 27 Apr 2020 12:41:38 -0700 Subject: [PATCH] Saturate when converting image between datatypes in adjust_jpeg_quality. PiperOrigin-RevId: 308677540 Change-Id: Ibd1f2cfebb11fce2dcce8cafb1c7e191ce8ae368 --- tensorflow/python/ops/image_ops_impl.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tensorflow/python/ops/image_ops_impl.py b/tensorflow/python/ops/image_ops_impl.py index 26d08ca6166..e6a5cdbf4e8 100644 --- a/tensorflow/python/ops/image_ops_impl.py +++ b/tensorflow/python/ops/image_ops_impl.py @@ -2308,10 +2308,10 @@ def adjust_jpeg_quality(image, jpeg_quality, name=None): ... [10.0, 11.0, 12.0]]] >>> tf.image.adjust_jpeg_quality(x, 75) + array([[[1., 1., 1.], + [1., 1., 1.]], + [[1., 1., 1.], + [1., 1., 1.]]], dtype=float32)> Args: image: 3D image. The size of the last dimension must be None, 1 or 3. @@ -2330,14 +2330,14 @@ def adjust_jpeg_quality(image, jpeg_quality, name=None): channels = image.shape.as_list()[-1] # Remember original dtype to so we can convert back if needed orig_dtype = image.dtype - image = convert_image_dtype(image, dtypes.uint8) + image = convert_image_dtype(image, dtypes.uint8, saturate=True) if not _is_tensor(jpeg_quality): # If jpeg_quality is a int (not tensor). jpeg_quality = ops.convert_to_tensor(jpeg_quality, dtype=dtypes.int32) image = gen_image_ops.encode_jpeg_variable_quality(image, jpeg_quality) image = gen_image_ops.decode_jpeg(image, channels=channels) - return convert_image_dtype(image, orig_dtype) + return convert_image_dtype(image, orig_dtype, saturate=True) @tf_export('image.random_saturation')