tf.image.rgb_to_grayscale
Converts one or more images from RGB to Grayscale.
tf.image.rgb_to_grayscale(
images, name=None
)
Outputs a tensor of the same DType
and rank as images
. The size of the
last dimension of the output is 1, containing the Grayscale value of the
pixels.
original = tf.constant([[[1.0, 2.0, 3.0]]])
converted = tf.image.rgb_to_grayscale(original)
print(converted.numpy())
[[[1.81...]]]
Args |
images
|
The RGB tensor to convert. The last dimension must have size 3 and
should contain RGB values.
|
name
|
A name for the operation (optional).
|
Returns |
The converted grayscale image(s).
|
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-01-23 UTC.
[null,null,["Last updated 2024-01-23 UTC."],[],[]]