Free output gamma see #issue679 and #issue672 with the help and advice of Michael and Olli
This commit is contained in:
@@ -898,6 +898,35 @@ void ImProcFunctions::colorCurve (LabImage* lold, LabImage* lnew) {
|
||||
b = ((rgb_xyz[2][0]*x + rgb_xyz[2][1]*y + rgb_xyz[2][2]*z)) ;
|
||||
|
||||
}
|
||||
|
||||
void ImProcFunctions::calcGamma (double pwr, double ts, int mode, int imax, double &gamma0, double &gamma1, double &gamma2, double &gamma3, double &gamma4, double &gamma5) {
|
||||
{//from Dcraw (D.Coffin)
|
||||
int i;
|
||||
double g[6], bnd[2]={0,0}, r;
|
||||
|
||||
g[0] = pwr;
|
||||
g[1] = ts;
|
||||
g[2] = g[3] = g[4] = 0;
|
||||
bnd[g[1] >= 1] = 1;
|
||||
if (g[1] && (g[1]-1)*(g[0]-1) <= 0) {
|
||||
for (i=0; i < 48; i++) {
|
||||
g[2] = (bnd[0] + bnd[1])/2;
|
||||
if (g[0]) bnd[(pow(g[2]/g[1],-g[0]) - 1)/g[0] - 1/g[2] > -1] = g[2];
|
||||
else bnd[g[2]/exp(1-1/g[2]) < g[1]] = g[2];
|
||||
}
|
||||
g[3] = g[2] / g[1];
|
||||
if (g[0]) g[4] = g[2] * (1/g[0] - 1);
|
||||
}
|
||||
if (g[0]) g[5] = 1 / (g[1]*SQR(g[3])/2 - g[4]*(1 - g[3]) +
|
||||
(1 - pow(g[3],1+g[0]))*(1 + g[4])/(1 + g[0])) - 1;
|
||||
else g[5] = 1 / (g[1]*SQR(g[3])/2 + 1
|
||||
- g[2] - g[3] - g[2]*g[3]*(log(g[3]) - 1)) - 1;
|
||||
if (!mode--) {
|
||||
gamma0=g[0];gamma1=g[1];gamma2=g[2];gamma3=g[3];gamma4=g[4];gamma5=g[5];
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ImProcFunctions::Lab2XYZ(float L, float a, float b, float &x, float &y, float &z) {
|
||||
float fy = (0.00862069 * L) + 0.137932; // (L+16)/116
|
||||
|
Reference in New Issue
Block a user