diff --git a/rtengine/curves.cc b/rtengine/curves.cc index 5a5b93d2a..df2696fff 100644 --- a/rtengine/curves.cc +++ b/rtengine/curves.cc @@ -622,47 +622,6 @@ void CurveFactory::complexCurve (double ecomp, double black, double hlcompr, dou //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // tone curve base. a: slope (from exp.comp.), b: black, def_mul: max. x value (can be>1), hr,sr: highlight,shadow recovery - /* - std::vector basecurvePoints; - basecurvePoints.push_back((double)((CurveType)NURBS)); - float blackx = MIN(1,black/(a*def_mul)); - float whitex = 1/(a*def_mul);//point in x at which line of slope a*def_mul starting at (0,0) reaches y=1 - float toneslope=(1-0)/(shoulderx-toex); - toey = 0.01 + 0.3*(MAX(0,shcompr/100.0-0.25)); - toex = blackx + toey/toneslope; - if (whitex<1) {//a>1; positive EC - //move shoulder down if there is highlight rolloff - shouldery = 1-(0.3)*(MAX(0,hlcompr/100.0-0.25)); - shoulderx = whitex - (1-shouldery)/toneslope; - } else {//a<1; negative EC - //if (shoulderx>1) { - shoulderx = 1; - shouldery = a*def_mul; - } - - basecurvePoints.push_back(MAX(0,blackx*(1-shcompr/25.0))); //black point. Value in [0 ; 1] range - basecurvePoints.push_back(0); //black point. Value in [0 ; 1] range - - basecurvePoints.push_back(toex); //toe point - basecurvePoints.push_back(toey); //value at toe point - - if (toex<1) { - //add a point along the line between the toe point and shoulder point - basecurvePoints.push_back(0.4*toex+0.6*shoulderx); //mid point - basecurvePoints.push_back(0.4*toey+0.6*shouldery); //value at mid point - - basecurvePoints.push_back(shoulderx); //shoulder point - basecurvePoints.push_back(shouldery); //value at shoulder point - if (shoulderx<1) { - basecurvePoints.push_back(MIN(0.99,whitex+0.01+(1-whitex-0.01)*(hlcompr/70.0)); // lead into white point - basecurvePoints.push_back(1); // value near white point - basecurvePoints.push_back(1); // white point - basecurvePoints.push_back(1); // value at white point - } - } - Curve* basecurve = NULL; - basecurve = new Curve (basecurvePoints, CURVES_MIN_POLY_POINTS/skip); // Actually, CURVES_MIN_POLY_POINTS = 1000, - */ //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% std::vector brightcurvePoints; @@ -702,7 +661,6 @@ void CurveFactory::complexCurve (double ecomp, double black, double hlcompr, dou // apply base curve, thus, exposure compensation and black point with shadow and highlight protection val = basecurve (val*def_mul, a, 0, def_mul, hlcompr/100.0, 0); //val = basecurve (val*def_mul, a, black, def_mul, hlcompr/100.0, 1.5*shcompr/100.0); - //val = basecurvenew->getVal (val); hlCurve[i] = (65535.0 * CLIPD(val)); @@ -710,7 +668,7 @@ void CurveFactory::complexCurve (double ecomp, double black, double hlcompr, dou // change to [0,1] range val = (double)i / 65535.0; - val = basecurve (val, 1, black, def_mul, 1, 1.5*shcompr/100.0); + val = basecurve (val, 1, black, 1, 0, 1.5*shcompr/100.0); shCurve[i] = (65535.0 * CLIPD(val)); } @@ -721,7 +679,6 @@ void CurveFactory::complexCurve (double ecomp, double black, double hlcompr, dou // change to [0,1] range double val = (double)i / 65535.0; float val0 = val; - float cum = (int)shCurve[(int)(hlCurve[i])]; // gamma correction if (gamma_>0) @@ -751,8 +708,6 @@ void CurveFactory::complexCurve (double ecomp, double black, double hlcompr, dou dcurve[i] = CLIPD(val); } delete tcurve; - - //delete basecurvenew; // ...when you don't need it anymore delete brightcurve; // if skip>1, let apply linear interpolation in the skipped points of the curve diff --git a/rtengine/curves.h b/rtengine/curves.h index c9bad3d37..0330863e4 100644 --- a/rtengine/curves.h +++ b/rtengine/curves.h @@ -103,13 +103,13 @@ class CurveFactory { else return y*clower2(x/m, slope*m/y, 2.0-sr); } else { - double m = a>1 ? b+0.25*(1-b)/a : b+(1-b)/4; - double y = a>1 ? 0.25 : 0.25*a; double slope = a/(1-b); + double m = a*D>1 ? b/a+(0.25+0.75*(1-1/D))/slope : b+(1-b)/4; + double y = a*D>1 ? 0.25 : (m-b/a)*slope; if (x<=m) - return b==0 ? x*a : clower (x/m, slope*m/y, sr) * y; - else if (a>1) - return y+(1.0-y)*cupper2((x-m)/(1-m), slope*(1-m)/(1.0-y), hr); + return b==0 ? x*slope : clower (x/m, slope*m/y, sr) * y; + else if (a*D>1) + return y+(1.0-y)*cupper2((x-m)/(D-m), slope*(D-m)/(1.0-y), hr); else return y+(x-m)*slope; } diff --git a/rtengine/improccoordinator.cc b/rtengine/improccoordinator.cc index 9483955e5..7664ffb7c 100644 --- a/rtengine/improccoordinator.cc +++ b/rtengine/improccoordinator.cc @@ -375,10 +375,15 @@ void ImProcCoordinator::updateHistograms (int x1, int y1, int x2, int y2) { memset (rhist, 0, 256*sizeof(int)); memset (ghist, 0, 256*sizeof(int)); memset (bhist, 0, 256*sizeof(int)); + + memset (bcrgbhist, 0, 256*sizeof(int)); + memset (bcLhist, 0, 256*sizeof(int)); for (int i=y1; idata[ofs]+587*previmg->data[ofs+1]+114*previmg->data[ofs+2]),0,255000)/1000; + bcrgbhist[Y]++; rhist[previmg->data[ofs++]]++; ghist[previmg->data[ofs++]]++; bhist[previmg->data[ofs++]]++; @@ -387,8 +392,10 @@ void ImProcCoordinator::updateHistograms (int x1, int y1, int x2, int y2) { memset (Lhist, 0, 256*sizeof(int)); for (int i=y1; iL[i][j]/256]++; + bcLhist[nprevl->L[i][j]/256]++; + } /*for (int i=0; i<256; i++) { Lhist[i] = (int)(256*sqrt(Lhist[i]));