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

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 CIELAB system DeltaE values?

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
AndyColmes Posted - Jan 25 2013 : 14:00:26
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.
7   L A T E S T    R E P L I E S    (Newest First)
fab Posted - Feb 09 2013 : 05:34:33
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));
AndyColmes Posted - Feb 09 2013 : 03:04:38
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.
fab Posted - Feb 09 2013 : 02:33:06
I think you have enough info: just loop among the squares, getting pixels with Pixels_ieCIELab[] and calculate the avarege for each square.
AndyColmes Posted - Feb 04 2013 : 02:10:23
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.
fab Posted - Feb 01 2013 : 09:25:23
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?
AndyColmes Posted - Jan 28 2013 : 17:40:31
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.
fab Posted - Jan 28 2013 : 07:50:11
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.