Selective editing - modifies the activation of the Laplacian according to the spots with Dehaze (#7122)

* Disable Laplace when others Spot with dehaze

* Disable Laplace when others Spot with dehaze

* appimage and widows yml with drexpos

* Compatibility 5.10 contrast attenuator

* Change control out of boud when using Contrast attenuator

* Comment code

* Comment code

* Comment code and fixed

* Clip original retinex to avoid crash in some cases

* Change tooltip

* Clip only Lapalacian if expose or soft enabled

* Various improvment to avoid crash

* Tonecurve hsv colortoning chmixer not allow negative RGB

* Fattal and black need clip issue 7151

* Disable Fattal

* Clean code

* Disable appimage and windows yml
This commit is contained in:
Desmis 2024-07-28 07:13:58 +02:00 committed by GitHub
parent 6d8e80029d
commit cc0e941652
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 83 additions and 8 deletions

View File

@ -85,6 +85,12 @@ constexpr float clipDE(float x)
return rtengine::LIM(x, 0.3f, 1.f); return rtengine::LIM(x, 0.3f, 1.f);
} }
constexpr float clipR(float x)
{
return rtengine::LIM(x, 0.f, 65535.f);//used when Laplacian Contrast attenuator
}
constexpr float clipC(float x) constexpr float clipC(float x)
{ {
return rtengine::LIM(x, -100000.f, 100000.f);//increase LIM from 42000 to 1000000 to avoid clip and also imaginaries colors return rtengine::LIM(x, -100000.f, 100000.f);//increase LIM from 42000 to 1000000 to avoid clip and also imaginaries colors
@ -18000,8 +18006,6 @@ void ImProcFunctions::Lab_Local(
} }
} }
if (exlocalcurve && localexutili) {// L=f(L) curve enhanced if (exlocalcurve && localexutili) {// L=f(L) curve enhanced
#ifdef _OPENMP #ifdef _OPENMP
@ -18104,8 +18108,8 @@ void ImProcFunctions::Lab_Local(
} }
if (lp.laplacexp > 0.1f) { if (lp.laplacexp > 0.1f) {//don't use if an other spot use Dehaze.
//printf("EXEC ATTENUATOR\n");
MyMutex::MyLock lock(*fftwMutex); MyMutex::MyLock lock(*fftwMutex);
std::unique_ptr<float[]> datain(new float[bfwr * bfhr]); std::unique_ptr<float[]> datain(new float[bfwr * bfhr]);
std::unique_ptr<float[]> dataout(new float[bfwr * bfhr]); std::unique_ptr<float[]> dataout(new float[bfwr * bfhr]);
@ -20521,6 +20525,65 @@ void ImProcFunctions::Lab_Local(
} }
} }
} }
int bw = transformed->W;
int bh = transformed->H;
bool notzero = false; //verify that RGB values are > 0.f issue 7121 to avoid crash. Could perhaps be used in other cases as RGB curves (main)
bool notlaplacian = false;//no use of strong Laplacian
float epsi = 0.000001f;
if((lp.laplacexp > 1.f && lp.exposena) || (lp.strng > 2.f && lp.sfena)){//strong Laplacian
notlaplacian = true;
}
if(((lp.laplacexp > 0.f && lp.laplacexp <= 1.f) && lp.exposena && lp.blac == 0.f)) { // use Laplacian with very small values
notzero = true;
} else if ((lp.laplacexp > 0.f && lp.laplacexp <= 1.f) && lp.exposena && lp.blac != 0.f) {//for curvelocal simplebasecurve with black
notlaplacian = true;
}
ToneCurveMode curveMode = params->toneCurve.curveMode;//Tone curve does not allow negative values
if((curveMode == ToneCurveMode::PERCEPTUAL) || (curveMode == ToneCurveMode::STD) || (curveMode == ToneCurveMode::WEIGHTEDSTD) || (curveMode == ToneCurveMode::FILMLIKE) || (curveMode == ToneCurveMode::SATANDVALBLENDING) || (curveMode == ToneCurveMode::LUMINANCE)) {
notzero = true;
}
ToneCurveMode curveMode2 = params->toneCurve.curveMode2;//Tone curve does not allow negative values
if((curveMode2 == ToneCurveMode::PERCEPTUAL) || (curveMode2 == ToneCurveMode::STD) || (curveMode2 == ToneCurveMode::WEIGHTEDSTD) || (curveMode2 == ToneCurveMode::FILMLIKE) || (curveMode2 == ToneCurveMode::SATANDVALBLENDING) || (curveMode2 == ToneCurveMode::LUMINANCE)) {
notzero = true;
}
if(params->rgbCurves.enabled || params->hsvequalizer.enabled || params->chmixer.enabled || params->colorToning.enabled ) {//rgb curves, HSV, Channel mixer, Color Toning does not allow negative values. Perhaps others cases ?
notzero = true;
}
if(notlaplacian || notzero) {//allows memory and conversion labrgb only in these cases
const std::unique_ptr<Imagefloat> prov1(new Imagefloat(bw, bh));
lab2rgb(*transformed, *prov1, params->icm.workingProfile);
if(notlaplacian) {//clip value above 65535.f and > epsilon when Contrast attenuator with high values Laplacian or Original Retinex
#ifdef _OPENMP
#pragma omp parallel for
#endif
for (int i = 0; i < bh; ++i)
for (int j = 0; j < bw; ++j) {
prov1->r(i, j) = clipR(rtengine::max(prov1->r(i, j), epsi));
prov1->g(i, j) = clipR(rtengine::max(prov1->g(i, j), epsi));
prov1->b(i, j) = clipR(rtengine::max(prov1->b(i, j), epsi));
}
} else if(notzero) {//standard case only with small values Laplace no clip
#ifdef _OPENMP
#pragma omp parallel for
#endif
for (int i = 0; i < bh; ++i)
for (int j = 0; j < bw; ++j) {
prov1->r(i, j) = rtengine::max(prov1->r(i, j), epsi);
prov1->g(i, j) = rtengine::max(prov1->g(i, j), epsi);
prov1->b(i, j) = rtengine::max(prov1->b(i, j), epsi);
}
}
rgb2lab(*prov1, *transformed, params->icm.workingProfile);
}
// Gamut and Munsell control - very important do not deactivated to avoid crash // Gamut and Munsell control - very important do not deactivated to avoid crash

