PDA

View Full Version : RGB to greyscale


Jake
2003.01.01, 04:16 PM
If I have a Red,Green, and blue value of a pixel how would I convert it to greyscale? Averaging won't work right? (or will it)

furballphat
2003.01.01, 05:30 PM
A quick Google pulled up this:


The Kernel used in most of the testing for the cache converts RGB Images to Gray Scale Images. The conversion algorithm is relatively simple: Read in R,G,B values for a pixel. Multiply each of these values by a constant, and add the results.

The result is stored as the Gray value for the pixel in an output image.
Assumed constants: The constants are similar to the ones used by Photoshop in converting RGB to Grayscale. They are as follows:

R = 0.30
G = 0.59
B = 0.11

Equation: Out = R * 0.3 + G * 0.59 + B * 0.11

OneSadCookie
2003.01.01, 05:32 PM
Try luminance = 0.30078125 * red + 0.58984375 * green + 0.109375 * blue -- apparently that's what QuickDraw 3D uses.

Jake
2003.01.01, 05:46 PM
Thanks!