[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: 3d highlights on dark colors
From: |
Gerd Moellmann |
Subject: |
Re: 3d highlights on dark colors |
Date: |
Fri, 10 Nov 2000 14:12:03 +0100 (CET) |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.0.90 |
Miles Bader <address@hidden> writes:
> Gerd Moellmann <address@hidden> writes:
> > I think it would be better to introduce two variables, say
> > top-shadow-contrast and bottom-shadow-contrast. These would replace
> > the hard coded constants 1.2 and 0.6 that are currently used to make
> > lighter and darker colors.
>
> That would be a good change too, but it wouldn't suffice to deal with
> the case I was addressing. You can't use a single multiplicative factor
> for all colors, it just doesn't work.
>
> [I've tried a lot of different tweaks to get emacs to generate
> good-looking highlights for all colors, and the code I sent is by far
> the best I've been able to come up with.]
I believe you.
If we really want to address this complicated matter, I'd propose we
try to make use of available knowledge about color perception. For
example, there exist formulas to determine a color's luminance (Y) and
its perceived lightness (L*) (another issue might be gamma correction
for device-dependent non-linearity).
The URL <http://www.inforamp.net/~poynton/Poynton-color.html> has
links to 2 useful FAQ documents. I've also attached another one.
address@hidden (David Bourgin (The best player).)
Color space FAQ
15 Oct 1994 16:22:38 GMT
ufrima
- Newsgroups:
- comp.graphics,sci.image.processing,comp.answers,sci.answers,news.answers
Archive-name: graphics/colorspace-faq
Posting-Frequency: Weekly
Last-modified: 28/9/94
###########################################################
Color spaces FAQ - David Bourgin
Date: 28/9/94 (items 5.2 to 5.10 fully rewritten)
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, HSV
5.3 - CIE XYZ and gray level (monochrome included) 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 - SMPTE-240M YPbPr (HD televisions)
5.9 - Xerox Corporation YES
5.10- Kodak Photo CD YCC
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 information, 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 output device 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 or enhance 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, ...).
See item 5.3.
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.
Those temperatures define the white points of particular systems. A white
point of a system is the color at which all three of the tristimuli (RGB,
for instance) are equal to each other. Being that a white point is
achromatic (=it has no color), we can define some temperatures associated
to the white references, in order we get a standard.
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 colors 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
called a palette 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 in the 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 and vice-versa, 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. A matrix is in mathematics an array of values. And to
go from one to another space color, you just make a matrix inversion.
E.g. RGB -> CIE XYZrec601-1 (C illuminant) 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.116 |
and CIE XYZrec601-1 (C illuminant) -> RGB provides the following matrix:
| 1.910 -0.532 -0.288 |
| -0.985 1.999 -0.028 |
| 0.058 -0.118 0.898 |
These two matrices are the (approximative) inversion of each other.
If you are a beginner 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 resulting 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, HSV
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 HSV model can be represented by a trigonal cone, as:
Green
/\
/ \ ^
/V=1 x \ \ Hue (angle, so that Hue(Red)=0, Hue(Green)=120, and Hue(blue)=240 deg)
Blue -------------- Red
\ | /
\ |-> Saturation (distance from the central axis)
\ | /
\ | /
\ | /
\ |/
V=0 x (Value=0 at the top of the apex and =1 at the base of the cone)
The big disadvantage of this model is the conversion. Most of publishings
(Microsoft, and Foley's "Computer Graphics: Principles and Practice",
included) give unaccurate transforms. Actually, the transforms are really
complicate, as given below:
Hue = (Alpha-arctan((Red-Luminosity)*(3^0.5)/(Green-Blue)))/(2*PI)
with { Alpha=PI/2 if Green>Blue
{ Aplha=3*PI/2 if Green CIE XYZccir601-1 (C illuminant):
|X| |0.606881 0.173505 0.200336| |Red |
|Y| = |0.298912 0.586611 0.114478| * |Green|
|Z| |0.000000 0.066097 1.116157| |Blue |
Because I'm a programer, I preferr to round these values up or down (in
regard with the new precision) and I get:
RGB -> CIE XYZccir601-1 (C illuminant) | CIE XYZccir601-1 (C illuminant) -> RGB
X = 0.607*Red+0.174*Green+0.200*Blue | Red = 1.910*X-0.532*Y-0.288*Z
Y = 0.299*Red+0.587*Green+0.114*Blue | Green = -0.985*X+1.999*Y-0.028*Z
Z = 0.000*Red+0.066*Green+1.116*Blue | Blue = 0.058*X-0.118*Y+0.898*Z
The other common recommendation is the 709. The white point is D65 and have
coordinates fixed as (xn;yn)=(0.312713;0.329016). The RGB chromacity
coordinates are:
Red: xr=0.64 yr=0.33
Green: xg=0.30 yg=0.60
Blue: xb=0.15 yb=0.06
Finally, we have RGB -> CIE XYZccir709 (709):
|X| |0.412411 0.357585 0.180454| |Red |
|Y| = |0.212649 0.715169 0.072182| * |Green|
|Z| |0.019332 0.119195 0.950390| |Blue |
This provides the formula to transform RGB to CIE XYZccir709 and vice-versa:
RGB -> CIE XYZccir709 (D65) | CIE XYZccir709 (D65) -> RGB
X = 0.412*Red+0.358*Green+0.180*Blue | Red = 3.241*X-1.537*Y-0.499*Z
Y = 0.213*Red+0.715*Green+0.072*Blue | Green = -0.969*X+1.876*Y+0.042*Z
Z = 0.019*Red+0.119*Green+0.950*Blue | Blue = 0.056*X-0.204*Y+1.057*Z
Recently (about one year ago), CCIR and CCITT were both absorbed into their
parent body, the International Telecommunications Union (ITU). So you must
*not* use CCIR 601-1 and CCIR 709 anymore. Furthermore, their names have
changed respectively to Rec 601-1 and Rec 709 ("Rec" stands for
Recommendation). Here is the new ITU recommendation.
The white point is D65 and have coordinates fixed as (xn;yn)=(0.312713;
0.329016). The RGB chromacity coordinates are:
Red: xr=0.64 yr=0.33
Green: xg=0.29 yg=0.60
Blue: xb=0.15 yb=0.06
Finally, we have RGB -> CIE XYZitu (D65):
|X| |0.430574 0.341550 0.178325| |Red |
|Y| = |0.222015 0.706655 0.071330| * |Green|
|Z| |0.020183 0.129553 0.939180| |Blue |
This provides the formula to transform RGB to CIE XYZitu and vice-versa:
RGB -> CIE XYZitu (D65) | CIE XYZitu (D65) -> RGB
X = 0.431*Red+0.342*Green+0.178*Blue | Red = 3.063*X-1.393*Y-0.476*Z
Y = 0.222*Red+0.707*Green+0.071*Blue | Green = -0.969*X+1.876*Y+0.042*Z
Z = 0.020*Red+0.130*Green+0.939*Blue | Blue = 0.068*X-0.229*Y+1.069*Z
All the conversions I presented until there in this item are not just for
fun ;-). They can really be useful. For example, in most of your
applications you have true color images in RGB color space. How to render
them fastly on your screen or on your favorite printer. This is simple.
You can convert your picture instantaneously in gray scale pictures see
even in a black and white pictures as a magician.
To do so, you just need to convert your RGB values into the Y component.
Actually, Y is linked to the luminosity (Y is an achromatic component) and
X and Z are linked to the colorfulness (X and Z are two chromatic
components). Old softwares used Rec 601-1 and produced:
Gray scale=Y=(299*Red+587*Green+114*Blue)/1000
With Rec 709, we have:
Gray scale=Y=(213*Red+715*Green+72*Blue)/1000
Some others do as if:
Gray scale=Green (They don't consider the red and blue components at all)
Or Gray scale=(Red+Green+Blue)/3
But now all people *should* use the most accurate, it means ITU standard:
Gray scale=Y=(222*Red+707*Green+71*Blue)/1000
(That's very close to Rec 709!)
I made some personal tests and have sorted them in regard with the global
resulting luminosity of the picture (from my eye point of view!). The
following summary gives what I found ordered increasingly:
+-----------------------------+----------------+
|Scheme |Luminosity level|
+-----------------------------+----------------+
|Gray=Green | 1 |
|Gray=ITU (D65) | 2 |
|Gray=Rec 709 (D65) | 3 |
|Gray=Rec 601-1 (C illuminant)| 4 |
|Gray=(Red+Green+Blue)/3 | 5 |
+-----------------------------+----------------+
So softwares with Gray=Rec 709 (D65) produce a more dark picture than with
Gray=Green. Even if you theorically lose many details with Gray=Green
scheme, in fact, and with the 64-gray levels of a VGA card of a PC it is
hard to distinguish the losts.
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 is used in European TVs and YIQ in North American TVs (NTSC).
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.
YUV uses D65 white point which coordinates are (xn;yn)=(0.312713;0.329016).
The RGB chromacity coordinates are:
Red: xr=0.64 yr=0.33
Green: xg=0.29 yg=0.60
Blue: xb=0.15 yb=0.06
See item 5.3 to understand why the above values.
RGB -> YUV | YUV -> RGB
Y = 0.299*Red+0.587*Green+0.114*Blue | Red = Y+0.000*U+1.140*V
U = -0.147*Red-0.289*Green+0.436*Blue | Green = Y-0.396*U-0.581*V
V = 0.615*Red-0.515*Green-0.100*Blue | Blue = Y+2.029*U+0.000*V
RGB -> YIQ | YUV -> RGB
Y = 0.299*Red+0.587*Green+0.114*Blue | Red = Y+0.956*I+0.621*Q
I = 0.596*Red-0.274*Green+0.322*Blue | Green = Y-0.272*I-0.647*Q
Q = 0.212*Red-0.523*Green-0.311*Blue | Blue = Y-1.105*I+1.702*Q
YUV -> YIQ | YIQ -> YUV
Y = Y (no changes) | Y = Y (no changes)
I = -0.2676*U+0.7361*V | U = -1.1270*I+1.8050*Q
Q = 0.3869*U+0.4596*V | V = 0.9489*I+0.6561*Q
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 precision from Rec 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 respective components of blue and
red. Futhermore, with YCbCr color space you can choose your luminancy from
your favorite recommendation. The most popular are given below:
+----------------+---------------+-----------------+----------------+
| Recommendation | Coef. for red | Coef. for Green | Coef. for Blue |
+----------------+---------------+-----------------+----------------+
| Rec 601-1 | 0.299 | 0.587 | 0.114 |
| Rec 709 | 0.2125 | 0.7154 | 0.0721 |
| ITU | 0.2125 | 0.7154 | 0.0721 |
+----------------+---------------+-----------------+----------------+
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.)
Usually, you'll need the following conversions based on Rec 601-1
for TIFF and JPEG works:
RGB -> YCbCr (with Rec 601-1 specs) | YCbCr (with Rec 601-1 specs) -> RGB
Y= 0.2989*Red+0.5866*Green+0.1145*Blue | Red= Y+0.0000*Cb+1.4022*Cr
Cb=-0.1687*Red-0.3312*Green+0.5000*Blue | Green=Y-0.3456*Cb-0.7145*Cr
Cr= 0.5000*Red-0.4183*Green-0.0816*Blue | Blue= Y+1.7710*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).
The white point is D65. The white point coordinates are (xn;yn)=(0.312713;
0.329016). The RGB chromacity coordinates are:
Red: xr=0.630 yr=0.340
Green: xg=0.310 yg=0.595
Blue: xb=0.155 yb=0.070
See item 5.3 to understand why the above values.
To get the conversion from SMPTE-C RGB to CIE XYZ or from CIE XYZ 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.5058*X-1.7397*Y-0.5440*Z
Green=f1(Green') | Green=-1.0690*X+1.9778*Y+0.0352*Z
Blue=f1(Blue') | Blue = 0.0563*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.0866*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 - SMPTE-240M YPbPr (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.
The white point is D65. The white point coordinates are (xn;yn)=(0.312713;
0.329016). The RGB chromacity coordinates are:
Red: xr=0.67 yr=0.33
Green: xg=0.21 yg=0.71
Blue: xb=0.15 yb=0.06
See item 5.3 to understand why the above values.
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
5.9 - Xerox Corporation YES
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 (D50) or from CIE XYZ (D50) to YES, you have two
steps:
YES -> CIE XYZ (D50) | CIE XYZ (D50) -> YES
- Gamma correction | - Linear transformations:
Y=f1(Y') | Y= 0.000*X+1.000*Y+0.000*Z
E=f1(E') | E= 1.783*X-1.899*Y+0.218*Z
S=f1(S') | S=-0.374*X-0.245*Y+0.734*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=0.964*Y+0.528*E-0.157*S | S'=f2(S)
Y=1.000*Y+0.000*E+0.000*S | where { f2(t)=t^(1/2.2) whether t>=0.0
Z=0.825*Y+0.269*E+1.283*S | { f2(t)-(abs(t)^(1/2.2)) whether t<0.0
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= 0.000*X+1.000*Y+0.000*Z
E=f1(E') | E=-2.019*X+1.743*Y-0.246*Z
S=f1(S') | S= 0.423*X+0.227*Y-0.831*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=0.782*Y-0.466*E+0.138*S | S'=f2(S)
Y=1.000*Y+0.000*E+0.000*S | where { f2(t)=t^(1/2.2) whether t>=0.0
Z=0.671*Y-0.237*E-1.133*S | { f2(t)-(abs(t)^(1/2.2)) whether t<0.0
Usually, you should use YES <-> CIE XYZ (D65) conversions because your
screen and the usual pictures have D65 as white point. Of course, sometime
you'll need the first conversions. Just take care on your pictures.
5.10- Kodak Photo CD YCC
YCC is a color space intented for Kodak Photo CD. It uses Rec 709 as gamma
correction but 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).
YC1C2->RGB | RGB->YC1C2
- Gamma correction: | Y' =1.3584*Y
Red =f(red') | C1'=2.2179*(C1-156)
Green=f(Green') | C2'=1.8215*(C2-137)
Blue =f(Blue') | Red =Y'+C2'
where { f(t)=-1.099*abs(t)^0.45+0.999 if t<=-0.018 | Green=Y'-0.194*C1'-0.509*C2'
{ f(t)=4.5*t if -0.018=0.018 |
- Linear transforms: |
Y' = 0.299*Red+0.587*Green+0.114*Blue |
C1'=-0.299*Red-0.587*Green+0.886*Blue |
C2'= 0.701*Red-0.587*Green-0.114*Blue |
- To fit it into 8-bit data: |
Y =(255/1.402)*Y' |
C1=111.40*C1'+156 |
C2=135.64*C2'+137 |
Finally, I assume Red, Green, Blue, Y, C1, and C2 are in the range of
[0;255]. Take care that your RGB values are not constrainted to positive
values. So, some colors can be outside the Rec 709 display phosphor
limit, it means some colors can be outside the trangle I defined in
item 5.3. This can be explained because Kodak want to preserve some
accurate infos, such as specular highlight information.
You can note that the relations to transform YC1C2 to RGB is not exactly
the reverse to transform RGB to YC1C2. This can be explained (from Kodak
point of view) because the output displays are limited in the range of
their capabilities.
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 talked 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:
address@hidden (David Bourgin)
Special thanks to the following persons (there are actually many other
people to cite) for contributing to valid these data:
- Adrian Ford (address@hidden)
- Tom Lane (address@hidden)
- Alan Roberts and Richard Salmon (address@hidden,
address@hidden)
- Grant Sayer (address@hidden)
- Steve Westland (address@hidden)
Note: We are installing some new devices in our net and it could be
disturbed for some time. Furthermore, I think there's a lot of chances
I'm going for my national service on next month, it means from 4/10/94.
(Yes I'm young. :-).) It will take 10 months but I'll try to read and
answer to my e-mails. Thanks to not be in a hurry ;-).
###########################################################
- 3d highlights on dark colors, Miles Bader, 2000/11/06
- Re: 3d highlights on dark colors, Eli Zaretskii, 2000/11/06
- Re: 3d highlights on dark colors, Miles Bader, 2000/11/06
- Re: 3d highlights on dark colors, Miles Bader, 2000/11/07
- Re: 3d highlights on dark colors, Miles Bader, 2000/11/07
- Re: 3d highlights on dark colors, Gerd Moellmann, 2000/11/08
- Re: 3d highlights on dark colors, Miles Bader, 2000/11/08
- Re: 3d highlights on dark colors,
Gerd Moellmann <=
- Re: 3d highlights on dark colors, Miles Bader, 2000/11/10
- Re: 3d highlights on dark colors, Gerd Moellmann, 2000/11/13