Chroma Key - Programming

Programming

There are several different quality- and speed-optimized techniques for implementing color keying in software.

In most versions, a function f(r, g, b) → α is applied to every pixel in the image. α (alpha) has a meaning similar to that in alpha compositing techniques. α ≤ 0 means the pixel is the green screen, α ≥ 1 means the pixel is in the foreground object. Values between 0 and 1 indicate a pixel that is partially covered by the foreground object. A usable green screen example, which matches how chroma key was done on an optical printer, is f(r, g, b) = K0 * bK1 * g + K2 (K0..2 are user-adjustable constants, 1 is a good initial guess for all of them).

Often the software does screen-spill removal from the colors as well as figure out the alpha. This may be a separate function g(r, g, b) → (r, g, b), a very simple green-screen example is g(r, g, b) → (r, min(g, b), b). Or f is changed to return (r, g, b, a) all at once, this is useful if part of the calculation is shared.

Most keyers use far more complicated functions. A popular approach is to describe a closed 3D surface in RGB space and determine the signed distance the point (r, g, b) is from this surface, or to find the distance the point (r, g, b) is between two closed nested surfaces. It is also very common for f to depend on more than just the current pixel's color, it may also use the (x, y) position, the values of nearby pixels, the value from reference images, and values from user-drawn masks.

A different class of algorithm tries to figure out a 2D path that separates the foreground from the background. This path can be the output, or the image can be drawn by filling the path with α = 1 as a final step. An example of such an algorithm is the use of active contour. Most research in recent years has been into these algorithms.

Read more about this topic:  Chroma Key

Famous quotes containing the word programming:

    If there is a price to pay for the privilege of spending the early years of child rearing in the driver’s seat, it is our reluctance, our inability, to tolerate being demoted to the backseat. Spurred by our success in programming our children during the preschool years, we may find it difficult to forgo in later states the level of control that once afforded us so much satisfaction.
    Melinda M. Marshall (20th century)