Specifications
Intel
®
Image Processing Library Reference Manual
5-18
5
Using Pre-multiplied Alpha Values
In many cases it is computationally more efficient to store the color
channels pre-multiplied by the alpha values. In the RGBA example, the
pixel (r, g, b, α) would actually be stored as (r*α,g*α,b*α, α). This
storage format reduces the number of multiplications required in the
compositing operations. In interactive environments, when an image is
composited many times, this capability is especially efficient.
One known disadvantage of the pre-multiplication is that once a pixel is
marked as transparent, its color value is gone because the pixel’s color
channels are multiplied by 0.
The function
iplPreMultiplyAlpha() implements various alpha
compositing operations between two images. One of them is converting the
pixel values to pre-multiplied form.
The color channels in images with the alpha channel can be optionally pre-
multiplied with the alpha value. This saves a significant amount of
computation for some of the alpha compositing operations. For example, in
an RGBA color model image, if (r, g, b, α) are the channel values for a
pixel, then upon pre-multiplication they are stored as (r*α,g*α,b*α,[α).
AlphaComposite
AlphaCompositeC
Composite two images using
alpha (opacity) values.
void iplAlphaComposite(IplImage*
srcImageA
, IplImage*
srcImageB
, IplImage*
dstImage
, int
compositeType
,
IplImage*
alphaImageA
, IplImage*
alphaImageB
, IplImage*
alphaImageDst
, BOOL
premulAlpha
, BOOL
divideMode
);