A lot of people mention this on forums and struggle to understand why it’s needed. Even after reading some books that touch upon it I was confused. Maybe I’m too stupid? Possibly. But I was frustrated by this so grabbed a pen and paper and did the maths myself, and it clicked.

Theory

A premultiplied images is an image that has the RGB multiplied by the alpha channel. This is usually for creating transparency when merging with a background (with the over operation). However problems occur when colour correcting the premultiplied image.

R * A = R
G * A = G
B * A = B

‘Unpremultiple’ is the process of dividing the alpha out of the image. Then the colour corrections can be done. After this stage, the alpha can then again be multiplied back in. This can often be done within the colour correction node itself, or manually.

Let’s look at an example.

R = 0.5
A = 0.2
X = 0.3

So I’ve set some variables. This example concentrates on just the red channel (R) and the alpha (A). The last variable is X, which is a colour correction value input by the user. In this example it is added (brightness increase) to the pixels.

Example 1 is what standardly happens; the alpha is premultiplied and then the brightness is added. Example 2 is what should happen; the alpha is removed, the colour correction performed, and then the alpha is put back.

Example 1:
R * A = 0.1
0.1 + X = 0.4

R = 0.3

Example 2:
R * A = 0.1
0.1 / A = 0.5
0.5 + X = 0.8
0.8 * 0.2 = 0.16

R = 0.16

Both equations run a brightness increase of 0.2 to the same pixels. However, the results are different!

You should notice how the red channel is changed by the alpha at the start of the equation, which changes the outcome after the brightness increase. Unpremultiplying removes this alpha so the red channel is effected how it should be.

The image becomes unpremultiplied, by performing a pre-divide. This is why Fusion calls the process ‘premultiply/predivide’ instead. Either way, both are correct terminology.

When you do these equations with the alpha and 1 or 0, the results are the same. Therefore if there is no semi-transparency it could be argued there is no need to do unpremultiply. Most premultiplied images will have semi-transparent areas, from blurred rotoscope edges to anti-aliased renders, so it is good practise to do so whenever the image is premultied.

Practicality

The effect is a brightening or darkening of transparent pixels. The greater the colour correction, the more noticeable it will become. An anti-aliased image will have a dark/light border around the render which will look nasty, especially when trying to blend it in with the environment.

Advertisements