Specifications

Image Arithmetic and Logical Operations
5-23
5
The above operation is done for each color channel in A, B, and C. When the
images A and B contain pre-multiplied alpha values, C is determined as
C=A+(1- α
A
)*B
The resultant alpha value
aC
(alpha in the resultant image C) is computed
as (both pre-multiplied and not pre-multiplied alpha cases) from
aA
(alpha
in the source image A) and
aB
(alpha in the source image B):
α
C
= α
A
+(1-[α
A
)*α
B
Thus, to perform an OVER operation, use the IPL_COMPOSITE_OVER
identifier for the argument
compositeType
. For all other types, use
IPL_COMPOSITE_IN, IPL_COMPOSITE_OUT, IPL_COMPOSITE_ATOP,
IPL_COMPOSITE_XOR,and IPL_COMPOSITE_PLUS, respectively.
The argument
divideMode
is typically set to false to give adequate results
as shown in the above example for an OVER operation and in Table 5-2.
When
divideMode
is set to true, the resultant pixel color is divided by the
resultant alpha value. This gives an accurate result pixel value, but the
division operation is expensive. In terms of the OVER example without
pre-multiplication, the final value of the pixel C is computed as
C=(α
A
*A+(1- α
A
)*α
B
*B)/α
C
There is no change in the value of α
C
, and it is computed as shown above.
When both A and B are 100% transparent (that is, α
A
is zero and α
B
is
zero), α
C
is also zero and the result cannot be determined. In many cases,
the value of α
C
is 1, so the division has no effect.