Add Soft radius for Color and Light Luminance

This commit is contained in:
Desmis 2019-03-15 17:52:45 +01:00
parent 8da8bf9a18
commit 78d7b392ab
10 changed files with 92 additions and 2 deletions

View File

@ -906,6 +906,7 @@ HISTORY_MSG_652;Local - Color mask slope
HISTORY_MSG_653;Local - SH mask chroma
HISTORY_MSG_654;Local - SH mask gamma
HISTORY_MSG_655;Local - SH mask slope
HISTORY_MSG_656;Local - Color 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

View File

@ -154,6 +154,7 @@ struct local_params {
float gammaexp;
float slomaexp;
float softradiusexp;
float softradiuscol;
float blendmaexp;
float radmaSH;
float blendmaSH;
@ -497,6 +498,7 @@ static void calcLocalParams(int sp, int oW, int oH, const LocallabParams& locall
float gammaskexpo = ((float) locallab.spots.at(sp).gammaskexp);
float slomaskexpo = ((float) locallab.spots.at(sp).slomaskexp);
float softradiusexpo = ((float) locallab.spots.at(sp).softradiusexp);
float softradiuscolor = ((float) locallab.spots.at(sp).softradiuscol);
float blendmaskSH = ((float) locallab.spots.at(sp).blendmaskSH) / 100.f ;
float radmaskSH = ((float) locallab.spots.at(sp).radmaskSH);
float chromaskSH = ((float) locallab.spots.at(sp).chromaskSH);
@ -560,6 +562,7 @@ static void calcLocalParams(int sp, int oW, int oH, const LocallabParams& locall
lp.gammaexp = gammaskexpo;
lp.slomaexp = slomaskexpo;
lp.softradiusexp = softradiusexpo;
lp.softradiuscol = softradiuscolor;
lp.struexc = structexclude;
lp.blendmaexp = blendmaskexpo;
lp.blendmaSH = blendmaskSH;
@ -8628,6 +8631,52 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o
}
delete bufcolcalc;
if (lp.softradiuscol > 0.f) {
float maxlig = -50000.f;
float minlig = 50000.f;
for (int ir = 0; ir < bfh; ir++)
for (int jr = 0; jr < bfw; jr++) {
if (buflight[ir][jr] > maxlig) {
maxlig = buflight[ir][jr];
}
if (buflight[ir][jr] < minlig) {
minlig = buflight[ir][jr];
}
}
array2D<float> blesoft(bfw, bfh);
array2D<float> guidsoft(bfw, bfh);
#ifdef _OPENMP
#pragma omp parallel for schedule(dynamic,16)
#endif
for (int ir = 0; ir < bfh; ir++)
for (int jr = 0; jr < bfw; jr++) {
blesoft[ir][jr] = LIM01((buflight[ir][jr] - minlig) / (100.f - minlig));
guidsoft[ir][jr] = ((bufcolorig->L[ir][jr]) / 32768.f);
}
guidedFilter(guidsoft, blesoft, blesoft, lp.softradiuscol * 10.f / sk, 0.04, multiThread, 4); //lp.softradiuscol
#ifdef _OPENMP
#pragma omp parallel for schedule(dynamic,16)
#endif
for (int ir = 0; ir < bfh; ir++)
for (int jr = 0; jr < bfw; jr++) {
buflight[ir][jr] = ((100.f - minlig) * blesoft[ir][jr]) + minlig;
}
guidsoft(0, 0);
blesoft(0, 0);
}
}
transit_shapedetect(0, bufcolorig, originalmaskcol, buflight, bufchro, buf_a, buf_b, bufhh, HHutili, hueref, chromaref, lumaref, sobelref, meansob, blend2, lp, original, transformed, cx, cy, sk);

View File

@ -682,6 +682,7 @@ enum ProcEventCode {
EvlocallabchromaskSH = 652,
EvlocallabgammaskSH = 653,
EvlocallabslomaskSH = 654,
Evlocallabsoftradiuscol = 655,
NUMOFEVENTS
};

View File

@ -2388,6 +2388,7 @@ LocallabParams::LocallabSpot::LocallabSpot() :
CCmaskcurve{(double)FCT_MinMaxCPoints, 0.0, 1.0, 0.35, 0.35, 0.50, 1.0, 0.35, 0.35, 1.00, 1.0, 0.35, 0.35 },
LLmaskcurve{(double)FCT_MinMaxCPoints, 0.0, 1.0, 0.35, 0.35, 0.50, 1.0, 0.35, 0.35, 1.00, 1.0, 0.35, 0.35 },
HHmaskcurve{(double)FCT_MinMaxCPoints, 0.0, 1.0, 0.35, 0.35, 0.50, 1.0, 0.35, 0.35, 1.00, 1.0, 0.35, 0.35 },
softradiuscol(5.0),
// Exposure
expexpose(false),
expcomp(0.0),
@ -2566,6 +2567,7 @@ bool LocallabParams::LocallabSpot::operator ==(const LocallabSpot& other) const
&& LLmaskcurve == other.LLmaskcurve
&& HHmaskcurve == other.HHmaskcurve
&& blurcolde == other.blurcolde
&& softradiuscol == other.softradiuscol
// Exposure
&& expexpose == other.expexpose
&& expcomp == other.expcomp
@ -3701,6 +3703,7 @@ int ProcParams::save(const Glib::ustring& fname, const Glib::ustring& fname2, bo
saveToKeyfile(!pedited || pedited->locallab.spots.at(i).CCmaskcurve, "Locallab", "CCmaskCurve_" + std::to_string(i), spot.CCmaskcurve, keyFile);
saveToKeyfile(!pedited || pedited->locallab.spots.at(i).LLmaskcurve, "Locallab", "LLmaskCurve_" + std::to_string(i), spot.LLmaskcurve, keyFile);
saveToKeyfile(!pedited || pedited->locallab.spots.at(i).HHmaskcurve, "Locallab", "HHmaskCurve_" + std::to_string(i), spot.HHmaskcurve, keyFile);
saveToKeyfile(!pedited || pedited->locallab.spots.at(i).softradiuscol, "Locallab", "Softradiuscol_" + std::to_string(i), spot.softradiuscol, keyFile);
// Exposure
saveToKeyfile(!pedited || pedited->locallab.spots.at(i).expexpose, "Locallab", "Expexpose_" + std::to_string(i), spot.expexpose, keyFile);
saveToKeyfile(!pedited || pedited->locallab.spots.at(i).expcomp, "Locallab", "Expcomp_" + std::to_string(i), spot.expcomp, keyFile);
@ -4964,6 +4967,7 @@ int ProcParams::load(const Glib::ustring& fname, ParamsEdited* pedited)
assignFromKeyfile(keyFile, "Locallab", "CCmaskCurve_" + std::to_string(i), pedited, spot.CCmaskcurve, spotEdited.CCmaskcurve);
assignFromKeyfile(keyFile, "Locallab", "LLmaskCurve_" + std::to_string(i), pedited, spot.LLmaskcurve, spotEdited.LLmaskcurve);
assignFromKeyfile(keyFile, "Locallab", "HHmaskCurve_" + std::to_string(i), pedited, spot.HHmaskcurve, spotEdited.HHmaskcurve);
assignFromKeyfile(keyFile, "Locallab", "Softradiuscol_" + std::to_string(i), pedited, spot.softradiuscol, spotEdited.softradiuscol);
// Exposure
assignFromKeyfile(keyFile, "Locallab", "Expexpose_" + std::to_string(i), pedited, spot.expexpose, spotEdited.expexpose);
assignFromKeyfile(keyFile, "Locallab", "Expcomp_" + std::to_string(i), pedited, spot.expcomp, spotEdited.expcomp);

View File

@ -988,6 +988,7 @@ struct LocallabParams {
std::vector<double> CCmaskcurve;
std::vector<double> LLmaskcurve;
std::vector<double> HHmaskcurve;
double softradiuscol;
// Exposure
bool expexpose;
// int expcomp;

View File

@ -681,7 +681,8 @@ int refreshmap[rtengine::NUMOFEVENTS] = {
LUMINANCECURVE, //EvLocallabslomaskcol
LUMINANCECURVE, //EvLocallabchromaskSH
LUMINANCECURVE, //EvLocallabgammaskSH
LUMINANCECURVE //EvLocallabslomaskSH
LUMINANCECURVE, //EvLocallabslomaskSH
LUMINANCECURVE //EvLocallabsoftradiuscol
};

View File

@ -89,6 +89,7 @@ Locallab::Locallab():
chromaskcol(Gtk::manage(new Adjuster(M("TP_LOCALLAB_CHROMASKCOL"), -100.0, 100.0, 0.1, 0.))),
gammaskcol(Gtk::manage(new Adjuster(M("TP_LOCALLAB_GAMMASKCOL"), 0.25, 4.0, 0.01, 1.))),
slomaskcol(Gtk::manage(new Adjuster(M("TP_LOCALLAB_SLOMASKCOL"), 0.0, 15.0, 0.1, 0.))),
softradiuscol(Gtk::manage(new Adjuster(M("TP_LOCALLAB_SOFTRADIUSCOL"), 0.0, 100.0, 0.1, 5.))),
// Exposure
expcomp(Gtk::manage(new Adjuster(M("TP_EXPOSURE_EXPCOMP"), -2.0, 4.0, 0.05, 0.0))),
hlcompr(Gtk::manage(new Adjuster(M("TP_EXPOSURE_COMPRHIGHLIGHTS"), 0, 500, 1, 0))),
@ -270,6 +271,7 @@ Locallab::Locallab():
chromaskcol->setAdjusterListener(this);
gammaskcol->setAdjusterListener(this);
slomaskcol->setAdjusterListener(this);
softradiuscol->setAdjusterListener(this);
qualitycurveMethod->append(M("TP_LOCALLAB_CURVNONE"));
qualitycurveMethod->append(M("TP_LOCALLAB_CURVCURR"));
@ -397,8 +399,9 @@ Locallab::Locallab():
superFrame->add(*superBox);
colorBox->pack_start(*superFrame);
colorBox->pack_start(*sensi);
colorBox->pack_start(*blurcolde);
colorBox->pack_start(*structcol);
colorBox->pack_start(*blurcolde);
colorBox->pack_start(*softradiuscol);
Gtk::HBox* const qualcurvbox = Gtk::manage(new Gtk::HBox());
qualcurvbox->pack_start(*labqualcurv, Gtk::PACK_SHRINK, 4);
qualcurvbox->pack_start(*qualitycurveMethod);
@ -1715,6 +1718,7 @@ void Locallab::write(ProcParams* pp, ParamsEdited* pedited)
pp->locallab.spots.at(pp->locallab.selspot).chromaskcol = chromaskcol->getValue();
pp->locallab.spots.at(pp->locallab.selspot).gammaskcol = gammaskcol->getValue();
pp->locallab.spots.at(pp->locallab.selspot).slomaskcol = slomaskcol->getValue();
pp->locallab.spots.at(pp->locallab.selspot).softradiuscol = softradiuscol->getValue();
// Exposure
pp->locallab.spots.at(pp->locallab.selspot).expexpose = expexpose->getEnabled();
pp->locallab.spots.at(pp->locallab.selspot).expcomp = expcomp->getValue();
@ -1909,6 +1913,7 @@ void Locallab::write(ProcParams* pp, ParamsEdited* pedited)
pe->locallab.spots.at(pp->locallab.selspot).chromaskcol = pe->locallab.spots.at(pp->locallab.selspot).chromaskcol || chromaskcol->getEditedState();
pe->locallab.spots.at(pp->locallab.selspot).gammaskcol = pe->locallab.spots.at(pp->locallab.selspot).gammaskcol || gammaskcol->getEditedState();
pe->locallab.spots.at(pp->locallab.selspot).slomaskcol = pe->locallab.spots.at(pp->locallab.selspot).slomaskcol || slomaskcol->getEditedState();
pe->locallab.spots.at(pp->locallab.selspot).softradiuscol = pe->locallab.spots.at(pp->locallab.selspot).softradiuscol || softradiuscol->getEditedState();
// Exposure
pe->locallab.spots.at(pp->locallab.selspot).expexpose = pe->locallab.spots.at(pp->locallab.selspot).expexpose || !expexpose->get_inconsistent();
pe->locallab.spots.at(pp->locallab.selspot).expcomp = pe->locallab.spots.at(pp->locallab.selspot).expcomp || expcomp->getEditedState();
@ -2089,6 +2094,7 @@ void Locallab::write(ProcParams* pp, ParamsEdited* pedited)
pedited->locallab.spots.at(pp->locallab.selspot).chromaskcol = pedited->locallab.spots.at(pp->locallab.selspot).chromaskcol || chromaskcol->getEditedState();
pedited->locallab.spots.at(pp->locallab.selspot).gammaskcol = pedited->locallab.spots.at(pp->locallab.selspot).gammaskcol || gammaskcol->getEditedState();
pedited->locallab.spots.at(pp->locallab.selspot).slomaskcol = pedited->locallab.spots.at(pp->locallab.selspot).slomaskcol || slomaskcol->getEditedState();
pedited->locallab.spots.at(pp->locallab.selspot).softradiuscol = pedited->locallab.spots.at(pp->locallab.selspot).softradiuscol || softradiuscol->getEditedState();
// Exposure
pedited->locallab.spots.at(pp->locallab.selspot).expexpose = pedited->locallab.spots.at(pp->locallab.selspot).expexpose || !expexpose->get_inconsistent();
pedited->locallab.spots.at(pp->locallab.selspot).expcomp = pedited->locallab.spots.at(pp->locallab.selspot).expcomp || expcomp->getEditedState();
@ -2647,6 +2653,7 @@ void Locallab::inversChanged()
structcol->show();
strengthgrid->hide();
blurcolde->show();
softradiuscol->show();
showmaskcolMethod->hide(); // Being able to change Color & Light mask visibility is useless in batch mode
gridFrame->hide();
} else if (invers->get_active()) {
@ -2661,6 +2668,7 @@ void Locallab::inversChanged()
blurcolde->show();
gridFrame->hide();
strengthgrid->hide();
softradiuscol->hide();
} else {
sensi->show();
@ -2673,6 +2681,7 @@ void Locallab::inversChanged()
structcol->show();
blurcolde->show();
gridFrame->show();
softradiuscol->show();
if (batchMode) {
showmaskcolMethod->hide(); // Being able to change Color & Light mask visibility is useless in batch mode
@ -2993,6 +3002,7 @@ void Locallab::setDefaults(const ProcParams * defParams, const ParamsEdited * pe
chromaskcol->setDefault(defSpot->chromaskcol);
gammaskcol->setDefault(defSpot->gammaskcol);
slomaskcol->setDefault(defSpot->slomaskcol);
softradiuscol->setDefault(defSpot->softradiuscol);
// Exposure
expcomp->setDefault(defSpot->expcomp);
hlcompr->setDefault((double)defSpot->hlcompr);
@ -3100,6 +3110,7 @@ void Locallab::setDefaults(const ProcParams * defParams, const ParamsEdited * pe
chromaskcol->setDefaultEditedState(Irrelevant);
gammaskcol->setDefaultEditedState(Irrelevant);
slomaskcol->setDefaultEditedState(Irrelevant);
softradiuscol->setDefaultEditedState(Irrelevant);
// Exposure
expcomp->setDefaultEditedState(Irrelevant);
hlcompr->setDefaultEditedState(Irrelevant);
@ -3211,6 +3222,7 @@ void Locallab::setDefaults(const ProcParams * defParams, const ParamsEdited * pe
chromaskcol->setDefaultEditedState(defSpotState->chromaskcol ? Edited : UnEdited);
gammaskcol->setDefaultEditedState(defSpotState->gammaskcol ? Edited : UnEdited);
slomaskcol->setDefaultEditedState(defSpotState->slomaskcol ? Edited : UnEdited);
softradiuscol->setDefaultEditedState(defSpotState->softradiuscol ? Edited : UnEdited);
// Exposure
expcomp->setDefaultEditedState(defSpotState->expcomp ? Edited : UnEdited);
hlcompr->setDefaultEditedState(defSpotState->hlcompr ? Edited : UnEdited);
@ -3417,6 +3429,12 @@ void Locallab::adjusterChanged(Adjuster * a, double newval)
}
}
if (a == softradiuscol) {
if (listener) {
listener->panelChanged(Evlocallabsoftradiuscol, softradiuscol->getTextValue());
}
}
}
// Exposure
@ -3984,6 +4002,7 @@ void Locallab::setBatchMode(bool batchMode)
chromaskcol->showEditedCB();
gammaskcol->showEditedCB();
slomaskcol->showEditedCB();
softradiuscol->showEditedCB();
// Exposure
expcomp->showEditedCB();
hlcompr->showEditedCB();
@ -4365,6 +4384,7 @@ void Locallab::updateLocallabGUI(const rtengine::procparams::ProcParams* pp, con
chromaskcol->setValue(pp->locallab.spots.at(index).chromaskcol);
gammaskcol->setValue(pp->locallab.spots.at(index).gammaskcol);
slomaskcol->setValue(pp->locallab.spots.at(index).slomaskcol);
softradiuscol->setValue(pp->locallab.spots.at(index).softradiuscol);
// Exposure
expexpose->setEnabled(pp->locallab.spots.at(index).expexpose);
@ -4588,6 +4608,7 @@ void Locallab::updateLocallabGUI(const rtengine::procparams::ProcParams* pp, con
chromaskcol->setEditedState(spotState->chromaskcol ? Edited : UnEdited);
gammaskcol->setEditedState(spotState->gammaskcol ? Edited : UnEdited);
slomaskcol->setEditedState(spotState->slomaskcol ? Edited : UnEdited);
softradiuscol->setEditedState(spotState->softradiuscol ? Edited : UnEdited);
// Exposure
expexpose->set_inconsistent(!spotState->expexpose);
@ -4750,6 +4771,7 @@ void Locallab::updateSpecificGUIState()
maskcolFrame->show();
structcol->show();
blurcolde->show();
softradiuscol->show();
showmaskcolMethod->hide(); // Being able to change Color & Light mask visibility is useless in batch mode
gridFrame->hide();
} else if (invers->get_active()) {
@ -4760,6 +4782,7 @@ void Locallab::updateSpecificGUIState()
qualitycurveMethod->hide();
labqualcurv->hide();
maskcolFrame->hide();
softradiuscol->hide();
structcol->hide();
blurcolde->show();
gridFrame->hide();
@ -4774,6 +4797,7 @@ void Locallab::updateSpecificGUIState()
structcol->show();
blurcolde->show();
gridFrame->show();
softradiuscol->show();
if (batchMode) {
showmaskcolMethod->hide(); // Being able to change Color & Light mask visibility is useless in batch mode

View File

@ -107,6 +107,7 @@ private:
Adjuster* const chromaskcol;
Adjuster* const gammaskcol;
Adjuster* const slomaskcol;
Adjuster* const softradiuscol;
// Exposure
Adjuster* const expcomp;
Adjuster* const hlcompr;

View File

@ -977,6 +977,7 @@ void ParamsEdited::initFrom(const std::vector<rtengine::procparams::ProcParams>&
locallab.spots.at(j).CCmaskcurve = locallab.spots.at(j).CCmaskcurve && pSpot.CCmaskcurve == otherSpot.CCmaskcurve;
locallab.spots.at(j).LLmaskcurve = locallab.spots.at(j).LLmaskcurve && pSpot.LLmaskcurve == otherSpot.LLmaskcurve;
locallab.spots.at(j).HHmaskcurve = locallab.spots.at(j).HHmaskcurve && pSpot.HHmaskcurve == otherSpot.HHmaskcurve;
locallab.spots.at(j).softradiuscol = locallab.spots.at(j).softradiuscol && pSpot.softradiuscol == otherSpot.softradiuscol;
// Exposure
locallab.spots.at(j).expexpose = locallab.spots.at(j).expexpose && pSpot.expexpose == otherSpot.expexpose;
locallab.spots.at(j).expcomp = locallab.spots.at(j).expcomp && pSpot.expcomp == otherSpot.expcomp;
@ -2723,6 +2724,10 @@ void ParamsEdited::combine(rtengine::procparams::ProcParams& toEdit, const rteng
toEdit.locallab.spots.at(i).HHmaskcurve = mods.locallab.spots.at(i).HHmaskcurve;
}
if (locallab.spots.at(i).softradiuscol) {
toEdit.locallab.spots.at(i).softradiuscol = mods.locallab.spots.at(i).softradiuscol;
}
// Exposure
if (locallab.spots.at(i).expexpose) {
toEdit.locallab.spots.at(i).expexpose = mods.locallab.spots.at(i).expexpose;
@ -4156,6 +4161,7 @@ LocallabParamsEdited::LocallabSpotEdited::LocallabSpotEdited(bool v) :
CCmaskcurve(v),
LLmaskcurve(v),
HHmaskcurve(v),
softradiuscol(v),
// Exposure
expexpose(v),
expcomp(v),
@ -4331,6 +4337,7 @@ void LocallabParamsEdited::LocallabSpotEdited::set(bool v)
CCmaskcurve = v;
LLmaskcurve = v;
HHmaskcurve = v;
softradiuscol = v;
// Exposure
expexpose = v;
expcomp = v;

View File

@ -404,6 +404,7 @@ public:
bool CCmaskcurve;
bool LLmaskcurve;
bool HHmaskcurve;
bool softradiuscol;
// Exposure
bool expexpose;
bool expcomp;