Graphics Reference
In-Depth Information
showing the background has mask value 0, and a pixel at the edge (e.g., in the
actor's hair) has some intermediate value.
In computer graphics, we often perform similar operations: We generate a
rendering of some scene, and we want to place other objects (which we also ren-
der) into the scene after the fact. Porter and Duff [PD84] gave the first published
description of the details of these operations, but they credit the ideas to prior
work at the New York Institute of Technology. Fortunately, in computer graphics,
as we render these foreground objects we can usually compute the mask value at
the same time, rather than having to estimate it; after all, we know the exact geom-
etry of our object and the virtual camera. The mask value in computer graphics
is typically denoted by the letter
α
so that pixels are represented by a 4-tuple
( R , G , B ,
α
) . Images with pixels of this form are referred to as RGBA images and
as RGB
images.
Porter and Duff [PD84] describe a wide collection of image composition oper-
ations; we'll follow their development after first concentrating on the single oper-
ation described above: If U and V are images, the image “ U over V ” corresponds
to “actor over (i.e., in front of) situation.”
α
17.4.1 The Meaning of a Pixel During Image
Compositing
The value
represents the opacity of a single pixel of the image. If we regard the
image as being composed of tiny squares, then
α
= 0.75 for some square tells us
that the square is three-quarters covered by some object (i.e., 3/4 opaque) but 1/4
uncovered (i.e., 1/4 transparent). Thus, if our rendering is of an object consisting
of a single pure-red triangle whose interior covers three-quarters of some pixel,
the
α
-value for that pixel would be 0.75, while the R value would indicate the
intensity of the red light from the object, and G and B would be zero.
With a single number,
α
, we cannot indicate anything more than the opacity;
we cannot, for instance, indicate whether it is the left or the right half of the pixel
that is most covered, or whether it's covered in a striped or polka-dot pattern. We
therefore make the assumption that the coverage is uniformly distributed across
the pixel: If you picked a point at random in the pixel, the probability that it is
opaque rather than transparent is
α
. We make the further assumption that there is
no correlation between these probabilities in the two images; that is, if
α
α U = 0.5
and
α V = 0.75, then the probability that a random point is opaque in both images
is 0.5
0.75 = 0.375, and the probability that it is transparent in both is 0.125.
The red, green, and blue values represent the intensity of light that would arise
from the pixel if it were fully opaque, that is, if
·
α
= 1.
17.4.2 Computing U over V
Because compositing is performed one pixel at a time, we can illustrate our com-
putation with a single pixel. Figure 17.3 shows an example in which
α U = 0.4
α V = 0.3. The fraction of the image covered by both is 0.4
·
0.3 = 0.12,
and
while the fraction covered by V but not U is 0.6
·
0.3 = 0.18.
To compute U over V , we must assign both an
α
-value and a color to the resul-
tant pixel. The coverage,
, will be 0.4 + 0.18, representing that all the opaque
parts of U persist in the composite, as do the parts of V not obscured by U .In
more generality, we have
α
 
 
 
Search WWH ::




Custom Search