From 1be52c1024d49075e2617428c72289151599f6c2 Mon Sep 17 00:00:00 2001 From: Desmis Date: Sun, 3 Feb 2019 10:49:22 +0100 Subject: [PATCH] Fixed bug in previous commit - cland code with unused variables --- rtengine/curves.cc | 12 +-------- rtengine/curves.h | 2 +- rtengine/dcrop.cc | 4 +-- rtengine/improccoordinator.cc | 49 ++++------------------------------- rtengine/improccoordinator.h | 2 +- rtengine/improcfun.h | 2 +- rtengine/iplocallab.cc | 33 +---------------------- rtengine/simpleprocess.cc | 7 +++-- 8 files changed, 14 insertions(+), 97 deletions(-) diff --git a/rtengine/curves.cc b/rtengine/curves.cc index af9c7e78a..2b840352d 100644 --- a/rtengine/curves.cc +++ b/rtengine/curves.cc @@ -1054,7 +1054,7 @@ void CurveFactory::complexCurve(double ecomp, double black, double hlcompr, doub //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% void CurveFactory::complexCurvelocal(double ecomp, double black, double hlcompr, double hlcomprthresh, - double shcompr, double br, double cont, LUTu & histogram, double lumare, + double shcompr, double br, double cont, double lumare, LUTf & hlCurve, LUTf & shCurve, LUTf & outCurve, LUTf & lightCurveloc, float avg, int skip) { @@ -1123,14 +1123,6 @@ void CurveFactory::complexCurvelocal(double ecomp, double black, double hlcompr, // check if contrast curve is needed if (cont > 0.00001 || cont < -0.00001) { - // compute mean luminance of the image with the curve applied -// int sum = 0; -// float avg = 0; - -// for (int i = 0; i < 32768; i++) { -// avg += lightCurveloc[i] * histogram[i]; -// sum += histogram[i]; -// } int k = avg * 32768; avg = lightCurveloc[k]; @@ -1138,8 +1130,6 @@ void CurveFactory::complexCurvelocal(double ecomp, double black, double hlcompr, std::vector contrastcurvePoints; bool lumm = true; if (lumm) { -// avg /= sum; -// avg = lumare / 100.f; //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% contrastcurvePoints.resize(9); contrastcurvePoints.at(0) = double (DCT_NURBS); diff --git a/rtengine/curves.h b/rtengine/curves.h index 78d258d8a..9b54b9112 100644 --- a/rtengine/curves.h +++ b/rtengine/curves.h @@ -360,7 +360,7 @@ public: int skip = 1); - static void complexCurvelocal(double ecomp, double black, double hlcompr, double hlcomprthresh, double shcompr, double br, double cont, LUTu & histogram, double lumare, + static void complexCurvelocal(double ecomp, double black, double hlcompr, double hlcomprthresh, double shcompr, double br, double cont, double lumare, LUTf & hlCurve, LUTf & shCurve, LUTf & outCurve, LUTf & lightCurveloc, float avg, int skip = 1); diff --git a/rtengine/dcrop.cc b/rtengine/dcrop.cc index 1f7c87985..de589fc06 100644 --- a/rtengine/dcrop.cc +++ b/rtengine/dcrop.cc @@ -892,7 +892,6 @@ void Crop::update(int todo) LUTf shtonecurveloc2(65536, 0); LUTf tonecurveloc2(65536, 0); LUTf lightCurveloc2(32770, 0); - LUTu lhist16loc2(32770, 0); bool LHutili = parent->LHutili; bool HHutili = parent->HHutili; bool llmasutili = parent->llmasutili; @@ -950,7 +949,6 @@ void Crop::update(int todo) double br = params.locallab.spots.at(sp).lightness; double cont = params.locallab.spots.at(sp).contrast; - lhist16loc2 = parent->lhist16loc; double huere, chromare, lumare, huerefblu, chromarefblu, lumarefblu, sobelre; huerefblu = parent->huerefblurs[sp]; chromarefblu = parent->chromarefblurs[sp]; @@ -959,7 +957,7 @@ void Crop::update(int todo) chromare = parent->chromarefs[sp]; lumare = parent->lumarefs[sp]; sobelre = parent->sobelrefs[sp]; - CurveFactory::complexCurvelocal(ecomp, black / 65535., hlcompr, hlcomprthresh, shcompr, br, cont, lhist16loc2, lumare, + CurveFactory::complexCurvelocal(ecomp, black / 65535., hlcompr, hlcomprthresh, shcompr, br, cont, lumare, hltonecurveloc2, shtonecurveloc2, tonecurveloc2, lightCurveloc2, avg, sca); // Locallab mask are only shown for selected spot diff --git a/rtengine/improccoordinator.cc b/rtengine/improccoordinator.cc index cf48d968c..309409d26 100644 --- a/rtengine/improccoordinator.cc +++ b/rtengine/improccoordinator.cc @@ -108,7 +108,6 @@ ImProcCoordinator::ImProcCoordinator() shtonecurveloc(65536, 0), tonecurveloc(65536, 0), lightCurveloc(32770, 0), - lhist16loc(32770, 0), locallutili(false), localcutili(false), localskutili(false), localexutili(false), LHutili(false), HHutili(false), huerefs(500, -100000.f), huerefblurs(500, -100000.f), @@ -816,13 +815,12 @@ void ImProcCoordinator::updatePreviewImage(int todo, bool panningRelatedChange) double shcompr = params.locallab.spots.at(sp).shcompr; double br = params.locallab.spots.at(sp).lightness; double cont = params.locallab.spots.at(sp).contrast; - lhist16loc.clear(); // Reference parameters computation if (params.locallab.spots.at(sp).spotMethod == "exc") { - ipf.calc_ref(0, sp, reserv, reserv, 0, 0, pW, pH, scale, huerefblu, chromarefblu, lumarefblu, huere, chromare, lumare, sobelre, lhist16loc, avg); + ipf.calc_ref(0, sp, reserv, reserv, 0, 0, pW, pH, scale, huerefblu, chromarefblu, lumarefblu, huere, chromare, lumare, sobelre, avg); } else { - ipf.calc_ref(0, sp, nprevl, nprevl, 0, 0, pW, pH, scale, huerefblu, chromarefblu, lumarefblu, huere, chromare, lumare, sobelre, lhist16loc, avg); + ipf.calc_ref(0, sp, nprevl, nprevl, 0, 0, pW, pH, scale, huerefblu, chromarefblu, lumarefblu, huere, chromare, lumare, sobelre, avg); } // printf("improc avg=%f\n", avg); @@ -833,7 +831,7 @@ void ImProcCoordinator::updatePreviewImage(int todo, bool panningRelatedChange) chromar = chromarefs[sp] = chromare; lumar = lumarefs[sp] = lumare ; sobeler = sobelrefs[sp] = sobelre; - CurveFactory::complexCurvelocal(ecomp, black / 65535., hlcompr, hlcomprthresh, shcompr, br, cont, lhist16loc, lumar, + CurveFactory::complexCurvelocal(ecomp, black / 65535., hlcompr, hlcomprthresh, shcompr, br, cont, lumar, hltonecurveloc, shtonecurveloc, tonecurveloc, lightCurveloc, avg, sca); @@ -841,7 +839,6 @@ void ImProcCoordinator::updatePreviewImage(int todo, bool panningRelatedChange) locallListener->refChanged(huer, lumar, chromar); } - //printf("sp=%i huerblu=%f, huer=%f, chromar=%f, lumar=%f, sobeler=%f\n", sp, huerblu, huer, chromar, lumar, sobeler); // Locallab tools computation /* Notes: @@ -857,17 +854,10 @@ void ImProcCoordinator::updatePreviewImage(int todo, bool panningRelatedChange) } //recalculate references after if (params.locallab.spots.at(sp).spotMethod == "exc") { - ipf.calc_ref(1, sp, reserv, reserv, 0, 0, pW, pH, scale, huerefblu, chromarefblu, lumarefblu, huere, chromare, lumare, sobelre, lhist16loc, avg); + ipf.calc_ref(1, sp, reserv, reserv, 0, 0, pW, pH, scale, huerefblu, chromarefblu, lumarefblu, huere, chromare, lumare, sobelre, avg); } else { - ipf.calc_ref(1, sp, nprevl, nprevl, 0, 0, pW, pH, scale, huerefblu, chromarefblu, lumarefblu, huere, chromare, lumare, sobelre, lhist16loc, avg); + ipf.calc_ref(1, sp, nprevl, nprevl, 0, 0, pW, pH, scale, huerefblu, chromarefblu, lumarefblu, huere, chromare, lumare, sobelre, avg); } - huerblu = huerefblurs[sp] = huerefblu; - chromarblu = chromarefblurs[sp] = chromarefblu; - lumarblu = lumarefblurs[sp] = lumarefblu; - huer = huerefs[sp] = huere; - chromar = chromarefs[sp] = chromare; - lumar = lumarefs[sp] = lumare ; - sobeler = sobelrefs[sp] = sobelre; lllocalcurve.clear(); cclocalcurve.clear(); @@ -883,36 +873,7 @@ void ImProcCoordinator::updatePreviewImage(int todo, bool panningRelatedChange) locccmasexpCurve.Reset(); lochhmasexpCurve.Reset(); - /* - if (params.locallab.spots.at(sp).spotMethod == "exc") { - ipf.calc_ref(sp, reserv, reserv, 0, 0, pW, pH, scale, huerefblu, huere, chromare, lumare, sobelre, lhist16loc); - } else { - ipf.calc_ref(sp, nprevl, nprevl, 0, 0, pW, pH, scale, huerefblu, huere, chromare, lumare, sobelre, lhist16loc); - } - - // Clear local curves - lllocalcurve.clear(); - cclocalcurve.clear(); - sklocalcurve.clear(); - exlocalcurve.clear(); - */ } - /* - for (int sp = 0; sp < params.locallab.nbspot && sp < (int)params.locallab.spots.size(); sp++) { - //update references after threatment - if (params.locallab.spots.at(sp).spotMethod == "exc") { - ipf.calc_ref(sp, reserv, reserv, 0, 0, pW, pH, scale, huerefblu, huere, chromare, lumare, sobelre, lhist16loc); - } else { - ipf.calc_ref(sp, nprevl, nprevl, 0, 0, pW, pH, scale, huerefblu, huere, chromare, lumare, sobelre, lhist16loc); - } - huerblu = huerefblurs[sp] = huerefblu; - huer = huerefs[sp] = huere; - chromar = chromarefs[sp] = chromare; - lumar = lumarefs[sp] = lumare ; - sobeler = sobelrefs[sp] = sobelre; - - } - */ } //************************************************************* diff --git a/rtengine/improccoordinator.h b/rtengine/improccoordinator.h index 292487c10..daeb70fd6 100644 --- a/rtengine/improccoordinator.h +++ b/rtengine/improccoordinator.h @@ -230,7 +230,7 @@ protected: LUTf shtonecurveloc; LUTf tonecurveloc; LUTf lightCurveloc; - LUTu lhist16loc; +// LUTu lhist16loc; LocretigainCurve locRETgainCurve; LocretigainCurverab locRETgainCurverab; LocLHCurve loclhCurve; diff --git a/rtengine/improcfun.h b/rtengine/improcfun.h index 2ab126ccc..f9bc1a52f 100644 --- a/rtengine/improcfun.h +++ b/rtengine/improcfun.h @@ -285,7 +285,7 @@ public: int pitch, int scale, const int luma, const int chroma/*, LUTf & Lcurve, LUTf & abcurve*/); //locallab void MSRLocal(int sp, float** luminance, float** templ, const float* const *originalLuminance, const int width, const int height, const LocallabParams &loc, const int skip, const LocretigainCurve &locRETgainCcurve, const int chrome, const int scall, const float krad, float &minCD, float &maxCD, float &mini, float &maxi, float &Tmean, float &Tsigma, float &Tmin, float &Tmax); - void calc_ref(int befend, int sp, LabImage* original, LabImage* transformed, int cx, int cy, int oW, int oH, int sk, double &huerefblur, double &chromarefblur, double &lumarefblur, double &huere, double &chromare, double &lumare, double &sobelref, LUTu & histogram, float &avg); + void calc_ref(int befend, int sp, LabImage* original, LabImage* transformed, int cx, int cy, int oW, int oH, int sk, double &huerefblur, double &chromarefblur, double &lumarefblur, double &huere, double &chromare, double &lumare, double &sobelref, float &avg); 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 sp, float** shbuffer, LabImage* original, LabImage* transformed, LabImage* reserved, int cx, int cy, int oW, int oH, int sk, const LocretigainCurve & locRETgainCcurve, LUTf & lllocalcurve, bool & locallutili, const LocLHCurve & loclhCurve, const LocHHCurve & lochhCurve, const LocCCmaskCurve & locccmasCurve, bool & lcmasutili, const LocLLmaskCurve & locllmasCurve, bool & llmasutili, const LocHHmaskCurve & lochhmasCurve, bool & lhmasutili, const LocCCmaskexpCurve & locccmasexpCurve, bool &lcmasexputili, const LocLLmaskexpCurve & locllmasexpCurve, bool &llmasexputili, const LocHHmaskexpCurve & lochhmasexpCurve, bool & lhmasexputili, 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 &chromarefblur, double & lumarefblur, double &hueref, double &chromaref, double &lumaref, double &sobelref, int llColorMask, int llExpMask); diff --git a/rtengine/iplocallab.cc b/rtengine/iplocallab.cc index 91460c9a3..6be2933d7 100644 --- a/rtengine/iplocallab.cc +++ b/rtengine/iplocallab.cc @@ -4290,7 +4290,7 @@ void ImProcFunctions::InverseColorLight_Local(const struct local_params & lp, LU } -void ImProcFunctions::calc_ref(int befend, int sp, LabImage * original, LabImage * transformed, int cx, int cy, int oW, int oH, int sk, double & huerefblur, double & chromarefblur, double & lumarefblur, double & hueref, double & chromaref, double & lumaref, double & sobelref, LUTu & histogram, float &avg) +void ImProcFunctions::calc_ref(int befend, int sp, LabImage * original, LabImage * transformed, int cx, int cy, int oW, int oH, int sk, double & huerefblur, double & chromarefblur, double & lumarefblur, double & hueref, double & chromaref, double & lumaref, double & sobelref, float &avg) { if (params->locallab.enabled) { //always calculate hueref, chromaref, lumaref before others operations use in normal mode for all modules exceprt denoise @@ -4317,37 +4317,6 @@ void ImProcFunctions::calc_ref(int befend, int sp, LabImage * original, LabImage avg2 /= 32768.f; avg = avg2 / nc2; // printf("calc avg=%f \n", avg); -//claculate histogram for area selected -#ifdef _OPENMP - const int numThreads = min(max(transformed->W * transformed->H / (int)histogram.getSize(), 1), omp_get_max_threads()); - #pragma omp parallel num_threads(numThreads) if(numThreads>1) -#endif - { - LUTu lhist16thrloc(histogram.getSize()); - lhist16thrloc.clear(); - histogram.clear(); -#ifdef _OPENMP - #pragma omp for nowait -#endif - - for (int y = 0; y < transformed->H ; y++) //{ - for (int x = 0; x < transformed->W; x++) { - int lox = cx + x; - int loy = cy + y; - - if (lox >= begx && lox < xEn && loy >= begy && loy < yEn) { - int pos = (int)(original->L[y][x]); - lhist16thrloc[pos]++; - } - } - - -#ifdef _OPENMP - #pragma omp critical -#endif - histogram += lhist16thrloc; - } - // double precision for large summations double aveA = 0.; double aveB = 0.; diff --git a/rtengine/simpleprocess.cc b/rtengine/simpleprocess.cc index 35c34d2c0..edd9b3d5f 100644 --- a/rtengine/simpleprocess.cc +++ b/rtengine/simpleprocess.cc @@ -1088,7 +1088,6 @@ private: LUTf shtonecurveloc(65536, 0); LUTf tonecurveloc(65536, 0); LUTf lightCurveloc(32770, 0); - LUTu lhist16loc(32770, 0); LUTf exlocalcurve(65536, 0); // int maxspot = 1; @@ -1143,11 +1142,11 @@ private: double huere, chromare, lumare, huerefblu, chromarefblu, lumarefblu, sobelre; float avg = 0.f; if (params.locallab.spots.at(sp).spotMethod == "exc") { - ipf.calc_ref(0, sp, reservView, reservView, 0, 0, fw, fh, 1, huerefblu, chromarefblu, lumarefblu, huere, chromare, lumare, sobelre, lhist16loc, avg); + ipf.calc_ref(0, sp, reservView, reservView, 0, 0, fw, fh, 1, huerefblu, chromarefblu, lumarefblu, huere, chromare, lumare, sobelre, avg); } else { - ipf.calc_ref(0, sp, labView, labView, 0, 0, fw, fh, 1, huerefblu, chromarefblu, lumarefblu, huere, chromare, lumare, sobelre, lhist16loc, avg); + ipf.calc_ref(0, sp, labView, labView, 0, 0, fw, fh, 1, huerefblu, chromarefblu, lumarefblu, huere, chromare, lumare, sobelre, avg); } - CurveFactory::complexCurvelocal(ecomp, black / 65535., hlcompr, hlcomprthresh, shcompr, br, cont, lhist16loc, lumare, + CurveFactory::complexCurvelocal(ecomp, black / 65535., hlcompr, hlcomprthresh, shcompr, br, cont, lumare, hltonecurveloc, shtonecurveloc, tonecurveloc, lightCurveloc, avg, 1);