Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

HSL and HSV

From Wikipedia, the free encyclopedia
(Redirected fromHSV color space)
Alternative representations of the RGB color model
Fig. 1. HSL (a–d) and HSV (e–h). Above (a, e): cut-away three-dimensional models of each. Below: two-dimensional plots showing two of a model's three parameters at once, holding the other constant: cylindrical shells (b, f) of constant saturation, in this case the outside surface of each cylinder; horizontal cross-sections (c, g) of constant HSL lightness or HSV value, in this case the slices halfway down each cylinder; and rectangular vertical cross-sections (d, h) of constant hue, in this case of hues 0° red and its complement 180° cyan.

HSL andHSV are the two most commoncylindrical-coordinate representations of points in anRGB color model. The two representations rearrange the geometry of RGB in an attempt to be more intuitive andperceptually relevant than thecartesian (cube) representation. Developed in the 1970s forcomputer graphics applications, HSL and HSV are used today incolor pickers, inimage editing software, and less commonly inimage analysis andcomputer vision.

HSL stands forhue,saturation, andlightness, and is often also calledHLS. HSV stands forhue,saturation, andvalue, and is also often calledHSB (B forbrightness). A third model, common in computer vision applications, isHSI, forhue,saturation, andintensity. However, while typically consistent, these definitions are not standardized, and any of these abbreviations might be used for any of these three or several other related cylindrical models. (For technical definitions of these terms, seebelow.)

In each cylinder, the angle around the central vertical axis corresponds to "hue", the distance from the axis corresponds to "saturation", and the distance along the axis corresponds to "lightness", "value" or "brightness". Note that while "hue" in HSL and HSV refers to the same attribute, their definitions of "saturation" differ dramatically. Because HSL and HSV are simple transformations of device-dependent RGB models, the physical colors they define depend on the colors of the red, green, and blueprimaries of the device or of the particular RGB space, and on thegamma correction used to represent the amounts of those primaries. Each unique RGB device therefore has unique HSL and HSV spaces to accompany it, and numerical HSL or HSV values describe a different color for each basis RGB space.[1]

Both of these representations are used widely in computer graphics, and one or the other of them is often more convenient than RGB, but both are also criticized for not adequately separating color-making attributes, or for their lack of perceptual uniformity. Other more computationally intensive models, such asCIELAB orCIECAM02 are said to better achieve these goals.

Basic principle

[edit]
Fig. 2a. HSL cylinder.
Fig. 2b. HSV cylinder.

HSL and HSV are both cylindrical geometries (fig. 2), with hue, their angular dimension, starting at theredprimary at 0°, passing through thegreen primary at 120° and theblue primary at 240°, and then wrapping back to red at 360°. In each geometry, the central vertical axis comprises theneutral,achromatic, orgray colors ranging, from top to bottom, white at lightness 1 (value 1) to black at lightness 0 (value 0).

In both geometries, theadditive primary andsecondary colors – red,yellow, green,cyan, blue andmagenta – and linear mixtures between adjacent pairs of them, sometimes calledpure colors, are arranged around the outside edge of the cylinder with saturation 1. These saturated colors have lightness 0.5 in HSL, while in HSV they have value 1. Mixing these pure colors with black – producing so-calledshades – leaves saturation unchanged. In HSL, saturation is also unchanged bytinting with white, and only mixtures with both black and white – calledtones – have saturation less than 1. In HSV, tinting alone reduces saturation.

Fig. 3a–b. If we plot hue and (a) HSL lightness or (b) HSV value against chroma (range of RGB values) rather than saturation (chroma over maximum chroma for that slice), the resulting solid is abicone orcone, respectively, not a cylinder. Such diagrams often claim to represent HSL or HSV directly, with the chroma dimension confusingly labeled "saturation".

Because these definitions of saturation – in which very dark (in both models) or very light (in HSL) near-neutral colors are considered fully saturated (for instance, from the bottom right in the sliced HSL cylinder or from the top right) – conflict with the intuitive notion of color purity, often aconic orbiconic solid is drawn instead (fig. 3), with what this article callschroma as its radial dimension (equal to therange of the RGB values), instead of saturation (where the saturation is equal to the chroma over the maximum chroma in that slice of the (bi)cone). Confusingly, such diagrams usually label this radial dimension "saturation", blurring or erasing the distinction between saturation and chroma.[A]As described below, computing chroma is a helpful step in the derivation of each model. Because such an intermediate model – with dimensions hue, chroma, and HSV value or HSL lightness – takes the shape of a cone or bicone, HSV is often called the "hexcone model" while HSL is often called the "bi-hexcone model" (fig. 8).[B]

Motivation

[edit]
See also:Color theory,RGB color model, andRGB color space
Fig. 4. Painters long mixed colors by combining relatively bright pigments with black and white. Mixtures with white are calledtints, mixtures with black are calledshades, and mixtures with both are calledtones. SeeTints and shades.[2]
Several paint mixing terms can be arranged into a triangular arrangement: the left edge of the triangle shows white at its top and black at its bottom with gray between the two, each in its respective oval. A pure color (in this case, a bright blue-green) lies at the right corner of the triangle. On the edge between the pure color and black is a shade (a darker blue-green), between the pure color and white is a tint (a lighter, faded blue-green), and a tone lies in the middle of the triangle (a muted blue-green).
Fig. 5. This 1916 color model by German chemistWilhelm Ostwald exemplifies the "mixtures with white and black" approach, organizing 24 "pure" colors into ahue circle, and colors of each hue into a triangle. The model thus takes the shape of a bicone.[3][4]
The RGB cube has black at its origin, and the three dimensions R, G, and B pointed in orthogonal directions away from black. The corner in each of those directions is the respective primary color (red, green, or blue), while the corners further away from black are combinations of two primaries (red plus green makes yellow, red plus blue makes magenta, green plus blue makes cyan). At the cube's corner farthest from the origin lies white. Any point in the cube describes a particular color within the gamut of RGB.
Fig. 6a. The RGB gamut can be arranged in a cube.
The same image, with a portion removed for clarity.
Fig. 6b. The same image, with a portion removed for clarity.
In classic patent application style, this is a black-and-white diagram with the patent name, inventor name, and patent number listed at the top, shaded by crosshatching. This diagram shows a three-dimensional view of Tektronix's biconic HSL geometry, made up of horizontal circular slices along a vertical axis expanded for ease of viewing. Within each circular slice, saturation goes from zero at the center to one at the margins, while hue is an angular dimension, beginning at blue with hue zero, through red with hue 120 degrees and green with hue 240 degrees, and back to blue.
Fig. 7. Tektronix graphics terminals used the earliest commercial implementation of HSL, in 1979. This diagram, from a patent filed in 1983, shows the bicone geometry underlying the model.[5]

Most televisions, computer displays, and projectors produce colors by combining red, green, and blue light in varying intensities – the so-calledRGBadditiveprimary colors. The resulting mixtures inRGB color space can reproduce a wide variety of colors (called agamut); however, the relationship between the constituent amounts of red, green, and blue light and the resulting color is unintuitive, especially for inexperienced users, and for users familiar withsubtractive color mixing of paints or traditional artists' models based on tints and shades (fig. 4). Furthermore, neither additive nor subtractive color models define color relationships the same way thehuman eye does.[C]

For example, imagine we have an RGB display whose color is controlled by threesliders ranging from0–255, one controlling the intensity of each of the red, green, and blue primaries. If we begin with a relatively colorfulorange, withsRGB valuesR = 217,G = 118,B = 33, and want to reduce its colorfulness by half to a less saturated orange, we would need to drag the sliders to decreaseR by 31, increaseG by 24, and increaseB by 59, as pictured below.

Beginning in the 1950s,color television broadcasts used acompatible color system whereby "luminance" and "chrominance" signals were encoded separately, so that existing unmodified black-and-white televisions could still receive color broadcasts and show a monochrome image.[9]

In an attempt to accommodate more traditional and intuitive color mixing models, computer graphics pioneers atPARC andNYIT introduced the HSV model for computer display technology in the mid-1970s, formally described byAlvy Ray Smith[10] in the August 1978 issue ofComputer Graphics. In the same issue, Joblove and Greenberg[11] described the HSL model – whose dimensions they labeledhue,relative chroma, andintensity – and compared it to HSV (fig. 1). Their model was based more upon how colors are organized and conceptualized inhuman vision in terms of other color-making attributes, such as hue, lightness, and chroma; as well as upon traditional color mixing methods – e.g., in painting – that involve mixing brightly colored pigments with black or white to achieve lighter, darker, or less colorful colors.

The following year, 1979, atSIGGRAPH,Tektronix introduced graphics terminals using HSL for color designation, and the Computer Graphics Standards Committee recommended it in their annual status report (fig. 7). These models were useful not only because they were more intuitive than raw RGB values, but also because the conversions to and from RGB were extremely fast to compute: they could run in real time on the hardware of the 1970s. Consequently, these models and similar ones have become ubiquitous throughout image editing and graphics software since then. Some of their uses are describedbelow.[12][13][14][15]

