From bc23a7063e5ee68acefc367410fa84a93249f9f8 Mon Sep 17 00:00:00 2001 From: Desmis Date: Mon, 2 Sep 2019 10:50:05 +0200 Subject: [PATCH] Fixed bug in local contrast wavelet --- rtengine/dcrop.cc | 1 + rtengine/improccoordinator.cc | 1 + rtengine/iplocallab.cc | 32 +++++++++++++++++++------------- rtgui/locallab.cc | 1 - rtgui/paramsedited.cc | 2 +- 5 files changed, 22 insertions(+), 15 deletions(-) diff --git a/rtengine/dcrop.cc b/rtengine/dcrop.cc index 4b5334d8d..86e3e36b3 100644 --- a/rtengine/dcrop.cc +++ b/rtengine/dcrop.cc @@ -1059,6 +1059,7 @@ void Crop::update(int todo) locllmasblCurve.Reset(); locccmasblCurve.Reset(); lochhmasblCurve.Reset(); + locwavCurve.Reset(); if (skip <= 2) { usleep(settings->cropsleep); //wait to avoid crash when crop 100% and move window diff --git a/rtengine/improccoordinator.cc b/rtengine/improccoordinator.cc index d380b24e1..6ffb54008 100644 --- a/rtengine/improccoordinator.cc +++ b/rtengine/improccoordinator.cc @@ -1038,6 +1038,7 @@ void ImProcCoordinator::updatePreviewImage(int todo, bool panningRelatedChange) locllmasblCurve.Reset(); locccmasblCurve.Reset(); lochhmasblCurve.Reset(); + locwavCurve.Reset(); } } diff --git a/rtengine/iplocallab.cc b/rtengine/iplocallab.cc index 0c6e4bdbb..7a39f0e91 100644 --- a/rtengine/iplocallab.cc +++ b/rtengine/iplocallab.cc @@ -7733,7 +7733,8 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o } } } - +if(wavcurve) printf("wav true\n"); +else printf("wav false\n"); //params->locallab.spots.at(sp).clarilres != 0.f) if ((lp.lcamount > 0.f || wavcurve || params->locallab.spots.at(sp).residcont != 0.f || params->locallab.spots.at(sp).clarilres != 0.f || params->locallab.spots.at(sp).claricres != 0.f) && call < 3 && lp.lcena) { int ystart = std::max(static_cast(lp.yc - lp.lyT) - cy, 0); @@ -8076,20 +8077,19 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o delete wdspotresidb; } - wavelet_decomposition wdspot(tmp1->L[0], bfw, bfh, wavelet_level, 1, sk, numThreads, 6); -// wavelet_decomposition *wdspot = new wavelet_decomposition(tmp1->L[0], tmp1->W, tmp1->H, wavelet_level, 1, sk, numThreads, 6); + wavelet_decomposition *wdspot = new wavelet_decomposition(tmp1->L[0], tmp1->W, tmp1->H, wavelet_level, 1, sk, numThreads, 6); - if (wdspot.memoryAllocationFailed) { + if (wdspot->memoryAllocationFailed) { return; } const float contrast = params->locallab.spots.at(sp).residcont; - int maxlvl = wdspot.maxlevel(); + int maxlvl = wdspot->maxlevel(); if (contrast != 0) { - int W_L = wdspot.level_W(0); - int H_L = wdspot.level_H(0); - float *wav_L0 = wdspot.coeff0; + int W_L = wdspot->level_W(0); + int H_L = wdspot->level_H(0); + float *wav_L0 = wdspot->coeff0; double avedbl = 0.0; // use double precision for large summations @@ -8133,14 +8133,14 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o float sigmaN[10]; float MaxP[10]; float MaxN[10]; - Evaluate2(wdspot, mean, meanN, sigma, sigmaN, MaxP, MaxN); + Evaluate2(*wdspot, mean, meanN, sigma, sigmaN, MaxP, MaxN); // printf("mean=%f sig=%f\n", mean[3], sigma[3]); for (int dir = 1; dir < 4; dir++) { for (int level = 0; level < maxlvl; ++level) { - int W_L = wdspot.level_W(level); - int H_L = wdspot.level_H(level); - float **wav_L = wdspot.level_coeffs(level); + int W_L = wdspot->level_W(level); + int H_L = wdspot->level_H(level); + float **wav_L = wdspot->level_coeffs(level); if (MaxP[level] > 0.f && mean[level] != 0.f && sigma[level] != 0.f) { float insigma = 0.666f; //SD @@ -8184,7 +8184,10 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o } } - wdspot.reconstruct(tmp1->L[0], 1.f); + wdspot->reconstruct(tmp1->L[0], 1.f); + delete wdspot; + + float thr = 0.001f; int flag = 0; @@ -8245,6 +8248,9 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o float coef = 0.01f * (max(fabs(minL), fabs(maxL))); float coefC = 0.01f * (max(fabs(minC), fabs(maxC))); + if(coefC == 0.f) {//prevent bad behavior + coefC = 1.f; + } #ifdef _OPENMP #pragma omp parallel for schedule(dynamic,16) diff --git a/rtgui/locallab.cc b/rtgui/locallab.cc index 15abf1241..c06182d7c 100644 --- a/rtgui/locallab.cc +++ b/rtgui/locallab.cc @@ -2944,7 +2944,6 @@ void Locallab::write(ProcParams* pp, ParamsEdited* pedited) 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(); pp->locallab.spots.at(pp->locallab.selspot).HHmaskreticurve = HHmaskretishape->getCurve(); diff --git a/rtgui/paramsedited.cc b/rtgui/paramsedited.cc index e5eb393c2..2920a8a6d 100644 --- a/rtgui/paramsedited.cc +++ b/rtgui/paramsedited.cc @@ -4736,6 +4736,7 @@ LocallabParamsEdited::LocallabSpotEdited::LocallabSpotEdited(bool v) : sensilc(v), fftwlc(v), localcontMethod(v), + locwavcurve(v), // Contrast by detail levels expcbdl(v), mult{v, v, v, v, v, v}, @@ -4988,7 +4989,6 @@ void LocallabParamsEdited::LocallabSpotEdited::set(bool v) fftwlc = v; localcontMethod = v; locwavcurve = v; - locwavcurve = v; // Contrast by detail levels expcbdl = v;