HSV and RGB

Last Updated on : 2022-11-24 09:20:20download

RGB color model

The RGB (red, green, blue) color model is an additive color model in which red, green, and blue light are added together in various ways to reproduce a broad array of colors. The main purpose of the RGB color model is for the sensing, representation, and display of images in electronic systems. The color is expressed as an RGB triplet, each component of which can vary from zero to a defined maximum value. If all the components are at zero, the result is black; if all are at maximum, the result is the brightest representable white. A color’s RGB value is not directly related to color-making attributes: hue, saturation, and lightness.

HSV color model

HSV (hue, saturation, value) is a color model that specifies colors based on the dimensions of color most intuitive to human cognition.

It is an alternative representation of the RGB color model and more closely aligns with the way human vision perceives color-making attributes.

  • Hue
    Hue is the angle counterclockwise around the color cone, representing the actual color itself. Its value ranges from 0° to 360°, typically 0° is red, 60° yellow, 120° green, 180° cyan, 240° blue, and 300° magenta.

  • Saturation
    Saturation is the distance from the center of a circular cross-section of the cone, representing the vibrancy of the color. Its value ranges from 0.0 to 1.0, where 0.0 is a shade of grey and 1.0 is the full color.

  • Value
    Value is the brightness of the color. Value is the height of the cone, representing the brightness of the color. Its value ranges from 0.0 to 1.0, with 0.0 being black and 1.0 white.

    HSV and RGB

Applications of HSV

The HSV color model is widely used to produce high quality computer graphics. The HSV color wheel is used to pick the desired color. Hue is represented by the circle in the wheel. A separate triangle is used to represent saturation and value. The horizontal axis of the triangle indicates value and the vertical axis represents saturation.

When users need a particular color, they first need to select hue from the circular region and then saturation and value from the triangle. The HSV color space can also be illustrated as a cylindrical model, where the hue is the angle around the color cylinder, the saturation is the distance from the center, and the value is the height from the bottom.

Conversion between HSV and RGB

The HSV color model is more intuitive to human vision but the RGB color model is preferred by display hardware. Therefore, we sometimes need to make a conversion between them.

Suppose R, G, and B are the red, green, and blue values of a color and each value must be a real number between 0 to 1. Let Max and Min be the maximum value and the minimum value among R, G, and B. For the HSV color space, H ∈ [0°, 360°), S ∈ [0, 1], and V ∈ [0, 1]. Since there are operations with decimals in the conversion, the precision might be compromised.

HSV to RGB

HSV and RGB HSV and RGB

RGB to HSV

HSV and RGB