diff --git a/rtdata/languages/default b/rtdata/languages/default index f842edff5..2f3cb2d14 100644 --- a/rtdata/languages/default +++ b/rtdata/languages/default @@ -1968,7 +1968,8 @@ TP_LOCALLAB_CURVENCONTRAST;Super+Contrast threshold (experimental) TP_LOCALLAB_CURVENSOB2;Combined HueChroma + Contrast threshold (experimental) TP_LOCALLAB_DENOIS;Denoise TP_LOCALLAB_DEHAZ;Dehaze -TP_LOCALLAB_LUM;Curves +TP_LOCALLAB_LUM;Curves LC +TP_LOCALLAB_HLH;Curves H TP_LOCALLAB_CHROMACBDL;Chroma TP_LOCALLAB_CHROMACB_TOOLTIP;Acts as an amplifier-reducer action compare to sliders of luminance.\nUnder 100 reduce, above 100 amplifie TP_LOCALLAB_CURVEEDITOR_TONES_TOOLTIP;L=f(L), can be used with L(H) in Color and Light diff --git a/rtengine/dcrop.cc b/rtengine/dcrop.cc index de589fc06..945feaf52 100644 --- a/rtengine/dcrop.cc +++ b/rtengine/dcrop.cc @@ -963,10 +963,10 @@ void Crop::update(int todo) // Locallab mask are only shown for selected spot if (sp == parent->params.locallab.selspot) { parent->ipf.Lab_Local(1, sp, (float**)shbuffer, labnCrop, labnCrop, reservCrop, cropx / skip, cropy / skip, skips(parent->fw, skip), skips(parent->fh, skip), skip, locRETgainCurve, lllocalcurve2,locallutili, - loclhCurve, lochhCurve, locccmasCurve, lcmasutili, locllmasCurve, llmasutili, lochhmasCurve, lhmasutili, locccmasexpCurve, lcmasexputili, locllmasexpCurve, llmasexputili, lochhmasexpCurve, lhmasexputili, LHutili, HHutili, cclocalcurve2, localskutili, sklocalcurve2, localexutili, exlocalcurve2, hltonecurveloc2, shtonecurveloc2, tonecurveloc2, lightCurveloc2, huerefblu, chromarefblu, lumarefblu, huere, chromare, lumare, sobelre, parent->locallColorMask, parent->locallExpMask); + loclhCurve, lochhCurve, locccmasCurve, lcmasutili, locllmasCurve, llmasutili, lochhmasCurve, lhmasutili, locccmasexpCurve, lcmasexputili, locllmasexpCurve, llmasexputili, lochhmasexpCurve, lhmasexputili, LHutili, HHutili, cclocalcurve2, localcutili, localskutili, sklocalcurve2, localexutili, exlocalcurve2, hltonecurveloc2, shtonecurveloc2, tonecurveloc2, lightCurveloc2, huerefblu, chromarefblu, lumarefblu, huere, chromare, lumare, sobelre, parent->locallColorMask, parent->locallExpMask); } else { parent->ipf.Lab_Local(1, sp, (float**)shbuffer, labnCrop, labnCrop, reservCrop, cropx / skip, cropy / skip, skips(parent->fw, skip), skips(parent->fh, skip), skip, locRETgainCurve, lllocalcurve2,locallutili, - loclhCurve, lochhCurve, locccmasCurve, lcmasutili, locllmasCurve, llmasutili, lochhmasCurve, lhmasutili, locccmasexpCurve, lcmasexputili, locllmasexpCurve, llmasexputili, lochhmasexpCurve, lhmasexputili, LHutili, HHutili, cclocalcurve2, localskutili, sklocalcurve2, localexutili, exlocalcurve2, hltonecurveloc2, shtonecurveloc2, tonecurveloc2, lightCurveloc2, huerefblu, chromarefblu, lumarefblu, huere, chromare, lumare, sobelre, 0, 0); + loclhCurve, lochhCurve, locccmasCurve, lcmasutili, locllmasCurve, llmasutili, lochhmasCurve, lhmasutili, locccmasexpCurve, lcmasexputili, locllmasexpCurve, llmasexputili, lochhmasexpCurve, lhmasexputili, LHutili, HHutili, cclocalcurve2, localcutili, localskutili, sklocalcurve2, localexutili, exlocalcurve2, hltonecurveloc2, shtonecurveloc2, tonecurveloc2, lightCurveloc2, huerefblu, chromarefblu, lumarefblu, huere, chromare, lumare, sobelre, 0, 0); } lllocalcurve2.clear(); cclocalcurve2.clear(); diff --git a/rtengine/improccoordinator.cc b/rtengine/improccoordinator.cc index 40d4df64e..f84d56811 100644 --- a/rtengine/improccoordinator.cc +++ b/rtengine/improccoordinator.cc @@ -846,10 +846,10 @@ void ImProcCoordinator::updatePreviewImage(int todo, bool panningRelatedChange) // Locallab mask are only shown for selected spot if (sp == params.locallab.selspot) { ipf.Lab_Local(3, sp, (float**)shbuffer, nprevl, nprevl, reserv, 0, 0, pW, pH, scale, locRETgainCurve, lllocalcurve, locallutili, loclhCurve, lochhCurve, locccmasCurve, lcmasutili, locllmasCurve, llmasutili, lochhmasCurve, lhmasutili, locccmasexpCurve, lcmasexputili, locllmasexpCurve, llmasexputili, lochhmasexpCurve, lhmasexputili, - LHutili, HHutili, cclocalcurve, localskutili, sklocalcurve, localexutili, exlocalcurve, hltonecurveloc, shtonecurveloc, tonecurveloc, lightCurveloc, huerblu, chromarblu, lumarblu, huer, chromar, lumar, sobeler, locallColorMask, locallExpMask); + LHutili, HHutili, cclocalcurve, localcutili, localskutili, sklocalcurve, localexutili, exlocalcurve, hltonecurveloc, shtonecurveloc, tonecurveloc, lightCurveloc, huerblu, chromarblu, lumarblu, huer, chromar, lumar, sobeler, locallColorMask, locallExpMask); } else { ipf.Lab_Local(3, sp, (float**)shbuffer, nprevl, nprevl, reserv, 0, 0, pW, pH, scale, locRETgainCurve, lllocalcurve, locallutili, loclhCurve, lochhCurve, locccmasCurve, lcmasutili, locllmasCurve, llmasutili, lochhmasCurve, lhmasutili, locccmasexpCurve, lcmasexputili, locllmasexpCurve, llmasexputili, lochhmasexpCurve, lhmasexputili, - LHutili, HHutili, cclocalcurve, localskutili, sklocalcurve, localexutili, exlocalcurve, hltonecurveloc, shtonecurveloc, tonecurveloc, lightCurveloc, huerblu, chromarblu, lumarblu, huer, chromar, lumar, sobeler, 0, 0); + LHutili, HHutili, cclocalcurve, localcutili, localskutili, sklocalcurve, localexutili, exlocalcurve, hltonecurveloc, shtonecurveloc, tonecurveloc, lightCurveloc, huerblu, chromarblu, lumarblu, huer, chromar, lumar, sobeler, 0, 0); } //recalculate references after if (params.locallab.spots.at(sp).spotMethod == "exc") { diff --git a/rtengine/improcfun.h b/rtengine/improcfun.h index 90915924d..054d3abb3 100644 --- a/rtengine/improcfun.h +++ b/rtengine/improcfun.h @@ -288,7 +288,7 @@ public: void calc_ref(int befend, int sp, LabImage* original, LabImage* transformed, int cx, int cy, int oW, int oH, int sk, double &huerefblur, double &chromarefblur, double &lumarefblur, double &huere, double &chromare, double &lumare, double &sobelref, float &avg); void copy_ref(LabImage* spotbuffer, LabImage* original, LabImage* transformed, int cx, int cy, int sk, const struct local_params & lp, double &huerefspot, double &chromarefspot, double &lumarefspot); void paste_ref(LabImage* spotbuffer, LabImage* transformed, int cx, int cy, int sk, const struct local_params & lp); - void Lab_Local(int call, int sp, float** shbuffer, LabImage* original, LabImage* transformed, LabImage* reserved, int cx, int cy, int oW, int oH, int sk, const LocretigainCurve & locRETgainCcurve, LUTf & lllocalcurve, bool & locallutili, const LocLHCurve & loclhCurve, const LocHHCurve & lochhCurve, const LocCCmaskCurve & locccmasCurve, bool & lcmasutili, const LocLLmaskCurve & locllmasCurve, bool & llmasutili, const LocHHmaskCurve & lochhmasCurve, bool & lhmasutili, const LocCCmaskexpCurve & locccmasexpCurve, bool &lcmasexputili, const LocLLmaskexpCurve & locllmasexpCurve, bool &llmasexputili, const LocHHmaskexpCurve & lochhmasexpCurve, bool & lhmasexputili, bool &LHutili, bool &HHutili, LUTf & cclocalcurve, bool & localskutili, LUTf & sklocalcurve, bool & localexutili, LUTf & exlocalcurve, LUTf & hltonecurve, LUTf & shtonecurve, LUTf & tonecurve, LUTf & lightCurveloc, double & huerefblur, double &chromarefblur, double & lumarefblur, double &hueref, double &chromaref, double &lumaref, double &sobelref, int llColorMask, int llExpMask); + void Lab_Local(int call, int sp, float** shbuffer, LabImage* original, LabImage* transformed, LabImage* reserved, int cx, int cy, int oW, int oH, int sk, const LocretigainCurve & locRETgainCcurve, LUTf & lllocalcurve, bool & locallutili, const LocLHCurve & loclhCurve, const LocHHCurve & lochhCurve, const LocCCmaskCurve & locccmasCurve, bool & lcmasutili, const LocLLmaskCurve & locllmasCurve, bool & llmasutili, const LocHHmaskCurve & lochhmasCurve, bool & lhmasutili, const LocCCmaskexpCurve & locccmasexpCurve, bool &lcmasexputili, const LocLLmaskexpCurve & locllmasexpCurve, bool &llmasexputili, const LocHHmaskexpCurve & lochhmasexpCurve, bool & lhmasexputili, bool &LHutili, bool &HHutili, LUTf & cclocalcurve, bool & localcutili, bool & localskutili, LUTf & sklocalcurve, bool & localexutili, LUTf & exlocalcurve, LUTf & hltonecurve, LUTf & shtonecurve, LUTf & tonecurve, LUTf & lightCurveloc, double & huerefblur, double &chromarefblur, double & lumarefblur, double &hueref, double &chromaref, double &lumaref, double &sobelref, int llColorMask, int llExpMask); 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); void InverseBlurNoise_Local(const struct local_params& lp, LabImage* original, LabImage* transformed, const LabImage* const tmp1, int cx, int cy); @@ -308,7 +308,7 @@ public: void fftw_denoise(int GW, int GH, int max_numblox_W, int min_numblox_W, float **tmp1, array2D *Lin, int numThreads, const struct local_params & lp, int chrom); void ColorLight_Local(float moddE, float powdE, int call, LabImage * bufcolorig, LabImage * originalmask, float **buflight, float **bufchro, float **bufchroslid, float ** bufhh, float ** buflightslid, bool &LHutili, bool &HHutili, const float hueplus, const float huemoins, const float hueref, const float dhue, const float chromaref, const float lumaref, float sobelref, float ** blend2, LUTf & lllocalcurve, const LocLHCurve & loclhCurve, const LocHHCurve & lochhCurve, LUTf & lightCurveloc, const local_params& lp, LabImage* original, LabImage* transformed, int cx, int cy, int sk); - void InverseColorLight_Local(int sp, int senstype, const struct local_params& lp, LUTf & lightCurveloc, LUTf & hltonecurveloc, LUTf & shtonecurveloc, LUTf & tonecurveloc, LabImage* original, LabImage* transformed, int cx, int cy, const float hueref, const float chromaref, const float lumaref, int sk); + void InverseColorLight_Local(int sp, int senstype, const struct local_params& lp, LUTf & lightCurveloc, LUTf & hltonecurveloc, LUTf & shtonecurveloc, LUTf & tonecurveloc, LUTf & exlocalcurve, LUTf & cclocalcurve, float adjustr, bool localcutili, LUTf & lllocalcurve, bool locallutili, LabImage* original, LabImage* transformed, int cx, int cy, const float hueref, const float chromaref, const float lumaref, int sk); void Sharp_Local(int call, float **loctemp, int senstype, const float hueref, const float chromaref, const float lumaref, const local_params & lp, LabImage * original, LabImage * transformed, int cx, int cy, int sk); // void Sharp_Local(int call, float **loctemp, int senstype, const float hueplus, const float huemoins, const float hueref, const float dhue, const float chromaref, const local_params& lp, LabImage* original, LabImage* transformed, int cx, int cy, int sk); diff --git a/rtengine/iplocallab.cc b/rtengine/iplocallab.cc index 0e316b058..6930999ec 100644 --- a/rtengine/iplocallab.cc +++ b/rtengine/iplocallab.cc @@ -4084,12 +4084,11 @@ void ImProcFunctions::transit_shapedetect(int senstype, LabImage * bufexporig, L } } -void ImProcFunctions::InverseColorLight_Local(int sp, int senstype, const struct local_params & lp, LUTf & lightCurveloc, LUTf & hltonecurveloc, LUTf & shtonecurveloc, LUTf & tonecurveloc, LabImage * original, LabImage * transformed, int cx, int cy, const float hueref, const float chromaref, const float lumaref, int sk) +void ImProcFunctions::InverseColorLight_Local(int sp, int senstype, const struct local_params & lp, LUTf & lightCurveloc, LUTf & hltonecurveloc, LUTf & shtonecurveloc, LUTf & tonecurveloc, LUTf & exlocalcurve, LUTf & cclocalcurve, float adjustr, bool localcutili, LUTf & lllocalcurve, bool locallutili, LabImage * original, LabImage * transformed, int cx, int cy, const float hueref, const float chromaref, const float lumaref, int sk) { // BENCHFUN float ach = (float)lp.trans / 100.f; const float facc = (100.f + lp.chro) / 100.f; //chroma factor transition - // ImProcFunctions::exlabLocal(lp, bfh, bfw, bufexptemp, bufexpfin, hltonecurveloc, shtonecurveloc, tonecurveloc); float varsens = lp.sens; if (senstype == 0) { //Color and Light @@ -4101,6 +4100,7 @@ void ImProcFunctions::InverseColorLight_Local(int sp, int senstype, const struct } LabImage *temp = nullptr; + LabImage *tempCL = nullptr; int GW = transformed->W; int GH = transformed->H; @@ -4111,16 +4111,92 @@ void ImProcFunctions::InverseColorLight_Local(int sp, int senstype, const struct temp = new LabImage(GW, GH); ImProcFunctions::exlabLocal(lp, GH, GW, original, temp, hltonecurveloc, shtonecurveloc, tonecurveloc); + if (exlocalcurve) { +#ifdef _OPENMP + #pragma omp parallel for schedule(dynamic,16) +#endif + + for (int y = 0; y < temp->H; y++) { + for (int x = 0; x < temp->W; x++) { + float lighn = temp->L[y][x]; + float lh = 0.5f * exlocalcurve[2.f * lighn]; // / ((lighn) / 1.9f) / 3.61f; //lh between 0 and 0 50 or more + temp->L[y][x] = lh; + } + } + } + if (lp.war != 0) { ImProcFunctions::ciecamloc_02float(sp, temp, temp); } } + if (senstype == 0) { //Color and Light curves L C + tempCL = new LabImage(GW, GH); +#ifdef _OPENMP + #pragma omp parallel for schedule(dynamic,16) +#endif + + for (int y = 0; y < tempCL->H; y++) { + for (int x = 0; x < tempCL->W; x++) { + tempCL->a[y][x] = original->a[y][x]; + tempCL->b[y][x] = original->b[y][x]; + tempCL->L[y][x] = original->L[y][x]; + } + } + + if (cclocalcurve && localcutili) { // C=f(C) curve +#ifdef _OPENMP + #pragma omp parallel for schedule(dynamic,16) +#endif + + for (int y = 0; y < transformed->H; y++) { + for (int x = 0; x < transformed->W; x++) { + //same as in "normal" + float chromat = sqrt(SQR(original->a[y][x]) + SQR(original->b[y][x])); + float ch; + float ampli = 25.f; + ch = (cclocalcurve[chromat * adjustr ]) / ((chromat + 0.00001f) * adjustr); //ch between 0 and 0 50 or more + float chprocu = CLIPCHRO(ampli * ch - ampli); //ampli = 25.f arbitrary empirical coefficient between 5 and 50 + tempCL->a[y][x] = original->a[y][x] * (1.f + 0.01f * (chprocu)); + tempCL->b[y][x] = original->b[y][x] * (1.f + 0.01f * (chprocu)); + + } + } + + } + + if (lllocalcurve && locallutili) { +#ifdef _OPENMP + #pragma omp parallel for schedule(dynamic,16) +#endif + + for (int y = 0; y < transformed->H; y++) { + for (int x = 0; x < transformed->W; x++) { + float lighn = original->L[y][x]; + float lh = 0.5f * lllocalcurve[2.f * lighn]; + tempCL->L[y][x] = lh; + } + } + } + + } + LabImage *origblur = nullptr; origblur = new LabImage(GW, GH); float radius = 3.f / sk; + + + if (senstype == 1) { + radius = (2.f + 0.2f * lp.blurexp) / sk; + } + + if (senstype == 0) { + radius = (2.f + 0.2f * lp.blurcol) / sk; + } + + #ifdef _OPENMP #pragma omp parallel #endif @@ -4239,13 +4315,35 @@ void ImProcFunctions::InverseColorLight_Local(int sp, int senstype, const struct case 1: { // inside transition zone float diflc = 0.f; + float difL = 0.f; float difa = 0.f; float difb = 0.f; float factorx = 1.f - localFactor; float fac = 1.f; + float facCa = 1.f; + float facCb = 1.f; + float epsia = 0.f; + float epsib = 0.f; if (senstype == 0) { float lumnew = original->L[y][x]; + difL = (tempCL->L[y][x] - original->L[y][x]) * reducdE; + difa = (tempCL->a[y][x] - original->a[y][x]) * reducdE; + difb = (tempCL->b[y][x] - original->b[y][x]) * reducdE; + difL *= factorx; + difa *= factorx; + difb *= factorx; + + if (original->a[y][x] == 0.f) { + epsia = 0.0001f; + } + + if (original->b[y][x] == 0.f) { + epsib = 0.0001f; + } + + facCa = 1.f + (difa / (original->a[y][x] + epsia)); + facCb = 1.f + (difb / (original->b[y][x] + epsib)); if (lp.sens < 75.f) { float lightcont; @@ -4262,10 +4360,10 @@ void ImProcFunctions::InverseColorLight_Local(int sp, int senstype, const struct diflc = (lightcont - original->L[y][x]) * reducdE; diflc *= factorx; //transition lightness - transformed->L[y][x] = CLIP(1.f * (original->L[y][x] + diflc)); + transformed->L[y][x] = CLIP(1.f * (original->L[y][x] + diflc + difL)); - transformed->a[y][x] = CLIPC(original->a[y][x] * fac) ; - transformed->b[y][x] = CLIPC(original->b[y][x] * fac); + transformed->a[y][x] = CLIPC(original->a[y][x] * fac * facCa) ; + transformed->b[y][x] = CLIPC(original->b[y][x] * fac * facCb); } else { float factorx = 1.f - localFactor; float fac = (100.f + factorx * lp.chro) / 100.f; //chroma factor transition @@ -4279,9 +4377,9 @@ void ImProcFunctions::InverseColorLight_Local(int sp, int senstype, const struct float diflc = lightcont - original->L[y][x]; diflc *= factorx; - transformed->L[y][x] = CLIP(original->L[y][x] + diflc); - transformed->a[y][x] = CLIPC(original->a[y][x] * fac); - transformed->b[y][x] = CLIPC(original->b[y][x] * fac); + transformed->L[y][x] = CLIP(original->L[y][x] + diflc + difL); + transformed->a[y][x] = CLIPC(original->a[y][x] * fac * facCa); + transformed->b[y][x] = CLIPC(original->b[y][x] * fac * facCb); } @@ -4303,12 +4401,31 @@ void ImProcFunctions::InverseColorLight_Local(int sp, int senstype, const struct case 0: { // inside selection => full effect, no transition float diflc = 0.f; + float difL = 0.f; float difa = 0.f; float difb = 0.f; float fac = 1.f; + float facCa = 1.f; + float facCb = 1.f; + float epsia = 0.f; + float epsib = 0.f; if (senstype == 0) { float lumnew = original->L[y][x]; + difL = (tempCL->L[y][x] - original->L[y][x]) * reducdE; + difa = (tempCL->a[y][x] - original->a[y][x]) * reducdE; + difb = (tempCL->b[y][x] - original->b[y][x]) * reducdE; + + if (original->a[y][x] == 0.f) { + epsia = 0.0001f; + } + + if (original->b[y][x] == 0.f) { + epsib = 0.0001f; + } + + facCa = 1.f + (difa / (original->a[y][x] + epsia)); + facCb = 1.f + (difb / (original->b[y][x] + epsib)); if (lp.sens < 75.f) { @@ -4325,10 +4442,10 @@ void ImProcFunctions::InverseColorLight_Local(int sp, int senstype, const struct fac = (100.f + lp.chro * reducdE) / 100.f; //chroma factor transition diflc = (lightcont - original->L[y][x]) * reducdE; - transformed->L[y][x] = CLIP(1.f * (original->L[y][x] + diflc)); + transformed->L[y][x] = CLIP(1.f * (original->L[y][x] + diflc + difL)); - transformed->a[y][x] = CLIPC(original->a[y][x] * fac) ; - transformed->b[y][x] = CLIPC(original->b[y][x] * fac); + transformed->a[y][x] = CLIPC(original->a[y][x] * fac * facCa) ; + transformed->b[y][x] = CLIPC(original->b[y][x] * fac * facCb); } else { @@ -4337,9 +4454,9 @@ void ImProcFunctions::InverseColorLight_Local(int sp, int senstype, const struct } float lightcont = lumnew ; - transformed->L[y][x] = CLIP(lightcont); - transformed->a[y][x] = CLIPC(original->a[y][x] * facc); - transformed->b[y][x] = CLIPC(original->b[y][x] * facc); + transformed->L[y][x] = CLIP(lightcont + difL) ; + transformed->a[y][x] = CLIPC(original->a[y][x] * facc * facCa); + transformed->b[y][x] = CLIPC(original->b[y][x] * facc * facCb); } } else if (senstype == 1) { @@ -4366,6 +4483,10 @@ void ImProcFunctions::InverseColorLight_Local(int sp, int senstype, const struct delete temp; } + if (senstype == 0) { + delete tempCL; + } + } void ImProcFunctions::calc_ref(int befend, int sp, LabImage * original, LabImage * transformed, int cx, int cy, int oW, int oH, int sk, double & huerefblur, double & chromarefblur, double & lumarefblur, double & hueref, double & chromaref, double & lumaref, double & sobelref, float &avg) @@ -4804,7 +4925,7 @@ void ImProcFunctions::fftw_denoise(int GW, int GH, int max_numblox_W, int min_nu void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * original, LabImage * transformed, LabImage * reserved, int cx, int cy, int oW, int oH, int sk, const LocretigainCurve & locRETgainCcurve, LUTf & lllocalcurve, bool & locallutili, const LocLHCurve & loclhCurve, const LocHHCurve & lochhCurve, const LocCCmaskCurve & locccmasCurve, bool & lcmasutili, const LocLLmaskCurve & locllmasCurve, bool & llmasutili, const LocHHmaskCurve & lochhmasCurve, bool &lhmasutili, const LocCCmaskexpCurve & locccmasexpCurve, bool &lcmasexputili, const LocLLmaskexpCurve & locllmasexpCurve, bool &llmasexputili, const LocHHmaskexpCurve & lochhmasexpCurve, bool & lhmasexputili, - bool & LHutili, bool & HHutili, LUTf & cclocalcurve, bool & localskutili, LUTf & sklocalcurve, bool & localexutili, LUTf & exlocalcurve, LUTf & hltonecurveloc, LUTf & shtonecurveloc, LUTf & tonecurveloc, LUTf & lightCurveloc, double & huerefblur, double &chromarefblur, double & lumarefblur, double & hueref, double & chromaref, double & lumaref, double & sobelref, int llColorMask, int llExpMask) + bool & LHutili, bool & HHutili, LUTf & cclocalcurve, bool & localcutili, bool & localskutili, LUTf & sklocalcurve, bool & localexutili, LUTf & exlocalcurve, LUTf & hltonecurveloc, LUTf & shtonecurveloc, LUTf & tonecurveloc, LUTf & lightCurveloc, double & huerefblur, double &chromarefblur, double & lumarefblur, double & hueref, double & chromaref, double & lumaref, double & sobelref, int llColorMask, int llExpMask) { //general call of others functions : important return hueref, chromaref, lumaref if (params->locallab.enabled) { @@ -7684,8 +7805,8 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o } //inverse else if (lp.invex && (lp.expcomp != 0 || lp.war != 0) && lp.exposena) { - - InverseColorLight_Local(sp, 1, lp, lightCurveloc, hltonecurveloc, shtonecurveloc, tonecurveloc, original, transformed, cx, cy, hueref, chromaref, lumaref, sk); + float adjustr = 2.f; + InverseColorLight_Local(sp, 1, lp, lightCurveloc, hltonecurveloc, shtonecurveloc, tonecurveloc, exlocalcurve, cclocalcurve, adjustr, localcutili, lllocalcurve, locallutili, original, transformed, cx, cy, hueref, chromaref, lumaref, sk); } @@ -8118,12 +8239,12 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o bufcolcalc->b[loy - begy][lox - begx] = bufcolorig->b[loy - begy][lox - begx]; bufcolcalc->L[loy - begy][lox - begx] = bufcolorig->L[loy - begy][lox - begx]; - if (cclocalcurve && lp.qualcurvemet != 0) { // C=f(C) curve + if (cclocalcurve && lp.qualcurvemet != 0 && localcutili) { // C=f(C) curve float chromat = sqrt(SQR(bufcolcalc->a[loy - begy][lox - begx]) + SQR(bufcolcalc->b[loy - begy][lox - begx])); float ch; float ampli = 25.f; - ch = (cclocalcurve[chromat * adjustr ]) / ((chromat + 0.00001f) * adjustr); //ch between 0 and 0 50 or more + ch = (cclocalcurve[chromat * adjustr]) / ((chromat + 0.00001f) * adjustr); //ch between 0 and 0 50 or more chprocu = CLIPCHRO(ampli * ch - ampli); //ampli = 25.f arbitrary empirical coefficient between 5 and 50 } @@ -8225,9 +8346,27 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o } } //inverse - else if (lp.inv && (lp.chro != 0 || lp.ligh != 0) && lp.colorena) { + else if (lp.inv && (lp.chro != 0 || lp.ligh != 0 || exlocalcurve) && lp.colorena) { + float adjustr = 1.0f; - InverseColorLight_Local(sp, 0, lp, lightCurveloc, hltonecurveloc, shtonecurveloc, tonecurveloc, original, transformed, cx, cy, hueref, chromaref, lumaref, sk); +//adapt chroma to working profile + if (params->icm.workingProfile == "ProPhoto") { + adjustr = 1.2f; // 1.2 instead 1.0 because it's very rare to have C>170.. + } else if (params->icm.workingProfile == "Adobe RGB") { + adjustr = 1.8f; + } else if (params->icm.workingProfile == "sRGB") { + adjustr = 2.0f; + } else if (params->icm.workingProfile == "WideGamut") { + adjustr = 1.2f; + } else if (params->icm.workingProfile == "Beta RGB") { + adjustr = 1.4f; + } else if (params->icm.workingProfile == "BestRGB") { + adjustr = 1.4f; + } else if (params->icm.workingProfile == "BruceRGB") { + adjustr = 1.8f; + } + + InverseColorLight_Local(sp, 0, lp, lightCurveloc, hltonecurveloc, shtonecurveloc, tonecurveloc, exlocalcurve, cclocalcurve, adjustr, localcutili, lllocalcurve, locallutili, original, transformed, cx, cy, hueref, chromaref, lumaref, sk); } // Gamut and Munsell control - very important do not desactivated to avoid crash diff --git a/rtengine/simpleprocess.cc b/rtengine/simpleprocess.cc index b57df924d..6ea8d786d 100644 --- a/rtengine/simpleprocess.cc +++ b/rtengine/simpleprocess.cc @@ -1159,7 +1159,7 @@ private: // No Locallab mask is shown in exported picture ipf.Lab_Local(2, sp, (float**)shbuffer, labView, labView, reservView, 0, 0, fw, fh, 1, locRETgainCurve, lllocalcurve, locallutili, loclhCurve, lochhCurve, locccmasCurve, lcmasutili, locllmasCurve, llmasutili, lochhmasCurve, lhmasutili, locccmasexpCurve, lcmasexputili, locllmasexpCurve, llmasexputili, lochhmasexpCurve, lhmasexputili, - LHutili, HHutili, cclocalcurve, localskutili, sklocalcurve, localexutili, exlocalcurve, hltonecurveloc, shtonecurveloc, tonecurveloc, lightCurveloc, huerefblu, chromarefblu, lumarefblu, huere, chromare, lumare, sobelre, 0, 0); + LHutili, HHutili, cclocalcurve, localcutili, localskutili, sklocalcurve, localexutili, exlocalcurve, hltonecurveloc, shtonecurveloc, tonecurveloc, lightCurveloc, huerefblu, chromarefblu, lumarefblu, huere, chromare, lumare, sobelre, 0, 0); // Clear local curves lllocalcurve.clear(); diff --git a/rtgui/locallab.cc b/rtgui/locallab.cc index 6d5057f37..ebc2c2f56 100644 --- a/rtgui/locallab.cc +++ b/rtgui/locallab.cc @@ -61,6 +61,7 @@ Locallab::Locallab(): // CurveEditorGroup widgets // Color & Light llCurveEditorG(new CurveEditorGroup(options.lastlocalCurvesDir, M("TP_LOCALLAB_LUM"))), + HCurveEditorG(new CurveEditorGroup(options.lastlocalCurvesDir, M("TP_LOCALLAB_HLH"))), maskCurveEditorG(new CurveEditorGroup(options.lastlocalCurvesDir, M("TP_LOCALLAB_MASK"))), // Exposure curveEditorG(new CurveEditorGroup(options.lastlocalCurvesDir, M("TP_LOCALLAB_CURVEEDITOR_TONES_LABEL"))), @@ -265,9 +266,11 @@ Locallab::Locallab(): ccshape->setBottomBarBgGradient(mccshape); ccshape->setLeftBarBgGradient(mccshape); - llCurveEditorG->newLine(); + // llCurveEditorG->newLine(); + llCurveEditorG->curveListComplete(); + HCurveEditorG->setCurveListener(this); - LHshape = static_cast(llCurveEditorG->addCurve(CT_Flat, "L(H)", nullptr, false, true)); + LHshape = static_cast(HCurveEditorG->addCurve(CT_Flat, "L(H)", nullptr, false, true)); LHshape->setIdentityValue(0.); LHshape->setResetCurve(FlatCurveType(defSpot.LHcurve.at(0)), defSpot.LHcurve); LHshape->setTooltip(M("TP_LOCALLAB_CURVEEDITOR_LL_TOOLTIP")); @@ -283,7 +286,7 @@ Locallab::Locallab(): LHshape->setBottomBarBgGradient(mLHshape); // llCurveEditorG->curveListComplete(); - HHshape = static_cast(llCurveEditorG->addCurve(CT_Flat, "H(H)", nullptr, false, true)); + HHshape = static_cast(HCurveEditorG->addCurve(CT_Flat, "H(H)", nullptr, false, true)); HHshape->setIdentityValue(0.); HHshape->setResetCurve(FlatCurveType(defSpot.HHcurve.at(0)), defSpot.HHcurve); HHshape->setTooltip(M("TP_LOCALLAB_CURVEEDITOR_LL_TOOLTIP")); @@ -299,7 +302,7 @@ Locallab::Locallab(): HHshape->setBottomBarBgGradient(mHHshape); - llCurveEditorG->curveListComplete(); + HCurveEditorG->curveListComplete(); inversConn = invers->signal_toggled().connect(sigc::mem_fun(*this, &Locallab::inversChanged)); @@ -357,6 +360,7 @@ Locallab::Locallab(): qualcurvbox->pack_start(*qualitycurveMethod); colorBox->pack_start(*qualcurvbox); colorBox->pack_start(*llCurveEditorG, Gtk::PACK_SHRINK, 4); // Padding is mandatory to correct behavior of curve editor + colorBox->pack_start(*HCurveEditorG, Gtk::PACK_SHRINK, 4); // Padding is mandatory to correct behavior of curve editor colorBox->pack_start(*invers); maskcolFrame->set_label_align(0.025, 0.5); ToolParamBlock* const maskcolBox = Gtk::manage(new ToolParamBlock()); @@ -844,6 +848,7 @@ Locallab::~Locallab() idle_register.destroy(); delete llCurveEditorG; + delete HCurveEditorG; delete curveEditorG; delete curveEditorGG; delete LocalcurveEditorgainT; @@ -2301,6 +2306,7 @@ void Locallab::inversChanged() if (multiImage && invers->get_inconsistent()) { sensi->show(); llCurveEditorG->show(); + HCurveEditorG->show(); curvactiv->hide(); qualitycurveMethod->show(); labqualcurv->show(); @@ -2310,17 +2316,19 @@ void Locallab::inversChanged() showmaskcolMethod->hide(); // Being able to change Color & Light mask visibility is useless in batch mode } else if (invers->get_active()) { sensi->show(); - llCurveEditorG->hide(); + llCurveEditorG->show(); + HCurveEditorG->hide(); curvactiv->hide(); qualitycurveMethod->hide(); labqualcurv->hide(); maskcolFrame->hide(); structcol->hide(); - blurcolde->hide(); + blurcolde->show(); } else { sensi->show(); llCurveEditorG->show(); + HCurveEditorG->show(); curvactiv->hide(); qualitycurveMethod->show(); labqualcurv->show(); @@ -2368,10 +2376,10 @@ void Locallab::inversexChanged() showmaskexpMethod->hide(); // Being able to change Color & Light mask visibility is useless in batch mode } else if (inversex->get_active()) { sensiex->show(); - curveEditorG->hide(); + curveEditorG->show(); maskexpFrame->hide(); structexp->hide(); - blurexpde->hide(); + blurexpde->show(); } else { sensiex->show(); @@ -4025,6 +4033,7 @@ void Locallab::updateSpecificGUIState() if (multiImage && invers->get_inconsistent()) { sensi->show(); llCurveEditorG->show(); + HCurveEditorG->show(); curvactiv->hide(); qualitycurveMethod->show(); labqualcurv->show(); @@ -4034,16 +4043,18 @@ void Locallab::updateSpecificGUIState() showmaskcolMethod->hide(); // Being able to change Color & Light mask visibility is useless in batch mode } else if (invers->get_active()) { sensi->show(); - llCurveEditorG->hide(); + llCurveEditorG->show(); + HCurveEditorG->hide(); curvactiv->hide(); qualitycurveMethod->hide(); labqualcurv->hide(); maskcolFrame->hide(); structcol->hide(); - blurcolde->hide(); + blurcolde->show(); } else { sensi->show(); llCurveEditorG->show(); + HCurveEditorG->show(); curvactiv->hide(); qualitycurveMethod->show(); labqualcurv->show(); @@ -4065,10 +4076,10 @@ void Locallab::updateSpecificGUIState() showmaskexpMethod->hide(); // Being able to change Color & Light mask visibility is useless in batch mode } else if (inversex->get_active()) { sensiex->show(); - curveEditorG->hide(); + curveEditorG->show(); maskexpFrame->hide(); structexp->hide(); - blurexpde->hide(); + blurexpde->show(); } else { sensiex->show(); curveEditorG->show(); diff --git a/rtgui/locallab.h b/rtgui/locallab.h index e215e34c2..867814fda 100644 --- a/rtgui/locallab.h +++ b/rtgui/locallab.h @@ -64,6 +64,7 @@ private: // Curve widgets // Color & Light CurveEditorGroup* const llCurveEditorG; + CurveEditorGroup* const HCurveEditorG; CurveEditorGroup* const maskCurveEditorG; DiagonalCurveEditor* llshape; DiagonalCurveEditor* ccshape;