Today’s Question: This may be silly, but can you tell me how you calculated the number of color values available based on bit depth?
Tim’s Quick Answer: There are two “basic” steps to calculating the number of colors available based on bit depth. First you raise the number 2 to a power based on the bit depth you’re calculating, such as raising 2 to the 8th power for 8 bits per channel. Then you take the result from step one and multiply it by itself based on the number of color channels. In other words, you would cube the result for a three-channel RGB image to obtain the number of colors available for an 8-bit per channel RGB image.
More Detail: Bit depth refers to the number of bits used to store a specific numeric value, which in this case refers to pixel values in a digital image. Each bit can have one of two values, which represent “on” or “off” and are often described as “1” and “0” in the parlance of computer systems.
When we say that a value is “8 bits” we are essentially saying that the value can be represented by an 8-digit number, but where each digit can only be “1” or “0”. So the first digit can have one of two values, and the second digit can have one of two values, and so on. Thus, we can calculate the total number of possible values for an 8-bit number by multiplying 2 by itself a total of 8 times. For different bit depths, simply repeat the multiplication based on the bit depth value (in place of 8 used in the example here).
Of course, instead of multiplying 2 by itself multiple times, you can also simply raise the number 2 to a power based on the bit depth. So, for an 8-bit number you could raise 2 to the power of 8. This function is available on many calculators as an “x-to-the-y” function, which calls for entering “2”, then pressing the “x-to-the-y” button, followed by the power you want to raise 2 to.
At this point you will have the number of possible tonal values for a single channel. For an 8-bit value that would be 256 shades of gray for a black and white image. But for a typical RGB color image there are three channels (red, green, and blue). Therefore, you need to take the result you got from the first step and multiply it by itself based on the number of channels. So in this example you could multiply 256 by 256 by 256 (for a total of three instances of 256, if you will). That also translates into cubing the value.
So, completing our example here, 256 raised to the power of 3 produces a result of 16,777,216 possible color values for an 8-bit per channel RGB image. Keep in mind, of course, that this is only the theoretical maximum number of colors available, and the actual number represented in a given photo could be significantly lower.