Digital compositing is the process of digitally assembling multiple images to make a final image, typically for print, motion pictures or screen display. It is the evolution into the digital realm of optical film compositing.
Contents
Mathematics
The basic operation used is known as 'alpha blending', where an opacity value, 'α' is used to control the proportions of two input pixel values that end up a single output pixel.
Consider three pixels;
 a foreground pixel, f
 a background pixel, b
 a composited pixel, c
and
 α, the opacity value of the foreground pixel. (α=1 for opaque foreground, α=0 for a completely transparent foreground). A monochrome raster image where the pixel values are to be interpreted as alpha values is known as a matte.
Then, considering all three colour channels, and assuming that the colour channels are expressed in a γ=1 colour space (that is to say, the measured values are proportional to light intensity), we have:
Note that if the operations are performed in a colour space where γ is not equal to 1 then the operation will lead to nonlinear effects which can potentially be seen as aliasing artifacts (or 'jaggies') along sharp edges in the matte. More generally, nonlinear compositing can have effects such as "halos" around composited objects, because the influence of the alpha channel is nonlinear. It is possible for a compositing artist to compensate for the effects of compositing in nonlinear space.
Performing alpha blending is an expensive operation if performed on an entire image or 3D scene. If this operation has to be done in real time video games there is an easy trick to boost performance.
By simply rewriting the mathematical expression one can save 50% of the multiplications required.
Algebraic properties
When many partially transparent layers need to be composited together, it is worthwhile to consider the algebraic properties of compositing operators used. Specifically, the associativity and commutativity determine when repeated calculation can or cannot be avoided.
Consider the case when we have four layers to blend to produce the final image: F=A*(B*(C*D)) where A, B, C, D are partially transparent image layers and "*" denotes a compositing operator (with the left layer on top of the right layer). If only layer C changes, we should find a way to avoid reblending all of the layers when computing F. Without any special considerations, four fullimage blends would need to occur. For compositing operators that are commutative, such as additive blending, it is safe to reorder the blending operations. In this case, we might compute T=A*(B*D) only once and simply blend T*C to produce F, a single operation. Unfortunately, most operators are not commutative. However, many are associative, suggesting it is safe to regroup operations without changing their order. In this case we may compute S=A*B once and save this result. To form F with an associative operator, we need only do two additional compositing operations to integrate the new layer C: F=S*(C*D). Note that this expression indicates compositing C with all of the layers below it in one step and then blending all of the layers on top of it with the previous result to produce the final image in the second step.
Full article ▸
