From: dave@imax.imax.com (Dave Martindale)
Subject: Re: why ".299 r + .587 g + .114 b" ??
Keywords: red green blue grayscale color
Organization: Imax Corporation, Mississauga Canada
Date: Thu, 15 Oct 1992 01:51:39 GMT

hpchen@blackberry.Eng.Sun.COM (Huei-Ping Chen) writes:
>
>I have just downloaded pbmplus tools, and am trying to understand it
> and use it.
>
>there is a function ppmtopgm which converts color pictures to grayscale,
>the man page says the quantization formula used is ".299 r + .587 g + .114 b".
>
>my question is why this formular, is there any color theory behind it ??
>can someone recommend me a paper or book that I can read to understand it.

Those particular "magic numbers" are the way the luminance (Y) signal
is derived from R, G, and B in the NTSC colour system.  And, yes, there
is some logic behind it.

The basic idea is that, to represent colours as amount of red, green,
and blue light, you have to figure out *which* red, green, and blue
colours you mean.  The NTSC committee picked particular red, green, and
blue colours that happened to be the colours of CRT phosphors available
at the time.  The colour of each phosphor can be described uniquely by
its coordinates in the CIE (x,y,z) colour space.

Then, you have to pick a white point.  There is a wide range of colours
that you can see as "white" under the right circumstances, and you have
to pick a particular standard white when defining a television colour
system.  NTSC chose a white called "Illuminant C".

Now, given that you have three colours and a white point, you can ask
"how much of each colour must one mix together to get this particular
white"?  Solving this is a matter of solving three linear equations in
three unknowns - an easy task.

It happens that the "y" component of the CIE (x,y,z) colour space is
the apparent brightness of the colour.  This isn't an accident - it's
the way the colour space was designed.  So, once we've solved the
equations above, we know how much of the "y" component of the reference
white is contributed by the "y" component of red alone, of green alone,
and of blue alone.  And that's where the magic numbers come from.

To get an intuitive feel for what is going on, it says that for the
particular R, G, B, and white colours chosen, if you have a CRT
displaying white and then turn off green and blue, the remaining red
will look .299 as bright as the white did, OR the red will look equally
bright as a white that is only .299 as bright as the original colour.
In a sense, 29.9% of the brightness of white is contributed by red.
The same applies to green and blue.

Now, note that those three magic numbers only apply to one particular
set of (R, G, B, W).  They are certainly wrong for any modern monitor.
People continue to use the NTSC values because they are better than
ones picked at random, and far better than .33, .33, .33!  If you look
at the SMPTE-240M HDTV standard, you will notice that the authors
picked a different set of (R, G, B, W) and recomputed the magic numbers
because of that.

If you're interested, I have a piece of C code that takes an arbitrary
set of chromaticities for RGB and white, and computes the matrix for
the RGB to YUV transformation.  The first line of this matrix is the
"magic numbers" for computing Y from RGB.  It was used to generate all
of the matrices in the article found on page 147 of Graphics Gems II.

	Dave Martindale
Newsgroups: alt.graphics.pixutils