# tf.image.rgb_to_grayscale

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.14.0/tensorflow/python/ops/image_ops_impl.py#L2554-L2587) |

Converts one or more images from RGB to Grayscale.

#### View aliases


**Compat aliases for migration**

See
[Migration guide](https://www.tensorflow.org/guide/migrate) for
more details.

[`tf.compat.v1.image.rgb_to_grayscale`](https://www.tensorflow.org/api_docs/python/tf/image/rgb_to_grayscale)

<br />

    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...]]]

<br />

<br />

<br />

| ## 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). |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| The converted grayscale image(s). ||

<br />