Intel® Integrated Performance Primitives Developer Guide and Reference

ID 790148
Date 11/07/2023
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

Alpha Composition

The Intel IPP provides functions that composite two image buffers using either the opacity (alpha) channel in the images or provided alpha values.

These functions operate on image buffers with 8-bit or 16-bit data in RGB or RGBA format. In all compositing operations a resultant pixel in destination buffer pDst is created by overlaying a pixel from the foreground image buffer pSrc1 over a pixel from the background image buffer pSrc2. The supported types of images combining by using alpha values are listed in the table below.

Types of Image Composing Operations

Type

 

Output Pixel

Description in Imaging Terms

 

Color Components

Alpha value

OVER

αA*A+(1- αA)* αB*B

αA+(1-αA)* αB

A occludes B

IN

αA*A*αB

αA*αB

A within B. A acts as a matte for B. A shows only where B is visible.

OUT

αA*A*(1-αB)

αA*(1-αB)

A outside B. NOT-B acts as a matte for A. A shows only where B is not visible.

ATOP

αA*A*αB+(1- αA)* αB*B

αA*αB+(1- αA)* αB

Combination of (A IN B) and (B OUT A). B is both back-ground and matte for A.

XOR

αA*A*(1-αB)+(1- αA)* αB*B

αA*(1-αB)+(1- αA)* αB

Combination of (A OUT B) and (B OUT A). A and B mutually exclude each other.

PLUS

αA*A+αB*B

αA+αB

Blend without precedence

In the formulas above, the input image buffers are denoted as A and B for simplicity. The Greek letter α with subscripts denotes the normalized (scaled) alpha value in the range 0 to 1. It is related to the integer alpha value alpha as:

α = alpha / max_val

where max_val is 255 for 8-bit or 65535 for 16-bit unsigned pixel data.

For the ippiAlphaComp function that operates on 4-channel RGBA buffers only, αA andαB are the normalized alpha values of the two input image buffers, respectively.

For the ippiAlphaCompC function, αA andαBare the normalized constant alpha values that are passed as parameters to the function.

Note that in formulas for computing the resultant color channel values, A and B stand for the pixel color components of the respective input image buffers.

To save a significant amount of computation for some of the alpha compositing operations, use functions AlphaPremul , AlphaPremulC for pre-multiplying color channel values by the alpha values. This reduces the number of multiplications required in the compositing operations, which is especially efficient for repeated compositing of an image.

The type of composition operation that is performed by the function AlphaComp and AlphaCompC is specified by the parameter alphaType, the table below lists its possible values.

Possible Values of alphaType Parameter

Operation types

Parameter Value

OVER

ippAlphaOver

ippAlphaOverPremul

IN

ippAlphaIn

ippAlphaInPremul

OUT

ippAlphaOut

ippAlphaOutPremul

ATOP

ippAlphaATop

ippAlphaATopPremul

XOR

ippAlphaXor

ippAlphaXorPremul

PLUS

ippAlphaPlus

ippAlphaPlusPremul