Premult Unpremult

Premult

The simple definition of premult is to multiply the alpha and the RGB of the input together.

As an example of this, I will take a checkerboard and copy the alpha made from a roto node. The result of this is the original checkerboard but when I press a to look at the alpha, it now has the shape of the roto instead of the solid white alpha that it had before.

checkerboard

Now, you might be thinking that this should have cut out around the circle shape, leaving that circle containing the checkerboard image. This has not happened yet, as the circular alpha has only been copied and is present in the alpha channel of the checkerboard, but it has not gone under any type of operation to cut out the shape using the alpha.

premultscript

However if I now use a premult node after this, a mathematical operation is applied to the input. As i said at the beginning, it is the RGB values multiplied with the alpha value. The alpha is black and white but the computer sees this as 1 and 0, with white being 1 and black being 0. Therefore if you multiply anything by 0, you will recieve a value of 0 and that area will remain black. But if you multiply it by 1, the area will keep the original RGB since any number multiplied by 1 stays the same.

 

premultedAlpha
Checker Board after premult

 

 

Unpremult

So after understanding premult there is also the unpremult node to worry about. The definition of the node is relatively easy to derive from the name of the node it’s self. Un-Premult suggests that this does the opposite operation to the premult node. Therefore instead of multiplying the RGB values by the alpha, it divides instead.

The effect of this is best shown on transparent edges of an alpha. The unpremult basically removes the RGB transparrency and allows the edges to keep the full block color.

 

premult
Original Premulted Edge
unpremult
Unpremulted Edge

 

The reason this would be used is when it comes to grading and color correction. If you try to color grade a premulted input, the colour will be incorrect in the transparent areas. You need to unpremult it, to retain the full colour of the edge, and then premult it again to re-apply the edge from the alpha.

The alpha is not affected through premulting and unpremulting, only the RGB, this is the reason why the edge can be re-applied through the premult.

shapeOncheckerboardNograde

Here is an example, I have created a blue shape with a feathered edge and merged it on top of a checkerboard. This is fine but I then decided that I wanted to colour grade the shape, if I apply a grade node after the premult, it ruins the edge of the shape.

The edge transparency has been effected by the grade node as is now not accurate to the alpha.

unpremultScript.JPG

However, If I add a unpremult before and a premult after the grade, It performs the grade on all of the colour pixels that are available and then re applies the correct feathered edge from the alpha.

 

Leave a comment