diff --git a/rtengine/iplocallab.cc b/rtengine/iplocallab.cc index 2720a1e0f..9cd51e181 100644 --- a/rtengine/iplocallab.cc +++ b/rtengine/iplocallab.cc @@ -2273,8 +2273,8 @@ void ImProcFunctions::transit_shapedetect_retinex(int senstype, LabImage * bufex const float refa = chromaref * cos(hueref); const float refb = chromaref * sin(hueref); - const bool retishow = ((lp.showmaskretimet == 1 || lp.showmaskretimet == 2) && senstype == 4); - const bool previewreti = ((lp.showmaskretimet == 4) && senstype == 4); + const bool retishow = ((lp.showmaskretimet == 1 || lp.showmaskretimet == 2)); + const bool previewreti = ((lp.showmaskretimet == 4)); //balance deltaE float kL = lp.balance; @@ -2353,7 +2353,7 @@ void ImProcFunctions::transit_shapedetect_retinex(int senstype, LabImage * bufex // reducdE /= 100.f; // cli *= reducdE; - clc *= reducdE; + clc *= reducdE / 100.f; if (rL > 0.1f) { //to avoid crash with very low gamut in rare cases ex : L=0.01 a=0.5 b=-0.9 if (senstype == 4) {//all except color and light (TODO) and exposure @@ -2373,9 +2373,9 @@ void ImProcFunctions::transit_shapedetect_retinex(int senstype, LabImage * bufex const float chra = bufexporig->a[loy - begy][lox - begx]; const float chrb = bufexporig->b[loy - begy][lox - begx]; - if (senstype == 4) { + // if (senstype == 4) { fliab = 1.f + clc; - } + // } const float difa = (chra * fliab - original->a[y][x]) * localFactor; const float difb = (chrb * fliab - original->b[y][x]) * localFactor; @@ -2392,7 +2392,7 @@ void ImProcFunctions::transit_shapedetect_retinex(int senstype, LabImage * bufex } if(previewreti) { transformed->a[y][x] = 0.f; - transformed->b[y][x] = difb; + transformed->b[y][x] = CLIPC(difb); } } } @@ -4901,7 +4901,7 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o float meanfab, fab; mean_fab(xstart, ystart, bfw, bfh, loctemp.get(), original, fab, meanfab, lp.chromacbm); - printf("fab=%f lpchro=%f \n", fab, lp.chromacbm); + // printf("fab=%f lpchro=%f \n", fab, lp.chromacbm); #ifdef _OPENMP #pragma omp parallel for schedule(dynamic,16) diff --git a/rtengine/ipretinex.cc b/rtengine/ipretinex.cc index 1b6e09ffe..651604d85 100644 --- a/rtengine/ipretinex.cc +++ b/rtengine/ipretinex.cc @@ -53,6 +53,7 @@ #define clipretinex( val, minv, maxv ) (( val = (val < minv ? minv : val ) ) > maxv ? maxv : val ) #define CLIPLOC(x) LIM(x,0.f,32767.f) +#define CLIPC(a) LIM(a, -42000.f, 42000.f) // limit a and b to 130 probably enough ? namespace { @@ -1095,7 +1096,7 @@ void ImProcFunctions::MSRLocal(int sp, int lum, LabImage * bufreti, LabImage * b kmaskLexp += 32768.f * valHH; } // printf("km=%f ",kmaskLexp); - bufmaskblurreti->L[ir][jr] = CLIPLOC(kmaskLexp); + bufmaskblurreti->L[ir][jr] = kmaskLexp; bufmaskblurreti->a[ir][jr] = kmaskCH; bufmaskblurreti->b[ir][jr] = kmaskCH; ble[ir][jr] = bufmaskblurreti->L[ir][jr] / 32768.f; @@ -1146,11 +1147,15 @@ void ImProcFunctions::MSRLocal(int sp, int lum, LabImage * bufreti, LabImage * b out[y][x] += fabs(modr) * bufmaskorigreti->L[y][x]; out[y][x] = LIM(out[y][x],0.f,60000.f); } else { - bufreti->L[y][x] += bufmaskorigreti->L[y][x] * modr; + bufreti->L[y][x] += bufmaskorigreti->L[y][x] * modr; + bufreti->L[y][x] = CLIPLOC(bufreti->L[y][x]); + } bufreti->a[y][x] *= (1.f + bufmaskorigreti->a[y][x] * modr * (1.f + 0.01f * loc.spots.at(sp).chromaskreti)); bufreti->b[y][x] *= (1.f + bufmaskorigreti->b[y][x] * modr * (1.f + 0.01f * loc.spots.at(sp).chromaskreti)); + bufreti->a[y][x] = CLIPC(bufreti->a[y][x]); + bufreti->b[y][x] = CLIPC(bufreti->b[y][x]); } } } @@ -1163,8 +1168,8 @@ void ImProcFunctions::MSRLocal(int sp, int lum, LabImage * bufreti, LabImage * b for (int y = 0; y < H_L; y++) { for (int x = 0; x < W_L; x++) { bufmask->L[y][x] = 6000.f + CLIPLOC(bufmaskorigreti->L[y][x]); - bufmask->a[y][x] = bufreti->a[y][x] * bufmaskorigreti->a[y][x]; - bufmask->b[y][x] = bufreti->b[y][x] * bufmaskorigreti->b[y][x]; + bufmask->a[y][x] = CLIPC(bufreti->a[y][x] * bufmaskorigreti->a[y][x]); + bufmask->b[y][x] = CLIPC(bufreti->b[y][x] * bufmaskorigreti->b[y][x]); } } diff --git a/rtgui/locallab.cc b/rtgui/locallab.cc index 099b4f018..061d6242a 100644 --- a/rtgui/locallab.cc +++ b/rtgui/locallab.cc @@ -894,7 +894,7 @@ Locallab::Locallab(): showmaskretiMethod->append(M("TP_LOCALLAB_SHOWMODIF")); showmaskretiMethod->append(M("TP_LOCALLAB_SHOWMODIFMASK")); showmaskretiMethod->append(M("TP_LOCALLAB_SHOWMASK")); -// showmaskretiMethod->append(M("TP_LOCALLAB_PREVIEWSEL")); + showmaskretiMethod->append(M("TP_LOCALLAB_PREVIEWSEL")); showmaskretiMethod->set_active(0);