Developer Reference for Intel® Integrated Performance Primitives 2018

BGRToLab, RGBToLab

Converts a BGR or RGB image to the Lab color model.

Syntax

Case 1: BGR to Lab

IppStatus ippiBGRToLab_8u_C3R(const Ipp8u* pSrc, int srcStep, Ipp8u* pDst, int dstStep, IppiSize roiSize);

IppStatus ippiBGRToLab_8u16u_C3R(const Ipp8u* pSrc, int srcStep, Ipp16u* pDst, int dstStep, IppiSize roiSize);

IppStatus ippiBGRToLab_32f_C3R(const Ipp32f* pSrc, int srcStep, Ipp32f* pDst, int dstStep, IppiSize roiSize);

Case 2: RGB to Lab

IppStatus ippiRGBToLab_8u_C3R(const Ipp8u* pSrc, int srcStep, Ipp8u* pDst, int dstStep, IppiSize roiSize);

IppStatus ippiRGBToLab_32f_C3R(const Ipp32f* pSrc, int srcStep, Ipp32f* pDst, int dstStep, IppiSize roiSize);

Include Files

ippcc.h

Domain Dependencies

Headers: ippcore.h, ippvm.h, ipps.h, ippi.h

Libraries: ippcore.lib, ippvm.lib, ipps.lib, ippi.lib

Parameters

pSrc

Pointer to the source image ROI.

srcStep

Distance in bytes between starts of consecutive lines in the source image.

pDst

Pointer to the destination image ROI.

dstStep

Distance in bytes between starts of consecutive lines in the destination image.

roiSize

Size of the source and destination ROI in pixels.

Description

This function operates with ROI (see Regions of Interest in Intel IPP).

This function converts the BGR or RGB image pSrc to the CIE Lab image pDst, and vice versa. Conversion to Lab consists of two steps. First, the conversion is done into CIE XYZ format, using equations defined for the function ippiRGBToXYZ. After that, conversion to the Lab image is performed in accordance with the following equations:

L = 116. * (Y/Yn)1/3. - 16 for Y/Yn > 0.008856

L = 903.3 * (Y/Yn)1/3. for Y/Yn0.008856

a = 500. * [f(X/Xn)-f(Y/Yn)]

b = 200. * [f(Y/Yn)-f(Z/Zn)]

where



Here Yn = 1.0, Xn = 0.950455, Zn = 1.088753 for the D65 white point with the CIE chromaticity coordinates xn = 0.312713, yn = 0.329016.

The equations above are given on the assumption that initial B, G, R values are normalized to the range [0..1]. The computed values of the L component are in the range [0..100], a and b component values are in the range [-128..127].

These values are quantized and scaled to the 8-bit range of 0 to 255 for 8u_C3 flavors:

L = L * 255./100.

a = (a + 128.)

b = (a + 128.)

or to the 16-bit range of 0 to 65535 for ippiBGRToLab_8u16u_C3R:

L = L * 65535./100.

a = (a + 128.)* 255

b = (a + 128.)* 255

Return Values

ippStsNoErr

Indicates no error. Any other value indicates an error.

ippStsNullPtrErr

Indicates an error condition if pSrc or pDst is NULL.

ippStsSizeErr

Indicates an error condition if roiSize has a field with a zero or negative value.