Saturday, August 6, 2011

bits and pieces

"256" on my abacus


Today's special is a 3-course dinner. You have two choices for appetizer, two choices for entree, and two choices for dessert. How many different combinations can you get?

2 x 2 x 2 = 8.

Now if we have 8-bits to represent different shades of gray, how many of them can we have? Well, each bit can either be 1 or 0, so two choices for each bit.

2 x 2 x 2 x 2 x 2 x 2 x 2 x 2 = 256.

24-bit color? No problem. 8 bits for the Red Channel, 8 bits for the Green Channel, and 8 bits for the Blue Channel. Quick, whip out that abacus. 16,777,216 colors. Man, that's a lot of colors. Not enough to represent all the colors in the world. Nope.

When you see 32-bit color, there's usually 8 bits dedicated to the Alpha channel to control transparency or opacity, so you can do fancy layer stuff in Photoshop, for example.

What about CMYK? That's for Cyan, Magenta, Yellow and Black, for laying down ink on paper. That's another discussion.

Sometimes instead of using 8 bits per channel, we could have 16-bits for each color channel in the super-duper modes.  For example, when you shoot RAW, the camera may use 10 or 12 bits to record each channel. Adobe Camera Raw, for example, in Lightroom or Photoshop uses 16 bits per channel for processing. Your monitors can't display all those colors, but after the fancy adjustments, the image is converted back to 8-bits per channel so you can see the result on the screen.

How do they convert color images to grayscale or black-and-white? Fancy math. For example, you can take 30% of the red, 59% of the green, and 11% of the blue, stir well and get a standard luminance value for the gray image. When you convert the mode from RGB to Grayscale in Photoshop or GIMP, this is probably what's done behind the scene. And arguably one of the worst in terms of contrast. There are literally infinite number of ways of black-n-white conversion, but the idea is the same, and you can map different RGB colors to different shades of gray. If you ever play with Grayscale Mix sliders in Lightroom or Camera Raw, this is what happens. (Incidentally, in RGB mode, when the three values are the same, you'll get a shade of gray.)

That, boys and girls, is some of the bits and pieces.

No comments:

Post a Comment