Graphic Delphi

Title: Color system conversion XYZ to LAB
Question: How to convert CIE Lab to XYZ?
Answer:
Procedure XYZtoLAB(X, Y, Z: Real; Var L, a, b: Real);
Const
// standart D65 illimunant 10 observer
Xn: Real = 94.82;
Yn: Real = 100;
Zn: Real = 107.38;
Begin
//
X := X / Xn; //inp_X = From 0 to ref_X
Y := Y / Yn; //inp_Y = From 0 to ref_Y
Z := Z / Zn; //inp_Z = From 0 to ref_Z
If (X 0.008856) Then
X := power(x, 1 / 3)
Else
X := (7.787 * X) + (16 / 116);
If (Y 0.008856) Then
Y := power(y, 1 / 3)
Else
Y := (7.787 * Y) + (16 / 116);
If (Z 0.008856) Then
Z := power(z, 1 / 3)
Else
Z := (7.787 * Z) + (16 / 116);
if Y0.008856 then L := (116 * Y) - 16 else L:=903.3*Y;
a := 500 * (X - Y);
b := 200 * (Y - Z);
End;