return to MAIN PAGE

Many analog photography techniques have equivalents in the digital domain. For example, one can simulate a double exposure (sometimes termed a "DX") by adding ( + ) together two digital images. As one might imagine, the pixel color values arithmetically sum. Since addition is commutative, the order in which the images are summed does not matter.


As an example of digital double exposure in action, One could avoid the use of alpha channels, and naively add a lens flare to a background using image addition. While this technique guarantees a lack of matte lines, it is seldom used in practice ...


...
because image addition easily causes pixel values to rise above 100% white, causing highlight areas to become overexposed and unattractively "clamped" at white. (You can see this problem in the lens flare above)

Many artists avoid this outcome by first running the negative of the foreground element as a 3-color holdback matte on the background before DX'ing the foreground. Adobe photoshop calls this the screen blend mode. In fact, Photoshop uses the screen blend mode as its "official" way of adding lens flares to an image. Here's a tip: Ever wish you could easily reposition a flare? Run it on a separate black layer, screen it over the other layer, and reposition it all you like:

Mathematically, one inverts ( ~ ) the foreground and multiplies ( * ) it by the background, then adds ( + ) the foreground on top. Alternatively, one can print from the sandwiched negatives of both foreground and background. (invert both, multiply them together, then invert the result.) The results are identical. In other words, ~fg * bg + fg = ~(~bg * ~fg).
"Multiply." We throw that term around quite a bit without always understanding it. What exactly is being multiplied?

To understand digital image multiplication, we must first understand that it is only useful when images are represented not as 8-bit 0 to 255 values, but as "floating point" 0.0 to 1.0 fractional values — akin to percentages, if you prefer.

Suppose we have an image that is too pink. That is to say, the image is too red and too blue, but its green channel is just fine. To reduce the red and blue channels, we need to multiply them by a percentage which is less than 100%. For example, to pull 20% from the red and blue channels of an image, one must multiply it by the color (0.8, 1.0, 0.8). Since multiplication by a color is analogous to looking through a filter of that color, we need to look at our overly-magenta image through (as any photographer will have guessed) a "pale green" filter.

Image multiplication makes sense when pixel values range from 0 (black) to 1 (white)

The multiplication has no useful meaning when the color values are expressed in 0 to 255 space, but in 0 to 1 space it all makes sense. Since anything times zero is zero, black (0.0) times anything is black. Since anything times 1 leaves that thing unchanged, white (1.0) times anything has no effect. A point five gray (0.5) times anything will make that thing half as bright. Pale red (1.0, 0.9, 0.9) times anything makes that thing just a bit redder looking. Traditional photographers call this process the subtractive color model which is unfortunate, because no subtraction occurs. If subtraction did occur, then the physical world would have "negative colors" which, of course, it does not. A better, more clearly understandable term would be "multiplicative color model," but the notion of color "subtraction" is deeply ingrained and won't die anytime soon.

Muliplication provides a good way to color line drawings. Here you can really see the "black times anything is black, white times anything is that thing unchanged" rule in action. The sepia regions of the line drawing simply tint sepia the corresponding pixels of the color image.

Since multiplication is commutative, the order of the layering does not matter.


Image Arithmetic is the basis on which CG shaders (Renderman and otherwise) are written. A CG artist often renders flatly-lit objects through the two-step process of 1) multiplying the shading, and then 2) adding (or screening) the highlights. Notice how the shading can contain warm and cool tones, and that those tones will, in turn, warm or cool the object being shaded.

Here we multiply the shading, then add the highlight

Some digital artists — especially those who render not in 3D, by by hand painting or other 2D methods, have sought to collapse this two step process into a single step. Photoshop obliges such digital painters with its hard light blend mode. This often poorly understood blend mode muliplies values below middle gray, and screens those above middle gray. The color (127 127 127) in a hard light blend mode foreground image causes no effect on background images.

HARD LIGHT simulates shading and hilights from a single image

One can use the hard light blend mode and a glass object on a gray background to put an object "behind glass" after the fact.


Anyone interested in compositing digital images would do well to understand some of the underlying arithmetic that should be (but often is not) used to manipulate such images.
Follow this link for more on alpha channels and digital compositing