cpercep.c: The CPercep Functions v0.9: 2002-02-10 Adam D. Moss: adam@gimp.org This code module concerns itself with conversion from a hard-coded RGB colour space (sRGB by default) to CIE L*a*b* and back again with (primarily) precision and (secondarily) speed, oriented largely towards the purposes of quantifying the PERCEPTUAL difference between two arbitrary RGB colours with a minimum of fuss. Motivation One: The author is disheartened at the amount of graphics processing software around which uses weighted or non-weighted Euclidean distance between co-ordinates within a (poorly-defined) RGB space as the basis of what should really be an estimate of perceptual difference to the human eye. Certainly it's fast to do it that way, but please think carefully about whether your particular application should be tolerating sloppy results for the sake of real-time response. Motivation Two: Lack of tested, re-usable and free code available for this purpose. The difficulty in finding something similar to CPercep with a free license motivated this project; I hope that this code also serves to illustrate how to perform the R'G'B'->XYZ->L*a*b*->XYZ->R'G'B' transformation correctly since I was distressed to note how many of the equations and code snippets on the net were omitting the reverse transform and/or were using incorrectly-derived or just plain wrong constants. TODO: document functions, rename erroneously-named arguments