What is sRGB?

sRGB is a standard 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. Its predecessor NIF RGB was used in FlashPix and was almost the same. 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.

sRGB uses the ITU-R BT.709 primaries, the same as in studio monitors and HDTV, 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.

The sRGB gamut

ChromaticityRedGreenBlueWhite point
x0.64000.30000.15000.3127
y0.33000.60000.06000.3290
Y0.21260.71520.07221.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 (XYZ = 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, which corrected small rounding errors in the original publication by sRGB’s creators, and assume the 2° standard colorimetric observer for CIE XYZ.)

{\displaystyle {\begin{bmatrix}R_{\mathrm {linear} }\\G_{\mathrm {linear} }\\B_{\mathrm {linear} }\end{bmatrix}}={\begin{bmatrix}+3.24096994&-1.53738318&-0.49861076\\-0.96924364&+1.8759675&+0.04155506\\+0.05563008&-0.20397696&+1.05697151\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}}}

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

Again the sRGB component values 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}}}

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.41239080&0.35758434&0.18048079\\0.21263901&0.71516868&0.07219232\\0.01933082&0.11919478&0.95053215\end{bmatrix}}{\begin{bmatrix}R_{\mathrm {linear} }\\G_{\mathrm {linear} }\\B_{\mathrm {linear} }\end{bmatrix}}}

Theory of the transformation

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.

We will be happy to hear your thoughts

      Leave a Comment

      Web Training Guides
      Compare items
      • Total (0)
      Compare
      0