Convert from BGR to Lab
MT
FwStatus | fwiBGRToLab_8u_C3R | ( | const Fw8u * pSrc, int srcStep, Fw8u * pDst, int dstStep, FwiSize roiSize ); | |
FwStatus | fwiBGRToLab_8u16u_C3R | ( | const Fw8u * pSrc, int srcStep, Fw16u * pDst, int dstStep, FwiSize roiSize ); |
dstStep | Destination buffer step size (width of the buffer in bytes). | |
pDst | Pointer to a location in a destination buffer. | |
pSrc | Pointer to a location in a source buffer. | |
roiSize | Specifies the height and width of an ROI. | |
srcStep | Source buffer step size (width of the buffer in bytes). |
These functions step through an ROI in a source buffer, convert the source data from the BGR color model to the Lab color space, and write the converted data to a destination buffer.
A gamma-corrected RGB image (pSrc) declared in the ROI is converted to a CIE Lab image (pDst) in two steps.
1. Normalize the data to [0 to 1] and convert RGB to XYZ using the following formulas. X = 0.412453*R + 0.35758 *G + 0.180423*B Y = 0.212671*R + 0.71516 *G + 0.072169*B Z = 0.019334*R + 0.119193*G + 0.950227*B The formulas assume that R, G, and B values are normalized to [0 to 1] for integer data types. For floating point data types, the data must already be in the range [0 to 1]. For integer data types, the converted image data is saturated to [0 to 1] and scaled to the data type range. For floating point data type, data is saturated to [0 to 1]. 2. Convert( ) XYZ To Lab as follows. D65 white point: Xn = 0.950455 Yn = 1.0 Zn = 1.088753 CIE chromaticity coordinates: xn = 0.312713 yn = 0.329016 if ((Y / Yn) > 0.008856) L = 116 * (Y/Yn)^(1/3) - 16 else L = 903.3 * (Y/Yn)^(1/3) a = 500 * [f(X/Xn) - f(Y/Yn)] b = 200 * [f(Y/Yn) - f(Z/Zn)] where if (t > 0.008856) f(t) = t^(1/3) - 16 else f(t) = 7.787*t + 16/116 The computed L, a, and b are in the range [0 to 100], [-128 to 127], and [-128b to 127], respectively. The computed image data is quantized and scaled to fit the 8-bit or 16-bit range. 8U data type: L = L * 255/100 a = a + 128 b = b + 128 16u data type: L = L * 65535 / 100 a = (a+128) * 255 b = (b+128) * 255