From 7701a56e6cc8d023b259d3d5874bf1f8c638cece Mon Sep 17 00:00:00 2001 From: Desmis Date: Sat, 23 Feb 2019 14:34:17 +0100 Subject: [PATCH] add method to Labgrid color correction --- rtdata/languages/default | 3 +++ rtengine/iplocallab.cc | 12 ++++++++++++ rtengine/procevents.h | 1 + rtengine/procparams.cc | 4 ++++ rtengine/procparams.h | 1 + rtengine/refreshmap.cc | 3 ++- rtgui/locallab.cc | 40 ++++++++++++++++++++++++++++++++++++++++ rtgui/locallab.h | 3 +++ rtgui/paramsedited.cc | 7 +++++++ rtgui/paramsedited.h | 1 + 10 files changed, 74 insertions(+), 1 deletion(-) diff --git a/rtdata/languages/default b/rtdata/languages/default index 4ecc85b70..3ccc3a0c9 100644 --- a/rtdata/languages/default +++ b/rtdata/languages/default @@ -878,6 +878,7 @@ HISTORY_MSG_622;Local - Exclude structure HISTORY_MSG_623;Local - Exp Chroma compensation HISTORY_MSG_624;Local - Color correction grid HISTORY_MSG_625;Local - Color correction strength +HISTORY_MSG_626;Local - Color correction Method HISTORY_MSG_CLAMPOOG;Clip out-of-gamut colors HISTORY_MSG_COLORTONING_LABGRID_VALUE;CT - Color correction HISTORY_MSG_COLORTONING_LABREGION_AB;CT - Color correction @@ -1972,6 +1973,8 @@ TP_LOCALLAB_CURVENCONTRAST;Super+Contrast threshold (experimental) TP_LOCALLAB_CURVENSOB2;Combined HueChroma + Contrast threshold (experimental) TP_LOCALLAB_DENOIS;Denoise TP_LOCALLAB_DEHAZ;Dehaze +TP_LOCALLAB_GRIDONE;Color Toning +TP_LOCALLAB_GRIDTWO;Direct TP_LOCALLAB_LUM;Curves LC TP_LOCALLAB_HLH;Curves H TP_LOCALLAB_CHROMACBDL;Chroma diff --git a/rtengine/iplocallab.cc b/rtengine/iplocallab.cc index bdd889e52..cf99cc141 100644 --- a/rtengine/iplocallab.cc +++ b/rtengine/iplocallab.cc @@ -190,6 +190,7 @@ struct local_params { float str; int qualmet; int qualcurvemet; + int gridmet; int showmaskcolmet; int showmaskexpmet; int blurmet; @@ -405,6 +406,12 @@ static void calcLocalParams(int sp, int oW, int oH, const LocallabParams& locall lp.qualcurvemet = 1; } + if (locallab.spots.at(sp).gridMethod == "one") { + lp.gridmet = 0; + } else if (locallab.spots.at(sp).gridMethod == "two") { + lp.gridmet = 1; + } + lp.showmaskcolmet = llColorMask; lp.showmaskexpmet = llExpMask; lp.enaColorMask = locallab.spots.at(sp).enaColorMask && llColorMask == 0 && llExpMask == 0; // Color & Light mask is deactivated if Exposure mask is visible @@ -8461,8 +8468,13 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o } if (ctoning) { + if(lp.gridmet == 0) { bufcolcalc->a[loy - begy][lox - begx] += bufcolcalc->L[loy - begy][lox - begx] * a_scale + a_base; bufcolcalc->b[loy - begy][lox - begx] += bufcolcalc->L[loy - begy][lox - begx] * b_scale + b_base; + } else if(lp.gridmet == 1) { + bufcolcalc->a[loy - begy][lox - begx] += 35000.f * a_scale; + bufcolcalc->b[loy - begy][lox - begx] += 35000.f * b_scale; + } } float rL; diff --git a/rtengine/procevents.h b/rtengine/procevents.h index c66b884ea..7b1effa2d 100644 --- a/rtengine/procevents.h +++ b/rtengine/procevents.h @@ -652,6 +652,7 @@ enum ProcEventCode { Evlocallabexpchroma = 622, EvLocallabLabGridValue = 623, EvLocallabLabstrengthgrid = 624, + EvLocallabgridMethod = 625, NUMOFEVENTS }; diff --git a/rtengine/procparams.cc b/rtengine/procparams.cc index c1f67181c..e31a91104 100644 --- a/rtengine/procparams.cc +++ b/rtengine/procparams.cc @@ -2373,6 +2373,7 @@ LocallabParams::LocallabSpot::LocallabSpot() : blurcolde(5), blendmaskcol(0), qualitycurveMethod("none"), + gridMethod("one"), llcurve{(double)DCT_NURBS, 0.0, 0.0, 1.0, 1.0}, cccurve{(double)DCT_NURBS, 0.0, 0.0, 1.0, 1.0}, LHcurve{(double)FCT_MinMaxCPoints, 0.0, 0.50, 0.35, 0.35, 0.166, 0.50, 0.35, 0.35, 0.333, 0.50, 0.35, 0.35, 0.50, 0.50, 0.35, 0.35, 0.666, 0.50, 0.35, 0.35, 0.833, 0.50, 0.35, 0.35}, @@ -2522,6 +2523,7 @@ bool LocallabParams::LocallabSpot::operator ==(const LocallabSpot& other) const && structcol == other.structcol && blendmaskcol == other.blendmaskcol && qualitycurveMethod == other.qualitycurveMethod + && gridMethod == other.gridMethod && llcurve == other.llcurve && cccurve == other.cccurve && LHcurve == other.LHcurve @@ -3630,6 +3632,7 @@ int ProcParams::save(const Glib::ustring& fname, const Glib::ustring& fname2, bo saveToKeyfile(!pedited || pedited->locallab.spots.at(i).blurcolde, "Locallab", "Blurcolde_" + std::to_string(i), spot.blurcolde, keyFile); saveToKeyfile(!pedited || pedited->locallab.spots.at(i).blendmaskcol, "Locallab", "Blendmaskcol_" + std::to_string(i), spot.blendmaskcol, keyFile); saveToKeyfile(!pedited || pedited->locallab.spots.at(i).qualitycurveMethod, "Locallab", "QualityCurveMethod_" + std::to_string(i), spot.qualitycurveMethod, keyFile); + saveToKeyfile(!pedited || pedited->locallab.spots.at(i).gridMethod, "Locallab", "gridMethod_" + std::to_string(i), spot.gridMethod, keyFile); saveToKeyfile(!pedited || pedited->locallab.spots.at(i).llcurve, "Locallab", "LLCurve_" + std::to_string(i), spot.llcurve, keyFile); saveToKeyfile(!pedited || pedited->locallab.spots.at(i).cccurve, "Locallab", "CCCurve_" + std::to_string(i), spot.cccurve, keyFile); saveToKeyfile(!pedited || pedited->locallab.spots.at(i).LHcurve, "Locallab", "LHCurve_" + std::to_string(i), spot.LHcurve, keyFile); @@ -4865,6 +4868,7 @@ int ProcParams::load(const Glib::ustring& fname, ParamsEdited* pedited) assignFromKeyfile(keyFile, "Locallab", "Blurcolde_" + std::to_string(i), pedited, spot.blurcolde, spotEdited.blurcolde); assignFromKeyfile(keyFile, "Locallab", "Blendmaskcol_" + std::to_string(i), pedited, spot.blendmaskcol, spotEdited.blendmaskcol); assignFromKeyfile(keyFile, "Locallab", "QualityCurveMethod_" + std::to_string(i), pedited, spot.qualitycurveMethod, spotEdited.qualitycurveMethod); + assignFromKeyfile(keyFile, "Locallab", "gridMethod_" + std::to_string(i), pedited, spot.gridMethod, spotEdited.gridMethod); assignFromKeyfile(keyFile, "Locallab", "LLCurve_" + std::to_string(i), pedited, spot.llcurve, spotEdited.llcurve); assignFromKeyfile(keyFile, "Locallab", "CCCurve_" + std::to_string(i), pedited, spot.cccurve, spotEdited.cccurve); assignFromKeyfile(keyFile, "Locallab", "LHCurve_" + std::to_string(i), pedited, spot.LHcurve, spotEdited.LHcurve); diff --git a/rtengine/procparams.h b/rtengine/procparams.h index 85929dc57..d098e4adc 100644 --- a/rtengine/procparams.h +++ b/rtengine/procparams.h @@ -973,6 +973,7 @@ struct LocallabParams { int blurcolde; int blendmaskcol; Glib::ustring qualitycurveMethod; + Glib::ustring gridMethod; std::vector llcurve; std::vector cccurve; std::vector LHcurve; diff --git a/rtengine/refreshmap.cc b/rtengine/refreshmap.cc index f516bae4d..ac9f265e8 100644 --- a/rtengine/refreshmap.cc +++ b/rtengine/refreshmap.cc @@ -651,7 +651,8 @@ int refreshmap[rtengine::NUMOFEVENTS] = { LUMINANCECURVE, // Evlocallabstructexclu LUMINANCECURVE, // Evlocallabexpchroma LUMINANCECURVE, //EvLocallabLabGridValue - LUMINANCECURVE //EvLocallabLabstrengthgrid + LUMINANCECURVE, //EvLocallabLabstrengthgrid + LUMINANCECURVE //EvLocallabgridMethod }; diff --git a/rtgui/locallab.cc b/rtgui/locallab.cc index 7c4f5ae25..f7cbfd591 100644 --- a/rtgui/locallab.cc +++ b/rtgui/locallab.cc @@ -172,6 +172,7 @@ Locallab::Locallab(): // ComboBox widgets // Color & Light qualitycurveMethod(Gtk::manage(new MyComboBoxText())), + gridMethod(Gtk::manage(new MyComboBoxText())), showmaskcolMethod(Gtk::manage(new MyComboBoxText())), //Exposure showmaskexpMethod(Gtk::manage(new MyComboBoxText())), @@ -245,6 +246,12 @@ Locallab::Locallab(): qualitycurveMethod->set_tooltip_markup(M("TP_LOCALLAB_CURVEMETHOD_TOOLTIP")); qualitycurveMethodConn = qualitycurveMethod->signal_changed().connect(sigc::mem_fun(*this, &Locallab::qualitycurveMethodChanged)); + gridMethod->append(M("TP_LOCALLAB_GRIDONE")); + gridMethod->append(M("TP_LOCALLAB_GRIDTWO")); + gridMethod->set_active(0); +// gridMethod->set_tooltip_markup(M("TP_LOCALLAB_GRIDMETHOD_TOOLTIP")); + gridMethodConn = gridMethod->signal_changed().connect(sigc::mem_fun(*this, &Locallab::gridMethodChanged)); + llCurveEditorG->setCurveListener(this); llshape = static_cast(llCurveEditorG->addCurve(CT_Diagonal, "L(L)")); @@ -353,6 +360,7 @@ Locallab::Locallab(): gridFrame->set_label_align(0.025, 0.5); ToolParamBlock* const gridBox = Gtk::manage(new ToolParamBlock()); gridBox->pack_start(*labgrid); + gridBox->pack_start(*gridMethod); gridBox->pack_start(*strengthgrid); gridFrame->add(*gridBox); superBox->pack_start(*gridFrame); @@ -1523,6 +1531,12 @@ void Locallab::write(ProcParams* pp, ParamsEdited* pedited) pp->locallab.spots.at(pp->locallab.selspot).qualitycurveMethod = "std"; } + if (gridMethod->get_active_row_number() == 0) { + pp->locallab.spots.at(pp->locallab.selspot).gridMethod = "one"; + } else if (gridMethod->get_active_row_number() == 1) { + pp->locallab.spots.at(pp->locallab.selspot).gridMethod = "two"; + } + pp->locallab.spots.at(pp->locallab.selspot).llcurve = llshape->getCurve(); pp->locallab.spots.at(pp->locallab.selspot).cccurve = ccshape->getCurve(); pp->locallab.spots.at(pp->locallab.selspot).LHcurve = LHshape->getCurve(); @@ -1685,6 +1699,7 @@ void Locallab::write(ProcParams* pp, ParamsEdited* pedited) pe->locallab.spots.at(pp->locallab.selspot).sensi = pe->locallab.spots.at(pp->locallab.selspot).sensi || sensi->getEditedState(); pe->locallab.spots.at(pp->locallab.selspot).structcol = pe->locallab.spots.at(pp->locallab.selspot).structcol || structcol->getEditedState(); pe->locallab.spots.at(pp->locallab.selspot).qualitycurveMethod = pe->locallab.spots.at(pp->locallab.selspot).qualitycurveMethod || qualitycurveMethod->get_active_text() != M("GENERAL_UNCHANGED"); + pe->locallab.spots.at(pp->locallab.selspot).gridMethod = pe->locallab.spots.at(pp->locallab.selspot).gridMethod || gridMethod->get_active_text() != M("GENERAL_UNCHANGED"); pe->locallab.spots.at(pp->locallab.selspot).llcurve = pe->locallab.spots.at(pp->locallab.selspot).llcurve || !llshape->isUnChanged(); pe->locallab.spots.at(pp->locallab.selspot).cccurve = pe->locallab.spots.at(pp->locallab.selspot).cccurve || !ccshape->isUnChanged(); pe->locallab.spots.at(pp->locallab.selspot).LHcurve = pe->locallab.spots.at(pp->locallab.selspot).LHcurve || !LHshape->isUnChanged(); @@ -1834,6 +1849,7 @@ void Locallab::write(ProcParams* pp, ParamsEdited* pedited) pedited->locallab.spots.at(pp->locallab.selspot).sensi = pedited->locallab.spots.at(pp->locallab.selspot).sensi || sensi->getEditedState(); pedited->locallab.spots.at(pp->locallab.selspot).structcol = pedited->locallab.spots.at(pp->locallab.selspot).structcol || structcol->getEditedState(); pedited->locallab.spots.at(pp->locallab.selspot).qualitycurveMethod = pedited->locallab.spots.at(pp->locallab.selspot).qualitycurveMethod || qualitycurveMethod->get_active_text() != M("GENERAL_UNCHANGED"); + pedited->locallab.spots.at(pp->locallab.selspot).gridMethod = pedited->locallab.spots.at(pp->locallab.selspot).gridMethod || gridMethod->get_active_text() != M("GENERAL_UNCHANGED"); pedited->locallab.spots.at(pp->locallab.selspot).llcurve = pedited->locallab.spots.at(pp->locallab.selspot).llcurve || !llshape->isUnChanged(); pedited->locallab.spots.at(pp->locallab.selspot).cccurve = pedited->locallab.spots.at(pp->locallab.selspot).cccurve || !ccshape->isUnChanged(); pedited->locallab.spots.at(pp->locallab.selspot).LHcurve = pedited->locallab.spots.at(pp->locallab.selspot).LHcurve || !LHshape->isUnChanged(); @@ -2186,6 +2202,17 @@ void Locallab::qualitycurveMethodChanged() } } +void Locallab::gridMethodChanged() +{ + // printf("qualitycurveMethodChanged\n"); + + if (getEnabled() && expcolor->getEnabled()) { + if (listener) { + listener->panelChanged(EvLocallabgridMethod, gridMethod->get_active_text()); + } + } +} + void Locallab::showmaskcolMethodChanged() { // printf("showmaskcolMethodChanged\n"); @@ -3467,6 +3494,7 @@ void Locallab::setBatchMode(bool batchMode) // Set batch mode for comboBoxText // Color & Light qualitycurveMethod->append(M("GENERAL_UNCHANGED")); + gridMethod->append(M("GENERAL_UNCHANGED")); // Blur & Noise blurMethod->append(M("GENERAL_UNCHANGED")); // Retinex @@ -3612,6 +3640,7 @@ void Locallab::enableListener() enablecolorConn.block(false); curvactivConn.block(false); qualitycurveMethodConn.block(false); + gridMethodConn.block(false); inversConn.block(false); showmaskcolMethodConn.block(false); enaColorMaskConn.block(false); @@ -3658,6 +3687,7 @@ void Locallab::disableListener() enablecolorConn.block(true); curvactivConn.block(true); qualitycurveMethodConn.block(true); + gridMethodConn.block(true); inversConn.block(true); showmaskcolMethodConn.block(true); enaColorMaskConn.block(true); @@ -3719,6 +3749,12 @@ void Locallab::updateLocallabGUI(const rtengine::procparams::ProcParams* pp, con qualitycurveMethod->set_active(1); } + if (pp->locallab.spots.at(index).gridMethod == "one") { + gridMethod->set_active(0); + } else if (pp->locallab.spots.at(index).gridMethod == "two") { + gridMethod->set_active(1); + } + llshape->setCurve(pp->locallab.spots.at(index).llcurve); ccshape->setCurve(pp->locallab.spots.at(index).cccurve); LHshape->setCurve(pp->locallab.spots.at(index).LHcurve); @@ -3909,6 +3945,10 @@ void Locallab::updateLocallabGUI(const rtengine::procparams::ProcParams* pp, con qualitycurveMethod->set_active_text(M("GENERAL_UNCHANGED")); } + if (!spotState->gridMethod) { + gridMethod->set_active_text(M("GENERAL_UNCHANGED")); + } + llshape->setUnChanged(!spotState->llcurve); ccshape->setUnChanged(!spotState->cccurve); LHshape->setUnChanged(!spotState->LHcurve); diff --git a/rtgui/locallab.h b/rtgui/locallab.h index 7ba076b11..3bb17c928 100644 --- a/rtgui/locallab.h +++ b/rtgui/locallab.h @@ -198,6 +198,8 @@ private: // Color & Light MyComboBoxText* const qualitycurveMethod; sigc::connection qualitycurveMethodConn; + MyComboBoxText* const gridMethod; + sigc::connection gridMethodConn; MyComboBoxText* const showmaskcolMethod; sigc::connection showmaskcolMethodConn; //Exposure @@ -271,6 +273,7 @@ private: // ComboBox event functions // Color & Light void qualitycurveMethodChanged(); + void gridMethodChanged(); void showmaskcolMethodChanged(); //Exposure void showmaskexpMethodChanged(); diff --git a/rtgui/paramsedited.cc b/rtgui/paramsedited.cc index 978dc5323..04ea895c9 100644 --- a/rtgui/paramsedited.cc +++ b/rtgui/paramsedited.cc @@ -958,6 +958,7 @@ void ParamsEdited::initFrom(const std::vector& locallab.spots.at(j).blurcolde = locallab.spots.at(j).blurcolde && pSpot.blurcolde == otherSpot.blurcolde; locallab.spots.at(j).blendmaskcol = locallab.spots.at(j).blendmaskcol && pSpot.blendmaskcol == otherSpot.blendmaskcol; locallab.spots.at(j).qualitycurveMethod = locallab.spots.at(j).qualitycurveMethod && pSpot.qualitycurveMethod == otherSpot.qualitycurveMethod; + locallab.spots.at(j).gridMethod = locallab.spots.at(j).gridMethod && pSpot.gridMethod == otherSpot.gridMethod; locallab.spots.at(j).llcurve = locallab.spots.at(j).llcurve && pSpot.llcurve == otherSpot.llcurve; locallab.spots.at(j).cccurve = locallab.spots.at(j).cccurve && pSpot.cccurve == otherSpot.cccurve; locallab.spots.at(j).LHcurve = locallab.spots.at(j).LHcurve && pSpot.LHcurve == otherSpot.LHcurve; @@ -2627,6 +2628,10 @@ void ParamsEdited::combine(rtengine::procparams::ProcParams& toEdit, const rteng toEdit.locallab.spots.at(i).qualitycurveMethod = mods.locallab.spots.at(i).qualitycurveMethod; } + if (locallab.spots.at(i).gridMethod) { + toEdit.locallab.spots.at(i).gridMethod = mods.locallab.spots.at(i).gridMethod; + } + if (locallab.spots.at(i).llcurve) { toEdit.locallab.spots.at(i).llcurve = mods.locallab.spots.at(i).llcurve; } @@ -3993,6 +3998,7 @@ LocallabParamsEdited::LocallabSpotEdited::LocallabSpotEdited(bool v) : blurcolde(v), blendmaskcol(v), qualitycurveMethod(v), + gridMethod(v), llcurve(v), cccurve(v), LHcurve(v), @@ -4140,6 +4146,7 @@ void LocallabParamsEdited::LocallabSpotEdited::set(bool v) blurcolde = v; blendmaskcol = v; qualitycurveMethod = v; + gridMethod = v; llcurve = v; cccurve = v; LHcurve = v; diff --git a/rtgui/paramsedited.h b/rtgui/paramsedited.h index 84ab9c55d..db9668a46 100644 --- a/rtgui/paramsedited.h +++ b/rtgui/paramsedited.h @@ -497,6 +497,7 @@ public: bool blurcolde; bool blendmaskcol; bool qualitycurveMethod; + bool gridMethod; bool llcurve; bool cccurve; bool LHcurve;