Interpreting Alpha

Associating alpha values with pixel colors is an important technique in computer graphics, allowing us to create complex composite images. However, the interpretation of the meaning of alpha is often a fluid concept, switching between coverage (a measure of area) and opacity (a measure of a color) based on convenience. It can appear very strange that a single number could represent both of these qualitatively different ideas at the same time – they don’t even have the same units!

By tracking coverage and opacity separately through the compositing process, we can see that alpha is actually the product of coverage and opacity, so it is only one of these terms if we assume that the other has the value 1. This leads to a simple and consistent understanding of the internal structure of pixels that are described by color and alpha.

To frame the problem, let’s first consider the picture at the left. It shows a partly transparent orange ellipse with an opacity 0.4, over a transparent background (represented by the classic white-and-gray checkerboard). I’ll use Ak to refer to a pixel’s coverage, and Ao to refer to its opacity.

The figure calls out three pixels: one fully inside the ellipse, one outside the ellipse, and one straddling an edge. The ellipse has an opacity of.4. The pixel inside the ellipse is fully covered, so Ak = 1, and its fragment has the opacity of the ellipse, so Ao = 0.4. The pixel in the upper-left is about 60% covered by the ellipse, so Ak = 0.6, and the opacity of the fragment inside that pixel is again the opacity of the ellipse, so Ao = 0.4. The pixel in the lower-right that is outside the ellipse is not covered at all, so Ak = 0. The opacity value Ao is moot, since there’s no fragment from which to derive an opacity value. In Figure 2, this Ao is given a value of x to indicate “don’t know” or “don’t care.”

Consider now the same three pixels in the figure on the right, where the ellipse is fully opaque.

In each pixel, the coverage Ak is the same as above. But the opacities of the two covered pixels are now both Ak = 1. That is, the partially covered pixel is only partly covered by its fragment, but that fragment is entirely opaque.

Modern renderers compute a value of alpha at each pixel by multiplying that pixel’s Ak and Ao together (assuming, as we are for the moment, that the pixel contains only one fragment). This satisfies common sense when handling a single fragment. For example, if a pixel is one-third-covered by an opaque fragment, then α = AkAo = (1/3) × 1. Similarly, if a pixel is completely covered by a one-third opaque fragment, the result is the same: α = AkAo = 1 × 1/3. And if a pixel is one-fifth covered by a fragment that is one-third opaque, then 20% of the pixel is blocking 33% of the color from beneath it, so α = AkAo = 0.2 ∗ 0.33 = .066. It’s this product of coverage and opacity that we are implicitly describing when we refer to a pixel’s “alpha.”

In the paper, I work through the math that shows that in all of these situations, alpha really is referring to the product of coverage and opacity. That leads to some fun interpretations. On the left are blowups of six different pixels. In each pixel, the alpha value is the same at 0.24 (well, not really – I drew these by hand to get the point across, but I didn’t scale them to set the alpha to exactly 0.24. That would be a fun little program to write). The point is that the opacity can change over the pixel, and coverage can change, but when we integrate each quality over the pixel and multiply the result, we get a single value that we call alpha.

The conclusion of the paper is that a pixel’s alpha actually represents the product of the total coverage and the total opacity. In the absence of additional information, we are free to distribute those qualities throughout the pixel in any way we want.

References

Glassner, Andrew S., “Interpreting Alpha,” Journal of Computer Graphics Techniques, Vol. 4, No. 2, 2015