From 932d022f8e0e04277182ef48b2edf0ccbce3b8bd Mon Sep 17 00:00:00 2001 From: Desmis Date: Fri, 15 Feb 2019 08:27:47 +0100 Subject: [PATCH] Improve chroma compensation in exposure - suppress compilation warning --- rtengine/improcfun.h | 2 +- rtengine/iplocallab.cc | 47 ++++++++++++++++-------------------------- rtengine/procparams.cc | 2 +- rtgui/locallab.cc | 2 +- 4 files changed, 21 insertions(+), 32 deletions(-) diff --git a/rtengine/improcfun.h b/rtengine/improcfun.h index 1a1fb8b31..ac5480e9d 100644 --- a/rtengine/improcfun.h +++ b/rtengine/improcfun.h @@ -300,7 +300,7 @@ public: void vibrancelocal(int sp, int bfw, int bfh, LabImage* lab, LabImage* dest, bool & localskutili, LUTf & sklocalcurve); void transit_shapedetect(int senstype, LabImage * bufexporig, LabImage * originalmask, float **buflight, float **bufchro, float **buf_a_cat, float ** buf_b_cat, float ** bufhh, bool HHutili, const float hueref, const float chromaref, const float lumaref, float sobelref, float meansobel, float ** blend2, const struct local_params & lp, LabImage * original, LabImage * transformed, int cx, int cy, int sk); void exlabLocal(const local_params& lp, int bfh, int bfw, LabImage* bufexporig, LabImage* lab, LUTf & hltonecurve, LUTf & shtonecurve, LUTf & tonecurve); - void Exclude_Local(int sen, float **deltaso, float **buflight, float **bufchro, const float hueref, const float chromaref, const float lumaref, float sobelref, float meansobel, const struct local_params & lp, LabImage * original, LabImage * transformed, LabImage * rsv, LabImage * reserv, int cx, int cy, int sk); + void Exclude_Local(int sen, float **deltaso, const float hueref, const float chromaref, const float lumaref, float sobelref, float meansobel, const struct local_params & lp, LabImage * original, LabImage * transformed, LabImage * rsv, LabImage * reserv, int cx, int cy, int sk); void DeNoise_Local(int call, const struct local_params& lp, int levred, float hueref, float lumaref, float chromaref, LabImage* original, LabImage* transformed, LabImage &tmp1, int cx, int cy, int sk); diff --git a/rtengine/iplocallab.cc b/rtengine/iplocallab.cc index d555e614f..2e387b70b 100644 --- a/rtengine/iplocallab.cc +++ b/rtengine/iplocallab.cc @@ -3330,7 +3330,7 @@ void ImProcFunctions::Sharp_Local(int call, float **loctemp, int senstype, cons -void ImProcFunctions::Exclude_Local(int sen, float **deltaso, float **buflight, float **bufchro, const float hueref, const float chromaref, const float lumaref, float sobelref, float meansobel, const struct local_params & lp, LabImage * original, LabImage * transformed, LabImage * rsv, LabImage * reserv, int cx, int cy, int sk) +void ImProcFunctions::Exclude_Local(int sen, float **deltaso, const float hueref, const float chromaref, const float lumaref, float sobelref, float meansobel, const struct local_params & lp, LabImage * original, LabImage * transformed, LabImage * rsv, LabImage * reserv, int cx, int cy, int sk) { BENCHFUN { @@ -4147,30 +4147,6 @@ void ImProcFunctions::InverseColorLight_Local(int sp, int senstype, const struct if (senstype == 1) { //exposure temp = new LabImage(GW, GH); float chprosl = 0.f; - /* - if (lp.expchroma != 0.f) { - float ch; - float ampli = 70.f; - ch = (1.f + 0.03f * lp.expchroma) ; - - if (ch <= 1.f) {//convert data curve near values of slider -100 + 100, to be used after to detection shape - chprosl = 99.f * ch - 99.f; - } else { - chprosl = CLIPCHRO(ampli * ch - ampli); //ampli = 25.f arbitrary empirical coefficient between 5 and 50 - } - #ifdef _OPENMP - #pragma omp parallel for schedule(dynamic,16) - #endif - - for (int y = 0; y < transformed->H; y++) { - for (int x = 0; x < transformed->W; x++) { - original->a[y][x] *= 0.01f * (100.f + 100.f * chprosl); - } - } - } - - // } - */ ImProcFunctions::exlabLocal(lp, GH, GW, original, temp, hltonecurveloc, shtonecurveloc, tonecurveloc); @@ -4205,8 +4181,15 @@ void ImProcFunctions::InverseColorLight_Local(int sp, int senstype, const struct for (int y = 0; y < transformed->H; y++) { for (int x = 0; x < transformed->W; x++) { - temp->a[y][x] *= 0.01f * (100.f + 100.f * chprosl); - temp->b[y][x] *= 0.01f * (100.f + 100.f * chprosl); + float epsi = 0.f; + + if (original->L[y][x] == 0.f) { + epsi = 0.001f; + } + + float rapexp = temp->L[y][x] / (original->L[y][x] + epsi); + temp->a[y][x] *= 0.01f * (100.f + 100.f * chprosl * rapexp); + temp->b[y][x] *= 0.01f * (100.f + 100.f * chprosl * rapexp); } } } @@ -5263,7 +5246,7 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o bufchro[ir][jr] = rch ; } - Exclude_Local(1, deltasobelL->L, buflight, bufchro, hueref, chromaref, lumaref, sobelref, meansob, lp, original, transformed, bufreserv, reserved, cx, cy, sk); + Exclude_Local(1, deltasobelL->L, hueref, chromaref, lumaref, sobelref, meansob, lp, original, transformed, bufreserv, reserved, cx, cy, sk); delete deltasobelL; @@ -7885,6 +7868,7 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o for (int x = 0; x < transformed->W; x++) { int lox = cx + x; int loy = cy + y; + float epsi = 0.f; if (lox >= begx && lox < xEn && loy >= begy && loy < yEn) { if (lp.expchroma != 0.f) { @@ -7898,7 +7882,12 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o chprosl = CLIPCHRO(ampli * ch - ampli); //ampli = 25.f arbitrary empirical coefficient between 5 and 50 } - bufl_ab[loy - begy][lox - begx] = chprosl; + if (bufexporig->L[loy - begy][lox - begx] == 0.f) { + epsi = 0.001f; + } + + float rapexp = bufcat02fin->L[loy - begy][lox - begx] / (bufexporig->L[loy - begy][lox - begx] + epsi); + bufl_ab[loy - begy][lox - begx] = chprosl * rapexp; } diff --git a/rtengine/procparams.cc b/rtengine/procparams.cc index 44050bc9e..dde54c1a8 100644 --- a/rtengine/procparams.cc +++ b/rtengine/procparams.cc @@ -2383,7 +2383,7 @@ LocallabParams::LocallabSpot::LocallabSpot() : hlcomprthresh(33), black(0), shcompr(50), - expchroma(0), + expchroma(30), warm(0), sensiex(15), structexp(0), diff --git a/rtgui/locallab.cc b/rtgui/locallab.cc index 21feda668..206ab9725 100644 --- a/rtgui/locallab.cc +++ b/rtgui/locallab.cc @@ -86,7 +86,7 @@ Locallab::Locallab(): hlcomprthresh(Gtk::manage(new Adjuster(M("TP_EXPOSURE_COMPRHIGHLIGHTSTHRESHOLD"), 0, 100, 1, 33))), black(Gtk::manage(new Adjuster(M("TP_EXPOSURE_BLACKLEVEL"), -16384, 32768, 50, 0))), shcompr(Gtk::manage(new Adjuster(M("TP_EXPOSURE_COMPRSHADOWS"), 0, 100, 1, 50))), - expchroma(Gtk::manage(new Adjuster(M("TP_LOCALLAB_EXPCHROMA"), -50, 100, 1, 0))), + expchroma(Gtk::manage(new Adjuster(M("TP_LOCALLAB_EXPCHROMA"), -50, 100, 1, 30))), warm(Gtk::manage(new Adjuster(M("TP_LOCALLAB_WARM"), -100., 100., 1., 0., Gtk::manage(new RTImage("circle-blue-small.png")), Gtk::manage(new RTImage("circle-orange-small.png"))))), sensiex(Gtk::manage(new Adjuster(M("TP_LOCALLAB_SENSI"), 0, 100, 1, 15))), structexp(Gtk::manage(new Adjuster(M("TP_LOCALLAB_STRUCCOL"), 0, 100, 1, 0))),