Hi Richard,

Back from holidays. I realize this message is quite old, so I apologize...

Ok, There was a reason to limit the tone curve plug-in and disallow the 
file IO. It happens that the file format is defined by the ICC (and only 
by the ICC!), so any addition made by anyone else would turn the profile 
in not compliant, and I'm afraid many CCM will just discard it. So the 
plug-in feature allows you to create new tone curves and play with those 
tone curves in pipelines, evaluators, etc. but keeping in mind this is 
only for data handling and not to be saved as a profile. An example 
would be to create a special tone curve for a profiler to be used to 
compute LUT points, the points then are meant be saved as a CLUT in the 
final profile but the math curve is not.

But anyway, I think there is a clean way to do what you wish, and this 
needs only a few math.
It seems to me the issue comes because parametric 5 is in the form

(a*x)^g

and you need

a*(x)^g

But nothing prevents you to compute a new a' instead

a'=a^(1/g)


See below the parameters disposition

     params[0] = 0.45; /* y */
     params[1] = pow(1.099, 1.0 / 0.45); /* a' */
     params[2] = 0.0; /* b */
     params[3] = 4.5; /* c */
     params[4] = 0.018; /* d */
     params[5] = -0.099; /* e */
     params[6] = 0.0; /* f */


I've checked this against the "normal" Rec709, and it works at 16 bits 
precision. See the testing code below. Sorry again for the delay

Regards
Marti
-----

static
double Rec709(double L)
{
     if (L <0.018) return 4.5*L;
     else
     {
           double a = 1.099* pow(L, 0.45);

           a = a - 0.099;
           return a;
     }
}


static
cmsInt32Number CheckParametricRec709(void)
{
     cmsFloat64Number params[7];
     cmsToneCurve* t;
     int i;

     params[0] = 0.45; /* y */
     params[1] = pow(1.099, 1.0 / 0.45); /* a */
     params[2] = 0.0; /* b */
     params[3] = 4.5; /* c */
     params[4] = 0.018; /* d */
     params[5] = -0.099; /* e */
     params[6] = 0.0; /* f */

     t = cmsBuildParametricToneCurve (NULL, 5, params);


     for (i=0; i < 256; i++)
     {
         cmsUInt16Number f1 = floor(255.0*cmsEvalToneCurveFloat(t, i / 
255.0) + 0.5);
         cmsUInt16Number f2 = floor(255.0*Rec709((double) i / 255.0) + 0.5);

         if (f1 != f2)
         {
                 return 0;
         }
     }

     return 1;
}




------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. SALE $99.99 this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122412
_______________________________________________
Lcms-user mailing list
Lcms-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lcms-user

Reply via email to