From 241fb8fdb9af18fa7d6665ebd579f557236740de Mon Sep 17 00:00:00 2001 From: Desmis Date: Thu, 18 Apr 2019 07:58:44 +0200 Subject: [PATCH] Add sofradius TM --- rtdata/languages/default | 1 + rtengine/iplocallab.cc | 10 +++++++++- rtengine/procevents.h | 1 + rtengine/procparams.cc | 4 ++++ rtengine/procparams.h | 1 + rtengine/refreshmap.cc | 3 ++- rtgui/locallab.cc | 19 +++++++++++++++++++ rtgui/locallab.h | 1 + rtgui/paramsedited.cc | 7 +++++++ rtgui/paramsedited.h | 1 + 10 files changed, 46 insertions(+), 2 deletions(-) diff --git a/rtdata/languages/default b/rtdata/languages/default index adbdf68e6..ad48702a3 100644 --- a/rtdata/languages/default +++ b/rtdata/languages/default @@ -918,6 +918,7 @@ HISTORY_MSG_670;Local - cbdl mask C HISTORY_MSG_671;Local - cbdl mask L HISTORY_MSG_672;Local - cbdl mask CL HISTORY_MSG_673;Local - Use cbdl mask +HISTORY_MSG_675;Local - TM soft radius 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 4ee92de09..75a2a8bcc 100644 --- a/rtengine/iplocallab.cc +++ b/rtengine/iplocallab.cc @@ -182,6 +182,7 @@ struct local_params { float softradiuscol; float softradiuscb; float softradiusret; + float softradiustm; float blendmaexp; float radmaSH; float blendmaSH; @@ -505,6 +506,7 @@ static void calcLocalParams(int sp, int oW, int oH, const LocallabParams& locall float softradiusexpo = ((float) locallab.spots.at(sp).softradiusexp); float softradiuscolor = ((float) locallab.spots.at(sp).softradiuscol); float softradiusreti = ((float) locallab.spots.at(sp).softradiusret); + float softradiustma = ((float) locallab.spots.at(sp).softradiustm); float softradiuscbdl = ((float) locallab.spots.at(sp).softradiuscb); float blendmaskSH = ((float) locallab.spots.at(sp).blendmaskSH) / 100.f ; float radmaskSH = ((float) locallab.spots.at(sp).radmaskSH); @@ -580,6 +582,7 @@ static void calcLocalParams(int sp, int oW, int oH, const LocallabParams& locall lp.softradiuscol = softradiuscolor; lp.softradiusret = softradiusreti; lp.softradiuscb = softradiuscbdl; + lp.softradiustm = softradiustma; lp.struexc = structexclude; lp.blendmaexp = blendmaskexpo; lp.blendmaSH = blendmaskSH; @@ -4916,7 +4919,7 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o const int bfw = xend - xstart; if (bfw > 0 && bfh > 0) { - JaggedArray buflight(bfw, bfh); + array2D buflight(bfw, bfh); JaggedArray bufchro(bfw, bfh); 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 @@ -4965,6 +4968,11 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o bufchro[y][x] /= coefC; } } + + if (lp.softradiustm > 0.f) { + softprocess(bufgb.get(), buflight, lp.softradiustm, bfh, bfw, sk, multiThread); + } + bufgb.reset(); transit_shapedetect(8, tmp1.get(), nullptr, buflight, bufchro, nullptr, nullptr, nullptr, false, hueref, chromaref, lumaref, sobelref, 0.f, nullptr, lp, original, transformed, cx, cy, sk); } diff --git a/rtengine/procevents.h b/rtengine/procevents.h index 8c470e1d7..621585a6a 100644 --- a/rtengine/procevents.h +++ b/rtengine/procevents.h @@ -701,6 +701,7 @@ enum ProcEventCode { EvlocallabHHmaskcbshape = 671, EvLocallabEnacbMask = 672, EvlocallabshowmaskcbMethod = 673, + Evlocallabsoftradiustm = 674, NUMOFEVENTS }; diff --git a/rtengine/procparams.cc b/rtengine/procparams.cc index 409178dad..e97b30777 100644 --- a/rtengine/procparams.cc +++ b/rtengine/procparams.cc @@ -2462,6 +2462,7 @@ LocallabParams::LocallabSpot::LocallabSpot() : scaltm(10), rewei(0), sensitm(19), + softradiustm(0.0), // Retinex expreti(false), retinexMethod("high"), @@ -2657,6 +2658,7 @@ bool LocallabParams::LocallabSpot::operator ==(const LocallabSpot& other) const && scaltm == other.scaltm && rewei == other.rewei && sensitm == other.sensitm + && softradiustm == other.softradiustm // Retinex && expreti == other.expreti && retinexMethod == other.retinexMethod @@ -3808,6 +3810,7 @@ int ProcParams::save(const Glib::ustring& fname, const Glib::ustring& fname2, bo saveToKeyfile(!pedited || pedited->locallab.spots.at(i).scaltm, "Locallab", "Scaltm_" + std::to_string(i), spot.scaltm, keyFile); 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); // 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); @@ -5100,6 +5103,7 @@ int ProcParams::load(const Glib::ustring& fname, ParamsEdited* pedited) assignFromKeyfile(keyFile, "Locallab", "Scaltm_" + std::to_string(i), pedited, spot.scaltm, spotEdited.scaltm); 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); // 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 9d95f78b0..6fb35ac71 100644 --- a/rtengine/procparams.h +++ b/rtengine/procparams.h @@ -1063,6 +1063,7 @@ struct LocallabParams { int scaltm; int rewei; int sensitm; + double softradiustm; // Retinex bool expreti; Glib::ustring retinexMethod; diff --git a/rtengine/refreshmap.cc b/rtengine/refreshmap.cc index 085272c24..9760f0aa8 100644 --- a/rtengine/refreshmap.cc +++ b/rtengine/refreshmap.cc @@ -700,7 +700,8 @@ int refreshmap[rtengine::NUMOFEVENTS] = { LUMINANCECURVE, //EvlocallabLLmaskcbshape LUMINANCECURVE, //EvlocallabHHmaskcbshape LUMINANCECURVE, //EvLocallabEnacbMask - LUMINANCECURVE //EvlocallabshowmaskcbMethod + LUMINANCECURVE, //EvlocallabshowmaskcbMethod + LUMINANCECURVE //Evlocallabsoftradiustm }; diff --git a/rtgui/locallab.cc b/rtgui/locallab.cc index d80336190..5e9b67cbb 100644 --- a/rtgui/locallab.cc +++ b/rtgui/locallab.cc @@ -143,6 +143,7 @@ Locallab::Locallab(): 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.))), // 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))), @@ -768,6 +769,7 @@ Locallab::Locallab(): 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(*stren); @@ -775,6 +777,7 @@ Locallab::Locallab(): tmBox->pack_start(*estop); tmBox->pack_start(*scaltm); tmBox->pack_start(*rewei); + tmBox->pack_start(*softradiustm); tmBox->pack_start(*sensitm); exptonemap->add(*tmBox); exptonemap->setLevel(2); @@ -1919,6 +1922,7 @@ void Locallab::write(ProcParams* pp, ParamsEdited* pedited) 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).sensitm = sensitm->getIntValue(); + pp->locallab.spots.at(pp->locallab.selspot).softradiustm = softradiustm->getValue(); // Retinex pp->locallab.spots.at(pp->locallab.selspot).expreti = expreti->getEnabled(); @@ -2124,6 +2128,7 @@ void Locallab::write(ProcParams* pp, ParamsEdited* pedited) pe->locallab.spots.at(pp->locallab.selspot).scaltm = pe->locallab.spots.at(pp->locallab.selspot).scaltm || scaltm->getEditedState(); 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(); // 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"); @@ -2323,6 +2328,7 @@ void Locallab::write(ProcParams* pp, ParamsEdited* pedited) pedited->locallab.spots.at(pp->locallab.selspot).scaltm = pedited->locallab.spots.at(pp->locallab.selspot).scaltm || scaltm->getEditedState(); 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(); // 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"); @@ -3285,6 +3291,7 @@ void Locallab::setDefaults(const ProcParams * defParams, const ParamsEdited * pe scaltm->setDefault((double)defSpot->scaltm); rewei->setDefault((double)defSpot->rewei); sensitm->setDefault((double)defSpot->sensitm); + softradiustm->setDefault(defSpot->softradiustm); // Retinex str->setDefault((double)defSpot->str); chrrt->setDefault((double)defSpot->chrrt); @@ -3405,6 +3412,7 @@ void Locallab::setDefaults(const ProcParams * defParams, const ParamsEdited * pe scaltm->setDefaultEditedState(Irrelevant); rewei->setDefaultEditedState(Irrelevant); sensitm->setDefaultEditedState(Irrelevant); + softradiustm->setDefaultEditedState(Irrelevant); // Retinex str->setDefaultEditedState(Irrelevant); chrrt->setDefaultEditedState(Irrelevant); @@ -3529,6 +3537,7 @@ void Locallab::setDefaults(const ProcParams * defParams, const ParamsEdited * pe scaltm->setDefaultEditedState(defSpotState->scaltm ? Edited : UnEdited); rewei->setDefaultEditedState(defSpotState->rewei ? Edited : UnEdited); sensitm->setDefaultEditedState(defSpotState->sensitm ? Edited : UnEdited); + softradiustm->setDefaultEditedState(defSpotState->softradiustm ? Edited : UnEdited); // Retinex str->setDefaultEditedState(defSpotState->str ? Edited : UnEdited); chrrt->setDefaultEditedState(defSpotState->chrrt ? Edited : UnEdited); @@ -3991,6 +4000,13 @@ void Locallab::adjusterChanged(Adjuster * a, double newval) listener->panelChanged(Evlocallabsensitm, sensitm->getTextValue()); } } + + if (a == softradiustm) { + if (listener) { + listener->panelChanged(Evlocallabsoftradiustm, softradiustm->getTextValue()); + } + } + } // Retinex @@ -4377,6 +4393,7 @@ void Locallab::setBatchMode(bool batchMode) scaltm->showEditedCB(); rewei->showEditedCB(); sensitm->showEditedCB(); + softradiustm->showEditedCB(); // Retinex str->showEditedCB(); chrrt->showEditedCB(); @@ -4807,6 +4824,7 @@ void Locallab::updateLocallabGUI(const rtengine::procparams::ProcParams* pp, con scaltm->setValue(pp->locallab.spots.at(index).scaltm); rewei->setValue(pp->locallab.spots.at(index).rewei); sensitm->setValue(pp->locallab.spots.at(index).sensitm); + softradiustm->setValue(pp->locallab.spots.at(index).softradiustm); // Retinex expreti->setEnabled(pp->locallab.spots.at(index).expreti); @@ -5042,6 +5060,7 @@ void Locallab::updateLocallabGUI(const rtengine::procparams::ProcParams* pp, con scaltm->setEditedState(spotState->scaltm ? Edited : UnEdited); rewei->setEditedState(spotState->rewei ? Edited : UnEdited); sensitm->setEditedState(spotState->sensitm ? Edited : UnEdited); + softradiustm->setEditedState(spotState->softradiustm ? Edited : UnEdited); // Retinex expreti->set_inconsistent(!spotState->expreti); diff --git a/rtgui/locallab.h b/rtgui/locallab.h index 770e75092..8fbb3830c 100644 --- a/rtgui/locallab.h +++ b/rtgui/locallab.h @@ -165,6 +165,7 @@ private: Adjuster* const scaltm; Adjuster* const rewei; Adjuster* const sensitm; + Adjuster* const softradiustm; // Retinex Adjuster* const str; Adjuster* const chrrt; diff --git a/rtgui/paramsedited.cc b/rtgui/paramsedited.cc index bcdf1bd91..5cf0125e1 100644 --- a/rtgui/paramsedited.cc +++ b/rtgui/paramsedited.cc @@ -1052,6 +1052,7 @@ void ParamsEdited::initFrom(const std::vector& locallab.spots.at(j).scaltm = locallab.spots.at(j).scaltm && pSpot.scaltm == otherSpot.scaltm; 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; // 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; @@ -3019,6 +3020,10 @@ void ParamsEdited::combine(rtengine::procparams::ProcParams& toEdit, const rteng toEdit.locallab.spots.at(i).sensitm = mods.locallab.spots.at(i).sensitm; } + if (locallab.spots.at(i).softradiustm) { + toEdit.locallab.spots.at(i).softradiustm = mods.locallab.spots.at(i).softradiustm; + } + // Retinex if (locallab.spots.at(i).expreti) { toEdit.locallab.spots.at(i).expreti = mods.locallab.spots.at(i).expreti; @@ -4320,6 +4325,7 @@ LocallabParamsEdited::LocallabSpotEdited::LocallabSpotEdited(bool v) : scaltm(v), rewei(v), sensitm(v), + softradiustm(v), // Retinex expreti(v), retinexMethod(v), @@ -4512,6 +4518,7 @@ void LocallabParamsEdited::LocallabSpotEdited::set(bool v) scaltm = v; rewei = v; sensitm = v; + softradiustm = v; // Retinex expreti = v; retinexMethod = v; diff --git a/rtgui/paramsedited.h b/rtgui/paramsedited.h index a30b758f7..6636f877c 100644 --- a/rtgui/paramsedited.h +++ b/rtgui/paramsedited.h @@ -479,6 +479,7 @@ public: bool scaltm; bool rewei; bool sensitm; + bool softradiustm; // Retinex bool expreti; bool retinexMethod;