diff --git a/rtengine/improcfun.cc b/rtengine/improcfun.cc index 90f986a74..fa9b5153a 100644 --- a/rtengine/improcfun.cc +++ b/rtengine/improcfun.cc @@ -5292,7 +5292,7 @@ void ImProcFunctions::EPDToneMaplocal(int sp, LabImage *lab, LabImage *tmp1, uns float edgest = ((float)params->locallab.spots.at(sp).estop) / 100.f; float sca = ((float)params->locallab.spots.at(sp).scaltm) / 10.f; float gamm = ((float)params->locallab.spots.at(sp).gamma) / 100.f; -// float satur = ((float)params->locallab.spots.at(sp).satur) / 100.f; + float satur = ((float)params->locallab.spots.at(sp).satur) / 100.f; float rew = ((float)params->locallab.spots.at(sp).rewei); //Pointers to whole data and size of it. float *L = lab->L[0]; @@ -5304,34 +5304,15 @@ void ImProcFunctions::EPDToneMaplocal(int sp, LabImage *lab, LabImage *tmp1, uns EdgePreservingDecomposition epd(lab->W, lab->H); //Due to the taking of logarithms, L must be nonnegative. Further, scale to 0 to 1 using nominal range of L, 0 to 15 bit. - float minL = FLT_MAX; - float maxL = 0.f; - #pragma omp parallel - { - float lminL = FLT_MAX; - float lmaxL = 0.f; - #pragma omp for - - for (i = 0; i < N; i++) { - if (L[i] < lminL) { - lminL = L[i]; - } - - if (L[i] > lmaxL) { - lmaxL = L[i]; - } - } - - #pragma omp critical - - if (lminL < minL) { - minL = lminL; - } - - if (lmaxL > maxL) { - maxL = lmaxL; - } + float minL = L[0]; + float maxL = minL; +#ifdef _OPENMP + #pragma omp parallel for reduction(max:maxL) reduction(min:minL) schedule(dynamic,16) +#endif + for (i = 0; i < N; i++) { + minL = rtengine::min(minL, L[i]); + maxL = rtengine::max(maxL, L[i]); } if (minL > 0.0f) { @@ -5345,7 +5326,6 @@ void ImProcFunctions::EPDToneMaplocal(int sp, LabImage *lab, LabImage *tmp1, uns #pragma omp parallel for for (i = 0; i < N; i++) - //{L[i] = (L[i] - minL)/32767.0f; { L[i] = (L[i] - minL) / maxL; L[i] *= gamm; @@ -5375,10 +5355,9 @@ void ImProcFunctions::EPDToneMaplocal(int sp, LabImage *lab, LabImage *tmp1, uns //Restore past range, also desaturate a bit per Mantiuk's Color correction for tone mapping. float s = (1.0f + 38.7889f) * powf(Compression, 1.5856f) / (1.0f + 38.7889f * powf(Compression, 1.5856f)); -// float ss = 1.f - s; -// float sat = 1.f + (2.5f * satur) * ss; -// printf("s=%f ss=%f sat=%f \n", s, ss, sat); -// if(sat == 1.f) sat = 1.001f; + float sat = s + 0.3f * s * satur; + printf("s=%f sat=%f \n", s, sat); + if(sat == 1.f) sat = 1.001f; #ifdef _OPENMP #pragma omp parallel for // removed schedule(dynamic,10) #endif @@ -5388,8 +5367,8 @@ void ImProcFunctions::EPDToneMaplocal(int sp, LabImage *lab, LabImage *tmp1, uns int y = i - x * WW; tmp1->L[x][y] = L[i] * maxL * (1.f / gamm) + minL; - tmp1->a[x][y] = s * a[i]; - tmp1->b[x][y] = s * b[i]; + tmp1->a[x][y] = sat * a[i]; + tmp1->b[x][y] = sat * b[i]; } } diff --git a/rtengine/iplocallab.cc b/rtengine/iplocallab.cc index a7c9d69d6..8c7c65596 100644 --- a/rtengine/iplocallab.cc +++ b/rtengine/iplocallab.cc @@ -2633,10 +2633,10 @@ void ImProcFunctions::transit_shapedetect(int senstype, const LabImage *bufexpor const float lightc = bufexporig->L[y - ystart][x - xstart]; const float fli = (100.f + realstrdE) / 100.f; transformed->L[y][x] = CLIP(original->L[y][x] + (lightc * fli - original->L[y][x]) * factorx); - } else if (senstype == 6 || senstype == 8 ) { + } else if (senstype == 6 || senstype == 8 || senstype == 10) { difL = (bufexporig->L[y - ystart][x - xstart] - original->L[y][x]) * localFactor * reducdE; transformed->L[y][x] = CLIP(original->L[y][x] + difL); - } else if (senstype == 1 || senstype == 0 || senstype == 9 || senstype == 3 || senstype == 10) { + } else if (senstype == 1 || senstype == 0 || senstype == 9 || senstype == 3) { if (HHutili) { const float hhro = bufhh[y - ystart][x - xstart]; @@ -2756,10 +2756,10 @@ void ImProcFunctions::transit_shapedetect(int senstype, const LabImage *bufexpor const float lightc = bufexporig->L[y - ystart][x - xstart]; const float fli = (100.f + realstrdE) / 100.f; transformed->L[y][x] = CLIP(original->L[y][x] + lightc * fli - original->L[y][x]); - } else if (senstype == 6 || senstype == 8) { + } else if (senstype == 6 || senstype == 8 || senstype == 10) { difL = (bufexporig->L[y - ystart][x - xstart] - original->L[y][x]) * reducdE; transformed->L[y][x] = CLIP(original->L[y][x] + difL); - } else if (senstype == 1 || senstype == 0 || senstype == 9 || senstype == 3 || senstype == 10) { + } else if (senstype == 1 || senstype == 0 || senstype == 9 || senstype == 3) { if (HHutili) { const float hhro = bufhh[y - ystart][x - xstart]; @@ -5244,6 +5244,7 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o // itera = 5; } ImProcFunctions::EPDToneMaplocal(sp, bufgb.get(), tmp1.get(), itera, sk);//iterate to 0 calculate with edgstopping, improve result, call=1 dcrop we can put iterate to 5 +/* //to reactivate if we change transit_shapedetct parameters #ifdef _OPENMP #pragma omp parallel for schedule(dynamic,16) #endif @@ -5252,7 +5253,7 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o tmp1->L[y][x] = 0.01f* (lp.amo * tmp1->L[y][x] + (100.f - lp.amo) * bufgb->L[y][x]); } } - +*/ float minL = tmp1->L[0][0] - bufgb->L[0][0]; float maxL = minL; float minC = sqrt(SQR(tmp1->a[0][0]) + SQR(tmp1->b[0][0])) - sqrt(SQR(bufgb->a[0][0]) + SQR(bufgb->b[0][0])); @@ -5289,7 +5290,7 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o /* if (lp.softradiustm > 0.f) { guidedFilter(guid, ble, ble, 0.1f * lp.softradiustm / sk, 0.0001, multiThread); - softprocess(bufgb.get(), buflight, lp.softradiustm, bfh, bfw, sk, multiThread); + // softprocess(bufgb.get(), buflight, lp.softradiustm, bfh, bfw, sk, multiThread); } #ifdef _OPENMP diff --git a/rtengine/procparams.cc b/rtengine/procparams.cc index 25ecc4d0d..ecc46e667 100644 --- a/rtengine/procparams.cc +++ b/rtengine/procparams.cc @@ -2459,10 +2459,10 @@ LocallabParams::LocallabSpot::LocallabSpot() : exptonemap(false), stren(10), gamma(100), - estop(80), - scaltm(10), + estop(70), + scaltm(40), rewei(0), - satur(5), + satur(0.), sensitm(19), softradiustm(0.0), amount(95), diff --git a/rtengine/procparams.h b/rtengine/procparams.h index 77ae01ca0..04d14c9cb 100644 --- a/rtengine/procparams.h +++ b/rtengine/procparams.h @@ -1063,7 +1063,7 @@ struct LocallabParams { int estop; int scaltm; int rewei; - int satur; + double satur; int sensitm; double softradiustm; int amount; diff --git a/rtgui/locallab.cc b/rtgui/locallab.cc index 1ff6ce1e0..af1f65bfb 100644 --- a/rtgui/locallab.cc +++ b/rtgui/locallab.cc @@ -139,13 +139,13 @@ Locallab::Locallab(): // Tone Mapping stren(Gtk::manage(new Adjuster(M("TP_LOCALLAB_STREN"), -50, 200, 1, 10))), gamma(Gtk::manage(new Adjuster(M("TP_LOCALLAB_GAM"), 40, 400, 1, 100))), - estop(Gtk::manage(new Adjuster(M("TP_LOCALLAB_ESTOP"), 10, 400, 1, 80))), - scaltm(Gtk::manage(new Adjuster(M("TP_LOCALLAB_SCALTM"), 1, 100, 1, 10))), + estop(Gtk::manage(new Adjuster(M("TP_LOCALLAB_ESTOP"), 10, 400, 1, 70))), + scaltm(Gtk::manage(new Adjuster(M("TP_LOCALLAB_SCALTM"), 1, 100, 1, 40))), rewei(Gtk::manage(new Adjuster(M("TP_LOCALLAB_REWEI"), 0, 3, 1, 0))), sensitm(Gtk::manage(new Adjuster(M("TP_LOCALLAB_SENSI"), 0, 100, 1, 15))), softradiustm(Gtk::manage(new Adjuster(M("TP_LOCALLAB_SOFTRADIUSCOL"), 0.0, 100.0, 0.1, 0.))), amount(Gtk::manage(new Adjuster(M("TP_LOCALLAB_AMOUNT"), 50, 100, 1, 95))), - satur(Gtk::manage(new Adjuster(M("TP_LOCALLAB_SATUR"), -100, 100, 1, 5))), + satur(Gtk::manage(new Adjuster(M("TP_LOCALLAB_SATUR"), -100., 100., 0.1, 0.))),//by default satur = 0 ==> use Mantiuk value // 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))), @@ -789,14 +789,14 @@ Locallab::Locallab(): if(showtooltip) rewei->set_tooltip_text(M("TP_LOCALLAB_TONEMAPESTOP_TOOLTIP")); ToolParamBlock* const tmBox = Gtk::manage(new ToolParamBlock()); - tmBox->pack_start(*amount); +// tmBox->pack_start(*amount);//to use if we change transit_shapedetect parameters tmBox->pack_start(*stren); tmBox->pack_start(*gamma); -// tmBox->pack_start(*satur); + tmBox->pack_start(*satur); tmBox->pack_start(*estop); tmBox->pack_start(*scaltm); tmBox->pack_start(*rewei); -// tmBox->pack_start(*softradiustm); +// tmBox->pack_start(*softradiustm);//always bad with TM ?? tmBox->pack_start(*sensitm); exptonemap->add(*tmBox); exptonemap->setLevel(2); @@ -2016,7 +2016,7 @@ void Locallab::write(ProcParams* pp, ParamsEdited* pedited) pp->locallab.spots.at(pp->locallab.selspot).estop = estop->getIntValue(); pp->locallab.spots.at(pp->locallab.selspot).scaltm = scaltm->getIntValue(); pp->locallab.spots.at(pp->locallab.selspot).rewei = rewei->getIntValue(); - pp->locallab.spots.at(pp->locallab.selspot).satur = satur->getIntValue(); + pp->locallab.spots.at(pp->locallab.selspot).satur = satur->getValue(); pp->locallab.spots.at(pp->locallab.selspot).sensitm = sensitm->getIntValue(); pp->locallab.spots.at(pp->locallab.selspot).softradiustm = softradiustm->getValue(); pp->locallab.spots.at(pp->locallab.selspot).amount = amount->getIntValue(); @@ -3393,7 +3393,7 @@ void Locallab::setDefaults(const ProcParams * defParams, const ParamsEdited * pe estop->setDefault((double)defSpot->estop); scaltm->setDefault((double)defSpot->scaltm); rewei->setDefault((double)defSpot->rewei); - satur->setDefault((double)defSpot->satur); + satur->setDefault(defSpot->satur); sensitm->setDefault((double)defSpot->sensitm); softradiustm->setDefault(defSpot->softradiustm); amount->setDefault((double)defSpot->amount);