# HSV color space

Color value H , saturation S , darkness V
Color scale

The HSV color space is the color space of a number of color models . In it the chromaticity point of a color is defined with the help of the three coordinates:

• Color value ( English h ue ): color angle on the color wheel (0 ° for red, 120 ° for green, 240 ° for blue)
• Saturation ( s aturation) : (0% =  neutral gray , 50% = low in saturated color, 100% = saturated, pure color ), corresponding to an interval from zero to one
• Brightness value (also called dark level) ( v alue) : (0% = no brightness, 100% = full brightness), corresponds to an interval from zero to one

• an HSL color space having the relative brightness ( l ightness) instead of the bright value
• an HSB color space with absolute brightness ( b rightness)
• an HSI color space with the light intensity ( i ntensity) .

## HSV room and color perception

The HSV coordinates using the example of navy blue

In matters of color matching the HSV paradigm over the alternatives RGB and CMYK preferred because it is the human (artistic) perception of color is similar. For the color mixture , you can immediately choose the desired shade and then decide how saturated and how light (or dark) it should be, or whether another shade is more suitable:

• the hue angle specifies the dominant wavelength of the color, with the exception of the area between blue-violet and red (240 ° and 360 °), where it indicates a position on the purple line .
• the saturation corresponds to the admixture of pure white (i.e. light with equal intensities in all wavelengths) to a simulated spectral color (or rather the corresponding slit width around the dominant wavelength); a stronger addition of white corresponds to a lower saturation.
• the brightness is a parameter for the total energy content or for the maximum amplitude of the light; the level of darkness complements this value on the contrary. The disadvantage of the dark level is that white and any hue can have the same saturation. In this system, white is treated as a chromatic color. In practice, on the other hand, it is not possible to convert a color image into a black and white image by changing just one coordinate.

RGB and CMYK, on ​​the other hand, are selection methods that are tied to the existing (device-dependent) basic colors , so that the focus is less on the free choice than on the color result.

The HSV coordinates of a body color  - which is necessarily a mixed color - cannot be determined directly from the parameters of its physical light spectrum , as is possible in radiometry with the spectral value curves . In contrast, the HSV coordinates are used to infer the parameters of the spectrum such as wavelength and amplitude using suitable colorimetric formula sets . However, metamerism has a limiting effect here , since it is not possible without problems to determine the multiplicity of a spectrum from three coordinates; However, this is not a major problem, since the HSV system is usually not used to determine the properties of a spectrum, but to select colors.

## Visualization

### Models

 HSV color space as a cone HSV color space as a cylinder

Color models that clearly illustrate the HSV parameters are:

• the HSV cone standing on the tip , in which the brightness decreases from the top (color circle) to the bottom (tip = black).
• a cylinder in which the brightness decreases to an area (instead of a point).
• a hemisphere , the colorimetrically correct model.
• a hexagonal pyramid (illustration e.g. here ), which deals more precisely with the gamut problem. However, the S values ​​can no longer be read directly, or they only give a total of 100% for the six basic colors . The hexagonal pyramid is not a color space.

For the HSL, HSI and HSB models described below, there are variants as double cones, double pyramids or spheres .

Due to the wide variety of forms of representation, the HSV values ​​for the same color point differ in some cases, which means that it is essential to specify the model used. While this makes the HSV models useful for selecting and displaying colors, complications can arise when it comes to colorimetry .

By specifying the model used, HSV values ​​can be converted into Lab coordinates , which can then be transferred to other color models.

### Color picker

An HSV color picker

For color selectors in computer science, it is common to use the HSV model to represent the color space. In order to select a certain color with the help of its HSV parameters and to determine the values, the HSV color wheel is used in a separate diagram , from which the hue  H is selected directly. Then the other two parameters  S and  V are selected. This can be done on a triangle in which the saturation is plotted on one side of the triangle and the brightness is plotted on its center perpendicular . One variant is an SV triangle inside the color wheel, the tip of which points to the hue in the color wheel, the side of the triangle of saturation ends in this tip. Variants with a fixed vertical axis for  S are also common. A program that uses such a color picker determines the appropriate section through the color body for color  H and displays it in a triangle. The section is a vertical, radial section along the white-black axis.

Another variant of the color selector based on the HSV model is a HV level, in addition to which a separate S control is available. In order to support the color selection by the user, the saturation of the color tones displayed in the HV level is adapted to the respective value of the S controller as soon as it is changed. This representation corresponds to a conical or cylindrical section through the color space, the respective saturation corresponding to the radius of the section relative to the white-black axis.

## Transformation of HSV / HSL and RGB

