Performing Alpha Compositing Operations

Alpha compositing is a realm of image processing operations that blend two or more images to create a final composite image. The alpha channel defines the degree to which the various images are blended.

Quartz 2D and most modern video cards do an excellent job of alpha compositing. vImage provides these functions for completeness. Developers who want to do image compositing should understand the principles of alpha compositing.

This chapter describes how to use the alpha compositing functions in vImage. By reading this chapter, you’ll:

Alpha Compositing

Alpha compositing is a common image processing routine used to blend two or more images to create a final composite image. Alpha compositing is built upon the concept of layers — each image used in the composite image has a certain hierarchical layer. The image’s alpha channel determines how much of the images in layers underneath it can be seen at its own layer. In other words, the alpha channels control the transparency of the image, and alpha compositing uses the alpha channel to appropriately blend this image with another to exhibit this transparency. Figure 6-1 illustrates this concept.

Figure 6-1  Example of composited layers

Premultiplied Versus Non-Premultiplied Alpha Compositing

As with the commonly-used red, green, and blue channels, the alpha channel is a 2D array of pixel intensities. Depending on the image’s pixel format, its intensities may span the ranges of 0 to 255 (integers), or 0 to 1 (floats). In a premultiplied alpha composite, the values of the the alpha channel are multiplied to each of the of color channels, which alleviates the need to process the alpha channel any further. In a non-premultiplied alpha composite, the alpha channel still needs to be composited.