I try...please re-check this code. Also I cannot guarantee that it works correctly or at all and I cannot support it!
All value types are double or extended, except for color1 and color2 that are TIECIELab.
color1 := ImageEnView1.IEBitmap.Pixels_ieCIELab[col, row];
color2 := ImageEnView2.IEBitmap.Pixels_ieCIELab[col, row];
// l and c from CMC(l:c), for example CMD(1:1) l = 1 and c = 1. Read the link for more info.
l := ….
c := ….
a1 := color1.a;
b1 := color1.b;
L1 := color1.L;
a2 := color2.a;
b2 := color2.b;
L2 := color2.L;
C1 := sqrt( sqr(a1) + sqr(b1) );
C2 := sqrt( sqr(a2) + sqr(b2) );
DeltaC := C1 - C2;
DeltaL := L1 - L2;
DeltaA := a1 - a2;
DeltaB := b1 - b2;
DeltaH := sqrt( sqr(DeltaA) + sqr(DeltaB) - sqr(DeltaC) );
if (a1 = 0) and (b1 > 0) then
H1 := Pi / 2
else if (a1 = 0) and (b1 < 0) then
H1 := -Pi / 2
else
H1 := ArcTan2(b1, a1);
H1 := RadToDeg(H1);
if H1 < 0 then
H1 := H1 + 360
else if H1 >= 360 then
H1 := H1 - 360;
if (H1 <= 345) and (H1 >= 164) then
T := 0.56 + abs(0.2 * cos(DegToRad(H1 + 168)))
else
T := 0.36 + abs(0.4 * cos(DegToRad(H1 + 35)));
F := sqrt( Power(C1, 4) / (Power(C1, 4) + 1900) );
if L1 < 16 then
SL := 0.511
else
SL := (0.040975 * L1) / (1 + 0.01765 * L1);
SC := (0.0638 * C1) / (1 + 0.0131 * C1) + 0.638;
SH := SC * (F * T + 1 - F);
DeltaE := sqrt( sqr(DeltaL / l * SL) + sqr(DeltaC / c * SC) + sqr(DeltaH / SH));