From e7327f3da997ceb46a0468f48a84ddc95c5c4905 Mon Sep 17 00:00:00 2001 From: Desmis Date: Thu, 20 Dec 2018 08:54:55 +0100 Subject: [PATCH] Some bugs fixed --- rtengine/dcrop.cc | 4 +-- rtengine/improccoordinator.cc | 4 +-- rtengine/improcfun.h | 4 +-- rtengine/iplocallab.cc | 49 ++++++++++++++++++----------------- rtengine/simpleprocess.cc | 4 +-- 5 files changed, 33 insertions(+), 32 deletions(-) diff --git a/rtengine/dcrop.cc b/rtengine/dcrop.cc index 4e488cc2a..ae2f601ee 100644 --- a/rtengine/dcrop.cc +++ b/rtengine/dcrop.cc @@ -906,7 +906,7 @@ void Crop::update(int todo) int sca = skip; // bool tyty = false; - int maxspot = 1; + // int maxspot = 1; if (needslocal) { for (int sp = 0; sp < params.locallab.nbspot; sp++) { @@ -940,7 +940,7 @@ void Crop::update(int todo) lumare = parent->lumarefs[sp]; sobelre = parent->sobelrefs[sp]; - parent->ipf.Lab_Local(1, maxspot, sp, parent->huerefs, parent->sobelrefs, parent->centerx, parent->centery, (float**)shbuffer, labnCrop, labnCrop, reservCrop, cropx / skip, cropy / skip, skips(parent->fw, skip), skips(parent->fh, skip), skip, locRETgainCurve, lllocalcurve2, + parent->ipf.Lab_Local(1, sp, parent->huerefs, parent->sobelrefs, parent->centerx, parent->centery, (float**)shbuffer, labnCrop, labnCrop, reservCrop, cropx / skip, cropy / skip, skips(parent->fw, skip), skips(parent->fh, skip), skip, locRETgainCurve, lllocalcurve2, loclhCurve, lochhCurve, LHutili, HHutili, cclocalcurve2, localskutili, sklocalcurve2, localexutili, exlocalcurve2, hltonecurveloc2, shtonecurveloc2, tonecurveloc2, lightCurveloc2, huerefblu, huere, chromare, lumare, sobelre); lllocalcurve2.clear(); diff --git a/rtengine/improccoordinator.cc b/rtengine/improccoordinator.cc index 17114878c..ddf7d7a9d 100644 --- a/rtengine/improccoordinator.cc +++ b/rtengine/improccoordinator.cc @@ -739,7 +739,7 @@ void ImProcCoordinator::updatePreviewImage(int todo, bool panningRelatedChange) nprevl->CopyFrom(oprevl); reserv->CopyFrom(oprevl); - int maxspot = 1; + // int maxspot = 1; progress("Applying Color Boost...", 100 * readyphase / numofphases); //************************************************************* @@ -818,7 +818,7 @@ void ImProcCoordinator::updatePreviewImage(int todo, bool panningRelatedChange) * - maxspot, huerefs, centerx and centery aren't used in Lab_Local (only for printf) so values aren't important * - shbuffer is used as nullptr */ - ipf.Lab_Local(3, maxspot, sp, huerefs, sobelrefs, centerx, centery, (float**)shbuffer, nprevl, nprevl, reserv, 0, 0, pW, pH, scale, locRETgainCurve, lllocalcurve, loclhCurve, lochhCurve, + ipf.Lab_Local(3, sp, huerefs, sobelrefs, centerx, centery, (float**)shbuffer, nprevl, nprevl, reserv, 0, 0, pW, pH, scale, locRETgainCurve, lllocalcurve, loclhCurve, lochhCurve, LHutili, HHutili, cclocalcurve, localskutili, sklocalcurve, localexutili, exlocalcurve, hltonecurveloc, shtonecurveloc, tonecurveloc, lightCurveloc, huerblu, huer, chromar, lumar, sobeler); // Clear local curves diff --git a/rtengine/improcfun.h b/rtengine/improcfun.h index 8d4d4ee7f..40192da96 100644 --- a/rtengine/improcfun.h +++ b/rtengine/improcfun.h @@ -289,13 +289,13 @@ public: void calc_ref(int sp, LabImage* original, LabImage* transformed, int cx, int cy, int oW, int oH, int sk, double &huerefblur, double &huere, double &chromare, double &lumare, double &sobelref); void copy_ref(LabImage* spotbuffer, LabImage* original, LabImage* transformed, int cx, int cy, int sk, const struct local_params & lp, double &huerefspot, double &chromarefspot, double &lumarefspot); void paste_ref(LabImage* spotbuffer, LabImage* transformed, int cx, int cy, int sk, const struct local_params & lp); - void Lab_Local(int call, int maxspot, int sp, LUTf & huerefs, LUTf & sobelrefs, LUTi & centerx, LUTi & centery, float** shbuffer, LabImage* original, LabImage* transformed, LabImage* reserved, int cx, int cy, int oW, int oH, int sk, const LocretigainCurve & locRETgainCcurve, LUTf & lllocalcurve, const LocLHCurve & loclhCurve, const LocHHCurve & lochhCurve, bool &LHutili, bool &HHutili, LUTf & cclocalcurve, bool & localskutili, LUTf & sklocalcurve, bool & localexutili, LUTf & exlocalcurve, LUTf & hltonecurve, LUTf & shtonecurve, LUTf & tonecurve, LUTf & lightCurveloc, double & huerefblur, double &hueref, double &chromaref, double &lumaref, double &sobelref); + void Lab_Local(int call, int sp, LUTf & huerefs, LUTf & sobelrefs, LUTi & centerx, LUTi & centery, float** shbuffer, LabImage* original, LabImage* transformed, LabImage* reserved, int cx, int cy, int oW, int oH, int sk, const LocretigainCurve & locRETgainCcurve, LUTf & lllocalcurve, const LocLHCurve & loclhCurve, const LocHHCurve & lochhCurve, bool &LHutili, bool &HHutili, LUTf & cclocalcurve, bool & localskutili, LUTf & sklocalcurve, bool & localexutili, LUTf & exlocalcurve, LUTf & hltonecurve, LUTf & shtonecurve, LUTf & tonecurve, LUTf & lightCurveloc, double & huerefblur, double &hueref, double &chromaref, double &lumaref, double &sobelref); void addGaNoise(LabImage *lab, LabImage *dst, const float mean, const float variance, const int sk); void BlurNoise_Localold(int call, const struct local_params& lp, LabImage* original, LabImage* transformed, const LabImage* const tmp1, int cx, int cy); void InverseBlurNoise_Local(const struct local_params& lp, LabImage* original, LabImage* transformed, const LabImage* const tmp1, int cx, int cy); void Reti_Local(float moddE, float powdE, float ** buflight, float **bufchro, const float hueplus, const float huemoins, const float hueref, const float dhue, const float chromaref, const float lumaref, const struct local_params& lp, LabImage* original, LabImage* transformed, const LabImage* const tmp1, int cx, int cy, int chro, int sk); void InverseReti_Local(const struct local_params& lp, LabImage* original, LabImage* transformed, const LabImage* const tmp1, int cx, int cy, int chro); - void Contrast_Local(float moddE, float powdE, int call, float ** buflightc, const float hueplus, const float huemoins, const float hueref, const float dhue, const float chromaref, float pm, struct local_contra &lco, float lumaref, const struct local_params& lp, LabImage* original, LabImage* transformed, int cx, int cy, int sk); + void Contrast_Local(float powdE, int call, float ** buflightc, const float hueplus, const float huemoins, const float hueref, const float dhue, const float chromaref, float pm, struct local_contra &lco, float lumaref, const struct local_params& lp, LabImage* original, LabImage* transformed, int cx, int cy, int sk); void cbdl_Local(float moddE, float powdE, float ** buflight, float ** bufchrom, float **loctemp, float **loctempch, const float hueplus, const float huemoins, const float hueref, const float dhue, const float chromaref, const float lumaref, const local_params& lp, LabImage* original, LabImage* transformed, int cx, int cy, int chro, int sk); void BlurNoise_Local(float moddE, float powdE, int call, LabImage* tmp1, LabImage* tmp2, float ** buflight, float ** bufchro, const float hueplus, const float huemoins, const float hueref, const float dhue, const float chromaref, const float lumaref, const local_params& lp, LabImage* original, LabImage* transformed, int cx, int cy, int sk); void TM_Local(float moddE, float powdE, LabImage* tmp1, float ** buflight, const float hueplus, const float huemoins, const float hueref, const float dhue, const float chromaref, const float lumaref, const local_params& lp, LabImage* original, LabImage* transformed, int cx, int cy, int sk); diff --git a/rtengine/iplocallab.cc b/rtengine/iplocallab.cc index f109677ea..56b3ccf74 100644 --- a/rtengine/iplocallab.cc +++ b/rtengine/iplocallab.cc @@ -820,7 +820,7 @@ void ImProcFunctions::ciecamloc_02float(int sp, LabImage* lab, LabImage* dest) float yb = 18.f; float d, dj; - const int gamu = 0; //(params->colorappearance.gamut) ? 1 : 0; + // const int gamu = 0; //(params->colorappearance.gamut) ? 1 : 0; xw = 100.0f * Xw; yw = 100.0f * Yw; zw = 100.0f * Zw; @@ -4463,7 +4463,7 @@ struct local_contra { float al, bl; }; -void ImProcFunctions::Contrast_Local(float moddE, float powdE, int call, float ** buflightc, const float hueplus, const float huemoins, const float hueref, const float dhue, const float chromaref, float pm, struct local_contra & lco, float lumaref, const struct local_params & lp, LabImage * original, LabImage * transformed, int cx, int cy, int sk) +void ImProcFunctions::Contrast_Local(float powdE, int call, float ** buflightc, const float hueplus, const float huemoins, const float hueref, const float dhue, const float chromaref, float pm, struct local_contra & lco, float lumaref, const struct local_params & lp, LabImage * original, LabImage * transformed, int cx, int cy, int sk) { BENCHFUN // contrast - perhaps for 4 areas if need @@ -5145,7 +5145,7 @@ void ImProcFunctions::InverseContrast_Local(float ave, struct local_contra & lco delete origblur; } -static void calclight(float lum, float koef, float & lumnew, bool inv, LUTf & lightCurveloc) +static void calclight(float lum, float koef, float & lumnew, LUTf & lightCurveloc) //replace L-curve that does not work in local or bad { /* @@ -5815,8 +5815,6 @@ void ImProcFunctions::Exclude_Local(float moddE, float powdE, int sen, float **d float cli = 1.f; float clc = 1.f; - float cli2 = 1.f; - float clc2 = 1.f; cli = (buflight[loy - begy][lox - begx]); clc = (bufchro[loy - begy][lox - begx]); @@ -7313,7 +7311,7 @@ void ImProcFunctions::ColorLight_Local(float moddE, float powdE, int call, LabIm } if (lp.ligh != 0.f && lp.curvact == false) { - calclight(lumnew, lp.ligh, lumnew, true, lightCurveloc); //replace L-curve + calclight(lumnew, lp.ligh, lumnew, lightCurveloc); //replace L-curve lightcont = lumnew; } else { @@ -7439,7 +7437,7 @@ void ImProcFunctions::ColorLight_Local(float moddE, float powdE, int call, LabIm if (lp.ligh != 0.f && lp.curvact == false) { - calclight(lumnew, lp.ligh, lumnew, true, lightCurveloc); //replace L-curve + calclight(lumnew, lp.ligh, lumnew, lightCurveloc); //replace L-curve lightcont = lumnew; } else { @@ -7936,7 +7934,7 @@ void ImProcFunctions::InverseColorLight_Local(const struct local_params & lp, LU float lightcont; if (lp.ligh != 0.f) { - calclight(lumnew, lp.ligh, lumnew, true, lightCurveloc); //replace L-curve + calclight(lumnew, lp.ligh, lumnew, lightCurveloc); //replace L-curve lightcont = lumnew; } else { @@ -7963,7 +7961,7 @@ void ImProcFunctions::InverseColorLight_Local(const struct local_params & lp, LU float lumnew = original->L[y][x]; if (lp.ligh != 0.f) { - calclight(original->L[y][x], lp.ligh, lumnew, false, lightCurveloc); + calclight(original->L[y][x], lp.ligh, lumnew, lightCurveloc); } float lightcont = lumnew ; //apply lightness @@ -7988,7 +7986,7 @@ void ImProcFunctions::InverseColorLight_Local(const struct local_params & lp, LU float lightcont; if (lp.ligh != 0.f) { - calclight(lumnew, lp.ligh, lumnew, true, lightCurveloc); //replace L-curve + calclight(lumnew, lp.ligh, lumnew, lightCurveloc); //replace L-curve lightcont = lumnew; } else { @@ -8012,7 +8010,7 @@ void ImProcFunctions::InverseColorLight_Local(const struct local_params & lp, LU } else { if (lp.ligh != 0.f) { - calclight(original->L[y][x], lp.ligh, lumnew, false, lightCurveloc); + calclight(original->L[y][x], lp.ligh, lumnew, lightCurveloc); } float lightcont = lumnew ; @@ -8524,7 +8522,7 @@ void ImProcFunctions::fftw_denoise(int GW, int GH, int max_numblox_W, int min_nu -void ImProcFunctions::Lab_Local(int call, int maxspot, int sp, LUTf & huerefs, LUTf & sobelrefs, LUTi & centerx, LUTi & centery, float** shbuffer, LabImage * original, LabImage * transformed, LabImage * reserved, int cx, int cy, int oW, int oH, int sk, +void ImProcFunctions::Lab_Local(int call, int sp, LUTf & huerefs, LUTf & sobelrefs, LUTi & centerx, LUTi & centery, float** shbuffer, LabImage * original, LabImage * transformed, LabImage * reserved, int cx, int cy, int oW, int oH, int sk, const LocretigainCurve & locRETgainCcurve, LUTf & lllocalcurve, const LocLHCurve & loclhCurve, const LocHHCurve & lochhCurve, bool & LHutili, bool & HHutili, LUTf & cclocalcurve, bool & localskutili, LUTf & sklocalcurve, bool & localexutili, LUTf & exlocalcurve, LUTf & hltonecurveloc, LUTf & shtonecurveloc, LUTf & tonecurveloc, LUTf & lightCurveloc, double & huerefblur, double & hueref, double & chromaref, double & lumaref, double & sobelref) { @@ -11088,7 +11086,7 @@ void ImProcFunctions::Lab_Local(int call, int maxspot, int sp, LUTf & huerefs, L float lighLnew; float amplil = 140.f; float lighL = bufcolorig->L[loy - begy][lox - begx]; - calclight(lighL, lp.ligh, lighLnew, true, lightCurveloc); //replace L-curve + calclight(lighL, lp.ligh, lighLnew, lightCurveloc); //replace L-curve lL = lighLnew / lighL; if (lL <= 1.f) {//convert data curve near values of slider -100 + 100, to be used after to detection shape @@ -11128,7 +11126,7 @@ void ImProcFunctions::Lab_Local(int call, int maxspot, int sp, LUTf & huerefs, L if (lp.qualcurvemet >= 4) { JaggedArray blend(bfw, bfh); float contrastf = lp.sensexclu / 100.f; - LabImage * tmpsob; + //LabImage * tmpsob; // tmpsob = new LabImage(bfw, bfh); // SobelCannyLuma(tmpsob->L, bufcolorig->L, bfw, bfh, 1.f); @@ -11149,7 +11147,7 @@ void ImProcFunctions::Lab_Local(int call, int maxspot, int sp, LUTf & huerefs, L } } - delete tmpsob; + // delete tmpsob; } @@ -11323,7 +11321,7 @@ void ImProcFunctions::Lab_Local(int call, int maxspot, int sp, LUTf & huerefs, L } - Contrast_Local(moddE, powdE, call, buflightc, hueplus, huemoins, hueref, dhue, chromaref, pm, lco, lumaref, lp, original, transformed, cx, cy, sk); + Contrast_Local(powdE, call, buflightc, hueplus, huemoins, hueref, dhue, chromaref, pm, lco, lumaref, lp, original, transformed, cx, cy, sk); if (call <= 3) { @@ -12182,17 +12180,19 @@ void ImProcFunctions::Lab_Local(int call, int maxspot, int sp, LUTf & huerefs, L //calc dehaze Imagefloat *tmpImage = nullptr; - tmpImage = new Imagefloat(bfw, bfh); - lab2rgb(*bufreti, *tmpImage, params->icm.workingProfile); - float deha = LIM01(float(0.9f * params->locallab.dehaz.at(sp) + 0.3f*lp.str) / 100.f * 0.9f); - float depthcombi = 0.3f*params->locallab.neigh.at(sp) + 0.15f * (500.f - params->locallab.vart.at(sp)); - float depth = -LIM01(depthcombi / 100.f); + if(lp.dehaze > 0) { + tmpImage = new Imagefloat(bfw, bfh); + lab2rgb(*bufreti, *tmpImage, params->icm.workingProfile); + float deha = LIM01(float(0.9f * lp.dehaze + 0.3f*lp.str) / 100.f * 0.9f); + float depthcombi = 0.3f*params->locallab.neigh.at(sp) + 0.15f * (500.f - params->locallab.vart.at(sp)); + float depth = -LIM01(depthcombi / 100.f); - dehazeloc(tmpImage, deha, depth); - - rgb2lab(*tmpImage, *bufreti, params->icm.workingProfile); + dehazeloc(tmpImage, deha, depth); + rgb2lab(*tmpImage, *bufreti, params->icm.workingProfile); + delete tmpImage; + } } float *orig[Hd] ALIGNED16; @@ -12228,6 +12228,7 @@ void ImProcFunctions::Lab_Local(int call, int maxspot, int sp, LUTf & huerefs, L tmpl = new LabImage(Wd, Hd); } else { + #ifdef _OPENMP #pragma omp parallel for schedule(dynamic,16) diff --git a/rtengine/simpleprocess.cc b/rtengine/simpleprocess.cc index d5eac7516..cba48dca7 100644 --- a/rtengine/simpleprocess.cc +++ b/rtengine/simpleprocess.cc @@ -1083,7 +1083,7 @@ private: LUTf lightCurveloc(32770, 0); LUTf exlocalcurve(65536, 0); - int maxspot = 1; + // int maxspot = 1; float** shbuffer = nullptr; for (int sp = 0; sp < params.locallab.nbspot; sp++) { @@ -1130,7 +1130,7 @@ private: } - ipf.Lab_Local(2, maxspot, sp, huerefs, sobelrefs, centerx, centery, (float**)shbuffer, labView, labView, reservView, 0, 0, fw, fh, 1, locRETgainCurve, lllocalcurve, loclhCurve, lochhCurve, + ipf.Lab_Local(2, sp, huerefs, sobelrefs, centerx, centery, (float**)shbuffer, labView, labView, reservView, 0, 0, fw, fh, 1, locRETgainCurve, lllocalcurve, loclhCurve, lochhCurve, LHutili, HHutili, cclocalcurve, localskutili, sklocalcurve, localexutili, exlocalcurve, hltonecurveloc, shtonecurveloc, tonecurveloc, lightCurveloc, huerefblu, huere, chromare, lumare, sobelre); // Clear local curves