Alpha Channels

Alpha channel fundamentals

This Alpha channel tutorial came from a discussion I had with Jeff Cantin and Francois Maree. I recommend Jeff's alpha tutorial.

Usually, a color image file is composed of 3 channels: RGB for Red, Green and Blue. A transparency channel may be added to describe the importance of each pixels when composited over another image. This transparency channel is called the Alpha channel.

Although the whole Alpha channel technique is generally credited to Thomas Porter and Tom Duff back in 1984 while they where working on composition techniques for the Star Trek film "The Wrath of Khan". Other articles appeared before that which described the use of Alpha Channels for compositing but the Porter and Duff article is the one which completely generalized the use of alpha blendings. The chronology of published papers about Alpha compositing can be roughly presented this way:

For a detailed overview of the history of the development of the alpha channel, see "Alpha and the History of Digital Compositing" by Alvy Ray Smith.

For those not interested in the technical details, I have devised a quick tutorial about Alpha channels and some specific info for when they are used with A:M.

The illustration on the left is a representation of 5 pixels of an RGBA bitmap. There is one color which is RGB(191, 63, 255) and five alpha values that goe from 255 (fully opaque) to 0 (fully transparent). In percentage values, the alpha values are 100%, 75%, 50%, 25% and 0%.

The green background color is RGB(63, 191, 127).

The color RGB(191, 63, 255) is represented in the next to last row under the double bar in the illustration and the resulting merge with the background given the different alpha values are represented in the last row.

Although the alpha channel is said to contain the transparency information, in fact, it actually contains an opacity information. Taking the example above, the bitmap is respectively 100% opaque, 75% opaque, 50% opaque, 25% opaque and 0% opaque.

It is still possible to think in term of transparency although in this case, the concept of transparency must be thought as being applied to the background image over which the current image is composited. In this case, we could say that the background is respectively 100% transparent, 75% transparent, 50% transparent, 25% transparent and 0% transparent.

Now, this may seem like unnecessary hair splitting but this is fundamental to how alpha channels are used in compositing. The actual resulting merged color is computed this way: (image color × alpha) + (background color × (100% - alpha)).

So taking the five examplar alpha values above, we get respectively 100%f + 0%b, 75%f + 25%b, 50%f + 50%b, 25%f + 75%b and 0%f + 100%b where f and b represent the foreground image color and the background color.

Premultiplied alpha images

One possible optimization of the image to background merging process is to get rid of the first multiplication since the image will never change and the alpha is already known. By doing that, the process of merging with the background is simplified to: (image color) + (background color × (100% - alpha)).

The resulting bitmap is represented in the illustration on the right. Since the compositing application knows that the image is already premultiplied, the resulting composition stays the same.

The first thing to note here is that by premultiplying the image, the rendered foreground image must fade to a black background. The reason for this is that the merge with a background step is done as a post process and we don't want any backgri=ound information is the to-be-composited image since we want the rendered image to be able to merge with any background later. If you wonder why your rendered image with alpha have a black background, that is why.

When you ask A:M to render with alpha, the resulting image file is stored as a premultiplied alpha image which explains why it fades to a black background.