Question

I don't understand how to convert sRGB to CIELab and backward. Help me please. it's desirable in с++ code

Was it helpful?

Solution

Convert from sRGB to RGB by applying inverse gamma, convert RGB to XYZ using 3x3 matrix, convert XYZ to Lab using standard formula and D6500 white point

References:

The rest... you can do on your own :-)

OTHER TIPS

In case, I have prepared a list of links (in different programming languages) which can be helpful for the conversion process (sRGB to LAB and back) and also, conversion of sRGB to linear RGB. Linear RGB can be further used for white balance and color calibration of an image (provided color patch, like Macbeth color chart).

Interesting links:

(i) Understanding sRGB and linear RGB space: http://filmicgames.com/archives/299; http://www.cambridgeincolour.com/tutorials/gamma-correction.htm

(ii) MATLAB tutorial: https://de.mathworks.com/help/vision/ref/colorspaceconversion.html

(iii) Python package: http://pydoc.net/Python/pwkit/0.2.1/pwkit.colormaps/

(iv) C code: http://svn.int64.org/viewvc/int64/colors/color.c?view=markup

(v) OpenCV does not provide sRGB to linear RGB conversion but it does the conversion inside color.cpp code (OpenCV_DIR\modules\imgproc\src\color.cpp). Check out method called initLabTabs(), there is a gamma encoding and decoding. OpenCV color conversion API: http://docs.opencv.org/3.1.0/de/d25/imgproc_color_conversions.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top