diff --git a/rtdata/languages/default b/rtdata/languages/default index 497196c78..e359008ee 100644 --- a/rtdata/languages/default +++ b/rtdata/languages/default @@ -872,6 +872,7 @@ HISTORY_MSG_616;Local - Blend Exp HISTORY_MSG_617;Local - Blur Exp HISTORY_MSG_618;Local - Use Color Mask HISTORY_MSG_619;Local - Use Exp Mask +HISTORY_MSG_620;Local - Blur col HISTORY_MSG_CLAMPOOG;Clip out-of-gamut colors HISTORY_MSG_COLORTONING_LABGRID_VALUE;CT - Color correction HISTORY_MSG_COLORTONING_LABREGION_AB;CT - Color correction diff --git a/rtengine/dcrop.cc b/rtengine/dcrop.cc index 4b0e13f14..291fdac3c 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, + 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, 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, + 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, huere, chromare, lumare, sobelre, 0, 0); } diff --git a/rtengine/improccoordinator.cc b/rtengine/improccoordinator.cc index 02cb3db60..d3a56e799 100644 --- a/rtengine/improccoordinator.cc +++ b/rtengine/improccoordinator.cc @@ -843,10 +843,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, loclhCurve, lochhCurve, locccmasCurve, lcmasutili, locllmasCurve, llmasutili, lochhmasCurve, lhmasutili, locccmasexpCurve, lcmasexputili, locllmasexpCurve, llmasexputili, lochhmasexpCurve, lhmasexputili, + 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, huer, chromar, lumar, sobeler, locallColorMask, locallExpMask); } else { - ipf.Lab_Local(3, sp, (float**)shbuffer, nprevl, nprevl, reserv, 0, 0, pW, pH, scale, locRETgainCurve, lllocalcurve, loclhCurve, lochhCurve, locccmasCurve, lcmasutili, locllmasCurve, llmasutili, lochhmasCurve, lhmasutili, locccmasexpCurve, lcmasexputili, locllmasexpCurve, llmasexputili, lochhmasexpCurve, lhmasexputili, + 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, huer, chromar, lumar, sobeler, 0, 0); } diff --git a/rtengine/improcfun.h b/rtengine/improcfun.h index b746430aa..fee98c563 100644 --- a/rtengine/improcfun.h +++ b/rtengine/improcfun.h @@ -280,7 +280,7 @@ public: // pyramid denoise procparams::DirPyrDenoiseParams dnparams; void dirpyr(LabImage* data_fine, LabImage* data_coarse, int level, LUTf &rangefn_L, LUTf &rangefn_ab, - int pitch, int scale, const int luma, int chroma); + int pitch, int scale, const int luma, int chroma); void idirpyr(LabImage* data_coarse, LabImage* data_fine, int level, LUTf &rangefn_L, LUTf & nrwt_l, LUTf & nrwt_ab, int pitch, int scale, const int luma, const int chroma/*, LUTf & Lcurve, LUTf & abcurve*/); //locallab @@ -289,7 +289,7 @@ public: void calc_ref(int sp, LabImage* original, LabImage* transformed, int cx, int cy, int oW, int oH, int sk, double &huerefblur, double &huere, double &chromare, double &lumare, double &sobelref, LUTu & histogram, 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, 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 &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 & localskutili, LUTf & sklocalcurve, bool & localexutili, LUTf & exlocalcurve, LUTf & hltonecurve, LUTf & shtonecurve, LUTf & tonecurve, LUTf & lightCurveloc, double & huerefblur, 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); @@ -299,7 +299,7 @@ public: static void strcurv_data(std::string retistr, int *s_datc, int &siz); void vibrancelocal(int sp, int bfw, int bfh, LabImage* lab, LabImage* dest, bool & localskutili, LUTf & sklocalcurve); - void transit_shapedetect(int senstype, LabImage * bufexporig, LabImage * originalmask, float **buflight, float **bufchro, float **buf_a_cat, float ** buf_b_cat, const float hueref, const float chromaref, const float lumaref, float sobelref, float ** blend2, const struct local_params & lp, LabImage * original, LabImage * transformed, int cx, int cy, int sk); + void transit_shapedetect(int senstype, LabImage * bufexporig, LabImage * originalmask, float **buflight, float **bufchro, float **buf_a_cat, float ** buf_b_cat, float ** bufhh, bool HHutili, const float hueref, const float chromaref, const float lumaref, float sobelref, float ** blend2, const struct local_params & lp, LabImage * original, LabImage * transformed, int cx, int cy, int sk); void exlabLocal(const local_params& lp, int bfh, int bfw, LabImage* bufexporig, LabImage* lab, LUTf & hltonecurve, LUTf & shtonecurve, LUTf & tonecurve); void Exclude_Local(int sen, float **deltaso, float **buflight, float **bufchro, const float hueref, const float chromaref, const float lumaref, const struct local_params & lp, LabImage * original, LabImage * transformed, LabImage * rsv, LabImage * reserv, int cx, int cy, int sk); diff --git a/rtengine/iplocallab.cc b/rtengine/iplocallab.cc index ab4c32fe8..c9a0c5974 100644 --- a/rtengine/iplocallab.cc +++ b/rtengine/iplocallab.cc @@ -162,6 +162,7 @@ struct local_params { float blendmaexp; float struexp; float blurexp; + float blurcol; float ligh; int shamo, shdamp, shiter, senssha, sensv; float neig; @@ -228,6 +229,7 @@ struct local_params { int shapmet; bool enaColorMask; bool enaExpMask; + bool enaColMask; }; static void SobelCannyLuma(float **sobelL, float **luma, int bfw, int bfh, float radius) @@ -385,7 +387,8 @@ static void calcLocalParams(int sp, int oW, int oH, const LocallabParams& locall lp.qualcurvemet = 0; } else if (locallab.spots.at(sp).qualitycurveMethod == "std") { lp.qualcurvemet = 1; - } else if (locallab.spots.at(sp).qualitycurveMethod == "enh") { + } /* else if (locallab.spots.at(sp).qualitycurveMethod == "enh") { + lp.qualcurvemet = 2; } else if (locallab.spots.at(sp).qualitycurveMethod == "enhsup") { lp.qualcurvemet = 3; @@ -394,7 +397,7 @@ static void calcLocalParams(int sp, int oW, int oH, const LocallabParams& locall } else if (locallab.spots.at(sp).qualitycurveMethod == "sob2") { lp.qualcurvemet = 5; } - +*/ lp.showmaskcolmet = llColorMask; lp.showmaskexpmet = llExpMask; lp.enaColorMask = locallab.spots.at(sp).enaColorMask && llColorMask == 0 && llExpMask == 0; // Color & Light mask is deactivated if Exposure mask is visible @@ -456,6 +459,7 @@ static void calcLocalParams(int sp, int oW, int oH, const LocallabParams& locall float blendmaskexpo = ((float) locallab.spots.at(sp).blendmaskexp) / 100.f ; float structexpo = (float) locallab.spots.at(sp).structexp; float blurexpo = (float) locallab.spots.at(sp).blurexpde; + float blurcolor = (float) locallab.spots.at(sp).blurcolde; int local_transit = locallab.spots.at(sp).transit; double radius = (double) locallab.spots.at(sp).radius; double sharradius = ((double) locallab.spots.at(sp).sharradius) / 100. ; @@ -495,6 +499,7 @@ static void calcLocalParams(int sp, int oW, int oH, const LocallabParams& locall lp.blendmaexp = blendmaskexpo; lp.struexp = structexpo; lp.blurexp = blurexpo; + lp.blurcol = blurcolor; lp.sens = local_sensi; lp.sensh = local_sensih; lp.dehaze = local_dehaze; @@ -3606,7 +3611,7 @@ void ImProcFunctions::Exclude_Local(int sen, float **deltaso, float **buflight, float refa = chromaref * cos(hueref); float refb = chromaref * sin(hueref); - + LabImage *origblur = nullptr; @@ -3689,7 +3694,7 @@ void ImProcFunctions::Exclude_Local(int sen, float **deltaso, float **buflight, } #ifdef __SSE2__ - // float rhue = atan2Buffer[x]; +// float rhue = atan2Buffer[x]; #else // float rhue = xatan2f(origblur->b[y][x], origblur->a[y][x]); #endif @@ -3742,10 +3747,11 @@ void ImProcFunctions::Exclude_Local(int sen, float **deltaso, float **buflight, float difL; difL = rsv->L[loy - begy][lox - begx] - original->L[y][x]; - // difL *= factorx * (100.f + realstr * falL) / 100.f; - // difL *= kch * fach; - difL *= factorx * (100.f + realstrdE ) / 100.f; - // difL *= kch * fach; + // difL *= factorx * (100.f + realstr * falL) / 100.f; + // difL *= kch * fach; + difL *= factorx * (100.f + realstrdE) / 100.f; + + // difL *= kch * fach; if (deltaso[loy - begy][lox - begx] == 0.f) { transformed->L[y][x] = original->L[y][x]; @@ -3757,12 +3763,13 @@ void ImProcFunctions::Exclude_Local(int sen, float **deltaso, float **buflight, difa = rsv->a[loy - begy][lox - begx] - original->a[y][x]; difb = rsv->b[loy - begy][lox - begx] - original->b[y][x]; - // difa *= factorx * (100.f + realstrch * falu * falL) / 100.f; - // difb *= factorx * (100.f + realstrch * falu * falL) / 100.f; + // difa *= factorx * (100.f + realstrch * falu * falL) / 100.f; + // difb *= factorx * (100.f + realstrch * falu * falL) / 100.f; difa *= factorx * (100.f + realstrchdE) / 100.f; difb *= factorx * (100.f + realstrchdE) / 100.f; - // difa *= kch * fach; - // difb *= kch * fach; + + // difa *= kch * fach; + // difb *= kch * fach; if (deltaso[loy - begy][lox - begx] == 0.f) { transformed->a[y][x] = original->a[y][x]; //rsv->a[loy - begy][lox - begx]; @@ -3781,7 +3788,8 @@ void ImProcFunctions::Exclude_Local(int sen, float **deltaso, float **buflight, difL = rsv->L[loy - begy][lox - begx] - original->L[y][x]; difL *= (100.f + realstrdE) / 100.f; - // difL *= kch * fach; + + // difL *= kch * fach; if (deltaso[loy - begy][lox - begx] == 0.f) { // printf ("0"); @@ -3797,8 +3805,9 @@ void ImProcFunctions::Exclude_Local(int sen, float **deltaso, float **buflight, difb = rsv->b[loy - begy][lox - begx] - original->b[y][x]; difa *= (100.f + realstrchdE) / 100.f; difb *= (100.f + realstrchdE) / 100.f; - // difa *= kch * fach; - // difb *= kch * fach; + + // difa *= kch * fach; + // difb *= kch * fach; if (deltaso[loy - begy][lox - begx] == 0.f) { // printf ("0"); @@ -3824,13 +3833,18 @@ void ImProcFunctions::Exclude_Local(int sen, float **deltaso, float **buflight, } -void ImProcFunctions::transit_shapedetect(int senstype, LabImage * bufexporig, LabImage * originalmask, float **buflight, float **bufchro, float **buf_a_cat, float ** buf_b_cat, const float hueref, const float chromaref, const float lumaref, float sobelref, float ** blend2, const struct local_params & lp, LabImage * original, LabImage * transformed, int cx, int cy, int sk) +void ImProcFunctions::transit_shapedetect(int senstype, LabImage * bufexporig, LabImage * originalmask, float **buflight, float **bufchro, float **buf_a_cat, float ** buf_b_cat, float ** bufhh, bool HHutili, const float hueref, const float chromaref, const float lumaref, float sobelref, float ** blend2, const struct local_params & lp, LabImage * original, LabImage * transformed, int cx, int cy, int sk) { BENCHFUN { const float ach = (float)lp.trans / 100.f; float varsens = lp.sensex; + if (senstype == 0) //Color and Light + { + varsens = lp.sens; + } + if (senstype == 1) //exposure { varsens = lp.sensex; @@ -3849,7 +3863,7 @@ void ImProcFunctions::transit_shapedetect(int senstype, LabImage * bufexporig, L if (senstype == 4 || senstype == 5) //retinex { varsens = lp.sensh; - } + } if (senstype == 6 || senstype == 7) //cbdl { @@ -3873,17 +3887,31 @@ void ImProcFunctions::transit_shapedetect(int senstype, LabImage * bufexporig, L float refa = chromaref * cos(hueref); float refb = chromaref * sin(hueref); + bool expshow = ((lp.showmaskexpmet == 1 || lp.showmaskexpmet == 2) && senstype == 1); + bool colshow = ((lp.showmaskcolmet == 1 || lp.showmaskcolmet == 2) && senstype == 0); + LabImage *origblur = nullptr; origblur = new LabImage(GW, GH); LabImage *origblurmask = nullptr; - float radius = (2.f + 0.2f * lp.blurexp) / sk; + float radius = 3.f; + + if (senstype == 1) + { + radius = (2.f + 0.2f * lp.blurexp) / sk; + } + + if (senstype == 0) + { + radius = (2.f + 0.2f * lp.blurcol) / sk; + } bool usemask = (lp.showmaskexpmet == 2 || lp.enaExpMask) && senstype == 1; + bool usemaskcol = (lp.showmaskcolmet == 2 || lp.enaColorMask) && senstype == 0; - if (usemask) + if (usemask || usemaskcol) { origblurmask = new LabImage(GW, GH); @@ -3980,7 +4008,7 @@ void ImProcFunctions::transit_shapedetect(int senstype, LabImage * bufexporig, L float csob = 0.f; float rs = 0.f; - if (senstype == 1) { + if (senstype == 1 || senstype == 0) { csob = (blend2[loy - begy][lox - begx]) / 100.f ; if (csob > 60.f) { @@ -3998,23 +4026,33 @@ void ImProcFunctions::transit_shapedetect(int senstype, LabImage * bufexporig, L rsob = 1.1f * lp.struexp * rs; } - if (usemask) { + if (lp.struco > 0.f && rs > 0.f && senstype == 0) { + rsob = 1.1f * lp.struco * rs; + } + + if (usemask || usemaskcol) { dE = rsob + sqrt(SQR(refa - origblurmask->a[y][x] / 327.68f) + SQR(refb - origblurmask->b[y][x] / 327.68f) + SQR(lumaref - origblurmask->L[y][x] / 327.68f)); } else { dE = rsob + sqrt(SQR(refa - origblur->a[y][x] / 327.68f) + SQR(refb - origblur->b[y][x] / 327.68f) + SQR(lumaref - rL)); } - float cli = 1.f; - float clc = 1.f; - float cla = 1.f; - float clb = 1.f; + float cli = 0.f; + float clc = 0.f; + float cla = 0.f; + float clb = 0.f; + float hhro = 0.f; + + if (HHutili) { + hhro = bufhh[loy - begy][lox - begx]; + } cli = (buflight[loy - begy][lox - begx]); clc = (bufchro[loy - begy][lox - begx]); - if (senstype == 1) { + if (senstype == 1 || senstype == 0) { cla = buf_a_cat[loy - begy][lox - begx]; clb = buf_b_cat[loy - begy][lox - begx]; + // printf("a=%f b=%f", cla, clb); } float reducdE = 0.f; @@ -4042,6 +4080,13 @@ void ImProcFunctions::transit_shapedetect(int senstype, LabImage * bufexporig, L float realstradE = reducdE * cla; float realstrbdE = reducdE * clb; float realstrchdE = reducdE * clc; + float realhhdE = reducdE * hhro; + + float addh = 0.f; +// float chromhr = sqrt(SQR(original->a[y][x]) + SQR(original->b[y][x])); +// float2 sincosval; +// sincosval.y = 1.f; +// sincosval.x = 0.0f; if (rL > 0.1f) { //to avoid crash with very low gamut in rare cases ex : L=0.01 a=0.5 b=-0.9 @@ -4059,6 +4104,7 @@ void ImProcFunctions::transit_shapedetect(int senstype, LabImage * bufexporig, L case 1: { // inside transition zone float factorx = localFactor; float diflc = 0.f; + float newhr = 0.f; if (senstype == 4 || senstype == 6 || senstype == 2 || senstype == 3) {//all except color and light (TODO) and exposure float lightc = bufexporig->L[loy - begy][lox - begx]; @@ -4067,11 +4113,22 @@ void ImProcFunctions::transit_shapedetect(int senstype, LabImage * bufexporig, L float diflc = lightc * fli - original->L[y][x]; diflc *= factorx; transformed->L[y][x] = CLIP(original->L[y][x] + diflc); - } else if (senstype == 1) {//exposure the TODO color and light + } else if (senstype == 1 || senstype == 0) {//exposure the TODO color and light transformed->L[y][x] = CLIP(original->L[y][x] + 328.f * factorx * realstrdE);//kch fach diflc = 328.f * factorx * realstrdE; } + if (HHutili) { + addh = 0.01f * realhhdE * factorx; + newhr = rhue + addh; + + if (newhr > rtengine::RT_PI) { + newhr -= 2 * rtengine::RT_PI; + } else if (newhr < -rtengine::RT_PI) { + newhr += 2 * rtengine::RT_PI; + } + } + if (senstype == 7) { float difab = bufexporig->L[loy - begy][lox - begx] - sqrt(SQR(original->a[y][x]) + SQR(original->b[y][x])); float difa = difab * cos(rhue); @@ -4080,16 +4137,24 @@ void ImProcFunctions::transit_shapedetect(int senstype, LabImage * bufexporig, L difb *= factorx * (100.f + realstrchdE) / 100.f; transformed->a[y][x] = CLIPC(original->a[y][x] + difa); transformed->b[y][x] = CLIPC(original->b[y][x] + difb); - } else { + } /* else if (senstype == 0 && HHutili) { + + float fac = (100.f + factorx * realstrchdE) / 100.f; + + sincosval = xsincosf(newhr); + transformed->a[y][x] = CLIPC(chromhr * sincosval.y * fac) ; + transformed->b[y][x] = CLIPC(chromhr * sincosval.x * fac); + + } */else { float flia = 1.f; float flib = 1.f; float chra = bufexporig->a[loy - begy][lox - begx]; float chrb = bufexporig->b[loy - begy][lox - begx]; - if (senstype != 1) { + if (senstype == 4 || senstype == 6 || senstype == 2 || senstype == 3 || senstype == 0) { flia = flib = ((100.f + realstrchdE) / 100.f); - } else { + } else if (senstype == 1) { flia = (100.f + realstradE) / 100.f; flib = (100.f + realstrbdE) / 100.f; } @@ -4102,7 +4167,7 @@ void ImProcFunctions::transit_shapedetect(int senstype, LabImage * bufexporig, L transformed->a[y][x] = CLIPC(original->a[y][x] + difa); transformed->b[y][x] = CLIPC(original->b[y][x] + difb); - if ((lp.showmaskexpmet == 1 || lp.showmaskexpmet == 2) && senstype == 1) { + if (expshow || colshow) { transformed->L[y][x] = CLIP(12000.f + diflc); transformed->a[y][x] = CLIPC(difa); transformed->b[y][x] = CLIPC(difb); @@ -4115,17 +4180,29 @@ void ImProcFunctions::transit_shapedetect(int senstype, LabImage * bufexporig, L case 2: { // inside selection => full effect, no transition float diflc = 0.f; + float newhr = 0.f; if (senstype == 4 || senstype == 6 || senstype == 2 || senstype == 3) {//retinex & cbdl float lightc = bufexporig->L[loy - begy][lox - begx]; float fli = ((100.f + realstrdE) / 100.f); float diflc = lightc * fli - original->L[y][x]; transformed->L[y][x] = CLIP(original->L[y][x] + diflc); - } else if (senstype == 1) { + } else if (senstype == 1 || senstype == 0) { transformed->L[y][x] = CLIP(original->L[y][x] + 328.f * realstrdE);//kch fach diflc = 328.f * realstrdE; } + if (HHutili) { + addh = 0.01f * realhhdE; + newhr = rhue + addh; + + if (newhr > rtengine::RT_PI) { + newhr -= 2 * rtengine::RT_PI; + } else if (newhr < -rtengine::RT_PI) { + newhr += 2 * rtengine::RT_PI; + } + } + if (senstype == 7) {//cbdl chroma float difab = bufexporig->L[loy - begy][lox - begx] - sqrt(SQR(original->a[y][x]) + SQR(original->b[y][x])); float difa = difab * cos(rhue); @@ -4134,15 +4211,22 @@ void ImProcFunctions::transit_shapedetect(int senstype, LabImage * bufexporig, L difb *= (100.f + realstrchdE) / 100.f; transformed->a[y][x] = CLIPC(original->a[y][x] + difa); transformed->b[y][x] = CLIPC(original->b[y][x] + difb); - } else { + }/* else if (senstype == 0 && HHutili) { + + float fac = (100.f + realstrchdE) / 100.f; + + sincosval = xsincosf(newhr); + transformed->a[y][x] = CLIPC(chromhr * sincosval.y * fac) ; + transformed->b[y][x] = CLIPC(chromhr * sincosval.x * fac); + */else { float flia = 1.f; float flib = 1.f; float chra = bufexporig->a[loy - begy][lox - begx]; float chrb = bufexporig->b[loy - begy][lox - begx]; - if (senstype != 1) { + if (senstype == 4 || senstype == 6 || senstype == 2 || senstype == 3 || senstype == 0) { flia = flib = (100.f + realstrchdE) / 100.f; - } else { + } else if (senstype == 1) { flia = (100.f + realstradE) / 100.f; flib = (100.f + realstrbdE) / 100.f; } @@ -4153,7 +4237,7 @@ void ImProcFunctions::transit_shapedetect(int senstype, LabImage * bufexporig, L transformed->a[y][x] = CLIPC(original->a[y][x] + difa); transformed->b[y][x] = CLIPC(original->b[y][x] + difb); - if ((lp.showmaskexpmet == 1 || lp.showmaskexpmet == 2) && senstype == 1) { + if (expshow || colshow) { transformed->L[y][x] = CLIP(12000.f + diflc); transformed->a[y][x] = CLIPC(difa); transformed->b[y][x] = CLIPC(difb); @@ -4210,950 +4294,6 @@ void ImProcFunctions::transit_shapedetect(int senstype, LabImage * bufexporig, L } } - -void ImProcFunctions::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) -{ - BENCHFUN -// chroma and lightnesse - const float ach = (float)lp.trans / 100.f; - - //chroma - constexpr float amplchsens = 2.5f; - constexpr float achsens = (amplchsens - 1.f) / (100.f - 20.f); //20. default locallab.sensi - constexpr float bchsens = 1.f - 20.f * achsens; - const float multchro = lp.sens * achsens + bchsens; - - //luma - constexpr float ampllumsens = 2.f; - constexpr float alumsens = (ampllumsens - 1.f) / (100.f - 20.f); //20. default locallab.sensi - constexpr float blumsens = 1.f - 20.f * alumsens; - const float multlum = lp.sens * alumsens + blumsens; - - //skin - constexpr float amplchsensskin = 1.6f; - constexpr float achsensskin = (amplchsensskin - 1.f) / (100.f - 20.f); //20. default locallab.sensi - constexpr float bchsensskin = 1.f - 20.f * achsensskin; - const float multchroskin = lp.sens * achsensskin + bchsensskin; - - //transition = difficult to avoid artifact with scope on flat area (sky...) - constexpr float delhu = 0.05f; //between 0.05 and 0.2 ==> minima for scope - constexpr float delhuhr = 0.1f; // same - - - const float aplus = (1.f - lp.chro) / delhu; - const float bplus = 1.f - aplus * hueplus; - const float amoins = (lp.chro - 1.f) / delhu; - const float bmoins = 1.f - amoins * huemoins; - - const float apl = (-1.f) / delhu; - const float bpl = - apl * hueplus; - const float amo = 1.f / delhu; - const float bmo = - amo * huemoins; - - - const float pb = 4.f; - const float pa = (1.f - pb) / 40.f; - - const float ahu = 1.f / (2.8f * lp.sens - 280.f); - const float bhu = 1.f - ahu * 2.8f * lp.sens; - - //luma - constexpr float lumdelta = 11.f; //11 - float modlum = lumdelta * multlum; - float refa = chromaref * cos(hueref); - float refb = chromaref * sin(hueref); - -// const float moddE = 2.f; - sobelref /= 100.; - - if (sobelref > 60.) { - sobelref = 60.; - } - - sobelref = log(1.f + sobelref); - - // constant and variables to prepare shape detection - if (lumaref + modlum >= 100.f) { - modlum = (100.f - lumaref) / 2.f; - } - - if (lumaref - modlum <= 0.f) { - modlum = (lumaref) / 2.f; - } - - float aa, bb, aaa, bbb, ccc; - float reducac = settings->reduchigh;//0.85f; - float reducac2 = settings->reduclow;//0.2f; - - float vinf = (lumaref + modlum) / 100.f; - float vi = (lumaref - modlum) / 100.f; - ImProcFunctions::secondeg_begin(reducac, vi, aa, bb); //parabolic - ImProcFunctions::secondeg_end(reducac, vinf, aaa, bbb, ccc); //parabolic - float vinf2 = (lumaref + modlum) / 100.f; - float vi2 = (lumaref - modlum) / 100.f; - float aaaa, bbbb, cccc, aO, bO; - ImProcFunctions::secondeg_end(reducac2, vinf2, aaaa, bbbb, cccc); //parabolic - ImProcFunctions::secondeg_begin(reducac2, vi2, aO, bO); //parabolic - - float hueplushr = Color::huelab_to_huehsv2(hueplus); - float huemoinshr = Color::huelab_to_huehsv2(huemoins); - - int GW = transformed->W; - int GH = transformed->H; - - LabImage *origblur = nullptr; - - origblur = new LabImage(GW, GH); - LabImage *origblurmask = nullptr; - - - float radius = 3.f / sk; - - if (lp.showmaskcolmet == 2 || lp.enaColorMask) { - origblurmask = new LabImage(GW, GH); - -#ifdef _OPENMP - #pragma omp parallel -#endif - { - gaussianBlur(originalmask->L, origblurmask->L, GW, GH, radius); - gaussianBlur(originalmask->a, origblurmask->a, GW, GH, radius); - gaussianBlur(originalmask->b, origblurmask->b, GW, GH, radius); - } - } - -#ifdef _OPENMP - #pragma omp parallel -#endif - { - gaussianBlur(original->L, origblur->L, GW, GH, radius); - gaussianBlur(original->a, origblur->a, GW, GH, radius); - gaussianBlur(original->b, origblur->b, GW, GH, radius); - } - - - if (call <= 3) { - //Todo optimization in this first part with bufcolorig and bufcoltra - -#ifdef _OPENMP - #pragma omp parallel if (multiThread) -#endif - { -#ifdef __SSE2__ - float atan2Buffer[transformed->W] ALIGNED16; - float sqrtBuffer[transformed->W] ALIGNED16; - vfloat c327d68v = F2V(327.68f); -#endif - -#ifdef _OPENMP - #pragma omp for schedule(dynamic,16) -#endif - - for (int y = 0; y < transformed->H; y++) - { - const int loy = cy + y; - const bool isZone0 = loy > lp.yc + lp.ly || loy < lp.yc - lp.lyT; // whole line is zone 0 => we can skip a lot of processing - - if (isZone0) { // outside selection and outside transition zone => no effect, keep original values - continue; - } - -#ifdef __SSE2__ - int i = 0; - - for (; i < transformed->W - 3; i += 4) { - vfloat av = LVFU(origblur->a[y][i]); - vfloat bv = LVFU(origblur->b[y][i]); - STVF(atan2Buffer[i], xatan2f(bv, av)); - STVF(sqrtBuffer[i], _mm_sqrt_ps(SQRV(bv) + SQRV(av)) / c327d68v); - } - - for (; i < transformed->W; i++) { - atan2Buffer[i] = xatan2f(origblur->b[y][i], origblur->a[y][i]); - sqrtBuffer[i] = sqrt(SQR(origblur->b[y][i]) + SQR(origblur->a[y][i])) / 327.68f; - } - -#endif - - - for (int x = 0; x < transformed->W; x++) { - const int lox = cx + x; - const int begx = int (lp.xc - lp.lxL); - const int begy = int (lp.yc - lp.lyT); - - int zone = 0; - - float localFactor = 1.f; - - if (lp.shapmet == 0) { - calcTransition(lox, loy, ach, lp, zone, localFactor); - } else if (lp.shapmet == 1) { - calcTransitionrect(lox, loy, ach, lp, zone, localFactor); - } - - if (zone == 0) { - continue; - } - - -#ifdef __SSE2__ - float rhue = atan2Buffer[x]; - float rchro = sqrtBuffer[x]; -#else - - float rhue = xatan2f(origblur->b[y][x], origblur->a[y][x]); - - float rchro = sqrt(SQR(origblur->b[y][x]) + SQR(origblur->a[y][x])) / 327.68f; -#endif - float rhuehr = Color::huelab_to_huehsv2(rhue); - - float rL = origblur->L[y][x] / 327.68f; - float rLL = origblur->L[y][x] / 327.68f; - - if (fabs(origblur->b[y][x]) < 0.01f) { - origblur->b[y][x] = 0.01f; - } - - //Sobel - float csob = (blend2[loy - begy][lox - begx]) / 100.f ; - - if (csob > 60.f) { - csob = 60.f; - } - - csob = log(1.f + csob + 0.001f); - float rs = sobelref / csob; - - float dE = 0.f; - float rhuemask = 0.f; - float rchromask = 0.f; - float rLmask = 0.f; - float rsob = 0.f; - - if (lp.struco > 0.f && rs > 0.f) { - rsob = 1.1f * lp.struco * (rs); - } - - if (lp.showmaskcolmet == 2 || lp.enaColorMask) { - rhuemask = xatan2f(origblurmask->b[y][x], origblurmask->a[y][x]); - rchromask = sqrt(SQR(origblurmask->b[y][x]) + SQR(origblurmask->a[y][x])) / 327.68f; - rLmask = origblurmask->L[y][x] / 327.68f; - dE = rsob + sqrt(SQR(refa - origblurmask->a[y][x] / 327.68f) + SQR(refb - origblurmask->b[y][x] / 327.68f) + SQR(lumaref - origblurmask->L[y][x] / 327.68f)); - } else { - dE = rsob + sqrt(SQR(refa - origblur->a[y][x] / 327.68f) + SQR(refb - origblur->b[y][x] / 327.68f) + SQR(lumaref - rL)); - rhuemask = rhue; - rchromask = rchro; - rLmask = rL; - } - - //retriev data curve lightness - float cli = (buflight[loy - begy][lox - begx]); - //parameters for linear interpolation in function of real hue - float apluscligh = (1.f - cli) / delhu; - float bpluscligh = 1.f - apluscligh * hueplus; - float amoinscligh = (cli - 1.f) / delhu; - float bmoinscligh = 1.f - amoinscligh * huemoins; - - //chroma curve - float cchro = (bufchro[loy - begy][lox - begx]); - float apluscurv = (1.f - cchro) / delhu; - float bpluscurv = 1.f - apluscurv * hueplus; - float amoinscurv = (cchro - 1.f) / delhu; - float bmoinscurv = 1.f - amoinscurv * huemoins; - - //chroma slider - float cchroslid = (bufchroslid[loy - begy][lox - begx]); - float apluschroslid = (1.f - cchroslid) / delhu; - float bpluschroslid = 1.f - apluschroslid * hueplus; - float amoinschroslid = (cchroslid - 1.f) / delhu; - float bmoinschroslid = 1.f - amoinschroslid * huemoins; - - //HH - - float hhro = (bufhh[loy - begy][lox - begx]); - float aplushh = (1.f - hhro) / delhuhr; - float bplushh = 1.f - aplushh * hueplushr; - float amoinshh = (hhro - 1.f) / delhuhr; - float bmoinshh = 1.f - amoinshh * huemoinshr; - - float clisl = (buflightslid[loy - begy][lox - begx]); - //parameters for linear interpolation in function of real hue - float aplusclighsl = (1.f - clisl) / delhu; - float bplusclighsl = 1.f - aplusclighsl * hueplus; - float amoinsclighsl = (clisl - 1.f) / delhu; - float bmoinsclighsl = 1.f - amoinsclighsl * huemoins; - - - //prepare shape detection - // real... = coefficient to apply at lightness, chroma,... - float realchro = 1.f; - float realchroslid = 1.f; - float realcurv = 1.f; - float realcligh = 1.f; - float realclighsl = 1.f; - float realhh = 0.f; - //evaluate delta Hue and delta Chro - float deltachro = fabs(rchromask - chromaref); - - float deltahue = fabs(rhuemask - hueref); - - if (deltahue > rtengine::RT_PI) { - deltahue = - (deltahue - 2.f * rtengine::RT_PI); - } - - //pseudo deltaE - float deltaE = 20.f * deltahue + deltachro; //pseudo deltaE between 0 and 280 - float deltaL = fabs(lumaref - rLmask); //between 0 and 100 - - float kchchro = 1.f; - float kch = 1.f; - float khu = 0.f; - float fach = 1.f; - float falu = 1.f; - - /* - //kch acts on luma - if (deltachro < 160.f * SQR(lp.sens / 100.f)) { - kch = 1.f; - } else { - float ck = 160.f * SQR(lp.sens / 100.f); - float ak = 1.f / (ck - 160.f); - float bk = -160.f * ak; - kch = ak * deltachro + bk; - } - - if (lp.sens < 40.f) { - kch = pow(kch, pa * lp.sens + pb); //increase under 40 - } - */ - //kch and kgcchro acts on luma and chroma - - - if (deltachro < 160.f * SQR(lp.sens / 100.f)) { - kch = kchchro = 1.f; - } else { - float ck = 160.f * SQR(lp.sens / 100.f); - float ak = 1.f / (ck - 160.f); - float bk = -160.f * ak; - kch = kchchro = ak * deltachro + bk; - } - - float kkch = 1.f; - kkch = pa * lp.sens + pb; - float kch0 = kch; - - if (lp.sens < 40.f) { - kch = kchchro = pow(kch0, kkch); //increase under 40 - float dEsens = moddE * lp.sens; - float kdE = 1.f; - - if (dE > dEsens) { - kdE = 1.f; - } else { - kdE = SQR(SQR(dE / dEsens)); - } - - if (deltahue < 0.3f) {//for very low differences with smal values of scope - kchchro = kch = pow(kch0, (1.f + kdE * moddE * (3.f - 10.f * deltahue)) * kkch); - } - } - - //take into account deltaE but only for mode >= super - float dEsensall = lp.sens; - float kD = 1.f; - - if (dE < dEsensall) { - kD = 1.f; - } else { - kD = pow(dEsensall / dE, powdE);// 5 empirical - } - - bool kzon = false; - - - //transition = difficult to avoid artifact with scope on flat area (sky...) - //hue detection - //for each quart calculate realchro, realcligh,... in function of Hue pixel - if ((hueref + dhue) < rtengine::RT_PI && rhue < hueplus && rhue > huemoins) { //transition are good - if (rhue >= hueplus - delhu) { - realchro = aplus * rhue + bplus; - realchroslid = apluschroslid * rhue + bpluschroslid; - realcurv = apluscurv * rhue + bpluscurv; - realcligh = apluscligh * rhue + bpluscligh; - realclighsl = aplusclighsl * rhue + bplusclighsl; - realhh = aplushh * rhuehr + bplushh; - khu = apl * rhue + bpl; - - } else if (rhue < huemoins + delhu) { - realchro = amoins * rhue + bmoins; - realchroslid = amoinschroslid * rhue + bmoinschroslid; - realcurv = amoinscurv * rhue + bmoinscurv; - realcligh = amoinscligh * rhue + bmoinscligh; - realclighsl = amoinsclighsl * rhue + bmoinsclighsl; - realhh = amoinshh * rhuehr + bmoinshh; - - khu = amo * rhue + bmo; - - } else { - realchro = lp.chro; - realchroslid = cchroslid; - realcurv = cchro; - realcligh = cli; - realclighsl = clisl; - realhh = hhro; - khu = 1.f; - - } - - kzon = true; - } else if ((hueref + dhue) >= rtengine::RT_PI && (rhue > huemoins || rhue < hueplus)) { - if (rhue >= hueplus - delhu && rhue < hueplus) { - realchro = aplus * rhue + bplus; - realchroslid = apluschroslid * rhue + bpluschroslid; - realcurv = apluscurv * rhue + bpluscurv; - realcligh = apluscligh * rhue + bpluscligh; - realclighsl = aplusclighsl * rhue + bplusclighsl; - realhh = aplushh * rhuehr + bplushh; - - khu = apl * rhue + bpl; - - } else if (rhue >= huemoins && rhue < huemoins + delhu) { - realchro = amoins * rhue + bmoins; - realchroslid = amoinschroslid * rhue + bmoinschroslid; - realcurv = amoinscurv * rhue + bmoinscurv; - realcligh = amoinscligh * rhue + bmoinscligh; - realclighsl = amoinsclighsl * rhue + bmoinsclighsl; - realhh = amoinshh * rhuehr + bmoinshh; - - khu = amo * rhue + bmo; - - } else { - realchro = lp.chro; - realchroslid = cchroslid; - realcurv = cchro; - realcligh = cli; - realclighsl = clisl; - realhh = hhro; - khu = 1.f; - - } - - kzon = true; - } - - if ((hueref - dhue) > -rtengine::RT_PI && rhue < hueplus && rhue > huemoins) { - if (rhue >= hueplus - delhu && rhue < hueplus) { - realchro = aplus * rhue + bplus; - realchroslid = apluschroslid * rhue + bpluschroslid; - realcurv = apluscurv * rhue + bpluscurv; - realcligh = apluscligh * rhue + bpluscligh; - realclighsl = aplusclighsl * rhue + bplusclighsl; - realhh = aplushh * rhuehr + bplushh; - - khu = apl * rhue + bpl; - - } else if (rhue >= huemoins && rhue < huemoins + delhu) { - realchro = amoins * rhue + bmoins; - realchroslid = amoinschroslid * rhue + bmoinschroslid; - realcurv = amoinscurv * rhue + bmoinscurv; - realcligh = amoinscligh * rhue + bmoinscligh; - realclighsl = amoinsclighsl * rhue + bmoinsclighsl; - realhh = amoinshh * rhuehr + bmoinshh; - - khu = amo * rhue + bmo; - - } else { - realchro = lp.chro; - realchroslid = cchroslid; - realcurv = cchro; - realcligh = cli; - realclighsl = clisl; - realhh = hhro; - khu = 1.f; - - } - - kzon = true; - } else if ((hueref - dhue) <= -rtengine::RT_PI && (rhue > huemoins || rhue < hueplus)) { - if (rhue >= hueplus - delhu && rhue < hueplus) { - realchro = aplus * rhue + bplus; - realchroslid = apluschroslid * rhue + bpluschroslid; - realcurv = apluscurv * rhue + bpluscurv; - realcligh = apluscligh * rhue + bpluscligh; - realclighsl = aplusclighsl * rhue + bplusclighsl; - realhh = aplushh * rhuehr + bplushh; - - khu = apl * rhue + bpl; - - } else if (rhue >= huemoins && rhue < huemoins + delhu) { - realchro = amoins * rhue + bmoins; - realchroslid = amoinschroslid * rhue + bmoinschroslid; - realcurv = amoinscurv * rhue + bmoinscurv; - realcligh = amoinscligh * rhue + bmoinscligh; - realclighsl = amoinsclighsl * rhue + bmoinsclighsl; - // realhh = amoinshh * rhuehr + bmoinshh; - - khu = amo * rhue + bmo; - - } else { - realchro = lp.chro; - realchroslid = cchroslid; - realcurv = cchro; - realcligh = cli; - realclighsl = clisl; - realhh = hhro; - khu = 1.f; - - } - - kzon = true; - } - - realcligh *= kD; - realchro *= kD; - realchroslid *= kD; - realcurv *= kD; - realclighsl *= kD; - - if (settings->detectshape == false) { - - //detection of deltaE and deltaL - if (lp.sens <= 20.f) { //to try... - //fach and kch acts on luma - if (deltaE < 2.8f * lp.sens) { - fach = khu; - } else { - fach = khu * (ahu * deltaE + bhu); - } - - float kcr = 10.f; - - if (rchro < kcr) { - fach *= (1.f / (kcr * kcr)) * rchro * rchro; - } - - //can be probably improved - if (lp.qualmet >= 1) { - } else { - fach = 1.f; - } - - //falu acts on chroma - if (deltaL < lp.sens) { - falu = 1.f; - } else { - falu = 1.f;// alum * deltaL + blum; - } - - } - } - - if (kzon) { - if (lp.sens < 60.f) { //arbitrary value - if (hueref < -1.1f && hueref > -2.8f) { // detect blue sky - if (chromaref > 0.f && chromaref < 35.f * multchro) { // detect blue sky - if ((rhue > -2.79f && rhue < -1.11f) && (rchro < 35.f * multchro)) { - realchro *= 0.9f; - realcurv *= 0.9f; - realchroslid *= 0.9f; - } else { - realchro = 1.f; - realcurv = 1.f; - realchroslid = 1.f; - - } - } - } else { - realchro = lp.chro; - realcurv = cchro; - realchroslid = cchroslid; - - } - - if (lp.sens < 50.f && lp.chro > 0.f) { - if (hueref > -0.1f && hueref < 1.6f) { // detect skin - if (chromaref > 0.f && chromaref < 55.f * multchroskin) { // detect skin - if ((rhue > -0.09f && rhue < 1.59f) && (rchro < 55.f * multchroskin)) { - realchro *= 0.9f; - realcurv *= 0.9f; - realchroslid *= 0.9f; - - } else { - realchro = 1.f; - realcurv = 1.f; - realchroslid = 1.f; - - - } - } - } else { - realchro = lp.chro; - realcurv = cchro; - realchroslid = cchroslid; - - } - } - } - - } - - float kLinf = rLL / (100.f); - float kLsup = kLinf; - - float kdiff = 1.f; - - if (kzon) { ///rhue < hueplus && rhue > huemoins - - if ((rLL > (lumaref - modlum) && rLL < (lumaref + modlum))) { - kdiff = 1.f; - } else if (rLL > 0.f && rLL <= (lumaref - modlum)) { - kdiff = (aa * kLinf * kLinf + bb * kLinf); //parabolic - - if (kdiff < 0.01f) { - kdiff = 0.01f; - } - } else if (rLL <= 100.f && rLL >= (lumaref + modlum)) { - - kdiff = (aaa * kLsup * kLsup + bbb * kLsup + ccc); //parabolic - - if (kdiff < 0.01f) { - kdiff = 0.01f; - } - - } - - //end luma - } else { - float ktes = 1.f; - - if ((rLL > (lumaref - modlum) && rLL < (lumaref + modlum))) { - kdiff = ktes; - } else if (rLL > 0.f && rLL <= (lumaref - modlum)) { - - kdiff = (ktes * (aO * kLinf * kLinf + bO * kLinf)); //parabolic - - if (kdiff < 0.01f) { - kdiff = 0.01f; - } - - } else if (rLL <= 100.f && rLL >= (lumaref + modlum)) { - - kdiff = (ktes * (aaaa * kLsup * kLsup + bbbb * kLsup + cccc)); //parabolic - - if (kdiff < 0.01f) { - kdiff = 0.01f; - } - - } - - } - - float kcr = 100.f * lp.thr; - float falL = 1.f; - - if (rchro < kcr && chromaref > kcr) { // reduce artifacts in grey tones near hue spot and improve algorithm - falL *= pow(rchro / kcr, lp.iterat / 10.f); - } - - - float th_r = 0.01f; - float2 sincosval; - sincosval.y = 1.f; - sincosval.x = 0.0f; - float ddhue = 0.f; -// printf("kch=%f ", kch); - - if (rL > th_r) { //to avoid crash with very low gamut in rare cases ex : L=0.01 a=0.5 b=-0.9 - switch (zone) { - case 0: { // outside selection and outside transition zone => no effect, keep original values - transformed->L[y][x] = original->L[y][x]; - transformed->a[y][x] = original->a[y][x]; - transformed->b[y][x] = original->b[y][x]; - break; - } - - case 1: { // inside transition zone - float lumnew = bufcolorig->L[loy - begy][lox - begx]; - - float lightcont; - - if (lp.qualcurvemet >= 1) { - - if (lllocalcurve) { - float lumprov = lllocalcurve[lumnew * 1.9f]; - float lumred = 0.526316f * lumprov; //0.526316f - lumnew = lumnew + (lumred - lumnew) / 4.f;//reduce sensibility - - } - - if (loclhCurve && LHutili) { - float l_r;//Luminance Lab in 0..1 - l_r = lumnew / 32768.f; - { - float khu = 1.9f; //in reserve in case of! - - float valparam = float ((loclhCurve[500.f * Color::huelab_to_huehsv2(rhue)] - 0.5f)); //get l_r=f(H) - float valparamneg; - valparamneg = valparam; - - if (valparam > 0.f) { - l_r = (1.f - valparam) * l_r + valparam * (1.f - SQR(((SQR(1.f - min(l_r, 1.0f)))))); - } else - //for negative - { - l_r *= (1.f + khu * valparamneg); - } - } - - lumnew = l_r * 32768.f; - } - - } - - if ((lp.ligh != 0.f || lp.cont != 0) && lp.curvact == false) { - calclight(lumnew, lp.ligh, lumnew, lightCurveloc); //replace L-curve - lightcont = lumnew; - - } else { - lightcont = lumnew; - } - - float factorx = localFactor; - float fli = 1.f; - float flisl = 1.f; - - // float flichrosl = 1.f; - - if (lp.curvact && (lp.ligh != 0.f || lp.cont != 0)) { - flisl = ((100.f + realclighsl * falL * kchchro) / 100.f); //luma transition - } - - if (lp.curvact && lp.chro != 0.f) { - realchro = realchroslid;//chroma transition - } - - if (lp.qualcurvemet >= 2) { - fli = ((100.f + realcligh * falL) / 100.f); //luma transition - } - - float flicur = 1.f; - - if (lp.qualcurvemet != 0) { - flicur = ((100.f + realcurv * factorx * falu * falL * kchchro) / 100.f); - } - - float fac = flicur * (100.f + factorx * realchro * falu * falL) / 100.f; //chroma factor transition - - float diflc = lightcont * fli * flisl - original->L[y][x]; - kdiff *= fach * kch; - diflc *= kdiff ; - diflc *= kch ; - - diflc *= factorx; //transition lightness - transformed->L[y][x] = CLIP((original->L[y][x] + diflc)); - - // if (lp.showmaskcolmet == 1 || lp.showmaskcolmet == 2) { - // transformed->L[y][x] = CLIP(12000.f + diflc); //CLIPL((original->L[y][x] + diflc)); - // } - - if (lochhCurve && lp.qualcurvemet >= 1 && HHutili) { - float addh = 0.f; - float chromhr = sqrt(SQR(original->a[y][x]) + SQR(original->b[y][x])); - - if (lp.qualcurvemet == 1) { - float valparam = float ((lochhCurve[500.f * Color::huelab_to_huehsv2(rhue)] - 0.5f)); //get H=f(H) 1.7 optimisation ! - // float hh = 0.5 * ((rhue / rtengine::RT_PI) + 1.); - // float valparam = float ((lochhCurve[500.f * hh] - 0.5f)); //get H=f(H) 1.7 optimisation ! - ddhue = 2 * valparam; - - addh = ddhue * factorx; - // float dh = (0.02f*addh - 1.f) * rtengine::RT_PI; - } - - if (lp.qualcurvemet >= 2) { - addh = 0.01f * realhh * factorx; - } - - float newhr = rhue + addh; - - if (newhr > rtengine::RT_PI) { - newhr -= 2 * rtengine::RT_PI; - } else if (newhr < -rtengine::RT_PI) { - newhr += 2 * rtengine::RT_PI; - } - - sincosval = xsincosf(newhr); - transformed->a[y][x] = CLIPC(chromhr * sincosval.y * fac) ; - transformed->b[y][x] = CLIPC(chromhr * sincosval.x * fac); - - if (lp.showmaskcolmet == 1 || lp.showmaskcolmet == 2) { - transformed->a[y][x] = CLIPC(chromhr * sincosval.y * (fac - 1.f)) ; - transformed->b[y][x] = CLIPC(chromhr * sincosval.x * (fac - 1.f)); - } - } else { - - transformed->a[y][x] = CLIPC(original->a[y][x] * fac) ; - transformed->b[y][x] = CLIPC(original->b[y][x] * fac); - - if (lp.showmaskcolmet == 1 || lp.showmaskcolmet == 2) { - transformed->L[y][x] = CLIP(12000.f + diflc); - transformed->a[y][x] = CLIPC(original->a[y][x] * (fac - 1.f)) ; - transformed->b[y][x] = CLIPC(original->b[y][x] * (fac - 1.f)); - } - } - - break; - } - - case 2: { // inside selection => full effect, no transition - float lumnew = bufcolorig->L[loy - begy][lox - begx]; - float lightcont; - - if (lp.qualcurvemet >= 1) { - - if (lllocalcurve) { - float lumprov = lllocalcurve[lumnew * 1.9f]; - float lumred = 0.526316 * lumprov; // 0.526316f - lumnew = lumnew + (lumred - lumnew) / 4.f;//reduce sensibility - } - - if (loclhCurve && LHutili) { - float l_r;//Luminance Lab in 0..1 - l_r = lumnew / 32768.f; - { - float khu = 1.9f; - - float valparam = float ((loclhCurve[500.f * Color::huelab_to_huehsv2(rhue)] - 0.5f)); //get l_r=f(H) - float valparamneg; - valparamneg = valparam; - - if (valparam > 0.f) { - l_r = (1.f - valparam) * l_r + valparam * (1.f - SQR(((SQR(1.f - min(l_r, 1.0f)))))); - } else - //for negative - { - l_r *= (1.f + khu * valparamneg); - } - } - - lumnew = l_r * 32768.f; - } - - } - - - if ((lp.ligh != 0.f || lp.cont != 0.f) && lp.curvact == false) { - calclight(lumnew, lp.ligh, lumnew, lightCurveloc); //replace L-curve - lightcont = lumnew; - - } else { - lightcont = lumnew; - } - - float fli = 1.f; - float flisl = 1.f; - - if (lp.curvact && (lp.ligh != 0.f || lp.cont != 0)) { - flisl = ((100.f + realclighsl * falL) / 100.f); //luma transition - // flisl = ((100.f + realclighsl) / 100.f); //luma transition - } - - if (lp.curvact && lp.chro != 0.f) { - realchro = realchroslid;//chroma transition - //realchro = 1.f; - } - - if (lp.qualcurvemet >= 2) { - fli = ((100.f + realcligh * falL) / 100.f);//luma transition - // fli = ((100.f + realcligh ) / 100.f);//luma transition - } - - float flicur = 1.f; - - if (lp.qualcurvemet != 0) { - flicur = ((100.f + realcurv * falu * falL * kchchro) / 100.f); - } - - float fac = flicur * (100.f + realchro * falu * falL) / 100.f; //chroma factor transition7 - - float diflc = lightcont * fli * flisl - original->L[y][x]; - - kdiff *= fach * kch; - diflc *= kdiff ; - diflc *= kch ; - transformed->L[y][x] = CLIP((original->L[y][x] + diflc)); - -// if (lp.showmaskcolmet == 1 || lp.showmaskcolmet == 2) { -// transformed->L[y][x] = CLIP(12000.f + diflc); //CLIPL((original->L[y][x] + diflc)); -// } - - - if (lochhCurve && lp.qualcurvemet >= 1 && HHutili) { - float addh = 0.f; - float chromhr = sqrt(SQR(original->a[y][x]) + SQR(original->b[y][x])); - - if (lp.qualcurvemet == 1) { - float valparam = float ((lochhCurve[500.f * Color::huelab_to_huehsv2(rhue)] - 0.5f)); //get H=f(H) 1.7 optimisation ! - - ddhue = 2 * valparam; - - addh = ddhue; - } - - if (lp.qualcurvemet >= 2) { - addh = 0.01f * realhh; - - } - - float newhr = rhue + addh; - - if (newhr > rtengine::RT_PI) { - newhr -= 2 * rtengine::RT_PI; - } else if (newhr < -rtengine::RT_PI) { - newhr += 2 * rtengine::RT_PI; - } - - sincosval = xsincosf(newhr); - transformed->a[y][x] = CLIPC(chromhr * sincosval.y * fac) ; - transformed->b[y][x] = CLIPC(chromhr * sincosval.x * fac); - - if (lp.showmaskcolmet == 1 || lp.showmaskcolmet == 2) { - transformed->a[y][x] = CLIPC(chromhr * sincosval.y * (fac - 1.f)) ; - transformed->b[y][x] = CLIPC(chromhr * sincosval.x * (fac - 1.f)); - } - - } else { - transformed->a[y][x] = CLIPC(original->a[y][x] * fac) ; - transformed->b[y][x] = CLIPC(original->b[y][x] * fac); - - if (lp.showmaskcolmet == 1 || lp.showmaskcolmet == 2) { - transformed->L[y][x] = CLIP(12000.f + diflc); - transformed->a[y][x] = CLIPC(original->a[y][x] * (fac - 1.f)) ; - transformed->b[y][x] = CLIPC(original->b[y][x] * (fac - 1.f)); - } - } - - - } - - } - } - - // } - } - } - } - - - } - - delete origblur; - - if (lp.showmaskcolmet == 2 || lp.enaColorMask) { - delete origblurmask; - } -} - void ImProcFunctions::InverseColorLight_Local(const struct local_params & lp, LUTf & lightCurveloc, LabImage * original, LabImage * transformed, int cx, int cy, const float hueplus, const float huemoins, const float hueref, const float dhue, const float chromaref, const float lumaref, int sk) { // BENCHFUN @@ -6102,7 +5242,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, 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, + 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 & hueref, double & chromaref, double & lumaref, double & sobelref, int llColorMask, int llExpMask) { //general call of others functions : important return hueref, chromaref, lumaref @@ -7814,8 +6954,9 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o } } - transit_shapedetect(2, bufexporig, nullptr, buflight, bufl_ab, nullptr, nullptr, hueref, chromaref, lumaref, sobelref, nullptr, lp, original, transformed, cx, cy, sk); + transit_shapedetect(2, bufexporig, nullptr, buflight, bufl_ab, nullptr, nullptr, nullptr, false, hueref, chromaref, lumaref, sobelref, nullptr, lp, original, transformed, cx, cy, sk); //call Expo_vibr_Local with first parameter = 2 for vibrance + // transit_shapedetect(6, loctemp, nullptr, buflight, bufchrom, nullptr, nullptr, nullptr, false, hueref, chromaref, lumaref, sobelref, nullptr, lp, original, transformed, cx, cy, sk); } @@ -8038,7 +7179,7 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o } - transit_shapedetect(6, loctemp, nullptr, buflight, bufchrom, nullptr, nullptr, hueref, chromaref, lumaref, sobelref, nullptr, lp, original, transformed, cx, cy, sk); + transit_shapedetect(6, loctemp, nullptr, buflight, bufchrom, nullptr, nullptr, nullptr, false, hueref, chromaref, lumaref, sobelref, nullptr, lp, original, transformed, cx, cy, sk); delete loctemp; @@ -8080,7 +7221,7 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o } } - transit_shapedetect(7, loctempch, nullptr, buflight, bufchrom, nullptr, nullptr, hueref, chromaref, lumaref, sobelref, nullptr, lp, original, transformed, cx, cy, sk); + transit_shapedetect(7, loctempch, nullptr, buflight, bufchrom, nullptr, nullptr, nullptr, false, hueref, chromaref, lumaref, sobelref, nullptr, lp, original, transformed, cx, cy, sk); delete loctempch; } @@ -8190,7 +7331,7 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o } } - transit_shapedetect(3, bufexporig, nullptr, buflight, bufl_ab, nullptr, nullptr, hueref, chromaref, lumaref, sobelref, nullptr, lp, original, transformed, cx, cy, sk); + transit_shapedetect(3, bufexporig, nullptr, buflight, bufl_ab, nullptr, nullptr, nullptr, false, hueref, chromaref, lumaref, sobelref, nullptr, lp, original, transformed, cx, cy, sk); } @@ -8492,7 +7633,7 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o if (!lp.invret) { - transit_shapedetect(4, bufreti, nullptr, buflight, bufchro, nullptr, nullptr, hueref, chromaref, lumaref, sobelref, nullptr, lp, original, transformed, cx, cy, sk); + transit_shapedetect(4, bufreti, nullptr, buflight, bufchro, nullptr, nullptr, nullptr, false, hueref, chromaref, lumaref, sobelref, nullptr, lp, original, transformed, cx, cy, sk); } else { InverseReti_Local(lp, original, transformed, tmpl, cx, cy, 0); @@ -8576,7 +7717,7 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o if (!lp.invret) { - transit_shapedetect(5, tmpl, nullptr, buflight, bufchro, nullptr, nullptr, hueref, chromaref, lumaref, sobelref, nullptr, lp, original, transformed, cx, cy, sk); + transit_shapedetect(5, tmpl, nullptr, buflight, bufchro, nullptr, nullptr, nullptr, false, hueref, chromaref, lumaref, sobelref, nullptr, lp, original, transformed, cx, cy, sk); } else { InverseReti_Local(lp, original, transformed, tmpl, cx, cy, 1); @@ -9092,7 +8233,7 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o } } - transit_shapedetect(1, bufexporig, originalmaskexp, buflight, bufl_ab, buf_a_cat, buf_b_cat, hueref, chromaref, lumaref, sobelref, blend2, lp, original, transformed, cx, cy, sk); + transit_shapedetect(1, bufexporig, originalmaskexp, buflight, bufl_ab, buf_a_cat, buf_b_cat, nullptr, false, hueref, chromaref, lumaref, sobelref, blend2, lp, original, transformed, cx, cy, sk); //view mask } @@ -9114,6 +8255,7 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o //local color and light if (!lp.inv && (lp.chro != 0 || lp.ligh != 0.f || lp.cont != 0 || lp.qualcurvemet != 0 || lp.showmaskcolmet == 2 || lp.enaColorMask || lp.showmaskcolmet == 3 || lp.showmaskcolmet == 4) && lp.colorena) { // || lllocalcurve)) { //interior ellipse renforced lightness and chroma //locallutili +// if (!lp.inv && (lp.chro != 0 || lp.ligh != 0.f || lp.cont != 0 || lp.showmaskcolmet == 2 || lp.enaColorMask || lp.showmaskcolmet == 3 || lp.showmaskcolmet == 4) && lp.colorena) { // || lllocalcurve)) { //interior ellipse renforced lightness and chroma //locallutili float hueplus = hueref + dhue; float huemoins = hueref - dhue; @@ -9133,9 +8275,10 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o LabImage *bufmaskblurcol = nullptr; LabImage *originalmaskcol = nullptr; - float chpro = 1.f; - float cligh = 1.f; - float clighL = 1.f; + float chprosl = 1.f; + float chprocu = 1.f; + // float cligh = 1.f; + // float clighL = 1.f; int bfh = 0.f, bfw = 0.f; bfh = int (lp.ly + lp.lyT) + del; //bfw bfh real size of square zone @@ -9147,6 +8290,8 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o JaggedArray bufhh(bfw, bfh); JaggedArray blend2(bfw, bfh); JaggedArray buforigchro(bfw, bfh); + JaggedArray buf_a(bfw, bfh); + JaggedArray buf_b(bfw, bfh); float adjustr = 1.0f; @@ -9199,6 +8344,8 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o } bufchro[ir][jr] = 0.f; + buf_a[ir][jr] = 0.f; + buf_b[ir][jr] = 0.f; bufchroslid[ir][jr] = 0.f; buflightslid[ir][jr] = 0.f; buflight[ir][jr] = 0.f; @@ -9508,6 +8655,10 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o } if (lp.showmaskcolmet == 0 || lp.showmaskcolmet == 1 || lp.showmaskcolmet == 2 || lp.enaColorMask) { + + LabImage *bufcolcalc = nullptr; + bufcolcalc = new LabImage(bfw, bfh); + #ifdef _OPENMP #pragma omp parallel for schedule(dynamic,16) #endif @@ -9518,101 +8669,105 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o int loy = cy + y; if (lox >= begx && lox < xEn && loy >= begy && loy < yEn) { - chpro = 0.f; + bufcolcalc->a[loy - begy][lox - begx] = bufcolorig->a[loy - begy][lox - begx]; + bufcolcalc->b[loy - begy][lox - begx] = bufcolorig->b[loy - begy][lox - begx]; + bufcolcalc->L[loy - begy][lox - begx] = bufcolorig->L[loy - begy][lox - begx]; - //Chroma curve if (cclocalcurve && lp.qualcurvemet != 0) { // C=f(C) curve - float chromat = sqrt(SQR(bufcolorig->a[loy - begy][lox - begx]) + SQR(bufcolorig->b[loy - begy][lox - begx])); + 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 - chpro = CLIPCHRO(ampli * ch - ampli); //ampli = 25.f arbitrary empirical coefficient between 5 and 50 - bufchro[loy - begy][lox - begx] = chpro; + chprocu = CLIPCHRO(ampli * ch - ampli); //ampli = 25.f arbitrary empirical coefficient between 5 and 50 } - chpro = 0.f; - - if (lp.chro != 0.f && lp.curvact) { - // process to improve eg same as in Lab adjustements + if (lp.chro != 0.f) { float ch; float ampli = 70.f; ch = (1.f + 0.01f * lp.chro) ; //* (chromat * adjustr) / ((chromat + 0.00001f) * adjustr); //ch between 0 and 0 50 or more if (ch <= 1.f) {//convert data curve near values of slider -100 + 100, to be used after to detection shape - chpro = 99.f * ch - 99.f; + chprosl = 99.f * ch - 99.f; } else { - chpro = CLIPCHRO(ampli * ch - ampli); //ampli = 25.f arbitrary empirical coefficient between 5 and 50 + chprosl = CLIPCHRO(ampli * ch - ampli); //ampli = 25.f arbitrary empirical coefficient between 5 and 50 } - - bufchroslid[loy - begy][lox - begx] = chpro; } - if (lochhCurve && lp.qualcurvemet >= 2 && HHutili) { - float hhforcurv = xatan2f(bufcolorig->b[loy - begy][lox - begx], bufcolorig->a[loy - begy][lox - begx]); + bufchro[loy - begy][lox - begx] = chprosl + chprocu; + + if (lochhCurve && HHutili && lp.qualcurvemet != 0) { + float hhforcurv = xatan2f(bufcolcalc->b[loy - begy][lox - begx], bufcolcalc->a[loy - begy][lox - begx]); float valparam = float ((lochhCurve[500.f * Color::huelab_to_huehsv2(hhforcurv)] - 0.5f)); //get H=f(H) 1.7 optimisation ! float ddhue = CLIPRET(200.f * valparam); bufhh[loy - begy][lox - begx] = ddhue;//valparamdh; // } - //slider lightness - clighL = 0.f; - if ((lp.ligh != 0.f || lp.cont != 0) && lp.curvact) { - float lL; - float lighLnew; - float amplil = 140.f; - float lighL = bufcolorig->L[loy - begy][lox - begx]; + if ((lp.ligh != 0.f || lp.cont != 0)) { + float lighLnew = 0.f; + float lighL = bufcolcalc->L[loy - begy][lox - begx]; calclight(lighL, lp.ligh, lighLnew, lightCurveloc); //replace L-curve - lL = lighLnew / lighL; + bufcolcalc->L[loy - begy][lox - begx] = lighLnew; + } - if (lL <= 1.f) {//convert data curve near values of slider -100 + 100, to be used after to detection shape - clighL = 99.f * lL - 99.f; - } else { - clighL = CLIPLIG(amplil * lL - amplil); //ampli = 25.f arbitrary empirical coefficient between 5 and 150 + if (lllocalcurve && locallutili && lp.qualcurvemet != 0) {// L=f(L) curve enhanced + float lh; + float lighn = bufcolcalc->L[loy - begy][lox - begx]; + lh = 0.5f * (lllocalcurve[lighn * 2.f]);// / ((lighn + 0.00001f) * 1.9f) ; // / ((lighn) / 1.9f) / 3.61f; //lh between 0 and 0 50 or more + bufcolcalc->L[loy - begy][lox - begx] = lh; + } + + if (loclhCurve && LHutili && lp.qualcurvemet != 0) { + float l_r;//Luminance Lab in 0..1 + float rhue = xatan2f(bufcolcalc->b[loy - begy][lox - begx], bufcolcalc->a[loy - begy][lox - begx]); + float lighn = bufcolcalc->L[loy - begy][lox - begx]; + + l_r = lighn / 32768.f; + { + float khu = 1.9f; //in reserve in case of! + + float valparam = float ((loclhCurve[500.f * Color::huelab_to_huehsv2(rhue)] - 0.5f)); //get l_r=f(H) + float valparamneg; + valparamneg = valparam; + + if (valparam > 0.f) { + l_r = (1.f - valparam) * l_r + valparam * (1.f - SQR(((SQR(1.f - min(l_r, 1.0f)))))); + } else + //for negative + { + l_r *= (1.f + khu * valparamneg); + } } - buflightslid[loy - begy][lox - begx] = clighL; - // printf("cl=%f ", clighL); + bufcolcalc->L[loy - begy][lox - begx] = l_r * 32768.f; + } - cligh = 0.f; + float rL; + rL = CLIPRET((bufcolcalc->L[loy - begy][lox - begx] - bufcolorig->L[loy - begy][lox - begx]) / 328.f); + buflight[loy - begy][lox - begx] = rL; + + float rA; + rA = CLIPRET((bufcolcalc->a[loy - begy][lox - begx] - bufcolorig->a[loy - begy][lox - begx]) / 328.f); + buf_a[loy - begy][lox - begx] = rA; + + + float rB; + rB = CLIPRET((bufcolcalc->b[loy - begy][lox - begx] - bufcolorig->b[loy - begy][lox - begx]) / 328.f); + buf_b[loy - begy][lox - begx] = rB; + - //luma curve - if (lllocalcurve && lp.qualcurvemet >= 2) {// L=f(L) curve enhanced - float lh; - float amplil = 25.f; - float lighn = bufcolorig->L[loy - begy][lox - begx]; - lh = (lllocalcurve[lighn * 1.9f]) / ((lighn + 0.00001f) * 1.9f) ; // / ((lighn) / 1.9f) / 3.61f; //lh between 0 and 0 50 or more - cligh = CLIPLIG(amplil * lh - amplil); - buflight[loy - begy][lox - begx] = cligh; - } } } - if (lp.qualcurvemet >= 4) { - JaggedArray blend(bfw, bfh); - float contrastf = lp.sensexclu / 100.f; - buildBlendMask(bufcolorig->L, blend, bfw, bfh, contrastf, 1.f, true); - -#ifdef _OPENMP - #pragma omp parallel for -#endif - - for (int i = 0; i < bfh; ++i) { - for (int j = 0; j < bfw; ++j) { - if (blend[i][j] > 0.05f) { - blend[i][j] = 1.22361f * sqrt(blend[i][j]) - 0.22361f; - } - - buflight[i][j] = intp(blend[i][j], buflight[i][j], 0.f);// tmpsob->L[i][j]); - bufchro[i][j] = intp(blend[i][j], bufchro[i][j], 0.f); //tmpsob->L[i][j] ); - } - } - } + delete bufcolcalc; } - ColorLight_Local(moddE, powdE, call, bufcolorig, originalmaskcol, buflight, bufchro, bufchroslid, bufhh, buflightslid, LHutili, HHutili, hueplus, huemoins, hueref, dhue, chromaref, lumaref, sobelref, blend2, lllocalcurve, loclhCurve, lochhCurve, lightCurveloc, lp, original, transformed, cx, cy, sk); + transit_shapedetect(0, bufcolorig, originalmaskcol, buflight, bufchro, buf_a, buf_b, bufhh, HHutili, hueref, chromaref, lumaref, sobelref, blend2, lp, original, transformed, cx, cy, sk); + + // ColorLight_Local(moddE, powdE, call, bufcolorig, originalmaskcol, buflight, bufchro, bufchroslid, bufhh, buflightslid, LHutili, HHutili, hueplus, huemoins, hueref, dhue, chromaref, lumaref, sobelref, blend2, lllocalcurve, loclhCurve, lochhCurve, lightCurveloc, lp, original, transformed, cx, cy, sk); if (call <= 3) { diff --git a/rtengine/procevents.h b/rtengine/procevents.h index a1f7c193f..2b321324b 100644 --- a/rtengine/procevents.h +++ b/rtengine/procevents.h @@ -646,6 +646,7 @@ enum ProcEventCode { Evlocallabblurexpde = 616, EvLocallabEnaColorMask = 617, EvLocallabEnaExpMask = 618, + Evlocallabblurcolde = 619, NUMOFEVENTS }; diff --git a/rtengine/procparams.cc b/rtengine/procparams.cc index 4ae9d48fe..08bccefac 100644 --- a/rtengine/procparams.cc +++ b/rtengine/procparams.cc @@ -2341,7 +2341,7 @@ LocallabParams::LocallabSpot::LocallabSpot() : isvisible(true), shape("ELI"), spotMethod("norm"), - sensiexclu(19), + sensiexclu(12), struc(0), shapeMethod("IND"), locX(250), @@ -2361,8 +2361,9 @@ LocallabParams::LocallabSpot::LocallabSpot() : lightness(0), contrast(0), chroma(0), - sensi(19), + sensi(15), structcol(0), + blurcolde(5), blendmaskcol(0), qualitycurveMethod("none"), llcurve{(double)DCT_NURBS, 0.0, 0.0, 1.0, 1.0}, @@ -2399,12 +2400,12 @@ LocallabParams::LocallabSpot::LocallabSpot() : protectskins(false), avoidcolorshift(true), pastsattog(true), - sensiv(19), + sensiv(15), skintonescurve{(double)DCT_Linear}, // Soft Light expsoft(false), streng(0), - sensisf(19), + sensisf(15), // Lab Region explabregion(false), // Blur & Noise @@ -2430,7 +2431,7 @@ LocallabParams::LocallabSpot::LocallabSpot() : neigh(50), vart(200), dehaz(0), - sensih(19), + sensih(15), localTgaincurve{(double)FCT_MinMaxCPoints, 0.0, 0.12, 0.35, 0.35, 0.70, 0.50, 0.35, 0.35, 1.00, 0.12, 0.35, 0.35}, inversret(false), // Sharpening @@ -2455,7 +2456,7 @@ LocallabParams::LocallabSpot::LocallabSpot() : mult{100.0, 100.0, 100.0, 100.0, 100.0}, chromacbdl(0), threshold(20.0), - sensicb(19), + sensicb(15), // Denoise expdenoi(false), noiselumf(0), @@ -2515,6 +2516,7 @@ bool LocallabParams::LocallabSpot::operator ==(const LocallabSpot& other) const && CCmaskcurve == other.CCmaskcurve && LLmaskcurve == other.LLmaskcurve && HHmaskcurve == other.HHmaskcurve + && blurcolde == other.blurcolde // Exposure && expexpose == other.expexpose && expcomp == other.expcomp @@ -3598,6 +3600,7 @@ int ProcParams::save(const Glib::ustring& fname, const Glib::ustring& fname2, bo saveToKeyfile(!pedited || pedited->locallab.spots.at(i).chroma, "Locallab", "Chroma_" + std::to_string(i), spot.chroma, keyFile); saveToKeyfile(!pedited || pedited->locallab.spots.at(i).sensi, "Locallab", "Sensi_" + std::to_string(i), spot.sensi, keyFile); saveToKeyfile(!pedited || pedited->locallab.spots.at(i).structcol, "Locallab", "Structcol_" + std::to_string(i), spot.structcol, keyFile); + saveToKeyfile(!pedited || pedited->locallab.spots.at(i).blurcolde, "Locallab", "Blurcolde_" + std::to_string(i), spot.blurcolde, keyFile); saveToKeyfile(!pedited || pedited->locallab.spots.at(i).blendmaskcol, "Locallab", "Blendmaskcol_" + std::to_string(i), spot.blendmaskcol, keyFile); saveToKeyfile(!pedited || pedited->locallab.spots.at(i).qualitycurveMethod, "Locallab", "QualityCurveMethod_" + std::to_string(i), spot.qualitycurveMethod, keyFile); saveToKeyfile(!pedited || pedited->locallab.spots.at(i).llcurve, "Locallab", "LLCurve_" + std::to_string(i), spot.llcurve, keyFile); @@ -4824,6 +4827,7 @@ int ProcParams::load(const Glib::ustring& fname, ParamsEdited* pedited) assignFromKeyfile(keyFile, "Locallab", "Chroma_" + std::to_string(i), pedited, spot.chroma, spotEdited.chroma); assignFromKeyfile(keyFile, "Locallab", "Sensi_" + std::to_string(i), pedited, spot.sensi, spotEdited.sensi); assignFromKeyfile(keyFile, "Locallab", "Structcol_" + std::to_string(i), pedited, spot.structcol, spotEdited.structcol); + assignFromKeyfile(keyFile, "Locallab", "Blurcolde_" + std::to_string(i), pedited, spot.blurcolde, spotEdited.blurcolde); assignFromKeyfile(keyFile, "Locallab", "Blendmaskcol_" + std::to_string(i), pedited, spot.blendmaskcol, spotEdited.blendmaskcol); assignFromKeyfile(keyFile, "Locallab", "QualityCurveMethod_" + std::to_string(i), pedited, spot.qualitycurveMethod, spotEdited.qualitycurveMethod); assignFromKeyfile(keyFile, "Locallab", "LLCurve_" + std::to_string(i), pedited, spot.llcurve, spotEdited.llcurve); diff --git a/rtengine/procparams.h b/rtengine/procparams.h index b21d931a7..91eb31c11 100644 --- a/rtengine/procparams.h +++ b/rtengine/procparams.h @@ -963,6 +963,7 @@ struct LocallabParams { int chroma; int sensi; int structcol; + int blurcolde; int blendmaskcol; Glib::ustring qualitycurveMethod; std::vector llcurve; diff --git a/rtengine/refreshmap.cc b/rtengine/refreshmap.cc index c35ecc73e..fd6d966e0 100644 --- a/rtengine/refreshmap.cc +++ b/rtengine/refreshmap.cc @@ -645,7 +645,8 @@ int refreshmap[rtengine::NUMOFEVENTS] = { LUMINANCECURVE, // Evlocallabblendmaskexp LUMINANCECURVE, // Evlocallabblurexpde LUMINANCECURVE, // EvLocallabEnaColorMask - LUMINANCECURVE // EvLocallabEnaExpMask + LUMINANCECURVE, // EvLocallabEnaExpMask + LUMINANCECURVE // Evlocallabblurcolde }; diff --git a/rtengine/simpleprocess.cc b/rtengine/simpleprocess.cc index d5742cc0e..909cff6f7 100644 --- a/rtengine/simpleprocess.cc +++ b/rtengine/simpleprocess.cc @@ -1152,7 +1152,7 @@ private: 1); // 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, loclhCurve, lochhCurve, locccmasCurve, lcmasutili, locllmasCurve, llmasutili, lochhmasCurve, lhmasutili, locccmasexpCurve, lcmasexputili, locllmasexpCurve, llmasexputili, lochhmasexpCurve, lhmasexputili, + 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, huere, chromare, lumare, sobelre, 0, 0); // Clear local curves diff --git a/rtgui/controlspotpanel.cc b/rtgui/controlspotpanel.cc index e0cb4b52c..e9b680fd4 100644 --- a/rtgui/controlspotpanel.cc +++ b/rtgui/controlspotpanel.cc @@ -212,7 +212,7 @@ ControlSpotPanel::ControlSpotPanel(): Gtk::Label* const labelqualitymethod = Gtk::manage(new Gtk::Label(M("TP_LOCALLAB_QUAL_METHOD") + ":")); ctboxqualitymethod->pack_start(*labelqualitymethod, Gtk::PACK_SHRINK, 4); ctboxqualitymethod->set_tooltip_markup(M("TP_LOCALLAB_METHOD_TOOLTIP")); - qualityMethod_->append(M("TP_LOCALLAB_STD")); +// qualityMethod_->append(M("TP_LOCALLAB_STD")); qualityMethod_->append(M("TP_LOCALLAB_ENH")); qualityMethod_->append(M("TP_LOCALLAB_ENHDEN")); qualityMethod_->set_active(1); @@ -235,7 +235,7 @@ ControlSpotPanel::ControlSpotPanel(): artifBox->pack_start(*iter_); iter_->setAdjusterListener(this); artifFrame->add(*artifBox); - pack_start(*artifFrame); +// pack_start(*artifFrame); show_all(); } diff --git a/rtgui/locallab.cc b/rtgui/locallab.cc index f8e7bbea4..0ce5ed44c 100644 --- a/rtgui/locallab.cc +++ b/rtgui/locallab.cc @@ -75,8 +75,9 @@ Locallab::Locallab(): lightness(Gtk::manage(new Adjuster(M("TP_LOCALLAB_LIGHTNESS"), -100, 100, 1, 0))), contrast(Gtk::manage(new Adjuster(M("TP_LOCALLAB_CONTRAST"), -100, 100, 1, 0))), chroma(Gtk::manage(new Adjuster(M("TP_LOCALLAB_CHROMA"), -100, 150, 1, 0))), - sensi(Gtk::manage(new Adjuster(M("TP_LOCALLAB_SENSI"), 0, 100, 1, 19))), + sensi(Gtk::manage(new Adjuster(M("TP_LOCALLAB_SENSI"), 0, 100, 1, 15))), structcol(Gtk::manage(new Adjuster(M("TP_LOCALLAB_STRUCCOL"), 0, 100, 1, 0))), + blurcolde(Gtk::manage(new Adjuster(M("TP_LOCALLAB_BLURDE"), 2, 100, 1, 5))), blendmaskcol(Gtk::manage(new Adjuster(M("TP_LOCALLAB_BLENDMASKCOL"), -100, 100, 1, 0))), // Exposure expcomp(Gtk::manage(new Adjuster(M("TP_EXPOSURE_EXPCOMP"), -200, 400, 5, 0))), @@ -92,10 +93,10 @@ Locallab::Locallab(): // Vibrance saturated(Gtk::manage(new Adjuster(M("TP_VIBRANCE_SATURATED"), -100., 100., 1., 0.))), pastels(Gtk::manage(new Adjuster(M("TP_VIBRANCE_PASTELS"), -100., 100., 1., 0.))), - sensiv(Gtk::manage(new Adjuster(M("TP_LOCALLAB_SENSI"), 0, 100, 1, 19))), + sensiv(Gtk::manage(new Adjuster(M("TP_LOCALLAB_SENSI"), 0, 100, 1, 15))), //Soft Light streng(Gtk::manage(new Adjuster(M("TP_LOCALLAB_STRENG"), 1, 100, 1, 1))), - sensisf(Gtk::manage(new Adjuster(M("TP_LOCALLAB_SENSI"), 1, 100, 1, 19))), + sensisf(Gtk::manage(new Adjuster(M("TP_LOCALLAB_SENSI"), 1, 100, 1, 15))), // Blur & Noise radius(Gtk::manage(new Adjuster(M("TP_LOCALLAB_RADIUS"), 1, 100, 1, 1))), strength(Gtk::manage(new Adjuster(M("TP_LOCALLAB_STRENGTH"), 0, 100, 1, 0))), @@ -106,14 +107,14 @@ Locallab::Locallab(): estop(Gtk::manage(new Adjuster(M("TP_LOCALLAB_ESTOP"), 10, 400, 1, 140))), scaltm(Gtk::manage(new Adjuster(M("TP_LOCALLAB_SCALTM"), 1, 100, 1, 10))), rewei(Gtk::manage(new Adjuster(M("TP_LOCALLAB_REWEI"), 0, 9, 1, 0))), - sensitm(Gtk::manage(new Adjuster(M("TP_LOCALLAB_SENSI"), 0, 100, 1, 19))), + sensitm(Gtk::manage(new Adjuster(M("TP_LOCALLAB_SENSI"), 0, 100, 1, 15))), // Retinex str(Gtk::manage(new Adjuster(M("TP_LOCALLAB_STR"), 0, 100, 1, 0))), chrrt(Gtk::manage(new Adjuster(M("TP_LOCALLAB_CHRRT"), 0, 100, 1, 0))), neigh(Gtk::manage(new Adjuster(M("TP_LOCALLAB_NEIGH"), 14, 200, 1, 50))),//14, 150, 1, 50))), vart(Gtk::manage(new Adjuster(M("TP_LOCALLAB_VART"), 50, 500, 1, 200))), dehaz(Gtk::manage(new Adjuster(M("TP_LOCALLAB_DEHAZ"), 0, 100, 1, 0))), - sensih(Gtk::manage(new Adjuster(M("TP_LOCALLAB_SENSIH"), 0, 100, 1, 19))), + sensih(Gtk::manage(new Adjuster(M("TP_LOCALLAB_SENSIH"), 0, 100, 1, 15))), // Sharpening sharcontrast(Gtk::manage(new Adjuster(M("TP_SHARPENING_CONTRAST"), 0, 200, 1, 20))), sharradius(Gtk::manage(new Adjuster(M("TP_LOCALLAB_SHARRADIUS"), 42, 500, 1, 4))), @@ -131,7 +132,7 @@ Locallab::Locallab(): // Contrast by detail levels chromacbdl(Gtk::manage(new Adjuster(M("TP_LOCALLAB_CHROMACBDL"), 0, 300, 1, 0))), threshold(Gtk::manage(new Adjuster(M("TP_DIRPYREQUALIZER_THRESHOLD"), 0, 100, 1, 20))), - sensicb(Gtk::manage(new Adjuster(M("TP_LOCALLAB_SENSICB"), 0, 100, 1, 19))), + sensicb(Gtk::manage(new Adjuster(M("TP_LOCALLAB_SENSICB"), 0, 100, 1, 15))), // Denoise noiselumf(Gtk::manage(new Adjuster(M("TP_LOCALLAB_NOISELUMFINE"), MINCHRO, MAXCHRO, 1, 0))), noiselumc(Gtk::manage(new Adjuster(M("TP_LOCALLAB_NOISELUMCOARSE"), MINCHRO, MAXCHROCC, 1, 0))), @@ -227,16 +228,17 @@ Locallab::Locallab(): sensi->setAdjusterListener(this); structcol->setAdjusterListener(this); + blurcolde->setAdjusterListener(this); blendmaskcol->setAdjusterListener(this); qualitycurveMethod->append(M("TP_LOCALLAB_CURVNONE")); qualitycurveMethod->append(M("TP_LOCALLAB_CURVCURR")); - qualitycurveMethod->append(M("TP_LOCALLAB_CURVENH")); +/* qualitycurveMethod->append(M("TP_LOCALLAB_CURVENH")); qualitycurveMethod->append(M("TP_LOCALLAB_CURVENHSU")); qualitycurveMethod->append(M("TP_LOCALLAB_CURVENCONTRAST")); qualitycurveMethod->append(M("TP_LOCALLAB_CURVENSOB2")); - +*/ qualitycurveMethod->set_active(0); qualitycurveMethod->set_tooltip_markup(M("TP_LOCALLAB_CURVEMETHOD_TOOLTIP")); qualitycurveMethodConn = qualitycurveMethod->signal_changed().connect(sigc::mem_fun(*this, &Locallab::qualitycurveMethodChanged)); @@ -277,6 +279,7 @@ Locallab::Locallab(): } LHshape->setBottomBarBgGradient(mLHshape); + llCurveEditorG->curveListComplete(); HHshape = static_cast(llCurveEditorG->addCurve(CT_Flat, "H(H)", nullptr, false, true)); HHshape->setIdentityValue(0.); @@ -294,7 +297,7 @@ Locallab::Locallab(): HHshape->setBottomBarBgGradient(mHHshape); - llCurveEditorG->curveListComplete(); + // llCurveEditorG->curveListComplete(); inversConn = invers->signal_toggled().connect(sigc::mem_fun(*this, &Locallab::inversChanged)); @@ -345,6 +348,7 @@ Locallab::Locallab(): superFrame->add(*superBox); colorBox->pack_start(*superFrame); colorBox->pack_start(*sensi); + colorBox->pack_start(*blurcolde); colorBox->pack_start(*structcol); Gtk::HBox* const qualcurvbox = Gtk::manage(new Gtk::HBox()); qualcurvbox->pack_start(*labqualcurv, Gtk::PACK_SHRINK, 4); @@ -1118,9 +1122,10 @@ void Locallab::read(const ProcParams* pp, const ParamsEdited* pedited) r->centerY = pp->locallab.spots.at(i).centerY; r->circrad = pp->locallab.spots.at(i).circrad; - if (pp->locallab.spots.at(i).qualityMethod == "std") { + /* if (pp->locallab.spots.at(i).qualityMethod == "std") { r->qualityMethod = 0; - } else if (pp->locallab.spots.at(i).qualityMethod == "enh") { + }*/ + if (pp->locallab.spots.at(i).qualityMethod == "enh") { r->qualityMethod = 1; } else { r->qualityMethod = 2; @@ -1218,9 +1223,9 @@ void Locallab::write(ProcParams* pp, ParamsEdited* pedited) r->centerY = newSpot->centerY; r->circrad = newSpot->circrad; - if (newSpot->qualityMethod == "std") { + /* if (newSpot->qualityMethod == "std") { r->qualityMethod = 0; - } else if (newSpot->qualityMethod == "enh") { + } */ if (newSpot->qualityMethod == "enh") { r->qualityMethod = 1; } else { r->qualityMethod = 2; @@ -1492,9 +1497,9 @@ void Locallab::write(ProcParams* pp, ParamsEdited* pedited) pp->locallab.spots.at(pp->locallab.selspot).centerY = r->centerY; pp->locallab.spots.at(pp->locallab.selspot).circrad = r->circrad; - if (r->qualityMethod == 0) { + /* if (r->qualityMethod == 0) { pp->locallab.spots.at(pp->locallab.selspot).qualityMethod = "std"; - } else if (r->qualityMethod == 1) { + } */ if (r->qualityMethod == 1) { pp->locallab.spots.at(pp->locallab.selspot).qualityMethod = "enh"; } else { pp->locallab.spots.at(pp->locallab.selspot).qualityMethod = "enhden"; @@ -1511,14 +1516,21 @@ void Locallab::write(ProcParams* pp, ParamsEdited* pedited) pp->locallab.spots.at(pp->locallab.selspot).chroma = chroma->getIntValue(); pp->locallab.spots.at(pp->locallab.selspot).sensi = sensi->getIntValue(); pp->locallab.spots.at(pp->locallab.selspot).structcol = structcol->getIntValue(); + pp->locallab.spots.at(pp->locallab.selspot).blurcolde = blurcolde->getIntValue(); if (qualitycurveMethod->get_active_row_number() == 0) { pp->locallab.spots.at(pp->locallab.selspot).qualitycurveMethod = "none"; } else if (qualitycurveMethod->get_active_row_number() == 1) { pp->locallab.spots.at(pp->locallab.selspot).qualitycurveMethod = "std"; - } else if (qualitycurveMethod->get_active_row_number() == 2) { + } /* else if (qualitycurveMethod->get_active_row_number() == 2) { pp->locallab.spots.at(pp->locallab.selspot).qualitycurveMethod = "enh"; - } + } else if (qualitycurveMethod->get_active_row_number() == 3) { + pp->locallab.spots.at(pp->locallab.selspot).qualitycurveMethod = "enhsup"; + } else if (qualitycurveMethod->get_active_row_number() == 4) { + pp->locallab.spots.at(pp->locallab.selspot).qualitycurveMethod = "contr"; + } else if (qualitycurveMethod->get_active_row_number() == 5) { + pp->locallab.spots.at(pp->locallab.selspot).qualitycurveMethod = "sob2"; + }*/ pp->locallab.spots.at(pp->locallab.selspot).llcurve = llshape->getCurve(); pp->locallab.spots.at(pp->locallab.selspot).cccurve = ccshape->getCurve(); @@ -1688,6 +1700,7 @@ void Locallab::write(ProcParams* pp, ParamsEdited* pedited) pe->locallab.spots.at(pp->locallab.selspot).CCmaskcurve = pe->locallab.spots.at(pp->locallab.selspot).CCmaskcurve || !CCmaskshape->isUnChanged(); pe->locallab.spots.at(pp->locallab.selspot).LLmaskcurve = pe->locallab.spots.at(pp->locallab.selspot).LLmaskcurve || !LLmaskshape->isUnChanged(); pe->locallab.spots.at(pp->locallab.selspot).HHmaskcurve = pe->locallab.spots.at(pp->locallab.selspot).HHmaskcurve || !HHmaskshape->isUnChanged(); + pe->locallab.spots.at(pp->locallab.selspot).blurcolde = pe->locallab.spots.at(pp->locallab.selspot).blurcolde || blurcolde->getEditedState(); pe->locallab.spots.at(pp->locallab.selspot).blendmaskcol = pe->locallab.spots.at(pp->locallab.selspot).blendmaskcol || blendmaskcol->getEditedState(); // Exposure pe->locallab.spots.at(pp->locallab.selspot).expexpose = pe->locallab.spots.at(pp->locallab.selspot).expexpose || !expexpose->get_inconsistent(); @@ -1834,6 +1847,7 @@ void Locallab::write(ProcParams* pp, ParamsEdited* pedited) pedited->locallab.spots.at(pp->locallab.selspot).CCmaskcurve = pedited->locallab.spots.at(pp->locallab.selspot).CCmaskcurve || !CCmaskshape->isUnChanged(); pedited->locallab.spots.at(pp->locallab.selspot).LLmaskcurve = pedited->locallab.spots.at(pp->locallab.selspot).LLmaskcurve || !LLmaskshape->isUnChanged(); pedited->locallab.spots.at(pp->locallab.selspot).HHmaskcurve = pedited->locallab.spots.at(pp->locallab.selspot).HHmaskcurve || !HHmaskshape->isUnChanged(); + pedited->locallab.spots.at(pp->locallab.selspot).blurcolde = pedited->locallab.spots.at(pp->locallab.selspot).blurcolde || blurcolde->getEditedState(); pedited->locallab.spots.at(pp->locallab.selspot).blendmaskcol = pedited->locallab.spots.at(pp->locallab.selspot).blendmaskcol || blendmaskcol->getEditedState(); // Exposure pedited->locallab.spots.at(pp->locallab.selspot).expexpose = pedited->locallab.spots.at(pp->locallab.selspot).expexpose || !expexpose->get_inconsistent(); @@ -2288,7 +2302,7 @@ void Locallab::inversChanged() if (multiImage && invers->get_inconsistent()) { sensi->show(); llCurveEditorG->show(); - curvactiv->show(); + curvactiv->hide(); qualitycurveMethod->show(); labqualcurv->show(); maskcolFrame->show(); @@ -2303,7 +2317,7 @@ void Locallab::inversChanged() } else { sensi->show(); llCurveEditorG->show(); - curvactiv->show(); + curvactiv->hide(); qualitycurveMethod->show(); labqualcurv->show(); maskcolFrame->show(); @@ -2517,6 +2531,7 @@ void Locallab::setDefaults(const ProcParams * defParams, const ParamsEdited * pe chroma->setDefault((double)defSpot->chroma); sensi->setDefault((double)defSpot->sensi); structcol->setDefault((double)defSpot->structcol); + blurcolde->setDefault((double)defSpot->blurcolde); blendmaskcol->setDefault((double)defSpot->blendmaskcol); // Exposure expcomp->setDefault((double)defSpot->expcomp); @@ -2596,6 +2611,7 @@ void Locallab::setDefaults(const ProcParams * defParams, const ParamsEdited * pe chroma->setDefaultEditedState(Irrelevant); sensi->setDefaultEditedState(Irrelevant); structcol->setDefaultEditedState(Irrelevant); + blurcolde->setDefaultEditedState(Irrelevant); blendmaskcol->setDefaultEditedState(Irrelevant); // Exposure expcomp->setDefaultEditedState(Irrelevant); @@ -2679,6 +2695,7 @@ void Locallab::setDefaults(const ProcParams * defParams, const ParamsEdited * pe chroma->setDefaultEditedState(defSpotState->chroma ? Edited : UnEdited); sensi->setDefaultEditedState(defSpotState->sensi ? Edited : UnEdited); structcol->setDefaultEditedState(defSpotState->structcol ? Edited : UnEdited); + blurcolde->setDefaultEditedState(defSpotState->blurcolde ? Edited : UnEdited); blendmaskcol->setDefaultEditedState(defSpotState->blendmaskcol ? Edited : UnEdited); // Exposure expcomp->setDefaultEditedState(defSpotState->expcomp ? Edited : UnEdited); @@ -2817,6 +2834,12 @@ void Locallab::adjusterChanged(Adjuster * a, double newval) } } + if (a == blurcolde) { + if (listener) { + listener->panelChanged(Evlocallabblurcolde, blurcolde->getTextValue()); + } + } + if (a == structcol) { if (listener) { listener->panelChanged(Evlocallabstructcol, structcol->getTextValue()); @@ -3288,6 +3311,7 @@ void Locallab::setBatchMode(bool batchMode) chroma->showEditedCB(); sensi->showEditedCB(); structcol->showEditedCB(); + blurcolde->showEditedCB(); blendmaskcol->showEditedCB(); // Exposure expcomp->showEditedCB(); @@ -3608,7 +3632,7 @@ void Locallab::updateLocallabGUI(const rtengine::procparams::ProcParams* pp, con qualitycurveMethod->set_active(0); } else if (pp->locallab.spots.at(index).qualitycurveMethod == "std") { qualitycurveMethod->set_active(1); - } else if (pp->locallab.spots.at(index).qualitycurveMethod == "enh") { + } /* else if (pp->locallab.spots.at(index).qualitycurveMethod == "enh") { qualitycurveMethod->set_active(2); } else if (pp->locallab.spots.at(index).qualitycurveMethod == "enhsup") { qualitycurveMethod->set_active(3); @@ -3617,7 +3641,7 @@ void Locallab::updateLocallabGUI(const rtengine::procparams::ProcParams* pp, con } else if (pp->locallab.spots.at(index).qualitycurveMethod == "sob2") { qualitycurveMethod->set_active(5); } - +*/ llshape->setCurve(pp->locallab.spots.at(index).llcurve); ccshape->setCurve(pp->locallab.spots.at(index).cccurve); LHshape->setCurve(pp->locallab.spots.at(index).LHcurve); @@ -3627,6 +3651,7 @@ void Locallab::updateLocallabGUI(const rtengine::procparams::ProcParams* pp, con CCmaskshape->setCurve(pp->locallab.spots.at(index).CCmaskcurve); LLmaskshape->setCurve(pp->locallab.spots.at(index).LLmaskcurve); HHmaskshape->setCurve(pp->locallab.spots.at(index).HHmaskcurve); + blurcolde->setValue(pp->locallab.spots.at(index).blurcolde); blendmaskcol->setValue(pp->locallab.spots.at(index).blendmaskcol); // Exposure @@ -3813,6 +3838,7 @@ void Locallab::updateLocallabGUI(const rtengine::procparams::ProcParams* pp, con CCmaskshape->setUnChanged(!spotState->CCmaskcurve); LLmaskshape->setUnChanged(!spotState->LLmaskcurve); HHmaskshape->setUnChanged(!spotState->HHmaskcurve); + blurcolde->setEditedState(spotState->blurcolde ? Edited : UnEdited); blendmaskcol->setEditedState(spotState->blendmaskcol ? Edited : UnEdited); // Exposure @@ -3944,7 +3970,7 @@ void Locallab::updateSpecificGUIState() if (multiImage && invers->get_inconsistent()) { sensi->show(); llCurveEditorG->show(); - curvactiv->show(); + curvactiv->hide(); qualitycurveMethod->show(); labqualcurv->show(); maskcolFrame->show(); @@ -3959,7 +3985,7 @@ void Locallab::updateSpecificGUIState() } else { sensi->show(); llCurveEditorG->show(); - curvactiv->show(); + curvactiv->hide(); qualitycurveMethod->show(); labqualcurv->show(); maskcolFrame->show(); diff --git a/rtgui/locallab.h b/rtgui/locallab.h index cf25baeb7..87f535653 100644 --- a/rtgui/locallab.h +++ b/rtgui/locallab.h @@ -93,6 +93,7 @@ private: Adjuster* const chroma; Adjuster* const sensi; Adjuster* const structcol; + Adjuster* const blurcolde; Adjuster* const blendmaskcol; // Exposure Adjuster* const expcomp; diff --git a/rtgui/paramsedited.cc b/rtgui/paramsedited.cc index 3ed6f1970..a2b0e9f03 100644 --- a/rtgui/paramsedited.cc +++ b/rtgui/paramsedited.cc @@ -949,6 +949,7 @@ void ParamsEdited::initFrom(const std::vector& locallab.spots.at(j).chroma = locallab.spots.at(j).chroma && pSpot.chroma == otherSpot.chroma; locallab.spots.at(j).sensi = locallab.spots.at(j).sensi && pSpot.sensi == otherSpot.sensi; locallab.spots.at(j).structcol = locallab.spots.at(j).structcol && pSpot.structcol == otherSpot.structcol; + locallab.spots.at(j).blurcolde = locallab.spots.at(j).blurcolde && pSpot.blurcolde == otherSpot.blurcolde; locallab.spots.at(j).blendmaskcol = locallab.spots.at(j).blendmaskcol && pSpot.blendmaskcol == otherSpot.blendmaskcol; locallab.spots.at(j).qualitycurveMethod = locallab.spots.at(j).qualitycurveMethod && pSpot.qualitycurveMethod == otherSpot.qualitycurveMethod; locallab.spots.at(j).llcurve = locallab.spots.at(j).llcurve && pSpot.llcurve == otherSpot.llcurve; @@ -2581,6 +2582,10 @@ void ParamsEdited::combine(rtengine::procparams::ProcParams& toEdit, const rteng toEdit.locallab.spots.at(i).sensi = mods.locallab.spots.at(i).sensi; } + if (locallab.spots.at(i).blurcolde) { + toEdit.locallab.spots.at(i).blurcolde = mods.locallab.spots.at(i).blurcolde; + } + if (locallab.spots.at(i).structcol) { toEdit.locallab.spots.at(i).structcol = mods.locallab.spots.at(i).structcol; } @@ -3946,6 +3951,7 @@ LocallabParamsEdited::LocallabSpotEdited::LocallabSpotEdited(bool v) : chroma(v), sensi(v), structcol(v), + blurcolde(v), blendmaskcol(v), qualitycurveMethod(v), llcurve(v), @@ -4084,6 +4090,7 @@ void LocallabParamsEdited::LocallabSpotEdited::set(bool v) chroma = v; sensi = v; structcol = v; + blurcolde = v; blendmaskcol = v; qualitycurveMethod = v; llcurve = v; diff --git a/rtgui/paramsedited.h b/rtgui/paramsedited.h index b040e6266..77825b262 100644 --- a/rtgui/paramsedited.h +++ b/rtgui/paramsedited.h @@ -488,6 +488,7 @@ public: bool chroma; bool sensi; bool structcol; + bool blurcolde; bool blendmaskcol; bool qualitycurveMethod; bool llcurve;