< Previous | Contents | Next >
What does this mean for compositing? The edges of a premultiplied image look much smoother, making them the preferred choice when compositing foreground over the background in a merge. Consequently, all alpha channels are made to be premultiplied in compositing operations if they weren’t already.
On the other hand, it is always preferred to color correct a non-premultiplied RGBA image, because you don’t want to alter the pixel values of an image after the RGB channels have been multiplied by the alpha channel.
If you think of this from a mathematical perspective:
— RGB pixel value x 0 = 0: The black transparent areas of an alpha channel have a pixel value
of 0. When you take the value of an RGB pixel and multiply it by 0 (n x 0 = 0) then by the laws of multiplication, the RGB value becomes 0, or fully transparent.
— RGB Pixel value x 1 = RGB Pixel: The solid or opaque white areas have a value of 1.0. When you take the value of an RGB pixel and multiply it by 1 (n x 1 = n), then the RGB value stays the same, fully opaque.
— RGB Pixel value x 0.3 = A different color: Along the edges of an alpha channel are gray pixels, indicating semi-transparency. These semi-transparent pixels have a value falling somewhere between 1.0 and 0.0. To apply the alpha channel’s anti-aliased edges to the RGB channels, you multiply the pixel values. The multiplication process mixes some percentage of the transparent pixels (black) with the RGB pixels. Although this is desired to get good anti-aliased edges, you can not color correct the image because it alters the smooth semi-transparency you created once it is done.
RGB pixels are multiplied by varying degrees of transparency and the result is a different RGB value.
The Rules of Premultiplication
Following from the information presented above, when you’re compositing multiple images together and one or more has a built-in alpha channel, you want to make sure you follow these general rules to avoid problems:
— Always use premultiplied images with a Merge node.
— Only color-correct images that are not premultiplied.
— Always filter and transform images that are premultiplied.
— Never double premultiply an image.
Premultiplication and the Merge Node
The foreground input of a Merge node expects a premultiplied RGBA image. It is an additive merge, meaning the semi-transparent areas of the foreground are added over the background.
However, if the image is not premultiplied, the pixels that should be transparent are still added, which typically results in an unwanted bright fringe around the edges of your foreground subject.
If you are compositing with a non-premultiplied alpha, you can fix these bright edges by changing the Merge to perform a Subtractive merge in the Inspector.
Nonpremultiplied edges in an additive Merge (left) and premultiplied edges in an additive Merge (right)
TIP: When an RGB image and a Mask node are combined using, for instance, a Matte Control node, if the RGB image is not multiplied by the mask in the Matte control, the checkerboard background pattern in the viewer will appear only semi-transparent when it should be fully transparent.
TIP: When an RGB image and a Mask node are combined using, for instance, a Matte Control node, if the RGB image is not multiplied by the mask in the Matte control, the checkerboard background pattern in the viewer will appear only semi-transparent when it should be fully transparent.
TIP: When an RGB image and a Mask node are combined using, for instance, a Matte Control node, if the RGB image is not multiplied by the mask in the Matte control, the checkerboard background pattern in the viewer will appear only semi-transparent when it should be fully transparent.
Color Correcting Premultiplied RGBA Images
When you premultiply an image, you tie any changes made to the brightness of the RGB pixels to the alpha channel pixels as well. If, for example, you raise the brightness of the foreground image in any way, you’ll also raise the brightness of the alpha channel, which will likely not be desirable as this will change the transparency the alpha channel creates. The visible result of this when viewing the Merge node is that the entire background will become brighter (or darker if you’d lowered the RGB brightness) based on your color adjustment.
For this reason, the rule is always to divide the semi-transparent pixels before performing any color correction on an image with an alpha channel. You can do this turning on the Pre-Divide/Post Multiply checkbox in any node that performs color correction. Alternatively, you can use the Alpha Divide
and Alpha Multiply nodes to do the same thing. These methods are covered in more detail later in this chapter.