Relationships between HSV and RGB space
Comparison of HSV / HSL and RGB
colour H S. V | H S. L. | R. G B.
red 0 ° 100% 100% 0 ° 100% 50% 100% 0% 0%
orange 30 ° 100% 100% 30 ° 100% 50% 100% 50% 0%
yellow 60 ° 100% 100% 60 ° 100% 50% 100% 100% 0%
Dark green 120 ° 100% 50% 120 ° 100% 25% 0% 50% 0%
violet 270 ° 100% 100% 270 ° 100% 50% 50% 0% 100%
black - - 0% - - 0% 0% 0% 0%
blue 240 ° 100% 100% 240 ° 100% 50% 0% 0% 100%
brown 20 ° 75% 36% 20 ° 60% 22.5% 36% 18% 9%
White - 0% 100% - - 100% 100% 100% 100%
green 120 ° 100% 100% 120 ° 100% 50% 0% 100% 0%
Cyan 180 ° 100% 100% 180 ° 100% 50% 0% 100% 100%
magenta 300 ° 100% 100% 300 ° 100% 50% 100% 0% 100%
Blue green 150 ° 100% 100% 150 ° 100% 50% 0% 100% 50%
Green Blue 210 ° 100% 100% 210 ° 100% 50% 0% 50% 100%
Green yellow 90 ° 100% 100% 90 ° 100% 50% 50% 100% 0%
Blue red 330 ° 100% 100% 330 ° 100% 50% 100% 0% 50%
cinnabar 15 ° 100% 100% 15 ° 100% 50% 100% 25% 0%
indigo 255 ° 100% 100% 255 ° 100% 50% 25% 0% 100%
Light blue-green 135 ° 100% 100% 135 ° 100% 50% 0% 100% 25%
Blue cyan 195 ° 100% 100% 195 ° 100% 50% 0% 75% 100%
Light green yellow 75 ° 100% 100% 75 ° 100% 50% 75% 100% 0%
Red magenta 315 ° 100% 100% 315 ° 100% 50% 100% 0% 75%
saffron 45 ° 100% 100% 45 ° 100% 50% 100% 75% 0%
Blue magenta 285 ° 100% 100% 285 ° 100% 50% 75% 0% 100%
Green cyan 165 ° 100% 100% 165 ° 100% 50% 0% 100% 75%
Light green-blue 225 ° 100% 100% 225 ° 100% 50% 0% 25% 100%
Lime 105 ° 100% 100% 105 ° 100% 50% 25% 100% 0%
Light blue red 345 ° 100% 100% 345 ° 100% 50% 100% 0% 25%

The conversion follows the Gonzalez and Woods formula.

• ( R , G , B ): Color values ​​according to RGB. R , G and B are in the interval .${\ displaystyle [0,1]}$
• ( H , S , V ): Associated HSV color. H lies in the half-open interval to ensure uniqueness, S and V again in the interval or .${\ displaystyle [0 ^ {\ circ}, 360 ^ {\ circ}]}$${\ displaystyle [0.100 \, \%]}$${\ displaystyle [0,1]}$

These intervals apply to the model presented here. Other formula sets with the same result give Foley and Van Dam or Travis.

• Colorimetric specifications of H , S and V are also normalized , which are therefore similar to those of the RGB model. The formula set below would then be correspondingly simpler.${\ displaystyle [0,1]}$
• Furthermore, values ​​in intervals are used ( hexadecimal as , octal as ) that are suitable for 8-bit information (discrete model). For the specified formulas, such values ​​are to be normalized to the intervals used here. In addition, it should be noted whether the body for the underlying model is a cube, a sphere, a cone or a double cone.${\ displaystyle [0.255]}$${\ displaystyle [0, FF]}$${\ displaystyle [0.377]}$

### Conversion from RGB to HSV / HSL

