ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 CIELAB system DeltaE values?
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

AndyColmes

USA
351 Posts

Posted - Jan 25 2013 :  14:00:26  Show Profile  Reply
I've been asked to get DeltaE values of color differences in the CIELAB color system. I have no resource on this and I was wondering if ImageEn can help in any way regarding this. Currently, I use ImageEn to get the RGB values of a pixel area, but how do I get the DeltaE values?

Any help in this is very much appreciated.

Thanks.

fab

1310 Posts

Posted - Jan 28 2013 :  07:50:11  Show Profile  Reply
If you have a (for example) a TIFF with CIELab image, you can load it using:
ImageEnView.LegacyBitmap := false;
ImageEnView.IO.NativePixelFormat := true;
ImageEnView.IO.LoadFromFile('cielabimage.tiff');

Otherwise, you can load an RGB image and convert it to CIELab:
ImageEnView.LegacyBitmap := false;
ImageEnView.IO.LoadFromFile('rgbimage.jpg');
ImageEnView.IEBitmap.PixelFormat := ieCIELab;

Now you have a matrix of CIELab values, accessible with:
cielab := ImageEnView.IEBitmap.Pixels_ieCIELab[col, row];
Where cielab is a TCIELab variable (defined in hyieutils unit).

Of course you have to do it also for the other image to compare.

Having CIELab values, you can get the Delta E value applying one of the well known formulas, depends by the Delta E you want. Here is some useful links:

Delta E (CIE 1976): http://www.brucelindbloom.com/index.html?Eqn_DeltaE_CIE76.html
Delta E (CIE 1994): http://www.brucelindbloom.com/index.html?Eqn_DeltaE_CIE94.html
Delta E (CIE 2000): http://www.brucelindbloom.com/index.html?Eqn_DeltaE_CIE2000.html
Delta E (CMC): http://www.brucelindbloom.com/index.html?Eqn_DeltaE_CMC.html

Hope this helps.
Go to Top of Page

AndyColmes

USA
351 Posts

Posted - Jan 28 2013 :  17:40:31  Show Profile  Reply
Wow, thanks very much Fabrizio. ImageEn never ceases to amaze me.

I would appreciate it if you could help in getting any resource on how to apply the formulas in Delphi. Is there a Math component out there that can facilitate this?

Thanks again.
Go to Top of Page

fab

1310 Posts

Posted - Feb 01 2013 :  09:25:23  Show Profile  Reply
For the simplest Delta-E (CIE 1976) it is just:
deltaE := sqrt(sqr(L1-L2) + sqr(a1-a2) + sqr(b1-b2))

This calculates deltaE of a single pixel, at "col" and "row":

var c1, c2: TCIELab;
var deltaE: double;

c1 := ImageEnView1.IEBitmap.Pixels_ieCIELab[col, row];
c2 := ImageEnView2.IEBitmap.Pixels_ieCIELab[col, row];
deltaE := sqrt(sqr(c1.l-c2.l) + sqr(c1.a-c2.a) + sqr(c1.b-c2.b));

Do you need a single deltaE for the overall image, or a matrix (an image) of DeltaEs?
Go to Top of Page

AndyColmes

USA
351 Posts

Posted - Feb 04 2013 :  02:10:23  Show Profile  Reply
I would like to get a 3x3 or 5x5 pixel square and find the average DeltaEs. What would be the good way to do that? Thanks again, Fabrizio.
Go to Top of Page

fab

1310 Posts

Posted - Feb 09 2013 :  02:33:06  Show Profile  Reply
I think you have enough info: just loop among the squares, getting pixels with Pixels_ieCIELab[] and calculate the avarege for each square.
Go to Top of Page

AndyColmes

USA
351 Posts

Posted - Feb 09 2013 :  03:04:38  Show Profile  Reply
Thank you Fabrizio. I will try that.

Can you help with the formula for Delta E (CMC)? I think this is the formula that is needed for my application.

Thanks in advance.
Go to Top of Page

fab

1310 Posts

Posted - Feb 09 2013 :  05:34:33  Show Profile  Reply
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));
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: