[comp.graphics] Simple RGB to Gray scale question

nick@hp-sdd.UUCP (02/25/87)

How does one convert a pixel defined by an R, G, B value into
a single Gray level?

Gray = (R+G+B) / 3  ???

It seems like the R, G, B components should have different weights since
I'm aware that the eye is less sensitive to blue light.

Anyways, please E-MAIL all responses. 


Nick
-- 
+ Disclaimer: The above opinions are my own, not necessarily my employers'.
/ Nick V. Flor / ..hplabs!hp-sdd!nick / Hewlett Packard, San Diego Division
* "What's going down in this world, you got no idea.  Believe me."-The Comedian
- "Less Thunder with the Mouth, More Lightning with the Fists."

del@hpfcdq.UUCP (02/26/87)

The "standard" formula for RGB to intensity is

	intensity = 0.30*RED + 0.59*GREEN + 0.11*BLUE

Dave Larson

paul@imsvax.UUCP (02/27/87)

Nick V. Flor / ..hplabs!hp-sdd!nick / Hewlett Packard, San Diego Division
asks:

> How does one convert a pixel defined by an R, G, B value into
> a single Gray level?

> Gray = (R+G+B) / 3  ???

> It seems like the R, G, B components should have different weights since
> I'm aware that the eye is less sensitive to blue light.

You are quite right that different weights are generally used.  The weights
used in NTSC TV signals (which allow one to view a color signal on a
black-and-white set) are:

   Luminance (gray) = 0.30 red  +  0.59 green  +  0.11 blue

I think this is what you want, although a great deal of work is still being
done in this field.
A good discussion of some of the background for these factors is in:

"Digital Coding of Color Video Signals - A Review", Limb et al., IEEE
Transactions on Communications, vol. COM-25, pp. 1349-1384, Nov. 1977.

Hope this helps!

-- 
                                Paul Knight

           God created man in his own image.
           Man, being a grateful creature, returned the favor.

flip@osu-cgrg.UUCP (02/27/87)

In article <718@hp-sdd.HP.COM>, nick@hp-sdd.HP.COM (Nick Flor) writes:
> 
> How does one convert a pixel defined by an R, G, B value into
> a single Gray level?
> 
> Gray = (R+G+B) / 3  ???
> 
> It seems like the R, G, B components should have different weights since
> I'm aware that the eye is less sensitive to blue light.
> 

and the mystery weights are:
 	
	0.30 red
	0.59 green
	0.11 blue

makes for beautyful flesh tones...

-- 

	Flip Phillips {ucbvax,decvax}!cbosg!osu-cgrg!flip
	Computer Graphics Research Group, The Ohio State University

	Delphi: FPHILLIPS
	USnail: 1501 Neil Ave.,  Columbus, OH 43201

	"All I wanted was a Pepsi, and she wouldn't give it to me."
			-Suicidal Tendancies

gary@uoregon.UUCP (02/28/87)

In article <718@hp-sdd.HP.COM> nick@hp-sdd.HP.COM (Nick Flor) writes:

>
>How does one convert a pixel defined by an R, G, B value into
>a single Gray level?
>

What you want to compute here is the luminance of the light that is
being emitted from your color television monitor.  This will depend on
the chromaticities of the monitor phosphors, the chromaticities of the
white point that the monitor has been balanced to, and the non-linear
relationship between voltage applied to the CRT guns and light emitted
from the display (gamma correction).  Using the colorimetric properties
of the NTSC color television system with an assumed gamma of 2.2, this
works out to

     Y = 0.30 ( R ** 2.2 ) + 0.59 ( G ** 2.2 ) + 0.11 ( B ** 2.2 )

where R, G, and B correspond to the values stored in image memory and
are assumed to lie on the range 0.0 to 1.0.  If you are content to map
this back onto the neutral axis of the monitor gamut, then the values
to be reloaded into image memory are

     R = G = B = Y ** ( 1 / 2.2 )

It is easy to work this out for the colorimetric properties of your
own system, but the above expressions are fine for most practical
applications.

kendalla@blast.UUCP (03/02/87)

In article <718@hp-sdd.HP.COM> nick@hp-sdd.HP.COM (Nick Flor) writes:
>
>How does one convert a pixel defined by an R, G, B value into
>a single Gray level?
>
Let me guess... You're converting the colorized version of "The Maltese
Falcon" back to black-and-white.  Right?? (:-)

Gray = 30%(Red) + 59%(Green) + 11%(Blue).


Kendall Auel			   ^ ^
				  /O O\
Tektronix, Inc.			  | V |
Information Display Group	/  """  \
Graphics Workstations Division	/ """"" \
(kendalla@blast.GWD.TEK.COM)	 /|\ /|\

ao@tub.UUCP (03/02/87)

> /***** tub:comp.graph / hp-sdd!nick /  6:48 pm  Feb 25, 1987*/
> 
> How does one convert a pixel defined by an R, G, B value into
> a single Gray level?
> 
> Gray = (R+G+B) / 3  ???
> 

You wouldn't be able to distinguish between the New York Jets and
Giants ( if I remember correctly ) seen on a black and white TV monitor.

> It seems like the R, G, B components should have different weights since
> I'm aware that the eye is less sensitive to blue light.
> 
In the YIQ model, that is used in commercial color TV, the Y-component
of the color signal is shown on a B/W screen.
It is defined as:

Y = 0.3 * Red + 0.59 * Green + 0.11 * Blue

and matches the luminosity response curve of the eye.

Expierences are good with that formula used in a
GKS to PostScript filter for our LaserWriter.

Arnfried Ossen, ao @ tub.UUCP, Technische Universitaet Berlin, West Germany