Home Portfolio About Tutorials Links Client Login Contact  
ID PWD
 

What is an Alpha Channel?

If you've ever used Photoshop you know how handy it is to have transparency in raster (bitmap) images. Not every program can read a Photoshop file though, and only a few graphic file formats support transparency.

Typically an image has three channels Red Green and Blue (RGB). Each channel contains the value 0-255 for that pixel for each color. An Alpha Channel looks just like any of the RGB color channels, except it's value doesn't represent a color value, but rather a transparency value. In most alpha channels Black or Zero = Completely Transparent. White or 255 = Completely Opaque or Not Transparent. Any level of gray in between will display as partly transparent.

Some software packages such as Avid use what is referred to as an 'Inverted Alpha'. Here, black is opaque and white is transparent. Often when inverted alphas are used there is an option to convert from one format to the other.

Creating an image with an alpha in Photoshop is easy.
First take any PSD image that is partly transparent.
Next, from your layers pallet choose 'Merge Visible' to flatten the image and keep transparency.
Then, Ctrl+Click on the layer to auto select it.
Switch to the Channels pallet and click the 'Save Selection As Channel' button
Finally you need to save the image in a format that supports Alpha Channels.
I usually choose Targa .tga files for video. Click File>Save As, then set the format to 'Targa (*.TGA; *.VDA; *.ICB; *.VST)' and click 'Save'. Lastly set the Targa Options to 32 bits/pixel and use Compress (RLE) if you choose.

There you have it, a nice and neat 32 bit Targa with Alpha!

Why 32 bit?

Most RGB images are stored in 24 bit. This means 8 bits for Red 8 bits for Green and 8 bits for Blue. Since each color has 8 bits or 2 to the 8th power that makes 256 distinct values. We could express those values as 1-256, but for images it is standard to say 0-255 because zero seems like black more than one, doesn't it?

When you add an alpha channel you need a place to store the transparency information. This info is stored in an additional 8 bits giving each pixel 32 bits or RGBA, the 'A' being Alpha. This makes for files that are 33% larger in size if you are not compressing them.

Premultiplied & Straight Alphas

Often when you load an image with an alpha you will be asked if it should be interpreted Straight, or Premultiplied with a color and what color that should be.

When you start to make pixels transparent things can be seen through them. When the file is saved a red pixel that is 50% transparent will be 50% red and 50% the background color. 'Premultiplied - Matted with color' is the same as asking "What was the background color?" Sometimes this is Black sometimes it's white, but it could also be any color you can think of. If you choose the wrong color any area that is partially transparent will look a little strange, and most likely not what you are after.

In our example of a 50% transparent red pixel, if you tell it you matted it over Green, it will take your pixel and say, 'OK this is 50% transparent over Green, so I need to remove 50% green and then we will have the original color. If it was in fact over green you have now recovered the proper color and transparency, however if it was over black you just subtracted green from the red you wanted and your color is all messed up.

Straight Alphas keep the color values separate from the transparency values. This way there is no blending with a background color. In our previous example the color value for our 50% transparent red pixel would have been half way between the background value and 255,0,0. Neither Red nor the background color. In Straight Alphas the color value for a half transparent red pixel is always 255,0,0 and a 25% transparent would also be 255,0,0 so there is no telling the difference between the two, the only thing that changes is the alpha from 128 for 50% and so on. Straight images look just like premultiplied images when they are interpreted properly, but if you were to look at each without the alpha channel applied, Premultiplied images give you an idea of what the final result will be because you can still see the background color where it should be transparent.