[comp.graphics] Converting RGB <-> HSV

cosell@cosell.bbn.com (Bernie Cosell) (11/10/87)

Does anyone have the formulae for converting Red/Green/Blue color
specs to and from Hue/Saturation/Value specs?  Also, does anyone
have the equation for converting color->grayscale?  Thanks
  /Bernie\

Bernie Cosell                       Internet:  cosell@bbn.com
Bolt, Beranek & Newman, Inc         USENET:    bbn.com!cosell
Cambridge, MA   02238               Telco:     (617) 497-3503

thom@hpfcdq.HP.COM (Tom Morrissey) (11/12/87)

For a complete answer to your questions see "Fundamentals of Interactive
Computer Graphics", J.D. Foley and A. van Dam, Addison-Wesely 1983, 
chapter 17, pgs 593-623.  There is pseudo-code on pages 615 and 616
for the HSV<->RGB conversions.

A fairly standard RGB->I conversion is:

   0.3*red + 0.59*green + 0.11*blue

Which is derived from the NTSC mapping and is used in the graphics
interface standards.

-- Tom Morrissey
  UUCP: hplabs!hpfcla!thom
  ARPA Internet: thom%hpfcla@hplabs.HP.COM
  USPS: HP/TWO, 3404 E. Harmony Rd., Bldg 1U-73, Fort Collins, CO  80525-9599
  PHONE: 303-229-2869
  FAX: 303-229-2692 (with attn: Tom Morrissey, MS 1U-73, x2869)

3ksnn64@pur-ee.UUCP (Joe Cychosz) (11/13/87)

In article <6781@bbn.COM> cosell@bbn.com.UUCP (Bernie Cosell) writes:
>
>Does anyone have the formulae for converting Red/Green/Blue color
>specs to and from Hue/Saturation/Value specs?  Also, does anyone
>have the equation for converting color->grayscale?  Thanks


RGB to grayscale:

	Y = .59*R + .11*G + .33*B

RGB to/from HSV:

	This is discussed in Foley and Van Dam book "Fundementals of
	Interactive Computer Graphics."

falk%peregrine@Sun.COM (Edward Falk) (11/14/87)

In article <7018@pur-ee.UUCP> 3ksnn64@pur-ee.UUCP (Joe Cychosz) writes:
>
>
>RGB to grayscale:
>
>	Y = .59*R + .11*G + .33*B
>

EEEEAAAAAYYYYAAAGGGGHHH!!!!  This is WRONG!  Your numbers don't even
add up to 1.0

	Y = .30*R + .59*G + .11*B

Look at a chart someday that describes the eye's sensitivity to the three
colors.  You'll see that blue is the least sensitive.  Film has a different
spectrum, which is why blue objects in a B&W picture look lighter than
you remember them.


		-ed falk, sun microsystems
		 sun!falk, falk@sun.com
I'll take a drug test when Oliver North takes a lie detector test.

garyc@tekecs.TEK.COM (Gary Combs) (11/16/87)

	You might look in the text "Fundamentals of Interactive Computer Graphics" by
	Foley and Van Dam at pages 615-616. 
-- 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
Gary Combs                  garyc@tekecs.GWD.TEK
Tektronix, Inc.             Wilsonvile, Oregon
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

daveb@cbmvax.UUCP (Dave Berezowski) (01/21/88)

In article <7018@pur-ee.UUCP> 3ksnn64@pur-ee.UUCP (Joe Cychosz) writes:
>In article <6781@bbn.COM> cosell@bbn.com.UUCP (Bernie Cosell) writes:
>>
>>Does anyone have the formulae for converting Red/Green/Blue color
>>specs to and from Hue/Saturation/Value specs?  Also, does anyone
>>have the equation for converting color->grayscale?  Thanks
>
>
>RGB to grayscale:
>
>	Y = .59*R + .11*G + .33*B
>
>RGB to/from HSV:
>
>	This is discussed in Foley and Van Dam book "Fundementals of
>	Interactive Computer Graphics."


	A more accurate formula is:

	White = .299*R + .587*G + .114*B