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:
- tex2html_nowrap
38.
- Draw in0 into the color buffer.
- tex2html_nowrap
39.
- Load in0, scaling by (1-x) (glAccumGL_LOAD, (1-x)(GL_LOAD, (1-x))).
- tex2html_nowrap
40.
- Draw in1 into the color buffer.
- tex2html_nowrap
41.
- Accumulate in1, scaling by x (glAccumGL_ACCUM,x(GL_ACCUM,x)).
- tex2html_nowrap
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:- tex2html_nowrap
43.
- Compute s.
- tex2html_nowrap
44.
- Draw in0 into the color buffer.
- tex2html_nowrap
45.
- Load in0, scaling by
(glAccumGL_LOAD, (1-x)/s(GL_LOAD, (1-x)/s)).
- tex2html_nowrap
46.
- Draw in1 into the color buffer.
- tex2html_nowrap
47.
- Accumulate in1, scaling by
(glAccumGL_ACCUM, x/s(GL_ACCUM, x/s)).
- tex2html_nowrap
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