You may be photographing in raw rather than jpeg because you know that raw files contain more information and because they are unprocessed, giving you more flexibility. But how do they contain more information? Among other things, digital photography raw files are captured at a higher bit depth — depending on the camera, 12, 14 or 16 bit, compared to 8 bit for jpegs. Whether 12, 14 or 16, these higher bit-depth files potentially contain much more information than 8 bit files.
So what is bit depth?
For each pixel in your image, the tonal value or brightness of the scene you are photographing is stored in the image file on your memory card, along with the color. Computer files store information in zeros and ones. Bit depth refers to how many digits the tonal information for each pixel is stored in. Imagine if your camera used a bit-depth of one: you would have one digit to store how dark each piece of the scene was, the only possible values would be 0 and 1, and the only two tones that could be represented are black and white:
This image of course has very little detail, since it contains no shades of gray.
If the file had a bit depth of two, there would be two digits, and the four values of 00, 01, 10, and 11 would be possible, so the image could have black, dark gray, light gray, and white:
Notice that we have gained some detail, but that the image is still very choppy. In the histogram for this image, below, we see huge gaps between the tones, confirming the choppiness or posterization. (The histogram is a graph of the tones in an image, going from pure black on the left side to pure white on the right side.)
Let’s jump to a file with a bit depth of 5, which allows 2 to the 5th, or 32 possible values from 00000 to 11111:
We gain alot of detail, but there is still obvious posterization in the sky (click on the image to see it larger). The histogram supports this:
Now let’s jump to 8, which allows 2 to the 8th, or 256 values, and is what a jpeg supports:
This image shows the full detail of the scene with no visible posterization, even when viewed at full size, and the histogram looks much better. (If you see any posterization, it is not real, but rather just the result of my blog save process.) So why not stop here, with 8 bits and 256 tones?
The problem is that as soon as you start enhancing your image, you start compressing and expanding the tonal range. This creates choppiness in the histogram and potentially, visible posterization in your image. To show this, I took this 8 bit image into Photoshop, and added contrast and darkened it:
Notice how this pulled apart the histogram: