Template:Short description Template:Lowercase title Template:Infobox technology standard Template:For

sRGB (standard RGB) is a colorspace, for use on monitors, printers, and the World Wide Web. It was initially proposed by HP and Microsoft in 1996<ref name=IEC1996draft/> and became an official standard of the International Electrotechnical Commission (IEC) as IEC 61966-2-1:1999.<ref name=IEC1999/> It is the current standard colorspace for the web, and it is usually the assumed colorspace for images that do not have an embedded color profile.

The sRGB standard uses the same color primaries and white point as the ITU-R BT.709 standard for HDTV,<ref name=poyn2003/> but a different transfer function (or gamma) compatible with the era's CRT displays,<ref name=ImEn2012/> and assumes a viewing environment closer to typical home and office viewing conditions. Matching the behavior of PC video cards and CRT displays greatly aided sRGB's popularity.

HistoryEdit

By the 1970s, most computers translated 8-bit digital data fairly linearly to a signal that was sent to a video monitor. However video monitors and TVs produced a brightness that was not linear with the input signal, roughly a power law with an exponent between 2 and 3. The exponent was commonly denoted with the letter <math>\gamma</math>, hence the common name "gamma correction" for this function. This design has the benefit of displaying an image with much less visual artifacts, as it places the digital values closer together near black and further apart near white (where changes in brightness are less visible). This gamma varied according to CRT manufacturers, but was normalized in 1993 for use in HDTV systems, as the ITU BT.709 standard<ref name=ITU1993.709/> The BT.709 standard specified a decoding function with a linear section near zero, transitioning to a shifted power law with exponent 1/0.45 ≈ 2.22...

sRGB was created a few years later by Hewlett-Packard and Microsoft. It was meant to describe the decoding function of most CRT computer monitors used with Windows operating systems at the time, which was still different from that assumed by BT.709.<ref name=HPWWWW/> The first draft of the standard <ref name=IEC1996draft/> was published in 1996. A fourth draft, still incomplete, is available online.<ref name=IEC1966-4/> Like the BT.709, the sRGB decoding function was defined as a linear section near zero that transitions to a shifted power law <ref name=robe1991/><ref name=colo2015/>

Actually using the sRGB standard became important as computer graphics software started to calculate in linear light levels in the late 1990s,Template:Cn and needed to use sRGB to convert from and to the common 8-bit image standards.

File:Srgbnonlinearity.png
On an sRGB display, each solid bar should look as bright as the surrounding striped dither. (Note: must be viewed at original, 100% size)

Images such as shown here became popular for adjusting a CRT monitor to correctly display sRGB.

Amendment 1 to IEC 61966-2-1:1999, approved in 2003, also defines a Yuv-style colorspace called sYCC and a conversion to more than 8 bits called Template:Nowrap. The scRGB standard also tries to extend sRGB to more bits.

DefinitionEdit

Transfer function ("gamma")Edit

File:SRGB gamma.svg
Plot of the sRGB intensities (red), and this function's slope in log-log space (blue), which is the instantaneous gamma. Below a compressed value of 0.04045 or a linear intensity of 0.00313, the curve is linear so the gamma is 1. Behind the red curve is a dashed black curve showing an exact gamma = 2.2 power law.

An sRGB image file contains Template:Mvar values for each pixel. 0.0 is "black" while 1.0 is the intensity of a color primary needed by "white". These floating-point values are derived from the file data, for a typical 8-bit-per-channel image the bytes are divided by 255.0.

The mapping from these values to intensity is a non-linear transfer function which is the combination of a linear function at low brightness values and a displaced power law for the rest of the range. Linear intensities Template:Mvar are derived using (same for all channels):<ref name=IEC2003/>

<math>R = \begin{cases}

