Kerr 2005 - Color and Color Spaces
Kerr 2005 - Color and Color Spaces
ABSTRACT
TABLE OF CONTENTS
BACKGROUND .................................................................................... 2
Color ............................................................................................... 2
“Color model” and “color space” ......................................................... 3
Luminance and related metrics ............................................................ 3
COLOR SPACE FAMILIES ...................................................................... 3
Luminance-chromaticity color spaces ................................................... 3
The luminance-hue-saturation space ................................................. 3
The CIE xyY color space and the CIE chromaticity diagram.................. 4
Tristimulus spaces............................................................................. 5
Luminance-chrominance spaces .......................................................... 5
Chromaticity vs. chrominance ............................................................. 6
GAMMA.............................................................................................. 7
COLOR SPACES FOR COMPUTER GRAPHICS.......................................... 8
The RGB space ................................................................................. 8
The HSV (HSB) space ...................................................................... 10
The HSL space................................................................................ 12
COLOR SPACES FOR TELEVISION IMAGES........................................... 12
Introduction .................................................................................... 12
The YUV color space ....................................................................... 13
The YIQ color space ........................................................................ 14
The YPbPr space ............................................................................. 15
The YCbCr space ............................................................................ 16
COLOR SPACES RELATED TO COLOR PRINTING ................................... 17
Three-color printing ......................................................................... 18
Copyright 2001-2005 Douglas A. Kerr. May be reproduced and/or distributed but only intact, including this
notice. Brief citations may be reproduced with credit.
Color Spaces Page 2
BACKGROUND
Color
Color is the principal property of visible light by which a human observer can
distinguish different “kinds” of light. It is a subjective property, and in
general the color of a light source cannot be determined by simple
measurement of fundamental physical properties of the light.
1
For example: rectangular (Cartesian) coordinates, cylindrical coordinates, spherical
coordinates, geodesic coordinates.
Color Spaces Page 3
There are other potency metrics that are closely parallel to luminance. If we
are interested in the totality of light emitted by some emitter, the potency
metric is luminous flux. If we are interested in the light emitted in a particular
direction from a “point source” (such as a distant star), the potency metric is
luminous intensity. If we are interested in the light falling on a surface, the
potency metric is illuminance. These metrics have different dimensionalities
and are quantified with different units.
Luminous flux is rather akin to electrical power, and the other metrics follow
this similarity. Accordingly, if we combine the output of two sources which
exhibit certain luminances, the total emission has a luminance that is the
sum of those two luminances.
Hue is the property that distinguishes red from orange from blue from
blue-green, and so forth.
The properties hue and saturation are said to jointly describe the chromaticity
of the color of interest. Chromaticity is in fact the property that the average
person thinks of as the “color” of light (not realizing that luminance is one
aspect). Since chromaticity actually embraces two of our “color
coordinates”, it is a two-dimensional property (in the mathematical sense.
There are various scales by which hue and saturation may be quantified
(given numerical values). An important scheme depends on a graphic
presentation of chromaticity called the CIE chromaticity diagram. It is
actually part of a different color space within the luminance-chromaticity
family.
The CIE xyY color space and the CIE chromaticity diagram
Another important luminance-chrominance color space which is very useful
in technical work is known as the CIE xyY color space (CIE are the initials of
the French name of the International Commission on Illumination). It plots
any chromaticity as a point on a graph (the CIE chromaticity diagram3) whose
two axes correspond to two arbitrary variables called x and y.4 These are
defined so that the “mapping” of different chromaticities to points on this
graph results in certain desirable properties. This description of chromaticity
2
Rigorously, as we mentioned just previously, luminance only relates to the strength of light
emerging from an area of finite size, such as a spot on a scene being photographed. Other
metrics apply to other situations. We need not be concerned here with the distinction. So far
as the description of color is concerned, the concept is the same in each case.
3
Actually, the “1931 CIE chromaticity diagram”; two later chromaticity diagrams have been
adopted by the CIE, one in 1960 (with variables u and v) and one in 1976 (with variables u’
and v’, generally called today just u and v). The 1931 version is still the one most widely
used for general discussions of chromaticity, and when we speak in this paper of the “CIE
chromaticity diagram” without specifying the version, it is the 1931 version which is meant.
4
See Appendix B for a description of the concepts of this coordinate system.
Color Spaces Page 5
This space, and the CIE chromaticity diagram itself, are discussed in detail in
Appendixes A and B.
Tristimulus spaces
Tristimulus spaces describe the color on interest in terms of the amounts of
light of three specified primary chromaticities that may be combined to
produce that color. One important example of this class, the “RGB” space, is
based on the use of the primaries which are the red, green, and blue
emissions from a color cathode ray tube display system. Thus, color
descriptions in this space can be readily used to drive such a display. The
RGB space also relates well to the capture of color images by the typical
television camera or digital still camera.
Luminance-chrominance spaces
There is another family of color spaces, of interest to the representation of
color in television signals and digital images, that describe color in terms of
luminance (as before) and a two-dimensional property called chrominance.
(One must be careful not to confuse chrominance and chromaticity—we’ll
emphasize the distinction in a little bit.)
The concept is this. Suppose we first generate white light6 whose luminance
is the luminance of the color of interest. Now imagine that we add to that
white light the amount and “flavor” of non-white light required to produce
the color of interest. This “colorant dose” (as we would say when mixing
paint) is described by the property chrominance. As we would expect,
5
Also discussed in Appendix B. In fact, the term ”tristimulus space”, while applicable to a
range of color spaces, is usually reserved for use in connection with this space.
6
“White” does not automatically describe a specific chromaticity, but only an arbitrary
conceptual range. Various chromaticities have been defined to be considered as white in
different situations. Most color spaces involve a certain definition of white. This matter is
discussed further in Appendix A.
Color Spaces Page 6
The reader may note an apparent paradox in this concept. If the white light
component alone has the luminance which is the luminance of the color of
interest, and we add further light (the “colorant” described by the
chrominance property), won’t the resulting light (the color of interest) have a
greater luminance, a luminance greater than we have already stated for that
very color?
The secret is that the “colorant” has zero luminance! Then how can it have
any effect on the composite light? How can it even exist?
Since the colorant component must have zero luminance, its own RGB
description will involve negative values of the amount at least one of the
RGB primaries (again, not physically possible, but fine for a mathematical
fiction). However, for any color that can be represented by the RGB space,
when this description is added to the RGB description of the white light
component, R, G, and B will all have positive values.
7
Different “luminance-chrominance” color spaces use different pairs of coordinates for the
purpose. We will see the details of several of these when we later discuss specific color
spaces.
Color Spaces Page 7
Now let us again consider our example of the color of a spot on an object
illuminated by two floodlights. This time we describe the color in a
luminance-chrominance space. When we turn off one floodlight, the
luminance of the light is reduced. The magnitude (“potency”) of the
chrominance also drops correspondingly.
If we instead need to mix only a quart of paint, to produce the same color
we must cut down the size of the colorant dose proportionately. Thus, to
mix up a “batch of light” of a reduced luminance, we must decrease both the
amount of the “base white” (the luminance) and the amount of “colorant”
(the chrominance).
GAMMA
Before we can discuss specific color spaces used for the encoding of color
for computer graphics and television images, we must discuss the concept of
gamma.
In a cathode-ray tube (CRT) visual display, the luminance of the spot on the
screen generated by the electron beam from a beam gun is typically not
proportional to the control voltage to the gun, but rather to some power of
the voltage (often about 2.2).9 This exponent is often designated gamma by
parallel with the related concept for film.
8
Density for a point in a photographic negative is numerically defined as the common
logarithm of the ratio of the intensity of the light falling on the point to the intensity of the
light passing through the point. Thus, a point having a density of 2.0 allows only 1/100 of
the light intensity to pass through.
9
This should not really be a surprise; luminance has a dimensionality akin to electrical
power, and power varies as the square (second power) of voltage or current. Thus from this
alone we might well expect an exponent of 2.
Color Spaces Page 8
Actually, the human eye does not respond linearly to luminance. The
response, as with many other areas of human perception (such as sound
loudness), is more nearly logarithmic. The gamma-precompensated luminance
signal involved in TV transmission is in fact a crude but still useful
approximation to a logarithmic representation: the human eye responds
nearly linearly to gamma-precompensated luminance. This affords many
advantages in image manipulation.
In any case, as well will see shortly, in most color spaces of the RGB family
(to be discussed next), the variables indicating the amounts of the three
primaries needed to “make up” the color of interest are expressed as a
nonlinear transform of the original values. The nonlinear function used is
often a power function similar to (in fact, often identical to) that used for
gamma precompensation in television systems (often with the same
exponent, or “gamma”), and in fact its initial purpose was identical. Thus,
even in RGB-family color spaces other than those use in television, the
nonlinear transformation is often referred to as “gamma precompensation”.
Figure 1 shows the chromaticity of the three primaries in a typical RGB color
space on the CIE chromaticity diagram. (See Appendix A for a discussion of
this diagram.)
In formal mathematical work, the symbols R, G, and B are used for the
“linear” (non-gamma-precompensated) form of the variables, and R’, G’, and
B’ for the gamma-precompensated form. However, in connection with the
RGB color space in practical use, the symbols R, G, and B always refer to the
gamma-precompensated form of the variables. Thus, to avoid confusion, in
mathematical work in this paper, we will use the symbols r, g, and b for the
non-gamma-precompensated variables, and R, G, and B for the
gamma-precompensated ones.10
Using a form of that notation, the nonlinear transformation used in many (but
not all) the standardized RGB color spaces takes on this form:
10
Note also that, while in equations we will follow the usual mathematical convention of
showing the symbols for variables in italics, we do not do so in the text proper, since in
many cases those variables identify the “coordinates” of a color where, by convention, they
are not shown in italics.
Color Spaces Page 10
C = c1/ γ
This space followed directly from the color display mechanism of most
computers, which used a tricolor cathode-ray tube with guns controlling the
emission of light of three primary chromaticities, “red”, “green”, and “blue”
(just as was used for classical color television).
The luminance of the color rendered does not follow an absolute scale, but
rather depends on the display mechanism and the setting of its “brightness”
control.
But this can be misleading. Not all those chromaticities can be achieved for
every luminance that can be represented by the RGB model.
For example, we can only have the a color with the chromaticity of the G
primary itself by using “G” light alone; that is, the values R and B must be
zero. With a “100%” dose of G (that is, for R,G,B=0,1,0), we will have a
certain luminance—less than that we would have if R, G, and B were all 1,
the maximum luminance of the color gamut of the RGB space.
color.11 Thus, at the human interface, another space came into play, with its
coordinates being hue, saturation, and value (a synonym for luminance): H,
S, and V. It is sometimes called the HSB space (for hue, saturation, and
brightness).
How is hue described in this system? In “theoretical” work, hue (for spectral
hues) is often described in terms of the wavelength of the spectral
(monochromatic) color having that hue. For the non-spectral purple colors,
the hue is usually described as a fractional distance along the locus of non-
spectral purples on the CIE chromaticity diagram.
Of course this means of describing hue would not be practical for a working
artist (or even for a computer user setting the color of his Windows
desktop!). Instead, in the HSV color space, hue is described in terms of a
“color wheel”, reminiscent of those we used in elementary school art
classes.
The hues of the three primaries of the assumed display system are arbitrarily
placed at equidistant azimuths around this circle, at 0° (red), 120° (green),
and 240° (blue). Well-known names of three intermediate hues, yellow,
cyan, and magenta, are placed at intermediate azimuths. The “non-spectral
purples” fall in the azimuth range between magenta and red.
Then, in the HSV representation of a color, the hue parameter (H) would be
given as the azimuth (in degrees) of the corresponding hue on the wheel,
with 0° representing the hue of the red primary.
Here we have the same dilemma as with the RGB space: we cannot achieve
as much saturation for higher brightness as we can for lower brightness.
11
We should perhaps note here that none of the spaces we will discuss here are really
satisfying for the sophisticated graphic artist, who will likely wish to choose colors under
systems developed years ago for use with pigments, such as the Munsell or Pantone
systems. Most serious graphic art software packages afford the opportunity to choose
colors based on one or more of these systems. The colors chosen are then usually converted
by the software to an RGB representation for storage.
12
Again, brightness is not defined on an absolute scale, but rather on a relative scale, the
absolute value depending on the display mechanism and the setting of its brightness control.
Color Spaces Page 12
The details of the HSB space definition—in fact, of any of the several
different definitions encountered in practice—are beyond the scope of this
article.
The third parameter is again called saturation, and again has the symbol S,
but is also defined in a rather peculiar way. Its value runs from 0-100%. It
indicates not the actual saturation of the color of interest but rather the
fraction that saturation is of the maximum saturation available at the
particular lightness called for (considering the brightness-saturation conflict
mentioned above).
In particular, to get the highest available saturation for red for an L of 80%,
we would need to use R=100%, G=60%, and B=60%. The actual
saturation we would get would be about 25%. Nevertheless, under the HSB
system, that saturation would be called 100%, since it is the greatest
attainable at that lightness for the stated hue.
The details of the HSL space definition—in fact, of any of its several
different definitions encountered in practice—are beyond the scope of this
article.
In each case, we assume that the original image representation, from the
camera or equivalent, is in RGB form, with the values R, G, and B
precompensated for the assumed gamma of the ultimate display device.
R=r0.45 (0.45=1/2.2)
G=g0.45
B=b0.45
Y=0.299R+0.587G+0.114B
The object is to approach the situation in which we would have the same
value of Y for colors of different chromaticities which nevertheless appear to
the human viewer to be “equally bright”.14 However, this is only
approximately achieved, since Y is derived from a linear combination of
gamma-precompensated RGB values, whereas true luminance is best
reckoned as a linear combination of the non-gamma-precompensated (linear)
rgb values. Y is thus not a true indication of luminance (not even a gamma-
precompensated one). As we will see later, this value is often given the
name luma.
U=0.492(B-Y)
13
The YUV color space should not be confused with the CIE L*uv color space, a different
creature altogether.
14
A “black-and-white” TV receiver operates only from the signal carrying Y.
Color Spaces Page 14
V=0.877(R-Y)
In PAL and modern NTSC television transmission, the portion of the overall
signal which conveys U and V is called the chrominance (or often chroma)
signal, sometimes designated C. The portion which conveys Y is called the
luminance (or luma) signal, designated Y. In addition to being shorter, the
terms chroma and luma by convention remind us that these are
gamma-precompensated values (and in the case of luma, reminds us that it
really isn’t a luminance value at all—not even a gamma-precompensated
one). These two short terms are borrowed for use in connection with other
color spaces of a similar nature.
Note that this color space should not be confused with the CIE uv
chromaticity diagram (part of the uvY color space) color space nor the CIE
L*uv color space. In fact, the chrominance axes of the YUV space do not
even approximately match the chromaticity axes of the uv chromaticity
diagram nor the chrominance axes of the L*uv space. If anything, they are
almost interchanged (u vs. v).
Consider the chrominance plane defined by U and V (that is, by Y’-B’ and
R’-B’ with the appropriate scaling). We define a new set of coordinate axes,
Q and I16, with the same origin but lying at an angle of 33° counterclockwise
from the U and V axes, respectively. The Q and I values then describe the
chrominance of the color. In television transmission, the portion of the
overall signal which conveys Q and I is called the chrominance (or often
chroma) signal, sometimes designated C. The portion which conveys Y is
called the luminance (or luma) signal, designated Y. As in the case of the
YUV space, the terms chroma and luma by convention remind us that these
15
Recall that chrominance differs from chromaticity in that if a color of a given chromaticity
is increased in its luminance, the “magnitude” of its chrominance also increases.
16
The designations Q and I are mnemonic for quadrature and in-phase, an allusion to the
way in which these are transmitted in television transmission by quadrature amplitude
modulation of a “chrominance subcarrier”. They are generally mentioned in the opposite
order: “I and Q”; the order “Q and I” we used here is intended to reflect the parallelism with
U and V, respectively.
Color Spaces Page 15
Why the new set of axes? The eye’s chrominance acuity—its ability to
discern fine detail carried by chrominance change—is highest for
chrominance changes along a certain direction of the chrominance plane17,
and substantially lower for the direction at right angles to that. The Q axis is
aligned with the “lowest acuity” direction. This allows, in television
transmission, allocation of substantially less bandwidth to the Q component
(transmitting it with reduced “resolution”), reducing the overall bandwidth
required for the transmission of the image chrominance.
Y=0.299R+0.587G+0.114B
I=0.736(R-Y)-0.268(B-Y)
Q=0.478(R-Y)+0.413(B-Y)
(The more complex expressions for I and Q, compared to those for U and V
in the YUV space, are a result of the rotated axes of the YIQ space.)
The YPbPr space is conceptually identical to the YUV space, with Pb derived
from the blue color difference value, B-Y (like U), and Pr derived from the red
17
As seen on the CIE chromaticity diagram.
Color Spaces Page 16
color difference value, R-Y (like V). The coefficients of Pb and Pr, however,
are chosen so that both have the same range over the full gamut of colors
that can be represented by the space.
The ranges of the variables, in abstract terms, are: for Y, 0-1 “unit” (by
definition); for Pb and Pr, ±0.5 “unit”. The actual electrical signal at an
interface is ordinarily scaled such that the range for Y is 0-0.7 V and for Pb
and Pb, ±0.35 V (that is, one “unit” is 0.7 V).
Again, as in the case of the YUV and YIQ spaces, note that Y isn’t rigorously
an indicator of luminance (not even gamma-precompensated luminance).
Note that Y does not represent the luminance of the color; luminance is
reckoned as a weighted sum of the non-gamma-precompensated R, G, and B
values. Y is not even gamma-precompensated luminance. Y here is
sometimes spoken of as “pseudo-luminance”. It is also often called luma, a
term drawn from television signal practice.
Cb = 0.564(B − Y )
Cr = 0.713(R − Y )
The coefficients in those expressions ensure that (if R, G, and B are within
the range of 0-1) Cb and Cr will lie in the range -0.5 to +0.5.
(We can see that the YCbCr space is essentially a rescaled form of the YUV
space.)
Color Spaces Page 17
Cb and Cr collectively are said to express the chrominance of the color; this
is often called chroma (again, a term drawn from television practice).
However, in the forms of this color space used in such applications as the
JPEG representation of photographic images, Y, Cb, and Cr are all scaled so
that they occupy the range 0-25519. For Cb and Cr the center point in this
case (representing a “zero” value) is again 128.
We will encounter the YCbCr color space again (in its “sYCC” form) in the
section on Color Spaces for Photographic Images.
18
Called “headroom” and “footroom”.
19
At one time the coefficients of the conversion to 8-bit form were such that for the
maximum should be 256, but of course that is not possible with an 8-bit representation.
This little “oops” has been gently squeezed out of the current version of the controlling
specification, and the coefficients are now scaled to suit a range of 255 units.
Color Spaces Page 18
This is a very complex field, involving sophisticated science, art, and craft.
We will here take a very simplified view of the area.
Three-color printing
In the basic technique of “three-color” printing, three different inks are used
to print an image. They are said to be of three different “colors”. Rigorously,
however, an ink does not have a color. Rather, it has a reflectance spectrum,
a curve of the fraction of the light falling on the ink that is reflected as a
function of the wavelength of the light. If we take the spectrum of the
incident light and multiply it by the reflectance spectrum of the ink, we will
get the spectrum of the reflected light. That light, to a human observer, will
exhibit a particular color—it will have a certain brightness (luminance) and a
certain chromaticity.
To the user, that color is thought of as “the color of the ink”. However, if we
change the spectrum of the incident light, the spectrum of the reflected light
will also change, and thus its apparent color. Thus, to have a sample of a
certain ink exhibit a consistent color, it must be viewed under light of a
consistent spectrum.
Note that that this is not as simple as just calling for a consistent color of
incident light. We can have incident light of two different spectra which
nevertheless exhibit the same color to an observer. But the light reflected by
a certain ink illuminated by those two kinds of light may not exhibit the same
color to an observer.20
All that having been said, from here on we will nevertheless, for
conciseness, refer to the “color” of ink and to the “color” achieved by the
use of the ink on paper.
Traditionally, the “three-color” printing process has used three kinds of ink
whose reflectance spectra have been fairly well standardized. We describe
these qualitatively, in terms of the hue which they exhibit when illuminated
by light of some fairly-standard spectrum (such as “sunlight”), as cyan,
magenta, and yellow. Formerly (and to some extent yet today), they were
described as “process blue”, “process red”, and “process yellow”, the word
“process” of course being an allusion to the “three-color printing process”.
20
This is of course a large problem in the design of not only printing inks but also of paints
for products. The manufacturer would like for a refrigerator in “sea blue” to look the same
whether it is illuminated by incandescent or fluorescent light. The problem is complicated by
the fact that the human perception of chrominance is actually relative, and the person
viewing the refrigerator is also seeing surrounding objects whose apparent chrominances
also depend on the type of illumination.
Color Spaces Page 19
In an ink printing process, each ink acts as a filter, reflecting the various
wavelengths of the incident light in accordance with the ink’s reflectance
spectrum. Conversely, we can think of the ink as absorbing various
wavelengths of the incident light in inverse accordance with the ink’s
reflectance spectrum.
When two or three kinds of ink are applied, it is as though we have filters in
cascade: each ink absorbs the various wavelengths of the incident light as
appropriate. A certain wavelength may have a certain fraction of its energy
absorbed by the blue ink at a certain spot, and then another fraction of its
energy is absorbed by the yellow ink at that spot.
For that reason, the ink “primaries” (such as cyan, magenta, and yellow) are
often said to be subtractive primaries, in contrast to the emissive primaries
(such as red, green, and blue), said in this context to be additive primaries.
Color spaces related to the ink printing process are often distinguished as
“reflective spaces”.
There are some resulting subtleties in the way the absorption of the different
inks interact. Thus the phenomenon of the production of a “color” of the
printed image is not as simple as we make it appear in this article. Our intent
here is merely to give an understanding of the context in which print-related
color spaces operate.
21
We do not use “density” in this section to mean the logarithmic density used in
photographic technology, nor to any specific quantitative definition.
Color Spaces Page 20
C=1-R
M=1-G
Y=1-B
The CMY space is also relevant to color photography, where the image on a
color print or positive transparency is produced by three dyes operating in a
“subtractive” mechanism.
Four-color printing
The three-color printing process suffers from a number of practical
shortcomings. For one, even if the greatest practical “density” of all three
inks is applied to an area, not all the incident light is absorbed, and the area
will not appear black to the observer (but rather a muddy brown). Other low-
reflectance colors are similarly unsatisfactory. In addition, the use of three
“dense” layers of ink can make the printed paper wetter than is desirable.
22
The two terms refer to slightly different aspects of the process as practiced.
Color Spaces Page 21
undercolor removal should be done for each area of the image. Thus, a
sophisticated artist or photo editor, familiar with the practical subtleties of
the four-color printing process, can “tune” the undercolor removal process
for best final printed result.
Most graphic arts and photo editing software packages allow the operator to
adjust the parameters of the default algorithm for the automatic application
of undercolor removal. One parameter of the algorithm in effect tells the
system how aggressive to be in “factoring out” the common absorption of
the three additive primaries for any given color, the range being from “don’t
do it” to “take it all out”. In many cases, the algorithm varies for different
ranges of overall “brightness”.
The CIE thus subsequently defined other color spaces in which distance on
the chromaticity plane more nearly corresponds to perceived chromaticity
difference. A number of these figure in the description of color in modern
image coding systems.
In the color space we are about to review, the CIE L*a*b* space, there is no
concern with display device characteristics—the space is totally “device
independent”. However, correspondence with the nonlinear response of the
eye (not accommodated by earlier CIE spaces) is an objective, and thus again
the color parameters of this space are expressed in nonlinear form. The
exponent is optimized for correspondence with human response, a value of
1/3 being specified. Although not apt, some workers speak of inverse of this
value (3.0) as the “gamma” of the L*a*b* space.
It also introduced some concepts that had emerged from ongoing research
into human perception of color. It recognized that human response to
luminance was not linear with the “power-like” definition of luminance which
was the basis for earlier CIE spaces (as we discussed in the previous topic).
Although this new color space was intended to deal with reflective “color”, it
was soon adapted for use in describing “luminous” (light) colors as well. It
has come into widespread use in various graphics software packages and for
other “color management” purposes. It is a member of the “luminance-
chrominance” family. The traditional designation of the space is “L*a*b*,
23
This had been mentioned previously in connection with the Y-I-Q color space.
Color Spaces Page 23
where the asterisks remind us of the nonlinear nature of its three variables.
We will omit the asterisks from here on.
Yn=Y/Y0
where Y the traditional CIE luminance value of the light reflected by the
surface of interest and Y0 is the CIE luminance of the Illumination. (Note
that, curiously enough, the same value Y is both the luminance and the value
of one of the three CIE tristimulus values, Z, Y, and Z! 24) The exponent 1/3
provides the nonlinearity mentioned above.
* but only the range from -128 through +127 is usually used
where Xn, Yn, and Zn are the reflective CIE tristimulus values, defined as:
Xn=X/X0
Yn=Y/Y0 (yes, this is the same as the reflectance!)
Zn=Z/Z0
where X, Y, and Z are the CIE tristimulus values (amounts of the “fictional
primaries” X, Y, and Z) for the light reflected by the surface and X0, Y0, and
Z0 are the tristimulus values for the illumination.25 A positive value of a
represents the red direction on the red-green axis, while a positive value of b
represents the yellow direction on the yellow-blue axis.
24
How this comes about is described in Appendix B.
25
When used for luminous rather than reflective color, X0, Y0, and Z0 the tristimulus values
of the illuminance, are replaced by Xr, Yr, and Zr, the tristimulus values of the reference
white for the system.
Color Spaces Page 24
0-65280 (256 X 255) in a 16-bit context. But usually for a and b, only the
range -128 through +127 units is actually retained (mapped onto 0-255 in
an 8-bit context, 0-65280 in a 16-bit context 26).
For all the above expressions, if any of the ratios X/X0, Y/Y0, and Z/Z0 is less
than or equal to 0.008856, then that ratio is replaced by:
903.3F + 16
116
The purpose of the linear piece of the nonlinear function is that with the
traditional function (stated just above), when the inverse function is used (to
convert from Lab to XYZ) the slope of the function becomes infinite at the
origin, thus leading to implementation difficulties. The linear piece avoids this
complication.
When this space is applied to light as such (not to the “reflective color” of a
surface), the parameters X0, Y0, and Z0 become the description of the
“reference white” to be used.
With regard to the designation “CIELAB” for this space, many people
mistakenly believe that “LAB” is short for the word “laboratory”, and we
often read fanciful “translations” of this space’s designation based on that
fallacy.28
26
With the “CIELAB” encoding, this is done on a “signed integer” (twos-complement) basis,
where (in an 8-bit context) 0 means 0, 1 means 1, and 255 means “-1”; with the “ICCLAB”
encoding, this is done on an “offset” basis, where 128 means 0, 127 means -1, and 129
means +1.
27
The constants 903.3 and 0.008856 are given here in decimal form, as has been the case
so far in the formal CIE standard. However, decimal values of these constants, no matter to
how many significant figures they are expressed, produce a discontinuity in the function at
the “joint” between the two parts of the curve, leading to some problems in execution. As a
result of a campaign by noted color space maven Bruce Lindbloom, the latest version of the
CIE standard will express these constants as the ratios of integers, which produces a precise
“joint”.
28
But adding to the confusion is the color space, very similar to CIELAB, established by
Hunter Associates Laboratory, Inc., and called the “Hunter Lab color scale”.
Color Spaces Page 25
In the equations that follow, we will also use the symbols U and V (rather
than u and v) for the chrominance variables to avoid confusion with the
variables u and v of the CIE 1960 chromaticity diagram and the variables u’
and v’ of the CIE 1976 chromaticity diagram, upon the latter of which in fact
the definition of U and V are defined (as we will see shortly).29
Y
yr =
Yr
4X
u' =
X + 15Y + 3Z
9Y
v' =
X + 15Y + 3Z
4Xr
u'r =
X r + 15Yr + 3Z r
29
But note that this U and V are not the U and V of the YUV color space1
Color Spaces Page 26
9Yr
v'r =
X r + 15Yr + 3Z r
where X, Y, and Z are the CIE tristimulus values of the color of interest and
Xr, Yr, and Zr are the tristimulus values of the reference white for the system.
Note that the chrominance axes of this space essentially correspond in their
orientation to the chromaticity axes of the CIE uvY color space.
Note that H in this space essentially defines a position on a “hue wheel”, but
it is quite different from the hue wheel of the HSB and HSL spaces.
As we said at the outset, just as in the case of the Lab space, this is a
luminance-chrominance (not luminance-chromaticity) space. The coordinates
H and C collectively describe the chrominance. If we begin with some color
and “attenuate” it (such that its chromaticity does not change). L and C both
decrease. (H, being essentially an angle, does not change.)
There is a variant, called the LCH(uv) space in which the reference axis for
definition of the hue angle, H, is the positive u axis of the u-v plane of the
Luv space.
30
Remember than in “luminance-chrominance” spaces, for a given chromaticity (hue and
saturation), the chrominance variables scale with luminance.
31
This quantity is called ”chroma”, thus the choice of the symbol. However, in some
contexts the whole vector on this plane (described by both H and C) is called “chroma”,
consistent with the terminology used in color spaces applicable to television signals. Under
that viewpoint, C is the magnitude of the chroma.
Color Spaces Page 27
An advantage of the sRGB color space its that its gamut is a good match to
the gamut of a typical computer CRT display.
There are disadvantages of the use of the sRGB color space as this
“standard of interchange”. One is that its gamut (the range of colors that it
can directly represent) is relatively limited compared to the gamut that can
actually be achieved on many modern output devices (such as certain types
of printer.32 Accordingly, in some situations, various alternative color spaces
are utilized in representing a digital camera image or the like. We will look
into that presently.
The gamma precompensation curve used in the sRGB color space is defined
by the following expressions. Here, c represents any of the “linear” variables,
r, g, or b, while C represents the corresponding gamma-precompensated
variable, R, G or B.
C = 12.92c for 0<c≤0.0031308
C = 1.055c1/ 2.4 + 0.055 for 0.0031308<c
32
The gamut of the sRGB color space is essentially that of the type of display device
contemplated by the original RGB space.
Color Spaces Page 28
C = c1/ 2.2
which as we said earlier is the typical curve used for generalized RGB
spaces.
• Its green primary is different from the green primary in the sRGB color
space. being located farther from the white point. This provides a larger
chromaticity gamut.
The JPEG coding system actually operates upon image data in YCbCr form,
and in the form of JPEG prescribed for use in the Exif format, that YCbCr
form is specified to be based on an underlying sRGB color space.
The resulting color space is often described as the “sYCC” color space (YCC
being a shorthand for YCbCr), but that designation has an implication beyond
the use of the YCbCr representation.
Y: 0 to1
Cb, Cr: -0.5 to +0.5
This is a larger code space than is required to accommodate the possible
range of RGB values that are legitimate under the basic definition of the
sRGB space (in which R, G, and B can only take on values in the range 0-1).
Said another way, the YCbCr color space supports a gamut considerably
larger than that supported by the basic sRGB space. In fact, for parts of the
luminance range, the gamut implied by the YCbCr code space embraces
chromaticities outside the CIE chromaticity diagram, that is, “impossible” (or
“invisible”) chromaticities.
The sYCC colors lying outside the sRGB gamut have RGB representations in
which at least one of the variables R, G, and B have values lying lie outside
the range normal range of 0 to 1—values greater than 1, or negative values.
Negative values, in particular, are at first hard to visualize. Nevertheless,
such values can readily be treated mathematically.
Thus, if we fully utilize the sYCC color space (allowing the variables to take
on any values in their prescribed range) we can represent with valid YCbCr
coordinates some realizable colors lying outside the sRGB gamut, while still
operating within the basic sRGB encoding concept.
Only a small change in the sRGB color space definition is required for it to
participate as the underlying layer in the sYCC color space: the gamma
precompensation curve must be extended to accommodate negative values
of R, G, and B. This is done in the obvious way, with the added third
quadrant of the curve being symmetrical with the original first quadrant. This
symmetrical curve is defined by the following expressions:
In that case, the application must “map” such out-of-gamut colors to valid
sRGB colors. This can be done in several ways. One is to just force them
barely inside the sRGB chromaticity gamut, leaving the “in-gamut” colors
alone. However, this approach can result in a range of different colors in the
sYCC image ending up with the same sRGB color, leading to unpleasant
results in the affected areas of the final image—“flattening” of the colors
Color Spaces Page 30
(much as we see in the “clipping” of colors falling outside the dynamic range
of the camera).
The details of these processes and of their implications on image results are
beyond the scope of this article.
Before these values are placed in digital form, they are divided by 2 and then
0.375 is added, bringing their range to 0 to 1.
Following the usual equations defining Cb and Cr, those variables can also
attain the range -0.75 to +1.25 (a range of 2.0 “units” altogether). As with
the variables R, G, and B in the e-sRGB color space, these variables are
divided by two and 0.375 is added (making their range 0-1) before they are
converted to digital form (again, in either 10, 12, or 16 bits).
Again following the usual equation, Y it can also take on the range -0.75 to
+1.25. Here, however, that is fit into a final range of 0-1 before conversion
to digital form by merely clipping values below 0 and above 1 (forcing them
to 0 and 1, respectively).
Essentially these same two color spaces are also defined by IEC 61966-2-1,
Annex G, where they are spoken of as “bg-sRGB” and “bg-sYCC”.33
In any event, the PCS color space is ordinarily never used for an “external”
description of an image—only as the intermediate language between two
links of a transformation chain.
Of course, this is not necessarily done in two steps. The application may, in
effect, first “multiply” the two space transforms to get a “net transform”,
which it then uses to convert the color descriptions directly from the source
color space to the destination color space.
This is a highly complex field, with many ramifications, and its details are
beyond the scope of this article.
33
Perhaps “bg” is intended to be evocative of “big gamut”.
Color Spaces Page 32
APPENDIX A
The CIE xyY color space is derived from the CIE XYZ color space, a
tristimulus space. It is described in Appendix B.
The underlying principles behind the CIE XYZ and xyY spaces and the CIE
chromaticity diagram are described in Appendix B. Here, though, appendix
we will deal with the practical significance of the CIE chromaticity diagram.
Wavelength
Light is electromagnetic radiation, identical in physical nature to radio waves,
except that the frequency of light is immensely greater than the frequency of
even the highest-frequency radio waves in use today. When the science of
optics was first developed, there was no radio, no electrical engineering, and
no understanding of the wave nature of light. Even if there had been, there
were certainly no instruments for directly measuring the frequency of light
directly (there still aren’t). Thus, the frequency of a light source was
described in terms of the corresponding inverse property wavelength. Visible
light comprises light whose wavelengths range from approximately 400 to
700 nanometers. (A nanometer is a millionth of a millimeter.)
34
Actually, the “1931 CIE chromaticity diagram”; two later chromaticity diagrams have
been adopted by the CIE, one in 1960 (with variables u and v) and one in 1976 (with
variables u’ and v’). The 1931 version is still the one most widely used for general
discussions of chromaticity, and when we speak in this paper of the “CIE chromaticity
diagram” without specifying the version, it is the 1931 version which is meant.
35
See Appendix B for a description of the concepts of this coordinate system.
Color Spaces Page 33
The Spectrum
If we send a stream of sunlight through a triangular glass prism and direct
the emerging beam onto a screen, we see the familiar “rainbow” band of
continuously-changing hue. This is known as a light spectrum.
If we take an opaque plate with a very narrow slit and put it between the
prism and the screen, it will only pass the light of a particular part of the
spectrum. As the width of the slit approaches zero, we find that we
approach the situation in which the light passing through contains only one
frequency (wavelength), Such a light source is called monochromatic
(meaning “one color”, not really a technically-correct definition). These
chromaticities are called the spectral colors (again, not really technically
correct).
y
1.0
520
530
green
510 540 wavelength (nm)
550
locus of spectral
560
(monochromatic)
"colors"
570
500
cyan 580
yellow 590
600
blue 610
490
C 620
650
red 780
480
magenta
The curve is also labeled with the familiar names of various hues. However,
such a name (such as “red”) does not actually imply a specific wavelength
nor even a specific hue—it is a broad, qualitative designation.
We have not yet talked about the actual measures used to define hue and
saturation. For the moment, note that spectral (monochromatic)
chromaticities have the highest possible saturation (usually described as
100%); they are sometimes said to be the “pure colors” 36.
Chromaticities which lie along the straight line joining the open ends of the
locus of spectral chromaticities (they are various “purple” hues) do not
appear in the light spectrum, and accordingly are not monochromatic. They
are called the non-spectral purples, and are arbitrarily considered to have
100% saturation.
In the next part of our discussion, we will have to utilize the concept of
white light. In fact, the chromaticity we call “white” is not defined by a
unique set of physical or subjective properties; the choice of a chromaticity
to call white is arbitrary. Various chromaticities (defined in terms of their
position on the CIE diagram) have been standardized for different uses. One
often referenced is called “illuminant C”37. Its location is shown on the figure
(as “C”).
Any point in the interior of the region bounded by the locus of spectral
chromaticities and the locus of non-spectral purples represents a
chromaticity which is not 100% saturated.
In fact, the quantitative definition of any chromaticity, as seen on the CIE x-y
diagram, in terms of hue and saturation can be done this way.
36
Note that in many of phrases used in this field, the term “color” is used where
“chromaticity” is actually the property of interest. In this paper, we will be tediously
rigorous, and always use the term “chromaticity” where that is what is meant.
37
It is intended to correspond to a certain type of daylight. Another reference white, “D65”,
is also often utilized today. Its chromaticity is that of a “black body” radiator at a
temperature of about 6500 K.
Color Spaces Page 35
y
1.0
1.0
saturation line of constant hue
0
C
x
0 1.0
On the diagram, draw a line from point “C” through the point representing
the chromaticity of interest (P) and prolong it until it intersects the locus of
spectral chromaticities (or the locus of non-spectral purples). If it hits the
locus of spectral chromaticities, the hue is defined by the wavelength at the
point of intersection (said to be the dominant wavelength of the light). If the
line hits the locus of non-spectral purples, we have no tidy numerical way to
state the hue.
In either event, the saturation of a color is defined as the ratio of (a) the
distance from point “C” to the point representing the chromaticity of the
color to (b) the total distance from point “C” to the locus. Thus the point
halfway along a line from point “C” to the locus represents a chromaticity
with 50% saturation.38
Imagine that we have light that is made by combining two light streams,
each having a monochromatic (spectral) chromaticity and both of equal
luminance. The chromaticity which the observer will perceive can be located
on the CIE diagram merely by drawing a line between the points representing
the two spectral chromaticities and locating its midpoint. This is a useful
property of the CIE diagram39.
38
Note that this quantitative definition of saturation is dependent on the choice of a
particular chromaticity for “white”.
39
This property also obtains for the 1960 and 1976 CIE chromaticity diagrams.
Color Spaces Page 36
If the two components do not have equal luminances, we can still use this
technique. Suppose one spectral component has twice the luminance of the
other. Then we still draw the line between the two components’ points, but
we mark a point on the line which is one-third the distance from the
“stronger” point to the “weaker” one.
Does that mean that any point in the interior of the diagram represents a
chromaticity which can only be made by one combination of spectral
chromaticities (that is, by combining monochromatic light of only two
specific wavelengths)? No, as one can readily visualize, we could make a
particular “point” by many combinations of two or more spectral
components, or by many combinations of two or more non-spectral
chromaticities (ones inside the locus).
Thus the triangle R-G-B bounds the set of chromaticities that can be defined
in an orthodox manner by an RGB space based on that particular set of
primaries. This is said to be the “chromaticity gamut” of that particular
space. Any chromaticity lying outside that triangle would imply a negative
value of the quantity or one or more of the primaries. This is of course not
possible if we actually think of manufacturing the color with physical sources
of the three primaries.
#
Color Spaces Page 38
APPENDIX B
It turns out that, for any color which is so composed, the perceived
luminance of the color follows a certain weighted summation of the values r,
g, and b. The chromaticity of the color is determined by the ratios among r,
g, and b. (Note that only two values are needed to describe the ratios among
three values.) The set of these three values are the coordinates of one
particular three-dimensional “color space”.
Again, as we saw from out earlier study of the CIE diagram, with three
monochromatic primaries we cannot produce all possible visible
chromaticities, only those lying within the triangle formed by the primaries.
We could describe a chromaticity which lies outside that triangle by utilizing
negative values of at least one of the variables r, g, or b. That concept,
however, is intellectually untidy (but is in fact embraced by certain
“expanded gamut” color spaces in the RGB family).
To avoid this difficulty, the CIE decided to define a linear transform of the set
of three variables r, g, and b into another set of three arbitrary variables, X,
Y, and Z, such that for any visible chromaticity none of the variables would
need to have negative values.
Color Spaces Page 39
Now the CIE chromaticity diagram is not intended to show all three variables
(it would have to be a three-dimensional “solid” diagram to do that), but to
show chromaticity only (in two dimensions). Its two coordinates are derived
from X, Y, and Z this way:
X
x=
X +Y + Z
Y
y =
X +Y + Z
Note that in any color space, if we start with a particular color, with certain
values of three primaries, and increase its luminance (without changing its
chromaticity), the proportions of its three primary components remain
unchanged. Thus, in the CIE system, for an unchanging chromaticity, X and
Y increase by the same ratio that (X+Y+Z) does, and so x and y remain
unchanged. Therefore, the point x,y in fact represents the chromaticity of a
color.
Keeping in mind that the variable Y indicates the luminance of the color of
interest, the entire 1931 color space is often designated the “xyY” (or
sometimes “Yxy”) space.
40
For this reason, in fact, “Y” is the symbol for luminance in most color spaces (also the
symbol for luma, a property that is something like luminance).
41
Most written descriptions fail to alert the reader to the fact that “Y” is both the name of a
(fictional) primary chromaticity and the name of a variable (the amount of light of that
chromaticity), two different concepts.
Color Spaces Page 40
y
1.0 Y
Z X
x
0 1.0
We can see that the gamut triangle of X-Y-Z embraces the entire visible
chromaticity gamut, which as we recall was an objective of the choice of
those three primaries.