[comp.graphics] Need reference for RGB to greyscale formula

hollasch@ENUXHA.EAS.ASU.EDU (Steve Hollasch) (05/15/91)

    I'm looking for a reference to cite in my thesis that gives the
"Greyscale = 0.299 Red + 0.587 Green + 0.114 Blue" formula.  I've looked
in most of the common computer graphics texts, but haven't seen this puppy
anywhere.

______________________________________________________________________________
Steve Hollasch                /      Arizona State University (Tempe, Arizona)
hollasch@enuxha.eas.asu.edu  /  uunet!mimsy!oddjob!noao!asuvax!enuxha!hollasch

andreess@mrlaxs.mrl.uiuc.edu (Marc Andreessen) (05/15/91)

In article <9105150458.AA05702@enuxha.eas.asu.edu> hollasch@enuxha.eas.asu.edu (Steve Hollasch) writes:
>    I'm looking for a reference to cite in my thesis that gives the
>"Greyscale = 0.299 Red + 0.587 Green + 0.114 Blue" formula.  [...]

_Illumination and Color in Computer Generated Imagery_, Roy Hall, 1989,
Springer-Verlag, New York, p. 153.

Marc

-- 
Marc Andreessen___________University of Illinois Materials Research Laboratory
Internet: andreessen@uimrl7.mrl.uiuc.edu____________Bitnet: andreessen@uiucmrl

caine@hplabs.hpl.hp.com (Nate Caine) (05/17/91)

In article <1991May15.052411.22318@ux1.cso.uiuc.edu> andreess@mrlaxs.mrl.uiuc.edu (Marc Andreessen) writes:

> (Steve Hollasch) writes:
>>    I'm looking for a reference to cite in my thesis that gives the
>>"Greyscale = 0.299 Red + 0.587 Green + 0.114 Blue" formula.  [...]
>
>_Illumination and Color in Computer Generated Imagery_, Roy Hall, 1989,
>Springer-Verlag, New York, p. 153.
>
>Marc
>
Please DON'T use this book to reference this formula.
Despite being an otherwise excellent book, this equation is
incorrect in Hall's book, and the mistake is repeated pretty
much throughout.

Those of you that downloaded his code (thanks for posting it Roy!)
might want to take note of this.

regards nate caine@hplabs.hpl.hp.com

dave@imax.com (Dave Martindale) (06/06/91)

In article <9105150458.AA05702@enuxha.eas.asu.edu> hollasch@enuxha.eas.asu.edu (Steve Hollasch) writes:
>
>    I'm looking for a reference to cite in my thesis that gives the
>"Greyscale = 0.299 Red + 0.587 Green + 0.114 Blue" formula.  I've looked
>in most of the common computer graphics texts, but haven't seen this puppy
>anywhere.

That formula is used by the NTSC and PAL colour television systems to
derive the wideband luminance (black and white) signal from the RGB
signals produced by the camera.  It is derived this way:

First, you pick a set of phosphor chromaticites for your standard
red, green, and blue phosphors.  NTSC selected the ones called "NTSC"
in this table:


                     |      Red     |    Green     |     Blue
        Name         |   x      y   |   x      y   |   x      y
        -------------+--------------+--------------+--------------
        NTSC         | 0.67   0.33  | 0.21   0.71  | 0.14   0.08
        EBU          | 0.64   0.33  | 0.29   0.60  | 0.15   0.06
        SMPTE        | 0.630  0.340 | 0.310  0.595 | 0.155  0.070
        HDTV ideal   | 0.670  0.330 | 0.210  0.710 | 0.150  0.060

Then, you pick a "white point" - the chromaticity of the colour that
the CRT is supposed to display when fed a purely monochrome signal.
NTSC chose CIE Standard Illuminant C, with x=0.3101, y=0.3162.

