Bit-Depth & Linear Light

bpc_linear

This is an elementary introduction to the concepts of bit-depth and linear light in relation to digital imaging. Both these topics play a factor in digital compositing, color grading, and rendering computer generated images.

Bit-Depth:

An RGB image is comprised of at least 3 separate grayscale image channels (red, green, and blue) that, when combined, make up a colored image. Occasionally a fourth channel is used for transparency (alpha).

bpc_linear_01

Each of the color channels has a bit-depth, which determines how many shades of gray that particular channel can represent.

Probably the most common image format today is JPEG, which uses 8 bits-per-channel (bpc).

In 8 bits-per-channel images, there are only 28 (or 256) possible shades of gray for each RGB color channel. It can also be referred to as a 24-bit image (8 bits x 3 color channels = 24 bits of data for every pixel).

Because of the limited bit-depth, very fine gradients will sometimes exhibit artifacts known as “banding” or “posterization”. This occurs because there just isn’t enough information in 8-bits to properly display the image.

bpc_linear_02

Severe banding/posterization

One technique for reducing banding is to add dithering (noise) to the image – which can help break up smooth gradients.

16 bits-per-channel images hold much more data. At a maximum of 65,536 shades of gray (216) in each color channel, banding artifacts are greatly reduced. Again, it can also be called a 48-bit image (16 bits x 3 color channels = 48 bits of data for every pixel).

bpc_linear_03

Minimal banding/posterization

NOTE: There are more than just 8 and 16 bits-per-channel formats. Other bit-depths include 1-6, 10, 12, 32, etc.

Linear Light:

Digital cameras see light in a linear way (their sensitivity to light is directly related to the intensity of the light). If you double the light intensity, the pixel value gets doubled as well. This is also how the computer calculates pixel blending operations.

bpc_linear_04

Linear Gradient (gamma 1.0)

Our eyes work differently, however. We perceive more tones in the shadows and less in the highlights.

To account for this, a gamma curve is applied to the data. The gamma remaps the tones in the image so that it pushes more bits into the shadows. It is more economical as well – instead of wasting resources on imperceptible highlights.

bpc_linear_05

sRGB Gradient (~gamma 2.2)

In Practice:

The main issue with working in an 8 bits-per-channel environment (besides possible banding artifacts) is that the colors do not always blend properly. The gamma has essentially been baked into the RGB values.

bpc_linear_06

A simple experiment is to take two “middle gray” sRGB values (128) and add them together in an 8 bits-per-channel Photoshop document. Since the gamma is not compensated for, the result is incorrect:

bpc_linear_07

The problem is that the 128 value is not “middle gray”, but it’s being treated as if it were (it’s really only about 20% gray). When you take that same image into a 32 bits-per-channel linear workspace, the addition is correctly implemented.

bpc_linear_08

Here is another example of an 8 bits-per-channel image in Photoshop:

bpc_linear_09

Notice the dark line between the colors. Photoshop is trying to blend the colors without adjusting for the gamma.

Switching to a 32 bits-per-channel document moves everything into linear space, and allows the colors to blend correctly.

bpc_linear_10

The take-away from all this is that you should do your compositing, grading, and CGI rendering in a high bit-depth, linear environment. From there, you can always render out an 8-bit file if necessary.

Resources:

You can learn more about bit-depth and linear light at the following places:

Bit-Depth:

https://en.wikipedia.org/wiki/Color_depth

Linear Light Workflows:

http://ae.tutsplus.com/tutorials/workflow/linear-workflow-for-the-after-effects-user/

http://cg.tutsplus.com/tutorials/autodesk-maya/correctly-setting-up-a-linear-workflow-in-maya/

http://prolost.com/blog/2009/9/30/passing-the-linear-torch.html

http://www.lysator.liu.se/~zap/lwf/

Advertisements

Tags: , , , , , , , , , , ,

Trackbacks / Pingbacks

  1. Tips for realistic renders | 310.ch blender*files - January 26, 2016

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: