# sRGB

sRGB is a standard[2] RGB (red, green, blue) color space that HP and Microsoft created cooperatively in 1996 to use on monitors, printers, and the Web. It was subsequently standardized by the IEC as IEC 61966-2-1:1999.[1] Its predecessor NIF RGB was used in FlashPix and was almost the same.[3] It is often the "default" color space for images that contain no color space information, especially if the images' pixels are stored in 8-bit integers per color channel.

Native name Standard RGB sRGB colors situated at calculated position in CIE 1931 chromaticity diagram. Luminance ${\displaystyle Y}$ set so that ${\displaystyle R+G+B=1}$ to avoid bright lines toward primaries' complementary colours. Standard RGB IEC 61966-2-1:1999 Published October 18, 1999; 21 years ago[1] IEC[1] TC/SC: TC 100/TA 2[1] Color space, color model sRGB webstore.iec.ch/publication/6169
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 blackbody because it is based on atmospheric filtered daylight.

sRGB uses the ITU-R BT.709 primaries, the same as in studio monitors and HDTV,[4] a transfer function (gamma) typical of CRTs, and a viewing environment designed to match typical home and office viewing conditions. This specification allowed sRGB to be directly displayed on typical CRT monitors of the time, which greatly aided its acceptance. sYCC uses BT.601 YCbCr matrix to encode into extended-gamut space, negative R'G'B' values are decoded using extended transfer function.

## The sRGB gamut

Chromaticity 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

sRGB 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. As with any RGB color space, for non-negative values of R, G, and B it is not possible to represent colors outside this triangle, which is well inside the range of colors visible to a human with normal trichromatic vision.

The primaries come from HDTV (Rec. 709), which in turn is based on Color TV (Rec. 601). These values reflect the approximate color of consumer CRT phosphors.

## The sRGB transfer function ("gamma")

x axis - stored value
yL axis - effective local gamma
yR axis - intensity
Plot of the sRGB intensities versus sRGB numerical values (red), and this function's slope in log-log space (blue), which is the effective gamma at each point. 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.

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

sRGB also defines a nonlinear transfer function between the intensity of these primaries and the actual number stored. The curve is similar to the gamma response of a CRT display. This nonlinear conversion means that sRGB is a reasonably efficient use of the values in an integer-based image file to display human-discernible light levels.

Unlike most other RGB color spaces, the sRGB gamma cannot be expressed as a single numerical value. The overall gamma is approximately 2.2, consisting of a linear (gamma 1.0) section near black, and a non-linear section elsewhere involving a 2.4 exponent and a gamma (slope of log output versus log input) changing from 1.0 through about 2.3. The purpose of the linear section is so the curve does not have an infinite slope at zero, which could cause numerical problems.

## Specification of the transformation

### The forward transformation (CIE XYZ to sRGB)

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

