When thinking about how to encode color values of images in double matrices, I stumbled upon some interesting facts beyond just RGB (additive, screen) and CMYK (subtractive, printer) color spaces. An other value triple to describe a color is also HSB (hue, saturation, brightness), also HSV (v for value). Without knowing any better, until now I always used brightness(color) to get the gray value of a pixel. The following picture illustrates, why this is for some – if not all – cases not appropriate:
The brightness-function of processing just returns the maximum value of red, green and blue. This is a more technical value, based on the voltage needed by the screen to display the color. In terms of perception, calculating the luminance as a weighted sum of red, green and blue is much more appropriate. In the above image (right), the formula grey = 0.3*red + 0.59*green + 0.11*blue is used. See YUV color space for more information.