What is compositing ?
• Compositing is a technique of combining two or
more images into a single scene.
• Note that the individual elements are disjoint in
depth
• Compositing is associative but not commutative.
• We use a mask (matte) for each image that tells us
what portions make it to the final scene.
Pre-multiplied Alpha’s
• Normally pixels are represented as (R,G,B, α ).
• During compositing operations, we frequently find
that colors need to be multiplied by the alpha
value
• We could pre-multiply the R,G,B values with
alpha, pixel represented by (r,g,b, α) where r= α
*R, g= α*G, b= α*B
Use Alpha Channel to store
Matte Info
• We could use a 1 bit mask…but what if we
want to combine antialiased images?
• Anitialiased images have soft edges which
we want preserved in the composite.
• We use the 8 bit Alpha channel to store
matte information.
• This allows us to capture fractional
occlusion.
Assumptions about subpixel
coverage
• When two images are combined, we have
no information about coverage within a
pixel.
• Unknown subpixel geometry information is
approximated using the alpha value.
• If A is an opaque object with alpha value
αA , then A divides the pixel in two areas in
the ratio αA:1- αA
Example: Subpixel view with αA=.5
● ● ● ●
● ● ● ●
Likewise, an opaque object B with alpha value αB,
divides the pixel in two areas in the ratio αB: 1- αB
+
+
+
+
Example: Subpixel view with αB=.25
If B and A are both combined, then we assume that B
will divide each of the subpixel areas inside and
outside of A in the same ratio αB:1- αB
●+ ● ● ●
●+ ● ● ●
+
+
Result of assumptions
Region Area
covered by:
A and B αA*αB
A but not B αA(1- αB)
B but not A αB(1- αA)
neither (1-αA)(1- αB)
●+ ● ● ●
αA(1- αB)
αB*αA
●+ ● ● ●
+
αB(1-αA)
+
(1-αA)(1- αB)
This assumption is valid only for uncorrelated mattes!
Note that B does NOT divide A in equal ratio, because A
and B are correlated.
Here the background is completely covered, though we
expected .25 of pixel to show the background.
Background Middle (B) α=.5 Foreground (A) α=.5
Table of Subpixel Areas
Region Name Possible choices
covered by: that can contribute
to composite
A and B AB A,B,0
A but not B A A,0
B but not A B B,0
neither 0 0
Compositing Operators
A binary compositing operation can be
defined as a quadruple indicating the input
picture which contributes to the composite
in each of the four subpixel areas.
• There are 12 possible quadruple
combinations. Thus 12 operations.
Composite Arithmetic: Alpha
for pixel
• Each input picture survives within its own matte
• For A, FA is the fraction of the matte that survives
in the composite pixel.
• For B, FB is the fraction of the matte that survives
in the composite pixel.
• Let alpha value of composite be αo
• Note that αo also represents the total fraction of
the pixel covered.
• Thus αo= FA*αA + FB*αB
Composite Arithmetic:
Average Color for pixel
• Average color for composite pixel=Color of
picture A, times its fraction FA
• +Color of picture B times its fraction FB
• Co= (αAFACA+ αBFBCB)/( FA*αA + FB*αB )
• co= αoCo= αAFACA+ αBFBCB= αAcA+ αBcB