diff --git a/rtengine/curves.cc b/rtengine/curves.cc index 04a1e0f9d..a8a99e210 100644 --- a/rtengine/curves.cc +++ b/rtengine/curves.cc @@ -1033,7 +1033,7 @@ void CurveFactory::complexCurvelocal(double ecomp, double black, double hlcompr, const float slope = 1.055 * powf(start, 1.0 / gamma_ - 1) - 0.055 / start; const float mul = 1.055; const float add = 0.055; - float maxran = 32768.f; //65536 + float maxran = 65536.f; //65536 ecomp /= 100.;//for mip files in integer * 100 @@ -1049,7 +1049,7 @@ void CurveFactory::complexCurvelocal(double ecomp, double black, double hlcompr, std::unique_ptr brightcurve; - // check if brightness curve is needed + // check if brightness curve is needed ==> never in this case if (br > 0.00001 || br < -0.00001) { std::vector brightcurvePoints(9); @@ -1149,8 +1149,8 @@ void CurveFactory::complexCurvelocal(double ecomp, double black, double hlcompr, shCurve[0] = CLIPD(val2) / val; // gamma correction - // val = Color::gammatab_srgb[0] / maxran; - val = Color::gammatab_srgb327[0] / 32767.f; + val = Color::gammatab_srgb[0] / maxran; + // val = Color::gammatab_srgb327[0] / 32767.f; // apply brightness curve if (brightcurve) { @@ -1169,8 +1169,8 @@ void CurveFactory::complexCurvelocal(double ecomp, double black, double hlcompr, shCurve[i] = val2 / val; // gamma correction - // val = Color::gammatab_srgb[i] / maxran; - val = Color::gammatab_srgb327[i] / 32767.f; + val = Color::gammatab_srgb[i] / maxran; + // val = Color::gammatab_srgb327[i] / 32767.f; // apply brightness curve if (brightcurve) { @@ -1187,7 +1187,7 @@ void CurveFactory::complexCurvelocal(double ecomp, double black, double hlcompr, //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - // check if contrast curve is needed + // check if contrast curve is needed ==> never in this case if (contr > 0.00001 || contr < -0.00001) { // compute mean luminance of the image with the curve applied diff --git a/rtengine/curves.h b/rtengine/curves.h index a20b0e42d..d12e60930 100644 --- a/rtengine/curves.h +++ b/rtengine/curves.h @@ -279,28 +279,6 @@ public: } } - static inline float hlcurveloc(const float exp_scale, const float comp, const float hlrange, float level, float niv) - { - if (comp > 0.0) { - float val = level + (hlrange - niv);//655536 32768 - - if (val == 0.0f) { // to avoid division by zero - val = 0.000001f; - } - - float Y = val * exp_scale / hlrange; - Y *= comp; - - if (Y <= -1.0) { // to avoid log(<=0) - Y = -.999999f; - } - - float R = hlrange / (val * comp); - return log1p(Y) * R; - } else { - return exp_scale; - } - } public: static void complexCurve(double ecomp, double black, double hlcompr, double hlcomprthresh, double shcompr, double br, double contr, diff --git a/rtengine/dcrop.cc b/rtengine/dcrop.cc index 28dbb14c5..a19bb48d1 100644 --- a/rtengine/dcrop.cc +++ b/rtengine/dcrop.cc @@ -904,9 +904,9 @@ void Crop::update(int todo) LUTf sklocalcurve2(65536, 0); bool localexutili = parent->localexutili; LUTf exlocalcurve2(65536, 0); - LUTf hltonecurveloc2(32768, 0); //65536 - LUTf shtonecurveloc2(32768, 0); - LUTf tonecurveloc2(32768, 0); + LUTf hltonecurveloc2(65536, 0); //65536 + LUTf shtonecurveloc2(65536, 0); + LUTf tonecurveloc2(65536, 0); bool LHutili = parent->LHutili; bool HHutili = parent->HHutili; diff --git a/rtengine/improccoordinator.cc b/rtengine/improccoordinator.cc index 26ab8f6cc..86c84601d 100644 --- a/rtengine/improccoordinator.cc +++ b/rtengine/improccoordinator.cc @@ -61,9 +61,9 @@ ImProcCoordinator::ImProcCoordinator() cclocalcurve(65536, 0), sklocalcurve(65536, 0), exlocalcurve(65536, 0), - hltonecurveloc(32768, 0), //32768 - shtonecurveloc(32768, 0), - tonecurveloc(32768, 0), + hltonecurveloc(65536, 0), //32768 + shtonecurveloc(65536, 0), + tonecurveloc(65536, 0), cl2Toningcurve(65536, 0), Noisecurve(65536, 0), NoiseCCcurve(65536, 0), diff --git a/rtengine/iplocallab.cc b/rtengine/iplocallab.cc index aba77cf59..0e88ed5a4 100644 --- a/rtengine/iplocallab.cc +++ b/rtengine/iplocallab.cc @@ -1688,7 +1688,7 @@ void ImProcFunctions::vibrancelocal(int bfw, int bfh, LabImage* lab, LabImage* void ImProcFunctions::exlabLocal(const local_params& lp, int bfh, int bfw, LabImage* bufexporig, LabImage* lab, LUTf & hltonecurve, LUTf & shtonecurve, LUTf & tonecurve) { - float maxran = 32768.f; //65536 + float maxran = 65536.f; //65536 const float exp_scale = pow(2.0, lp.expcomp); //lp.expcomp const float comp = (max(0.0, lp.expcomp) + 1.0) * lp.hlcomp / 100.0; const float shoulder = ((maxran / max(1.0f, exp_scale)) * (lp.hlcompthr / 200.0)) + 0.1; @@ -1730,7 +1730,7 @@ void ImProcFunctions::exlabLocal(const local_params& lp, int bfh, int bfw, LabIm for (int i = istart, ti = 0; i < tH; i++, ti++) { for (int j = jstart, tj = 0; j < tW; j++, tj++) { - Ltemp[ti * TSE + tj] = 2.f * bufexporig->L[i][j]; + Ltemp[ti * TSE + tj] = bufexporig->L[i][j]; atemp[ti * TSE + tj] = bufexporig->a[i][j]; btemp[ti * TSE + tj] = bufexporig->b[i][j];; } @@ -1743,7 +1743,7 @@ void ImProcFunctions::exlabLocal(const local_params& lp, int bfh, int bfw, LabIm for (int j = jstart, tj = 0; j < tW; j++, tj++) { float L = Ltemp[ti * TSE + tj]; - float tonefactor = (L < MAXVALF ? hltonecurve[L] : CurveFactory::hlcurveloc(exp_scale, comp, hlrange, L, niv)); + float tonefactor = (2*L < MAXVALF ? 0.5f*hltonecurve[2*L] : 0.5f*CurveFactory::hlcurve(exp_scale, comp, hlrange, 2*L));// niv)); Ltemp[ti * TSE + tj] = L * tonefactor; } } @@ -1754,7 +1754,7 @@ void ImProcFunctions::exlabLocal(const local_params& lp, int bfh, int bfw, LabIm float L = Ltemp[ti * TSE + tj]; //shadow tone curve float Y = L; - float tonefactor = shtonecurve[Y]; + float tonefactor = 0.5f*shtonecurve[2*Y]; Ltemp[ti * TSE + tj] = Ltemp[ti * TSE + tj] * tonefactor; } } @@ -1791,7 +1791,7 @@ void ImProcFunctions::exlabLocal(const local_params& lp, int bfh, int bfw, LabIm for (int i = istart, ti = 0; i < tH; i++, ti++) { for (int j = jstart, tj = 0; j < tW; j++, tj++) { - lab->L[i][j] = 0.5f * Ltemp[ti * TSE + tj]; + lab->L[i][j] = Ltemp[ti * TSE + tj]; lab->a[i][j] = atemp[ti * TSE + tj]; lab->b[i][j] = btemp[ti * TSE + tj]; } @@ -6795,7 +6795,7 @@ void ImProcFunctions::Expo_vibr_Local(int senstype, float **buflight, float **bu if (rchro < kcr && chromaref > kcr) { // reduce artifacts in grey tones near hue spot and improve algorithm falL *= pow(rchro / kcr, lp.iterat / 10.f); } - + if(varsens > 99.f) {falu = 1.f; kch=1.f; fach=1.f; } if (rL > 0.1f) { //to avoid crash with very low gamut in rare cases ex : L=0.01 a=0.5 b=-0.9 switch (zone) { diff --git a/rtengine/simpleprocess.cc b/rtengine/simpleprocess.cc index 2b724bbec..86eee5ae9 100644 --- a/rtengine/simpleprocess.cc +++ b/rtengine/simpleprocess.cc @@ -1088,10 +1088,10 @@ private: LUTf lllocalcurve(65536, 0); LUTf cclocalcurve(65536, 0); LUTf sklocalcurve(65536, 0); - LUTf hltonecurveloc(32768, 0); - LUTf shtonecurveloc(32768, 0); - LUTf tonecurveloc(32768, 0); - LUTf exlocalcurve(32768, 0); + LUTf hltonecurveloc(65536, 0); + LUTf shtonecurveloc(65536, 0); + LUTf tonecurveloc(65536, 0); + LUTf exlocalcurve(65536, 0); // int realspot = params.locallab.nbspot; int maxspot = settings->nspot + 1; ifstream fic0(datalab, ios::in);