HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
(Premultiply or un-premultiply color by alpha)

Functions

ImageBuf OIIO_API ImageBufAlgo::unpremult (const ImageBuf &src, ROI roi={}, int nthreads=0)
 
bool OIIO_API ImageBufAlgo::unpremult (ImageBuf &dst, const ImageBuf &src, ROI roi={}, int nthreads=0)
 
ImageBuf OIIO_API ImageBufAlgo::premult (const ImageBuf &src, ROI roi={}, int nthreads=0)
 
bool OIIO_API ImageBufAlgo::premult (ImageBuf &dst, const ImageBuf &src, ROI roi={}, int nthreads=0)
 
ImageBuf OIIO_API ImageBufAlgo::repremult (const ImageBuf &src, ROI roi={}, int nthreads=0)
 
bool OIIO_API ImageBufAlgo::repremult (ImageBuf &dst, const ImageBuf &src, ROI roi={}, int nthreads=0)
 

Detailed Description

Premultiply or un-premultiply color by alpha

The unpremult operation returns (or copies into dst) the pixels of src within the ROI, and in the process divides all color channels (those not alpha or z) by the alpha value, to "un-premultiply" them. This presumes that the image starts of as "associated alpha" a.k.a. "premultipled," and you are converting to "unassociated alpha." For pixels with alpha == 0, the color values are not modified.

The premult operation returns (or copies into dst) the pixels of src within the ROI, and in the process multiplies all color channels (those not alpha or z) by the alpha value, to "premultiply" them. This presumes that the image starts of as "unassociated alpha" a.k.a. "non-premultipled" and converts it to "associated alpha / premultipled."

The repremult operation is like premult, but preserves the color values of pixels whose alpha is 0. This is intended for cases where you unpremult, do an operation (such as color transforms), then want to return to associated/premultiplied alpha – in that case, you want to make sure that "glow" pixels (those with alpha=0 but RGB > 0) are preserved for the round trip, and not crushed to black. This use case is distinct from a simple premult that is a one-time conversion from unassociated to associated alpha.

All three operations are simply a copy if there is no identified alpha channel (and a no-op if dst and src are the same image).

Function Documentation

ImageBuf OIIO_API ImageBufAlgo::premult ( const ImageBuf src,
ROI  roi = {},
int  nthreads = 0 
)
bool OIIO_API ImageBufAlgo::premult ( ImageBuf dst,
const ImageBuf src,
ROI  roi = {},
int  nthreads = 0 
)
ImageBuf OIIO_API ImageBufAlgo::repremult ( const ImageBuf src,
ROI  roi = {},
int  nthreads = 0 
)
bool OIIO_API ImageBufAlgo::repremult ( ImageBuf dst,
const ImageBuf src,
ROI  roi = {},
int  nthreads = 0 
)
ImageBuf OIIO_API ImageBufAlgo::unpremult ( const ImageBuf src,
ROI  roi = {},
int  nthreads = 0 
)
bool OIIO_API ImageBufAlgo::unpremult ( ImageBuf dst,
const ImageBuf src,
ROI  roi = {},
int  nthreads = 0 
)