Hi Paul,

Just change the line 

 

value = (value * max)/numberOfEntries;      // normalize to gamma range

 

to

 

value = (value * max)/(numberOfEntries-1);      // normalize to gamma range

 

And you’ll get the same numbers….  The correct value for vInt at the end of
the loop is 65535.

 

Best regards,

Lorenzo

 

From: Paul Cezanne [mailto:p...@fineeyecolor.com] 
Sent: terça-feira, 28 de setembro de 2010 18:34
To: Lcms Liste
Subject: [Lcms-user] Bug in LPGAMMATABLE? (LCMS 1)

 

I'm looking at a 1% error in what I expect my gamma to be and now I'm
wondering if it is an LCMS bug! Run this program. 

 

#include "lcms.h"

 

int main (int argc, const char * argv[]) {

 

    const int numberOfEntries = 100;

 

    LPGAMMATABLE transferFunctionsDebug;

    transferFunctionsDebug = cmsBuildGamma(numberOfEntries, 1.0);

 

   int max = transferFunctionsDebug[0].GammaTable[numberOfEntries-1];

 

  float value;

    int vInt;

   

    for(int i =0; i < 100; i++) {

       value = i;                              // convert to float

     value = (value * max)/numberOfEntries;      // normalize to gamma range

     vInt = (int) (value + 0.5);

     

        fprintf(stdout, "%d\t%d\n", vInt,
transferFunctionsDebug->GammaTable[i]);

   }

}

 

I get this output:

 

0   0

655    662

1311 1324

...

62914    63549

63569  64211

64224  64873

64880  65535

 

I would have expected the columns to be the same. Does cmsBuildGamma not
build a perfectly linear LUT?

 

 

= 

------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
Lcms-user mailing list
Lcms-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lcms-user

Reply via email to