From 724cb27b988a7f5797dd1f5dac3fe0e8df662107 Mon Sep 17 00:00:00 2001 From: heckflosse Date: Tue, 2 Apr 2019 17:32:57 +0200 Subject: [PATCH] newlocallab: further cleanups, #5246 --- rtengine/improcfun.h | 4 +- rtengine/iplocallab.cc | 343 +++++++++++++++-------------------------- 2 files changed, 127 insertions(+), 220 deletions(-) diff --git a/rtengine/improcfun.h b/rtengine/improcfun.h index f6c4e0906..5b178c14a 100644 --- a/rtengine/improcfun.h +++ b/rtengine/improcfun.h @@ -295,12 +295,12 @@ public: int pitch, int scale, const int luma, const int chroma/*, LUTf & Lcurve, LUTf & abcurve*/); //locallab void MSRLocal(int sp, float** luminance, float** templ, const float* const *originalLuminance, const int width, const int height, const procparams::LocallabParams &loc, const int skip, const LocretigainCurve &locRETgainCcurve, const int chrome, const int scall, const float krad, float &minCD, float &maxCD, float &mini, float &maxi, float &Tmean, float &Tsigma, float &Tmin, float &Tmax); - void calc_ref(int 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 calc_ref(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); 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, const LocCCmaskSHCurve & locccmasSHCurve, bool &lcmasSHutili, const LocLLmaskSHCurve & locllmasSHCurve, bool &llmasSHutili, const LocHHmaskSHCurve & lochhmasSHCurve, bool & lhmasSHutili, - bool &LHutili, bool &HHutili, LUTf & cclocalcurve, bool & localcutili, 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, int llSHMask); + bool &LHutili, bool &HHutili, LUTf & cclocalcurve, bool & localcutili, 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, int llSHMask); 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); diff --git a/rtengine/iplocallab.cc b/rtengine/iplocallab.cc index 2c51e5716..09b515514 100644 --- a/rtengine/iplocallab.cc +++ b/rtengine/iplocallab.cc @@ -2088,7 +2088,7 @@ static void blendmask(const local_params& lp, int xstart, int ystart, int cx, in bufexporig->a[y][x] = CLIPC(bufexporig->a[y][x]); bufexporig->b[y][x] = CLIPC(bufexporig->b[y][x]); - originalmas->L[y][x] = CLIP(bufexporig->L[y][x] - bufmaskor->L[y][x]); + originalmas->L[y][x] = CLIP(bufexporig->L[y][x] - bufmaskor->L[y][x]); originalmas->a[y][x] = CLIPC(bufexporig->a[y][x] * (1.f - bufmaskor->a[y][x])); originalmas->b[y][x] = CLIPC(bufexporig->b[y][x] * (1.f - bufmaskor->b[y][x])); @@ -5263,59 +5263,14 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o if (!adecomp.memoryAllocationFailed) { - /* - // Ain = new array2D(bfw, bfh); - #ifdef _OPENMP - #pragma omp parallel for - - #endif - - for (int i = 0; i < bfh; ++i) { - for (int j = 0; j < bfw; ++j) { - (*Ain)[i][j] = bufwv.a[i][j]; - } - } - */ adecomp.reconstruct(bufwv.a[0]); } - /* - if (!adecomp.memoryAllocationFailed) { - - - if ((lp.noisecf >= 0.1f || lp.noisecc >= 0.1f)) { - // fftw_denoise(bfw, bfh, max_numblox_W, min_numblox_W, bufwv.a, Ain, numThreads, lp, 1); - - } - } - */ if (!bdecomp.memoryAllocationFailed) { - /* - // Bin = new array2D(bfw, bfh); - #ifdef _OPENMP - #pragma omp parallel for - - #endif - - for (int i = 0; i < bfh; ++i) { - for (int j = 0; j < bfw; ++j) { - (*Bin)[i][j] = bufwv.b[i][j]; - } - } - */ bdecomp.reconstruct(bufwv.b[0]); } - /* - if (!bdecomp.memoryAllocationFailed) { - if ((lp.noisecf >= 0.1f || lp.noisecc >= 0.1f)) { - // fftw_denoise(bfw, bfh, max_numblox_W, min_numblox_W, bufwv.b, Bin, numThreads, lp, 1); - - } - } - */ - DeNoise_Local(call, lp, levred, huerefblur, lumarefblur, chromarefblur, original, transformed, bufwv, cx, cy, sk); } @@ -5339,9 +5294,9 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o std::unique_ptr bufexporig(new LabImage(bfw, bfh)); //buffer for data in zone limit std::unique_ptr bufexpfin(new LabImage(bfw, bfh)); //buffer for data in zone limit - #ifdef _OPENMP +#ifdef _OPENMP #pragma omp parallel for schedule(dynamic,16) - #endif +#endif for (int y = ystart; y < yend; y++) { for (int x = xstart; x < xend; x++) { @@ -5363,9 +5318,9 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o bufexpfin->CopyFrom(bufexporig.get()); ImProcFunctions::vibrance(bufexpfin.get(), vibranceParams, params->toneCurve.hrenabled, params->icm.workingProfile); - #ifdef _OPENMP +#ifdef _OPENMP #pragma omp parallel for schedule(dynamic,16) - #endif +#endif for (int y = 0; y < bfh; y++) { for (int x = 0; x < bfw; x++) { @@ -5398,9 +5353,9 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o std::unique_ptr bufgb(new LabImage(bfw, bfh)); //buffer for data in zone limit std::unique_ptr tmp1(new LabImage(bfw, bfh)); //buffer for data in zone limit - #ifdef _OPENMP +#ifdef _OPENMP #pragma omp parallel for schedule(dynamic,16) - #endif +#endif for (int y = ystart; y < yend; y++) { for (int x = xstart; x < xend; x++) { @@ -5412,9 +5367,9 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o ImProcFunctions::EPDToneMaplocal(sp, bufgb.get(), tmp1.get(), 5, sk); - #ifdef _OPENMP +#ifdef _OPENMP #pragma omp parallel for schedule(dynamic,16) - #endif +#endif for (int y = 0; y < bfh; y++) { for (int x = 0; x < bfw; x++) { @@ -5453,9 +5408,9 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o constexpr double skinprot = 0.; constexpr int choice = 0; - #ifdef _OPENMP +#ifdef _OPENMP #pragma omp parallel for schedule(dynamic,16) - #endif +#endif for (int y = ystart; y < yend; y++) { for (int x = xstart; x < xend; x++) { @@ -5467,9 +5422,9 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o ImProcFunctions::cbdl_local_temp(bufsh, loctemp->L, bfw, bfh, lp.mulloc, 1.f, lp.threshol, skinprot, false, b_l, t_l, t_r, b_r, choice, sk); - #ifdef _OPENMP +#ifdef _OPENMP #pragma omp parallel for schedule(dynamic,16) - #endif +#endif for (int ir = 0; ir < bfh; ir++) { for (int jr = 0; jr < bfw; jr++) { @@ -5486,9 +5441,9 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o //chroma CBDL begin here if (lp.chromacb > 0.f) { - #ifdef _OPENMP +#ifdef _OPENMP #pragma omp parallel for schedule(dynamic,16) - #endif +#endif for (int ir = 0; ir < bfh; ir++) { for (int jr = 0; jr < bfw; jr++) { bufsh[ir][jr] = sqrt(SQR(loctemp->a[ir][jr]) + SQR(loctemp->b[ir][jr])); @@ -5502,9 +5457,9 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o ImProcFunctions::cbdl_local_temp(bufsh, loctemp->L, bfw, bfh, multc, rtengine::max(lp.chromacb, 1.f), lp.threshol, skinprot, false, b_l, t_l, t_r, b_r, choice, sk); - #ifdef _OPENMP +#ifdef _OPENMP #pragma omp parallel for schedule(dynamic,16) - #endif +#endif for (int ir = 0; ir < bfh; ir++) { for (int jr = 0; jr < bfw; jr++) { @@ -5555,83 +5510,65 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o mean_fab(xstart, ystart, bfw, bfh, bufexporig.get(), original, fab, meanfab, lp.chromaSH); - LUTf *gammamaskSH = nullptr; - LUTf lutTonemaskSH; - lutTonemaskSH(65536); - double pwr = 1.0 / lp.gammaSH; - double gamm = lp.gammaSH; - double ts = lp.slomaSH; - double gamm2 = lp.gammaSH; - GammaValues g_a; - - if (gamm2 < 1.) { - std::swap(pwr, gamm); - } - - int mode = 0; - Color::calcGamma(pwr, ts, mode, g_a); // call to calcGamma with selected gamma and slope - - double start; - double add; - - if (gamm2 < 1.) { - start = g_a[2]; - add = g_a[4]; - } else { - start = g_a[3]; - add = g_a[4]; - } - - double mul = 1. + g_a[4]; - - - for (int i = 0; i < 65536; i++) { - double val = (i) / 65535.; - double x; - - if (gamm2 < 1.) { - x = Color::igammareti(val, gamm, start, ts, mul, add); - } else { - x = Color::gammareti(val, gamm, start, ts, mul, add); - } - - lutTonemaskSH[i] = CLIP(x * 65535.); // CLIP avoid in some case extra values - } - - gammamaskSH = &lutTonemaskSH; - - #ifdef _OPENMP +#ifdef _OPENMP #pragma omp parallel for schedule(dynamic,16) - #endif +#endif - for (int y = 0; y < bfh; y++) //{ + for (int y = 0; y < bfh; y++) { for (int x = 0; x < bfw; x++) { - if (lp.showmaskSHmet == 2 || lp.enaSHMask || lp.showmaskSHmet == 3 || lp.showmaskSHmet == 4) { - bufmaskorigSH->L[y][x] = original->L[y + ystart][x + xstart]; - bufmaskorigSH->a[y][x] = original->a[y + ystart][x + xstart]; - bufmaskorigSH->b[y][x] = original->b[y + ystart][x + xstart]; - bufmaskblurSH->L[y][x] = original->L[y + ystart][x + xstart]; - bufmaskblurSH->a[y][x] = original->a[y + ystart][x + xstart]; - bufmaskblurSH->b[y][x] = original->b[y + ystart][x + xstart]; - } bufexporig->L[y][x] = original->L[y + ystart][x + xstart]; } + } if (lp.showmaskSHmet == 2 || lp.enaSHMask || lp.showmaskSHmet == 3 || lp.showmaskSHmet == 4) { + LUTf lutTonemaskSH(65536); + double pwr = 1.0 / lp.gammaSH; + double gamm = lp.gammaSH; + double ts = lp.slomaSH; + double gamm2 = lp.gammaSH; + GammaValues g_a; - #ifdef _OPENMP + if (gamm2 < 1.) { + std::swap(pwr, gamm); + } + + int mode = 0; + Color::calcGamma(pwr, ts, mode, g_a); // call to calcGamma with selected gamma and slope + + double start; + double add; + + if (gamm2 < 1.) { + start = g_a[2]; + add = g_a[4]; + } else { + start = g_a[3]; + add = g_a[4]; + } + + double mul = 1. + g_a[4]; + + for (int i = 0; i < 65536; i++) { + double val = (i) / 65535.; + double x; + + if (gamm2 < 1.) { + x = Color::igammareti(val, gamm, start, ts, mul, add); + } else { + x = Color::gammareti(val, gamm, start, ts, mul, add); + } + + lutTonemaskSH[i] = CLIP(x * 65535.); // CLIP avoid in some case extra values + } + +#ifdef _OPENMP #pragma omp parallel for schedule(dynamic,16) - #endif +#endif for (int ir = 0; ir < bfh; ir++) { for (int jr = 0; jr < bfw; jr++) { - float kmaskLexp = 0; - float kmaskC = 0; - - float kmaskHL = 0; - float kmaskH = 0; - + float kmaskCH = 0; if (locllmasSHCurve && llmasSHutili) { float ligh = bufexporig->L[ir][jr] / 32768.f; @@ -5641,10 +5578,7 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o if (lp.showmaskSHmet != 4) { if (locccmasSHCurve && lcmasSHutili) { float chromask = 0.0001f + sqrt(SQR((bufexporig->a[ir][jr]) / fab) + SQR((bufexporig->b[ir][jr]) / fab)); - float chromaskr = chromask; - float valCC = float (locccmasSHCurve[500.f * chromaskr]); - valCC = LIM01(1.f - valCC); - kmaskC = valCC; + kmaskCH = LIM01(1.f - locccmasSHCurve[500.f * chromask]); } } @@ -5660,15 +5594,15 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o float valHH = LIM01(1.f - lochhmasSHCurve[500.f * h]); if (lp.showmaskSHmet != 4) { - kmaskH = valHH; + kmaskCH += valHH; } - kmaskHL = 32768.f * valHH; + kmaskLexp += 32768.f * valHH; } - bufmaskblurSH->L[ir][jr] = CLIPLOC(kmaskLexp + kmaskHL); - bufmaskblurSH->a[ir][jr] = kmaskC + kmaskH; - bufmaskblurSH->b[ir][jr] = kmaskC + kmaskH; + bufmaskblurSH->L[ir][jr] = CLIPLOC(kmaskLexp); + bufmaskblurSH->a[ir][jr] = kmaskCH; + bufmaskblurSH->b[ir][jr] = kmaskCH; ble[ir][jr] = bufmaskblurSH->L[ir][jr] / 32768.f; guid[ir][jr] = bufexporig->L[ir][jr] / 32768.f; @@ -5679,16 +5613,16 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o guidedFilter(guid, ble, ble, lp.radmaSH * 10.f / sk, 0.001, multiThread, 4); } - #ifdef _OPENMP +#ifdef _OPENMP #pragma omp parallel for schedule(dynamic,16) - #endif +#endif for (int ir = 0; ir < bfh; ir++) for (int jr = 0; jr < bfw; jr++) { float L_; bufmaskblurSH->L[ir][jr] = LIM01(ble[ir][jr]) * 32768.f; L_ = 2.f * bufmaskblurSH->L[ir][jr]; - bufmaskblurSH->L[ir][jr] = 0.5f * (*gammamaskSH)[L_]; + bufmaskblurSH->L[ir][jr] = 0.5f * lutTonemaskSH[L_]; } } @@ -5698,9 +5632,9 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o if (lp.showmaskSHmet == 2 || lp.enaSHMask || lp.showmaskSHmet == 3 || lp.showmaskSHmet == 4) { - #ifdef _OPENMP +#ifdef _OPENMP #pragma omp parallel - #endif +#endif { gaussianBlur(bufmaskblurSH->L, bufmaskorigSH->L, bfw, bfh, radiusb); gaussianBlur(bufmaskblurSH->a, bufmaskorigSH->a, bfw, bfh, 1.f + (0.5f * lp.radmaSH) / sk); @@ -5719,9 +5653,9 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o if (lp.showmaskSHmet == 0 || lp.showmaskSHmet == 1 || lp.showmaskSHmet == 2 || lp.showmaskSHmet == 4 || lp.enaSHMask) { - #ifdef _OPENMP +#ifdef _OPENMP #pragma omp parallel for schedule(dynamic,16) - #endif +#endif for (int y = 0; y < bfh ; y++) { for (int x = 0; x < bfw; x++) { @@ -5736,9 +5670,9 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o ImProcFunctions::shadowsHighlights(bufexpfin.get(), lp.hsena, 1, lp.highlihs, lp.shadowhs, lp.radiushs, sk, lp.hltonalhs, lp.shtonalhs); - #ifdef _OPENMP +#ifdef _OPENMP #pragma omp parallel for schedule(dynamic,16) - #endif +#endif for (int ir = 0; ir < bfh; ir++) { for (int jr = 0; jr < bfw; jr++) { @@ -6203,7 +6137,6 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o if (bfw > 0 && bfh > 0) { std::unique_ptr bufexporig(new LabImage(bfw, bfh)); std::unique_ptr bufexpfin(new LabImage(bfw, bfh)); - std::unique_ptr bufmaskorigexp; std::unique_ptr bufmaskblurexp; std::unique_ptr originalmaskexp; @@ -6218,8 +6151,7 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o float meansob = 0.f; if (lp.showmaskexpmet == 2 || lp.enaExpMask || lp.showmaskexpmet == 3 || lp.showmaskexpmet == 5) { - bufmaskorigexp.reset(new LabImage(bfw, bfh, true)); - bufmaskblurexp.reset(new LabImage(bfw, bfh, true)); + bufmaskblurexp.reset(new LabImage(bfw, bfh)); originalmaskexp.reset(new LabImage(bfw, bfh)); } @@ -6279,70 +6211,50 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o mean_fab(xstart, ystart, bfw, bfh, bufexporig.get(), original, fab, meanfab, lp.chromaexp); - LUTf *gammamask = nullptr; - LUTf lutTonemask; - lutTonemask(65536); - double pwr = 1.0 / lp.gammaexp; - double gamm = lp.gammaexp; - double ts = lp.slomaexp; - double gamm2 = lp.gammaexp; - GammaValues g_a; - - if (gamm2 < 1.) { - std::swap(pwr, gamm); - } - - int mode = 0; - Color::calcGamma(pwr, ts, mode, g_a); // call to calcGamma with selected gamma and slope - - double start; - double add; - - if (gamm2 < 1.) { - start = g_a[2]; - add = g_a[4]; - } else { - start = g_a[3]; - add = g_a[4]; - } - - double mul = 1. + g_a[4]; - - for (int i = 0; i < 65536; i++) { - double val = (i) / 65535.; - double x; + if (lp.showmaskexpmet == 2 || lp.enaExpMask || lp.showmaskexpmet == 3 || lp.showmaskexpmet == 5) { + LUTf lutTonemask(65536); + double pwr = 1.0 / lp.gammaexp; + double gamm = lp.gammaexp; + double ts = lp.slomaexp; + double gamm2 = lp.gammaexp; + GammaValues g_a; if (gamm2 < 1.) { - x = Color::igammareti(val, gamm, start, ts, mul, add); - } else { - x = Color::gammareti(val, gamm, start, ts, mul, add); + std::swap(pwr, gamm); } - lutTonemask[i] = CLIP(x * 65535.); // CLIP avoid in some case extra values - } + int mode = 0; + Color::calcGamma(pwr, ts, mode, g_a); // call to calcGamma with selected gamma and slope - gammamask = &lutTonemask; + double start; + double add; - if (lp.showmaskexpmet == 2 || lp.enaExpMask || lp.showmaskexpmet == 3 || lp.showmaskexpmet == 5) { + if (gamm2 < 1.) { + start = g_a[2]; + add = g_a[4]; + } else { + start = g_a[3]; + add = g_a[4]; + } + + double mul = 1. + g_a[4]; + + for (int i = 0; i < 65536; i++) { + double val = (i) / 65535.; + double x; + + if (gamm2 < 1.) { + x = Color::igammareti(val, gamm, start, ts, mul, add); + } else { + x = Color::gammareti(val, gamm, start, ts, mul, add); + } + + lutTonemask[i] = CLIP(x * 65535.); // CLIP avoid in some case extra values + } #ifdef _OPENMP #pragma omp parallel for schedule(dynamic,16) #endif - for (int y = 0; y < bfh; y++) { - for (int x = 0; x < bfw; x++) { - bufmaskorigexp->L[y][x] = original->L[y + ystart][x + xstart]; - bufmaskorigexp->a[y][x] = original->a[y + ystart][x + xstart]; - bufmaskorigexp->b[y][x] = original->b[y + ystart][x + xstart]; - } - } - bufmaskblurexp->CopyFrom(bufmaskorigexp.get()); - } - - if (lp.showmaskexpmet == 2 || lp.enaExpMask || lp.showmaskexpmet == 3 || lp.showmaskexpmet == 5) { - - #ifdef _OPENMP - #pragma omp parallel for schedule(dynamic,16) - #endif for (int ir = 0; ir < bfh; ir++) for (int jr = 0; jr < bfw; jr++) { @@ -6382,49 +6294,44 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o kmaskHL = 32768.f * valHH; } - bufmaskblurexp->L[ir][jr] = CLIPLOC(kmaskLexp + kmaskHL); bufmaskblurexp->a[ir][jr] = kmaskC + kmaskH; bufmaskblurexp->b[ir][jr] = kmaskC + kmaskH; - (*ble)[ir][jr] = LIM01(bufmaskblurexp->L[ir][jr] / 32768.f); + (*ble)[ir][jr] = LIM01(CLIPLOC(kmaskLexp + kmaskHL) / 32768.f); (*guid)[ir][jr] = LIM01(bufexporig->L[ir][jr] / 32768.f); - } if (lp.radmaexp > 0.f) { guidedFilter(*guid, *ble, *ble, lp.radmaexp * 10.f / sk, 0.001, multiThread, 4); } - #ifdef _OPENMP +#ifdef _OPENMP #pragma omp parallel for schedule(dynamic,16) - #endif +#endif for (int ir = 0; ir < bfh; ir++) { for (int jr = 0; jr < bfw; jr++) { const float L_ = 2.f * LIM01((*ble)[ir][jr]) * 32768.f; - bufmaskblurexp->L[ir][jr] = 0.5f * (*gammamask)[L_]; + bufmaskblurexp->L[ir][jr] = 0.5f * lutTonemask[L_]; } } - } - const float radiusb = 1.f / sk; + const float radiusb = 1.f / sk; - if (lp.showmaskexpmet == 2 || lp.enaExpMask || lp.showmaskexpmet == 3 || lp.showmaskexpmet == 5) { - - #ifdef _OPENMP +#ifdef _OPENMP #pragma omp parallel - #endif +#endif { - gaussianBlur(bufmaskblurexp->L, bufmaskorigexp->L, bfw, bfh, radiusb); - gaussianBlur(bufmaskblurexp->a, bufmaskorigexp->a, bfw, bfh, 1.f + (0.5f * lp.radmaexp) / sk); - gaussianBlur(bufmaskblurexp->b, bufmaskorigexp->b, bfw, bfh, 1.f + (0.5f * lp.radmaexp) / sk); + gaussianBlur(bufmaskblurexp->L, bufmaskblurexp->L, bfw, bfh, radiusb); + gaussianBlur(bufmaskblurexp->a, bufmaskblurexp->a, bfw, bfh, 1.f + (0.5f * lp.radmaexp) / sk); + gaussianBlur(bufmaskblurexp->b, bufmaskblurexp->b, bfw, bfh, 1.f + (0.5f * lp.radmaexp) / sk); } if (lp.showmaskexpmet == 0 || lp.showmaskexpmet == 1 || lp.showmaskexpmet == 2 || lp.showmaskexpmet == 4 || lp.showmaskexpmet == 5 || lp.enaExpMask) { - blendmask(lp, xstart, ystart, cx, cy, bfw, bfh, bufexporig.get(), original, bufmaskorigexp.get(), originalmaskexp.get(), lp.blendmaexp); + blendmask(lp, xstart, ystart, cx, cy, bfw, bfh, bufexporig.get(), original, bufmaskblurexp.get(), originalmaskexp.get(), lp.blendmaexp); } else if (lp.showmaskexpmet == 3) { - showmask(lp, xstart, ystart, cx, cy, bfw, bfh, bufexporig.get(), transformed, bufmaskorigexp.get()); + showmask(lp, xstart, ystart, cx, cy, bfw, bfh, bufexporig.get(), transformed, bufmaskblurexp.get()); return; } }