View File

@ -9235,7 +9235,13 @@ int ProcParams::load(const Glib::ustring& fname, ParamsEdited* pedited)
spotEdited.visiexpose = true; spotEdited.visiexpose = true;
} }
assignFromKeyfile(keyFile, "Locallab", "Laplacexp_" + index_str, spot.laplacexp, spotEdited.laplacexp);
assignFromKeyfile(keyFile, "Locallab", "Complexexpose_" + index_str, spot.complexexpose, spotEdited.complexexpose); assignFromKeyfile(keyFile, "Locallab", "Complexexpose_" + index_str, spot.complexexpose, spotEdited.complexexpose);
if (ppVersion <= 350 && spot.laplacexp > 0.f) { // Contrast attenuator moved to "advanced" after 5.10. Set complexity to "advanced" if Contrast attenuator is in use.
spot.complexexpose = 0;
spotEdited.complexexpose = true;
}
assignFromKeyfile(keyFile, "Locallab", "Expcomp_" + index_str, spot.expcomp, spotEdited.expcomp); assignFromKeyfile(keyFile, "Locallab", "Expcomp_" + index_str, spot.expcomp, spotEdited.expcomp);
assignFromKeyfile(keyFile, "Locallab", "Hlcompr_" + index_str, spot.hlcompr, spotEdited.hlcompr); assignFromKeyfile(keyFile, "Locallab", "Hlcompr_" + index_str, spot.hlcompr, spotEdited.hlcompr);
assignFromKeyfile(keyFile, "Locallab", "Hlcomprthresh_" + index_str, spot.hlcomprthresh, spotEdited.hlcomprthresh); assignFromKeyfile(keyFile, "Locallab", "Hlcomprthresh_" + index_str, spot.hlcomprthresh, spotEdited.hlcomprthresh);
@ -9277,7 +9283,7 @@ int ProcParams::load(const Glib::ustring& fname, ParamsEdited* pedited)
assignFromKeyfile(keyFile, "Locallab", "LmaskexpCurve_" + index_str, spot.Lmaskexpcurve, spotEdited.Lmaskexpcurve); assignFromKeyfile(keyFile, "Locallab", "LmaskexpCurve_" + index_str, spot.Lmaskexpcurve, spotEdited.Lmaskexpcurve);
assignFromKeyfile(keyFile, "Locallab", "ExpMethod_" + index_str, spot.expMethod, spotEdited.expMethod); assignFromKeyfile(keyFile, "Locallab", "ExpMethod_" + index_str, spot.expMethod, spotEdited.expMethod);
assignFromKeyfile(keyFile, "Locallab", "ExnoiseMethod_" + index_str, spot.exnoiseMethod, spotEdited.exnoiseMethod); assignFromKeyfile(keyFile, "Locallab", "ExnoiseMethod_" + index_str, spot.exnoiseMethod, spotEdited.exnoiseMethod);
assignFromKeyfile(keyFile, "Locallab", "Laplacexp_" + index_str, spot.laplacexp, spotEdited.laplacexp); // assignFromKeyfile(keyFile, "Locallab", "Laplacexp_" + index_str, spot.laplacexp, spotEdited.laplacexp);
assignFromKeyfile(keyFile, "Locallab", "Reparexp_" + index_str, spot.reparexp, spotEdited.reparexp); assignFromKeyfile(keyFile, "Locallab", "Reparexp_" + index_str, spot.reparexp, spotEdited.reparexp);
assignFromKeyfile(keyFile, "Locallab", "Balanexp_" + index_str, spot.balanexp, spotEdited.balanexp); assignFromKeyfile(keyFile, "Locallab", "Balanexp_" + index_str, spot.balanexp, spotEdited.balanexp);
assignFromKeyfile(keyFile, "Locallab", "Linearexp_" + index_str, spot.linear, spotEdited.linear); assignFromKeyfile(keyFile, "Locallab", "Linearexp_" + index_str, spot.linear, spotEdited.linear);

