i
i
i
i
i
i
i
i
474 10. Image-Based Effects
10.10 Color Correction
Color correction
8
is the process of taking an existing image and using some
function to convert each color to some other color (or not converting at
all). There are many reasons to color correct images or film, e.g., to mimic
the appearance of a specific kind of film stock, provide a coherent look
among elements, or to portray a particular mood or style. Color correction
typically consists of taking a single pixel’s RGB value as the input and
applying an algorithm to it to produce a new RGB. Another use is to
accelerate decoding video from, for example, the YUV color space to RGB.
More complex functions that rely on screen position or neighboring pixels
are possible [1148], but most operators use the color of each pixel as the
sole input. Some color correction functions treat each color separately,
i.e., the value of the red input is the only variable that affects the red
output channel. Others use all three channels as inputs that can affect each
output. The RGB to luminance conversion, Equation 7.11 on page 215, is
an example of the latter: All three inputs affect each output channel. In
this case, the output value is the same for all three outputs.
For a simple conversion such as luminance, a pixel shader program can
be applied with a screen-filling quadrilateral and the equation evaluated
directly. Simple formulae can perform basic operations such as scaling the
brightness or modifying saturation [476]. However, color correction func-
tions can be anything: complex mathematical functions or user-generated
tweaks and modifications. In addition, these functions can be mixed or
used multiple times. The final correction function can therefore be arbi-
trarily complex and so be expensive to apply in an interactive setting. On
the GPU, the normal solution for evaluating complex functions is to use a
look-up table (LUT). For a color correction function that has only one input
channel, the table can be one-dimensional. The input acts as the index into
the array, and the output value for that input is stored in the array. In
this way, any arbitrarily complex function for a single channel is reduced
to a constant-time lookup. Implementing this on the GPU is a matter of
storing the array in a texture. Given, say, 256 possible values for the input
color, a 1 × 256 texture is created to hold the output values. A texture
read is then used to access this array to perform the conversion [94].
When a color conversion uses three inputs, a three-dimensional LUT
of size 256
3
(more than 16 million texels) is usually out of the question.
If the color conversion function does not change rapidly between neigh-
boring values, a much smaller LUT array can be used, e.g., a cube of say
32
3
values. The resolution of the volume depends on the transform’s lin-
earity. The GPU’s texture sampling functionality can be used to perform
8
In film production, often called color grading or color timing.