ML Community Day is November 9! Join us for updates from TensorFlow, JAX, and more Learn more

tf.image.rgb_to_yuv

TensorFlow 1 version View source on GitHub

Converts one or more images from RGB to YUV.

Outputs a tensor of the same shape as the images tensor, containing the YUV value of the pixels. The output is only well defined if the value in images are in [0,1].

Usage Example:

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.rgb_to_yuv(x)
<tf.Tensor: shape=(2, 2, 3), dtype=float32, numpy=
array([[[ 1.815    ,  0.5831516, -0.7149856],
        [ 4.815    ,  0.5831516, -0.7149855]],
       [[ 7.815    ,  0.5831516, -0.7149856],
        [10.815001 ,  0.5831518, -0.7149852]]], dtype=float32)>

images 2-D or higher rank. Image data to convert. Last dimension must be size 3.

images tensor with the same shape as images.