diff --git a/rtdata/languages/default b/rtdata/languages/default index 235db4a3f..62a9ccbdc 100644 --- a/rtdata/languages/default +++ b/rtdata/languages/default @@ -989,6 +989,7 @@ HISTORY_MSG_748;Local - Exp Denoise HISTORY_MSG_749;Local - Reti Depth HISTORY_MSG_750;Local - Reti Mode log - lin HISTORY_MSG_751;Local - Reti Dehaze luminance +HISTORY_MSG_752;Local - Reti Offset HISTORY_MSG_CLAMPOOG;Clip out-of-gamut colors HISTORY_MSG_COLORTONING_LABGRID_VALUE;CT - Color correction HISTORY_MSG_COLORTONING_LABREGION_AB;CT - Color correction @@ -2200,6 +2201,7 @@ TP_LOCALLAB_RADMASKCOL;Radius TP_LOCALLAB_RESID;Residual Image TP_LOCALLAB_CONTRESID;Contrast TP_LOCALLAB_DEHAFRA;Dehaze +TP_LOCALLAB_OFFS;Offset TP_LOCALLAB_RETIFRA;Retinex TP_LOCALLAB_RETITOOLFRA;Retinex Tools TP_LOCALLAB_RETI;Dehaze - Retinex Strong local contrast diff --git a/rtengine/ipretinex.cc b/rtengine/ipretinex.cc index ec24fe9e3..a9648bf44 100644 --- a/rtengine/ipretinex.cc +++ b/rtengine/ipretinex.cc @@ -861,7 +861,7 @@ void ImProcFunctions::MSRLocal(int sp, bool fftw, int lum, LabImage * bufreti, L float delta; constexpr float eps = 2.f; bool useHslLin = false; - const float offse = 0.f; //loc.offs; + const float offse = loc.spots.at(sp).offs; const float chrT = (float)(loc.spots.at(sp).chrrt) / 100.f; const int scal = (loc.spots.at(sp).scalereti); float vart = loc.spots.at(sp).vart / 100.f;//variance @@ -1573,7 +1573,7 @@ void ImProcFunctions::MSRLocal(int sp, bool fftw, int lum, LabImage * bufreti, L cdmax = cd > cdmax ? cd : cdmax; cdmin = cd < cdmin ? cd : cdmin; - luminance[i][j] = CLIPMAX(LIM(cd, 0.f, maxclip) * str + (1.f - str) * originalLuminance[i][j]); + luminance[i][j] = intp(str, clipretinex(cd, 0.f, maxclip), originalLuminance[i][j]); } diff --git a/rtengine/procevents.h b/rtengine/procevents.h index d4fabd80c..a0455717d 100644 --- a/rtengine/procevents.h +++ b/rtengine/procevents.h @@ -778,6 +778,7 @@ enum ProcEventCode { Evlocallabdepth = 748, Evlocallabloglin = 749, Evlocallablumonly = 750, + Evlocallaboffs = 751, NUMOFEVENTS }; diff --git a/rtengine/procparams.cc b/rtengine/procparams.cc index 1260cf5bb..e6aaaf137 100644 --- a/rtengine/procparams.cc +++ b/rtengine/procparams.cc @@ -2582,6 +2582,7 @@ LocallabParams::LocallabSpot::LocallabSpot() : chrrt(0.0), neigh(50.0), vart(150.0), + offs(0.0), dehaz(0), depth(25), sensih(30), @@ -2846,6 +2847,7 @@ bool LocallabParams::LocallabSpot::operator ==(const LocallabSpot& other) const && chrrt == other.chrrt && neigh == other.neigh && vart == other.vart + && offs == other.offs && dehaz == other.dehaz && depth == other.depth && sensih == other.sensih @@ -4096,6 +4098,7 @@ int ProcParams::save(const Glib::ustring& fname, const Glib::ustring& fname2, bo saveToKeyfile(!pedited || pedited->locallab.spots.at(i).chrrt, "Locallab", "Chrrt_" + std::to_string(i), spot.chrrt, keyFile); saveToKeyfile(!pedited || pedited->locallab.spots.at(i).neigh, "Locallab", "Neigh_" + std::to_string(i), spot.neigh, keyFile); saveToKeyfile(!pedited || pedited->locallab.spots.at(i).vart, "Locallab", "Vart_" + std::to_string(i), spot.vart, keyFile); + saveToKeyfile(!pedited || pedited->locallab.spots.at(i).offs, "Locallab", "Offs_" + std::to_string(i), spot.offs, keyFile); saveToKeyfile(!pedited || pedited->locallab.spots.at(i).dehaz, "Locallab", "Dehaz_" + std::to_string(i), spot.dehaz, keyFile); saveToKeyfile(!pedited || pedited->locallab.spots.at(i).depth, "Locallab", "Depth_" + std::to_string(i), spot.depth, keyFile); saveToKeyfile(!pedited || pedited->locallab.spots.at(i).sensih, "Locallab", "Sensih_" + std::to_string(i), spot.sensih, keyFile); @@ -5473,6 +5476,7 @@ int ProcParams::load(const Glib::ustring& fname, ParamsEdited* pedited) assignFromKeyfile(keyFile, "Locallab", "Chrrt_" + std::to_string(i), pedited, spot.chrrt, spotEdited.chrrt); assignFromKeyfile(keyFile, "Locallab", "Neigh_" + std::to_string(i), pedited, spot.neigh, spotEdited.neigh); assignFromKeyfile(keyFile, "Locallab", "Vart_" + std::to_string(i), pedited, spot.vart, spotEdited.vart); + assignFromKeyfile(keyFile, "Locallab", "Offs_" + std::to_string(i), pedited, spot.offs, spotEdited.offs); assignFromKeyfile(keyFile, "Locallab", "Dehaz_" + std::to_string(i), pedited, spot.dehaz, spotEdited.dehaz); assignFromKeyfile(keyFile, "Locallab", "Depth_" + std::to_string(i), pedited, spot.depth, spotEdited.depth); assignFromKeyfile(keyFile, "Locallab", "Sensih_" + std::to_string(i), pedited, spot.sensih, spotEdited.sensih); diff --git a/rtengine/procparams.h b/rtengine/procparams.h index 44298a33d..84f937566 100644 --- a/rtengine/procparams.h +++ b/rtengine/procparams.h @@ -1131,6 +1131,7 @@ struct LocallabParams { double chrrt; double neigh; double vart; + double offs; int dehaz; int depth; int sensih; diff --git a/rtengine/refreshmap.cc b/rtengine/refreshmap.cc index 97a7032f0..85badd440 100644 --- a/rtengine/refreshmap.cc +++ b/rtengine/refreshmap.cc @@ -777,7 +777,8 @@ int refreshmap[rtengine::NUMOFEVENTS] = { LUMINANCECURVE, // EvlocallabexnoiseMethod LUMINANCECURVE, // Evlocallabdepth LUMINANCECURVE, // Evlocallabloglin - LUMINANCECURVE // Evlocallablumonly + LUMINANCECURVE, // Evlocallablumonly + LUMINANCECURVE // Evlocallaboffs }; diff --git a/rtgui/locallab.cc b/rtgui/locallab.cc index 684eaa9e4..822235ec6 100644 --- a/rtgui/locallab.cc +++ b/rtgui/locallab.cc @@ -269,6 +269,7 @@ Locallab::Locallab(): chrrt(Gtk::manage(new Adjuster(M("TP_LOCALLAB_CHRRT"), 0.0, 100.0, 0.1, 0.0))), neigh(Gtk::manage(new Adjuster(M("TP_LOCALLAB_NEIGH"), MINNEIGH, MAXNEIGH, 0.5, 50., nullptr, nullptr, &retiSlider2neigh, &retiNeigh2Slider))), vart(Gtk::manage(new Adjuster(M("TP_LOCALLAB_VART"), 0.1, 500., 0.1, 150.))), + offs(Gtk::manage(new Adjuster(M("TP_LOCALLAB_OFFS"), -4000., 10000., 1., 0.))), dehaz(Gtk::manage(new Adjuster(M("TP_LOCALLAB_DEHAZ"), 0, 100, 1, 0))), depth(Gtk::manage(new Adjuster(M("TP_LOCALLAB_DEPTH"), 0, 100, 1, 25))), sensih(Gtk::manage(new Adjuster(M("TP_LOCALLAB_SENSIH"), 0, 100, 1, 30))), @@ -1344,6 +1345,8 @@ Locallab::Locallab(): vart->set_tooltip_text(M("TP_LOCALLAB_RETI_NEIGH_VART_TOOLTIP")); } + offs->setAdjusterListener(this); + dehaz->setAdjusterListener(this); depth->setAdjusterListener(this); @@ -1483,6 +1486,7 @@ Locallab::Locallab(): retiBox->pack_start(*vart); retiBox->pack_start(*scalereti); retiBox->pack_start(*limd); + retiBox->pack_start(*offs); retiBox->pack_start(*darkness); retiBox->pack_start(*lightnessreti); // retiBox->pack_start(*softradiusret); @@ -3058,6 +3062,7 @@ void Locallab::write(ProcParams* pp, ParamsEdited* pedited) pp->locallab.spots.at(pp->locallab.selspot).chrrt = chrrt->getValue(); pp->locallab.spots.at(pp->locallab.selspot).neigh = neigh->getValue(); pp->locallab.spots.at(pp->locallab.selspot).vart = vart->getValue(); + pp->locallab.spots.at(pp->locallab.selspot).offs = offs->getValue(); pp->locallab.spots.at(pp->locallab.selspot).dehaz = dehaz->getIntValue(); pp->locallab.spots.at(pp->locallab.selspot).depth = depth->getIntValue(); pp->locallab.spots.at(pp->locallab.selspot).sensih = sensih->getIntValue(); @@ -3330,6 +3335,7 @@ void Locallab::write(ProcParams* pp, ParamsEdited* pedited) pe->locallab.spots.at(pp->locallab.selspot).chrrt = pe->locallab.spots.at(pp->locallab.selspot).chrrt || chrrt->getEditedState(); pe->locallab.spots.at(pp->locallab.selspot).neigh = pe->locallab.spots.at(pp->locallab.selspot).neigh || neigh->getEditedState(); pe->locallab.spots.at(pp->locallab.selspot).vart = pe->locallab.spots.at(pp->locallab.selspot).vart || vart->getEditedState(); + pe->locallab.spots.at(pp->locallab.selspot).offs = pe->locallab.spots.at(pp->locallab.selspot).offs || offs->getEditedState(); pe->locallab.spots.at(pp->locallab.selspot).dehaz = pe->locallab.spots.at(pp->locallab.selspot).dehaz || dehaz->getEditedState(); pe->locallab.spots.at(pp->locallab.selspot).depth = pe->locallab.spots.at(pp->locallab.selspot).depth || depth->getEditedState(); pe->locallab.spots.at(pp->locallab.selspot).sensih = pe->locallab.spots.at(pp->locallab.selspot).sensih || sensih->getEditedState(); @@ -3600,6 +3606,7 @@ void Locallab::write(ProcParams* pp, ParamsEdited* pedited) pedited->locallab.spots.at(pp->locallab.selspot).chrrt = pedited->locallab.spots.at(pp->locallab.selspot).chrrt || chrrt->getEditedState(); pedited->locallab.spots.at(pp->locallab.selspot).neigh = pedited->locallab.spots.at(pp->locallab.selspot).neigh || neigh->getEditedState(); pedited->locallab.spots.at(pp->locallab.selspot).vart = pedited->locallab.spots.at(pp->locallab.selspot).vart || vart->getEditedState(); + pedited->locallab.spots.at(pp->locallab.selspot).offs = pedited->locallab.spots.at(pp->locallab.selspot).offs || offs->getEditedState(); pedited->locallab.spots.at(pp->locallab.selspot).dehaz = pedited->locallab.spots.at(pp->locallab.selspot).dehaz || dehaz->getEditedState(); pedited->locallab.spots.at(pp->locallab.selspot).depth = pedited->locallab.spots.at(pp->locallab.selspot).depth || depth->getEditedState(); pedited->locallab.spots.at(pp->locallab.selspot).sensih = pedited->locallab.spots.at(pp->locallab.selspot).sensih || sensih->getEditedState(); @@ -5354,6 +5361,7 @@ void Locallab::setDefaults(const ProcParams * defParams, const ParamsEdited * pe chrrt->setDefault(defSpot->chrrt); neigh->setDefault(defSpot->neigh); vart->setDefault(defSpot->vart); + offs->setDefault(defSpot->offs); dehaz->setDefault((double)defSpot->dehaz); depth->setDefault((double)defSpot->depth); sensih->setDefault((double)defSpot->sensih); @@ -5517,6 +5525,7 @@ void Locallab::setDefaults(const ProcParams * defParams, const ParamsEdited * pe chrrt->setDefaultEditedState(Irrelevant); neigh->setDefaultEditedState(Irrelevant); vart->setDefaultEditedState(Irrelevant); + offs->setDefaultEditedState(Irrelevant); dehaz->setDefaultEditedState(Irrelevant); depth->setDefaultEditedState(Irrelevant); sensih->setDefaultEditedState(Irrelevant); @@ -5684,6 +5693,7 @@ void Locallab::setDefaults(const ProcParams * defParams, const ParamsEdited * pe chrrt->setDefaultEditedState(defSpotState->chrrt ? Edited : UnEdited); neigh->setDefaultEditedState(defSpotState->neigh ? Edited : UnEdited); vart->setDefaultEditedState(defSpotState->vart ? Edited : UnEdited); + offs->setDefaultEditedState(defSpotState->offs ? Edited : UnEdited); dehaz->setDefaultEditedState(defSpotState->dehaz ? Edited : UnEdited); depth->setDefaultEditedState(defSpotState->depth ? Edited : UnEdited); sensih->setDefaultEditedState(defSpotState->sensih ? Edited : UnEdited); @@ -6363,6 +6373,12 @@ void Locallab::adjusterChanged(Adjuster * a, double newval) } } + if (a == offs) { + if (listener) { + listener->panelChanged(Evlocallaboffs, offs->getTextValue()); + } + } + if (a == dehaz) { if (listener) { listener->panelChanged(Evlocallabdehaz, dehaz->getTextValue()); @@ -6857,6 +6873,7 @@ void Locallab::setBatchMode(bool batchMode) chrrt->showEditedCB(); neigh->showEditedCB(); vart->showEditedCB(); + offs->showEditedCB(); dehaz->showEditedCB(); depth->showEditedCB(); sensih->showEditedCB(); @@ -7472,6 +7489,7 @@ void Locallab::updateLocallabGUI(const rtengine::procparams::ProcParams* pp, con chrrt->setValue(pp->locallab.spots.at(index).chrrt); neigh->setValue(pp->locallab.spots.at(index).neigh); vart->setValue(pp->locallab.spots.at(index).vart); + offs->setValue(pp->locallab.spots.at(index).offs); dehaz->setValue(pp->locallab.spots.at(index).dehaz); depth->setValue(pp->locallab.spots.at(index).depth); sensih->setValue(pp->locallab.spots.at(index).sensih); @@ -7794,6 +7812,7 @@ void Locallab::updateLocallabGUI(const rtengine::procparams::ProcParams* pp, con chrrt->setEditedState(spotState->chrrt ? Edited : UnEdited); neigh->setEditedState(spotState->neigh ? Edited : UnEdited); vart->setEditedState(spotState->vart ? Edited : UnEdited); + offs->setEditedState(spotState->offs ? Edited : UnEdited); dehaz->setEditedState(spotState->dehaz ? Edited : UnEdited); depth->setEditedState(spotState->depth ? Edited : UnEdited); sensih->setEditedState(spotState->sensih ? Edited : UnEdited); diff --git a/rtgui/locallab.h b/rtgui/locallab.h index 872f0e995..bd4641923 100644 --- a/rtgui/locallab.h +++ b/rtgui/locallab.h @@ -217,6 +217,7 @@ private: Adjuster* const chrrt; Adjuster* const neigh; Adjuster* const vart; + Adjuster* const offs; Adjuster* const dehaz; Adjuster* const depth; Adjuster* const sensih; diff --git a/rtgui/paramsedited.cc b/rtgui/paramsedited.cc index 094c7074c..5fab4eff0 100644 --- a/rtgui/paramsedited.cc +++ b/rtgui/paramsedited.cc @@ -1123,6 +1123,7 @@ void ParamsEdited::initFrom(const std::vector& locallab.spots.at(j).chrrt = locallab.spots.at(j).chrrt && pSpot.chrrt == otherSpot.chrrt; locallab.spots.at(j).neigh = locallab.spots.at(j).neigh && pSpot.neigh == otherSpot.neigh; locallab.spots.at(j).vart = locallab.spots.at(j).vart && pSpot.vart == otherSpot.vart; + locallab.spots.at(j).offs = locallab.spots.at(j).offs && pSpot.vart == otherSpot.offs; locallab.spots.at(j).dehaz = locallab.spots.at(j).dehaz && pSpot.dehaz == otherSpot.dehaz; locallab.spots.at(j).depth = locallab.spots.at(j).depth && pSpot.depth == otherSpot.depth; locallab.spots.at(j).sensih = locallab.spots.at(j).sensih && pSpot.sensih == otherSpot.sensih; @@ -3338,6 +3339,10 @@ void ParamsEdited::combine(rtengine::procparams::ProcParams& toEdit, const rteng toEdit.locallab.spots.at(i).vart = mods.locallab.spots.at(i).vart; } + if (locallab.spots.at(i).offs) { + toEdit.locallab.spots.at(i).offs = mods.locallab.spots.at(i).offs; + } + if (locallab.spots.at(i).dehaz) { toEdit.locallab.spots.at(i).dehaz = mods.locallab.spots.at(i).dehaz; } @@ -4801,6 +4806,7 @@ LocallabParamsEdited::LocallabSpotEdited::LocallabSpotEdited(bool v) : chrrt(v), neigh(v), vart(v), + offs(v), dehaz(v), depth(v), sensih(v), @@ -5062,6 +5068,7 @@ void LocallabParamsEdited::LocallabSpotEdited::set(bool v) chrrt = v; neigh = v; vart = v; + offs = v; dehaz = v; depth = v; sensih = v; diff --git a/rtgui/paramsedited.h b/rtgui/paramsedited.h index 3b2bb05b6..16d73bcf4 100644 --- a/rtgui/paramsedited.h +++ b/rtgui/paramsedited.h @@ -541,6 +541,7 @@ public: bool chrrt; bool neigh; bool vart; + bool offs; bool dehaz; bool depth; bool sensih;