Next: 13.2.2 Pixel Scale and Up: 13.2 Colors and Color Previous: 13.2 Colors and Color

### 13.2.1 The Accumulation Buffer: Interpolation and Extrapolation

Haeberli and Voorhies [40] have suggested several interesting image processing techniques using linear interpolation and extrapolation. Each technique is stated in terms of the formula:

 out = (1 - x)*in0 + x*in1 (12)

This equation is evaluated on a per-pixel basis. in0 and in1 are the input images, out is the output image, and x is the blending factor. If x is between 0 and 1, the equations describe a linear interpolation. If x is allowed to range outside [0..1], the result is extrapolation [40].

In the limited case where , these equations may be implemented using the accumulation buffer via the following steps:

38.
Draw in0 into the color buffer.
39.
40.
Draw in1 into the color buffer.
41.
Accumulate in1, scaling by x (glAccumGL_ACCUM,x(GL_ACCUM,x)).
42.
Return the results (glAccumGL_RETURN, 1(GL_RETURN, 1)).
It is assumed that in0 and in1 are between 0 and 1. Since the accumulation buffer can only store values in the range [-1..1], for the case x < 0 or x > 1, the equation must be implemented in a different way. Given the value x, you can modify equation 12 and derive a list of accumulation buffer operations to perform the operation. Define a scale factor ssuch that:

s = max(x, 1-x)

Equation 12 becomes:

and the list of steps becomes:
43.
Compute s.
44.
Draw in0 into the color buffer.
45.
46.
Draw in1 into the color buffer.
47.
Accumulate in1, scaling by (glAccumGL_ACCUM, x/s(GL_ACCUM, x/s)).
48.
Return the results, scaling by s (glAccumGL_RETURN, s(GL_RETURN, s)).

The techniques suggested by Haeberli and Voorhies use a degenerate image as in0 and an appropriate value of x to move toward or away from that image. To increase brightness, in0 is set to a black image and x > 1. To change contrast, in0 is set to a gray image of the average luminance value of in1. Decreasing x (toward the gray image) decreases contrast; increasing x increases contrast. Saturation may be varied using a luminance version of in1 as in0. (For information on converting RGB images to luminance, see Section 13.2.4.) Sharpening may be accomplished by setting in0 to a blurred version of in1 [40].

Next: 13.2.2 Pixel Scale and Up: 13.2 Colors and Color Previous: 13.2 Colors and Color
David Blythe
1999-08-06