The first step in the calculation of sRGB from CIE XYZ is a linear transformation, which may be carried out by a matrix multiplication. (The numerical values below match those in the official sRGB specification,[1][5] which corrected small rounding errors in the original publication[2] by sRGB's creators, and assume the 2° standard colorimetric observer for CIE XYZ.[2])

It is actually matrix for BT.709 primaries, not just for sRGB (and second row of the sRGB to XYZ in the next paragraph is BT.709-2 matrix coefficients):

${\displaystyle {\begin{bmatrix}R_{\mathrm {linear} }\\G_{\mathrm {linear} }\\B_{\mathrm {linear} }\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_{D65}\\Y_{D65}\\Z_{D65}\end{bmatrix}}}$

These linear RGB values are not the final result; gamma correction must still be applied. The following formula transforms the linear values into sRGB:

${\displaystyle \gamma (u)={\begin{cases}12.92u&={\frac {323u}{25}}&u\leq 0.0031308\\1.055u^{1/2.4}-0.055&={\frac {211u^{\frac {5}{12}}-11}{200}}&{\text{otherwise}}\end{cases}}}$

• where ${\displaystyle u}$  is ${\displaystyle R}$ , ${\displaystyle G}$ , or ${\displaystyle B}$ .

These gamma-compressed values (sometimes called "non-linear values") are usually clipped to the 0 to 1 range. This clipping can be done before or after the gamma calculation, or done as part of converting to 8 bits. If values in the range 0 to 255 are required, e.g. for video display or 8-bit graphics, the usual technique is to multiply by 255 and round to an integer.

### The reverse transformation (sRGB to CIE XYZ)

Again the sRGB component values ${\displaystyle R_{\mathrm {srgb} }}$ , ${\displaystyle G_{\mathrm {srgb} }}$ , ${\displaystyle B_{\mathrm {srgb} }}$  are in the range 0 to 1. (Values in the range of 0 to 255 can simply be divided by 255.0).

${\displaystyle \gamma ^{-1}(u)={\begin{cases}{\frac {u}{12.92}}&={\frac {25u}{323}}&u\leq 0.04045\\\left({\tfrac {u+0.055}{1.055}}\right)^{2.4}&=\left({\tfrac {200u+11}{211}}\right)^{\frac {12}{5}}&{\text{otherwise}}\end{cases}}}$

• where ${\displaystyle u}$  is ${\displaystyle R_{\mathrm {srgb} }}$ , ${\displaystyle G_{\mathrm {srgb} }}$ , or ${\displaystyle B_{\mathrm {srgb} }}$ .

These gamma-expanded values (sometimes called "linear values" or "linear-light values") are multiplied by a matrix to obtain CIE XYZ:

${\displaystyle {\begin{bmatrix}X_{D65}\\Y_{D65}\\Z_{D65}\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_{\mathrm {linear} }\\G_{\mathrm {linear} }\\B_{\mathrm {linear} }\end{bmatrix}}}$

### sYCC extended-gamut transformation

As was defined in Amendment 1 to IEC 61966-2-1:1999 the YCbCr transformation uses BT.601 matrix, but with 4 decimal places.

{\displaystyle {\begin{aligned}Y'_{sYCC}&=&0.2990\cdot R'&+0.5870\cdot G'+&0.1140\cdot B'\\Cb'_{sYCC}&=-&0.1687\cdot R'&-0.3313\cdot G'+&0.5\cdot B'\\Cb'_{sYCC}&=&0.5\cdot R'&-0.4187\cdot G'-&0.0813\cdot B'\end{aligned}}} .

sYCC also extends sRGB transfer function. It is extended-gamut (compared to sRGB),[6] just like xvYCC: out-of-gamut YCbCr values that map to negative ${\displaystyle R}$ , ${\displaystyle G}$  and ${\displaystyle B}$  can be used to further extend gamut by using the very same XYZ sRGB matrix. Cb and Cr that are out of limited range 16-240 are not used though, like they are used in xvYCC, thus it can be full range and limited range.

${\displaystyle \gamma (u)={\begin{cases}12.92u&={\frac {323u}{25}}&-0.0031308\leq u\leq 0.0031308\\1.055u^{1/2.4}-0.055&={\frac {211u^{\frac {5}{12}}-11}{200}}&u>0.0031308\\-1.055(-u)^{1/2.4}+0.055&={\frac {-211(-u)^{\frac {5}{12}}+11}{200}}&u<-0.0031308\end{cases}}}$

It can be used in JPEG (part of JEITA CP-3451 standard) and JPEG 2000, that use only full range sYCC. HDMI can use sYCC digital YCbCr format (in full or limited range), and Nvidia, AMD and Intel support it, if display signals it in Colorimetry block of EDID. 0 and 255 values are reserved in HDMI interface for limited range formats (RGB and YCbCr).[7]

Amendment 1 also recommends to use XYZ to RGB matrix with higher precision (7 decimal points) that has enough accuracy for the case of 16-bit per channel. You need to invert the very same 4 decimal places RGB to XYZ matrix to 7 decimal places, not further define RGB to XYZ matrix:

${\displaystyle {\begin{bmatrix}R_{\mathrm {linear} }\\G_{\mathrm {linear} }\\B_{\mathrm {linear} }\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_{D65}\\Y_{D65}\\Z_{D65}\end{bmatrix}}}$ .[8]

## Theory of the transformation

The sRGB gamut projected into other color spaces. Clockwise from top-left: CIELAB, CIELUV, CIExyY, CIEXYZ.

It is often casually stated that the decoding gamma for sRGB data is 2.2, yet the above transform shows an exponent of 2.4. This is because the net effect of the piecewise decomposition is necessarily a changing instantaneous gamma at each point in the range: it goes from gamma = 1 at zero to a gamma of 2.4 at maximum intensity with a median value being close to 2.2. The transformation was designed to approximate a gamma of about 2.2, but with a linear portion near zero to avoid having an infinite slope at K = 0, which can cause numerical problems. The continuity condition for the curve ${\displaystyle C_{\mathrm {linear} }}$ , which is defined above as a piecewise function of ${\displaystyle C_{\mathrm {srgb} }}$ , is

${\displaystyle \left({\frac {K_{0}+a}{1+a}}\right)^{\gamma }=\left({\frac {K_{0}+\alpha -1}{\alpha }}\right)^{\gamma }={\frac {K_{0}}{\phi }}.}$

Solving with ${\displaystyle \gamma =2.4}$  and the standard value ${\displaystyle \phi =12.92}$  yields two solutions, ${\displaystyle K_{0}}$ ${\displaystyle 0.0381548}$  or ${\displaystyle 0.0404482}$ . The IEC 61966-2-1 standard uses the rounded value ${\displaystyle K_{0}=0.04045}$ , which yields ${\displaystyle \beta ={\frac {K_{0}}{\phi }}\approx 0.0031308}$ . However, if we impose the condition that the slopes match as well then we must have

${\displaystyle \gamma \left({\frac {K_{0}+a}{1+a}}\right)^{\gamma -1}\left({\frac {1}{1+a}}\right)=\gamma \left({\frac {K_{0}+\alpha -1}{\alpha }}\right)^{\gamma -1}\left({\frac {1}{\alpha }}\right)={\frac {1}{\phi }}.}$

We now have two equations. If we take the two unknowns to be ${\displaystyle K_{0}}$  and ${\displaystyle \phi }$  then we can solve to give

${\displaystyle K_{0}={\frac {a}{\gamma -1}}={\frac {\alpha -1}{\gamma -1}}}$ ,
${\displaystyle \phi ={\frac {(1+a)^{\gamma }(\gamma -1)^{\gamma -1}}{(a^{\gamma -1})(\gamma ^{\gamma })}}={\frac {\alpha ^{\gamma }(\gamma -1)^{\gamma -1}}{((\alpha -1)^{\gamma -1})(\gamma ^{\gamma })}}.}$

Substituting ${\displaystyle a=0.055}$  or ${\displaystyle \alpha =1.055}$  and ${\displaystyle \gamma =2.4}$  gives ${\displaystyle K_{0}={\frac {11}{280}}\approx 0.0392857}$  and ${\displaystyle \phi \approx 12.9232102}$ , with the corresponding linear-domain threshold at ${\displaystyle \beta \approx 0.00303993}$ . These values, rounded to ${\displaystyle K_{0}=0.03928}$ , ${\displaystyle \phi =12.92321}$  and ${\displaystyle \beta =0.00304}$ , sometimes describe sRGB conversion.[9] Publications by sRGB's creators[2] rounded to ${\displaystyle K_{0}=0.03928}$  and ${\displaystyle \phi =12.92}$ , hence ${\displaystyle \beta \approx 0.00304025}$  (this was also used in FlashPix), resulting in a small discontinuity in the curve. Some authors adopted these values in spite of the discontinuity.[10] For the standard, the rounded value ${\displaystyle \phi =12.92}$  was kept and the ${\displaystyle K_{0}}$  value was recomputed to make the resulting curve continuous, as described above, resulting in a slope discontinuity from 12.92 below the intersection to 12.70 above.

## Viewing environment

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 sRGB specification assumes a dimly lit encoding (creation) environment with an ambient correlated color temperature (CCT) of 5003 K. This differs from the CCT of the illuminant (D65). Using D50 for both would have made the white point of most photographic paper appear excessively blue.[11] 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.[2]

## Usage

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. However, consumer-level CCDs are typically uncalibrated, meaning that even though the image is being labeled as sRGB, one can't conclude that the image is color-accurate sRGB.

If the color space of an image is unknown and it is an 8- to 16-bit image format, assuming it is in the sRGB color space is a safe choice. An ICC profile may be used; the ICC distributes three such profiles:[12] two profiles conforming to version 4 of the ICC specification, which they recommend, and one profile conforming to version 2, which is still commonly used. Version 2 of ICC profile does not support parametric curve encoding,[13] that is why to approximate the EOTF it uses 1024 points 1DLUT, which may be not obvious to see that it is piecewise.

As the sRGB gamut meets or exceeds the gamut of a low-end inkjet printer, an sRGB image is often regarded as satisfactory for home use and printing. sRGB 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. Such images used on the Internet may be converted to sRGB using color management tools that are usually included with software that works in these other color spaces.

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,[14] added to the core in OpenGL 2.1) and rendering into sRGB gamma encoded framebuffers (first introduced with EXT_framebuffer_sRGB extension,[15] added to the core in OpenGL 3.0). Direct3D supports both textures and rendering starting with DirectX 9.[citation needed] 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.[16]