Then, you ask "what combination of these particular red, green, and blue
phosphors gives this particular white?".  To answer this, you solve
the following system of linear equations:

        [ xr   xg   xb ]  [ Jr ]   [ xw ]
        [              ]  [    ]   [    ]
        [ yr   yg   yb ]  [ Jg ] = [ yw ]
        [              ]  [    ]   [    ]
        [ zr   zg   zb ]  [ Jb ]   [ zw ]

The first column of the matrix on the left is the chromaticity
of the red phosphor, the second column is the green, and the third is
the blue (note that for any colour, z = 1 - x - y by definition).
The J vector is the unknown, and the vector on the right is the
chromaticity of reference white.

When you've solved that, you ask yourself "When reproducing a monochrome
picture, how much do the luminance of red, green, and blue individually
contribute to the luminance of white?"  To answer this, note that
the CIE xyz colour space is defined so that the "y" component corresponds
to a spectral response that matches the human eye's perception of
"brightness".  From the matrix equation above, the contributions of RGB
to white are given by:

	yr*Jr + yg*Jg + yb*Jb = yw

Dividing through by yw gives us a more convenient form:

	Jr*yr/yw + Jg*yg/yw + Jb*yb/yw = 1

This tells us that for a white luminance of "1" in some arbitrary scale,
the red phosphor contributes (Jr*yr/yw) of the total luminance,
the green contributes (Jg*yg/yw) and the blue contributes (Jb*yb/yw).

Thus, this gives us three weighting factors that tell us how much RGB
each contribute to white, and thus how much we should weight RGB by
when calculating Y (luminance).  If you work all this out for the NTSC
phosphors and white point, you will get 0.299, 0.587, and 0.114.
That's where the magic numbers come from.

However, note that these numbers are correct *only* for the particular
RGB phosphor chromaticities and white point they were calculated for.
In fact, *no* CRT's being built today use these phosphors.  *No* TV's
are being adjusted for this particular white point.  European broadcasters
assume that their sets use the "EBU" phosphor set listed above.
Most studio monitors use the "SMPTE" set, and the HDTV standard uses
SMPTE chromaticities for the moment, but hopes to later switch to
the chromaticities listed as "HDTV ideal" to get a wider colour gamut.
Studio monitors are adjusted for, and the HDTV standard assumes,
a D65 white point, not Illuminant C.

What does this mean?  If you are generating a luminance signal for
television recording or broadcast from RGB components (e.g. your video
recorder needs YUV or YIQ instead of RGB as input), then you should use
the weighting factors that have been standardized for the particular
broadcast system you are going to use.  These are .299, .587, and .114
for NTSC and PAL.  They are .212, .701, and .087 for the HDTV production
standard (SMPTE 240M).

But if you want to obtain a monochrome image that accurately reproduces
the tones of a colour picture as displayed on your particular monitor,
you need to know the chromaticities of *its* phosphors, and the white
point you have adjusted it for.

In addition, the television broadcast standards specify that the RGB signals
should be gamma-corrected before calculating luminance.  This causes
incorrect luminance calculations in coloured areas - the higher the
colour saturation, the greater the error.  It was done this way to
make TV receivers cheaper.  But if you are calculating monochrome
images for your own use, you should do the calculation of the
black-and-white image with linear (not gamma-corrected) RGB signals,
and then apply gamma correction afterwards if necessary.

So, you can calculate a black&white image that looks correct on your
monitor, or you can calculate it so it is correctly encoded according
to some television broadcast standard, but not both simultaneously.

Why do computer graphics people usually use 0.299/0.587/0.114, even when
not encoding for television?  Because it's easy to borrow the numbers
that someone else worked out for some other context, and the resulting
images look good enough, so they're happy.  Using these weighting
factors is certainly better than the 0.333/0.333/0.333 suggested by
someone else here a few month ago!

To Steve: unless you are calculating "greyscale" for eventual television
broadcast, you probably don't want to reference the television
standards that define the 0.299/0.587/0.114 numbers.  Instead, you
probably should calculate and use the weights that are correct for
your particular application, on the principle that a thesis is worth
getting right.

	Dave Martindale