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:
- cr = α fr + (1 − α) br
- cg = α fg + (1 − α) bg
- cb = α fb + (1 − α) bb
Note that if the operations are performed in a colour space where γ is not equal to 1 then the operation will lead to non-linear 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 non-linear. It is possible for a compositing artist to compensate for the effects of compositing in non-linear 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.
- cout = α fin + (1 − α) bin
- cout = α fin + bin − α bin
- cout = bin + α (fin − bin)
By simply rewriting the mathematical expression one can save 50% of the multiplications required.
Read more about this topic: Digital Compositing
Famous quotes containing the word mathematics:
“Mathematics alone make us feel the limits of our intelligence. For we can always suppose in the case of an experiment that it is inexplicable because we dont happen to have all the data. In mathematics we have all the data ... and yet we dont understand. We always come back to the contemplation of our human wretchedness. What force is in relation to our will, the impenetrable opacity of mathematics is in relation to our intelligence.”
—Simone Weil (19091943)
“Why does man freeze to death trying to reach the North Pole? Why does man drive himself to suffer the steam and heat of the Amazon? Why does he stagger his mind with the mathematics of the sky? Once the question mark has arisen in the human brain the answer must be found, if it takes a hundred years. A thousand years.”
—Walter Reisch (19031963)
“... though mathematics may teach a man how to build a bridge, it is what the Scotch Universities call the humanities, that teach him to be civil and sweet-tempered.”
—Amelia E. Barr (18311919)