## References

1. "IEC 61966-2-1:1999". IEC Webstore. International Electrotechnical Commission. Retrieved 3 March 2017.
2. Michael Stokes; Matthew Anderson; Srinivasan Chandrasekar; Ricardo Motta (November 5, 1996). "A Standard Default Color Space for the Internet – sRGB, Version 1.10".
3. ^
4. ^ Charles A. Poynton (2003). Digital Video and HDTV: Algorithms and Interfaces. Morgan Kaufmann. ISBN 1-55860-792-7.
5. ^ "How to interpret the sRGB color space" (PDF). color.org. Retrieved 17 October 2017.
6. ^ ""New" Extended-gamut Color Space for Video Applications" (PDF). 2017-08-29. Archived (PDF) from the original on 2017-08-29. Retrieved 2021-03-31.
7. ^ "A DTV Profile for Uncompressed High Speed Digital Interfaces (ANSI/CTA-861-H)". Consumer Technology Association®. Retrieved 2021-03-31.
8. ^ "IEC 61966-2-1:1999/AMD1:2003 | IEC Webstore". webstore.iec.ch. Retrieved 2021-04-17.
9. ^ Phil Green & Lindsay W. MacDonald (2002). Colour Engineering: Achieving Device Independent Colour. John Wiley and Sons. ISBN 0-471-48688-4.
10. ^ Jon Y. Hardeberg (2001). Acquisition and Reproduction of Color Images: Colorimetric and Multispectral Approaches. Universal-Publishers.com. ISBN 1-58112-135-0.
11. ^ Rodney, Andrew (2005). Color Management for Photographers. Focal Press. p. 121. ISBN 978-0-240-80649-5. Why Calibrate Monitor to D65 When Light Booth is D50
12. ^ sRGB profiles, ICC
13. ^ "Android lock screen bug and ICC profiles". color.org. Retrieved 2021-03-24.
14. ^ "EXT_texture_sRGB". 24 January 2007. Retrieved 12 May 2020.
15. ^ "EXT_framebuffer_sRGB". 17 September 2010. Retrieved 12 May 2020.
16. ^ "GPU Gems 3: Chapter 24. The Importance of Being Linear, section 24.4.1". NVIDIA Corporation. Retrieved 3 March 2017.

### Standards

• IEC 61966-2-1:1999 is the official specification of sRGB. It provides viewing environment, encoding, and colorimetric details.
• Amendment A1:2003 to IEC 61966-2-1:1999 describes an analogous sYCC encoding for YCbCr color spaces, an extended-gamut RGB encoding, and a CIELAB transformation.
• sRGB on www.color.org
• The fourth working draft of IEC 61966-2-1 is available online, but is not the complete standard. It can be downloaded from www2.units.it.