diff --git a/rtdata/languages/default b/rtdata/languages/default index 68790b4d1..c0f914499 100644 --- a/rtdata/languages/default +++ b/rtdata/languages/default @@ -799,7 +799,7 @@ HISTORY_MSG_549;Local - Blur scope HISTORY_MSG_550;Local - Blur method HISTORY_MSG_551;Local - Blur Luminance only HISTORY_MSG_552;Local - Tone mapping -HISTORY_MSG_553;Local - TM strength +HISTORY_MSG_553;Local - TM compression strength HISTORY_MSG_554;Local - TM gamma HISTORY_MSG_555;Local - TM edge stopping HISTORY_MSG_556;Local - TM scale @@ -920,6 +920,8 @@ HISTORY_MSG_672;Local - cbdl mask CL HISTORY_MSG_673;Local - Use cbdl mask HISTORY_MSG_675;Local - TM soft radius HISTORY_MSG_676;Local Spot transition-differentiation +HISTORY_MSG_677;Local - TM amount + HISTORY_MSG_CLAMPOOG;Clip out-of-gamut colors HISTORY_MSG_COLORTONING_LABGRID_VALUE;CT - Color correction HISTORY_MSG_COLORTONING_LABREGION_AB;CT - Color correction @@ -1967,6 +1969,7 @@ TP_LENSPROFILE_USE_HEADER;Correct TP_LENSPROFILE_USE_VIGNETTING;Vignetting TP_LOCALLAB_ACTIV;Blur luminance only TP_LOCALLAB_ADJ;Equalizer blue-red +TP_LOCALLAB_AMOUNT;Amount TP_LOCALLAB_ARTIF;Shape detection TP_LOCALLAB_ARTIF_TOOLTIP;Increase deltaE Weakening improve shape detection, but can reduce the scope of detection.\nThreshold deltaE-scope increase the range of scope-deltaE - high values are for very wide gamut images.\nThreshold structure take into account the structure level of solid areas TP_LOCALLAB_AVOID;Avoid color shift @@ -2066,7 +2069,7 @@ TP_LOCALLAB_RESID;Residual Image TP_LOCALLAB_CONTRESID;Contrast TP_LOCALLAB_RETI;Retinex TP_LOCALLAB_TRANSMISSIONGAIN;Transmission gain -TP_LOCALLAB_STREN;Strength +TP_LOCALLAB_STREN;Compression Strength TP_LOCALLAB_STRGRID;Strength TP_LOCALLAB_TM;Tone Mapping TP_LOCALLAB_STR;Strength diff --git a/rtengine/iplocallab.cc b/rtengine/iplocallab.cc index febc6f8a4..3e83685a6 100644 --- a/rtengine/iplocallab.cc +++ b/rtengine/iplocallab.cc @@ -263,6 +263,7 @@ struct local_params { float esto; float scalt; float rewe; + float amo; bool colorena; bool blurena; bool tonemapena; @@ -389,6 +390,7 @@ static void calcLocalParams(int sp, int oW, int oH, const LocallabParams& locall float est = ((float)locallab.spots.at(sp).estop) / 100.f; float scal_tm = ((float)locallab.spots.at(sp).scaltm) / 10.f; float rewe = ((float)locallab.spots.at(sp).rewei); + float amo = ((float)locallab.spots.at(sp).amount); float strlight = ((float)locallab.spots.at(sp).streng); float strucc = locallab.spots.at(sp).struc; @@ -688,6 +690,7 @@ static void calcLocalParams(int sp, int oW, int oH, const LocallabParams& locall lp.scalt = scal_tm; lp.rewe = rewe; lp.senstm = local_sensitm; + lp.amo = amo; for (int y = 0; y < 6; y++) { lp.mulloc[y] = CLIP04(multi[y]);//to prevent crash with old pp3 integer @@ -2371,7 +2374,7 @@ void ImProcFunctions::transit_shapedetect(int senstype, const LabImage *bufexpor const int xend = std::min(static_cast(lp.xc + lp.lx) - cx, original->W); const int bfw = xend - xstart; const int bfh = yend - ystart; - +printf("h=%f l=%f c=%f s=%f\n", hueref, lumaref, chromaref, sobelref); const float ach = lp.trans / 100.f; float varsens = lp.sensex; @@ -4969,8 +4972,16 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o bufgb->b[y - ystart][x - xstart] = original->b[y][x]; } } - ImProcFunctions::EPDToneMaplocal(sp, bufgb.get(), tmp1.get(), 5, sk); +#ifdef _OPENMP + #pragma omp parallel for schedule(dynamic,16) +#endif + for (int y = 0; y < bfh; y++) { + for (int x = 0; x < bfw; x++) { + 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])); diff --git a/rtengine/procevents.h b/rtengine/procevents.h index ed848ce39..101fd5fe5 100644 --- a/rtengine/procevents.h +++ b/rtengine/procevents.h @@ -703,6 +703,7 @@ enum ProcEventCode { EvlocallabshowmaskcbMethod = 673, Evlocallabsoftradiustm = 674, EvLocallabSpotTransitgrad = 675, + Evlocallabamount = 676, NUMOFEVENTS }; diff --git a/rtengine/procparams.cc b/rtengine/procparams.cc index b07e6a824..e7c87feb1 100644 --- a/rtengine/procparams.cc +++ b/rtengine/procparams.cc @@ -2457,13 +2457,14 @@ LocallabParams::LocallabSpot::LocallabSpot() : activlum(false), // Tone Mapping exptonemap(false), - stren(1), + stren(10), gamma(100), estop(140), scaltm(10), rewei(0), sensitm(19), softradiustm(0.0), + amount(80), // Retinex expreti(false), retinexMethod("high"), @@ -2661,6 +2662,7 @@ bool LocallabParams::LocallabSpot::operator ==(const LocallabSpot& other) const && rewei == other.rewei && sensitm == other.sensitm && softradiustm == other.softradiustm + && amount == other.amount // Retinex && expreti == other.expreti && retinexMethod == other.retinexMethod @@ -3814,6 +3816,7 @@ int ProcParams::save(const Glib::ustring& fname, const Glib::ustring& fname2, bo saveToKeyfile(!pedited || pedited->locallab.spots.at(i).rewei, "Locallab", "Rewei_" + std::to_string(i), spot.rewei, keyFile); saveToKeyfile(!pedited || pedited->locallab.spots.at(i).sensitm, "Locallab", "Sensitm_" + std::to_string(i), spot.sensitm, keyFile); saveToKeyfile(!pedited || pedited->locallab.spots.at(i).softradiustm, "Locallab", "Softradiustm_" + std::to_string(i), spot.softradiustm, keyFile); + saveToKeyfile(!pedited || pedited->locallab.spots.at(i).amount, "Locallab", "Amount_" + std::to_string(i), spot.amount, keyFile); // Retinex saveToKeyfile(!pedited || pedited->locallab.spots.at(i).expreti, "Locallab", "Expreti_" + std::to_string(i), spot.expreti, keyFile); saveToKeyfile(!pedited || pedited->locallab.spots.at(i).retinexMethod, "Locallab", "retinexMethod_" + std::to_string(i), spot.retinexMethod, keyFile); @@ -5108,6 +5111,7 @@ int ProcParams::load(const Glib::ustring& fname, ParamsEdited* pedited) assignFromKeyfile(keyFile, "Locallab", "Rewei_" + std::to_string(i), pedited, spot.rewei, spotEdited.rewei); assignFromKeyfile(keyFile, "Locallab", "Sensitm_" + std::to_string(i), pedited, spot.sensitm, spotEdited.sensitm); assignFromKeyfile(keyFile, "Locallab", "Softradiustm_" + std::to_string(i), pedited, spot.softradiustm, spotEdited.softradiustm); + assignFromKeyfile(keyFile, "Locallab", "Amount_" + std::to_string(i), pedited, spot.amount, spotEdited.amount); // Retinex assignFromKeyfile(keyFile, "Locallab", "Expreti_" + std::to_string(i), pedited, spot.expreti, spotEdited.expreti); assignFromKeyfile(keyFile, "Locallab", "retinexMethod_" + std::to_string(i), pedited, spot.retinexMethod, spotEdited.retinexMethod); diff --git a/rtengine/procparams.h b/rtengine/procparams.h index 4163d719c..bcd181d63 100644 --- a/rtengine/procparams.h +++ b/rtengine/procparams.h @@ -1065,6 +1065,7 @@ struct LocallabParams { int rewei; int sensitm; double softradiustm; + int amount; // Retinex bool expreti; Glib::ustring retinexMethod; diff --git a/rtengine/refreshmap.cc b/rtengine/refreshmap.cc index 6861649ec..df9e37748 100644 --- a/rtengine/refreshmap.cc +++ b/rtengine/refreshmap.cc @@ -702,7 +702,8 @@ int refreshmap[rtengine::NUMOFEVENTS] = { LUMINANCECURVE, //EvLocallabEnacbMask LUMINANCECURVE, //EvlocallabshowmaskcbMethod LUMINANCECURVE, //Evlocallabsoftradiustm - LUMINANCECURVE // EvLocallabSpotTransitgrad + LUMINANCECURVE, // EvLocallabSpotTransitgrad + LUMINANCECURVE // Evlocallabamount }; diff --git a/rtgui/locallab.cc b/rtgui/locallab.cc index fb7c767f7..ed6d9c918 100644 --- a/rtgui/locallab.cc +++ b/rtgui/locallab.cc @@ -137,13 +137,14 @@ Locallab::Locallab(): strength(Gtk::manage(new Adjuster(M("TP_LOCALLAB_STRENGTH"), 0, 100, 1, 0))), sensibn(Gtk::manage(new Adjuster(M("TP_LOCALLAB_SENSIBN"), 0, 100, 1, 40))), // Tone Mapping - stren(Gtk::manage(new Adjuster(M("TP_LOCALLAB_STREN"), -50, 100, 1, 0))), + stren(Gtk::manage(new Adjuster(M("TP_LOCALLAB_STREN"), -50, 100, 1, 10))), gamma(Gtk::manage(new Adjuster(M("TP_LOCALLAB_GAM"), 80, 400, 1, 100))), 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, 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, 80))), // 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))), @@ -767,11 +768,14 @@ Locallab::Locallab(): rewei->setAdjusterListener(this); + amount->setAdjusterListener(this); + if(showtooltip) sensitm->set_tooltip_text(M("TP_LOCALLAB_SENSI_TOOLTIP")); sensitm->setAdjusterListener(this); softradiustm->setAdjusterListener(this); ToolParamBlock* const tmBox = Gtk::manage(new ToolParamBlock()); + tmBox->pack_start(*amount); tmBox->pack_start(*stren); tmBox->pack_start(*gamma); tmBox->pack_start(*estop); @@ -1999,6 +2003,7 @@ void Locallab::write(ProcParams* pp, ParamsEdited* pedited) pp->locallab.spots.at(pp->locallab.selspot).rewei = rewei->getIntValue(); 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(); // Retinex pp->locallab.spots.at(pp->locallab.selspot).expreti = expreti->getEnabled(); @@ -2206,6 +2211,7 @@ void Locallab::write(ProcParams* pp, ParamsEdited* pedited) pe->locallab.spots.at(pp->locallab.selspot).rewei = pe->locallab.spots.at(pp->locallab.selspot).rewei || rewei->getEditedState(); pe->locallab.spots.at(pp->locallab.selspot).sensitm = pe->locallab.spots.at(pp->locallab.selspot).sensitm || sensitm->getEditedState(); pe->locallab.spots.at(pp->locallab.selspot).softradiustm = pe->locallab.spots.at(pp->locallab.selspot).softradiustm || softradiustm->getEditedState(); + pe->locallab.spots.at(pp->locallab.selspot).amount = pe->locallab.spots.at(pp->locallab.selspot).amount || amount->getEditedState(); // Retinex pe->locallab.spots.at(pp->locallab.selspot).expreti = pe->locallab.spots.at(pp->locallab.selspot).expreti || !expreti->get_inconsistent(); pe->locallab.spots.at(pp->locallab.selspot).retinexMethod = pe->locallab.spots.at(pp->locallab.selspot).retinexMethod || retinexMethod->get_active_text() != M("GENERAL_UNCHANGED"); @@ -2407,6 +2413,7 @@ void Locallab::write(ProcParams* pp, ParamsEdited* pedited) pedited->locallab.spots.at(pp->locallab.selspot).rewei = pedited->locallab.spots.at(pp->locallab.selspot).rewei || rewei->getEditedState(); pedited->locallab.spots.at(pp->locallab.selspot).sensitm = pedited->locallab.spots.at(pp->locallab.selspot).sensitm || sensitm->getEditedState(); pedited->locallab.spots.at(pp->locallab.selspot).softradiustm = pedited->locallab.spots.at(pp->locallab.selspot).softradiustm || softradiustm->getEditedState(); + pedited->locallab.spots.at(pp->locallab.selspot).amount = pedited->locallab.spots.at(pp->locallab.selspot).amount || amount->getEditedState(); // Retinex pedited->locallab.spots.at(pp->locallab.selspot).expreti = pedited->locallab.spots.at(pp->locallab.selspot).expreti || !expreti->get_inconsistent(); pedited->locallab.spots.at(pp->locallab.selspot).retinexMethod = pedited->locallab.spots.at(pp->locallab.selspot).retinexMethod || retinexMethod->get_active_text() != M("GENERAL_UNCHANGED"); @@ -3370,6 +3377,7 @@ void Locallab::setDefaults(const ProcParams * defParams, const ParamsEdited * pe rewei->setDefault((double)defSpot->rewei); sensitm->setDefault((double)defSpot->sensitm); softradiustm->setDefault(defSpot->softradiustm); + amount->setDefault((double)defSpot->amount); // Retinex str->setDefault((double)defSpot->str); chrrt->setDefault((double)defSpot->chrrt); @@ -3491,6 +3499,7 @@ void Locallab::setDefaults(const ProcParams * defParams, const ParamsEdited * pe rewei->setDefaultEditedState(Irrelevant); sensitm->setDefaultEditedState(Irrelevant); softradiustm->setDefaultEditedState(Irrelevant); + amount->setDefaultEditedState(Irrelevant); // Retinex str->setDefaultEditedState(Irrelevant); chrrt->setDefaultEditedState(Irrelevant); @@ -3616,6 +3625,7 @@ void Locallab::setDefaults(const ProcParams * defParams, const ParamsEdited * pe rewei->setDefaultEditedState(defSpotState->rewei ? Edited : UnEdited); sensitm->setDefaultEditedState(defSpotState->sensitm ? Edited : UnEdited); softradiustm->setDefaultEditedState(defSpotState->softradiustm ? Edited : UnEdited); + amount->setDefaultEditedState(defSpotState->amount ? Edited : UnEdited); // Retinex str->setDefaultEditedState(defSpotState->str ? Edited : UnEdited); chrrt->setDefaultEditedState(defSpotState->chrrt ? Edited : UnEdited); @@ -4078,13 +4088,19 @@ void Locallab::adjusterChanged(Adjuster * a, double newval) listener->panelChanged(Evlocallabsensitm, sensitm->getTextValue()); } } - + if (a == softradiustm) { if (listener) { listener->panelChanged(Evlocallabsoftradiustm, softradiustm->getTextValue()); } } - + + if (a == amount) { + if (listener) { + listener->panelChanged(Evlocallabamount, amount->getTextValue()); + } + } + } // Retinex @@ -4472,6 +4488,7 @@ void Locallab::setBatchMode(bool batchMode) rewei->showEditedCB(); sensitm->showEditedCB(); softradiustm->showEditedCB(); + amount->showEditedCB(); // Retinex str->showEditedCB(); chrrt->showEditedCB(); @@ -4903,6 +4920,7 @@ void Locallab::updateLocallabGUI(const rtengine::procparams::ProcParams* pp, con rewei->setValue(pp->locallab.spots.at(index).rewei); sensitm->setValue(pp->locallab.spots.at(index).sensitm); softradiustm->setValue(pp->locallab.spots.at(index).softradiustm); + amount->setValue(pp->locallab.spots.at(index).amount); // Retinex expreti->setEnabled(pp->locallab.spots.at(index).expreti); @@ -5140,6 +5158,7 @@ void Locallab::updateLocallabGUI(const rtengine::procparams::ProcParams* pp, con rewei->setEditedState(spotState->rewei ? Edited : UnEdited); sensitm->setEditedState(spotState->sensitm ? Edited : UnEdited); softradiustm->setEditedState(spotState->softradiustm ? Edited : UnEdited); + amount->setEditedState(spotState->amount ? Edited : UnEdited); // Retinex expreti->set_inconsistent(!spotState->expreti); diff --git a/rtgui/locallab.h b/rtgui/locallab.h index d5a5d3e9e..56d1266e9 100644 --- a/rtgui/locallab.h +++ b/rtgui/locallab.h @@ -166,6 +166,7 @@ private: Adjuster* const rewei; Adjuster* const sensitm; Adjuster* const softradiustm; + Adjuster* const amount; // Retinex Adjuster* const str; Adjuster* const chrrt; diff --git a/rtgui/paramsedited.cc b/rtgui/paramsedited.cc index 88145837c..9dc5b8ddc 100644 --- a/rtgui/paramsedited.cc +++ b/rtgui/paramsedited.cc @@ -1054,6 +1054,7 @@ void ParamsEdited::initFrom(const std::vector& locallab.spots.at(j).rewei = locallab.spots.at(j).rewei && pSpot.rewei == otherSpot.rewei; locallab.spots.at(j).sensitm = locallab.spots.at(j).sensitm && pSpot.sensitm == otherSpot.sensitm; locallab.spots.at(j).softradiustm = locallab.spots.at(j).softradiustm && pSpot.softradiustm == otherSpot.softradiustm; + locallab.spots.at(j).amount = locallab.spots.at(j).amount && pSpot.amount == otherSpot.amount; // Retinex locallab.spots.at(j).expreti = locallab.spots.at(j).expreti && pSpot.expreti == otherSpot.expreti; locallab.spots.at(j).retinexMethod = locallab.spots.at(j).retinexMethod && pSpot.retinexMethod == otherSpot.retinexMethod; @@ -3029,6 +3030,10 @@ void ParamsEdited::combine(rtengine::procparams::ProcParams& toEdit, const rteng toEdit.locallab.spots.at(i).softradiustm = mods.locallab.spots.at(i).softradiustm; } + if (locallab.spots.at(i).amount) { + toEdit.locallab.spots.at(i).amount = mods.locallab.spots.at(i).amount; + } + // Retinex if (locallab.spots.at(i).expreti) { toEdit.locallab.spots.at(i).expreti = mods.locallab.spots.at(i).expreti; @@ -4332,6 +4337,7 @@ LocallabParamsEdited::LocallabSpotEdited::LocallabSpotEdited(bool v) : rewei(v), sensitm(v), softradiustm(v), + amount(v), // Retinex expreti(v), retinexMethod(v), @@ -4526,6 +4532,7 @@ void LocallabParamsEdited::LocallabSpotEdited::set(bool v) rewei = v; sensitm = v; softradiustm = v; + amount = v; // Retinex expreti = v; retinexMethod = v; diff --git a/rtgui/paramsedited.h b/rtgui/paramsedited.h index 441d02f0e..85f38302c 100644 --- a/rtgui/paramsedited.h +++ b/rtgui/paramsedited.h @@ -481,6 +481,7 @@ public: bool rewei; bool sensitm; bool softradiustm; + bool amount; // Retinex bool expreti; bool retinexMethod;