Bit Depth: Difference between revisions
m (DrSlony moved page 8-bit and 16-bit to Bit Depth: Previous title made obsolete by support for more bit depths) |
(Rewrote article) |
||
Line 1: | Line 1: | ||
== Introduction == | |||
You will hear terms such as "8-bit", "16-bit", "24-bit", "32-bit", "64-bit" and "96-bit" with reference to digital images. This article will clarify what those things mean. | |||
Digital images consist of millions of pixels, and each pixel describes one or more color channels. Grayscale images need only one channel (a value of 0 could represent pure black, 255 could represent pure white, and the values in-between would then represent shades between black and white), while RGB color images need three channels - one describes red, one green and one blue. Each channel describes only an intensity, so there is nothing inherently green about a number which describes a pixel from the green channel; colors derive from the interaction between all three channels in the [https://en.wikipedia.org/wiki/RGB_color_model RGB color model]. | |||
A single pixel could represent more than three channels, for example it could contain information about an alpha channel (which describes transparency) or an infra-red channel (which some scanners support). | |||
The higher the bit depth, the more precisely a color can be described, at a cost of requiring longer computation, more RAM and more storage space. | |||
== Bits Per What? == | |||
Bit depth is expressed as a value which describes either the number of '''bits per pixel''' (BPP), or '''bits per channel''' (BPC). The very popular [https://en.wikipedia.org/wiki/JPEG JPEG format] typically saves images with a precision of 8 bits per channel, using three channels, for a total of 24 bits per pixel. The [https://en.wikipedia.org/wiki/TIFF TIFF format] supports various bit depths, for example 32 bits per channel for a total of 96 bits per pixel. | |||
When describing bit depth, state what you're describing to leave no room for ambiguity. For example, if someone says they have a "32-bit" image, does that mean the image has 32 bits per channel, or does it have 4 channels at 8 bits per channel? | |||
== Precision == | |||
What difference does bit depth make? The more bits are available to describe a color, the more precisely you can describe that color. | |||
<ul> | |||
<li>A precision of 1 bit per channel means that there is only 1 bit to describe the value. A bit can only be 0 or 1, so you can only represent two values, which typically would mean black or white.</li> | |||
<li>A precision of 2 bits per channel means there are two bits available to describe a color. Since each bit can be 0 or 1, and there are two of them, they can represent 4 possible values: | |||
<pre>[00] = 0 | |||
[01] = 1 | |||
[10] = 2 | |||
[11] = 3</pre> | |||
If we use 0 to represent black and 3 to represent white, there are two additional shades of gray which can be described. | |||
</li> | |||
<li>A precision of 8 bits per channel means there are 8 bits which can represent 255 values: | |||
<pre>[0000 0000] = 0 | |||
[0000 0001] = 1 | |||
(...) | |||
[1111 1110] = 254 | |||
[1111 1111] = 255</pre> | |||
If we use 0 to represent black and 255 to represent white, 254 shades of gray can also be described. This is what JPEG files use - 8 bits per channel, with 3 channels. It is sufficient to be used for most ready-to-view photographs in the [https://en.wikipedia.org/wiki/sRGB sRGB color space] without visible posterization, so you can use it when saving photographs ready to be viewed over the internet. | |||
It is not suitable as an intermediate format nor as a final format if there is a chance you might need to tweak the photograph later on, as you run the risk of introducing posterization artifacts, depending on the strength of adjustments. 8-bit precision is not enough to represent a high dynamic range scene in a linear way without posterization, i.e. you theoretically could use 8 bits of precision to describe a high dynamic range scene linearly, but the numbers would be so far apart that heavy posterization would occur. For instance, if a photograph captures a sunny day in the park, and if we assume that black should be 0 and white should be 1 000 000, we could map 0 to 0 and 255 to 1 000 000, but then there would only be 254 values left for describing all the remaining 999 999 shades of the original scene. | |||
</li> | |||
<li>A precision of 16 bits per channel (16-bit integer) means there are 16 bits which can represent 65536 values: | |||
<pre>[0000 0000 0000 0000] = 0 | |||
[0000 0000 0000 0001] = 1 | |||
(...) | |||
[1111 1111 1111 1110] = 65534 | |||
[1111 1111 1111 1111] = 65535</pre> | |||
Digital cameras typically capture light in 12-bit or 14-bit precision (and due to noise and imprecise electronics the lowest bits are of dubious quality). 16 bits per channel are enough for most photography needs, including for use in intermediate files (if you want to pass an image from one program to another without data loss). | |||
</li> | |||
<li>A 16-bit [https://en.wikipedia.org/wiki/Floating-point_arithmetic floating point] image, also known as [https://en.wikipedia.org/wiki/Half-precision_floating-point_format half-precision floating point], can represent a wider range of values than 16-bit integer. The precision is not constant and some values are rounded off. | |||
</li> | |||
<li>A 32-bit [https://en.wikipedia.org/wiki/Floating-point_arithmetic floating point] image can represent 4.3 billion values per channel, and requires roughly twice the disk space as a 16-bit image. Few programs support 32-bit images. | |||
</li> | |||
</ul> | |||
== Gamma Encoding == | |||
[https://en.wikipedia.org/wiki/Gamma_correction Gamma encoding] can be used when saving image files, meaning that values are distributed in such a way that more can be allocated in the shadow range than in the highlight range, which better matches the human eye's sensitivity. This means that an 8 bit JPEG can display as much as log2((1/2^8)^2.2) = 17.6 stops of dynamic range, which indeed exceeds the 14 stops of the current best cameras, which explains why you sometimes can see a camera's shadow noise even in an 8-bit JPEG. However, due to the non-linear distribution, we lose precision compared to the raw file recorded in a linear way by the digital camera. Practically this is not a problem when the output file is the definitive one and will not be processed anymore, however a photo can be vastly improved when saved as raw data and processed using a state of the art raw processing program, such as yours truly - RawTherapee. | |||
== After RawTherapee == | |||
Once you have adjusted a photo in RawTherapee and are ready to [[Saving_Images|save]], you are faced with a choice of [[Color_Management#Output_Profile|output format, bit depth]], [[Color_Management_addon#Output_space_.22Output_Profile.22|color space and gamma encoding]]. If you plan to post-process your photos after RawTherapee in a 16-bit-capable image editing program, it is better to save them in a lossless 16-bit format. Uncompressed 16-bit TIFF is suggested as an intermediate format as it is the fastest to save. 32-bit files are roughly twice the size and not well supported by other programs. |
Revision as of 23:32, 5 January 2019
Introduction
You will hear terms such as "8-bit", "16-bit", "24-bit", "32-bit", "64-bit" and "96-bit" with reference to digital images. This article will clarify what those things mean.
Digital images consist of millions of pixels, and each pixel describes one or more color channels. Grayscale images need only one channel (a value of 0 could represent pure black, 255 could represent pure white, and the values in-between would then represent shades between black and white), while RGB color images need three channels - one describes red, one green and one blue. Each channel describes only an intensity, so there is nothing inherently green about a number which describes a pixel from the green channel; colors derive from the interaction between all three channels in the RGB color model.
A single pixel could represent more than three channels, for example it could contain information about an alpha channel (which describes transparency) or an infra-red channel (which some scanners support).
The higher the bit depth, the more precisely a color can be described, at a cost of requiring longer computation, more RAM and more storage space.
Bits Per What?
Bit depth is expressed as a value which describes either the number of bits per pixel (BPP), or bits per channel (BPC). The very popular JPEG format typically saves images with a precision of 8 bits per channel, using three channels, for a total of 24 bits per pixel. The TIFF format supports various bit depths, for example 32 bits per channel for a total of 96 bits per pixel.
When describing bit depth, state what you're describing to leave no room for ambiguity. For example, if someone says they have a "32-bit" image, does that mean the image has 32 bits per channel, or does it have 4 channels at 8 bits per channel?
Precision
What difference does bit depth make? The more bits are available to describe a color, the more precisely you can describe that color.
- A precision of 1 bit per channel means that there is only 1 bit to describe the value. A bit can only be 0 or 1, so you can only represent two values, which typically would mean black or white.
- A precision of 2 bits per channel means there are two bits available to describe a color. Since each bit can be 0 or 1, and there are two of them, they can represent 4 possible values:
[00] = 0 [01] = 1 [10] = 2 [11] = 3
If we use 0 to represent black and 3 to represent white, there are two additional shades of gray which can be described.
- A precision of 8 bits per channel means there are 8 bits which can represent 255 values:
[0000 0000] = 0 [0000 0001] = 1 (...) [1111 1110] = 254 [1111 1111] = 255
If we use 0 to represent black and 255 to represent white, 254 shades of gray can also be described. This is what JPEG files use - 8 bits per channel, with 3 channels. It is sufficient to be used for most ready-to-view photographs in the sRGB color space without visible posterization, so you can use it when saving photographs ready to be viewed over the internet. It is not suitable as an intermediate format nor as a final format if there is a chance you might need to tweak the photograph later on, as you run the risk of introducing posterization artifacts, depending on the strength of adjustments. 8-bit precision is not enough to represent a high dynamic range scene in a linear way without posterization, i.e. you theoretically could use 8 bits of precision to describe a high dynamic range scene linearly, but the numbers would be so far apart that heavy posterization would occur. For instance, if a photograph captures a sunny day in the park, and if we assume that black should be 0 and white should be 1 000 000, we could map 0 to 0 and 255 to 1 000 000, but then there would only be 254 values left for describing all the remaining 999 999 shades of the original scene.
- A precision of 16 bits per channel (16-bit integer) means there are 16 bits which can represent 65536 values:
[0000 0000 0000 0000] = 0 [0000 0000 0000 0001] = 1 (...) [1111 1111 1111 1110] = 65534 [1111 1111 1111 1111] = 65535
Digital cameras typically capture light in 12-bit or 14-bit precision (and due to noise and imprecise electronics the lowest bits are of dubious quality). 16 bits per channel are enough for most photography needs, including for use in intermediate files (if you want to pass an image from one program to another without data loss).
- A 16-bit floating point image, also known as half-precision floating point, can represent a wider range of values than 16-bit integer. The precision is not constant and some values are rounded off.
- A 32-bit floating point image can represent 4.3 billion values per channel, and requires roughly twice the disk space as a 16-bit image. Few programs support 32-bit images.
Gamma Encoding
Gamma encoding can be used when saving image files, meaning that values are distributed in such a way that more can be allocated in the shadow range than in the highlight range, which better matches the human eye's sensitivity. This means that an 8 bit JPEG can display as much as log2((1/2^8)^2.2) = 17.6 stops of dynamic range, which indeed exceeds the 14 stops of the current best cameras, which explains why you sometimes can see a camera's shadow noise even in an 8-bit JPEG. However, due to the non-linear distribution, we lose precision compared to the raw file recorded in a linear way by the digital camera. Practically this is not a problem when the output file is the definitive one and will not be processed anymore, however a photo can be vastly improved when saved as raw data and processed using a state of the art raw processing program, such as yours truly - RawTherapee.
After RawTherapee
Once you have adjusted a photo in RawTherapee and are ready to save, you are faced with a choice of output format, bit depth, color space and gamma encoding. If you plan to post-process your photos after RawTherapee in a 16-bit-capable image editing program, it is better to save them in a lossless 16-bit format. Uncompressed 16-bit TIFF is suggested as an intermediate format as it is the fastest to save. 32-bit files are roughly twice the size and not well supported by other programs.