Formal derivation

[edit]
A flow-chart–like diagram shows the derivation of HSL, HSV, and a luma/chroma/hue model. At the top lies an RGB "color cube", which as a first step is tilted onto its corner so that black lies at the bottom and white at the top. At the next step, the three models diverge, and the height of red, yellow, green, cyan, blue, and magenta is set based on the formula for lightness, value, or luma: in HSV, all six of these are placed in the plane with white, making an upside-down hexagonal pyramid; in HSL, all six are placed in a plane halfway between white and black, making a bipyramid; in the luma/chroma/hue model, the height is determined by the approximate formula luma equals 0.3 times red plus 0.6 times green plus 0.1 times blue. At the next step, each horizontal slice of HSL and HSV is expanded to fill a uniform-width hexagonal prism, while the luma/chroma/hue model is simply embedded in that prism without modification. As a final step, all three models' hexagonal prisms are warped into cylinders, reflecting the nature of the definition of hue and saturation or chroma. For full details and mathematical formalism, read the rest of this section.
Fig. 8. The geometric derivation of the cylindrical HSL and HSV representations of an RGB "colorcube".
Videos demonstrating the above geometric derivation for HSV (left) and HSL (right) as continuous deformations of the RGB cube

Color-making attributes

[edit]
See also:Color vision

The dimensions of the HSL and HSV geometries – simple transformations of the not-perceptually-based RGB model – are not directly related to thephotometric color-making attributes of the same names, as defined by scientists such as theCIE orASTM. Nonetheless, it is worth reviewing those definitions before leaping into the derivation of our models.[D] For the definitions of color-making attributes which follow, see:[16][17][18][19][20][21]

Hue
The "attribute of a visual sensation according to which an area appears to be similar to one of theperceived colors: red, yellow, green, and blue, or to a combination of two of them".[16]
Radiance (Le,Ω)
Theradiant power of light passing through a particular surface per unitsolid angle per unit projected area, measured inSI units inwatt persteradian persquare metre (W·sr−1·m−2).
Luminance (Y orLv,Ω)
The radiance weighted by the effect of each wavelength on a typical human observer, measured in SI units incandela per square meter (cd/m2). Often the termluminance is used for therelative luminance,Y/Yn, whereYn is the luminance of the referencewhite point.
Luma (Y)
The weighted sum ofgamma-correctedR,G, andB values, and used inYCbCr, forJPEG compression and video transmission.
Brightness (or value)
The "attribute of a visual sensation according to which an area appears to emit more or less light".[16]
Lightness
The "brightness relative to the brightness of a similarly illuminated white".[16]
Colorfulness
The "attribute of a visual sensation according to which the perceived color of an area appears to be more or less chromatic".[16]
Chroma
The "colorfulness relative to the brightness of a similarly illuminated white".[16]
Saturation
The "colorfulness of a stimulus relative to its own brightness".[16]

Brightness andcolorfulness are absolute measures, which usually describe thespectral distribution of light entering the eye, whilelightness andchroma are measured relative to some white point, and are thus often used for descriptions of surface colors, remaining roughly constant even as brightness and colorfulness change with differentillumination.Saturation can be defined as either the ratio of colorfulness to brightness, or that of chroma to lightness.

General approach

[edit]

HSL, HSV, and related models can be derived via geometric strategies, or can be thought of as specific instances of a "generalized LHS model". The HSL and HSV model-builders took an RGB cube – with constituent amounts of red, green, and blue light in a color denotedR,G,B[0, 1][E] – and tilted it on its corner, so that black rested at the origin with white directly above it along the vertical axis, then measured the hue of the colors in the cube by their angle around that axis, starting with red at 0°. Then they came up with a characterization of brightness/value/lightness, and defined saturation to range from 0 along the axis to 1 at the most colorful point for each pair of other parameters.[2][10][11]

Hue and chroma

[edit]
See also:Hue andChrominance
When an RGB cube, tilted so that its white corner rests vertically above its black corner, is projected into the plane perpendicular to that neutral axis, it makes the shape of a hexagon, with red, yellow, green, cyan, blue, and magenta arranged counterclockwise at its corners. This projection defines the hue and chroma of any color, as described in the caption and article text.
Fig. 9. Both hue and chroma are defined based on the projection of the RGB cube onto a hexagon in the "chromaticity plane". Chroma is the relative size of the hexagon passing through a point, and hue is how far around that hexagon's edge the point lies.

In each of our models, we calculate bothhue and what this article will callchroma, after Joblove and Greenberg (1978), in the same way – that is, the hue of a color has the same numerical values in all of these models, as does its chroma. If we take our tilted RGB cube, andproject it onto the "chromaticityplane"perpendicular to the neutral axis, our projection takes the shape of a hexagon, with red, yellow, green, cyan, blue, and magenta at its corners (fig. 9).Hue is roughly the angle of thevector to a point in the projection, with red at 0°, whilechroma is roughly the distance of the point from the origin.[F][G]

More precisely, both hue and chroma in this model are defined with respect to the hexagonal shape of the projection. Thechroma is the proportion of the distance from the origin to the edge of the hexagon. In the lower part of the adjacent diagram, this is the ratio of lengthsOP/OP, or alternatively the ratio of the radii of the two hexagons. This ratio is the difference between the largest and smallest values amongR,G, orB in a color. To make our definitions easier to write, we'll define these maximum, minimum, and chroma component values asM,m, andC, respectively.[H]

M=max(R,G,B){\displaystyle M=\max(R,G,B)}
m=min(R,G,B){\displaystyle m=\min(R,G,B)}
C=range(R,G,B)=Mm{\displaystyle C=\operatorname {range} (R,G,B)=M-m}

These operations do not require R, G and B values to be normalized to a specific range (e.g. a range of 0–1 works as well as a range of 0–255).

To understand why chroma can be written asMm, notice that any neutral color, withR =G =B, projects onto the origin and so has 0 chroma. Thus if we add or subtract the same amount from all three ofR,G, andB, we move vertically within our tilted cube, and do not change the projection. Therefore, any two colors of(R,G,B) and(Rm,Gm,Bm) project on the same point, and have the same chroma. The chroma of a color with one of its components equal to zero(m = 0) is simply the maximum of the other two components. This chroma isM in the particular case of a color with a zero component, andMm in general.

Thehue is the proportion of the distance around the edge of the hexagon which passes through the projected point, originally measured on the range[0, 1] but now typically measured indegrees[0°, 360°). For points which project onto the origin in the chromaticity plane (i.e., grays), hue is undefined. Mathematically, this definition of hue is writtenpiecewise:[I]

