TF 2.0 is out! Get hands-on practice at TF World, Oct 28-31. Use code TF20 for 20% off select passes. Register now


TensorFlow 1 version

Defined in generated file: python/ops/

Converts one or more images from RGB to HSV.


  • tf.compat.v1.image.rgb_to_hsv
  • tf.compat.v2.image.rgb_to_hsv

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

output[..., 0] contains hue, output[..., 1] contains saturation, and output[..., 2] contains value. All HSV values are in [0,1]. A hue of 0 corresponds to pure red, hue 1/3 is pure green, and 2/3 is pure blue.


  • images: A Tensor. Must be one of the following types: half, bfloat16, float32, float64. 1-D or higher rank. RGB data to convert. Last dimension must be size 3.
  • name: A name for the operation (optional).


A Tensor. Has the same type as images.