Color resolution
Color resolution, or bit depth, says how many bits store the color of one pixel or one component. It decides how many different colors an image can contain and how smooth its tonal transitions will be.
Bits per pixel and per component
| Bits per pixel | Encoding | Colors | Examples |
|---|---|---|---|
| 1 | 2-color palette | 2 | fax, black-and-white icons |
| 4 | 16-color palette | 16 | EGA, old Windows icons |
| 8 | 256-color palette or 256 grays | 256 | GIF, PNG-8 |
| 16 | RGB 5-6-5 | 65,536 | small displays, older phones |
| 24 | RGB 8-8-8 | 16,777,216 | JPEG, PNG-24, most displays |
| 30 | RGB 10-10-10 | over 1 billion | HDR, professional monitors |
| 48 | RGB 16-16-16 | about 2.8 · 10¹⁴ | PNG-48, TIFF, photo editing |
An alpha channel can be added on top (see transparency): RGBA 8-8-8-8 is 32 bits per pixel.
The 16-bit 5-6-5 format
16 bits do not split evenly into three, so green gets 6 bits and red and blue 5 each. Green, because the eye is most sensitive to it (see luminance). An example for #c85028:
When going back to 8 bits, multiply by 255/31 rather than shifting left. A plain shift (25 << 3 = 200) could never produce full white 255.
Banding in gradients
8 bits per component is 256 levels. On a gentle gradient across the whole screen, consecutive levels then form bands a few pixels wide. At 8 bits they are usually invisible, but they appear when:
- the gradient is dark or nearly flat (a dusk sky, for instance), because only a few levels differ there,
- the image has been processed several times at 8 bits: every brightness or contrast change rounds values and some levels disappear,
- values are linear instead of gamma-encoded. Linear 8 bits wastes levels in highlights and is badly short of them in shadows (see gamma correction).
That is why photos are edited at 16 bits per component and reduced to 8 bits only at the end, often with light dithering (see color palette). HDR images need at least 10 bits because they cover a much larger brightness range.
Color resolution in GIF
The GIF logical screen descriptor has three "color resolution" bits. Despite the name they do not change the number of colors in the file. They state how many bits per component the original had, from which the palette was made (value + 1). The GIF palette always stores each component in a full byte anyway. Software usually writes 7 (8 bits) here and nobody reads the field.
Bit depth and gamut are two different things. More bits split the same range of colors into finer steps. A wider gamut, such as Display P3 instead of sRGB, widens the range itself (see the RGB model). A wide gamut at 8 bits has coarser steps than sRGB at 8 bits.