H={undefined,if C=0GBCmod6,if M=RBRC+2,if M=GRGC+4,if M=B{\displaystyle H'={\begin{cases}\mathrm {undefined} ,&{\text{if }}C=0\\{\frac {G-B}{C}}{\bmod {6}},&{\text{if }}M=R\\{\frac {B-R}{C}}+2,&{\text{if }}M=G\\{\frac {R-G}{C}}+4,&{\text{if }}M=B\end{cases}}}
H=60×H{\displaystyle H=60^{\circ }\times H'}

Sometimes, neutral colors (i.e. withC = 0) are assigned a hue of 0° for convenience of representation.

Pictured at left is the hexagonal projection shown earlier. At right, each side of the hexagon has been changed into a 60° arc of a circle with the same radius.
Fig. 10. The definitions ofhue andchroma in HSL and HSV have the effect of warping hexagons into circles.

These definitions amount to a geometric warping of hexagons into circles: each side of the hexagon is mapped linearly onto a 60° arc of the circle (fig. 10). After such a transformation, hue is precisely the angle around the origin and chroma the distance from the origin: the angle and magnitude of thevector pointing to a color.

Instead of measuring hue and chroma with reference to the hexagonal edge of the projection of the RGB cube into the plane perpendicular to its neutral axis, we can define chromaticity coordinates alpha and beta in the plane – with alpha pointing in the direction of red, and beta perpendicular to it – and then define hue H2 and chroma C2 as the polar coordinates of these. That is, the tangent of hue is beta over alpha, and chroma squared is alpha squared plus beta squared.
Fig. 11. Constructing rectangular chromaticity coordinatesα andβ, and then transforming those into hueH2 and chromaC2 yields slightly different values than computing hexagonal hueH and chromaC: compare the numbers in this diagram to those earlier in this section.

Sometimes for image analysis applications, this hexagon-to-circle transformation is skipped, andhue andchroma (we'll denote theseH2 andC2) are defined by the usual cartesian-to-polar coordinate transformations (fig. 11). The easiest way to derive those is via a pair of cartesian chromaticity coordinates which we'll callα andβ:[22][23][24]

α=RGcos(60)Bcos(60)=12(2RGB){\displaystyle \alpha =R-G\cdot \cos(60^{\circ })-B\cdot \cos(60^{\circ })={\tfrac {1}{2}}(2R-G-B)}
β=Gsin(60)Bsin(60)=32(GB){\displaystyle \beta =G\cdot \sin(60^{\circ })-B\cdot \sin(60^{\circ })={\tfrac {\sqrt {3}}{2}}(G-B)}
H2=atan2(β,α){\displaystyle H_{2}=\operatorname {atan2} (\beta ,\alpha )}
C2=gmean(α,β)=α2+β2{\displaystyle C_{2}=\operatorname {gmean} (\alpha ,\beta )={\sqrt {\alpha ^{2}+\beta ^{2}}}}

(Theatan2 function, a "two-argument arctangent", computes the angle from a cartesian coordinate pair.)

Notice that these two definitions of hue (H andH2) nearly coincide, with a maximum difference between them for any color of about 1.12° – which occurs at twelve particular hues, for instanceH = 13.38°,H2 = 12.26° – and withH =H2 for every multiple of 30°. The two definitions of chroma (C andC2) differ more substantially: they are equal at the corners of our hexagon, but at points halfway between two corners, such asH =H2 = 30°, we haveC = 1, butC2=340.866,{\textstyle C_{2}={\sqrt {\frac {3}{4}}}\approx 0.866,} a difference of about 13.4%.

Lightness

[edit]
When we plot HSV value against chroma, the result, regardless of hue, is an upside-down isosceles triangle, with black at the bottom, and white at the top bracketed by the most chromatic colors of two complementary hues at the top right and left corners. When we plot HSL lightness against chroma, the result is a rhombus, again with black at the bottom and white at the top, but with the colorful complements at horizontal ends of the line halfway between them. When we plot the component average, sometimes called HSI intensity, against chroma, the result is a parallelogram whose shape changes depending on hue, as the most chromatic colors for each hue vary between one third and two thirds between black and white. Plotting luma against chroma yields a parallelogram of much more diverse shape: blue lies about 10 percent of the way from black to white, while its complement yellow lies 90 percent of the way there; by contrast, green is about 60 percent of the way from black to white while its complement magenta is 40 percent of the way there.
Fig. 12a–d. Four different possible "lightness" dimensions, plotted against chroma, for a pair of complementary hues. Each plot is a vertical cross-section of its three-dimensional color solid.

While the definition ofhue is relatively uncontroversial – it roughly satisfies the criterion that colors of the same perceived hue should have the same numerical hue – the definition of alightness orvalue dimension is less obvious: there are several possibilities depending on the purpose and goals of the representation. Here are four of the most common (fig. 12; three of these are also shown infig. 8):

All four of these leave the neutral axis alone. That is, for colors withR =G =B, any of the four formulations yields a lightness equal to the value ofR,G, orB.

For a graphical comparison, seefig. 13 below.

Saturation

[edit]
Fig. 14a–d. In both HSL and HSV,saturation is simply the chroma scaled to fill the interval[0, 1] for every combination of hue and lightness or value.

When encoding colors in a hue/lightness/chroma or hue/value/chroma model (using the definitions from the previous two sections), not all combinations of lightness (or value) and chroma are meaningful: that is, half of the colors denotable usingH ∈ [0°, 360°),C ∈ [0, 1], andV ∈ [0, 1] fall outside the RGB gamut (the gray parts of the slices in figure 14). The creators of these models considered this a problem for some uses. For example, in a color selection interface with two of the dimensions in a rectangle and the third on a slider, half of that rectangle is made of unused space. Now imagine we have a slider for lightness: the user's intent when adjusting this slider is potentially ambiguous: how should the software deal with out-of-gamut colors? Or conversely, If the user has selected as colorful as possible a dark purple, and then shifts the lightness slider upward, what should be done: would the user prefer to see a lighter purple still as colorful as possible for the given hue and lightness, or a lighter purple of exactly the same chroma as the original color?[11]

To solve problems such as these, the HSL and HSV models scale the chroma so that it always fits into the range[0, 1] for every combination of hue and lightness or value, calling the new attributesaturation in both cases (fig. 14). To calculate either, simply divide the chroma by the maximum chroma for that value or lightness.

SV={0,if V=0CV,otherwise{\displaystyle S_{V}={\begin{cases}0,&{\text{if }}V=0\\{\frac {C}{V}},&{\text{otherwise}}\end{cases}}}
SL={0,if L=1 or L=0C1|2L1|,otherwise{\displaystyle S_{L}={\begin{cases}0,&{\text{if }}L=1{\text{ or }}L=0\\{\frac {C}{1-|2L-1|}},&{\text{otherwise}}\end{cases}}}
Fig. 15a–b. In HSI,saturation, shown in the slice on the right, is roughly the chroma relative to lightness. Also common is a model with dimensionsI,H2,C2, shown in the slice on the left. Notice that the hue in these slices is the same as the hue above, butH differs slightly fromH2.

The HSI model commonly used for computer vision, which takesH2 as a hue dimension and the component averageI ("intensity") as a lightness dimension, does not attempt to "fill" a cylinder by its definition of saturation. Instead of presenting color choice or modification interfaces to end users, the goal of HSI is to facilitate separation of shapes in an image. Saturation is therefore defined in line with the psychometric definition: chroma relative to lightness (fig. 15). See theUse in image analysis section of this article.[28]

SI={0,if I=01mI,otherwise{\displaystyle S_{I}={\begin{cases}0,&{\text{if }}I=0\\1-{\frac {m}{I}},&{\text{otherwise}}\end{cases}}}

Using the same name for these three different definitions of saturation leads to some confusion, as the three attributes describe substantially different color relationships; in HSV and HSI, the term roughly matches the psychometric definition, of a chroma of a color relative to its own lightness, but in HSL it does not come close. Even worse, the wordsaturation is also often used for one of the measurements we call chroma above (C orC2).

Examples

[edit]

All parameter values shown below are given as values in theinterval[0, 1], except those forH andH2, which are in the interval[0°, 360°).[K]

ColorRGBHH2CC2VLIY601SHSVSHSLSHSI
#FFFFFF1.0001.0001.0000.0000.0001.0001.0001.0001.0000.0000.0000.000
#8080800.5000.5000.5000.0000.0000.5000.5000.5000.5000.0000.0000.000
#0000000.0000.0000.0000.0000.0000.0000.0000.0000.0000.0000.0000.000
#FF00001.0000.0000.0000.0°0.0°1.0001.0001.0000.5000.3330.2991.0001.0001.000
#BFBF000.7500.7500.00060.0°60.0°0.7500.7500.7500.3750.5000.6641.0001.0001.000
#0080000.0000.5000.000120.0°120.0°0.5000.5000.5000.2500.1670.2931.0001.0001.000
#80FFFF0.5001.0001.000180.0°180.0°0.5000.5001.0000.7500.8330.8500.5001.0000.400
#8080FF0.5000.5001.000240.0°240.0°0.5000.5001.0000.7500.6670.5570.5001.0000.250
#BF40BF0.7500.2500.750300.0°300.0°0.5000.5000.7500.5000.5830.4570.6670.5000.571
#A0A4240.6280.6430.14261.8°61.5°0.5010.4940.6430.3930.4710.5810.7790.6380.699
#411BEA0.2550.1040.918251.1°250.0°0.8140.7500.9180.5110.4260.2420.8870.8320.756
#1EAC410.1160.6750.255134.9°133.8°0.5590.5040.6750.3960.3490.4600.8280.7070.667
#F0C80E0.9410.7850.05349.5°50.5°0.8880.8210.9410.4970.5930.7480.9440.8930.911
#B430E50.7040.1870.897283.7°284.8°0.7100.6360.8970.5420.5960.4230.7920.7750.686
#ED76510.9310.4630.31614.3°13.2°0.6150.5560.9310.6240.5700.5860.6610.8170.446
#FEF8880.9980.9740.53256.9°57.4°0.4660.4540.9980.7650.8350.9310.4670.9910.363
#19CB970.0990.7950.591162.4°163.4°0.6960.6200.7950.4470.4950.5640.8750.7790.800
#3626980.2110.1490.597248.3°247.3°0.4480.4200.5970.3730.3190.2190.7500.6010.533
#7E7EB80.4950.4930.721240.5°240.4°0.2280.2270.7210.6070.5700.5200.3160.2900.135

Use in end-user software

[edit]
See also:Color picker andImage editing
Fig 16a–g. By the 1990s, HSL and HSV color selection tools were ubiquitous. The screenshots above are taken from: These are undoubtedly based on earlier examples, stretching back to PARC and NYIT in the mid-1970s.[L]

The original purpose of HSL and HSV and similar models, and their most common current application, is incolor selection tools. At their simplest, some such color pickers provide three sliders, one for each attribute. Most, however, show a two-dimensional slice through the model, along with a slider controlling which particular slice is shown. The latter type of GUI exhibits great variety, because of the choice of cylinders, hexagonal prisms, or cones/bicones that the models suggest (see the diagram near thetop of the page). Several color choosers from the 1990s are shown to the right, most of which have remained nearly unchanged in the intervening time: today, nearly every computer color chooser uses HSL or HSV, at least as an option. Some more sophisticated variants are designed for choosing whole sets of colors, basing their suggestions of compatible colors on the HSL or HSV relationships between them.[M]

Most web applications needing color selection also base their tools on HSL or HSV, and pre-packaged open source color choosers exist for most major web front-endframeworks. TheCSS 3 specification allows web authors to specify colors for their pages directly with HSL coordinates.[N][29]

HSL and HSV are sometimes used to define gradients fordata visualization, as in maps or medical images. For example, the popularGIS programArcGIS historically applied customizable HSV-based gradients to numerical geographical data.[O]

Fig. 17.xv's HSV-based color modifier.
Fig. 18. The hue/saturation tool inPhotoshop 2.5, ca. 1992.

Image editing software also commonly includes tools for adjusting colors with reference to HSL or HSV coordinates, or to coordinates in a model based on the "intensity" or lumadefined above. In particular, tools with a pair of "hue" and "saturation" sliders are commonplace, dating to at least the late-1980s, but various more complicated color tools have also been implemented. For instance, theUnix image viewer and color editorxv allowed six user-definable hue (H) ranges to be rotated and resized, included adial-like control for saturation (SHSV), and acurves-like interface for controlling value (V) – see fig. 17. The image editorPicture Window Pro includes a "color correction" tool which affords complex remapping of points in a hue/saturation plane relative to either HSL or HSV space.[P]

Video editors also use these models. For example, bothAvid andFinal Cut Pro include color tools based on HSL or a similar geometry for use adjusting the color in video. With the Avid tool, users pick a vector by clicking a point within the hue/saturation circle to shift all the colors at some lightness level (shadows, mid-tones, highlights) by that vector.

Since version 4.0, Adobe Photoshop's "Luminosity", "Hue", "Saturation", and "Color"blend modes composite layers using a luma/chroma/hue color geometry. These have been copied widely, but several imitators use the HSL (e.g.PhotoImpact,Paint Shop Pro) or HSV geometries instead.[Q][R]

Use in image analysis

[edit]
See also:Computer vision andImage analysis

HSL, HSV, HSI, or related models are often used incomputer vision andimage analysis forfeature detection orimage segmentation. The applications of such tools include object detection, for instance inrobot vision;object recognition, for instance offaces,text, orlicense plates;content-based image retrieval; andanalysis of medical images.[28]

For the most part, computer vision algorithms used on color images are straightforward extensions to algorithms designed forgrayscale images, for instancek-means orfuzzy clustering of pixel colors, orcannyedge detection. At the simplest, each color component is separately passed through the same algorithm. It is important, therefore, that thefeatures of interest can be distinguished in the color dimensions used. Because theR,G, andB components of an object's color in a digital image are all correlated with the amount of light hitting the object, and therefore with each other, image descriptions in terms of those components make object discrimination difficult. Descriptions in terms of hue/lightness/chroma or hue/lightness/saturation are often more relevant.[28]

Starting in the late 1970s, transformations like HSV or HSI were used as a compromise between effectiveness for segmentation and computational complexity. They can be thought of as similar in approach and intent to the neural processing used by human color vision, without agreeing in particulars: if the goal is object detection, roughly separating hue, lightness, and chroma or saturation is effective, but there is no particular reason to strictly mimic human color response. John Kender's 1976 master's thesis proposed the HSI model. Ohta et al. (1980) instead used a model made up of dimensions similar to those we have calledI,α, andβ. In recent years, such models have continued to see wide use, as their performance compares favorably with more complex models, and their computational simplicity remains compelling.[S][28][36][37][38]

Disadvantages

[edit]
Fig 20a. ThesRGB gamut mapped in CIELAB space. Notice that the lines pointing to the red, green, and blue primaries are not evenly spaced byhue angle, and are of unequal length. The primaries also have differentL* values.
Fig 20b. TheAdobe RGB gamut mapped in CIELAB space. Also notice that these two RGB spaces have different gamuts, and thus will have different HSL and HSV representations.

While HSL, HSV, and related spaces serve well enough to, for instance, choose a single color, they ignore much of the complexity of color appearance. Essentially, they trade off perceptual relevance for computation speed, from a time in computing history (high-end 1970s graphics workstations, or mid-1990s consumer desktops) when more sophisticated models would have been too computationally expensive.[T]

HSL and HSV are simple transformations of RGB which preserve symmetries in the RGB cube unrelated to human perception, such that itsR,G, andB corners are equidistant from the neutral axis, and equally spaced around it. If we plot the RGB gamut in a more perceptually-uniform space, such asCIELAB (seebelow), it becomes immediately clear that the red, green, and blue primaries do not have the same lightness or chroma, or evenly spaced hues. Furthermore, different RGB displays use different primaries, and so have different gamuts. Because HSL and HSV are defined purely with reference to some RGB space, they are notabsolute color spaces: to specify a color precisely requires reporting not only HSL or HSV values, but also the characteristics of the RGB space they are based on, including thegamma correction in use.

If we take an image and extract the hue, saturation, and lightness or value components, and then compare these to the components of the same name as defined by color scientists, we can quickly see the difference, perceptually. For example, examine the following images of a fire breather (fig. 13). The original is in the sRGB colorspace. CIELABL* is a CIE-defined achromatic lightness quantity (dependent solely on the perceptually achromatic luminanceY, but not the mixed-chromatic componentsX orZ, of the CIEXYZ colorspace from which the sRGB colorspace itself is derived), and it is plain that this appears similar in perceptual lightness to the original color image. Luma is roughly similar, but differs somewhat at high chroma, where it deviates most from depending solely on the true achromatic luminance (Y, or equivalentlyL*) and is influenced by the colorimetric chromaticity (x,y, or equivalently,a*,b* of CIELAB). HSLL and HSVV, by contrast, diverge substantially from perceptual lightness.

A full-color image shows a high-contrast and quite dramatic scene of a fire breather with a large orange-yellow flame extending from his lips. He wears dark but colorful orange-red clothing.
Fig. 13a. Color photograph (sRGB colorspace).
A grayscale image showing the CIELAB lightness component of the photograph appears to be a faithful rendering of the scene: it looks roughly like a black-and-white photograph taken on panchromatic film would look, with clear detail in the flame, which is much brighter than the man's outfit or the background.
Fig. 13b. CIELABL* (further transformed back to sRGB for consistent display).
A grayscale image showing the luma appears roughly similar to the CIELAB lightness image, but is a bit brighter in areas which were originally very colorful.
Fig. 13c. Rec. 601 lumaY'.
A grayscale image showing the component average (HSI intensity) of the photograph is much a less convincing facsimile of the color photograph, with reduced contrast, especially with its flame darker than in the original.
Fig. 13d. Component average: "intensity"I.
A grayscale image showing the HSV value component of the photograph leaves the flame completely white (in photographer's parlance, "blown out"), and the man's clothing much too bright.
Fig. 13e. HSV valueV.
A grayscale image showing the HSL lightness component of the photograph renders the flame, as approximately middle gray, and ruins the dramatic effect of the original by radically reducing its contrast.
Fig. 13f. HSL lightnessL.
Fig 20c. 12 points on the HSV color wheel in aCIELAB chroma plane, showing HSV's lack of uniformity in hue and saturation.

Though none of the dimensions in these spaces match their perceptual analogs, thevalue of HSV and thesaturation of HSL are particular offenders. In HSV, the blue primary and white are held to have the same value, even though perceptually the blue primary has somewhere around 10% of the luminance of white (the exact fraction depends on the particular RGB primaries in use). In HSL, a mix of 100% red, 100% green, 90% blue – that is, a very light yellow – is held to have the same saturation as the green primary, even though the former color has almost no chroma or saturation by the conventional psychometric definitions. Such perversities led Cynthia Brewer, expert in color scheme choices for maps and information displays, to tell theAmerican Statistical Association:

Computer science offers a few poorer cousins to these perceptual spaces that may also turn up in your software interface, such as HSV and HLS. They are easy mathematical transformations of RGB, and they seem to be perceptual systems because they make use of the hue–lightness/value–saturation terminology. But take a close look; don't be fooled. Perceptual color dimensions are poorly scaled by the color specifications that are provided in these and some other systems. For example, saturation and lightness are confounded, so a saturation scale may also contain a wide range of lightnesses (for example, it may progress from white to green which is a combination of both lightness and saturation). Likewise, hue and lightness are confounded so, for example, a saturated yellow and saturated blue may be designated as the same 'lightness' but have wide differences in perceived lightness. These flaws make the systems difficult to use to control the look of a color scheme in a systematic manner. If much tweaking is required to achieve the desired effect, the system offers little benefit over grappling with raw specifications in RGB or CMY.[39]

If these problems make HSL and HSV problematic for choosing colors or color schemes, they make them much worse for image adjustment. HSL and HSV, as Brewer mentioned, confound perceptual color-making attributes, so that changing any dimension results in non-uniform changes to all three perceptual dimensions, and distorts all of the color relationships in the image. For instance, rotating the hue of a pure dark blue toward green will also reduce its perceived chroma, and increase its perceived lightness (the latter is grayer and lighter), but the same hue rotation will have the opposite impact on lightness and chroma of a lighter bluish-green – to (the latter is more colorful and slightly darker). In the example below (fig. 21), the image (a) is the original photograph of agreen turtle. In the image (b), we have rotated the hue (H) of each color by−30°, while keeping HSV value and saturation or HSL lightness and saturation constant. In the image right (c), we make the same rotation to the HSL/HSV hue of each color, but then we force the CIELAB lightness (L*, a decent approximation of perceived lightness) to remain constant. Notice how the hue-shifted middle version without such a correction dramatically changes the perceived lightness relationships between colors in the image. In particular, the turtle's shell is much darker and has less contrast, and the background water is much lighter. Image (d) uses CIELAB to hue shift; the difference from (c) demonstrates the errors in hue and saturation.

Fig. 21a. Color photograph.
Fig. 21b. HSL/HSV hue of each color shifted by−30°.
Fig. 21c. Hue shifted but CIELAB lightness (L*) kept as in the original.
Fig. 21d. Hue shifted in CIELch(ab) color space by−30°.

Because hue is a circular quantity, represented numerically with a discontinuity at 360°, it is difficult to use in statistical computations or quantitative comparisons: analysis requires the use ofcircular statistics.[40] Furthermore, hue is defined piecewise, in 60° chunks, where the relationship of lightness, value, and chroma toR,G, andB depends on the hue chunk in question. This definition introduces discontinuities, corners which can plainly be seen in horizontal slices of HSL or HSV.[41]

Charles Poynton, digital video expert, lists the above problems with HSL and HSV in hisColor FAQ, and concludes that:

HSB and HLS were developed to specify numerical Hue, Saturation and Brightness (or Hue, Lightness and Saturation) in an age when users had to specify colors numerically. The usual formulations of HSB and HLS are flawed with respect to the properties of color vision. Now that users can choose colors visually, or choose colors related to other media (such asPANTONE), or use perceptually-based systems likeL*u*v* andL*a*b*, HSB and HLS should be abandoned.[42]

Other cylindrical-coordinate color models

[edit]
Main articles:Color model § Cylindrical-coordinate color models, andList of color spaces and their uses § Cylindrical transformations

The creators of HSL and HSV were far from the first to imagine colors fitting into conic or spherical shapes, with neutrals running from black to white in a central axis, and hues corresponding to angles around that axis. Similar arrangements date back to the 18th century, and continue to be developed in the most modern and scientific models.

Color conversion formulae

[edit]

To convert from HSL or HSV to RGB, we essentially invert the steps listedabove (as before,R,G,B[0, 1]). First, we compute chroma, by multiplying saturation by the maximum chroma for a given lightness or value. Next, we find the point on one of the bottom three faces of the RGB cube which has the same hue and chroma as our color (and therefore projects onto the same point in the chromaticity plane). Finally, we add equal amounts ofR,G, andB to reach the proper lightness or value.[G]

To RGB

[edit]

HSL to RGB

[edit]

Given a color with hueH ∈ [0°, 360°), saturationSL ∈ [0, 1], and lightnessL ∈ [0, 1], we first find chroma:

C=(1|2L1|)×SL{\displaystyle C=(1-\left\vert 2L-1\right\vert )\times S_{L}}

Then we can find a point(R1,G1,B1) along the bottom three faces of the RGB cube, with the same hue and chroma as our color (using the intermediate valueX for the second largest component of this color):

H=H60{\displaystyle H^{\prime }={\frac {H}{60^{\circ }}}}
X=C×(1|Hmod21|){\displaystyle X=C\times (1-|H^{\prime }\;{\bmod {2}}-1|)}

In the above equation, the notationHmod2{\displaystyle H^{\prime }\;{\bmod {2}}} refers to the remainder of theEuclidean division ofH{\displaystyle H^{\prime }} by 2.H{\displaystyle H^{\prime }} is not necessarily an integer.

(R1,G1,B1)={(C,X,0)if 0H<1(X,C,0)if 1H<2(0,C,X)if 2H<3(0,X,C)if 3H<4(X,0,C)if 4H<5(C,0,X)if 5H<6{\displaystyle (R_{1},G_{1},B_{1})={\begin{cases}(C,X,0)&{\text{if }}0\leq H^{\prime }<1\\(X,C,0)&{\text{if }}1\leq H^{\prime }<2\\(0,C,X)&{\text{if }}2\leq H^{\prime }<3\\(0,X,C)&{\text{if }}3\leq H^{\prime }<4\\(X,0,C)&{\text{if }}4\leq H^{\prime }<5\\(C,0,X)&{\text{if }}5\leq H^{\prime }<6\end{cases}}}

WhenH{\displaystyle H^{\prime }} is an integer, the "neighbouring" formula would yield the same result, asX=0{\displaystyle X=0} orX=C{\displaystyle X=C}, as appropriate.

Finally, we can findR,G, andB by adding the same amount to each component, to match lightness:

m=LC2{\displaystyle m=L-{\frac {C}{2}}}
(R,G,B)=(R1+m,G1+m,B1+m){\displaystyle (R,G,B)=(R_{1}+m,G_{1}+m,B_{1}+m)}
HSL to RGB alternative
[edit]

The polygonal piecewise functions can be somewhat simplified by clever use of minimum and maximum values as well as the remainder operation.

Given a color with hueH[0,360]{\displaystyle H\in [0^{\circ },360^{\circ }]}, saturationS=SL[0,1]{\displaystyle S=S_{L}\in [0,1]}, and lightnessL[0,1]{\displaystyle L\in [0,1]}, we first define the function:

f(n)=Lamax(1,min(k3,9k,1)){\displaystyle f(n)=L-a\max(-1,\min(k-3,9-k,1))}

wherek,nR0{\displaystyle k,n\in \mathbb {R} _{\geq 0}} and:

k=(n+H30)mod12{\displaystyle k=\left(n+{\frac {H}{30^{\circ }}}\right){\bmod {1}}2}
a=SLmin(L,1L){\displaystyle a=S_{L}\min(L,1-L)}

And output R,G,B values (from[0,1]3{\displaystyle [0,1]^{3}}) are:

(R,G,B)=(f(0),f(8),f(4)){\displaystyle (R,G,B)=(f(0),f(8),f(4))}

The above alternative formulas allow for shorter implementations. In the above formulas theamodb{\displaystyle a{\bmod {b}}} operation also returns the fractional part of the module e.g.7.4mod6=1.4{\displaystyle 7.4{\bmod {6}}=1.4}, andk[0,12){\displaystyle k\in [0,12)}.

The base shapeT(k)=t(n,H)=max(min(k3,9k,1),1){\displaystyle T(k)=t(n,H)=\max(\min(k-3,9-k,1),-1)} is constructed as follows:t1=min(k3,9k){\displaystyle t_{1}=\min(k-3,9-k)} is a "triangle" for which values greater or equal to −1 start from k=2 and end at k=10, and the highest point is at k=6. Then byt2=min(t1,1)=min(k3,9k,1){\displaystyle t_{2}=\min(t_{1},1)=\min(k-3,9-k,1)} we change values bigger than 1 to equal 1. Then byt=max(t2,1){\displaystyle t=\max(t_{2},-1)} we change values less than −1 to equal −1. At this point, we get something similar to the red shape from fig. 24 after a vertical flip (where the maximum is 1 and the minimum is −1). The R,G,B functions ofH use this shape transformed in the following way: modulo-shifted onX (byn) (differently for R,G,B) scaled onY (bya{\displaystyle -a}) and shifted onY (byL).

We observe the following shape properties (Fig. 24 can help to get an intuition about them):

t(n,H)=t(n+6,H){\displaystyle t(n,H)=-t(n+6,H)}
min (t(n,H),t(n+4,H),t(n+8,H))=1{\displaystyle \min \ (t(n,H),t(n+4,H),t(n+8,H))=-1}
max (t(n,H),t(n+4,H),t(n+8,H))=+1{\displaystyle \max \ (t(n,H),t(n+4,H),t(n+8,H))=+1}

HSV to RGB

[edit]
Fig. 24. A graphical representation of RGB coordinates given values for HSV. This equationV(1S)=VVS{\displaystyle V(1-S)=V-VS} shows origin of marked vertical axis values.

Given an HSV color with hueH ∈ [0°, 360°), saturationSV ∈ [0, 1], and valueV ∈ [0, 1], we can use the same strategy. First, we find chroma:

C=V×SV{\displaystyle C=V\times S_{V}}

Then we can, again, find a point(R1,G1,B1) along the bottom three faces of the RGB cube, with the same hue and chroma as our color (using the intermediate valueX for the second largest component of this color):

H=H60{\displaystyle H^{\prime }={\frac {H}{60^{\circ }}}}
X=C×(1|Hmod21|){\displaystyle X=C\times (1-|H^{\prime }{\bmod {2}}-1|)}
(R1,G1,B1)={(C,X,0)if 0H<1(X,C,0)if 1H<2(0,C,X)if 2H<3(0,X,C)if 3H<4(X,0,C)if 4H<5(C,0,X)if 5H<6{\displaystyle (R_{1},G_{1},B_{1})={\begin{cases}(C,X,0)&{\text{if }}0\leq H^{\prime }<1\\(X,C,0)&{\text{if }}1\leq H^{\prime }<2\\(0,C,X)&{\text{if }}2\leq H^{\prime }<3\\(0,X,C)&{\text{if }}3\leq H^{\prime }<4\\(X,0,C)&{\text{if }}4\leq H^{\prime }<5\\(C,0,X)&{\text{if }}5\leq H^{\prime }<6\end{cases}}}

As before, whenH{\displaystyle H^{\prime }} is an integer, "neighbouring" formulas would yield the same result.

Finally, we can findR,G, andB by adding the same amount to each component, to match value:

m=VC{\displaystyle m=V-C}
(R,G,B)=(R1+m,G1+m,B1+m){\displaystyle (R,G,B)=(R_{1}+m,G_{1}+m,B_{1}+m)}
HSV to RGB alternative
[edit]

Given a color with hueH[0,360]{\displaystyle H\in [0^{\circ },360^{\circ }]}, saturationS=SV[0,1]{\displaystyle S=S_{V}\in [0,1]}, and valueV[0,1]{\displaystyle V\in [0,1]}, first we define function :

f(n)=VVSmax(0,min(k,4k,1)){\displaystyle f(n)=V-VS\max(0,\min(k,4-k,1))}

wherek,nR0{\displaystyle k,n\in \mathbb {R} _{\geq 0}} and:

k=(n+H60)mod6{\displaystyle k=\left(n+{\frac {H}{60^{\circ }}}\right){\bmod {6}}}

And output R,G,B values (from[0,1]3{\displaystyle [0,1]^{3}}) are:

(R,G,B)=(f(5),f(3),f(1)){\displaystyle (R,G,B)=(f(5),f(3),f(1))}

Above alternative equivalent formulas allow shorter implementation. In above formulas theamodb{\displaystyle a{\bmod {b}}} returns also fractional part of module e.g. the formula7.4mod6=1.4{\displaystyle 7.4{\bmod {6}}=1.4}. The values ofkRk[0,6){\displaystyle k\in \mathbb {R} \land k\in [0,6)}. The base shape

t(n,H)=T(k)=max(0,min(k,4k,1)){\displaystyle t(n,H)=T(k)=\max(0,\min(k,4-k,1))}

is constructed as follows:t1=min(k,4k){\displaystyle t_{1}=\min(k,4-k)} is "triangle" for which non-negative values starts from k=0, highest point at k=2 and "ends" at k=4, then we change values bigger than one to one byt2=min(t1,1)=min(k,4k,1){\displaystyle t_{2}=\min(t_{1},1)=\min(k,4-k,1)}, then change negative values to zero byt=max(t2,0){\displaystyle t=\max(t2,0)} – and we get (forn=0{\displaystyle n=0}) something similar to green shape from Fig. 24 (which max value is 1 and min value is 0). The R,G,B functions ofH use this shape transformed in following way: modulo-shifted onX (byn) (differently for R,G,B) scaled onY (byVS{\displaystyle -VS}) and shifted onY (byV). We observe following shape properties(Fig. 24 can help to get intuition about this):

t(n,H)=1t(n+3,H){\displaystyle t(n,H)=1-t(n+3,H)}
min(t(n,H),t(n+2,H),t(n+4,H))=0{\displaystyle \min(t(n,H),t(n+2,H),t(n+4,H))=0}
max(t(n,H),t(n+2,H),t(n+4,H))=1{\displaystyle \max(t(n,H),t(n+2,H),t(n+4,H))=1}

HSI to RGB

[edit]

Given an HSI color with hueH ∈ [0°, 360°), saturationSI ∈ [0, 1], and intensityI ∈ [0, 1], we can use the same strategy, in a slightly different order:

H=H60{\displaystyle H^{\prime }={\frac {H}{60^{\circ }}}}
Z=1|Hmod21|{\displaystyle Z=1-|H^{\prime }\;{\bmod {2}}-1|}
C=3ISI1+Z{\displaystyle C={\frac {3\cdot I\cdot S_{I}}{1+Z}}}
X=CZ{\displaystyle X=C\cdot Z}

WhereC{\displaystyle C} is the chroma.

Then we can, again, find a point(R1,G1,B1) along the bottom three faces of the RGB cube, with the same hue and chroma as our color (using the intermediate valueX for the second largest component of this color):

(R1,G1,B1)={(0,0,0)if H is undefined(C,X,0)if 0H1(X,C,0)if 1H2(0,C,X)if 2H3(0,X,C)if 3H4(X,0,C)if 4H5(C,0,X)if 5H<6{\displaystyle (R_{1},G_{1},B_{1})={\begin{cases}(0,0,0)&{\text{if }}H{\text{ is undefined}}\\(C,X,0)&{\text{if }}0\leq H^{\prime }\leq 1\\(X,C,0)&{\text{if }}1\leq H^{\prime }\leq 2\\(0,C,X)&{\text{if }}2\leq H^{\prime }\leq 3\\(0,X,C)&{\text{if }}3\leq H^{\prime }\leq 4\\(X,0,C)&{\text{if }}4\leq H^{\prime }\leq 5\\(C,0,X)&{\text{if }}5\leq H^{\prime }<6\end{cases}}}

Overlap (whenH{\displaystyle H^{\prime }} is an integer) occurs because two ways to calculate the value are equivalent:X=0{\displaystyle X=0} orX=C{\displaystyle X=C}, as appropriate.

Finally, we can findR,G, andB by adding the same amount to each component, to match lightness:

m=I(1SI){\displaystyle m=I\cdot (1-S_{I})}
(R,G,B)=(R1+m,G1+m,B1+m){\displaystyle (R,G,B)=(R_{1}+m,G_{1}+m,B_{1}+m)}

Luma, chroma and hue to RGB

[edit]

Given a color with hueH ∈ [0°, 360°), chromaC ∈ [0, 1], and lumaY601 ∈ [0, 1],[U] we can again use the same strategy. Since we already haveH andC, we can straightaway find our point(R1,G1,B1) along the bottom three faces of the RGB cube:

H=H60X=C×(1|Hmod21|){\displaystyle {\begin{aligned}H^{\prime }&={\frac {H}{60^{\circ }}}\\X&=C\times (1-|H^{\prime }{\bmod {2}}-1|)\end{aligned}}}
(R1,G1,B1)={(0,0,0)if H is undefined(C,X,0)if 0H1(X,C,0)if 1H2(0,C,X)if 2H3(0,X,C)if 3H4(X,0,C)if 4H5(C,0,X)if 5H<6{\displaystyle (R_{1},G_{1},B_{1})={\begin{cases}(0,0,0)&{\text{if }}H{\text{ is undefined}}\\(C,X,0)&{\text{if }}0\leq H^{\prime }\leq 1\\(X,C,0)&{\text{if }}1\leq H^{\prime }\leq 2\\(0,C,X)&{\text{if }}2\leq H^{\prime }\leq 3\\(0,X,C)&{\text{if }}3\leq H^{\prime }\leq 4\\(X,0,C)&{\text{if }}4\leq H^{\prime }\leq 5\\(C,0,X)&{\text{if }}5\leq H^{\prime }<6\end{cases}}}

Overlap (whenH{\displaystyle H^{\prime }} is an integer) occurs because two ways to calculate the value are equivalent:X=0{\displaystyle X=0} orX=C{\displaystyle X=C}, as appropriate.

Then we can findR,G, andB by adding the same amount to each component, to match luma:

m=Y601(0.30R1+0.59G1+0.11B1){\displaystyle m=Y_{601}^{\prime }-(0.30R_{1}+0.59G_{1}+0.11B_{1})}
(R,G,B)=(R1+m,G1+m,B1+m){\displaystyle (R,G,B)=(R_{1}+m,G_{1}+m,B_{1}+m)}

Interconversion

[edit]

HSV to HSL

[edit]

Given a color with hueHV[0,360){\displaystyle H_{V}\in [0^{\circ },360^{\circ })}, saturationSV[0,1]{\displaystyle S_{V}\in [0,1]}, and valueV[0,1]{\displaystyle V\in [0,1]},

HL=HV{\displaystyle H_{L}=H_{V}}
SL={0if L=0 or L=1VLmin(L,1L)otherwise{\displaystyle S_{L}={\begin{cases}0&{\text{if }}L=0{\text{ or }}L=1\\{\frac {V-L}{\min(L,1-L)}}&{\text{otherwise}}\\\end{cases}}}
L=V(1SV2){\displaystyle L=V\left(1-{\frac {S_{V}}{2}}\right)}

HSL to HSV

[edit]

Given a color with hueHL[0,360){\displaystyle H_{L}\in [0^{\circ },360^{\circ })}, saturationSL[0,1]{\displaystyle S_{L}\in [0,1]}, and luminanceL[0,1]{\displaystyle L\in [0,1]},

HV=HL{\displaystyle H_{V}=H_{L}}
SV={0if V=02(1LV)otherwise{\displaystyle S_{V}={\begin{cases}0&{\text{if }}V=0\\2\left(1-{\frac {L}{V}}\right)&{\text{otherwise}}\\\end{cases}}}
V=L+SLmin(L,1L){\displaystyle V=L+S_{L}\min(L,1-L)}

From RGB

[edit]

This is a reiteration of the previous conversion.

Value must be in rangeR,G,B[0,1]{\displaystyle R,G,B\in [0,1]}.

With maximum component (i. e. value)

Xmax:=max(R,G,B)=:V{\displaystyle X_{\text{max}}:=\max(R,G,B)=:V}

and minimum component

Xmin:=min(R,G,B)=VC{\displaystyle X_{\text{min}}:=\min(R,G,B)=V-C},

range (i. e. chroma)

C:=XmaxXmin=2(VL){\displaystyle C:=X_{\text{max}}-X_{\text{min}}=2(V-L)}

and mid-range (i. e. lightness)

L:=mid(R,G,B)=Xmax+Xmin2=VC2{\displaystyle L:=\operatorname {mid} (R,G,B)={\frac {X_{\text{max}}+X_{\text{min}}}{2}}=V-{\frac {C}{2}}},

we get common hue:

H:={0,if C=060(GBCmod6),if V=R60(BRC+2),if V=G60(RGC+4),if V=B{\displaystyle H:={\begin{cases}0,&{\text{if }}C=0\\60^{\circ }\cdot \left({\frac {G-B}{C}}\mod 6\right),&{\text{if }}V=R\\60^{\circ }\cdot \left({\frac {B-R}{C}}+2\right),&{\text{if }}V=G\\60^{\circ }\cdot \left({\frac {R-G}{C}}+4\right),&{\text{if }}V=B\end{cases}}}

and distinct saturations:

SV:={0,if V=0CV,otherwise{\displaystyle S_{V}:={\begin{cases}0,&{\text{if }}V=0\\{\frac {C}{V}},&{\text{otherwise}}\end{cases}}}
SL:={0,if L=0 or L=1C1|2VC1|=2(VL)1|2L1|=VLmin(L,1L),otherwise{\displaystyle S_{L}:={\begin{cases}0,&{\text{if }}L=0{\text{ or }}L=1\\{\frac {C}{1-\left\vert 2V-C-1\right\vert }}={\frac {2(V-L)}{1-\left\vert 2L-1\right\vert }}={\frac {V-L}{\min(L,1-L)}},&{\text{otherwise}}\end{cases}}}

Swatches

[edit]

Mouse over theswatches below to see theR,G, andB values for each swatch in atooltip.

HSL

[edit]
 H = 180° H = 0°
L  S{\displaystyle \textstyle {\bcancel {\!{}_{\boldsymbol {L}}\ \ {}^{\boldsymbol {S}}\!\!}}}134121401412341
1         
78         
34         
58         
12         
38         
14         
18         
0         
 H = 210° H = 30°
L  S{\displaystyle \textstyle {\bcancel {\!{}_{\boldsymbol {L}}\ \ {}^{\boldsymbol {S}}\!\!}}}134121401412341
1         
78         
34         
58         
12         
38         
14         
18         
0         
 H = 240° H = 60°
L  S{\displaystyle \textstyle {\bcancel {\!{}_{\boldsymbol {L}}\ \ {}^{\boldsymbol {S}}\!\!}}}134121401412341
1         
78         
34         
58         
12         
38         
14         
18         
0         
 H = 270° H = 90°
L  S{\displaystyle \textstyle {\bcancel {\!{}_{\boldsymbol {L}}\ \ {}^{\boldsymbol {S}}\!\!}}}134121401412341
1         
78         
34         
58         
12         
38         
14         
18         
0         
 H = 300° H = 120°
L  S{\displaystyle \textstyle {\bcancel {\!{}_{\boldsymbol {L}}\ \ {}^{\boldsymbol {S}}\!\!}}}134121401412341
1         
78         
34         
58         
12         
38         
14         
18         
0         
 H = 330° H = 150°
L  S{\displaystyle \textstyle {\bcancel {\!{}_{\boldsymbol {L}}\ \ {}^{\boldsymbol {S}}\!\!}}}134121401412341
1         
78         
34         
58         
12         
38         
14         
18         
0         

HSV

[edit]
 H = 180° H = 0°
V   S{\displaystyle \textstyle {\bcancel {\!\!{}_{\boldsymbol {V}}\ \ ~\!{}^{\boldsymbol {S}}\!\!}}}134121401412341
1         
78         
34         
58         
12         
38         
14         
18         
0         
 H = 210° H = 30°
V   S{\displaystyle \textstyle {\bcancel {\!\!{}_{\boldsymbol {V}}\ \ ~\!{}^{\boldsymbol {S}}\!\!}}}134121401412341
1         
78         
34         
58         
12         
38         
14         
18         
0         
 H = 240° H = 60°
V   S{\displaystyle \textstyle {\bcancel {\!\!{}_{\boldsymbol {V}}\ \ ~\!{}^{\boldsymbol {S}}\!\!}}}134121401412341
1         
78         
34         
58         
12         
38         
14         
18         
0         
 H = 270° H = 90°
V   S{\displaystyle \textstyle {\bcancel {\!\!{}_{\boldsymbol {V}}\ \ ~\!{}^{\boldsymbol {S}}\!\!}}}134121401412341
1         
78         
34         
58         
12         
38         
14         
18         
0         
 H = 300° H = 120°
V   S{\displaystyle \textstyle {\bcancel {\!\!{}_{\boldsymbol {V}}\ \ ~\!{}^{\boldsymbol {S}}\!\!}}}134121401412341
1         
78         
34         
58         
12         
38         
14         
18         
0         
 H = 330° H = 150°
V   S{\displaystyle \textstyle {\bcancel {\!\!{}_{\boldsymbol {V}}\ \ ~\!{}^{\boldsymbol {S}}\!\!}}}134121401412341
1         
78         
34         
58         
12         
38         
14         
18         
0         

See also

[edit]

Notes

[edit]
  1. ^In theJoblove and Greenberg (1978) paper first introducing HSL, they called HSL lightness "intensity", called HSL saturation "relative chroma", called HSV saturation "saturation" and called HSV value "value". They carefully and unambiguously described and compared three models: hue/chroma/intensity, hue/relative chroma/intensity, and hue/value/saturation. Unfortunately, later authors were less fastidious, and current usage of these terms is inconsistent and often misleading.
  2. ^The namehexcone for hexagonal pyramid was coined inSmith (1978), and stuck.
  3. ^For instance, a 1982 study by Berk, et al., found that users were better at describing colors in terms of HSL than RGB coordinates, after being taught both systems, but were much better still at describing them in terms of the natural-language CNS model (which uses names such as "very dark grayish yellow-green" or "medium strong bluish purple"). This shouldn't be taken as gospel however: a 1987 study by Schwarz, et al., found that users could match colors using RGB controls faster than with HSL controls; a 1999 study by Douglas and Kirkpatrick found that the visual feedback in the user interface mattered more than the particular color model in use, for user matching speed.[6][7][8]
  4. ^"Clearly, if color appearance is to be described in a systematic, mathematical way, definitions of the phenomena being described need to be precise and universally agreed upon."[16]
  5. ^InLevkowitz and Herman's formulation,R,G, andB stand for the voltages on the guns of a CRT display, which might have different maxima, and so their cartesiangamut could be a box of any unequal dimensions. Other definitions commonly use integer values in the range[0, 255], storing the value for each component in onebyte. We define the RGB gamut to be aunit cube for convenience because it simplifies and clarifies the math. Also, in general, HSL and HSV are today computed directly fromgamma-correctedR,G, andB – for instance insRGB space – but, when the models were developed, might have been transformations of a linear RGB space. Early authors don't address gamma correction at all, exceptAlvy Ray Smith[10] who clearly states that "We shall assume that an RGB monitor is a linear device", and thus designed HSV using linear RGB. We will drop the primes, and the labelsR,G, andB should be taken to stand for the three attributes of the origin RGB space, whether or not it is gamma corrected.
  6. ^Using thechroma here not only agrees with the originalJoblove and Greenberg (1978) paper, but is also in the proper spirit of the psychometric definition of the term. Some models call this attributesaturation – for instanceAdobe Photoshop's "Saturation" blend mode – but such use is even more confusing than the use of the term in HSL or HSV, especially when two substantially different definitions are used side by side.
  7. ^abMost of the computer graphics papers and books discussing HSL or HSV have a formula or algorithm describing them formally. Our formulas which follow are some mix of those. See, for instance,Agoston (2005) orFoley (1995)
  8. ^Hanbury and Serra (2002) put a great deal of effort into explaining why what we callchroma here can be written asmax(R,G,B) − min(R,G,B), and showing that this value is aseminorm. They reserve the namechroma for theEuclidean norm in the chromaticity plane (ourC2), and call this hexagonal distancesaturation instead, as part of their IHLS model
  9. ^In the following, the multiplication of hue by 60° – that is, 360°/6 – can be seen as the hexagonal-geometry analogue of the conversion fromradians to degrees, a multiplication by 360°/2π: the circumference of aunit circle is 2π; the circumference of a unit hexagon is 6.
  10. ^For a more specific discussion of the termluma, see CharlesPoynton (2008). See alsoRGB color space#Specifications. Photoshop exclusively uses the NTSC coefficients for its "Luminosity" blend mode regardless of the RGB color space involved.[27]
  11. ^The first nine colors in this table were chosen by hand, and the last ten colors were chosen at random.
  12. ^SeeSmith (1978). Many of these screenshots were taken from theGUIdebook, and the rest were gathered from image search results.
  13. ^For instance, a tool inIllustrator CS4, and Adobe's related web tool,Kuler, both allow users to define color schemes based on HSV relationships, but with a hue circle modified to better match theRYB model used traditionally by painters. The web toolsColorJack,Color Wizard, andColorBlender all pick color schemes with reference to HSL or HSV.
  14. ^Try a web search for "[framework name] color picker" for examples for a given framework, or "JavaScript color picker" for general results.
  15. ^ArcGIS calls its map-symbol gradients "color ramps". Current versions of ArcGIS can use CIELAB instead for defining them.[30]
  16. ^For instance, the first version of Photoshop had an HSL-based tool; see"Photoshop hue/saturation" in the GUIdebook for screenshots.[31][32]
  17. ^Photoshop's documentation explains that, e.g., "Luminosity: Creates a result color with the hue and saturation of the base color and the luminance of the blend color."[33]
  18. ^The HSL-style mode (with a Rec. 601 Luminosity) are also standardized inCSS from a documentation contributed by Adobe and Canon.[34] GIMP 2.10 has switched toLCH(ab) from its older HSV geometry.[35]
  19. ^The Ohta et al. model has parametersI1 = (R +G +B)/3,I2 = (RB)/2,I3 = (2GRB)/4.I1 is the same as ourI, andI2 andI3 are similar to ourβ andα, respectively, except that (a) whereα points in the direction ofR in the "chromaticity plane",I3 points in the direction ofG, and (b) the parameters have a different linear scaling which avoids the3 of ourβ.
  20. ^Most of the disadvantages below are listed inPoynton (1997), though as mere statements, without examples.
  21. ^Some points in this cylinder fall out ofgamut.

References

[edit]
  1. ^SeeAbsolute color space.
  2. ^abLevkowitz and Herman (1993)
  3. ^Wilhelm Ostwald (1916).Die Farbenfibel. Leipzig.
  4. ^Wilhelm Ostwald (1918).Die Harmonie der Farben. Leipzig.
  5. ^US patent 4694286, Bergstedt, Gar A., "Apparatus and method for modifying displayed color images", published 1987-09-15, assigned to Tektronix, Inc 
  6. ^Toby Berk; Arie Kaufman; Lee Brownston (August 1982)."A human factors study of color notation systems for computer graphics".Communications of the ACM.25 (8):547–550.doi:10.1145/358589.358606.S2CID 14838329.
  7. ^Michael W. Schwarz; William B. Cowan; John C. Beatty (April 1987)."An experimental comparison of RGB, YIQ, LAB, HSV, and opponent color models".ACM Transactions on Graphics.6 (2):123–158.doi:10.1145/31336.31338.S2CID 17287484.
  8. ^Sarah A. Douglas; Arthur E. Kirkpatrick (April 1999)."Model and representation: the effect of visual feedback on human performance in a color picker interface".ACM Transactions on Graphics.18 (2):96–127.doi:10.1145/318009.318011.S2CID 14678328.
  9. ^The original patent on this idea was byGeorges Valensi in 1938:
    FR patent 841335, Valensi, Georges, "Procédé de télévision en couleurs", published 1939-05-17, issued 1939-02-06 
    US patent 2375966, Valensi, Georges, "System of television in colors", published 1945-05-15 
  10. ^abcdSmith (1978)
  11. ^abcdJoblove and Greenberg (1978)
  12. ^Maureen C. Stone (August 2001)."A Survey of Color for Computer Graphics". Course at SIGGRAPH 2001.
  13. ^Ware Myers (July 1979). "Interactive Computer Graphics: Flying High-Part I".Computer.12 (7):8–17.doi:10.1109/MC.1979.1658808.S2CID 15344162.
  14. ^N. Magnetat-Thalmann; N. Chourot; D. Thalmann (March 1984). "Colour Gradation, Shading and Texture Using a Limited Terminal".Computer Graphics Forum.3:83–90.doi:10.1111/j.1467-8659.1984.tb00092.x.S2CID 29541525.
  15. ^Computer Graphics Staff (August 1979). "Status report of the graphic standards planning committee".ACM SIGGRAPH Computer Graphics.13 (3):1–10.doi:10.1145/988497.988498.S2CID 43687764.
  16. ^abcdefghFairchild (2005),pp. 83–93
  17. ^Kuehni (2003)
  18. ^Standard Terminology of Appearance E284.ASTM. 2009.
  19. ^International Lighting Vocabulary (4th ed.).CIE andIEC. 1987.ISBN 978-3-900734-07-7. Archived fromthe original on 2010-02-27. Retrieved2010-02-05.
  20. ^Poynton (1997)
  21. ^Sharma, G. (2003).Digital Color Imaging Handbook. Boca Raton, FL: CRC Press.ISBN 978-0-8493-0900-7.
  22. ^Hanbury and Serra (2002)
  23. ^abHanbury (2008)
  24. ^Patrick Lambert; Thierry Carron (1999). "Symbolic fusion of luminance-hue-chroma features for region segmentation".Pattern Recognition.32 (11): 1857.Bibcode:1999PatRe..32.1857L.doi:10.1016/S0031-3203(99)00010-2.
  25. ^Rafael C. Gonzalez and Richard Eugene Woods (2008).Digital Image Processing, 3rd ed. Upper Saddle River, NJ: Prentice Hall.ISBN 0-13-168728-X.pp. 407–413.
  26. ^Poynton (1997)."What weighting of red, green and blue corresponds to brightness?"
  27. ^Bruce Lindbloom (2001-09-25).http://lists.apple.com/archives/colorsync-users/2001/Sep/msg00488.htmlArchived 2011-07-07 at theWayback Machine "Re: Luminosity channel...".
  28. ^abcdCheng et al. (2001)
  29. ^Tantek Çelik, Chris Lilley, and L. David Baron (July 2008)."CSS3 Color Module Level 3".
  30. ^"Working with color ramps".Environmental Systems Research Institute. January 2008. RetrievedAugust 30, 2017.
  31. ^Bradley, John (1994)."The HSV Modification Tools".John's World of XV and Other Cool Stuff.
  32. ^Sinkel, Kiril (January 2010)."User Guide for Picture Window and Picture Window Pro Digital Light & Color"(PDF). Archived fromthe original(PDF) on 2014-05-12.
  33. ^"Blending Modes".Photoshop User Guide. Adobe Systems Incorporated. February 15, 2017.
  34. ^"Compositing and Blending Level 1".www.w3.org.
  35. ^"GIMP's LCH Blend Modes".Nine Degrees Below.
  36. ^John Kender (1976). "Saturation, hue and normalized color". Carnegie Mellon University, Computer Science Dept. Pittsburgh, PA.
  37. ^Yu-Ichi Ohta; Takeo Kanade; Toshiyuki Sakai (1980). "Color information for region segmentation".Computer Graphics and Image Processing.13 (3): 222.doi:10.1016/0146-664X(80)90047-7.
  38. ^Ffrank Perez; Christof Koch (1994)."Toward color image segmentation in analog VLSI: Algorithm and hardware"(PDF).International Journal of Computer Vision.12:17–42.doi:10.1007/BF01420983.S2CID 6140819.
  39. ^Brewer, Cynthia A. (1999)."Color Use Guidelines for Data Representation".Proceedings of the Section on Statistical Graphics. Alexandria, VA: American Statistical Association. pp. 55–60. Archived fromthe original on 2009-08-07. Retrieved2010-02-05.
  40. ^Fisher, Nicholas (1993).Statistical Analysis of Circular Dat. Cambridge University Press.doi:10.1017/CBO9780511564345.ISBN 978-0-521-35018-1.
  41. ^Hanbury, Allan (2003).Circular Statistics Applied to Colour Images. 8th Computer Vision Winter Workshop.CiteSeerX 10.1.1.4.1381.
  42. ^Poynton (1997)."What are HSB and HLS?"

Bibliography

[edit]

External links

[edit]
CAM
CIE
RGB
Y′UV
Other
Color systems
and standards
For the vision capacities of organisms or machines, see Color vision.
Retrieved from "https://en.wikipedia.org/w/index.php?title=HSL_and_HSV&oldid=1282304854"
Category:
Hidden categories:

[8]ページ先頭

©2009-2025 Movatter.jp