View File

@ -3796,7 +3796,7 @@ void LocallabExposure::convertParamToNormal()
// Disable all listeners // Disable all listeners
disableListener(); disableListener();
gamex->setValue(defSpot.gamex); gamex->setValue(defSpot.gamex);
laplacexp->setValue(defSpot.laplacexp);
// Set hidden GUI widgets in Normal mode to default spot values // Set hidden GUI widgets in Normal mode to default spot values
structexp->setValue((double)defSpot.structexp); structexp->setValue((double)defSpot.structexp);
blurexpde->setValue((double)defSpot.blurexpde); blurexpde->setValue((double)defSpot.blurexpde);
@ -3819,6 +3819,7 @@ void LocallabExposure::convertParamToSimple()
// Disable all listeners // Disable all listeners
disableListener(); disableListener();
laplacexp->setValue(defSpot.laplacexp);
fatlevel->setValue(defSpot.fatlevel); fatlevel->setValue(defSpot.fatlevel);
fatanchor->setValue(defSpot.fatanchor); fatanchor->setValue(defSpot.fatanchor);
norm->set_active(false); norm->set_active(false);
@ -3865,7 +3866,7 @@ void LocallabExposure::updateGUIToMode(const modeType new_type)
fatlevel->hide(); fatlevel->hide();
fatanchor->hide(); fatanchor->hide();
gamex->hide(); gamex->hide();
exppde->hide();
break; break;
case Normal: case Normal:
@ -3893,6 +3894,7 @@ void LocallabExposure::updateGUIToMode(const modeType new_type)
// Specific Simple mode widgets are shown in Normal mode // Specific Simple mode widgets are shown in Normal mode
softradiusexp->hide(); softradiusexp->hide();
blurexpde->hide(); blurexpde->hide();
exppde->hide();
if (!inversex->get_active()) { // Keep widget hidden when invers is toggled if (!inversex->get_active()) { // Keep widget hidden when invers is toggled
expgradexp->show(); expgradexp->show();
@ -3937,6 +3939,7 @@ void LocallabExposure::updateGUIToMode(const modeType new_type)
maskusablee->hide(); maskusablee->hide();
maskunusablee->show(); maskunusablee->show();
} }
exppde->show();
expmaskexp->show(); expmaskexp->show();
lapmaskexp->show(); lapmaskexp->show();
@ -4192,13 +4195,15 @@ void LocallabExposure::updateExposureGUI3()
expcomp->setLabel(M("TP_LOCALLAB_EXPCOMP")); expcomp->setLabel(M("TP_LOCALLAB_EXPCOMP"));
gamex->hide(); gamex->hide();
expfat->show(); expfat->show();
exppde->show(); exppde->hide();
if (mode == Normal) { // Keep widgets hidden in Simple mode if (mode == Normal) { // Keep widgets hidden in Simple mode
softradiusexp->show(); softradiusexp->show();
expgradexp->show(); expgradexp->show();
exprecove->show(); exprecove->show();
blurexpde->show(); blurexpde->show();
exppde->hide();
} }
if (mode == Expert) { // Keep widgets hidden in Simple mode if (mode == Expert) { // Keep widgets hidden in Simple mode
softradiusexp->show(); softradiusexp->show();
@ -4207,6 +4212,7 @@ void LocallabExposure::updateExposureGUI3()
structexp->show(); structexp->show();
blurexpde->show(); blurexpde->show();
gamex->show(); gamex->show();
exppde->show();
} }