Bitmap Image Filters
Subject:   Grayscale conversion
Date:   2002-08-07 10:32:26
From:   chieftypist
The Y = (R + G + B) / 3 is a very rough approximation for grayscale. It's better to use:

Y = (0.222*R) + (0.707*G) + (0.071*B)


Y' = (0.299*R) + (0.587*G) + (0.114*B)

(depending on whose standard you want to follow :-)

With the speed of today's processors, the hit for doing the floating point aritmetic is negligible.

More information about colorspace conversions can be found at:

It's pretty hairy stuff, thankfully NSColor handles most of it transparently.

BTW, I'm loving this whole series. Really good work, Mike. Looking forward to the book!


1 to 1 of 1
  1. Michael Beam photo Grayscale conversion
    2002-08-08 14:06:03  Michael Beam | O'Reilly Author [View]

1 to 1 of 1