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
 IERGB2CIELAB or IeCielab2rgb wrong ?
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

klausdoege

Germany
389 Posts

Posted - Jan 03 2017 :  07:23:34  Show Profile  Reply
Hello,
i try to check the correct convert from RGB to Lab and back.
But i becomme different results siehe attached file.
For example RGB(0,0,10) ->LAb -> RGB = RGB(0,0,7)
Here my Test procedure.
What can i do ?


procedure TForm1.Button1Click(Sender: TObject);
var
  x,y,z, R, G, B, v: integer;
  ielab: TCielab;
  iergb: hyiedefs.TRGB;
begin
     memo3.Clear;

     for R := 0 to 15 do
      for G := 0 to 15 do
        for B := 0 to 15 do
        begin
          iergb.r := r;
          iergb.g := g;
          iergb.b := b;
          ielab := IERGB2CIELAB(iergb);
          rgbcolor := IeCielab2rgb(ielab);
          if (iergb.r <> rgbcolor.r) or
             (iergb.g <> rgbcolor.g) or
             (iergb.b <> rgbcolor.b) then
         begin
            memo3.Lines.Add('RGB :'+ inttostr(r)+','+inttostr(g)+','+
                                     inttostr(b)+' <> '+
                                     inttostr(rgbcolor.r)+','+
                                     inttostr(rgbcolor.g)+','+
                                     inttostr(rgbcolor.b));
         end;






Klaus
www.klausdoege.de

xequte

38611 Posts

Posted - Jan 03 2017 :  21:26:03  Show Profile  Reply
Hi Klaus

If you look at the source for IECIELAB2RGB, you will note that it is subject to rounding errors, so exact 1:1 conversion is not possible.



Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

klausdoege

Germany
389 Posts

Posted - Jan 09 2017 :  08:19:28  Show Profile  Reply
Hi Nigel,
i have function IERGB2CIELAB(rgb: TRGB): TCIELAB;
change, now it's a much better.
Here my changing, i have add only 0.2 to L.


 if (Y > 0.008856) then
  begin
    fY := IEPower2(Y, 1.0/3.0);
    // ################## +0.2 
    L := 116.0*fY - 16.0 +0.2;
  end
  else
  begin
    fY := 7.787*Y + 16.0/116.0;
    // ############# + 0.2
    L := 903.3*Y+ 0.2;
  end;



Klaus
www.klausdoege.de
Go to Top of Page

xequte

38611 Posts

Posted - Jan 09 2017 :  19:34:13  Show Profile  Reply
Hi Klaus

Is this change based on your testing, or format documentation?



Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

klausdoege

Germany
389 Posts

Posted - Jan 13 2017 :  04:46:49  Show Profile  Reply
Hi Nigel,
it's only my testing, but i have make a new test with more values.
And then is your formula the best, with minimum difference.
My idea with +0.2 it's not better.
Sorry but forget it. All is OK so.


Klaus
www.klausdoege.de
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: