Quick-tip: Straight alpha VS premultiplied alpha

Have you ever tried figuring out the difference between Straight Alpha and Premultiplied alpha and when to use what?

Some people swear premultiplied alpha is the way to go, some say straight alpha. To be frank, as long as the math and interpretation of the channels is done correctly, both are equal. But lets start with an explanation of what premultiplied and straight alpha is:

Premultiplied Alpha

In premultiplied alpha, partly transparent areas of your image (as in anti-aliased edges) will be premultiplied with a matting color. In 9 out of 10 cases, this color will be black, though it is possible to specify the color yourself. This means, although you have an alpha channel (RGB[A]) for your image, the RGB channels will be matted (premultiplied) with the specified color. If the math is done correctly and the alpha interpretation settings in your software (eg. After Effects) are correct, the amount of matted color will be substracted from your image by using the alpha channel.

Images with premultiplied alpha can look correct, even when the alpha-channel is ignored (or not supported by early-day applications)

Pixel-explanation:

  • A red pixel that has an alpha of 50% will have the following 8bit  RGBA information:      R[127], G[0], B[0], A[127]
  • An orange pixel that has an alpha of 75% will have the following 8bit RGBA information: R[191], G[95], B[0], A[191]

 

Premultiplied Alpha

Straight Alpha

In straight alpha, the RGB channels are left untouched and aren’t matted or premultiplied with a specified color. When ignoring the images alpha-channel the image will not look correct and have rough edges and dots all over the place. This can be surprising for people who do not know what straight alpha is.

Pixel-explanation:

  • A red pixel that has an alpha of 50% will have the following 8bit RGBA information:      R[255], G[0], B[0], A[127]
  • An orange pixel that has an alpha of 75% will have the following 8bit RGBA information: R[255], G[127], B[0], A[191]

 

Straight Alpha

 

Conclusion

Both techniques are equal, as long as you and your software interpret them correctly.

I recommend watching the following Video for more information:

Further Reading



  1. http://imgur.com/ on 16. Dec, 2013

    I just like the helpful information you provide on your articles.
    I’ll bookmark your blog and check again right here frequently.
    I am rather certain I’ll be informed lots of new stuff proper here!
    Good luck for the next!