From 3e6680b7ce1b3025bb342935c7f7bd877b0ea6d8 Mon Sep 17 00:00:00 2001 From: Desmis Date: Sun, 6 Oct 2019 17:36:58 +0200 Subject: [PATCH] add Laplacian threshold to mask exposure --- rtdata/languages/default | 1 + rtengine/iplocallab.cc | 4 +++- rtengine/procevents.h | 1 + rtengine/procparams.cc | 4 ++++ rtengine/procparams.h | 1 + rtengine/refreshmap.cc | 3 ++- rtgui/locallab.cc | 24 ++++++++++++++++++++++++ rtgui/locallab.h | 1 + rtgui/paramsedited.cc | 7 +++++++ rtgui/paramsedited.h | 1 + 10 files changed, 45 insertions(+), 2 deletions(-) diff --git a/rtdata/languages/default b/rtdata/languages/default index 86ea33f39..556ae6d8b 100644 --- a/rtdata/languages/default +++ b/rtdata/languages/default @@ -996,6 +996,7 @@ HISTORY_MSG_755;Local - TM use tm mask HISTORY_MSG_756;Local - Exp use algo exposure mask HISTORY_MSG_757;Local - Exp Laplacian mask HISTORY_MSG_758;Local - Reti Laplacian mask +HISTORY_MSG_759;Local - Exp Laplacian mask 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/iplocallab.cc b/rtengine/iplocallab.cc index aa41b516d..fd4ce5533 100644 --- a/rtengine/iplocallab.cc +++ b/rtengine/iplocallab.cc @@ -9929,10 +9929,12 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o float gamma = lp.gammaexp; float slope = lp.slomaexp; float blendm = lp.blendmaexp; + float lap = params->locallab.spots.at(sp).lapmaskexp; + // bool invmask = params->locallab.spots.at(sp).enaExpMaskaft; maskcalccol(false, bfw, bfh, xstart, ystart, sk, cx, cy, bufexporig.get(), bufmaskblurexp.get(), originalmaskexp.get(), original, inv, lp, locccmasexpCurve, lcmasexputili, locllmasexpCurve, llmasexputili, lochhmasexpCurve, lhmasexputili, multiThread, - enaMask, showmaske, deltaE, modmask, zero, modif, chrom, rad, 0.f, gamma, slope, blendm); + enaMask, showmaske, deltaE, modmask, zero, modif, chrom, rad, lap, gamma, slope, blendm); if (lp.showmaskexpmet == 3) { showmask(lp, xstart, ystart, cx, cy, bfw, bfh, bufexporig.get(), transformed, bufmaskblurexp.get(), 0); diff --git a/rtengine/procevents.h b/rtengine/procevents.h index 4f4c1ed33..eb0155071 100644 --- a/rtengine/procevents.h +++ b/rtengine/procevents.h @@ -785,6 +785,7 @@ enum ProcEventCode { EvLocallabEnaExpMaskaft = 755, Evlocallablapmasktm = 756, Evlocallablapmaskreti = 757, + Evlocallablapmaskexp = 758, NUMOFEVENTS }; diff --git a/rtengine/procparams.cc b/rtengine/procparams.cc index 09fa02646..986103f64 100644 --- a/rtengine/procparams.cc +++ b/rtengine/procparams.cc @@ -2488,6 +2488,7 @@ LocallabParams::LocallabSpot::LocallabSpot() : chromaskexp(0.0), gammaskexp(1.0), slomaskexp(0.0), + lapmaskexp(0.0), softradiusexp(0.0), expMethod("std"), exnoiseMethod("none"), @@ -2759,6 +2760,7 @@ bool LocallabParams::LocallabSpot::operator ==(const LocallabSpot& other) const && chromaskexp == other.chromaskexp && gammaskexp == other.gammaskexp && slomaskexp == other.slomaskexp + && lapmaskexp == other.lapmaskexp && softradiusexp == other.softradiusexp && expMethod == other.expMethod && exnoiseMethod == other.exnoiseMethod @@ -4016,6 +4018,7 @@ int ProcParams::save(const Glib::ustring& fname, const Glib::ustring& fname2, bo saveToKeyfile(!pedited || pedited->locallab.spots.at(i).chromaskexp, "Locallab", "Chromaskexp_" + std::to_string(i), spot.chromaskexp, keyFile); saveToKeyfile(!pedited || pedited->locallab.spots.at(i).gammaskexp, "Locallab", "Gammaskexp_" + std::to_string(i), spot.gammaskexp, keyFile); saveToKeyfile(!pedited || pedited->locallab.spots.at(i).slomaskexp, "Locallab", "Slomaskexp_" + std::to_string(i), spot.slomaskexp, keyFile); + saveToKeyfile(!pedited || pedited->locallab.spots.at(i).lapmaskexp, "Locallab", "Lapmaskexp_" + std::to_string(i), spot.lapmaskexp, keyFile); saveToKeyfile(!pedited || pedited->locallab.spots.at(i).softradiusexp, "Locallab", "Softradiusexp_" + std::to_string(i), spot.softradiusexp, keyFile); saveToKeyfile(!pedited || pedited->locallab.spots.at(i).expMethod, "Locallab", "ExpMethod_" + std::to_string(i), spot.expMethod, keyFile); saveToKeyfile(!pedited || pedited->locallab.spots.at(i).exnoiseMethod, "Locallab", "ExnoiseMethod_" + std::to_string(i), spot.exnoiseMethod, keyFile); @@ -5388,6 +5391,7 @@ int ProcParams::load(const Glib::ustring& fname, ParamsEdited* pedited) assignFromKeyfile(keyFile, "Locallab", "Chromaskexp_" + std::to_string(i), pedited, spot.chromaskexp, spotEdited.chromaskexp); assignFromKeyfile(keyFile, "Locallab", "Gammaskexp_" + std::to_string(i), pedited, spot.gammaskexp, spotEdited.gammaskexp); assignFromKeyfile(keyFile, "Locallab", "Slomaskexp_" + std::to_string(i), pedited, spot.slomaskexp, spotEdited.slomaskexp); + assignFromKeyfile(keyFile, "Locallab", "Lapmaskexp_" + std::to_string(i), pedited, spot.lapmaskexp, spotEdited.lapmaskexp); assignFromKeyfile(keyFile, "Locallab", "Softradiusexp_" + std::to_string(i), pedited, spot.softradiusexp, spotEdited.softradiusexp); assignFromKeyfile(keyFile, "Locallab", "ExpMethod_" + std::to_string(i), pedited, spot.expMethod, spotEdited.expMethod); assignFromKeyfile(keyFile, "Locallab", "ExnoiseMethod_" + std::to_string(i), pedited, spot.exnoiseMethod, spotEdited.exnoiseMethod); diff --git a/rtengine/procparams.h b/rtengine/procparams.h index 14ab83e70..f15f12ff9 100644 --- a/rtengine/procparams.h +++ b/rtengine/procparams.h @@ -1037,6 +1037,7 @@ struct LocallabParams { double chromaskexp; double gammaskexp; double slomaskexp; + double lapmaskexp; double softradiusexp; Glib::ustring expMethod; Glib::ustring exnoiseMethod; diff --git a/rtengine/refreshmap.cc b/rtengine/refreshmap.cc index d602c32ec..726abe95a 100644 --- a/rtengine/refreshmap.cc +++ b/rtengine/refreshmap.cc @@ -784,7 +784,8 @@ int refreshmap[rtengine::NUMOFEVENTS] = { LUMINANCECURVE, //Evlocallabenatmmaskaft LUMINANCECURVE, //EvlocallabenaExpmaskaft LUMINANCECURVE, //Evlocallablapmasktm - LUMINANCECURVE //Evlocallablapmaskreti + LUMINANCECURVE, //Evlocallablapmaskreti + LUMINANCECURVE //Evlocallablapmaskexp }; namespace rtengine diff --git a/rtgui/locallab.cc b/rtgui/locallab.cc index c0cf789ec..d57f10c72 100644 --- a/rtgui/locallab.cc +++ b/rtgui/locallab.cc @@ -208,6 +208,7 @@ Locallab::Locallab(): chromaskexp(Gtk::manage(new Adjuster(M("TP_LOCALLAB_CHROMASKCOL"), -100.0, 100.0, 0.1, 0.))), gammaskexp(Gtk::manage(new Adjuster(M("TP_LOCALLAB_GAMMASKCOL"), 0.25, 4.0, 0.01, 1.))), slomaskexp(Gtk::manage(new Adjuster(M("TP_LOCALLAB_SLOMASKCOL"), 0.0, 15.0, 0.1, 0.))), + lapmaskexp(Gtk::manage(new Adjuster(M("TP_LOCALLAB_LAPMASKCOL"), 0.0, 100.0, 0.1, 0.))), softradiusexp(Gtk::manage(new Adjuster(M("TP_LOCALLAB_SOFTRADIUSCOL"), 0.0, 100.0, 0.5, 0.))), laplacexp(Gtk::manage(new Adjuster(M("TP_LOCALLAB_LAPLACEXP"), 0.0, 100.0, 0.1, 0.))), balanexp(Gtk::manage(new Adjuster(M("TP_LOCALLAB_BALANEXP"), 0.2, 1.2, 0.01, 0.75))), @@ -768,6 +769,7 @@ Locallab::Locallab(): chromaskexp->setAdjusterListener(this); gammaskexp->setAdjusterListener(this); slomaskexp->setAdjusterListener(this); + lapmaskexp->setAdjusterListener(this); softradiusexp->setAdjusterListener(this); laplacexp->setAdjusterListener(this); balanexp->setAdjusterListener(this); @@ -778,6 +780,11 @@ Locallab::Locallab(): fatanchor->setAdjusterListener(this); fatlevel->setAdjusterListener(this); + if (showtooltip) { + radmaskexp->set_tooltip_text(M("TP_LOCALLAB_LAPRAD_TOOLTIP")); + lapmaskexp->set_tooltip_text(M("TP_LOCALLAB_LAPRAD_TOOLTIP")); + } + curveEditorG->setCurveListener(this); shapeexpos = static_cast(curveEditorG->addCurve(CT_Diagonal, "")); @@ -866,6 +873,7 @@ Locallab::Locallab(): pdeFrame->set_tooltip_text(M("TP_LOCALLAB_PDEFRAME_TOOLTIP")); } + ToolParamBlock* const pdeBox = Gtk::manage(new ToolParamBlock()); pdeBox->pack_start(*laplacexp); pdeBox->pack_start(*linear); @@ -914,6 +922,7 @@ Locallab::Locallab(): maskexpBox->pack_start(*maskexpCurveEditorG, Gtk::PACK_SHRINK, 4); // Padding is mandatory to correct behavior of curve editor maskexpBox->pack_start(*blendmaskexp, Gtk::PACK_SHRINK, 0); maskexpBox->pack_start(*radmaskexp, Gtk::PACK_SHRINK, 0); + maskexpBox->pack_start(*lapmaskexp, Gtk::PACK_SHRINK, 0); maskexpBox->pack_start(*chromaskexp, Gtk::PACK_SHRINK, 0); maskexpBox->pack_start(*gammaskexp, Gtk::PACK_SHRINK, 0); maskexpBox->pack_start(*slomaskexp, Gtk::PACK_SHRINK, 0); @@ -3045,6 +3054,7 @@ void Locallab::write(ProcParams* pp, ParamsEdited* pedited) pp->locallab.spots.at(pp->locallab.selspot).chromaskexp = chromaskexp->getValue(); pp->locallab.spots.at(pp->locallab.selspot).gammaskexp = gammaskexp->getValue(); pp->locallab.spots.at(pp->locallab.selspot).slomaskexp = slomaskexp->getValue(); + pp->locallab.spots.at(pp->locallab.selspot).lapmaskexp = lapmaskexp->getValue(); pp->locallab.spots.at(pp->locallab.selspot).softradiusexp = softradiusexp->getValue(); if (expMethod->get_active_row_number() == 0) { @@ -3385,6 +3395,7 @@ void Locallab::write(ProcParams* pp, ParamsEdited* pedited) pe->locallab.spots.at(pp->locallab.selspot).chromaskexp = pe->locallab.spots.at(pp->locallab.selspot).chromaskexp || chromaskexp->getEditedState(); pe->locallab.spots.at(pp->locallab.selspot).gammaskexp = pe->locallab.spots.at(pp->locallab.selspot).gammaskexp || gammaskexp->getEditedState(); pe->locallab.spots.at(pp->locallab.selspot).slomaskexp = pe->locallab.spots.at(pp->locallab.selspot).slomaskexp || slomaskexp->getEditedState(); + pe->locallab.spots.at(pp->locallab.selspot).lapmaskexp = pe->locallab.spots.at(pp->locallab.selspot).lapmaskexp || lapmaskexp->getEditedState(); pe->locallab.spots.at(pp->locallab.selspot).softradiusexp = pe->locallab.spots.at(pp->locallab.selspot).softradiusexp || softradiusexp->getEditedState(); pe->locallab.spots.at(pp->locallab.selspot).expMethod = pe->locallab.spots.at(pp->locallab.selspot).expMethod || expMethod->get_active_text() != M("GENERAL_UNCHANGED"); pe->locallab.spots.at(pp->locallab.selspot).exnoiseMethod = pe->locallab.spots.at(pp->locallab.selspot).exnoiseMethod || exnoiseMethod->get_active_text() != M("GENERAL_UNCHANGED"); @@ -3660,6 +3671,7 @@ void Locallab::write(ProcParams* pp, ParamsEdited* pedited) pedited->locallab.spots.at(pp->locallab.selspot).chromaskexp = pedited->locallab.spots.at(pp->locallab.selspot).chromaskexp || chromaskexp->getEditedState(); pedited->locallab.spots.at(pp->locallab.selspot).gammaskexp = pedited->locallab.spots.at(pp->locallab.selspot).gammaskexp || gammaskexp->getEditedState(); pedited->locallab.spots.at(pp->locallab.selspot).slomaskexp = pedited->locallab.spots.at(pp->locallab.selspot).slomaskexp || slomaskexp->getEditedState(); + pedited->locallab.spots.at(pp->locallab.selspot).lapmaskexp = pedited->locallab.spots.at(pp->locallab.selspot).lapmaskexp || lapmaskexp->getEditedState(); pedited->locallab.spots.at(pp->locallab.selspot).softradiusexp = pedited->locallab.spots.at(pp->locallab.selspot).softradiusexp || softradiusexp->getEditedState(); pedited->locallab.spots.at(pp->locallab.selspot).expMethod = pedited->locallab.spots.at(pp->locallab.selspot).expMethod || expMethod->get_active_text() != M("GENERAL_UNCHANGED"); pedited->locallab.spots.at(pp->locallab.selspot).exnoiseMethod = pedited->locallab.spots.at(pp->locallab.selspot).exnoiseMethod || exnoiseMethod->get_active_text() != M("GENERAL_UNCHANGED"); @@ -5508,6 +5520,7 @@ void Locallab::setDefaults(const ProcParams * defParams, const ParamsEdited * pe chromaskexp->setDefault(defSpot->chromaskexp); gammaskexp->setDefault(defSpot->gammaskexp); slomaskexp->setDefault(defSpot->slomaskexp); + lapmaskexp->setDefault(defSpot->lapmaskexp); softradiusexp->setDefault(defSpot->softradiusexp); laplacexp->setDefault(defSpot->laplacexp); balanexp->setDefault(defSpot->balanexp); @@ -5675,6 +5688,7 @@ void Locallab::setDefaults(const ProcParams * defParams, const ParamsEdited * pe chromaskexp->setDefaultEditedState(Irrelevant); gammaskexp->setDefaultEditedState(Irrelevant); slomaskexp->setDefaultEditedState(Irrelevant); + lapmaskexp->setDefaultEditedState(Irrelevant); softradiusexp->setDefaultEditedState(Irrelevant); laplacexp->setDefaultEditedState(Irrelevant); balanexp->setDefaultEditedState(Irrelevant); @@ -5846,6 +5860,7 @@ void Locallab::setDefaults(const ProcParams * defParams, const ParamsEdited * pe chromaskexp->setDefaultEditedState(defSpotState->chromaskexp ? Edited : UnEdited); gammaskexp->setDefaultEditedState(defSpotState->gammaskexp ? Edited : UnEdited); slomaskexp->setDefaultEditedState(defSpotState->slomaskexp ? Edited : UnEdited); + lapmaskexp->setDefaultEditedState(defSpotState->lapmaskexp ? Edited : UnEdited); softradiusexp->setDefaultEditedState(defSpotState->softradiusexp ? Edited : UnEdited); laplacexp->setDefaultEditedState(defSpotState->laplacexp ? Edited : UnEdited); balanexp->setDefaultEditedState(defSpotState->balanexp ? Edited : UnEdited); @@ -6219,6 +6234,12 @@ void Locallab::adjusterChanged(Adjuster * a, double newval) } } + if (a == lapmaskexp) { + if (listener) { + listener->panelChanged(Evlocallablapmaskexp, lapmaskexp->getTextValue()); + } + } + if (a == softradiusexp) { if (listener) { listener->panelChanged(Evlocallabsoftradiusexp, softradiusexp->getTextValue()); @@ -7050,6 +7071,7 @@ void Locallab::setBatchMode(bool batchMode) chromaskexp->showEditedCB(); gammaskexp->showEditedCB(); slomaskexp->showEditedCB(); + lapmaskexp->showEditedCB(); softradiusexp->showEditedCB(); laplacexp->showEditedCB(); balanexp->showEditedCB(); @@ -7582,6 +7604,7 @@ void Locallab::updateLocallabGUI(const rtengine::procparams::ProcParams* pp, con chromaskexp->setValue(pp->locallab.spots.at(index).chromaskexp); gammaskexp->setValue(pp->locallab.spots.at(index).gammaskexp); slomaskexp->setValue(pp->locallab.spots.at(index).slomaskexp); + lapmaskexp->setValue(pp->locallab.spots.at(index).lapmaskexp); softradiusexp->setValue(pp->locallab.spots.at(index).softradiusexp); if (pp->locallab.spots.at(index).expMethod == "std") { @@ -7946,6 +7969,7 @@ void Locallab::updateLocallabGUI(const rtengine::procparams::ProcParams* pp, con chromaskexp->setEditedState(spotState->chromaskexp ? Edited : UnEdited); gammaskexp->setEditedState(spotState->gammaskexp ? Edited : UnEdited); slomaskexp->setEditedState(spotState->slomaskexp ? Edited : UnEdited); + lapmaskexp->setEditedState(spotState->lapmaskexp ? Edited : UnEdited); softradiusexp->setEditedState(spotState->softradiusexp ? Edited : UnEdited); if (!spotState->expMethod) { diff --git a/rtgui/locallab.h b/rtgui/locallab.h index 6e4647a41..4279c13f2 100644 --- a/rtgui/locallab.h +++ b/rtgui/locallab.h @@ -157,6 +157,7 @@ private: Adjuster* const chromaskexp; Adjuster* const gammaskexp; Adjuster* const slomaskexp; + Adjuster* const lapmaskexp; Adjuster* const softradiusexp; Adjuster* const laplacexp; Adjuster* const balanexp; diff --git a/rtgui/paramsedited.cc b/rtgui/paramsedited.cc index 8e3f4dd1e..0390a6022 100644 --- a/rtgui/paramsedited.cc +++ b/rtgui/paramsedited.cc @@ -1029,6 +1029,7 @@ void ParamsEdited::initFrom(const std::vector& locallab.spots.at(j).chromaskexp = locallab.spots.at(j).chromaskexp && pSpot.chromaskexp == otherSpot.chromaskexp; locallab.spots.at(j).gammaskexp = locallab.spots.at(j).gammaskexp && pSpot.gammaskexp == otherSpot.gammaskexp; locallab.spots.at(j).slomaskexp = locallab.spots.at(j).slomaskexp && pSpot.slomaskexp == otherSpot.slomaskexp; + locallab.spots.at(j).lapmaskexp = locallab.spots.at(j).lapmaskexp && pSpot.lapmaskexp == otherSpot.lapmaskexp; locallab.spots.at(j).softradiusexp = locallab.spots.at(j).softradiusexp && pSpot.softradiusexp == otherSpot.softradiusexp; locallab.spots.at(j).expMethod = locallab.spots.at(j).expMethod && pSpot.expMethod == otherSpot.expMethod; locallab.spots.at(j).exnoiseMethod = locallab.spots.at(j).exnoiseMethod && pSpot.exnoiseMethod == otherSpot.exnoiseMethod; @@ -2987,6 +2988,10 @@ void ParamsEdited::combine(rtengine::procparams::ProcParams& toEdit, const rteng toEdit.locallab.spots.at(i).slomaskexp = mods.locallab.spots.at(i).slomaskexp; } + if (locallab.spots.at(i).lapmaskexp) { + toEdit.locallab.spots.at(i).lapmaskexp = mods.locallab.spots.at(i).lapmaskexp; + } + if (locallab.spots.at(i).softradiusexp) { toEdit.locallab.spots.at(i).softradiusexp = mods.locallab.spots.at(i).softradiusexp; } @@ -4742,6 +4747,7 @@ LocallabParamsEdited::LocallabSpotEdited::LocallabSpotEdited(bool v) : chromaskexp(v), gammaskexp(v), slomaskexp(v), + lapmaskexp(v), softradiusexp(v), expMethod(v), exnoiseMethod(v), @@ -5010,6 +5016,7 @@ void LocallabParamsEdited::LocallabSpotEdited::set(bool v) chromaskexp = v; gammaskexp = v; slomaskexp = v; + lapmaskexp = v; softradiusexp = v; expMethod = v; exnoiseMethod = v; diff --git a/rtgui/paramsedited.h b/rtgui/paramsedited.h index fffd5b5e7..f672d05d2 100644 --- a/rtgui/paramsedited.h +++ b/rtgui/paramsedited.h @@ -447,6 +447,7 @@ public: bool chromaskexp; bool gammaskexp; bool slomaskexp; + bool lapmaskexp; bool softradiusexp; bool expMethod; bool exnoiseMethod;