diff --git a/rtdata/languages/default b/rtdata/languages/default index 5dccad51a..baeec4bd0 100644 --- a/rtdata/languages/default +++ b/rtdata/languages/default @@ -1040,6 +1040,7 @@ HISTORY_MSG_799;Local - Opacity HISTORY_MSG_800;Local - Color RGB ToneCurve HISTORY_MSG_801;Local - Color ToneCurve Method HISTORY_MSG_802;Local - Color ToneCurve Special +HISTORY_MSG_803;Local - Contrast threshold HISTORY_MSG_CLAMPOOG;Clip out-of-gamut colors HISTORY_MSG_COLORTONING_LABGRID_VALUE;CT - Color correction HISTORY_MSG_COLORTONING_LABREGION_AB;CT - Color correction @@ -2166,6 +2167,8 @@ TP_LOCALLAB_MERGEFOU;Previous Spot(Mask 7) TP_LOCALLAB_MERGEFIV;Previous Spot(Mask 7) + Mask LCH TP_LOCALLAB_MERGE1COLFRA;Merge with Original TP_LOCALLAB_OPACOL;Opacity +TP_LOCALLAB_CONTTHR;Contrast Threshold +TP_LOCALLAB_MERGEOPA_TOOLTIP;Opacity merge % current Spot with original or previous Spot.\nContrast threshold : adjust result in function of Original contrast TP_LOCALLAB_MERGECOLFRA;Mask LCH TP_LOCALLAB_MERONE;Normal TP_LOCALLAB_MERTWO;Substract diff --git a/rtengine/iplocallab.cc b/rtengine/iplocallab.cc index b996f61ff..e64da46fd 100644 --- a/rtengine/iplocallab.cc +++ b/rtengine/iplocallab.cc @@ -6347,6 +6347,7 @@ void ImProcFunctions::DeNoise(int call, int del, float * slidL, float * slida, f mxsl = max(mxslid34, mxslid56); } + /* for(int j=0;j<8;j++){ printf("j=%i slidL=%f\n", j, slidL[j]); @@ -6435,9 +6436,9 @@ void ImProcFunctions::DeNoise(int call, int del, float * slidL, float * slida, f WaveletDenoiseAllL(Ldecomp, noisevarlum, madL, vari, edge, numThreads); } else { - + WaveletDenoiseAll_BiShrinkL(Ldecomp, noisevarlum, madL, vari, edge, numThreads); - + WaveletDenoiseAllL(Ldecomp, noisevarlum, madL, vari, edge, numThreads); } @@ -11741,6 +11742,7 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o int level_hr = params->locallab.spots.at(sp).csthresholdcol.getTopRight(); int shortcu = lp.mergemet; //params->locallab.spots.at(sp).shortc; int lumask = params->locallab.spots.at(sp).lumask; + float conthr = 0.01f * params->locallab.spots.at(sp).conthrcol; int tonemod = 0; if (params->locallab.spots.at(sp).toneMethod == "one") { @@ -12057,24 +12059,31 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o if (lp.mergemet >= 2) { //merge result with original bufcolreserv.reset(new LabImage(bfw, bfh)); + JaggedArray lumreserv(bfw, bfh); + #ifdef _OPENMP #pragma omp parallel for schedule(dynamic,16) #endif for (int y = 0; y < bfh ; y++) { for (int x = 0; x < bfw; x++) { - if(lp.mergemet == 2 || lp.mergemet == 3) { - bufcolreserv->L[y][x] = reserved->L[y + ystart][x + xstart]; - bufcolreserv->a[y][x] = reserved->a[y + ystart][x + xstart]; - bufcolreserv->b[y][x] = reserved->b[y + ystart][x + xstart]; + lumreserv[y][x] = reserved->L[y + ystart][x + xstart]; + + if (lp.mergemet == 2 || lp.mergemet == 3) { + bufcolreserv->L[y][x] = reserved->L[y + ystart][x + xstart]; + bufcolreserv->a[y][x] = reserved->a[y + ystart][x + xstart]; + bufcolreserv->b[y][x] = reserved->b[y + ystart][x + xstart]; } else { - bufcolreserv->L[y][x] = lastorig->L[y + ystart][x + xstart]; - bufcolreserv->a[y][x] = lastorig->a[y + ystart][x + xstart]; - bufcolreserv->b[y][x] = lastorig->b[y + ystart][x + xstart]; + bufcolreserv->L[y][x] = lastorig->L[y + ystart][x + xstart]; + bufcolreserv->a[y][x] = lastorig->a[y + ystart][x + xstart]; + bufcolreserv->b[y][x] = lastorig->b[y + ystart][x + xstart]; } } } + JaggedArray blend(bfw, bfh); + buildBlendMask(lumreserv, blend, bfw, bfh, conthr, 1.f); + if (lp.mergecolMethod == 0) { //normal @@ -12302,6 +12311,20 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o delete tmpImageorig; delete tmpImagereserv; + if (conthr > 0.f) { +#ifdef _OPENMP + #pragma omp parallel for schedule(dynamic,16) +#endif + + for (int y = 0; y < bfh ; y++) { + for (int x = 0; x < bfw; x++) { + bufcolfin->L[y][x] = intp(blend[y][x], bufcolfin->L[y][x], bufcolreserv->L[y][x]); + bufcolfin->a[y][x] = intp(blend[y][x], bufcolfin->a[y][x], bufcolreserv->a[y][x]); + bufcolfin->b[y][x] = intp(blend[y][x], bufcolfin->b[y][x], bufcolreserv->b[y][x]); + } + } + } + bool fordiff = false; if (lp.mergecolMethod == 2 && fordiff) {//display differences whithout deltaE...in case of generally disabled diff --git a/rtengine/procevents.h b/rtengine/procevents.h index 55ee0de75..7d0f19197 100644 --- a/rtengine/procevents.h +++ b/rtengine/procevents.h @@ -825,6 +825,7 @@ enum ProcEventCode { Evlocallabrgbshape = 799, EvLocallabtoneMethod = 800, EvLocallabspecial = 801, + Evlocallabconthrcol = 802, NUMOFEVENTS }; diff --git a/rtengine/procparams.cc b/rtengine/procparams.cc index 79cb2fc55..bf3dc282a 100644 --- a/rtengine/procparams.cc +++ b/rtengine/procparams.cc @@ -2483,6 +2483,7 @@ LocallabParams::LocallabSpot::LocallabSpot() : 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(0.0), opacol(100.0), + conthrcol(0.0), Lmaskcurve{(double)DCT_NURBS, 0.0, 0.0, 1.0, 1.0}, LLmaskcolcurvewav{(double)FCT_MinMaxCPoints, 0.0, 0.5, 0.35, 0.35, 1., 0.5, 0.35, 0.35}, csthresholdcol(0, 0, 6, 5, false), @@ -2798,6 +2799,7 @@ bool LocallabParams::LocallabSpot::operator ==(const LocallabSpot& other) const && blurcolde == other.blurcolde && softradiuscol == other.softradiuscol && opacol == other.opacol + && conthrcol == other.conthrcol && Lmaskcurve == other.Lmaskcurve && LLmaskcolcurvewav == other.LLmaskcolcurvewav && csthresholdcol == other.csthresholdcol @@ -4108,6 +4110,7 @@ int ProcParams::save(const Glib::ustring& fname, const Glib::ustring& fname2, bo 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); saveToKeyfile(!pedited || pedited->locallab.spots.at(i).opacol, "Locallab", "Opacol_" + std::to_string(i), spot.opacol, keyFile); + saveToKeyfile(!pedited || pedited->locallab.spots.at(i).conthrcol, "Locallab", "Conthrcol_" + std::to_string(i), spot.conthrcol, keyFile); saveToKeyfile(!pedited || pedited->locallab.spots.at(i).Lmaskcurve, "Locallab", "LmaskCurve_" + std::to_string(i), spot.Lmaskcurve, keyFile); saveToKeyfile(!pedited || pedited->locallab.spots.at(i).LLmaskcolcurvewav, "Locallab", "LLmaskcolCurvewav_" + std::to_string(i), spot.LLmaskcolcurvewav, keyFile); saveToKeyfile(!pedited || pedited->locallab.spots.at(i).csthresholdcol, "Locallab", "CSThresholdcol_" + std::to_string(i), spot.csthresholdcol.toVector(), keyFile); @@ -5526,6 +5529,7 @@ int ProcParams::load(const Glib::ustring& fname, ParamsEdited* pedited) 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); assignFromKeyfile(keyFile, "Locallab", "Opacol_" + std::to_string(i), pedited, spot.opacol, spotEdited.opacol); + assignFromKeyfile(keyFile, "Locallab", "Conthrcol_" + std::to_string(i), pedited, spot.conthrcol, spotEdited.conthrcol); assignFromKeyfile(keyFile, "Locallab", "LmaskCurve_" + std::to_string(i), pedited, spot.Lmaskcurve, spotEdited.Lmaskcurve); assignFromKeyfile(keyFile, "Locallab", "LLmaskcolCurvewav_" + std::to_string(i), pedited, spot.LLmaskcolcurvewav, spotEdited.LLmaskcolcurvewav); if (keyFile.has_key("Locallab", "CSThresholdcol_" + std::to_string(i))) { diff --git a/rtengine/procparams.h b/rtengine/procparams.h index d03bda484..f9032296f 100644 --- a/rtengine/procparams.h +++ b/rtengine/procparams.h @@ -1026,6 +1026,7 @@ struct LocallabParams { std::vector HHmaskcurve; double softradiuscol; double opacol; + double conthrcol; std::vector Lmaskcurve; std::vector LLmaskcolcurvewav; Threshold csthresholdcol; diff --git a/rtengine/refreshmap.cc b/rtengine/refreshmap.cc index 5cdeb664a..843d8ff64 100644 --- a/rtengine/refreshmap.cc +++ b/rtengine/refreshmap.cc @@ -828,7 +828,8 @@ int refreshmap[rtengine::NUMOFEVENTS] = { LUMINANCECURVE, //EvLocallabopacol LUMINANCECURVE, //Evlocallabrgbshape LUMINANCECURVE, //EvLocallabtoneMethod - LUMINANCECURVE // EvLocallabspecial + LUMINANCECURVE, // EvLocallabspecial + LUMINANCECURVE //EvLocallabconthrcol }; namespace rtengine diff --git a/rtgui/locallab.cc b/rtgui/locallab.cc index b94ef35c8..c91cc16f9 100644 --- a/rtgui/locallab.cc +++ b/rtgui/locallab.cc @@ -263,6 +263,7 @@ Locallab::Locallab(): shadmaskcol(Gtk::manage(new Adjuster(M("TP_LOCALLAB_SHAMASKCOL"), 0, 100, 1, 0))), softradiuscol(Gtk::manage(new Adjuster(M("TP_LOCALLAB_SOFTRADIUSCOL"), 0.0, 100.0, 0.5, 0.))), opacol(Gtk::manage(new Adjuster(M("TP_LOCALLAB_OPACOL"), 0.0, 100.0, 0.5, 100.))), + conthrcol(Gtk::manage(new Adjuster(M("TP_LOCALLAB_CONTTHR"), 0.0, 100.0, 0.5, 100.))), // 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))), @@ -636,6 +637,7 @@ Locallab::Locallab(): shadmaskcol->setAdjusterListener(this); softradiuscol->setAdjusterListener(this); opacol->setAdjusterListener(this); + conthrcol->setAdjusterListener(this); lapmaskcol->setAdjusterListener(this); if (showtooltip) { @@ -864,6 +866,11 @@ Locallab::Locallab(): mask2CurveEditorGwav->curveListComplete(); csThresholdcol->setAdjusterListener(this); + if (showtooltip) { + opacol->set_tooltip_text(M("TP_LOCALLAB_MERGEOPA_TOOLTIP")); + conthrcol->set_tooltip_text(M("TP_LOCALLAB_MERGEOPA_TOOLTIP")); + } + ToolParamBlock* const colorBox = Gtk::manage(new ToolParamBlock()); Gtk::Frame* const superFrame = Gtk::manage(new Gtk::Frame()); @@ -902,6 +909,7 @@ Locallab::Locallab(): ToolParamBlock* const mergecolBox = Gtk::manage(new ToolParamBlock()); mergecolBox->pack_start(*mergecolMethod); mergecolBox->pack_start(*opacol); + mergecolBox->pack_start(*conthrcol); merge1colFrame->add(*mergecolBox); ToolParamBlock* const maskcolBox = Gtk::manage(new ToolParamBlock()); @@ -3647,6 +3655,7 @@ void Locallab::write(rtengine::procparams::ProcParams* pp, ParamsEdited* pedited pp->locallab.spots.at(pp->locallab.selspot).lapmaskcol = lapmaskcol->getValue(); pp->locallab.spots.at(pp->locallab.selspot).softradiuscol = softradiuscol->getValue(); pp->locallab.spots.at(pp->locallab.selspot).opacol = opacol->getValue(); + pp->locallab.spots.at(pp->locallab.selspot).conthrcol = conthrcol->getValue(); pp->locallab.spots.at(pp->locallab.selspot).Lmaskcurve = Lmaskshape->getCurve(); pp->locallab.spots.at(pp->locallab.selspot).LLmaskcolcurvewav = LLmaskcolshapewav->getCurve(); pp->locallab.spots.at(pp->locallab.selspot).csthresholdcol = csThresholdcol->getValue(); @@ -4040,6 +4049,7 @@ void Locallab::write(rtengine::procparams::ProcParams* pp, ParamsEdited* pedited pe->locallab.spots.at(pp->locallab.selspot).lapmaskcol = pe->locallab.spots.at(pp->locallab.selspot).lapmaskcol || lapmaskcol->getEditedState(); pe->locallab.spots.at(pp->locallab.selspot).softradiuscol = pe->locallab.spots.at(pp->locallab.selspot).softradiuscol || softradiuscol->getEditedState(); pe->locallab.spots.at(pp->locallab.selspot).opacol = pe->locallab.spots.at(pp->locallab.selspot).opacol || opacol->getEditedState(); + pe->locallab.spots.at(pp->locallab.selspot).conthrcol = pe->locallab.spots.at(pp->locallab.selspot).conthrcol || conthrcol->getEditedState(); pe->locallab.spots.at(pp->locallab.selspot).Lmaskcurve = pe->locallab.spots.at(pp->locallab.selspot).Lmaskcurve || !Lmaskshape->isUnChanged(); pe->locallab.spots.at(pp->locallab.selspot).LLmaskcolcurvewav = pe->locallab.spots.at(pp->locallab.selspot).LLmaskcolcurvewav || !LLmaskcolshapewav->isUnChanged(); pe->locallab.spots.at(pp->locallab.selspot).csthresholdcol = pe->locallab.spots.at(pp->locallab.selspot).csthresholdcol || csThresholdcol->getEditedState(); @@ -4364,6 +4374,7 @@ void Locallab::write(rtengine::procparams::ProcParams* pp, ParamsEdited* pedited pedited->locallab.spots.at(pp->locallab.selspot).lapmaskcol = pedited->locallab.spots.at(pp->locallab.selspot).lapmaskcol || lapmaskcol->getEditedState(); pedited->locallab.spots.at(pp->locallab.selspot).softradiuscol = pedited->locallab.spots.at(pp->locallab.selspot).softradiuscol || softradiuscol->getEditedState(); pedited->locallab.spots.at(pp->locallab.selspot).opacol = pedited->locallab.spots.at(pp->locallab.selspot).opacol || opacol->getEditedState(); + pedited->locallab.spots.at(pp->locallab.selspot).conthrcol = pedited->locallab.spots.at(pp->locallab.selspot).conthrcol || conthrcol->getEditedState(); pedited->locallab.spots.at(pp->locallab.selspot).Lmaskcurve = pedited->locallab.spots.at(pp->locallab.selspot).Lmaskcurve || !Lmaskshape->isUnChanged(); pedited->locallab.spots.at(pp->locallab.selspot).LLmaskcolcurvewav = pedited->locallab.spots.at(pp->locallab.selspot).LLmaskcolcurvewav || !LLmaskcolshapewav->isUnChanged(); pedited->locallab.spots.at(pp->locallab.selspot).csthresholdcol = pedited->locallab.spots.at(pp->locallab.selspot).csthresholdcol || csThresholdcol->getEditedState(); @@ -6454,6 +6465,7 @@ void Locallab::setDefaults(const rtengine::procparams::ProcParams * defParams, c lapmaskcol->setDefault(defSpot->lapmaskcol); softradiuscol->setDefault(defSpot->softradiuscol); opacol->setDefault(defSpot->opacol); + conthrcol->setDefault(defSpot->conthrcol); csThresholdcol->setDefault(defSpot->csthresholdcol); // Exposure expcomp->setDefault(defSpot->expcomp); @@ -6647,6 +6659,7 @@ void Locallab::setDefaults(const rtengine::procparams::ProcParams * defParams, c lapmaskcol->setDefaultEditedState(Irrelevant); softradiuscol->setDefaultEditedState(Irrelevant); opacol->setDefaultEditedState(Irrelevant); + conthrcol->setDefaultEditedState(Irrelevant); csThresholdcol->setDefaultEditedState(Irrelevant); // Exposure expcomp->setDefaultEditedState(Irrelevant); @@ -6844,6 +6857,7 @@ void Locallab::setDefaults(const rtengine::procparams::ProcParams * defParams, c lapmaskcol->setDefaultEditedState(defSpotState->lapmaskcol ? Edited : UnEdited); softradiuscol->setDefaultEditedState(defSpotState->softradiuscol ? Edited : UnEdited); opacol->setDefaultEditedState(defSpotState->opacol ? Edited : UnEdited); + conthrcol->setDefaultEditedState(defSpotState->conthrcol ? Edited : UnEdited); csThresholdcol->setDefaultEditedState(defSpotState->csthresholdcol ? Edited : UnEdited); // Exposure expcomp->setDefaultEditedState(defSpotState->expcomp ? Edited : UnEdited); @@ -7174,6 +7188,12 @@ void Locallab::adjusterChanged(Adjuster * a, double newval) } } + if (a == conthrcol) { + if (listener) { + listener->panelChanged(Evlocallabconthrcol, conthrcol->getTextValue()); + } + } + } // Exposure @@ -8208,6 +8228,7 @@ void Locallab::setBatchMode(bool batchMode) lapmaskcol->showEditedCB(); softradiuscol->showEditedCB(); opacol->showEditedCB(); + conthrcol->showEditedCB(); csThresholdcol->showEditedCB(); // Exposure expcomp->showEditedCB(); @@ -8810,6 +8831,7 @@ void Locallab::updateLocallabGUI(const rtengine::procparams::ProcParams* pp, con lapmaskcol->setValue(pp->locallab.spots.at(index).lapmaskcol); softradiuscol->setValue(pp->locallab.spots.at(index).softradiuscol); opacol->setValue(pp->locallab.spots.at(index).opacol); + conthrcol->setValue(pp->locallab.spots.at(index).conthrcol); Lmaskshape->setCurve(pp->locallab.spots.at(index).Lmaskcurve); LLmaskcolshapewav->setCurve(pp->locallab.spots.at(index).LLmaskcolcurvewav); csThresholdcol->setValue(pp->locallab.spots.at(index).csthresholdcol); @@ -9233,6 +9255,7 @@ void Locallab::updateLocallabGUI(const rtengine::procparams::ProcParams* pp, con lapmaskcol->setEditedState(spotState->lapmaskcol ? Edited : UnEdited); softradiuscol->setEditedState(spotState->softradiuscol ? Edited : UnEdited); opacol->setEditedState(spotState->opacol ? Edited : UnEdited); + conthrcol->setEditedState(spotState->conthrcol ? Edited : UnEdited); Lmaskshape->setUnChanged(!spotState->Lmaskcurve); LLmaskcolshapewav->setUnChanged(!spotState->LLmaskcolcurvewav); csThresholdcol->setEditedState(spotState->csthresholdcol ? Edited : UnEdited); diff --git a/rtgui/locallab.h b/rtgui/locallab.h index 0ebf58e12..4a2a6541e 100644 --- a/rtgui/locallab.h +++ b/rtgui/locallab.h @@ -166,6 +166,7 @@ private: Adjuster* const shadmaskcol; Adjuster* const softradiuscol; Adjuster* const opacol; + Adjuster* const conthrcol; // Exposure Adjuster* const expcomp; Adjuster* const hlcompr; diff --git a/rtgui/paramsedited.cc b/rtgui/paramsedited.cc index 10c7f765b..95b8e4400 100644 --- a/rtgui/paramsedited.cc +++ b/rtgui/paramsedited.cc @@ -1019,6 +1019,7 @@ void ParamsEdited::initFrom(const std::vector& 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; locallab.spots.at(j).opacol = locallab.spots.at(j).opacol && pSpot.opacol == otherSpot.opacol; + locallab.spots.at(j).conthrcol = locallab.spots.at(j).conthrcol && pSpot.conthrcol == otherSpot.conthrcol; locallab.spots.at(j).Lmaskcurve = locallab.spots.at(j).Lmaskcurve && pSpot.Lmaskcurve == otherSpot.Lmaskcurve; locallab.spots.at(j).LLmaskcolcurvewav = locallab.spots.at(j).LLmaskcolcurvewav && pSpot.LLmaskcolcurvewav == otherSpot.LLmaskcolcurvewav; locallab.spots.at(j).csthresholdcol = locallab.spots.at(j).csthresholdcol && pSpot.csthresholdcol == otherSpot.csthresholdcol; @@ -2999,6 +3000,10 @@ void ParamsEdited::combine(rtengine::procparams::ProcParams& toEdit, const rteng toEdit.locallab.spots.at(i).opacol = mods.locallab.spots.at(i).opacol; } + if (locallab.spots.at(i).conthrcol) { + toEdit.locallab.spots.at(i).conthrcol = mods.locallab.spots.at(i).conthrcol; + } + if (locallab.spots.at(i).Lmaskcurve) { toEdit.locallab.spots.at(i).Lmaskcurve = mods.locallab.spots.at(i).Lmaskcurve; } @@ -4956,6 +4961,7 @@ LocallabParamsEdited::LocallabSpotEdited::LocallabSpotEdited(bool v) : HHmaskcurve(v), softradiuscol(v), opacol(v), + conthrcol(v), Lmaskcurve(v), LLmaskcolcurvewav(v), csthresholdcol(v), @@ -5268,6 +5274,7 @@ void LocallabParamsEdited::LocallabSpotEdited::set(bool v) HHmaskcurve = v; softradiuscol = v; opacol = v; + conthrcol = v; Lmaskcurve = v; LLmaskcolcurvewav = v; csthresholdcol = v; diff --git a/rtgui/paramsedited.h b/rtgui/paramsedited.h index bd54f1446..fb0919a73 100644 --- a/rtgui/paramsedited.h +++ b/rtgui/paramsedited.h @@ -449,6 +449,7 @@ public: bool HHmaskcurve; bool softradiuscol; bool opacol; + bool conthrcol; bool Lmaskcurve; bool LLmaskcolcurvewav; bool csthresholdcol;