Archive-name: graphics/colorspace-faq
Posting-Frequency: Weekly
Last-modified: 29/6/94

###########################################################
Color spaces FAQ - David Bourgin
Date: 15/6/94 (items 5.3 and 6 updated)
Last update: 29/6/94

---------------------------
     Table of contents
---------------------------
1 - Purpose of this FAQ
2 - What is a color?
3 - What is an image based on a color look-up table?
4 - What is this gamma component?
5 - Color space conversions
5.1 - RGB, CMY, and CMYK
5.2 - HSL
5.3 - CIE XYZ and gray level pictures
5.4 - CIE Luv
5.5 - CIE Lab and LCH
5.6 - The associated standards: YUV, YIQ, and YCbCr
5.7 - SMPTE-C RGB
5.8 - YES from Xerox Corporation
5.9 - Kodak Photo CD YCC
5.10- YPbPr SMPTE-240M (HD televisions)
6 - References
7 - Comments and thanks

---------------------------
          Contents
---------------------------
1 - Purpose of this FAQ

    I did a (too) long period of research in the video domain (video cards,
    image file formats, and so on) and I've decided to provide to all people
    who need some informations about that.
    I aim to cover a part of the Frequently Asked Questions (FAQ) in the video
    works, it means to provide some (useful?) informations about the colors,
    and more especially about color spaces. If you have some informations
    to ask/add to this document, please read item 7.

