next up previous contents
Next: 13.2.2 Pixel Scale and Up: 13.2 Colors and Color Previous: 13.2 Colors and Color   Contents


13.2.1 The Accumulation Buffer: Interpolation and Extrapolation

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

\begin{displaymath}
out = (1 - x)*in_0 + x*in_1
\end{displaymath} (12)

This equation is evaluated on a per-pixel basis. $in_0$ and $in_1$ 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 [43].

In the limited case where $0 \leq x \leq 1$, these equations may be implemented using the accumulation buffer via the following steps:

38.
Draw $in_0$ into the color buffer.
39.
Load $in_0$, scaling by $(1-x)$ (glAccumGL_ LOAD, (1-x)(GL_ LOAD, (1-x))).
40.
Draw $in_1$ into the color buffer.
41.
Accumulate $in_1$, scaling by $x$ (glAccumGL_ ACCUM,x(GL_ ACCUM,x)).
42.
Return the results (glAccumGL_ RETURN, 1(GL_ RETURN, 1)).
It is assumed that $in_0$ and $in_1$ 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 $s$ such that:

\begin{displaymath}
s = max(x, 1-x)
\end{displaymath}

Equation 12 becomes:

\begin{displaymath}
out = s(\frac{(1-x)}{s}in_0 + \frac{x}{s}in_1)
\end{displaymath}

and the list of steps becomes:
43.
Compute $s$.
44.
Draw $in_0$ into the color buffer.
45.
Load $in_0$, scaling by $\frac{(1-x)}{s}$ (glAccumGL_ LOAD, (1-x)/s(GL_ LOAD, (1-x)/s)).
46.
Draw $in_1$ into the color buffer.
47.
Accumulate $in_1$, scaling by $\frac{x}{s}$ (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 $in_0$ and an appropriate value of $x$ to move toward or away from that image. To increase brightness, $in_0$ is set to a black image and $x > 1$. To change contrast, $in_0$ is set to a gray image of the average luminance value of $in_1$. Decreasing $x$ (toward the gray image) decreases contrast; increasing $x$ increases contrast. Saturation may be varied using a luminance version of $in_1$ as $in_0$. (For information on converting RGB images to luminance, see Section 13.2.4.) Sharpening may be accomplished by setting $in_0$ to a blurred version of $in_1$ [43].


next up previous contents
Next: 13.2.2 Pixel Scale and Up: 13.2 Colors and Color Previous: 13.2 Colors and Color   Contents
2001-01-10