diff --git a/rtengine/dcrop.cc b/rtengine/dcrop.cc index 72b57e453..ba65c20f6 100644 --- a/rtengine/dcrop.cc +++ b/rtengine/dcrop.cc @@ -1033,10 +1033,23 @@ void Crop::update (int todo) CurveFactory::curveLocal (locallutili, params.locallab.llcurve, lllocalcurve2, sca); localcutili = false; CurveFactory::curveCCLocal (localcutili, params.locallab.cccurve, cclocalcurve2, sca); + /* + params.locallab.hueref = (parent->huerefs[sp]) / 100.f; + params.locallab.chromaref = parent->chromarefs[sp]; + params.locallab.lumaref = parent->lumarefs[sp]; + */ - params.locallab.hueref = (parent->huerefs[sp]) / 100.f; - params.locallab.chromaref = parent->chromarefs[sp]; - params.locallab.lumaref = parent->lumarefs[sp]; + double huere, chromare, lumare; + // params.locallab.hueref = parent->huer; + // params.locallab.chromaref = parent->chromar; + // params.locallab.lumaref = parent->lumar; + // printf("dcr1 sp=%i huer=%f \n", sp,parent->huerefs[sp] / 100.f ); + parent->ipf.calc_ref (1, sp, (float**)shbuffer, labnCrop, labnCrop, trafx / skip, trafy / skip, cropx / skip, cropy / skip, skips (parent->fw, skip), skips (parent->fh, skip), parent->fw, parent->fh, locutili, skip, locRETgainCurve, locallutili, lllocalcurve2, loclhCurve, cclocalcurve2, huere, chromare, lumare); + + + params.locallab.hueref = huere ; //parent->huer; + params.locallab.chromaref = chromare; //parent->chromar; + params.locallab.lumaref = lumare; //parent->lumar; parent->ipf.Lab_Local (1, sp, (float**)shbuffer, labnCrop, labnCrop, trafx / skip, trafy / skip, cropx / skip, cropy / skip, skips (parent->fw, skip), skips (parent->fh, skip), parent->fw, parent->fh, locutili, skip, locRETgainCurve, locallutili, lllocalcurve2, loclhCurve, cclocalcurve2, params.locallab.hueref, params.locallab.chromaref, params.locallab.lumaref); lllocalcurve2.clear(); @@ -1270,11 +1283,21 @@ void Crop::update (int todo) CurveFactory::curveCCLocal (localcutili, params.locallab.cccurve, cclocalcurve2, sca); // skip == 1 ? 1 : 16); - params.locallab.hueref = (parent->huerefs[sp]) / 100.f; - params.locallab.chromaref = parent->chromarefs[sp]; - params.locallab.lumaref = parent->lumarefs[sp]; + // params.locallab.hueref = (parent->huerefs[sp]) / 100.f; + // params.locallab.chromaref = parent->chromarefs[sp]; + // params.locallab.lumaref = parent->lumarefs[sp]; + // printf("dcr2 sp=%i huer=%f \n", sp, parent->huerefs[sp] / 100.f); + + double huere, chromare, lumare; + parent->ipf.calc_ref (1, sp, (float**)shbuffer, labnCrop, labnCrop, trafx / skip, trafy / skip, cropx / skip, cropy / skip, skips (parent->fw, skip), skips (parent->fh, skip), parent->fw, parent->fh, locutili, skip, locRETgainCurve, locallutili, lllocalcurve2, loclhCurve, cclocalcurve2, huere, chromare, lumare); + + + params.locallab.hueref = huere; //parent->huer; + params.locallab.chromaref = chromare;//parent->chromar; + params.locallab.lumaref = lumare;//parent->lumar; + + parent->ipf.Lab_Local (1, sp, (float**)shbuffer, labnCrop, labnCrop, trafx / skip, trafy / skip, cropx / skip, cropy / skip, skips (parent->fw, skip), skips (parent->fh, skip), parent->fw, parent->fh, locutili, skip, locRETgainCurve, locallutili, lllocalcurve2, loclhCurve, cclocalcurve2, params.locallab.hueref, params.locallab.chromaref, params.locallab.lumaref); - parent->ipf.Lab_Local (1, sp, (float**)shbuffer, labnCrop, labnCrop, trafx / skip, trafy / skip, cropx / skip, cropy / skip, skips (parent->fw, skip), skips (parent->fh, skip), parent->getFullWidth(), parent->getFullHeight(), locutili2, skip, locRETgainCurve, locallutili, lllocalcurve2, loclhCurve, cclocalcurve2, params.locallab.hueref, params.locallab.chromaref, params.locallab.lumaref); lllocalcurve2.clear(); cclocalcurve2.clear(); diff --git a/rtengine/improccoordinator.cc b/rtengine/improccoordinator.cc index c9fc0c25d..b07de5171 100644 --- a/rtengine/improccoordinator.cc +++ b/rtengine/improccoordinator.cc @@ -40,19 +40,19 @@ extern const Settings* settings; ImProcCoordinator::ImProcCoordinator () : orig_prev (nullptr), oprevi (nullptr), oprevl (nullptr), nprevl (nullptr), previmg (nullptr), workimg (nullptr), - ncie (nullptr), imgsrc (nullptr), shmap (nullptr), lastAwbEqual (0.), lastAwbTempBias(0.0), ipf (¶ms, true), monitorIntent (RI_RELATIVE), + ncie (nullptr), imgsrc (nullptr), shmap (nullptr), lastAwbEqual (0.), lastAwbTempBias (0.0), ipf (¶ms, true), monitorIntent (RI_RELATIVE), softProof (false), gamutCheck (false), scale (10), highDetailPreprocessComputed (false), highDetailRawComputed (false), allocated (false), bwAutoR (-9000.f), bwAutoG (-9000.f), bwAutoB (-9000.f), CAMMean (NAN), coordX (0), coordY (0), localX (0), localY (0), dataspot (nullptr), retistr (nullptr), retistrsav (nullptr), llstr (nullptr), lhstr (nullptr), ccstr (nullptr), - /* -======= - : orig_prev(nullptr), oprevi(nullptr), oprevl(nullptr), nprevl(nullptr), previmg(nullptr), workimg(nullptr), + /* + ======= + : orig_prev(nullptr), oprevi(nullptr), oprevl(nullptr), nprevl(nullptr), previmg(nullptr), workimg(nullptr), ncie(nullptr), imgsrc(nullptr), shmap(nullptr), lastAwbEqual(0.), lastAwbTempBias(0.0), ipf(¶ms, true), monitorIntent(RI_RELATIVE), softProof(false), gamutCheck(false), scale(10), highDetailPreprocessComputed(false), highDetailRawComputed(false), allocated(false), bwAutoR(-9000.f), bwAutoG(-9000.f), bwAutoB(-9000.f), CAMMean(NAN), ->>>>>>> dev -*/ + >>>>>>> dev + */ ctColorCurve(), // localcurve(65536, 0), hltonecurve (65536), @@ -166,7 +166,9 @@ ImProcCoordinator::ImProcCoordinator () lumarefs (500, -100000.f), chromarefs (500, -100000.f), huerefs (500, -100000.f), - + huer (0), + chromar (0), + lumar (0), rCurve(), gCurve(), @@ -177,7 +179,7 @@ ImProcCoordinator::ImProcCoordinator () fw (0), fh (0), tr (0), fullw (1), fullh (1), pW (-1), pH (-1), - plistener (nullptr), imageListener (nullptr), aeListener (nullptr), acListener (nullptr), abwListener (nullptr), awbListener(nullptr), aloListener (nullptr), actListener (nullptr), adnListener (nullptr), awavListener (nullptr), dehaListener (nullptr), hListener (nullptr), + plistener (nullptr), imageListener (nullptr), aeListener (nullptr), acListener (nullptr), abwListener (nullptr), awbListener (nullptr), aloListener (nullptr), actListener (nullptr), adnListener (nullptr), awavListener (nullptr), dehaListener (nullptr), hListener (nullptr), resultValid (false), lastOutputProfile ("BADFOOD"), lastOutputIntent (RI__COUNT), lastOutputBPC (false), thread (nullptr), changeSinceLast (0), updaterRunning (false), destroying (false), utili (false), autili (false), wavcontlutili (false), butili (false), ccutili (false), cclutili (false), clcutili (false), opautili (false), conversionBuffer (1, 1), colourToningSatLimit (0.f), colourToningSatLimitOpacity (0.f) @@ -381,13 +383,13 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) imgsrc->getAutoWBMultipliers (rm, gm, bm); if (rm != -1.) { - autoWB.update(rm, gm, bm, params.wb.equal, params.wb.tempBias); + autoWB.update (rm, gm, bm, params.wb.equal, params.wb.tempBias); lastAwbEqual = params.wb.equal; lastAwbTempBias = params.wb.tempBias; } else { lastAwbEqual = -1.; lastAwbTempBias = 0.0; - autoWB.useDefaults(params.wb.equal); + autoWB.useDefaults (params.wb.equal); } //double rr,gg,bb; @@ -399,8 +401,9 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) params.wb.temperature = currWB.getTemp (); params.wb.green = currWB.getGreen (); - if(params.wb.method == "Auto" && awbListener) { - awbListener->WBChanged(params.wb.temperature, params.wb.green); + + if (params.wb.method == "Auto" && awbListener) { + awbListener->WBChanged (params.wb.temperature, params.wb.green); } int tr = getCoarseBitMask (params.coarse); @@ -2007,7 +2010,14 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) params.locallab.getCurves (locRETgainCurve, locRETgainCurverab, loclhCurve); CurveFactory::curveLocal (locallutili, params.locallab.llcurve, lllocalcurve, sca); //scale == 1 ? 1 : 16); CurveFactory::curveCCLocal (localcutili, params.locallab.cccurve, cclocalcurve, sca); //scale == 1 ? 1 : 16); - + double huere, chromare, lumare; + ipf.calc_ref (3, sp, (float**)shbuffer, nprevl, nprevl, 0, 0, 0, 0, pW, pH, fw, fh, locutili, scale, locRETgainCurve, locallutili, lllocalcurve, loclhCurve, cclocalcurve, huere, chromare, lumare); + huer = huere; + chromar = chromare; + lumar = lumare ; + params.locallab.hueref = huer; + params.locallab.chromaref = chromar; + params.locallab.lumaref = lumar; ipf.Lab_Local (3, sp, (float**)shbuffer, nprevl, nprevl, 0, 0, 0, 0, pW, pH, fw, fh, locutili, scale, locRETgainCurve, locallutili, lllocalcurve, loclhCurve, cclocalcurve, params.locallab.hueref, params.locallab.chromaref, params.locallab.lumaref); dataspot[58][sp] = huerefs[sp] = 100.f * params.locallab.hueref; dataspot[59][sp] = chromarefs[sp] = params.locallab.chromaref; @@ -2312,8 +2322,17 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) CurveFactory::curveLocal (locallutili, params.locallab.llcurve, lllocalcurve, sca); //scale == 1 ? 1 : 16); CurveFactory::curveCCLocal (localcutili, params.locallab.cccurve, cclocalcurve, sca); //scale == 1 ? 1 : 16); + double huere, chromare, lumare; + ipf.calc_ref (3, sp, (float**)shbuffer, nprevl, nprevl, 0, 0, 0, 0, pW, pH, fw, fh, locutili, scale, locRETgainCurve, locallutili, lllocalcurve, loclhCurve, cclocalcurve, huere, chromare, lumare); + huer = huere; + chromar = chromare; + lumar = lumare ; + params.locallab.hueref = huer; + params.locallab.chromaref = chromar; + params.locallab.lumaref = lumar; + + ipf.Lab_Local (3, sp, (float**)shbuffer, nprevl, nprevl, 0, 0, 0, 0, pW, pH, fw, fh, locutili, scale, locRETgainCurve, locallutili, lllocalcurve, loclhCurve, cclocalcurve, params.locallab.hueref, params.locallab.chromaref, params.locallab.lumaref ); - ipf.Lab_Local (3, sp, (float**)shbuffer, nprevl, nprevl, 0, 0, 0, 0, pW, pH, fw, fh, locutili, scale, locRETgainCurve, locallutili, lllocalcurve, loclhCurve, cclocalcurve, params.locallab.hueref, params.locallab.chromaref, params.locallab.lumaref); dataspot[58][sp] = huerefs[sp] = 100.f * params.locallab.hueref; dataspot[59][sp] = chromarefs[sp] = params.locallab.chromaref; dataspot[60][sp] = lumarefs[sp] = params.locallab.lumaref; @@ -2908,12 +2927,12 @@ bool ImProcCoordinator::getAutoWB (double& temp, double& green, double equal, do imgsrc->getAutoWBMultipliers (rm, gm, bm); if (rm != -1) { - autoWB.update(rm, gm, bm, equal, tempBias); + autoWB.update (rm, gm, bm, equal, tempBias); lastAwbEqual = equal; lastAwbTempBias = tempBias; } else { lastAwbEqual = -1.; - autoWB.useDefaults(equal); + autoWB.useDefaults (equal); lastAwbTempBias = 0.0; } } @@ -3056,13 +3075,13 @@ void ImProcCoordinator::saveInputICCReference (const Glib::ustring & fname, bool imgsrc->getAutoWBMultipliers (rm, gm, bm); if (rm != -1.) { - autoWB.update(rm, gm, bm, params.wb.equal, params.wb.tempBias); + autoWB.update (rm, gm, bm, params.wb.equal, params.wb.tempBias); lastAwbEqual = params.wb.equal; lastAwbTempBias = params.wb.tempBias; } else { lastAwbEqual = -1.; lastAwbTempBias = 0.0; - autoWB.useDefaults(params.wb.equal); + autoWB.useDefaults (params.wb.equal); } } @@ -3107,11 +3126,11 @@ void ImProcCoordinator::saveInputICCReference (const Glib::ustring & fname, bool // image may contain out of range samples, clip them to avoid wrap-arounds #pragma omp parallel for - for(int i = 0; i < im->getHeight(); i++) { - for(int j = 0; j < im->getWidth(); j++) { - im->r(i, j) = CLIP(im->r(i, j)); - im->g(i, j) = CLIP(im->g(i, j)); - im->b(i, j) = CLIP(im->b(i, j)); + for (int i = 0; i < im->getHeight(); i++) { + for (int j = 0; j < im->getWidth(); j++) { + im->r (i, j) = CLIP (im->r (i, j)); + im->g (i, j) = CLIP (im->g (i, j)); + im->b (i, j) = CLIP (im->b (i, j)); } } diff --git a/rtengine/improccoordinator.h b/rtengine/improccoordinator.h index 097a26487..ab71b8e49 100644 --- a/rtengine/improccoordinator.h +++ b/rtengine/improccoordinator.h @@ -299,7 +299,7 @@ protected: LUTf chromarefs; LUTf lumarefs; - + double huer, chromar, lumar; void startProcessing (); void process (); float colourToningSatLimit; diff --git a/rtengine/improcfun.h b/rtengine/improcfun.h index bf5015e4a..c82d2c822 100644 --- a/rtengine/improcfun.h +++ b/rtengine/improcfun.h @@ -278,7 +278,7 @@ public: int pitch, int scale, const int luma, const int chroma/*, LUTf & Lcurve, LUTf & abcurve*/ ); //locallab void MSRLocal (float** luminance, float** templ, const float* const *originalLuminance, const int width, const int height, const LocallabParams &loc, const int skip, const LocretigainCurve &locRETgainCcurve, const int chrome, const int scall, const float krad, float &minCD, float &maxCD, float &mini, float &maxi, float &Tmean, float &Tsigma, float &Tmin, float &Tmax); - + void calc_ref (int call, int sp, float** shbuffer, LabImage* original, LabImage* transformed, int sx, int sy, int cx, int cy, int oW, int oH, int fw, int fh, bool locutili, int sk, const LocretigainCurve & locRETgainCcurve, bool locallutili, LUTf & lllocalcurve, const LocLHCurve & loclhCurve, LUTf & cclocalcurve, double &huere, double &chromare, double &lumare); void Lab_Local (int call, int sp, float** shbuffer, LabImage* original, LabImage* transformed, int sx, int sy, int cx, int cy, int oW, int oH, int fw, int fh, bool locutili, int sk, const LocretigainCurve & locRETgainCcurve, bool locallutili, LUTf & lllocalcurve, const LocLHCurve & loclhCurve, LUTf & cclocalcurve, double &hueref, double &chromaref, double &lumaref); void addGaNoise (LabImage *lab, LabImage *dst, const float mean, const float variance, const int sk); void BlurNoise_Localold (int call, const struct local_params& lp, LabImage* original, LabImage* transformed, const LabImage* const tmp1, int cx, int cy); diff --git a/rtengine/iplocallab.cc b/rtengine/iplocallab.cc index 333047bde..283730a58 100644 --- a/rtengine/iplocallab.cc +++ b/rtengine/iplocallab.cc @@ -3412,6 +3412,7 @@ void ImProcFunctions::ColorLight_Local (int call, LabImage * bufcolorig, LabImag } float fac = flicur * (100.f + factorx * realchro * falu * falL) / 100.f; //chroma factor transition + //if(fac < 0.2f) fac = 0.2f; float diflc = lightcont * fli * flisl - original->L[y][x]; kdiff *= fach * kch; diflc *= kdiff ; @@ -3495,6 +3496,7 @@ void ImProcFunctions::ColorLight_Local (int call, LabImage * bufcolorig, LabImag } float fac = flicur * (100.f + realchro * falu * falL) / 100.f; //chroma factor transition7 + //if(fac < 0.2f) fac = 0.2f; float diflc = lightcont * fli * flisl - original->L[y][x]; @@ -3589,6 +3591,55 @@ void ImProcFunctions::InverseColorLight_Local (const struct local_params & lp, L } } +void ImProcFunctions::calc_ref (int call, int sp, float** shbuffer, LabImage * original, LabImage * transformed, int sx, int sy, int cx, int cy, int oW, int oH, int fw, int fh, bool locutili, int sk, const LocretigainCurve & locRETgainCcurve, bool locallutili, LUTf & lllocalcurve, const LocLHCurve & loclhCurve, LUTf & cclocalcurve, double & hueref, double & chromaref, double & lumaref) +{ + if (params->locallab.enabled) { + //always calculate hueref, chromaref, lumaref before others operations + int GW = transformed->W; + int GH = transformed->H; + struct local_params lp; + calcLocalParams (oW, oH, params->locallab, lp); + +//begin contrast and evalue hue +// double precision for large summations + double ave = 0.; + double aveA = 0.; + double aveB = 0.; + double aveL = 0.; + double aveChro = 0.; +// int precision for the counters + int n = 0; + int nab = 0; +// single precision for the result + float av, avA, avB, avL; + int spotSize = 0.88623f * max (1, lp.cir / sk); //18 + //O.88623 = sqrt(PI / 4) ==> sqare equal to circle + + // very small region, don't use omp here + for (int y = max (cy, (int) (lp.yc - spotSize)); y < min (transformed->H + cy, (int) (lp.yc + spotSize + 1)); y++) { + for (int x = max (cx, (int) (lp.xc - spotSize)); x < min (transformed->W + cx, (int) (lp.xc + spotSize + 1)); x++) { + aveL += original->L[y - cy][x - cx]; + aveA += original->a[y - cy][x - cx]; + aveB += original->b[y - cy][x - cx]; + aveChro += sqrtf (SQR (original->b[y - cy][x - cx]) + SQR (original->a[y - cy][x - cx])); + + nab++; + } + } + + aveL = aveL / nab; + aveA = aveA / nab; + aveB = aveB / nab; + aveChro = aveChro / nab; + aveChro /= 327.68f; + avA = aveA / 327.68f; + avB = aveB / 327.68f; + avL = aveL / 327.68f; + hueref = xatan2f (avB, avA); //mean hue + chromaref = aveChro; + lumaref = avL; + } +} void ImProcFunctions::Lab_Local (int call, int sp, float** shbuffer, LabImage * original, LabImage * transformed, int sx, int sy, int cx, int cy, int oW, int oH, int fw, int fh, bool locutili, int sk, const LocretigainCurve & locRETgainCcurve, bool locallutili, LUTf & lllocalcurve, const LocLHCurve & loclhCurve, LUTf & cclocalcurve, double & hueref, double & chromaref, double & lumaref) { @@ -3631,19 +3682,23 @@ void ImProcFunctions::Lab_Local (int call, int sp, float** shbuffer, LabImage * } } -//begin contrast and evalue hue -// double precision for large summations double ave = 0.; - double aveA = 0.; - double aveB = 0.; - double aveL = 0.; - double aveChro = 0.; -// int precision for the counters int n = 0; - int nab = 0; -// single precision for the result - float av, avA, avB, avL; - + float av; + /* + //begin contrast and evalue hue + // double precision for large summations + double ave = 0.; + /* double aveA = 0.; + double aveB = 0.; + double aveL = 0.; + double aveChro = 0.; + // int precision for the counters + int n = 0; + int nab = 0; + // single precision for the result + float av, avA, avB, avL; + */ //evauate mean luminance for contrast : actually one area // evaluate also hue int levred; @@ -3657,27 +3712,43 @@ void ImProcFunctions::Lab_Local (int call, int sp, float** shbuffer, LabImage * noiscfactiv = false; } + /* + int spotSize = 0.88623f * max (1, lp.cir / sk); //18 + //O.88623 = sqrt(PI / 4) ==> sqare equal to circle + // very small region, don't use omp here + for (int y = max (cy, (int) (lp.yc - spotSize)); y < min (transformed->H + cy, (int) (lp.yc + spotSize + 1)); y++) { + for (int x = max (cx, (int) (lp.xc - spotSize)); x < min (transformed->W + cx, (int) (lp.xc + spotSize + 1)); x++) { + aveL += original->L[y - cy][x - cx]; + aveA += original->a[y - cy][x - cx]; + aveB += original->b[y - cy][x - cx]; + aveChro += sqrtf (SQR (original->b[y - cy][x - cx]) + SQR (original->a[y - cy][x - cx])); - - if ((!lp.inv && !lp.invret) && hueref == INFINITY && chromaref == INFINITY && lumaref == INFINITY) { - //evaluate hue, chroma, luma in center spot - int spotSize = 0.88623f * max (1, lp.cir / sk); //18 - //O.88623 = sqrt(PI / 4) ==> sqare equal to circle - - // very small region, don't use omp here - for (int y = max (cy, (int) (lp.yc - spotSize)); y < min (transformed->H + cy, (int) (lp.yc + spotSize + 1)); y++) { - for (int x = max (cx, (int) (lp.xc - spotSize)); x < min (transformed->W + cx, (int) (lp.xc + spotSize + 1)); x++) { - aveL += original->L[y - cy][x - cx]; - aveA += original->a[y - cy][x - cx]; - aveB += original->b[y - cy][x - cx]; - aveChro += sqrtf (SQR (original->b[y - cy][x - cx]) + SQR (original->a[y - cy][x - cx])); - - nab++; + nab++; + } } - } + */ + /* + if ((!lp.inv && !lp.invret) && hueref == INFINITY && chromaref == INFINITY && lumaref == INFINITY) { + //evaluate hue, chroma, luma in center spot + int spotSize = 0.88623f * max (1, lp.cir / sk); //18 + //O.88623 = sqrt(PI / 4) ==> sqare equal to circle - } else if (lp.inv || lp.invret) { //exterior || lp.curvact + // very small region, don't use omp here + for (int y = max (cy, (int) (lp.yc - spotSize)); y < min (transformed->H + cy, (int) (lp.yc + spotSize + 1)); y++) { + for (int x = max (cx, (int) (lp.xc - spotSize)); x < min (transformed->W + cx, (int) (lp.xc + spotSize + 1)); x++) { + aveL += original->L[y - cy][x - cx]; + aveA += original->a[y - cy][x - cx]; + aveB += original->b[y - cy][x - cx]; + aveChro += sqrtf (SQR (original->b[y - cy][x - cx]) + SQR (original->a[y - cy][x - cx])); + + nab++; + } + } + + } else + */ + if (lp.inv || lp.invret) { //exterior || lp.curvact ave = 0.f; n = 0; #pragma omp parallel for reduction(+:ave,n) @@ -3707,28 +3778,34 @@ void ImProcFunctions::Lab_Local (int call, int sp, float** shbuffer, LabImage * av = ave / 327.68f; } - aveL = aveL / nab; - aveA = aveA / nab; - aveB = aveB / nab; - aveChro = aveChro / nab; - aveChro /= 327.68f; - avA = aveA / 327.68f; - avB = aveB / 327.68f; - avL = aveL / 327.68f; - + /* + aveL = aveL / nab; + aveA = aveA / nab; + aveB = aveB / nab; + aveChro = aveChro / nab; + aveChro /= 327.68f; + avA = aveA / 327.68f; + avB = aveB / 327.68f; + avL = aveL / 327.68f; + hueref = xatan2f (avB, avA); //mean hue + chromaref = aveChro; + lumaref = avL; + */ //INFINITY to solve crop problem when Ref is outside preview - if (hueref == INFINITY) { - hueref = xatan2f (avB, avA); //mean hue - } + /* + if (hueref == INFINITY) { + hueref = xatan2f (avB, avA); //mean hue + } - if (chromaref == INFINITY) { - chromaref = aveChro; - } - - if (lumaref == INFINITY) { - lumaref = avL; - } + if (chromaref == INFINITY) { + chromaref = aveChro; + } + if (lumaref == INFINITY) { + lumaref = avL; + } + */ +// printf ("call= %i sp=%i hueref=%f chromaref=%f lumaref=%f\n", call, sp, hueref, chromaref, lumaref); struct local_contra lco; // we must here detect : general case, skin, sky,...foliages ??? diff --git a/rtengine/simpleprocess.cc b/rtengine/simpleprocess.cc index 90a62ab26..74146f2ab 100644 --- a/rtengine/simpleprocess.cc +++ b/rtengine/simpleprocess.cc @@ -165,8 +165,8 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p currWB = imgsrc->getWB (); } else if (params.wb.method == "Auto") { double rm, gm, bm; - imgsrc->getAutoWBMultipliers(rm, gm, bm); - currWB.update(rm, gm, bm, params.wb.equal, params.wb.tempBias); + imgsrc->getAutoWBMultipliers (rm, gm, bm); + currWB.update (rm, gm, bm, params.wb.equal, params.wb.tempBias); } NoiseCurve noiseLCurve; @@ -1596,6 +1596,12 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p CurveFactory::curveLocal (locallutili, params.locallab.llcurve, lllocalcurve, 1); CurveFactory::curveCCLocal (localcutili, params.locallab.cccurve, cclocalcurve, 1); + double huere, chromare, lumare; + + ipf.calc_ref (2, sp, (float**)shbuffer, labView, labView, 0, 0, 0, 0, fw, fh, fw, fh, locutili, 1, locRETgainCurve, locallutili, lllocalcurve, loclhCurve, cclocalcurve, huere, chromare, lumare); + params.locallab.hueref = huere; + params.locallab.chromaref = chromare; + params.locallab.lumaref = lumare; ipf.Lab_Local (2, sp, (float**)shbuffer, labView, labView, 0, 0, 0, 0, fw, fh, fw, fh, locutili, 1, locRETgainCurve, locallutili, lllocalcurve, loclhCurve, cclocalcurve, params.locallab.hueref, params.locallab.chromaref, params.locallab.lumaref); lllocalcurve.clear();