Improve Retinex with Normalize luminance
This commit is contained in:
parent
c0a4e4c11b
commit
3a2d0c4dc6
@ -937,8 +937,9 @@ HISTORY_MSG_690;Local - Retinex scale
|
||||
HISTORY_MSG_691;Local - Retinex darkness
|
||||
HISTORY_MSG_692;Local - Retinex lightness
|
||||
HISTORY_MSG_693;Local - Retinex threshold
|
||||
HISTORY_MSG_694;Local - Retinex Laplcian threshold
|
||||
HISTORY_MSG_694;Local - Retinex Laplacian threshold
|
||||
HISTORY_MSG_695;Local - Soft method
|
||||
HISTORY_MSG_696;Local - Retinex Normalize
|
||||
HISTORY_MSG_CLAMPOOG;Clip out-of-gamut colors
|
||||
HISTORY_MSG_COLORTONING_LABGRID_VALUE;CT - Color correction
|
||||
HISTORY_MSG_COLORTONING_LABREGION_AB;CT - Color correction
|
||||
@ -2032,6 +2033,7 @@ TP_LOCALLAB_GRIDTWO;Direct
|
||||
TP_LOCALLAB_LUM;Curves LC
|
||||
TP_LOCALLAB_LAPLACE;Laplacian threshold deltaE
|
||||
TP_LOCALLAB_HLH;Curves H
|
||||
TP_LOCALLAB_EQUIL;Normalize Luminance
|
||||
TP_LOCALLAB_CHROMACBDL;Chroma
|
||||
TP_LOCALLAB_CHROMACB_TOOLTIP;Acts as an amplifier-reducer action compare to sliders of luminance.\nUnder 100 reduce, above 100 amplifie
|
||||
TP_LOCALLAB_CURVEEDITOR_TONES_TOOLTIP;L=f(L), can be used with L(H) in Color and Light
|
||||
|
@ -235,6 +235,7 @@ struct local_params {
|
||||
bool curvact;
|
||||
bool invrad;
|
||||
bool invret;
|
||||
bool equret;
|
||||
bool invshar;
|
||||
bool actsp;
|
||||
float str;
|
||||
@ -580,6 +581,7 @@ static void calcLocalParams(int sp, int oW, int oH, const LocallabParams& locall
|
||||
bool inverseex = locallab.spots.at(sp).inversex;
|
||||
bool inversesh = locallab.spots.at(sp).inverssh;
|
||||
|
||||
bool equilret = locallab.spots.at(sp).equilret;
|
||||
bool inverserad = false; // Provision
|
||||
bool inverseret = locallab.spots.at(sp).inversret;
|
||||
bool inversesha = locallab.spots.at(sp).inverssha;
|
||||
@ -684,6 +686,7 @@ static void calcLocalParams(int sp, int oW, int oH, const LocallabParams& locall
|
||||
lp.curvact = curvacti;
|
||||
lp.invrad = inverserad;
|
||||
lp.invret = inverseret;
|
||||
lp.equret = equilret;
|
||||
lp.invshar = inversesha;
|
||||
lp.str = str;
|
||||
lp.shrad = sharradius;
|
||||
@ -6406,6 +6409,30 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o
|
||||
tmpl->L[ir][jr] = orig[ir][jr];
|
||||
}
|
||||
|
||||
if(lp.equret) {//equilibrate luminance before / after MSR
|
||||
float *datain = new float[Hd * Wd];
|
||||
float *data = new float[Hd * Wd];
|
||||
#ifdef _OPENMP
|
||||
#pragma omp parallel for
|
||||
#endif
|
||||
for (int ir = 0; ir < Hd; ir += 1)
|
||||
for (int jr = 0; jr < Wd; jr += 1) {
|
||||
datain[ir * Wd + jr] = orig1[ir][jr];
|
||||
data[ir * Wd + jr] = orig[ir][jr];
|
||||
}
|
||||
|
||||
normalize_mean_dt(data, datain, Hd * Wd);
|
||||
#ifdef _OPENMP
|
||||
#pragma omp parallel for
|
||||
#endif
|
||||
for (int ir = 0; ir < Hd; ir += 1)
|
||||
for (int jr = 0; jr < Wd; jr += 1) {
|
||||
tmpl->L[ir][jr] = data[ir * Wd + jr];
|
||||
}
|
||||
delete [] datain;
|
||||
delete [] data;
|
||||
}
|
||||
|
||||
if (!lp.invret) {
|
||||
float minL = tmpl->L[0][0] - bufreti->L[0][0];
|
||||
float maxL = minL;
|
||||
|
@ -722,6 +722,7 @@ enum ProcEventCode {
|
||||
Evlocallablimd = 692,
|
||||
Evlocallablaplace = 693,
|
||||
EvlocallabsoftMethod = 694,
|
||||
Evlocallabequilret = 695,
|
||||
NUMOFEVENTS
|
||||
};
|
||||
|
||||
|
@ -2479,6 +2479,7 @@ LocallabParams::LocallabSpot::LocallabSpot() :
|
||||
sensih(30),
|
||||
localTgaincurve{(double)FCT_MinMaxCPoints, 0.0, 0.12, 0.35, 0.35, 0.70, 0.50, 0.35, 0.35, 1.00, 0.12, 0.35, 0.35},
|
||||
inversret(false),
|
||||
equilret(true),
|
||||
softradiusret(0.0),
|
||||
CCmaskreticurve{(double)FCT_MinMaxCPoints, 0.0, 1.0, 0.35, 0.35, 0.50, 1.0, 0.35, 0.35, 1.0, 1.0, 0.35, 0.35 },
|
||||
LLmaskreticurve{(double)FCT_MinMaxCPoints, 0.0, 1.0, 0.35, 0.35, 0.50, 1.0, 0.35, 0.35, 1.0, 1.0, 0.35, 0.35},
|
||||
@ -2694,6 +2695,7 @@ bool LocallabParams::LocallabSpot::operator ==(const LocallabSpot& other) const
|
||||
&& sensih == other.sensih
|
||||
&& localTgaincurve == other.localTgaincurve
|
||||
&& inversret == other.inversret
|
||||
&& equilret == other.equilret
|
||||
&& softradiusret == other.softradiusret
|
||||
&& CCmaskreticurve == other.CCmaskreticurve
|
||||
&& LLmaskreticurve == other.LLmaskreticurve
|
||||
@ -3868,6 +3870,7 @@ int ProcParams::save(const Glib::ustring& fname, const Glib::ustring& fname2, bo
|
||||
saveToKeyfile(!pedited || pedited->locallab.spots.at(i).sensih, "Locallab", "Sensih_" + std::to_string(i), spot.sensih, keyFile);
|
||||
saveToKeyfile(!pedited || pedited->locallab.spots.at(i).localTgaincurve, "Locallab", "TgainCurve_" + std::to_string(i), spot.localTgaincurve, keyFile);
|
||||
saveToKeyfile(!pedited || pedited->locallab.spots.at(i).inversret, "Locallab", "Inversret_" + std::to_string(i), spot.inversret, keyFile);
|
||||
saveToKeyfile(!pedited || pedited->locallab.spots.at(i).equilret, "Locallab", "Equilret_" + std::to_string(i), spot.equilret, keyFile);
|
||||
saveToKeyfile(!pedited || pedited->locallab.spots.at(i).softradiusret, "Locallab", "Softradiusret_" + std::to_string(i), spot.softradiusret, keyFile);
|
||||
saveToKeyfile(!pedited || pedited->locallab.spots.at(i).enaretiMask, "Locallab", "EnaretiMask_" + std::to_string(i), spot.enaretiMask, keyFile);
|
||||
saveToKeyfile(!pedited || pedited->locallab.spots.at(i).enaretiMasktmap, "Locallab", "EnaretiMasktmap_" + std::to_string(i), spot.enaretiMasktmap, keyFile);
|
||||
@ -5177,6 +5180,7 @@ int ProcParams::load(const Glib::ustring& fname, ParamsEdited* pedited)
|
||||
assignFromKeyfile(keyFile, "Locallab", "Sensih_" + std::to_string(i), pedited, spot.sensih, spotEdited.sensih);
|
||||
assignFromKeyfile(keyFile, "Locallab", "TgainCurve_" + std::to_string(i), pedited, spot.localTgaincurve, spotEdited.localTgaincurve);
|
||||
assignFromKeyfile(keyFile, "Locallab", "Inversret_" + std::to_string(i), pedited, spot.inversret, spotEdited.inversret);
|
||||
assignFromKeyfile(keyFile, "Locallab", "Equilret_" + std::to_string(i), pedited, spot.equilret, spotEdited.equilret);
|
||||
assignFromKeyfile(keyFile, "Locallab", "Softradiusret_" + std::to_string(i), pedited, spot.softradiusret, spotEdited.softradiusret);
|
||||
assignFromKeyfile(keyFile, "Locallab", "CCmaskretiCurve_" + std::to_string(i), pedited, spot.CCmaskreticurve, spotEdited.CCmaskreticurve);
|
||||
assignFromKeyfile(keyFile, "Locallab", "LLmaskretiCurve_" + std::to_string(i), pedited, spot.LLmaskreticurve, spotEdited.LLmaskreticurve);
|
||||
|
@ -1080,6 +1080,7 @@ struct LocallabParams {
|
||||
int sensih;
|
||||
std::vector<double> localTgaincurve;
|
||||
bool inversret;
|
||||
bool equilret;
|
||||
double softradiusret;
|
||||
std::vector<double> CCmaskreticurve;
|
||||
std::vector<double> LLmaskreticurve;
|
||||
|
@ -720,8 +720,9 @@ int refreshmap[rtengine::NUMOFEVENTS] = {
|
||||
LUMINANCECURVE, //Evlocallabdarkness
|
||||
LUMINANCECURVE, //Evlocallablightnessreti
|
||||
LUMINANCECURVE, //Evlocallablimd
|
||||
LUMINANCECURVE, //Evlocallablaplace
|
||||
LUMINANCECURVE //EvlocallabsoftMethod
|
||||
LUMINANCECURVE, //Evlocallablaplace
|
||||
LUMINANCECURVE, //EvlocallabsoftMethod
|
||||
LUMINANCECURVE // Evlocallabequilret
|
||||
};
|
||||
|
||||
|
||||
|
@ -153,7 +153,7 @@ Locallab::Locallab():
|
||||
str(Gtk::manage(new Adjuster(M("TP_LOCALLAB_STR"), 0., 100., 0.1, 0.0))),
|
||||
chrrt(Gtk::manage(new Adjuster(M("TP_LOCALLAB_CHRRT"), 0.0, 100.0, 0.1, 0.0))),
|
||||
neigh(Gtk::manage(new Adjuster(M("TP_LOCALLAB_NEIGH"), 4., 500., 0.5, 50.))),
|
||||
vart(Gtk::manage(new Adjuster(M("TP_LOCALLAB_VART"), 10.0, 500., 0.1, 70.))),
|
||||
vart(Gtk::manage(new Adjuster(M("TP_LOCALLAB_VART"), 4.0, 500., 0.1, 70.))),
|
||||
dehaz(Gtk::manage(new Adjuster(M("TP_LOCALLAB_DEHAZ"), 0, 100, 1, 0))),
|
||||
sensih(Gtk::manage(new Adjuster(M("TP_LOCALLAB_SENSIH"), 0, 100, 1, 30))),
|
||||
softradiusret(Gtk::manage(new Adjuster(M("TP_LOCALLAB_GUIDFILTER"), 0.0, 100.0, 0.1, 0.))),
|
||||
@ -225,6 +225,7 @@ Locallab::Locallab():
|
||||
// Blur & Noise
|
||||
activlum(Gtk::manage(new Gtk::CheckButton(M("TP_LOCALLAB_ACTIV")))),
|
||||
// Retinex
|
||||
equilret(Gtk::manage(new Gtk::CheckButton(M("TP_LOCALLAB_EQUIL")))),
|
||||
inversret(Gtk::manage(new Gtk::CheckButton(M("TP_LOCALLAB_INVERS")))),
|
||||
enaretiMask(Gtk::manage(new Gtk::CheckButton(M("TP_LOCALLAB_ENABLE_MASK")))),
|
||||
enaretiMasktmap(Gtk::manage(new Gtk::CheckButton(M("TP_LOCALLAB_TM_MASK")))),
|
||||
@ -880,6 +881,7 @@ Locallab::Locallab():
|
||||
LocalcurveEditorgainT->curveListComplete();
|
||||
|
||||
inversretConn = inversret->signal_toggled().connect(sigc::mem_fun(*this, &Locallab::inversretChanged));
|
||||
equilretConn = equilret->signal_toggled().connect(sigc::mem_fun(*this, &Locallab::equilretChanged));
|
||||
|
||||
maskretiCurveEditorG->setCurveListener(this);
|
||||
|
||||
@ -943,6 +945,7 @@ Locallab::Locallab():
|
||||
|
||||
ToolParamBlock* const retiBox = Gtk::manage(new ToolParamBlock());
|
||||
retiBox->pack_start(*retinexMethod);
|
||||
retiBox->pack_start(*equilret);
|
||||
retiBox->pack_start(*str);
|
||||
retiBox->pack_start(*chrrt);
|
||||
retiBox->pack_start(*neigh);
|
||||
@ -2159,6 +2162,7 @@ void Locallab::write(ProcParams* pp, ParamsEdited* pedited)
|
||||
pp->locallab.spots.at(pp->locallab.selspot).localTgaincurve = cTgainshape->getCurve();
|
||||
pp->locallab.spots.at(pp->locallab.selspot).inversret = inversret->get_active();
|
||||
pp->locallab.spots.at(pp->locallab.selspot).softradiusret = softradiusret->getValue();
|
||||
pp->locallab.spots.at(pp->locallab.selspot).equilret = equilret->get_active();
|
||||
|
||||
pp->locallab.spots.at(pp->locallab.selspot).LLmaskreticurve = LLmaskretishape->getCurve();
|
||||
pp->locallab.spots.at(pp->locallab.selspot).CCmaskreticurve = CCmaskretishape->getCurve();
|
||||
@ -2376,6 +2380,7 @@ void Locallab::write(ProcParams* pp, ParamsEdited* pedited)
|
||||
pe->locallab.spots.at(pp->locallab.selspot).sensih = pe->locallab.spots.at(pp->locallab.selspot).sensih || sensih->getEditedState();
|
||||
pe->locallab.spots.at(pp->locallab.selspot).localTgaincurve = pe->locallab.spots.at(pp->locallab.selspot).localTgaincurve || !cTgainshape->isUnChanged();
|
||||
pe->locallab.spots.at(pp->locallab.selspot).inversret = pe->locallab.spots.at(pp->locallab.selspot).inversret || !inversret->get_inconsistent();
|
||||
pe->locallab.spots.at(pp->locallab.selspot).equilret = pe->locallab.spots.at(pp->locallab.selspot).equilret || !equilret->get_inconsistent();
|
||||
pe->locallab.spots.at(pp->locallab.selspot).softradiusret = pe->locallab.spots.at(pp->locallab.selspot).softradiusret || softradiusret->getEditedState();
|
||||
pe->locallab.spots.at(pp->locallab.selspot).CCmaskreticurve = pe->locallab.spots.at(pp->locallab.selspot).CCmaskreticurve || !CCmaskretishape->isUnChanged();
|
||||
pe->locallab.spots.at(pp->locallab.selspot).LLmaskreticurve = pe->locallab.spots.at(pp->locallab.selspot).LLmaskreticurve || !LLmaskretishape->isUnChanged();
|
||||
@ -2597,6 +2602,7 @@ void Locallab::write(ProcParams* pp, ParamsEdited* pedited)
|
||||
pedited->locallab.spots.at(pp->locallab.selspot).sensih = pedited->locallab.spots.at(pp->locallab.selspot).sensih || sensih->getEditedState();
|
||||
pedited->locallab.spots.at(pp->locallab.selspot).localTgaincurve = pedited->locallab.spots.at(pp->locallab.selspot).localTgaincurve || !cTgainshape->isUnChanged();
|
||||
pedited->locallab.spots.at(pp->locallab.selspot).inversret = pedited->locallab.spots.at(pp->locallab.selspot).inversret || !inversret->get_inconsistent();
|
||||
pedited->locallab.spots.at(pp->locallab.selspot).equilret = pedited->locallab.spots.at(pp->locallab.selspot).equilret || !equilret->get_inconsistent();
|
||||
pedited->locallab.spots.at(pp->locallab.selspot).softradiusret = pedited->locallab.spots.at(pp->locallab.selspot).softradiusret || softradiusret->getEditedState();
|
||||
pedited->locallab.spots.at(pp->locallab.selspot).CCmaskreticurve = pedited->locallab.spots.at(pp->locallab.selspot).CCmaskreticurve || !CCmaskretishape->isUnChanged();
|
||||
pedited->locallab.spots.at(pp->locallab.selspot).LLmaskreticurve = pedited->locallab.spots.at(pp->locallab.selspot).LLmaskreticurve || !LLmaskretishape->isUnChanged();
|
||||
@ -3491,6 +3497,33 @@ void Locallab::inversshaChanged()
|
||||
}
|
||||
}
|
||||
|
||||
void Locallab::equilretChanged()
|
||||
{
|
||||
// printf("inversretChanged\n");
|
||||
|
||||
if (multiImage) {
|
||||
if (equilret->get_inconsistent()) {
|
||||
equilret->set_inconsistent(false);
|
||||
equilretConn.block(true);
|
||||
equilret->set_active(false);
|
||||
equilretConn.block(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (getEnabled() && expreti->getEnabled()) {
|
||||
if (listener) {
|
||||
if (inversret->get_active()) {
|
||||
listener->panelChanged(Evlocallabequilret, M("GENERAL_ENABLED"));
|
||||
} else {
|
||||
listener->panelChanged(Evlocallabequilret, M("GENERAL_DISABLED"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Locallab::inversretChanged()
|
||||
{
|
||||
// printf("inversretChanged\n");
|
||||
@ -5138,6 +5171,7 @@ void Locallab::enableListener()
|
||||
enableretiConn.block(false);
|
||||
retinexMethodConn.block(false);
|
||||
inversretConn.block(false);
|
||||
equilretConn.block(false);
|
||||
enaretiMaskConn.block(false);
|
||||
enaretiMasktmapConn.block(false);
|
||||
showmaskretiMethodConn.block(false);
|
||||
@ -5195,6 +5229,7 @@ void Locallab::disableListener()
|
||||
enableretiConn.block(true);
|
||||
retinexMethodConn.block(true);
|
||||
inversretConn.block(true);
|
||||
equilretConn.block(true);
|
||||
enaretiMaskConn.block(true);
|
||||
enaretiMasktmapConn.block(true);
|
||||
showmaskretiMethodConn.block(true);
|
||||
@ -5380,6 +5415,7 @@ void Locallab::updateLocallabGUI(const rtengine::procparams::ProcParams* pp, con
|
||||
sensih->setValue(pp->locallab.spots.at(index).sensih);
|
||||
cTgainshape->setCurve(pp->locallab.spots.at(index).localTgaincurve);
|
||||
inversret->set_active(pp->locallab.spots.at(index).inversret);
|
||||
equilret->set_active(pp->locallab.spots.at(index).equilret);
|
||||
softradiusret->setValue(pp->locallab.spots.at(index).softradiusret);
|
||||
CCmaskretishape->setCurve(pp->locallab.spots.at(index).CCmaskreticurve);
|
||||
LLmaskretishape->setCurve(pp->locallab.spots.at(index).LLmaskreticurve);
|
||||
@ -5633,6 +5669,7 @@ void Locallab::updateLocallabGUI(const rtengine::procparams::ProcParams* pp, con
|
||||
sensih->setEditedState(spotState->sensih ? Edited : UnEdited);
|
||||
cTgainshape->setUnChanged(!spotState->localTgaincurve);
|
||||
inversret->set_inconsistent(multiImage && !spotState->inversret);
|
||||
equilret->set_inconsistent(multiImage && !spotState->equilret);
|
||||
softradiusret->setEditedState(spotState->softradiusret ? Edited : UnEdited);
|
||||
CCmaskretishape->setUnChanged(!spotState->CCmaskreticurve);
|
||||
LLmaskretishape->setUnChanged(!spotState->LLmaskreticurve);
|
||||
|
@ -261,6 +261,8 @@ private:
|
||||
Gtk::CheckButton* const activlum;
|
||||
sigc::connection activlumConn;
|
||||
// Retinex
|
||||
Gtk::CheckButton* const equilret;
|
||||
sigc::connection equilretConn;
|
||||
Gtk::CheckButton* const inversret;
|
||||
sigc::connection inversretConn;
|
||||
Gtk::CheckButton* const enaretiMask;
|
||||
@ -354,6 +356,7 @@ private:
|
||||
// Blur & Noise
|
||||
void activlumChanged();
|
||||
// Retinex
|
||||
void equilretChanged();
|
||||
void inversretChanged();
|
||||
void enaretiMaskChanged();
|
||||
void enaretiMasktmapChanged();
|
||||
|
@ -1069,6 +1069,7 @@ void ParamsEdited::initFrom(const std::vector<rtengine::procparams::ProcParams>&
|
||||
locallab.spots.at(j).sensih = locallab.spots.at(j).sensih && pSpot.sensih == otherSpot.sensih;
|
||||
locallab.spots.at(j).localTgaincurve = locallab.spots.at(j).localTgaincurve && pSpot.localTgaincurve == otherSpot.localTgaincurve;
|
||||
locallab.spots.at(j).inversret = locallab.spots.at(j).inversret && pSpot.inversret == otherSpot.inversret;
|
||||
locallab.spots.at(j).equilret = locallab.spots.at(j).equilret && pSpot.equilret == otherSpot.equilret;
|
||||
locallab.spots.at(j).softradiusret = locallab.spots.at(j).softradiusret && pSpot.softradiusret == otherSpot.softradiusret;
|
||||
locallab.spots.at(j).CCmaskreticurve = locallab.spots.at(j).CCmaskreticurve && pSpot.CCmaskreticurve == otherSpot.CCmaskreticurve;
|
||||
locallab.spots.at(j).LLmaskreticurve = locallab.spots.at(j).LLmaskreticurve && pSpot.LLmaskreticurve == otherSpot.LLmaskreticurve;
|
||||
@ -3108,6 +3109,10 @@ void ParamsEdited::combine(rtengine::procparams::ProcParams& toEdit, const rteng
|
||||
toEdit.locallab.spots.at(i).inversret = mods.locallab.spots.at(i).inversret;
|
||||
}
|
||||
|
||||
if (locallab.spots.at(i).equilret) {
|
||||
toEdit.locallab.spots.at(i).equilret = mods.locallab.spots.at(i).equilret;
|
||||
}
|
||||
|
||||
if (locallab.spots.at(i).CCmaskreticurve) {
|
||||
toEdit.locallab.spots.at(i).CCmaskreticurve = mods.locallab.spots.at(i).CCmaskreticurve;
|
||||
}
|
||||
@ -4437,6 +4442,7 @@ LocallabParamsEdited::LocallabSpotEdited::LocallabSpotEdited(bool v) :
|
||||
sensih(v),
|
||||
localTgaincurve(v),
|
||||
inversret(v),
|
||||
equilret(v),
|
||||
softradiusret(v),
|
||||
CCmaskreticurve(v),
|
||||
LLmaskreticurve(v),
|
||||
@ -4649,6 +4655,7 @@ void LocallabParamsEdited::LocallabSpotEdited::set(bool v)
|
||||
sensih = v;
|
||||
localTgaincurve = v;
|
||||
inversret = v;
|
||||
equilret = v;
|
||||
softradiusret = v;
|
||||
CCmaskreticurve = v;
|
||||
LLmaskreticurve = v;
|
||||
|
@ -496,6 +496,7 @@ public:
|
||||
bool sensih;
|
||||
bool localTgaincurve;
|
||||
bool inversret;
|
||||
bool equilret;
|
||||
bool softradiusret;
|
||||
bool CCmaskreticurve;
|
||||
bool LLmaskreticurve;
|
||||
|
Loading…
x
Reference in New Issue
Block a user