Shades of Gray

Shades of Gray

4096 Shades of Gray

(Due to the size of some of the images, a PDF is available here)


Today we are going to discuss the importance of 12-bit images over 8-bit images. We are going to look at the effect of bit depth in both images and the image histogram. To examine this, we are going to use a landscape image that has been rendered in several different bit depths, and then follow up with some biological images. Below is the unaltered image. (The landscape images and explanations were taken from

The histogram of an image is a bar graph with the pixel intensity (ranging from black on the left to white on the right) being the horizontal axis and the .number of pixels having that intensity being the vertical axis. A bright image will have mainly pixels with high intensities and therefore the peak or peaks of the histogram will be to the right. A dark image will have a histogram that is mainly to the left. Below is the histogram for the above image. Clearly, it is a moderately-bright image.

For each pixel in a gray-scale image, the intensity is stored as an integer number. Bit depth refers to how many integer levels are used to encode the intensity. If your camera was only able to capture a one-bit image (commonly known as a binary image), the only possible values would be 0 or 1, and the only tones that would be represented would be black or white:

Image with a bit depth of one

As you can see, there is very little detail, as there are no shades of gray.


If the image had a bit depth of two, there would be four values (0, 1, 2, and 3) and the image would be in the four shades of black, dark gray, light gray, and white:

Image with a bit depth of two

Notice that we have gained some detail, but the image is still poor in quality. In the histogram for this image, below, we see huge gaps between the tones. This is referred to as "choppiness" or "posterization". Another way of thinking about choppiness is that it indicates there is missing information in the gray levels that were not encoded.

Histogram for 2-bit image

Let's examine the same image with a bit depth of 5, which is 25 or 32 possible values.

Image with a bit depth of 5

In the 5-bit image, we have gained a large amount of detail, but there is still some obvious posterization in the sky - note the abrupt, unrealistic transitions in grey levels. The histogram also shows the choppiness:

Histogram for 5-bit image

Let's examine the 8-bit image, which allows 28, or 256 gray levels.

Image with a bit depth of 8

Histogram of 8-bit image

This image shows the full detail of the scene with no visible posterization, and the histogram looks much better. So why not stop here, with 8 bits and 256 values?


In fluorescent imaging of biological samples, the problem of stopping at 8 bits is two-fold. The first problem is that if you want to contrast-enhance your image in Photoshop (and when you do enhance an image, it is always good to acknowledge that you did), you are expanding the tonal range of the image in some range of levels. This can create choppiness and the loss of fine detail.

8-bit image that has been darkened and the contrast enhanced.

Histogram of the contrast-enhanced 8-bit image

Note how the enhancement process pulled apart the histogram. The more you push the enhancement, the more you widen the gaps in the histogram. 256 values are often not enough because the enhancement can cause the loss of fine detail.

On the other hand, 12-bit files have 4,096 tones, and 16-bit files have over 65,000. This is vastly better, and with almost any manipulation you could perform on an image, it would retain the fine detail. Here is the histogram of the 12-bit version of the above image, with the darkening and increased contrast.

Histogram of a 12-Bit Version with Darkening and Contrast increase

To have this additional "editing headroom", you have to capture a high bit-depth image, a 12 or 16 bit image. The downside to higher bit-depth is larger image files, but in most instances, that is no longer a problem.


The second problem is when we want to analyze the fluorescent image; our first segmentation process is to apply a threshold. With 256 gray levels, the increments between black and white are coarse, and we can get a much finer segmentation of image by using a 12-bit image.

In biological fluorescent imaging, a large bit depth makes it possible to show both very dim objects as well as very bright objects. Further, it enables thresholding with finer discrimination. Below are two examples of a biological image rendered in 12-bit and 8-bit.

12-bit image                                                8-bit imag


                             12 bit image                                        8 bit image 

                                12-bit threshold lower limit set at 750       8-bit threshold lower limit set at 46

In both images, a little over 3000 pixels were selected by the thresholds. The 12-bit image has 4096 gray levels versus the 8-bit images 256. Each single gray level in the 8-bit image is 16 times larger than a single gray level in the 12-bit image.

To illustrate, we will take the same images and raise the lower limit by 40 gray levels.

                             12 bit image                                                    8 bit image

12-bit threshold lower limit set at 790           8-bit threshold lower limit set at 86

With the lower level of the threshold increased by 40 gray levels in each sample, the 12-bit image has 3013 pixels highlighted while the 8-bit image only has 2315. So we can see that by raising the lower limit by 40 on the 12-bit image, it lost less than a percent of the highlighted area vs. the almost 25% loss in highlighted area in the 8-bit image.


In conclusion, it is always best to capture your images at the higher bit depth.