Python script implementing the conversion between RGB colour space and Lab colour space.
It specifically accepts RGBC data as produced by the Adafruit TCS34725 RGB Color Sensor Module, but it can be modified to accept conventional RGB values.
The maths behind the matrix conversion is explained at this site and on Wikipedia at this page.
Example usage: L,a,b = rgb2lab(140,107,96,255, illuminant='D50')