Precondition: ${\ displaystyle R, G, B \ in [0,1]}$
${\ displaystyle MAX: = \ max (R, G, B), \; MIN: = \ min (R, G, B)}$
${\ displaystyle H: = {\ begin {cases} 0, & {\ text {if}} \; MAX = MIN \ Leftrightarrow R = G = B \\ 60 ^ {\ circ} \ cdot \ left (0+ { \ frac {GB} {MAX-MIN}} \ right), & {\ text {if}} \; MAX = R \\ 60 ^ {\ circ} \ cdot \ left (2 + {\ frac {BR} { MAX-MIN}} \ right), & {\ text {if}} \; MAX = G \\ 60 ^ {\ circ} \ cdot \ left (4 + {\ frac {RG} {MAX-MIN}} \ right), & {\ text {falls}} \; MAX = B \ end {cases}}}$
${\ displaystyle {\ text {if}} \; H <0 ^ {\ circ} \; {\ text {then}} \; H: = H + 360 ^ {\ circ}}$
${\ displaystyle S _ {\ mathrm {HSV}}: = {\ begin {cases} 0, & {\ text {falls}} \; MAX = 0 \ Leftrightarrow R = G = B = 0 \\ {\ frac {MAX -MIN} {MAX}}, & {\ text {otherwise}} \ end {cases}}}$
${\ displaystyle S _ {\ mathrm {HSL}}: = {\ begin {cases} 0, & {\ text {falls}} \; MAX = 0 \ Leftrightarrow R = G = B = 0 \\ 0, & {\ text {if}} \; MIN = 1 \ Leftrightarrow R = G = B = 1 \\ {\ frac {MAX-MIN} {1- \ left \ vert MAX + MIN-1 \ right \ vert}}, & { \ text {otherwise}} \ end {cases}}}$
${\ displaystyle V: = MAX}$
${\ displaystyle L: = {\ frac {MAX + MIN} {2}}}$
Postcondition: ${\ displaystyle H \ in [0 ^ {\ circ}, 360 ^ {\ circ}], \; S, V, L \ in [0,1]}$

These formulas reflect some peculiarities of the HSV values:

• If R  =  G  =  B , then H has no meaning and is set by definition to H  = 0.
It is obvious. Because if S  = 0 (unsaturated color), then the color point is on the central gray line, the hue is so irrelevant and cannot be specified meaningfully.
• If R  =  G  =  B  = 0, then S is irrelevant and, by definition, S  = 0 is set.
Because if all three RGB values ​​are "zero", it is about black and the saturation of the color loses its meaning. However, the same does not apply in the case of MAX  =  MIN  = 1, i.e. H. Knows that the value 0 delivered by the formula is of elementary importance, as can be seen from the cone shape above.

For computational reasons, undefined values ​​are filled with "zero".

### Conversion from HSV to RGB

Precondition: ${\ displaystyle H \ in [0 ^ {\ circ}, 360 ^ {\ circ}], \; S, V \ in [0,1]}$

The basic color interval, the value within this interval in and three additional values ​​are determined which already contain the respective route lengths, but are to be distributed accordingly to the components R , G and B : ${\ displaystyle h_ {i}}$${\ displaystyle f}$${\ displaystyle [0,1]}$

${\ displaystyle h _ {\ mathrm {i}}: = \ left \ lfloor {H \ over 60 ^ {\ circ}} \ right \ rfloor; \; \; \; f: = \ left ({\ frac {H } {60 ^ {\ circ}}} - h _ {\ mathrm {i}} \ right)}$
${\ displaystyle p: = V \ cdot (1-S); \ quad q: = V \ cdot (1-S \ cdot f); \ quad t: = V \ cdot \ left (1-S \ cdot (1 -f) \ right)}$
${\ displaystyle (R, G, B): = {\ begin {cases} (V, t, p), & {\ text {falls}} h _ {\ mathrm {i}} \ in \ {0.6 \ } \\ (q, V, p), & {\ text {if}} h _ {\ mathrm {i}} = 1 \\ (p, V, t), & {\ text {if}} h _ {\ mathrm {i}} = 2 \\ (p, q, V), & {\ text {if}} h _ {\ mathrm {i}} = 3 \\ (t, p, V), & {\ text { if}} h _ {\ mathrm {i}} = 4 \\ (V, p, q), & {\ text {falls}} h _ {\ mathrm {i}} = 5 \ end {cases}}}$
Postcondition: ${\ displaystyle R, G, B \ in [0,1]}$

If S  = 0, the resulting color neutral gray, and the formula is simplified to R  =  G  =  B  =  V .

## Modified color models

Sometimes other assignments of the color angle to the color wheel are common, which then differ in the position of the zero point on the chrominance scale. Conversions for these modified HSV rooms can be found at Gonzalez and Woods or Foley and Van Dam.

### HSL

The HSL color space (also referred to as HLS) has the parameters color angle H, color saturation S and color lightness L. In contrast to the HSV color space, however, it is related to the gray point between white and black as neutral gray . The gray point is in the middle and the chromatic values ​​on the outside, the color body is therefore represented as a double cone , (double) cylinder or six-sided prism .

The CIE-LCh ° model has a similar structure with color brightness L, chroma  C (corresponds to the saturation) and the hue angle  h ° (corresponds to the hue angle), which corresponds to a Lab color space in cylindrical coordinates.

### HSB and HSI

The HSB and HSI models are based on the needs of colorimetry and phototechnical reproduction . Here, too, H stands for  hue and S for saturation. The difference relates to the third coordinate: