Improve Exposure PDE with gamma

This commit is contained in:
Desmis 2019-09-07 10:55:47 +02:00
parent 202fb8084d
commit 03aff81ebd
10 changed files with 66 additions and 6 deletions

View File

@ -978,6 +978,7 @@ HISTORY_MSG_738;Local - Local contrast Merge L
HISTORY_MSG_739;Local - Local contrast Soft radius
HISTORY_MSG_740;Local - Local contrast Merge C
HISTORY_MSG_741;Local - Local contrast Residual C
HISTORY_MSG_742;Local - Exp Laplacian gamma
HISTORY_MSG_CLAMPOOG;Clip out-of-gamut colors
HISTORY_MSG_COLORTONING_LABGRID_VALUE;CT - Color correction
HISTORY_MSG_COLORTONING_LABREGION_AB;CT - Color correction
@ -2122,6 +2123,7 @@ TP_LOCALLAB_GUIDFILTER_TOOLTIP;Adapt this values according to images - reduce if
TP_LOCALLAB_LOC_CONTRAST;Local contrast
TP_LOCALLAB_LAPLACEXP;Laplacian threshold
TP_LOCALLAB_BALANEXP;PDE balance
TP_LOCALLAB_GAMM;Gamma
TP_LOCALLAB_REFLABEL;Ref. (0..1) Chroma=%1 Luma=%2 Hue=%3
TP_LOCALLAB_NOISELUMFINE;Luminance fine 1 (Wav)
TP_LOCALLAB_NOISELUMFINEZERO;Luminance fine 0 (Wav)

View File

@ -9089,15 +9089,31 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o
float *datain = new float[bfwr * bfhr];
float *dataout = new float[bfwr * bfhr];
float *dataor = new float[bfwr * bfhr];
Imagefloat *tmpImage = nullptr;
tmpImage = new Imagefloat(bfwr, bfhr);
float gam = params->locallab.spots.at(sp).gamm;
float igam = 1.f / gam;
#ifdef _OPENMP
#pragma omp parallel for schedule(dynamic,16)
#endif
for (int y = 0; y < bfhr; y++) {
for (int x = 0; x < bfwr; x++) {
datain[y * bfwr + x] = bufexpfin->L[y][x];
dataor[y * bfwr + x] = bufexpfin->L[y][x];
float LogL = 1.f;
float X, Y, Z;
float L = bufexpfin->L[y][x] / 32768.f;
/* float a = bufexpfin->a[y][x];
float b = bufexpfin->b[y][x];
Color::Lab2XYZ(L, a, b, X, Y, Z);
tmpImage->r(y, x) = X;
tmpImage->g(y, x) = Y;
tmpImage->b(y, x) = Z;
*/
L = pow(L, gam);
L *= 32768.f;
datain[y * bfwr + x] = L;
dataor[y * bfwr + x] = L;
}
}
@ -9109,9 +9125,17 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o
for (int y = 0; y < bfhr; y++) {
for (int x = 0; x < bfwr; x++) {
bufexpfin->L[y][x] = dataout[y * bfwr + x] ;
// float X = tmpImage->r(y, x);
float Y = dataout[y * bfwr + x] / 32768.f;
// float Z = tmpImage->b(y, x);
// float L, a , b;
// Color::XYZ2Lab(X, Y, Z, L, a, b);
Y = pow(Y, igam);
Y *= 32768.f;
bufexpfin->L[y][x] = Y; //dataout[y * bfwr + x] ;
}
}
delete tmpImage;
delete [] datain;
delete [] dataout;

View File

@ -768,6 +768,7 @@ enum ProcEventCode {
Evlocallabclarisoft = 738,
Evlocallabclaricres = 739,
Evlocallabresidchro = 740,
Evlocallabgamm = 741,
NUMOFEVENTS
};

View File

@ -2458,6 +2458,7 @@ LocallabParams::LocallabSpot::LocallabSpot() :
laplacexp(20.0),
balanexp(0.8),
linear(0.0),
gamm(1.0),
// Shadow highlight
expshadhigh(false),
highlights(0),
@ -2713,6 +2714,7 @@ bool LocallabParams::LocallabSpot::operator ==(const LocallabSpot& other) const
&& laplacexp == other.laplacexp
&& balanexp == other.balanexp
&& linear == other.linear
&& gamm == other.gamm
// Shadow highlight
&& expshadhigh == other.expshadhigh
&& highlights == other.highlights
@ -3949,6 +3951,7 @@ int ProcParams::save(const Glib::ustring& fname, const Glib::ustring& fname2, bo
saveToKeyfile(!pedited || pedited->locallab.spots.at(i).laplacexp, "Locallab", "Laplacexp_" + std::to_string(i), spot.laplacexp, keyFile);
saveToKeyfile(!pedited || pedited->locallab.spots.at(i).balanexp, "Locallab", "Balanexp_" + std::to_string(i), spot.balanexp, keyFile);
saveToKeyfile(!pedited || pedited->locallab.spots.at(i).linear, "Locallab", "Linearexp_" + std::to_string(i), spot.linear, keyFile);
saveToKeyfile(!pedited || pedited->locallab.spots.at(i).gamm, "Locallab", "Gamm_" + std::to_string(i), spot.gamm, keyFile);
// Shadow highlight
saveToKeyfile(!pedited || pedited->locallab.spots.at(i).expshadhigh, "Locallab", "Expshadhigh_" + std::to_string(i), spot.expshadhigh, keyFile);
saveToKeyfile(!pedited || pedited->locallab.spots.at(i).highlights, "Locallab", "highlights_" + std::to_string(i), spot.highlights, keyFile);
@ -5295,6 +5298,7 @@ int ProcParams::load(const Glib::ustring& fname, ParamsEdited* pedited)
assignFromKeyfile(keyFile, "Locallab", "Laplacexp_" + std::to_string(i), pedited, spot.laplacexp, spotEdited.laplacexp);
assignFromKeyfile(keyFile, "Locallab", "Balanexp_" + std::to_string(i), pedited, spot.balanexp, spotEdited.balanexp);
assignFromKeyfile(keyFile, "Locallab", "Linearexp_" + std::to_string(i), pedited, spot.linear, spotEdited.linear);
assignFromKeyfile(keyFile, "Locallab", "Gamm_" + std::to_string(i), pedited, spot.gamm, spotEdited.gamm);
// Shadow highlight
assignFromKeyfile(keyFile, "Locallab", "Expshadhigh_" + std::to_string(i), pedited, spot.expshadhigh, spotEdited.expshadhigh);
assignFromKeyfile(keyFile, "Locallab", "highlights_" + std::to_string(i), pedited, spot.highlights, spotEdited.highlights);

View File

@ -1023,6 +1023,7 @@ struct LocallabParams {
double laplacexp;
double balanexp;
double linear;
double gamm;
// Shadow highlight
bool expshadhigh;
int highlights;

View File

@ -767,7 +767,8 @@ int refreshmap[rtengine::NUMOFEVENTS] = {
LUMINANCECURVE, //Evlocallabclarilres
LUMINANCECURVE, //Evlocallabclarisoft
LUMINANCECURVE, //Evlocallabclaricres
LUMINANCECURVE //Evlocallabresidchro
LUMINANCECURVE, //Evlocallabresidchro
LUMINANCECURVE //Evlocallabgamm
};

View File

@ -194,7 +194,7 @@ Locallab::Locallab():
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))),
hlcomprthresh(Gtk::manage(new Adjuster(M("TP_EXPOSURE_COMPRHIGHLIGHTSTHRESHOLD"), 0, 100, 1, 0))),
black(Gtk::manage(new Adjuster(M("TP_EXPOSURE_BLACKLEVEL"), -16384, 32768, 50, 0))),
black(Gtk::manage(new Adjuster(M("TP_EXPOSURE_BLACKLEVEL"), -30000, 32768, 50, 0))),
shadex(Gtk::manage(new Adjuster(M("TP_LOCALLAB_SHADEX"), 0, 100, 1, 0))),
shcompr(Gtk::manage(new Adjuster(M("TP_LOCALLAB_SHADEXCOMP"), 0, 100, 1, 50))),
expchroma(Gtk::manage(new Adjuster(M("TP_LOCALLAB_EXPCHROMA"), -50, 100, 1, 30))),
@ -211,6 +211,7 @@ Locallab::Locallab():
laplacexp(Gtk::manage(new Adjuster(M("TP_LOCALLAB_LAPLACEXP"), 0.0, 100.0, 0.1, 20.))),
balanexp(Gtk::manage(new Adjuster(M("TP_LOCALLAB_BALANEXP"), 0.2, 1.2, 0.01, 0.8))),
linear(Gtk::manage(new Adjuster(M("TP_LOCALLAB_LINEAR"), 0., 1., 0.01, 0.))),
gamm(Gtk::manage(new Adjuster(M("TP_LOCALLAB_GAMM"), 0.1, 2., 0.01, 1.))),
//Shadow hightlights
highlights(Gtk::manage(new Adjuster(M("TP_SHADOWSHLIGHTS_HIGHLIGHTS"), 0, 100, 1, 0))),
h_tonalwidth(Gtk::manage(new Adjuster(M("TP_SHADOWSHLIGHTS_HLTONALW"), 10, 100, 1, 70))),
@ -723,6 +724,7 @@ Locallab::Locallab():
laplacexp->setAdjusterListener(this);
balanexp->setAdjusterListener(this);
linear->setAdjusterListener(this);
gamm->setAdjusterListener(this);
curveEditorG->setCurveListener(this);
@ -810,6 +812,7 @@ Locallab::Locallab():
pdeBox->pack_start(*laplacexp);
pdeBox->pack_start(*linear);
pdeBox->pack_start(*balanexp);
pdeBox->pack_start(*gamm);
pdeFrame->add(*pdeBox);
@ -2815,6 +2818,7 @@ void Locallab::write(ProcParams* pp, ParamsEdited* pedited)
pp->locallab.spots.at(pp->locallab.selspot).laplacexp = laplacexp->getValue();
pp->locallab.spots.at(pp->locallab.selspot).balanexp = balanexp->getValue();
pp->locallab.spots.at(pp->locallab.selspot).linear = linear->getValue();
pp->locallab.spots.at(pp->locallab.selspot).gamm = gamm->getValue();
// Shadow highlight
pp->locallab.spots.at(pp->locallab.selspot).expshadhigh = expshadhigh->getEnabled();
@ -3117,6 +3121,7 @@ void Locallab::write(ProcParams* pp, ParamsEdited* pedited)
pe->locallab.spots.at(pp->locallab.selspot).laplacexp = pe->locallab.spots.at(pp->locallab.selspot).laplacexp || laplacexp->getEditedState();
pe->locallab.spots.at(pp->locallab.selspot).balanexp = pe->locallab.spots.at(pp->locallab.selspot).balanexp || balanexp->getEditedState();
pe->locallab.spots.at(pp->locallab.selspot).linear = pe->locallab.spots.at(pp->locallab.selspot).linear || linear->getEditedState();
pe->locallab.spots.at(pp->locallab.selspot).gamm = pe->locallab.spots.at(pp->locallab.selspot).gamm || gamm->getEditedState();
// Shadow highlight
pe->locallab.spots.at(pp->locallab.selspot).expshadhigh = pe->locallab.spots.at(pp->locallab.selspot).expshadhigh || !expshadhigh->get_inconsistent();
pe->locallab.spots.at(pp->locallab.selspot).highlights = pe->locallab.spots.at(pp->locallab.selspot).highlights || highlights->getEditedState();
@ -3376,6 +3381,7 @@ void Locallab::write(ProcParams* pp, ParamsEdited* pedited)
pedited->locallab.spots.at(pp->locallab.selspot).laplacexp = pedited->locallab.spots.at(pp->locallab.selspot).laplacexp || laplacexp->getEditedState();
pedited->locallab.spots.at(pp->locallab.selspot).balanexp = pedited->locallab.spots.at(pp->locallab.selspot).balanexp || balanexp->getEditedState();
pedited->locallab.spots.at(pp->locallab.selspot).linear = pedited->locallab.spots.at(pp->locallab.selspot).linear || linear->getEditedState();
pedited->locallab.spots.at(pp->locallab.selspot).gamm = pedited->locallab.spots.at(pp->locallab.selspot).gamm || gamm->getEditedState();
// Shadow highlight
pedited->locallab.spots.at(pp->locallab.selspot).expshadhigh = pedited->locallab.spots.at(pp->locallab.selspot).expshadhigh || !expshadhigh->get_inconsistent();
pedited->locallab.spots.at(pp->locallab.selspot).highlights = pedited->locallab.spots.at(pp->locallab.selspot).highlights || highlights->getEditedState();
@ -4116,11 +4122,13 @@ void Locallab::expMethodChanged()
laplacexp->set_sensitive(false);
balanexp->set_sensitive(false);
linear->set_sensitive(false);
gamm->set_sensitive(false);
} else if (expMethod->get_active_row_number() == 1) {
laplacexp->set_sensitive(true);
balanexp->set_sensitive(true);
linear->set_sensitive(true);
pdeFrame->set_sensitive(true);
gamm->set_sensitive(true);
}
enableListener();
@ -5067,6 +5075,7 @@ void Locallab::setDefaults(const ProcParams * defParams, const ParamsEdited * pe
laplacexp->setDefault(defSpot->laplacexp);
balanexp->setDefault(defSpot->balanexp);
linear->setDefault(defSpot->linear);
gamm->setDefault(defSpot->gamm);
// Shadow highlight
highlights->setDefault((double)defSpot->highlights);
h_tonalwidth->setDefault((double)defSpot->h_tonalwidth);
@ -5224,6 +5233,7 @@ void Locallab::setDefaults(const ProcParams * defParams, const ParamsEdited * pe
laplacexp->setDefaultEditedState(Irrelevant);
balanexp->setDefaultEditedState(Irrelevant);
linear->setDefaultEditedState(Irrelevant);
gamm->setDefaultEditedState(Irrelevant);
// Shadow highlight
highlights->setDefaultEditedState(Irrelevant);
h_tonalwidth->setDefaultEditedState(Irrelevant);
@ -5385,6 +5395,7 @@ void Locallab::setDefaults(const ProcParams * defParams, const ParamsEdited * pe
laplacexp->setDefaultEditedState(defSpotState->laplacexp ? Edited : UnEdited);
balanexp->setDefaultEditedState(defSpotState->balanexp ? Edited : UnEdited);
linear->setDefaultEditedState(defSpotState->linear ? Edited : UnEdited);
gamm->setDefaultEditedState(defSpotState->gamm ? Edited : UnEdited);
// Shadow highlight
highlights->setDefaultEditedState(defSpotState->highlights ? Edited : UnEdited);
h_tonalwidth->setDefaultEditedState(defSpotState->h_tonalwidth ? Edited : UnEdited);
@ -5768,6 +5779,12 @@ void Locallab::adjusterChanged(Adjuster * a, double newval)
}
}
if (a == gamm) {
if (listener) {
listener->panelChanged(Evlocallabgamm, gamm->getTextValue());
}
}
}
if (getEnabled() && expshadhigh->getEnabled()) {
@ -6511,6 +6528,7 @@ void Locallab::setBatchMode(bool batchMode)
laplacexp->showEditedCB();
balanexp->showEditedCB();
linear->showEditedCB();
gamm->showEditedCB();
//Shadow Highlight
highlights->showEditedCB();
h_tonalwidth->showEditedCB();

View File

@ -159,6 +159,7 @@ private:
Adjuster* const laplacexp;
Adjuster* const balanexp;
Adjuster* const linear;
Adjuster* const gamm;
//Shadow highlight
Adjuster* const highlights;
Adjuster* const h_tonalwidth;

View File

@ -1014,6 +1014,7 @@ void ParamsEdited::initFrom(const std::vector<rtengine::procparams::ProcParams>&
locallab.spots.at(j).laplacexp = locallab.spots.at(j).laplacexp && pSpot.laplacexp == otherSpot.laplacexp;
locallab.spots.at(j).balanexp = locallab.spots.at(j).balanexp && pSpot.balanexp == otherSpot.balanexp;
locallab.spots.at(j).linear = locallab.spots.at(j).linear && pSpot.linear == otherSpot.linear;
locallab.spots.at(j).gamm = locallab.spots.at(j).gamm && pSpot.gamm == otherSpot.gamm;
// Shadow highlight
locallab.spots.at(j).expshadhigh = locallab.spots.at(j).expshadhigh && pSpot.expshadhigh == otherSpot.expshadhigh;
locallab.spots.at(j).highlights = locallab.spots.at(j).highlights && pSpot.highlights == otherSpot.highlights;
@ -2931,6 +2932,10 @@ void ParamsEdited::combine(rtengine::procparams::ProcParams& toEdit, const rteng
toEdit.locallab.spots.at(i).linear = mods.locallab.spots.at(i).linear;
}
if (locallab.spots.at(i).gamm) {
toEdit.locallab.spots.at(i).gamm = mods.locallab.spots.at(i).gamm;
}
// Shadow highlight
if (locallab.spots.at(i).expshadhigh) {
toEdit.locallab.spots.at(i).expshadhigh = mods.locallab.spots.at(i).expshadhigh;
@ -4606,6 +4611,7 @@ LocallabParamsEdited::LocallabSpotEdited::LocallabSpotEdited(bool v) :
laplacexp(v),
balanexp(v),
linear(v),
gamm(v),
// Shadow highlight
expshadhigh(v),
highlights(v),
@ -4858,6 +4864,7 @@ void LocallabParamsEdited::LocallabSpotEdited::set(bool v)
laplacexp = v;
balanexp = v;
linear = v;
gamm = v;
// Shadow highlight
expshadhigh = v;
highlights = v;

View File

@ -437,6 +437,7 @@ public:
bool laplacexp;
bool balanexp;
bool linear;
bool gamm;
// Shadow highlight
bool expshadhigh;
bool highlights;