2 - What is a color?

    A color is defined from human eye capabilities. If you consider a normal
    human being, his vision of a color will be the same as for another normal
    being. Of course, to show any colored informations, you need a definition
    (or a model, to use the right word). There are two kinds of color
    definitions:
    - The device-dependent: These definitions are more or less accurate.
    It means that when you display on such a device one color
    with the particular definition, you get a rendering but when you display
    on an other device the same color, you get another rendering (more or less
    dramatically different).
    - The device-independent: This means that the model is accurate and you
    must adjust your device output to get the same answer. This model is based
    on some institute works (curves of colors and associated values).

    From an absolute point of view, it means from a human visual sensation, a
    color could be defined by:
    - Hue: The perception of the nuance. It is the perception of what you see
    in a rainbow.
    - Colorfulness: The perception of saturation, vividness, purity of a color.
    You can go from a sky blue to a deep blue by changing this component.
    - Luminancy: The perception of an area to exhibit more or less light. It is
    also called brightness. You can blurry an image by modifying this
    component.

    As you see above, I describe a color with three parameters. All the
    students in maths are quickly going to say that the easier representation
    of this stuff is a space, a tri-dimensional space with the previous
    presentation. And I totally agree with that. That is why we often call
    'color space' a particular model of colors.
    With a color space, colors can be interpreted with response curves. While
    in a spectral representation of the wave lengths you have a range from
    infra red to ultra violet, in a normalized color space, we consider a range
    from black to white. All the pros use the internationally recognized
    standard CIE 1931 Standard Calorimetric Observer. This standard defines
    color curves (color matching functions) based on tristimulus values of
    human capabilities and conditions of view (enlightments, ...).
    The CIE (Comission Internationale de l'Eclairage) defined two very useful
    references for the chromacity of the white point:
    - D50 white used as reference for reflective copy
    - D65 white used as reference for emissive devices
    - D90 white used as an approximative reference for phosphors of a monitor
    Dxx means a temperature at about xx00 Kelvins. Example, D65 is given
    at 6504 K.

3 - What is an image based on a color look-up table?

    All of the pictures don't use the full color space. That's why we often
    use another scheme to improve the encoding of the picture (especially
    to get a file which takes less space). To do so, you have two
    possibilities:
    - You reduce the bits/sample. It means you use less bits for each component
    that describe the color. the color are described as direct colors, it means
    that all the pixels (or vectors, for vectorial descriptions) are directly
    stored with the full components. For example, with a RGB (see item 5.1
    to know what RGB is) bitmapped image
    with a width of 5 pixels and a height of 8 pixels, you have:
    (R11,G11,B11) (R12,G12,B12) (R13,G13,B13) (R14,G14,B14) (R15,G15,B15)
    (R21,G21,B21) (R22,G22,B22) (R23,G23,B23) (R24,G24,B24) (R25,G25,B25)
    (R31,G31,B31) (R32,G32,B32) (R33,G33,B33) (R34,G34,B34) (R35,G35,B35)
    (R41,G41,B41) (R42,G42,B42) (R43,G43,B43) (R44,G44,B44) (R45,G45,B45)
    (R51,G51,B51) (R52,G52,B52) (R53,G53,B53) (R54,G54,B54) (R55,G55,B55)
    (R61,G61,B61) (R62,G62,B62) (R63,G63,B63) (R64,G64,B64) (R65,G65,B65)
    (R71,G71,B71) (R72,G72,B72) (R73,G73,B73) (R74,G74,B74) (R75,G75,B75)
    (R81,G81,B81) (R82,G82,B82) (R83,G83,B83) (R84,G84,B84) (R85,G85,B85)
    where Ryx, Gyx, Byx are respectively the Red, Green, and Blue components
    you need to render a color for the pixel located at (x;y).
    - You use a palette. In this case, all the colors are stored in a table
    and the components of all the colors for each pixel (or the vector data)
    are removed to be replaced with a number. This number is an index in the
    palette. It explains why we call the palette, a color look-up table.

4 - What is this gamma component?

    An important notion in image processing comes from physical properties of
    output devices. We often have to correct the colors of an image to get a
    better rendering, i.e. to sharpen or blurry the picture. With the monitors,
    this is really true because input signals - proportional to the voltage -
    don't output a linear answer curve. So, a normal monitor follows an answer
    curve with an exponential law and a monitor based on LCDs follows an "S"
    curve with a vicious hook near black and a slow roll-off near white.
    The adapted correction functions are called gamma correction.
    We will keep in mind that most of software propose a displaying correction
    based on a power law relationship. It is given as:

    Red  = a*(Red'^gamma)+b
    Green= a*(Green'^gamma)+b
    Blue = a*(Blue'^gamma)+b

    where Red', Green', and Blue' are the values of volts in input, i.e the
    values of each primary component for each pixel in the picture you have,
    Red, Green, and Blue are the adapted light components for your device,
    a and b are linear transformations to adapt the law relationship, and
    gamma is the correction factor.
    Be care: a, b, and gamma are usually real constant for *all* pixels.
    Note that the software set up a to 1 and b to 0...
    For CRTCs gray level drawing pictures, gamma is usually within the range of
    [1.2;1.8] but for true color pictures, the number is usually within the
    range of [1.8;2.2]. Normal display devices have an usual 2.35 (+/- 0.1)
    gamma value.
    I assume in the previous relationships that Red, Green, and Blue are
    given within the range of [0;1]. But if they were as well positive as
    negative, you could have, for *example*:
    Red' = -0.5
    and Red = -(abs(Red')^gamma) = -(0.5^gamma)

    In some image file formats or in graphics applications in general, you
    need sometimes some other kinds of correction. These corrections provide
    some specific processings rather than true gamma correction curves.
    This is often the case, for examples, with the printing devices or
    in animation. In the first case, it is interesting to specify that a color
    must be re-affected in order you get a better rendering, as we see it later
    in CMYK item. In the second case, some animations can need an extra
    component associated to each pixel. This component can be, for example,
    used as a transparency mask. We *improperly* call this extra component
    gamma correction.

5 - Color space conversions

    Except an historical point of view, most of you are - I hope - interested
    in color spaces to make renderings and, if possible, on your favorite
    computer. Most of computers display with RGB color space but you may need
    sometimes the CMYK color space for printing, the YCbCr or CIE Lab to
    compress with JPEG scheme, and so on. That is why we are going to see,
    from here, what are all these color spaces and how to convert them from one
    to another (and primary from one to RGB, this was my purpose when I started
    this FAQ).

    I provide the color space conversions for programmers. The specialists
    don't need most of these infos or they can give a glance to all the stuff
    and read carefully the item 6. Many of the conversions are based on linear
    functions. The best example is given in item 5.3. These conversions can
    be seen in matrices. And to go from one to another space color, you just
    make a matrix inversion.
    E.g. RGB -> CIE XYZccir601-1 (D65) provides the following matrix of numbers
    (see item 5.3):
    |  0.607   0.174   0.200 |
    |  0.299   0.587   0.114 |
    |  0.000   0.066   1.111 |
    and CIE XYZccir601-1 (D65) -> RGB provides the following matrix:
    |  1.910  -0.5338 -0.2891 |
    | -0.9844  1.9990 -0.0279 |
    | 0.0585  -0.1187 -0.9017 |
    These two matrices are the (approximative) inversion of each other.
    If you are a biginner in this mathematical stuff, skip the previous
    explainations, and just use the result...

5.1 - RGB, CMY, and CMYK

    The most popular color spaces are RGB and CMY. These two acronyms stand
    for Red-Green-Blue and Cyan-Magenta-Yellow. They're device-dependent.
    The first is normally used on monitors, the second on printers.
    RGB are called primary colors because a color is produced by adding
    the three components, red, green, and blue.
    CMY is called secondary colors because to describe a color in this color
    space, you consider the reflecting result. So, you become like a painter
    who puts some (secondary) colors on a sheet of paper. A *white* light is
    received on the sheet. You have to keep in mind that white in RGB is all
    components set up to their maximum values. The white color is reflected on
    the sheet so that the components of white (primary colors) are subtracted
    from the components of the 'painting' (secondary colors). Such reflecting
    colors are called secondary colors, for the previous reasons...

    RGB -> CMY    | CMY -> RGB
    Red   = 1-Cyan (0<=Cyan<=1) | Cyan    = 1-Red (0<=Red<=1)
    Green = 1-Magenta (0<=Magenta<=1) | Magenta = 1-Green (0<=Green<=1)
    Blue  = 1-Yellow (0<=Yellow<=1) | Yellow  = 1-Blue (0<=Blue<=1)

    On printer devices, a component of black is added to the CMY, and the
    second color space is then called CMYK (Cyan-Magenta-Yellow-blacK). This
    component is actually used because cyan, magenta, and yellow set up to the
    maximum should produce a black color. (The RGB components of the white are
    completly substracted from the CMY components.) But the resulted color
    isn't physically a 'true' black. The most usual definition for the CMYK
    color space is given below:
    CMY -> CMYK    | CMYK -> CMY
    Black=minimum(Cyan,Magenta,Yellow) | Cyan=minimum(1,Cyan*(1-Black)+Black)
    Cyan=(Cyan-Black)/(1-Black)  | Magenta=minimum(1,Magenta*(1-Black)+Black)
    Magenta=(Magenta-Black)/(1-Black) | Yellow=minimum(1,Yellow*(1-Black)+Black)
    Yellow=(Yellow-Black)/(1-Black) |

    RGB -> CMYK    | CMYK -> RGB
    Black=minimum(1-Red,1-Green,1-Blue) | Red=1-minimum(1,Cyan*(1-Black)+Black)
    Cyan=(1-Red-Black)/(1-Black) | Green=1-minimum(1,Magenta*(1-Black)+Black)
    Magenta=(1-Green-Black)/(1-Black) | Blue=1-minimum(1,Yellow*(1-Black)+Black)
    Yellow=(1-Blue-Black)/(1-Black) |

    Of course, I assume that C, M, Y, K, R, G, and B  have a range of [0;1]

5.2 - HSL

    The representation of the colors in the RGB space is quite adapted for
    monitors but from a human being, this is not a useful definition. To
    provide a user representation in the user interfaces, we preferr the HSL
    color space. The acronym stand for Hue (see definition of Hue in item 2),
    Saturation (see definition of Colorfulness in item 2), and Luminosity
    (see definition of Luminancy in item 2).
    The big disadvantage of this model is the conversion. The most complicated
    ones are:
    Hue = (Alpha-arctan((Red-Luminancy)*(3^0.5)/(Green-Blue)))/(2*PI)
    with { Alpha=PI/2 if Green>Blue
         { Aplha=3*PI/2 if Green<Blue
         { Hue=1 if Green=Blue
    Saturation = (Red^2+Green^2-Red*Green-Red*Blue-Blue*Green)^0.5
    Luminosity = (Red+Green+Blue)/3

    Note that you have to compute Luminosity *before* Hue. If not, you must
    assume that Hue =
(Alpha-arctan((2*Red-Green-Blue)/((Green-Blue)*(3^0.5))))/(2*PI).

    I assume that H, S, L, R, G, and B are within range of [0;1].

    If you have a simplification to go from and to RGB <-> HSL, let me know!
    (I've some but they're too unaccurate...)

5.3 - CIE XYZ and gray level pictures

    The CIE (a committee I presented in the item 2) has defined some relations
    to convert a RGB to its standard components. The standard components for
    CIE 1931 XYZ are X, Y, and Z. You have two main recommendations given by
    the CCIR (Comite Consultatif International de la Radio).
    The first is called CIE XYZccir601-1 and the second CIE XYZccir709.
    Here is *one* (the most used) of the conversion from CIE XYZccir601-1 (D65)
    to RGB and vice versa, it is CIE XYZ <-> NTSC RGB (NTSC: National
    Television Standards Committee) but you also have CIE XYZ <-> SMPTE RGB
    (see item 5.7), and CIE XYZ <-> PAL RGB.
    In fact, the conversion values depend on the device used to display
    the RGB colors.

    RGB -> CIE XYZccir601-1 (D65) | CIE XYZccir601-1 (D65) -> RGB
    X = 0.607*Red+0.174*Green+0.200*Blue| Red   =  1.9104*X-0.5338*Y-0.2891*Z
    Y = 0.299*Red+0.587*Green+0.114*Blue| Green = -0.9844*X+1.9985*Y-0.0279*Z
    Z = 0.000*Red+0.066*Green+1.111*Blue| Blue  =  0.0585*X-0.1187*Y-0.9017*Z

    Important: If you want to make gray level images, just take the Y
    component.
    To make a black and white images without dithering technics, just consider
    that a color is black if Y>=0.5 (normally encoded as a bit set up to 1) or
    white (normally encoded as a bit set up to 0) otherwise...
    To go faster but with some more (not so, usually) losts, you can use the
    green component as if it were Y, it means Gray level = Green value.

    The white point coordinates are Xn, Yn and Zn. Xn, Yn, and Zn can be drawn
    from the transformation RGB -> CIE XYZ
    Xn=Sum of the numbers on line X=... 
    (In math terms, we say it's the sigma of the coefs of the line.)
    Yn=Sum of the numbers on line Y=...
    Zn=Sum of the numbers on line Z=...
    With RGB -> CIE XYZccir601-1, we have:
    Xn=0.607+0.174+0.200=0.981
    Yn=0.299+0.587+0.114=1.000 (Luminancy component tabulated to 1 (!))
    Zn=0.000+0.066+1.111=1.177
    BE CARE: In fact, you will rather use the following relationships to get
    more accuracy (Xn;Yn;Zn) coordinates.

    Usually, you get your CIE values in CIE xyY space (from a diagram of
    tristimuli in regard with the wave length).
    All coordinates you have are then (x,y) and you can compute:
    z = 1-(x+y)
    X = x*Y/y
    Z = z*Y/y

    D65 white point coordinates are given in CIE xyY diagram as
    (xn;yn)=(0.312713;0.329016). So, when you use the previous transformations
    and know that Yn is always tabulated to 1, you have:
    z = 1-(0.312713+0.329016) = 0.358271
    Xn = 0.312713*1/0.329016 = 0.9504
    Yn = 1
    Zn = 0.358271*1/0.329016 = 1.0889

    Furthermore, with CIE XYZccir601-1, you have the following RGB reference
    chromacity phosphors in CIE xyY diagram:
    Red(x;y)  = (0.630;0.340)
    Green(x;y)= (0.310;0.595)
    Blue(x;y) = (0.155;0.070)

    Recently (one year ago), CCIR and CCITT were both absorbed into their
    parent body, the International Telecommunications Union (ITU).
    Alan Roberts and Richard Salmon mailed me the new equations you should use
    instead of CIE XYZccir601-1 (D65), it means:

    RGB -> CIE XYZitu601-1 (D65)  | CIE XYZitu601-1 (D65) -> RGB
    X = 0.4306*Red+0.3415*Green+0.1784*Blue | Red   = 3.0627*X-1.3928*Y-0.4759*Z
    Y = 0.2220*Red+0.7067*Green+0.0713*Blue | Green =-0.9689*X+1.8756*Y+0.0417*Z
    Z = 0.0202*Red+0.1295*Green+0.9394*Blue | Blue  = 0.0585*X-0.2286*Y+1.0690*Z

    For those who are interested, I'm going to explain how to get such values.
    Of course, whenever you just read this FAQ to get programming infos, just
    skip this stuff and go to item 5.4.
    We saw in item 5 that color space conversions can be expressed by using
    matrices. From there I just take the good explainations I had with Alan
    Roberts and Richard Salmon:

    |R|      -1 |X|           |X|         |R|
    |G| = |M| . |Y|    and    |Y| = |M| . |G|
    |B|         |Z|           |Z|         |B|
    the matrix M is 3 by 3, and consists of the tristimulus values of the RGB
    primaries in terms of the XYZ primaries. Now we know the chromaticity
    coordinates of the RGB primaries in xy values, that is how they are
    specified, but we don't know the luminances of the RGB primaries. We need
    another piece of information to get those, we use the colour of the white
    balance point (D65 in television).

    Take, for example, the EBU RGB primaries. The chromaticity coordinates of
    each are:
    Red  : x=0.64      y =0.33      z=1-x-y  =0.03
    Green: x=0.29      y =0.60      z=1-x-y  =0.11
    Blue : x=0.15      y =0.06      z=1-x-y  =0.79
    White: xn=0.312713 yn=0.329016 zn=1-xn-yn= 0.358271  (Illuminant D65)
    Now we can say that:
    |X|   |ar xr   ag xg   ab xb|   |R|
    |Y| = |ar yr   ag yg   ab yb| . |G|
    |Z|   |ar zr   ag zg   ab zb|   |B|
    where the xyz values are the chromaticity coordinates, and the a values are
    the linear multipliers needed to convert these to tristimulus values. We
    can substitute the values for the primaries, and then for the white point:
    |Xn|   |ar 0.64   ag 0.29   ab 0.15|     |Rn|
    |Yn| = |ar 0.33   ag 0.60   ab 0.06|  .  |Gn|
    |Zn|   |ar 0.03   ag 0.11   ab 0.79|     |Bn|
    (Rn = Gn = Bn = 1)
    so now we can substitute the actual values for the white point:
    Xn = xn/yn*Yn = 0.9504492182751
    Yn = 1
    Zn = zn/yn*Yn = 1.08891664843
    and get:
    |0.95044921827|   |0.64   0.29   0.15|    |ar|
    |1.00000000000| = |0.33   0.60   0.06|  . |ag|
    |1.08891664843|   |0.03   0.11   0.79|    |ab|
    which is just a set of simultaneous equations we can solve in the usual way
    to get:
    ar = 0.672771675
    ag = 1.177758695
    ab = 1.188835496
    then multiply the chromaticity coordinates in the matrix equation to get:
    |X|   |0.430573872   0.341550022   0.178325324|     |R|
    |Y| = |0.222014653   0.706655217   0.071330130|  .  |G|
    |Z|   |0.020183150   0.129553456   0.939180042|     |B|
    which is the general equation that relates EBU RGB values to XYZ. If we
    invert the matrix by standard means we get:
    |R|   | 3.063218379  -1.393325262  -0.475801571|     |X|
    |G| = |-0.969243017   1.875966302   0.041555031|  .  |Y|
    |B|   | 0.067871316  -0.228833893   1.069251402|     |Z|

5.4 - CIE Luv

    In 1976, the CIE defined two new color spaces to enable us to get more
    uniform and accurate models. The first of these two color spaces is the
    CIE Luv which component are L*, u* and v*. L* component defines the
    luminancy, and u*, v* define chrominancy. CIE Luv is very used in
    calculation of small colors or color differences, especially with additive
    colors. The CIE Luv color space is defined from CIE XYZ.

    CIE XYZ -> CIE Lab
    { L* = 116*((Y/Yn)^(1/3)) whether Y/Yn>0.008856
    { L* = 903.3*Y/Yn whether Y/Yn<=0.008856
    u* = 13*(L*)*(u'-u'n)
    v* = 13*(L*)*(v'-v'n)
    where u'=4*X/(X+15*Y*+3*Z) and v'=9*Y/(X+15*Y+3*Z)
    and u'n and v'n have the same definitions for u' and v' but applied to the
    white point reference. So, you have:
    u'n=4*Xn/(Xn+15*Yn*+3*Zn) and v'n=9*Yn/(Xn+15*Yn+3*Zn)

    See also item 5.3 about Xn, Yn, and Zn.

5.5 - CIE Lab and LCH

    As CIE Luv, CIE Lab is a color space introduced by CIE in 1976. It's a new
    incorporated color space in TIFF specs. In this color space you use three
    components: L* is the luminancy, a* and b* are respectively red/blue and
    yellow/blue chrominancies.
    This color space is also defined with regard to the CIE XYZ color spaces.

    CIE XYZ -> CIE Lab
    { L=116*((Y/Yn)^(1/3)) whether Y/Yn>0.008856
    { L=903.3*Y/Yn whether Y/Yn<=0.008856
    a=500*(f(X/Xn)-f(Y/Yn))
    b=200*(f(Y/Yn)-f(Z/Zn))
    where { f(t)=t^(1/3) whether Y/Yn>0.008856
          { f(t)=7.787*t+16/116

    See also item 5.3 about Xn, Yn, and Zn.

    The CIE Lab has the same problem as RGB, it is not very useful for user
    interface. That's why you will preferr the LCH, a color space based on
    CIE Lab (accurate and useful...). LCH stand for Luminosity (see this term
    in item 2), Chroma (see Colourfulness in item 2), and Hue (see this term
    in item 2).
    CIE Lab -> LCH
    L = L*
    C = (a*^2+b*^2)^0.5
    { H=0 whether a=0
    { H=(arctan((b*)/(a*))+k*PI/2)/(2*PI) whether a#0 (add PI/2 to H if H<0)
    { and { k=0 if a*>=0 and b*>=0
          { or k=1 if a*>0 and b*<0
          { or k=2 if a*<0 and b*<0
          { or k=3 if a*<0 and b*>0

5.6 - The associated standards: YUV, YIQ, and YCbCr

    YUV and YIQ are standard color spaces used for TVs.
    YUV is used in European TVs and YIQ in North American TVs (NTSC).
    These colors spaces are less device-dependent than RGB (or CMYK) but we
    can't say they're device-independent (!).
    Y is linked to the component of luminancy, and U,V and I,Q are linked
    to the components of chrominancy. Y come from the standard CIE 1931 XYZ.
    There're several recommendations about Y. The most popular are given below:
    +----------------+---------------+-----------------+----------------+
    | Recommendation | Coef. for red | Coef. for Green | Coef. for Blue |
    +----------------+---------------+-----------------+----------------+
    | CCIR 601-1     | 0.299         | 0.587           | 0.114          |
    | CCIR 709       | 0.2125        | 0.7154          | 0.0721         |
    +----------------+---------------+-----------------+----------------+
    The more usual coefficients are those of the CCIR 601-1.
    Here are the conversions between RGB, YUV, and YIQ:
    YUV -> YIQ    | YIQ -> YUV
    Y = Y (no changes)   | Y = Y (no changes)
    I = -0.2676*U+0.7361*V  | U = -1.127*I+ 1.805*Q
    Q =  0.3869*U+0.4596*V  | V = 0.9489*I+0.6561*Q

    RGB -> YUV
    Y =              Coef. for red*Red+Coef. for green*Green+    Coef. for
blue*Blue
    U = Blue-Y =    -Coef. for red*Red-Coef. for green*Green+(1-Coef. for
blue)*Blue
    V = Red-Y  = (1-Coef. for red)*Red-Coef. for green*Green    -Coef. for
blue*Blue
    YUV -> RGB
    Red   = V+Y
    Green = (Y-Coef. for red*(V+Y)-Coef. for blue*(U+Y))/Coef. for green
    Blue  = U+Y

    RGB -> YIQ
    Y =                 Coef. for red*Red+       Coef. for green*Green+         
       Coef. for blue*Blue
    I = (0.7361-0.4685*Coef. for red)*Red-0.4685*Coef. for
green*Green+(-0.2676-0.4685*Coef. for blue)*Blue
    Q = (0.4596-0.8465*Coef. for red)*Red-0.8465*Coef. for green*Green+
(0.3869-0.8465*Coef. for blue)*Blue
    YIQ -> RGB
    Red   = 0.9489*I+0.6561*Q+Y
    Green = (Y-Coef. for red*(0.9489*I+0.6561*Q+Y)-Coef. for
blue*(-1.127*I+1.805*Q+Y))/Coef. for green
    Blue  = -1.127*I+1.805*Q+Y

    Note that Y has a range of [0;1] (if red, green, and blue have a range of
[0;1])
    but U, V, I, and Q can be as well negative as positive. I can't give the
    range of U, V, I, and Q because it depends on red, green, and blue
    coefficients from CCIR specs. To avoid such problems, you'll preferr the
    YCbCr. This color space is similar to YUV and YIQ without the
    disadvantages. Y remains the component of luminancy but Cb and Cr become
    the repective components of blue and red.
    RGB -> YCbCr
    Y  = Coef. for red*Red+Coef. for green*Green+Coef. for blue*Blue
    Cb = (Blue-Y)/(2-2*Coef. for blue)
    Cr = (Red-Y)/(2-2*Coef. for red)
    YCbCr -> RGB
    Red   = Cr*(2-2*Coef. for red)+Y
    Green = (Y-Coef. for blue*Blue-Coef. for red*Red)/Coef. for green
    Blue  = Cb*(2-2*Coef. for blue)+Y
    (Note that the Green component must be computed *after* the two other
    components because Green component use the values of the two others.)
    With the IJG (Independent JPEG Group) source codes, you deduce:
    RGB -> YCbCr (with CCIR 601-1 specs) | YCbCr -> RGB
    Y=  0.2990*Red+0.5870*Green+0.1140*Blue | Red=  Y+0.0000*Cb+1.4020*Cr
    Cb=-0.1687*Red-0.3313*Green+0.5000*Blue | Green=Y-0.3441*Cb-0.7141*Cr
    Cr= 0.5000*Red-0.4187*Green-0.0813*Blue | Blue= Y+1.7720*Cb+0.0000*Cr

    I assume Y is within the range [0;1], and Cb and Cr are within the range
    [-0.5;0.5].

5.7 - SMPTE-C RGB

    SMPTE is an acronym which stands for Society of Motion Picture and
Television
    Engineers. They give a gamma (=2.2 with NTSC, and =2.8 with PAL) corrected
    color space with RGB components (about RGB, see item 5.1).
    Conversion from SMPTE-C RGB to CIE XYZ (D65) or from CIE XYZ (D65) to
    SMPTE-C RGB, you have two steps:
    SMPTE-C RGB -> CIE XYZ (D65)  | CIE XYZ (D65) -> SMPTE-C RGB
    - Gamma correction    | - Linear transformations:
    Red=f1(Red')    | Red  = 3.5064*X-1.7402*Y-0.5441*Z
    Green=f1(Green')    | Green=-1.0692*X+1.9778*Y+0.0353*Z
    Blue=f1(Blue')    | Blue = 0.0564*X-0.1970*Y+1.0501*Z
    where { f1(t)=t^2.2 whether t>=0.0  | - Gamma correction
          { f1(t)-(abs(t)^2.2) whether t<0.0 | Red'=f2(Red)
    - Linear transformations:   | Green'=f2(Green)
    X=0.3935*Red+0.3653*Green+0.1916*Blue | Blue'=f2(Blue)
    Y=0.2124*Red+0.7011*Green+0.0865*Blue | where { f2(t)=t^(1/2.2) whether
t>=0.0
    Z=0.0187*Red+0.1119*Green+0.9582*Blue |       { f2(t)-(abs(t)^(1/2.2))
whether t<0.0

5.8 - YES from Xerox Corporation

    YES have three components which are Y (see Luminancy, item 2), E
(chrominancy
    of red-green axis), and S (chrominancy of yellow-blue axis)
    Conversion from YES to CIE XYZ (D65) or from CIE XYZ (D65) to YES, you have
two
    steps:
    YES -> CIE XYZ (D65)   | CIE XYZ (D65) -> YES
    - Gamma correction    | - Linear transformations:
    Y=f1(Y')     | Y= 1.000*X+0.000*Y+0.000*Z
    E=f1(E')     | E=-0.359*X-0.883*Y-0.001*Z
    S=f1(S')     | S=-0.045*X+0.000*Y-0.883*Z
    where { f1(t)=t^2.2 whether t>=0.0  | - Gamma correction
          { f1(t)-(abs(t)^2.2) whether t<0.0 | Y'=f2(Y)
    - Linear transformations:   | E'=f2(E)
    X= 1.000*Y+0.000*E+0.000*S   | S'=f2(S)
    Y=-0.406*Y-1.132*E+0.001*S   | where { f2(t)=t^(1/2.2) whether t>=0.0
    Z=-0.051*Y+0.000*E-1.133*S   |       { f2(t)-(abs(t)^(1/2.2)) whether t<0.0

5.9 - Kodak Photo CD YCC

    YCC is a color space intented for Kodak Photo CD. Its components are
    defined with the D65 white point and are Y (see Luminancy, item 2) and C1
    and C2 (both are linked to chrominancy).

5.10- YPbPr SMPTE-240M (HD televisions)

    SMPTE give a gamma (=0.45) corrected color space with RGB components (about
    RGB, see item 5.1). With this space color, you have three components Y, Pb,
    and Pr respectively linked to luminancy (see item 2), green, and blue.
    You have the following RGB reference chromacity phosphors in CIE xyY
    diagram:
    Red(x;y)  = (0.670;0.330)
    Green(x;y)= (0.210;0.710)
    Blue(x;y) = (0.150;0.060)
    Conversion from SMPTE-240M RGB to CIE XYZ (D65) or from CIE XYZ (D65) to
    SMPTE-240M RGB, you have two steps:
    YPbPr -> RGB    | RGB -> YPbPr
    - Gamma correction    | - Linear transformations:
    Red=f(Red')     | Red  =1*Y+0.0000*Pb+1.5756*Pr
    Green=f(Green')    | Green=1*Y-0.2253*Pb+0.5000*Pr
    Blue=f(Blue')    | Blue =1*Y+1.8270*Pb+0.0000*Pr
    where { f(t)=t^0.45 whether t>=0.0  | - Gamma correction
          { f(t)-(abs(t)^0.45) whether t<0.0 | Red'=f(Red)
    - Linear transformations:   | Green'=f(Red)
    Y=  0.2122*Red+0.7013*Green+0.0865*Blue | Blue'=f(Red)
    Pb=-0.1162*Red-0.3838*Green+0.5000*Blue | where { f(t)=t^(1/0.45) whether
t>=0.0
    Pr= 0.5000*Red-0.4451*Green-0.0549*Blue |       { f(t)-(abs(t)^(1/0.45))
whether t<0.0

6 - References (most of them are provided by Adrian Ford)

    "An inexpensive scheme for calibration of a colour monitor in terms of CIE
    standard coordinates" W.B. Cowan, Computer Graphics, Vol. 17 No. 3, 1983

    "Calibration of a computer controlled color monitor", Brainard, D.H, Color 
    Research & Application, 14, 1, pp 23-34 (1989).

    "Color Monitor Colorimetry", SMPTE Recommended Practice RP 145-1987

    "Color Temperature for Color Television Studio Monitors", SMPTE Recommended
    Practice RP 37

    "Colour Science in Television and Display Systems" Sproson, W, N, 
    Adam Hilger Ltd, 1983. ISBN 0-85274-413-7
    (Color measuring from soft displays.
    Alan Roberts and Richard Salmon talks about it as a reference)

    "CIE Colorimetry" Official recommendations of the International Commission
    on Illumination, Publication 15.2 1986

    "CRT Colorimetry:Part 1 Theory and Practice, Part 2 Metrology", Berns,
    R.S., Motta, R.J. and Gorzynski, M.E., Color Research and Appliation, 18,
    (1993).
    (Adrian Ford talks about it as a must about color spaces)

    "Effective Color Displays. Theory and Practice", Travis, D, Academic Press,
    1991. ISBN 0-12-697690-2
    (Color applications in computer graphics)

    Field, G.G., Color and Its Reproduction, Graphics Arts Technical
    Foundation, 1988, pp. 320-9
    (Read this about CMY/CMYK)

    "Gamma and its disguises: The nonlinear mappings of intensity in
    perception, CRT's, Film and Video" C. A. Poynton, SMPTE Journal, December
    1993

    "Measuring Colour" second edition, R. W. G. Hunt, Ellis Horwood 1991,
    ISBN 0-13-567686-x
    (Calculation of CIE Luv and other CIE standard colors spaces)

    "On the Gun Independance and Phosphor Consistancy of Color Video Monitors"
    W.B. Cowan N. Rowell, Color Research and Application, V.11 Supplement 1986

    "Precision requirements for digital color reproduction" M Stokes
    MD Fairchild RS Berns, ACM Transactions on graphics, v11 n4 1992

    "The colorimetry of self luminous displays - a bibliography" CIE
    Publication n.87, Central Bureau of the CIE, Vienna 1990

    "The Reproduction of Colour in PhotoGraphy, Printing and Television", R. W.
    G. Hunt, Fountain Press, Tolworth, England, 1987

7 - Comments and thanks

    Whenever you would like to comment or suggest me some informations about
    this or about the color space transformations in general, please use email:
    david.bourgin@ufrima.imag.fr (David Bourgin)

    Special thanks to the following persons (there are actually many other
    people to cite) for contributing to valid these data:
    - Adrian Ford (ajoec1@westminster.ac.uk)
    - Tom Lane (Tom_Lane@G.GP.CS.CMU.EDU)
    - Alan Roberts and Richard Salmon (richard.salmon@rd.eng.bbc.co.uk)
    - Grant Sayer (grants@research.canon.oz.au)
    - Steve Westland (coa23@potter.cc.keele.ac.uk)

    Note: I'm going on holidays until september ("just" for two months ;-))
    but I'll be back with new items (changes for item 5.3 and new conversions
    in item 5.6 and some others...). Until there, send some mails if you
    want, I'll perhaps be able to read them on August (I can't be sure) or
    surely on September...

###########################################################
