Premultiplied or not?

 

Some 3D and compositing software give you the option to render the images premultiplied or not. This is just a short explanation of the differences, and how to avoid unexpected results.

First of all let's take a look at an image that's been rendered in a typical 3D program

 

 

This has been rendered premultiplied, in short, the edges of the teapot are antialised against the black background. The alpha channel is also antialiased, so we should be able to get a nice clean image when we later composite against a background.

Here's the same model rendered without it being premultiplied, the only difference are at the edges of the object.

 

 

If we look at it in close-up you can clearly see the difference. The non premultiplied rendered has very jagged edges.

 

 

If we then start to use the alpha channel to composite the teapot over another image we can see the sort of problems that can occur if your compositing software is expecting a different type of image than you give it.

If we take the premultiplied image into Photoshop, load the alpha as a selection, use it to cut the rgb channel out and then paste it onto a another image you can see exactly what the problem is.

 

 

It may not be immediately obvious what the problem is, but if we repeat these steps using the non premultiplied image we get a much cleaner comp.

 

 

It's a little hard to see in a web graphic but if we take a closer look...

 

 

The image on the left is the premultiplied image, as you can see it has a black 'halo' around it. This comes from the black background that it was rendered against. The non premultiplied image is correctly comped over the photo. When we composite in Photoshop this way it expects to get a non premultiplied image to work with. I've been unable to find a way of working with premultiplied images this way in Photoshop (I'm sure you can, and if you know how, please let me know).

If you take your images into a program like AfterEffects you have the option to specify wether the image is premultiplied or not, and if it is you can specify what the background colour is - this is important. AfterEffects will then make the correct adjustments to give you a clean comp.

 
Back to How to...