From 9d0d608189dfce88b5de5e98fb394b81b77090cc Mon Sep 17 00:00:00 2001 From: Desmis Date: Fri, 12 Jul 2019 17:34:45 +0200 Subject: [PATCH] Improve exposure with shadows --- rtdata/languages/default | 3 +++ rtengine/iplocallab.cc | 9 ++++++- rtengine/ipshadowshighlights.cc | 2 +- rtengine/procevents.h | 1 + rtengine/procparams.cc | 6 ++++- rtengine/procparams.h | 2 ++ rtengine/refreshmap.cc | 3 ++- rtgui/locallab.cc | 42 +++++++++++++++++++++++++++++++-- rtgui/locallab.h | 1 + rtgui/paramsedited.cc | 7 ++++++ rtgui/paramsedited.h | 1 + 11 files changed, 71 insertions(+), 6 deletions(-) diff --git a/rtdata/languages/default b/rtdata/languages/default index 257b74b65..1fd52c232 100644 --- a/rtdata/languages/default +++ b/rtdata/languages/default @@ -943,6 +943,7 @@ HISTORY_MSG_696;Local - Retinex Normalize HISTORY_MSG_697;Local - TM Normalize HISTORY_MSG_698;Local - Local contrast Fast Fourier HISTORY_MSG_699;Local - Retinex Fast Fourier +HISTORY_MSG_701;Local - Exp Shadows HISTORY_MSG_CLAMPOOG;Clip out-of-gamut colors HISTORY_MSG_COLORTONING_LABGRID_VALUE;CT - Color correction HISTORY_MSG_COLORTONING_LABREGION_AB;CT - Color correction @@ -2105,6 +2106,8 @@ TP_LOCALLAB_RETI_FFTW_TOOLTIP;FFT improve quality and allow big radius.\nThe tre TP_LOCALLAB_TRANSMISSIONGAIN;Transmission gain TP_LOCALLAB_STREN;Compression Strength TP_LOCALLAB_STRGRID;Strength +TP_LOCALLAB_SHADEX;Shadows +TP_LOCALLAB_SHADEXCOMP;Shadows compresion and tonal width TP_LOCALLAB_SHOWLAPLACE;Laplacian (first) TP_LOCALLAB_SHOWFOURIER;Fourier (dct) TP_LOCALLAB_SHOWPOISSON;Poisson (pde) diff --git a/rtengine/iplocallab.cc b/rtengine/iplocallab.cc index 95737fbc3..0b51ad5bc 100644 --- a/rtengine/iplocallab.cc +++ b/rtengine/iplocallab.cc @@ -291,6 +291,7 @@ struct local_params { float satur; int blac; int shcomp; + int shadex; int hlcomp; int hlcompthr; double expcomp; @@ -756,6 +757,7 @@ static void calcLocalParams(int sp, int oW, int oH, const LocallabParams& locall lp.cut_past = cupas; lp.blac = locallab.spots.at(sp).black; lp.shcomp = locallab.spots.at(sp).shcompr; + lp.shadex = locallab.spots.at(sp).shadex; lp.hlcomp = locallab.spots.at(sp).hlcompr; lp.hlcompthr = locallab.spots.at(sp).hlcomprthresh; lp.expcomp = locallab.spots.at(sp).expcomp; @@ -6409,7 +6411,6 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o bufexpfin->b[y][x] = original->b[y + ystart][x + xstart]; } } - ImProcFunctions::shadowsHighlights(bufexpfin.get(), lp.hsena, 1, lp.highlihs, lp.shadowhs, lp.radiushs, sk, lp.hltonalhs, lp.shtonalhs); #ifdef _OPENMP @@ -7424,6 +7425,12 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o bufexpfin->b[y][x] = original->b[y + ystart][x + xstart]; } } + //shadows with ipshadowshighlight + if(lp.shadex > 0) { + ImProcFunctions::shadowsHighlights(bufexporig.get(), true, 1, 0, lp.shadex, 40, sk, 0, lp.shcomp); + } + + if (exlocalcurve && localexutili) {// L=f(L) curve enhanced #ifdef _OPENMP diff --git a/rtengine/ipshadowshighlights.cc b/rtengine/ipshadowshighlights.cc index 96b8e84ef..d45377290 100644 --- a/rtengine/ipshadowshighlights.cc +++ b/rtengine/ipshadowshighlights.cc @@ -33,7 +33,7 @@ void ImProcFunctions::shadowsHighlights(LabImage *lab, bool ena, int labmode, in if (!ena || (!hightli && !shado)){ return; } - +printf("shhashaaaa\n"); const int width = lab->W; const int height = lab->H; const bool lab_mode = labmode; diff --git a/rtengine/procevents.h b/rtengine/procevents.h index 174300d55..e96a14cf2 100644 --- a/rtengine/procevents.h +++ b/rtengine/procevents.h @@ -727,6 +727,7 @@ enum ProcEventCode { Evlocallabfftwlc = 697, Evlocallabfftwreti = 698, EvlocallabshowmasksoftMethod = 699, + Evlocallabshadex = 700, NUMOFEVENTS }; diff --git a/rtengine/procparams.cc b/rtengine/procparams.cc index 59bcf47cb..9b8bd27da 100644 --- a/rtengine/procparams.cc +++ b/rtengine/procparams.cc @@ -2397,6 +2397,7 @@ LocallabParams::LocallabSpot::LocallabSpot() : hlcompr(0), hlcomprthresh(0), black(0), + shadex(0), shcompr(50), expchroma(30), warm(0), @@ -2616,6 +2617,7 @@ bool LocallabParams::LocallabSpot::operator ==(const LocallabSpot& other) const && hlcompr == other.hlcompr && hlcomprthresh == other.hlcomprthresh && black == other.black + && shadex == other.shadex && shcompr == other.shcompr && expchroma == other.expchroma && warm == other.warm @@ -3792,8 +3794,9 @@ int ProcParams::save(const Glib::ustring& fname, const Glib::ustring& fname2, bo saveToKeyfile(!pedited || pedited->locallab.spots.at(i).hlcompr, "Locallab", "Hlcompr_" + std::to_string(i), spot.hlcompr, keyFile); saveToKeyfile(!pedited || pedited->locallab.spots.at(i).hlcomprthresh, "Locallab", "Hlcomprthresh_" + std::to_string(i), spot.hlcomprthresh, keyFile); saveToKeyfile(!pedited || pedited->locallab.spots.at(i).black, "Locallab", "Black_" + std::to_string(i), spot.black, keyFile); + saveToKeyfile(!pedited || pedited->locallab.spots.at(i).shadex, "Locallab", "Shadex_" + std::to_string(i), spot.shadex, keyFile); saveToKeyfile(!pedited || pedited->locallab.spots.at(i).shcompr, "Locallab", "Shcompr_" + std::to_string(i), spot.shcompr, keyFile); - saveToKeyfile(!pedited || pedited->locallab.spots.at(i).shcompr, "Locallab", "Expchroma_" + std::to_string(i), spot.expchroma, keyFile); + saveToKeyfile(!pedited || pedited->locallab.spots.at(i).expchroma, "Locallab", "Expchroma_" + std::to_string(i), spot.expchroma, keyFile); saveToKeyfile(!pedited || pedited->locallab.spots.at(i).warm, "Locallab", "Warm_" + std::to_string(i), spot.warm, keyFile); saveToKeyfile(!pedited || pedited->locallab.spots.at(i).sensiex, "Locallab", "Sensiex_" + std::to_string(i), spot.sensiex, keyFile); saveToKeyfile(!pedited || pedited->locallab.spots.at(i).structexp, "Locallab", "Structexp_" + std::to_string(i), spot.structexp, keyFile); @@ -5096,6 +5099,7 @@ int ProcParams::load(const Glib::ustring& fname, ParamsEdited* pedited) assignFromKeyfile(keyFile, "Locallab", "Hlcompr_" + std::to_string(i), pedited, spot.hlcompr, spotEdited.hlcompr); assignFromKeyfile(keyFile, "Locallab", "Hlcomprthresh_" + std::to_string(i), pedited, spot.hlcomprthresh, spotEdited.hlcomprthresh); assignFromKeyfile(keyFile, "Locallab", "Black_" + std::to_string(i), pedited, spot.black, spotEdited.black); + assignFromKeyfile(keyFile, "Locallab", "Shadex_" + std::to_string(i), pedited, spot.shadex, spotEdited.shadex); assignFromKeyfile(keyFile, "Locallab", "Shcompr_" + std::to_string(i), pedited, spot.shcompr, spotEdited.shcompr); assignFromKeyfile(keyFile, "Locallab", "Expchroma_" + std::to_string(i), pedited, spot.expchroma, spotEdited.expchroma); assignFromKeyfile(keyFile, "Locallab", "Warm_" + std::to_string(i), pedited, spot.warm, spotEdited.warm); diff --git a/rtengine/procparams.h b/rtengine/procparams.h index 22d19df0f..6f1110c6a 100644 --- a/rtengine/procparams.h +++ b/rtengine/procparams.h @@ -998,6 +998,8 @@ struct LocallabParams { int hlcompr; int hlcomprthresh; int black; + + int shadex; int shcompr; int expchroma; int warm; diff --git a/rtengine/refreshmap.cc b/rtengine/refreshmap.cc index ae7d553c9..635a66590 100644 --- a/rtengine/refreshmap.cc +++ b/rtengine/refreshmap.cc @@ -726,7 +726,8 @@ int refreshmap[rtengine::NUMOFEVENTS] = { LUMINANCECURVE, // Evlocallabequiltm LUMINANCECURVE, // Evlocallabfftwlc LUMINANCECURVE, // Evlocallabfftwreti - LUMINANCECURVE //EvlocallabshowmasksoftMethod + LUMINANCECURVE, //EvlocallabshowmasksoftMethod + LUMINANCECURVE //Evlocallabshadex }; diff --git a/rtgui/locallab.cc b/rtgui/locallab.cc index d2cf6ee42..08117aedd 100644 --- a/rtgui/locallab.cc +++ b/rtgui/locallab.cc @@ -185,7 +185,8 @@ Locallab::Locallab(): 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))), - shcompr(Gtk::manage(new Adjuster(M("TP_EXPOSURE_COMPRSHADOWS"), 0, 100, 1, 50))), + 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))), warm(Gtk::manage(new Adjuster(M("TP_LOCALLAB_WARM"), -100., 100., 1., 0., Gtk::manage(new RTImage("circle-blue-small.png")), Gtk::manage(new RTImage("circle-orange-small.png"))))), sensiex(Gtk::manage(new Adjuster(M("TP_LOCALLAB_SENSI"), 0, 100, 1, 15))), @@ -572,6 +573,7 @@ Locallab::Locallab(): hlcomprthresh->setAdjusterListener(this); black->setAdjusterListener(this); + shadex->setAdjusterListener(this); shcompr->setAdjusterListener(this); expchroma->setAdjusterListener(this); @@ -648,6 +650,7 @@ Locallab::Locallab(): exposeBox->pack_start(*hlcompr); exposeBox->pack_start(*hlcomprthresh); exposeBox->pack_start(*black); + exposeBox->pack_start(*shadex); exposeBox->pack_start(*shcompr); exposeBox->pack_start(*expchroma); exposeBox->pack_start(*warm); @@ -2177,6 +2180,7 @@ void Locallab::write(ProcParams* pp, ParamsEdited* pedited) pp->locallab.spots.at(pp->locallab.selspot).hlcompr = hlcompr->getIntValue(); pp->locallab.spots.at(pp->locallab.selspot).hlcomprthresh = hlcomprthresh->getIntValue(); pp->locallab.spots.at(pp->locallab.selspot).black = black->getIntValue(); + pp->locallab.spots.at(pp->locallab.selspot).shadex = shadex->getIntValue(); pp->locallab.spots.at(pp->locallab.selspot).shcompr = shcompr->getIntValue(); pp->locallab.spots.at(pp->locallab.selspot).expchroma = expchroma->getIntValue(); pp->locallab.spots.at(pp->locallab.selspot).warm = warm->getIntValue(); @@ -2419,6 +2423,7 @@ void Locallab::write(ProcParams* pp, ParamsEdited* pedited) pe->locallab.spots.at(pp->locallab.selspot).hlcompr = pe->locallab.spots.at(pp->locallab.selspot).hlcompr || hlcompr->getEditedState(); pe->locallab.spots.at(pp->locallab.selspot).hlcomprthresh = pe->locallab.spots.at(pp->locallab.selspot).hlcomprthresh || hlcomprthresh->getEditedState(); pe->locallab.spots.at(pp->locallab.selspot).black = pe->locallab.spots.at(pp->locallab.selspot).black || black->getEditedState(); + pe->locallab.spots.at(pp->locallab.selspot).shadex = pe->locallab.spots.at(pp->locallab.selspot).shadex || shadex->getEditedState(); pe->locallab.spots.at(pp->locallab.selspot).shcompr = pe->locallab.spots.at(pp->locallab.selspot).shcompr || shcompr->getEditedState(); pe->locallab.spots.at(pp->locallab.selspot).expchroma = pe->locallab.spots.at(pp->locallab.selspot).expchroma || expchroma->getEditedState(); pe->locallab.spots.at(pp->locallab.selspot).warm = pe->locallab.spots.at(pp->locallab.selspot).warm || warm->getEditedState(); @@ -2642,6 +2647,7 @@ void Locallab::write(ProcParams* pp, ParamsEdited* pedited) pedited->locallab.spots.at(pp->locallab.selspot).hlcompr = pedited->locallab.spots.at(pp->locallab.selspot).hlcompr || hlcompr->getEditedState(); pedited->locallab.spots.at(pp->locallab.selspot).hlcomprthresh = pedited->locallab.spots.at(pp->locallab.selspot).hlcomprthresh || hlcomprthresh->getEditedState(); pedited->locallab.spots.at(pp->locallab.selspot).black = pedited->locallab.spots.at(pp->locallab.selspot).black || black->getEditedState(); + pedited->locallab.spots.at(pp->locallab.selspot).shadex = pedited->locallab.spots.at(pp->locallab.selspot).shadex || shadex->getEditedState(); pedited->locallab.spots.at(pp->locallab.selspot).shcompr = pedited->locallab.spots.at(pp->locallab.selspot).shcompr || shcompr->getEditedState(); pedited->locallab.spots.at(pp->locallab.selspot).expchroma = pedited->locallab.spots.at(pp->locallab.selspot).expchroma || expchroma->getEditedState(); pedited->locallab.spots.at(pp->locallab.selspot).warm = pedited->locallab.spots.at(pp->locallab.selspot).warm || warm->getEditedState(); @@ -3495,6 +3501,7 @@ void Locallab::inversexChanged() expmaskexp->show(); structexp->show(); blurexpde->show(); + shadex->show(); softradiusexp->show(); showmaskexpMethod->hide(); // Being able to change Color & Light mask visibility is useless in batch mode } else if (inversex->get_active()) { @@ -3502,6 +3509,7 @@ void Locallab::inversexChanged() curveEditorG->show(); expmaskexp->hide(); structexp->hide(); + shadex->hide(); blurexpde->show(); softradiusexp->hide(); @@ -3512,6 +3520,7 @@ void Locallab::inversexChanged() structexp->show(); blurexpde->show(); softradiusexp->show(); + shadex->show(); if (batchMode) { showmaskexpMethod->hide(); // Being able to change Color & Light mask visibility is useless in batch mode @@ -3883,6 +3892,7 @@ void Locallab::setDefaults(const ProcParams * defParams, const ParamsEdited * pe hlcompr->setDefault((double)defSpot->hlcompr); hlcomprthresh->setDefault((double)defSpot->hlcomprthresh); black->setDefault((double)defSpot->black); + shadex->setDefault((double)defSpot->shadex); shcompr->setDefault((double)defSpot->shcompr); expchroma->setDefault((double)defSpot->expchroma); warm->setDefault((double)defSpot->warm); @@ -4016,6 +4026,7 @@ void Locallab::setDefaults(const ProcParams * defParams, const ParamsEdited * pe hlcompr->setDefaultEditedState(Irrelevant); hlcomprthresh->setDefaultEditedState(Irrelevant); black->setDefaultEditedState(Irrelevant); + shadex->setDefaultEditedState(Irrelevant); shcompr->setDefaultEditedState(Irrelevant); expchroma->setDefaultEditedState(Irrelevant); warm->setDefaultEditedState(Irrelevant); @@ -4153,6 +4164,7 @@ void Locallab::setDefaults(const ProcParams * defParams, const ParamsEdited * pe hlcompr->setDefaultEditedState(defSpotState->hlcompr ? Edited : UnEdited); hlcomprthresh->setDefaultEditedState(defSpotState->hlcomprthresh ? Edited : UnEdited); black->setDefaultEditedState(defSpotState->black ? Edited : UnEdited); + shadex->setDefaultEditedState(defSpotState->shadex ? Edited : UnEdited); shcompr->setDefaultEditedState(defSpotState->shcompr ? Edited : UnEdited); expchroma->setDefaultEditedState(defSpotState->expchroma ? Edited : UnEdited); warm->setDefaultEditedState(defSpotState->warm ? Edited : UnEdited); @@ -4398,6 +4410,15 @@ void Locallab::adjusterChanged(Adjuster * a, double newval) } } + if (a == shadex) { + // Update Exposure GUI according to shadex adjuster state (to be compliant with updateSpecificGUIState function) + if (multiImage && shadex->getEditedState() != Edited) { + shcompr->set_sensitive(true); + } else { + shcompr->set_sensitive(!((int)shadex->getValue() == 0)); // At black = 0, shcompr value has no effect + } + } + if (getEnabled() && expexpose->getEnabled()) { if (a == expcomp) { if (listener) { @@ -4423,6 +4444,12 @@ void Locallab::adjusterChanged(Adjuster * a, double newval) } } + if (a == shadex) { + if (listener) { + listener->panelChanged(Evlocallabshadex, shadex->getTextValue()); + } + } + if (a == shcompr) { if (listener) { listener->panelChanged(Evlocallabshcompr, shcompr->getTextValue()); @@ -5103,6 +5130,7 @@ void Locallab::setBatchMode(bool batchMode) hlcompr->showEditedCB(); hlcomprthresh->showEditedCB(); black->showEditedCB(); + shadex->showEditedCB(); shcompr->showEditedCB(); expchroma->showEditedCB(); warm->showEditedCB(); @@ -5545,6 +5573,7 @@ void Locallab::updateLocallabGUI(const rtengine::procparams::ProcParams* pp, con hlcompr->setValue(pp->locallab.spots.at(index).hlcompr); hlcomprthresh->setValue(pp->locallab.spots.at(index).hlcomprthresh); black->setValue(pp->locallab.spots.at(index).black); + shadex->setValue(pp->locallab.spots.at(index).shadex); shcompr->setValue(pp->locallab.spots.at(index).shcompr); expchroma->setValue(pp->locallab.spots.at(index).expchroma); warm->setValue(pp->locallab.spots.at(index).warm); @@ -5811,6 +5840,7 @@ void Locallab::updateLocallabGUI(const rtengine::procparams::ProcParams* pp, con hlcompr->setEditedState(spotState->hlcompr ? Edited : UnEdited); hlcomprthresh->setEditedState(spotState->hlcomprthresh ? Edited : UnEdited); black->setEditedState(spotState->black ? Edited : UnEdited); + shadex->setEditedState(spotState->shadex ? Edited : UnEdited); warm->setEditedState(spotState->warm ? Edited : UnEdited); shcompr->setEditedState(spotState->shcompr ? Edited : UnEdited); expchroma->setEditedState(spotState->expchroma ? Edited : UnEdited); @@ -6038,14 +6068,16 @@ void Locallab::updateSpecificGUIState() if (multiImage && inversex->get_inconsistent()) { structexp->show(); softradiusexp->show(); + shadex->show(); showmaskexpMethod->hide(); // Being able to change Color & Light mask visibility is useless in batch mode } else if (inversex->get_active()) { structexp->hide(); softradiusexp->hide(); + shadex->hide(); } else { structexp->show(); softradiusexp->show(); - + shadex->show(); if (batchMode) { showmaskexpMethod->hide(); // Being able to change Color & Light mask visibility is useless in batch mode } @@ -6067,6 +6099,12 @@ void Locallab::updateSpecificGUIState() shcompr->set_sensitive(!((int)black->getValue() == 0)); // At black = 0, shcompr value has no effect } + if (multiImage && shadex->getEditedState() != Edited) { + shcompr->set_sensitive(true); + } else { + shcompr->set_sensitive(!((int)shadex->getValue() == 0)); // At black = 0, shcompr value has no effect + } + // Update Vibrance GUI according to pastsattog button state (to be compliant with pastsattog_toggled function) if (multiImage && pastSatTog->get_inconsistent()) { psThreshold->set_sensitive(true); diff --git a/rtgui/locallab.h b/rtgui/locallab.h index 97423d245..50baca6fd 100644 --- a/rtgui/locallab.h +++ b/rtgui/locallab.h @@ -127,6 +127,7 @@ private: Adjuster* const hlcompr; Adjuster* const hlcomprthresh; Adjuster* const black; + Adjuster* const shadex; Adjuster* const shcompr; Adjuster* const expchroma; Adjuster* const warm; diff --git a/rtgui/paramsedited.cc b/rtgui/paramsedited.cc index 87c59be02..7a6ebd83b 100644 --- a/rtgui/paramsedited.cc +++ b/rtgui/paramsedited.cc @@ -987,6 +987,7 @@ void ParamsEdited::initFrom(const std::vector& locallab.spots.at(j).hlcompr = locallab.spots.at(j).hlcompr && pSpot.hlcompr == otherSpot.hlcompr; locallab.spots.at(j).hlcomprthresh = locallab.spots.at(j).hlcomprthresh && pSpot.hlcomprthresh == otherSpot.hlcomprthresh; locallab.spots.at(j).black = locallab.spots.at(j).black && pSpot.black == otherSpot.black; + locallab.spots.at(j).shadex = locallab.spots.at(j).shadex && pSpot.shadex == otherSpot.shadex; locallab.spots.at(j).shcompr = locallab.spots.at(j).shcompr && pSpot.shcompr == otherSpot.shcompr; locallab.spots.at(j).expchroma = locallab.spots.at(j).expchroma && pSpot.expchroma == otherSpot.expchroma; locallab.spots.at(j).warm = locallab.spots.at(j).warm && pSpot.warm == otherSpot.warm; @@ -2802,6 +2803,10 @@ void ParamsEdited::combine(rtengine::procparams::ProcParams& toEdit, const rteng toEdit.locallab.spots.at(i).black = mods.locallab.spots.at(i).black; } + if (locallab.spots.at(i).shadex) { + toEdit.locallab.spots.at(i).shadex = mods.locallab.spots.at(i).shadex; + } + if (locallab.spots.at(i).expchroma) { toEdit.locallab.spots.at(i).expchroma = mods.locallab.spots.at(i).expchroma; } @@ -4375,6 +4380,7 @@ LocallabParamsEdited::LocallabSpotEdited::LocallabSpotEdited(bool v) : hlcompr(v), hlcomprthresh(v), black(v), + shadex(v), shcompr(v), expchroma(v), warm(v), @@ -4591,6 +4597,7 @@ void LocallabParamsEdited::LocallabSpotEdited::set(bool v) hlcompr = v; hlcomprthresh = v; black = v; + shadex = v; shcompr = v; expchroma = v; warm = v; diff --git a/rtgui/paramsedited.h b/rtgui/paramsedited.h index ede1e3dd1..bce036a94 100644 --- a/rtgui/paramsedited.h +++ b/rtgui/paramsedited.h @@ -414,6 +414,7 @@ public: bool hlcompr; bool hlcomprthresh; bool black; + bool shadex; bool shcompr; bool expchroma; bool warm;