R'/12.92, & R' \le 0.04045 \\[5mu] \left(\frac{\displaystyle R' + 0.055}{\displaystyle 1.055}\right) ^{2.4}, & R' > 0.04045 \end{cases}</math>

This function is quite close to <math>R'^{2.2}</math>. However, for low values near 0.04045 the difference is perceptible.<ref name=ImEn2012/><ref name=sira2020/>

The inverse function as defined by IEC2003 is:<ref name=IEC2003/>

<math>R' = \begin{cases}

12.92 R, & R \le 0.0031308 \\[5mu] (1.055)R^{1/2.4} - 0.055, & R > 0.0031308 \end{cases}</math>

If needed by the file format, values greater than 1.0 can be used (the results will also be greater than 1.0), and values less than 0.0 can be converted as Template:Math.<ref name=IEC2003/>

These functions are similar to those of BT.709, but the values are noticeably different.<ref name=ImEn2012/> Because of the rounding of the parameters, they have small discontinuities at the transition between the linear and non-linear part, on the order of 10−8, and they are not precise inverses of each other. These errors are too small to matter in practical situations.<ref name=summ2012/> In practice many pieces of software use different close-by values (see below), or ignore the linear section, or use a plain gamma 2.2 function. The change in the images is almost imperceptible, however it will make noticeable seams when differently-converted images are overlapped, and mismatched translations back and forth accumulate color shifts.<ref name=hard2001/> Many operating systems and programs send 8-bit sRGB images directly to video memory and assume this produces the correct levels.<ref name=sira2020/>

Deriving the transfer functionEdit

A shifted power law curve that passes through Template:Math is <math>y = \left(\frac{x+C}{1+C}\right)^\gamma</math>.

The first draft of the sRGB standard chose <math>\gamma= 2.4</math> and then computed <math>C=0.055</math><ref name=IEC1996draft/> so that the value at <math>x=0.4</math> was near <math>x^{2.2}</math>.Template:Cn

A straight line that passes through Template:Math, is <math>y = x/A</math>. The transition from the linear section to the power law section should be continuous (without a sudden step) and smooth (without a sudden change of slope).<ref name=HPWWWW/> To make it continuous when Template:Math, we must have

<math>\frac{X}{A} = \left(\frac{X+C}{1+C}\right)^\gamma</math>

To avoid a sudden change of slope where the two segments meet, the derivatives must also be equal at Template:Mvar:

<math>\frac{1}{A} = \gamma\left(\frac{X+C}{1+C}\right)^{\gamma-1}\left(\frac{1}{1+C}\right)</math>

Solving the two equations for Template:Mvar and Template:Mvar we get

<math>X = \frac{C}{\gamma-1}\;\;\;\;\; A = \frac{(1+C)^\gamma(\gamma-1)^{\gamma-1}}{(C^{\gamma-1})(\gamma^\gamma)}</math>

This produces <math>X \approx 0.0392857...</math> and <math>A \approx 12.9232102...</math>. These values, rounded to <math>X = 0.03928</math> and <math>A = 12.92321</math> are still incorrectly given in some publications.<ref name=gree2002/>

However, the sRGB draft standard rounded <math>A</math> to <math>12.92</math>,<ref name=IEC1996draft/> resulting in a small discontinuity in the curve.

The first official version of the standard was defined and published by the IEC in 1999. In this version, the rounded value of <math>A=12.92 </math> was retained, but the breakpoint <math>X</math> was redefined as <math>0.04045</math> to make the curve approximately continuous. With these values, there is still a discontinuity in the slope, from <math>1/12.92</math> just below the intersection to <math>1/12.70</math> just above it. The final standard also corrected some small rounding errors present in the draft.<ref name=IEC1996draft/>

PrimariesEdit

CIE values of sRGB primaries
Red Green Blue White point
x 0.6400 0.3000 0.1500 0.3127
y 0.3300 0.6000 0.0600 0.3290
Y 0.2126 0.7152 0.0722 1.0000

The sRGB standard defines the chromaticities of the red, green, and blue primaries, the colors where one of the three channels is nonzero and the other two are zero. The gamut of chromaticities that can be represented in sRGB is the color triangle defined by these primaries, which are set such that the range of colors inside the triangle is well within the range of colors visible to a human with normal trichromatic vision. As with any RGB color space, for non-negative values of Template:Mvar, Template:Mvar, and Template:Mvar it is not possible to represent colors outside this triangle.

The primaries come from HDTV (ITU-R BT.709), which are somewhat different from those for older color TV systems (ITU-R BT.601). These values were chosen to reflect the approximate color of consumer CRT phosphors at the time of its design. Since flat-panel displays at the time were generally designed to emulate CRT characteristics, the values also reflected prevailing practice for other display devices as well.<ref name=IEC1999/>

The sRGB standard specifies also the colors and relative intensities of the three primaries Template:Mvar, Template:Mvar, and Template:Mvar, by defining the mapping between these values (in linear brightness scale, before the gamma encoding) and the CIE XYZ perceptual color coordinates.<ref name=lindNNNN/> This mapping is the same specified by the BT.709 standard; in matrix notation,<ref name=IEC2003/>

<math>

\begin{bmatrix} X \\ Y \\ Z \end{bmatrix} = \begin{bmatrix}

0.4124 & 0.3576 & 0.1805 \\
0.2126 & 0.7152 & 0.0722 \\
0.0193 & 0.1192 & 0.9505

\end{bmatrix} \begin{bmatrix} R \\ G \\ B \end{bmatrix} </math>

These coefficients should be considered exact<ref name=IEC1999/> and assume the 2° standard colorimetric observer for CIE XYZ.<ref name=IEC1996draft/><ref name=ICC2015/> In particular, the second row of this matrix specifies the computation of the BT.709-2 luma (brightness) value from the linear Template:Mvar, Template:Mvar, and Template:Mvar values. (BT.709-1 had a typo in these coefficients.)

The inverse conversion, from CIE XYZ to (linear) Template:Mvar, can be obtained by inverting the matrix above to a suitable numerical accuracy. The 1999 standard provides the matrix

<math>

\begin{bmatrix} R \\ G \\ B \end{bmatrix} = \begin{bmatrix}

+3.2406 & -1.5372 & -0.4986 \\
-0.9689 & +1.8758 & +0.0415 \\
+0.0557 & -0.2040 & +1.0570

\end{bmatrix} \begin{bmatrix} X \\ Y \\ Z \end{bmatrix} </math> which is not the exact inverse of the sRGB to XYZ transformation, but was expected to be accurate enough for 8-bit encoded samples (with <math>M=255</math>).

The 1999 IEC standard was amended in 2003.<ref name=IEC2003/> The sRGB to CIE XYZ matrix was retained, but the inverse transformation above was replaced by a more accurate version, with seven decimal fraction digits. It provides the matrix

<math>

\begin{bmatrix} R \\ G \\ B \end{bmatrix} = \begin{bmatrix}

+3.2406255 & -1.5372080 & -0.4986286 \\
-0.9689307 & +1.8757561 & +0.0415175 \\
+0.0557101 & -0.2040211 & +1.0569959

\end{bmatrix} \begin{bmatrix} X \\ Y \\ Z \end{bmatrix} </math>. which is claimed to be sufficiently accurate for 16-bit samples.

For these formulas, the X, Y, and Z values must be scaled so that the Y of D65 ("white") is 1.0 (X = 0.9505, Y = 1.0000, Z = 1.0890). This is usually true but some color spaces use 100 or other values (such as in CIELAB, when using specified white points).

Viewing environmentEdit

File:Cie Chart with sRGB gamut by spigget.png
CIE 1931 xy chromaticity diagram showing the gamut of the sRGB color space (the triangle). The outer curved boundary is the spectral (or monochromatic) locus, with wavelengths shown in nanometers (labeled in blue). This image is drawn using sRGB, so colors outside the triangle cannot be accurately colored and have been interpolated. The D65 white point is shown in the center, and the Planckian locus is shown with color temperatures labeled in kelvins. D65 is not an ideal 6504-kelvin black body because it is based on atmospheric filtered daylight.

The sRGB specification assumes a dimly lit encoding (creation) environment with an ambient correlated color temperature (CCT) of 5003 K:

Parameter Value
Screen luminance level 80 cd/m2
Illuminant white point x = 0.3127, y = 0.3290 (D65)
Image surround reflectance 20% (~medium gray)
Encoding ambient illuminance level 64 lux
Encoding ambient white point x = 0.3457, y = 0.3585 (D50)
Encoding viewing flare 1.0%
Typical ambient illuminance level 200 lux
Typical ambient white point x = 0.3457, y = 0.3585 (D50)
Typical viewing flare 5.0%

The assumed ambient CCT differs from that of the BT.709 standard illuminant (D65), which is still retained for the screen white point. Using D50 for both would have made the white point of most photographic paper appear excessively blue.<ref name=rodn2005/><ref name=XritPPPP/> The other parameters, such as the luminance level, are representative of a typical CRT monitor.

For optimal results, the ICC recommends using the encoding viewing environment (i.e., dim, diffuse lighting) rather than the less-stringent typical viewing environment.<ref name=ICC.sRGB/>

Translation to integersEdit

Most file formats that use sRGB store 8-bit integers. Usually these are converted from 8 bits by dividing by 255.0, and converted to 8 bits by multiplying by 255 and rounding. However some software converts to 8 bits by multiplying by 256 and rounding down. Higher-quality software often uses dithering when writing so that color banding is hidden.

Annex G of the 2003 amendment of the sRGB standard describes an alternative encoding of color values, called bg-sRGB, that is recommended when the number of bits per channel is 10 or more. In this case 0.0 is mapped to a black point Template:Mvar and 1.0 is mapped to a white point Template:Mvar, with all other values interpreted linearly. For 10 bits Template:Math and Template:Math is specified, and for larger numbers Template:Mvar of bits:

<math> K = 3\times 2^{N-3}\quad\quad W = K + 255\times 2^{N-9}</math>

The 12-bit scRGB format does something similar, with Template:Math and Template:Math.

Allowing numbers greater than 1.0 allows high dynamic range images, and negative numbers allows colors outside the gamut triangle.<ref name=IEC2003/>

UsageEdit

File:CIE1931xy gamut comparison.svg
Comparison of some RGB and CMYK colour gamuts on a CIE 1931 xy chromaticity diagram

Due to the standardization of sRGB on the Internet, on computers, and on printers, many low- to medium-end consumer digital cameras and scanners use sRGB as the default (or only available) working color space.<ref>Even if uncalibrated, it is likely they match sRGB more closely than any other popular color space</ref> If the color space of an image is unknown and encoded with 8 bits in each channel, the sRGB encoding can be assumed. Due to programmers misunderstanding the meaning of "gamma" some image files that claim they contain a gamma of 1.0 should also be assumed to be sRGB.Template:Cn

As the sRGB gamut mostly meets or exceeds the gamut of a low-end inkjet printer, an sRGB image is often regarded as satisfactory for home printing. The sRGB color space is sometimes avoided by high-end print publishing professionals because its color gamut is not big enough, especially in the blue-green colors, to include all the colors that can be reproduced in CMYK printing. Images intended for professional printing via a fully color-managed workflow (e.g. prepress output) sometimes use another color space such as Adobe RGB (1998), which accommodates a wider gamut and CMYK color space like Fogra39.

Programming interface supportEdit

The two dominant programming interfaces for 3D graphics, OpenGL and Direct3D, have both incorporated support for the sRGB gamma curve. OpenGL supports textures with sRGB gamma encoded color components (first introduced with EXT_texture_sRGB extension,<ref name=OpGL2007/> added to the core in OpenGL 2.1) and rendering into sRGB gamma encoded framebuffers (first introduced with EXT_framebuffer_sRGB extension,<ref name=OpGL2010/> added to the core in OpenGL 3.0). Correct mipmapping and interpolation of sRGB gamma textures has direct hardware support in texturing units of most modern GPUs (for example nVidia GeForce 8 performs conversion from 8-bit texture to linear values before interpolating those values), and does not have any performance penalty.<ref name=NVIDZZZZ/>

ICC profilesEdit

A lookup table may be used to efficiently convert sRGB to other color spaces.Template:Citation needed The International Color Consortium (ICC) has published color profiles for this purpose, which are widely used.<ref name=ICC.sRGB/><ref name=ICC2015/> There are several variants,<ref name=ICC.profs/> including ICCmax, version 4, and version 2.

Version 4 is generally recommended, but version 2 is still commonly used and is the most compatible with other software including browsers.<ref>{{#invoke:citation/CS1|citation |CitationClass=web }}</ref> However, inconsistencies have been pointed out between those ICC profiles and the IEC sRGB standard.<ref name=stonQQQQ/> In particular, version 2 of the ICC profile specification does not implement the piecewise parametric curve encoding ("para") as specified by the IEC sRGB standard,<ref>{{#invoke:citation/CS1|citation |CitationClass=web }}</ref> and has to implement the sRGB transfer function using a one-dimensional lookup table.<ref name=ICC.profs/> Some implementations approximate the transfer function as 2.2 gamma, with no linear portion, called "simplified sRGB".<ref>{{#invoke:citation/CS1|citation |CitationClass=web }}</ref>

ReferencesEdit

Template:Notelist <references>

<ref name=IEC1996draft>{{#invoke:citation/CS1|citation |CitationClass=web }}</ref>

<ref name=IEC1966-4>fourth working draft (4WD) for 2CD of IEC 61966-2-1, (archived). Still not the complete standard.</ref>

<ref name=IEC1999>{{#invoke:citation/CS1|citation |CitationClass=web }}. The first official specification of sRGB.</ref>

<ref name=IEC2003>{{#invoke:citation/CS1|citation |CitationClass=web }} Replaces the version IEC 61966-2-1:1999, introducing the sYCC encoding for YCbCr color spaces, an extended-gamut RGB encoding bg-sRGB, and a CIELAB transformation.</ref>

<ref name=poyn2003>Template:Cite book</ref>

<ref name=gree2002>Template:Cite book</ref>

<ref name=summ2012>Jason Summers (2012): "A close look at the sRGB formula". Online document at entropymine.com. Accessed on 2014-12-17 (archived)</ref>

<ref name=sira2020>Daniele Siragusano (2020): "Colour Online: sRGB... We Need To Talk". YouTube video of talk (2020-07-17, 57 min) discussing mismatch between sRGB and actual monitor transfer functions. Posted in channel @FilmLight. Accessed on 2024-12-17.</ref>

<ref name=hard2001>Template:Cite book</ref>

<ref name=robe1991>Template:Cite report</ref>

<ref name=colo2015>NumFocus Colour Science (2015): "The Importance of Terminology and sRGB Uncertainty". Online document at www.colour-science.org, dated 2015-12-05. Accessed on 2024-12-17 (archived).</ref>

<ref name=ITU1993.709>{{#invoke:citation/CS1|citation |CitationClass=web }}</ref>

<ref name=OpGL2007>{{#invoke:citation/CS1|citation |CitationClass=web }}</ref>

<ref name=OpGL2010>{{#invoke:citation/CS1|citation |CitationClass=web }}</ref>

<ref name=NVIDZZZZ>{{#invoke:citation/CS1|citation |CitationClass=web }}</ref>

<ref name=HPWWWW>sRGB.com Notes on design and use of sRGB (archived) by HP.</ref>

<ref name=ImEn2012>Image Engineering GmbH (2012): "Color spaces - REC.709 vs. sRGB Online document at www.image-engineering.de. Includes a graph comparing two transfer functions. Accessed on 2024-12-17.</ref>

<ref name=ICC.profs>International Color Consortium (undated): "sRGB profiles". Summary page at color.org. Accessed on 2014-12-17 (archiving failed).</ref>

<ref name=ICC.sRGB>International Color Consortium (undated): "sRGB" Summary page at color.org. Accessed on 2014-12-17 (archiving failed).</ref>

<ref name=ICC2015>International Color Consortium (2015): "How to interpret the sRGB color space (specified in IEC 61966-2-1) for ICC profiles". Online document at www.color.org. Accessed on 2024-12-17 (archived)</ref>

<ref name=lindNNNN>Conversion matrices for RGB vs. XYZ conversion by Bruce Justin Lindbloom</ref>

<ref name=rodn2005>Template:Cite book</ref>

<ref name=XritPPPP>{{#invoke:citation/CS1|citation |CitationClass=web }}</ref>

<ref name=stonQQQQ>Will the Real sRGB Profile Please Stand Up? by Elle Stone. Analyzes the inconsistency among sRGB ICC profiles</ref>

</references>

External linksEdit

Template:Color space