|View source on GitHub|
dtype, scaling its values if needed.
Compat aliases for migration
See Migration guide for more details.
tf.image.convert_image_dtype( image, dtype, saturate=False, name=None )
Images that are represented using floating point values are expected to have values in the range [0,1). Image data stored in integer data types are expected to have values in the range
MAX is the largest positive representable number for the data type.
This op converts between data types, scaling the values appropriately before casting.
Note that converting from floating point inputs to integer types may lead to over/underflow problems. Set saturate to
True to avoid such problem in problematic conversions. If enabled, saturation will clip the output into the allowed range before performing a potentially dangerous cast (and only before performing such a cast, i.e., when casting from a floating point to an integer type, and when casting from a signed to an unsigned type;
saturate has no effect on casts between floats, or on casts that increase the type's range).
x = [[[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]], [[7.0, 8.0, 9.0], [10.0, 11.0, 12.0]]] tf.image.convert_image_dtype(x, dtype=tf.float16, saturate=False) <tf.Tensor: shape=(2, 2, 3), dtype=float16, numpy= array([[[ 1., 2., 3.], [ 4., 5., 6.]], [[ 7., 8., 9.], [10., 11., 12.]]], dtype=float16)>
| ||An image.|
| || A |
| || If |
| ||A name for this operation (optional).|
| ||Raises an attribute error when dtype is neither float nor integer|
© 2020 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 3.0.
Code samples licensed under the Apache 2.0 License.