diff --git a/rtengine/dcrop.cc b/rtengine/dcrop.cc index 28a562462..6b9da8492 100644 --- a/rtengine/dcrop.cc +++ b/rtengine/dcrop.cc @@ -1234,7 +1234,7 @@ void Crop::update (int todo) parent->ipf.Lab_Local (1, (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, params.locallab.hueref, params.locallab.chromaref, params.locallab.lumaref); + loclhCurve, lochhCurve, LHutili, HHutili, cclocalcurve2, localskutili, sklocalcurve2, localexutili, exlocalcurve2, hltonecurveloc2, shtonecurveloc2, tonecurveloc2, params.locallab.hueref, params.locallab.chromaref, params.locallab.lumaref, params.locallab.sobelref); lllocalcurve2.clear(); cclocalcurve2.clear(); sklocalcurve2.clear(); @@ -1619,7 +1619,7 @@ void Crop::update (int todo) params.locallab.lumaref = parent->lumarefs[sp]; params.locallab.sobelref = parent->sobelrefs[sp]; parent->ipf.Lab_Local (1, (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, params.locallab.hueref, params.locallab.chromaref, params.locallab.lumaref); + LHutili, HHutili, cclocalcurve2, localskutili, sklocalcurve2, localexutili, exlocalcurve2, hltonecurveloc2, shtonecurveloc2, tonecurveloc2, params.locallab.hueref, params.locallab.chromaref, params.locallab.lumaref, params.locallab.sobelref); lllocalcurve2.clear(); cclocalcurve2.clear(); diff --git a/rtengine/improccoordinator.cc b/rtengine/improccoordinator.cc index 2bb516434..60082ac40 100644 --- a/rtengine/improccoordinator.cc +++ b/rtengine/improccoordinator.cc @@ -2644,7 +2644,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) dataspot[maxdata - 1][sp] = sobelrefs[sp] = params.locallab.sobelref; //printf("sp=%i huerefsp=%f\n", sp, huerefs[sp]); ipf.Lab_Local (3, (float**)shbuffer, nprevl, nprevl, reserv, 0, 0, pW, pH, scale, locRETgainCurve, lllocalcurve, loclhCurve, lochhCurve, - LHutili, HHutili, cclocalcurve, localskutili, sklocalcurve, localexutili, exlocalcurve, hltonecurveloc, shtonecurveloc, tonecurveloc, params.locallab.hueref, params.locallab.chromaref, params.locallab.lumaref); + LHutili, HHutili, cclocalcurve, localskutili, sklocalcurve, localexutili, exlocalcurve, hltonecurveloc, shtonecurveloc, tonecurveloc, params.locallab.hueref, params.locallab.chromaref, params.locallab.lumaref, params.locallab.sobelref); lllocalcurve.clear(); cclocalcurve.clear(); sklocalcurve.clear(); @@ -3182,7 +3182,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) params.locallab.sobelref = sobelrefs[sp]; ipf.Lab_Local (3, (float**)shbuffer, nprevl, nprevl, reserv, 0, 0, pW, pH, scale, locRETgainCurve, lllocalcurve, loclhCurve, lochhCurve, LHutili, HHutili, cclocalcurve, - localskutili, sklocalcurve, localexutili, exlocalcurve, hltonecurveloc, shtonecurveloc, tonecurveloc, params.locallab.hueref, params.locallab.chromaref, params.locallab.lumaref); + localskutili, sklocalcurve, localexutili, exlocalcurve, hltonecurveloc, shtonecurveloc, tonecurveloc, params.locallab.hueref, params.locallab.chromaref, params.locallab.lumaref, params.locallab.sobelref); lllocalcurve.clear(); cclocalcurve.clear(); sklocalcurve.clear(); diff --git a/rtengine/improcfun.cc b/rtengine/improcfun.cc index 2cd1918c6..a21ec7dcd 100644 --- a/rtengine/improcfun.cc +++ b/rtengine/improcfun.cc @@ -6368,81 +6368,81 @@ SSEFUNCTION void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBu //void ImProcFunctions::colorCurve (LabImage* lold, LabImage* lnew) //{ - /* LUT cmultiplier(181021); +/* LUT cmultiplier(181021); - double boost_a = ((float)params->colorBoost.amount + 100.0) / 100.0; - double boost_b = ((float)params->colorBoost.amount + 100.0) / 100.0; + double boost_a = ((float)params->colorBoost.amount + 100.0) / 100.0; + double boost_b = ((float)params->colorBoost.amount + 100.0) / 100.0; - double c, amul = 1.0, bmul = 1.0; - if (boost_a > boost_b) { - c = boost_a; - if (boost_a > 0) - bmul = boost_b / boost_a; - } - else { - c = boost_b; - if (boost_b > 0) - amul = boost_a / boost_b; + double c, amul = 1.0, bmul = 1.0; + if (boost_a > boost_b) { + c = boost_a; + if (boost_a > 0) + bmul = boost_b / boost_a; + } + else { + c = boost_b; + if (boost_b > 0) + amul = boost_a / boost_b; + } + + if (params->colorBoost.enable_saturationlimiter && c>1.0) { + // re-generate color multiplier lookup table + double d = params->colorBoost.saturationlimit / 3.0; + double alpha = 0.5; + double threshold1 = alpha * d; + double threshold2 = c*d*(alpha+1.0) - d; + for (int i=0; i<=181020; i++) { // lookup table stores multipliers with a 0.25 chrominance resolution + double chrominance = (double)i/4.0; + if (chrominance < threshold1) + cmultiplier[i] = c; + else if (chrominance < d) + cmultiplier[i] = (c / (2.0*d*(alpha-1.0)) * (chrominance-d)*(chrominance-d) + c*d/2.0 * (alpha+1.0) ) / chrominance; + else if (chrominance < threshold2) + cmultiplier[i] = (1.0 / (2.0*d*(c*(alpha+1.0)-2.0)) * (chrominance-d)*(chrominance-d) + c*d/2.0 * (alpha+1.0) ) / chrominance; + else + cmultiplier[i] = 1.0; } + } - if (params->colorBoost.enable_saturationlimiter && c>1.0) { - // re-generate color multiplier lookup table - double d = params->colorBoost.saturationlimit / 3.0; - double alpha = 0.5; - double threshold1 = alpha * d; - double threshold2 = c*d*(alpha+1.0) - d; - for (int i=0; i<=181020; i++) { // lookup table stores multipliers with a 0.25 chrominance resolution - double chrominance = (double)i/4.0; - if (chrominance < threshold1) - cmultiplier[i] = c; - else if (chrominance < d) - cmultiplier[i] = (c / (2.0*d*(alpha-1.0)) * (chrominance-d)*(chrominance-d) + c*d/2.0 * (alpha+1.0) ) / chrominance; - else if (chrominance < threshold2) - cmultiplier[i] = (1.0 / (2.0*d*(c*(alpha+1.0)-2.0)) * (chrominance-d)*(chrominance-d) + c*d/2.0 * (alpha+1.0) ) / chrominance; - else - cmultiplier[i] = 1.0; + float eps = 0.001; + double shift_a = params->colorShift.a + eps, shift_b = params->colorShift.b + eps; + + float** oa = lold->a; + float** ob = lold->b; + + #pragma omp parallel for if (multiThread) + for (int i=0; iH; i++) + for (int j=0; jW; j++) { + + double wanted_c = c; + if (params->colorBoost.enable_saturationlimiter && c>1) { + float chroma = (float)(4.0 * sqrt((oa[i][j]+shift_a)*(oa[i][j]+shift_a) + (ob[i][j]+shift_b)*(ob[i][j]+shift_b))); + wanted_c = cmultiplier [chroma]; } - } - float eps = 0.001; - double shift_a = params->colorShift.a + eps, shift_b = params->colorShift.b + eps; - - float** oa = lold->a; - float** ob = lold->b; - - #pragma omp parallel for if (multiThread) - for (int i=0; iH; i++) - for (int j=0; jW; j++) { - - double wanted_c = c; - if (params->colorBoost.enable_saturationlimiter && c>1) { - float chroma = (float)(4.0 * sqrt((oa[i][j]+shift_a)*(oa[i][j]+shift_a) + (ob[i][j]+shift_b)*(ob[i][j]+shift_b))); - wanted_c = cmultiplier [chroma]; + double real_c = wanted_c; + if (wanted_c >= 1.0 && params->colorBoost.avoidclip) { + double cclip = 100000.0; + double cr = tightestroot ((double)lnew->L[i][j]/655.35, (double)(oa[i][j]+shift_a)*amul, (double)(ob[i][j]+shift_b)*bmul, 3.079935, -1.5371515, -0.54278342); + double cg = tightestroot ((double)lnew->L[i][j]/655.35, (double)(oa[i][j]+shift_a)*amul, (double)(ob[i][j]+shift_b)*bmul, -0.92123418, 1.87599, 0.04524418); + double cb = tightestroot ((double)lnew->L[i][j]/655.35, (double)(oa[i][j]+shift_a)*amul, (double)(ob[i][j]+shift_b)*bmul, 0.052889682, -0.20404134, 1.15115166); + if (cr>1.0 && cr1.0 && cg1.0 && cb= 1.0 && params->colorBoost.avoidclip) { - double cclip = 100000.0; - double cr = tightestroot ((double)lnew->L[i][j]/655.35, (double)(oa[i][j]+shift_a)*amul, (double)(ob[i][j]+shift_b)*bmul, 3.079935, -1.5371515, -0.54278342); - double cg = tightestroot ((double)lnew->L[i][j]/655.35, (double)(oa[i][j]+shift_a)*amul, (double)(ob[i][j]+shift_b)*bmul, -0.92123418, 1.87599, 0.04524418); - double cb = tightestroot ((double)lnew->L[i][j]/655.35, (double)(oa[i][j]+shift_a)*amul, (double)(ob[i][j]+shift_b)*bmul, 0.052889682, -0.20404134, 1.15115166); - if (cr>1.0 && cr1.0 && cg1.0 && cba[i][j] = LIM(nna,-32000.0f,32000.0f); - lnew->b[i][j] = LIM(nnb,-32000.0f,32000.0f); } - */ - //delete [] cmultiplier; + + float nna = ((oa[i][j]+shift_a) * real_c * amul); + float nnb = ((ob[i][j]+shift_b) * real_c * bmul); + lnew->a[i][j] = LIM(nna,-32000.0f,32000.0f); + lnew->b[i][j] = LIM(nnb,-32000.0f,32000.0f); + } +*/ +//delete [] cmultiplier; //} void ImProcFunctions::impulsedenoise (LabImage* lab) diff --git a/rtengine/improcfun.h b/rtengine/improcfun.h index 35d8648df..e21d13629 100644 --- a/rtengine/improcfun.h +++ b/rtengine/improcfun.h @@ -62,8 +62,8 @@ class ImProcFunctions void calcVignettingParams (int oW, int oH, const VignettingParams& vignetting, double &w2, double &h2, double& maxRadius, double &v, double &b, double &mul); void transformLuminanceOnly (Imagefloat* original, Imagefloat* transformed, int cx, int cy, int oW, int oH, int fW, int fH); - void transformGeneral(bool highQuality, Imagefloat *original, Imagefloat *transformed, int cx, int cy, int sx, int sy, int oW, int oH, int fW, int fH, const LensCorrection *pLCPMap); - void transformLCPCAOnly(Imagefloat *original, Imagefloat *transformed, int cx, int cy, const LensCorrection *pLCPMap); + void transformGeneral (bool highQuality, Imagefloat *original, Imagefloat *transformed, int cx, int cy, int sx, int sy, int oW, int oH, int fW, int fH, const LensCorrection *pLCPMap); + void transformLCPCAOnly (Imagefloat *original, Imagefloat *transformed, int cx, int cy, const LensCorrection *pLCPMap); void sharpenHaloCtrl (float** luminance, float** blurmap, float** base, int W, int H, const SharpeningParams &sharpenParam); void sharpenHaloCtrl (LabImage* lab, float** blurmap, float** base, int W, int H, SharpeningParams &sharpenParam); @@ -288,10 +288,11 @@ public: int pitch, int scale, const int luma, const int chroma/*, LUTf & Lcurve, LUTf & abcurve*/ ); //locallab void MSRLocal (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 (LabImage* original, LabImage* transformed, int cx, int cy, int oW, int oH, int sk, double &huere, double &chromare, double &lumare, double &sobelref); void calc_ref (LabImage* original, LabImage* transformed, int cx, int cy, int oW, int oH, int sk, 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, 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, double &hueref, double &chromaref, double &lumaref); + void Lab_Local (int call, 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, 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); @@ -306,7 +307,7 @@ public: void vibrancelocal (int bfw, int bfh, LabImage* lab, LabImage* dest, bool & localskutili, LUTf & sklocalcurve); void Expose_Local (int sen, 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); 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 **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, LabImage * rsv, int cx, int cy); + void Exclude_Local (int sen, float **deltaso, 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, LabImage * rsv, int cx, int cy); void DeNoise_Local (int call, const struct local_params& lp, LabImage* original, LabImage* transformed, const LabImage &tmp1, int cx, int cy); diff --git a/rtengine/iplocallab.cc b/rtengine/iplocallab.cc index 5b5447d0c..3e273aece 100644 --- a/rtengine/iplocallab.cc +++ b/rtengine/iplocallab.cc @@ -289,6 +289,14 @@ static void SobelCannyLuma (float **sobelL, float **deltasobelL, float **luma, i } delete [] tmLBuffer; + /* + //mean to exclude litlle values + for (int y = 1; y < bfh - 1 ; y++) { + for (int x = 1; x < bfw - 1 ; x++) { + sobelL[y][x] = (sobelL[y - 1][x - 1] + sobelL[y - 1][x] + sobelL[y - 1][x + 1] + sobelL[y][x - 1] + sobelL[y][x] + sobelL[y][x + 1] + sobelL[y + 1][x - 1] + sobelL[y + 1][x] + sobelL[y + 1][x + 1]) / 9; + } + } + */ } @@ -4105,7 +4113,8 @@ void ImProcFunctions::Sharp_Local (int call, float **loctemp, const float hueplu } -void ImProcFunctions::Exclude_Local (int sen, 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, LabImage * rsv, int cx, int cy) + +void ImProcFunctions::Exclude_Local (int sen, float **deltaso, 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, LabImage * rsv, int cx, int cy) { //local exposure @@ -4464,7 +4473,12 @@ void ImProcFunctions::Exclude_Local (int sen, float **buflight, float **bufchro, difL *= factorx * (100.f + realstr * falL) / 100.f; difL *= kch * fach; - transformed->L[y][x] = original->L[y][x] + difL; + if (deltaso[loy - begy][lox - begx] == 0.f) { + transformed->L[y][x] = original->L[y][x]; //orsv->L[loy - begy][lox - begx]; + } else { + transformed->L[y][x] = original->L[y][x] + difL; + } + float difa, difb; difa = rsv->a[loy - begy][lox - begx] - original->a[y][x]; @@ -4473,9 +4487,14 @@ void ImProcFunctions::Exclude_Local (int sen, float **buflight, float **bufchro, difb *= factorx * (100.f + realstrch * falu * falL) / 100.f; difa *= kch * fach; difb *= kch * fach; - transformed->a[y][x] = CLIPC (original->a[y][x] + difa); - transformed->b[y][x] = CLIPC (original->b[y][x] + difb); + if (deltaso[loy - begy][lox - begx] == 0.f) { + transformed->a[y][x] = original->a[y][x]; //rsv->a[loy - begy][lox - begx]; + transformed->b[y][x] = original->b[y][x]; //rsv->b[loy - begy][lox - begx]; + } else { + transformed->a[y][x] = CLIPC (original->a[y][x] + difa); + transformed->b[y][x] = CLIPC (original->b[y][x] + difb); + } break; @@ -4487,7 +4506,15 @@ void ImProcFunctions::Exclude_Local (int sen, float **buflight, float **bufchro, difL = rsv->L[loy - begy][lox - begx] - original->L[y][x]; difL *= (100.f + realstr * falL) / 100.f; difL *= kch * fach; - transformed->L[y][x] = original->L[y][x] + difL; + + if (deltaso[loy - begy][lox - begx] == 0.f) { + // printf ("0"); + transformed->L[y][x] = original->L[y][x]; //rsv->L[loy - begy][lox - begx]; + } else { + transformed->L[y][x] = original->L[y][x] + difL; + } + + // transformed->L[y][x] = original->L[y][x] + difL; float difa, difb; difa = rsv->a[loy - begy][lox - begx] - original->a[y][x]; @@ -4497,8 +4524,15 @@ void ImProcFunctions::Exclude_Local (int sen, float **buflight, float **bufchro, difa *= kch * fach; difb *= kch * fach; - transformed->a[y][x] = CLIPC (original->a[y][x] + difa); - transformed->b[y][x] = CLIPC (original->b[y][x] + difb); + if (deltaso[loy - begy][lox - begx] == 0.f) { + // printf ("0"); + transformed->a[y][x] = original->a[y][x]; //rsv->a[loy - begy][lox - begx]; + transformed->b[y][x] = original->b[y][x]; //rsv->b[loy - begy][lox - begx]; + } else { + // printf ("1"); + transformed->a[y][x] = CLIPC (original->a[y][x] + difa); + transformed->b[y][x] = CLIPC (original->b[y][x] + difb); + } } } @@ -5747,6 +5781,7 @@ void ImProcFunctions::InverseColorLight_Local (const struct local_params & lp, L } } + void ImProcFunctions::calc_ref (LabImage * original, LabImage * transformed, int cx, int cy, int oW, int oH, int sk, double & hueref, double & chromaref, double & lumaref, double &sobelref) { if (params->locallab.enabled) { @@ -5942,7 +5977,7 @@ void ImProcFunctions::paste_ref (LabImage * spotbuffer, LabImage * transformed, void ImProcFunctions::Lab_Local (int call, 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, double & hueref, double & chromaref, double & lumaref) + bool &LHutili, bool &HHutili, LUTf & cclocalcurve, bool & localskutili, LUTf & sklocalcurve, bool & localexutili, LUTf & exlocalcurve, LUTf & hltonecurveloc, LUTf & shtonecurveloc, LUTf & tonecurveloc, double & hueref, double & chromaref, double & lumaref, double &sobelref) { //general call of others functions : important return hueref, chromaref, lumaref if (params->locallab.enabled) { @@ -5960,7 +5995,7 @@ void ImProcFunctions::Lab_Local (int call, float** shbuffer, LabImage * original calcLocalParams (oW, oH, params->locallab, lp); const float radius = lp.rad / (sk * 1.4f); //0 to 70 ==> see skip - // float radiussob = 3.f / (sk * 1.4f); //0 to 70 ==> see skip + float radiussob = lp.strucc / (sk * 1.4f); //0 to 70 ==> see skip //printf("radiussob=%f rad=%f sk=%i\n", radiussob, lp.rad, sk); double ave = 0.; int n = 0; @@ -6128,10 +6163,329 @@ void ImProcFunctions::Lab_Local (int call, float** shbuffer, LabImage * original tmpsob = new LabImage (bfw, bfh); deltasobelL = new LabImage (bfw, bfh); - // SobelCannyLuma (tmpsob->L, deltasobelL->L, bufsob->L, bfw, bfh, radiussob); - //todo use of tmpsob and deltasobelL - shape detection + SobelCannyLuma (tmpsob->L, deltasobelL->L, bufsob->L, bfw, bfh, radiussob); +#ifdef _OPENMP + #pragma omp parallel for +#endif + + for (int ir = 0; ir < bfh; ir++) //fill with 0 + for (int jr = 0; jr < bfw; jr++) { + deltasobelL->L[ir][jr] = 1.f; + } + + bool titi = false; + + if (titi) { + + // if (lp.strucc > 0.f) { + // if (titi) { + //todo use of tmpsob and deltasobelL - shape detection + // float epsxy = 0.001f; + //first quarter superior + buflight = new float*[bfh]; + + for (int i = 0; i < bfh; i++) { + buflight[i] = new float[bfw]; + } + + int Xo = ceil (-lp.lxL); + int Xe = ceil (lp.lx); + // int Yo = ceil (-lp.ly); + int Ye = ceil (lp.lyT); + + int XR = max (-Xo, Xe); + float **val = nullptr; + int rr = sqrt (SQR (XR) + SQR (Ye)) + 3; + + val = new float*[xEn - begx + 3]; + + for (int i = 0; i < (xEn - begx + 3); i++) { + val[i] = new float[rr]; + } + + float *rad = nullptr; + rad = new float[xEn - begx + 3]; + float *radlim = nullptr; + radlim = new float[xEn - begx + 3]; + + //second quarter left + float *valL = nullptr; + valL = new float[yEn - begy + 3]; + float *radL = nullptr; + radL = new float[yEn - begy + 3]; + + float *radlimL = nullptr; + radlimL = new float[yEn - begy + 3]; + + float2 sincosval; + + for (int w = 0; w < (xEn - begx); w++) { + rad[w] = 0.f; + radlim[w] = 0.f; + } + + for (int w = 0; w < (xEn - begx); w++) { + for (int z = 0; z < rr; z++) { + val[w][z] = 0.f; + } + + } + + for (int w = 0; w < (yEn - begy); w++) { + radL[w] = 0.f; + radlimL[w] = 0.f; + } + + //change coordonate to XX, YY XX=x, YY=-y to can use easily trigo functions and polar coordonates + // xc yc are XX=0 YY=0 + //at the end we convert inverse + float sobelponder = 2.f * sobelref; + + if (sobelponder > 25000.f) { + sobelponder = 25000.f; + } + + + float valm = 0.f; + + /* + printf ("yT=%i xL=%i x=%i y=%i xc=%i yc=%i\n", (int)lp.lyT, (int)lp.lxL, (int)lp.lx, (int)lp.ly, (int)lp.xc, (int)lp.yc); + float tetabe1 = xatan2f (Ye, Xo ); + float tetaen1 = xatan2f (Ye, Xe); + printf ("tetbhaut1=%f tetend1=%f\n", tetabe1, tetaen1); + + float tetabe2 = xatan2f (Yo, Xo ); + float tetaen2 = xatan2f (Ye, Xo); + printf ("tetbhaut2=%f tetend2=%f\n", tetabe2, tetaen2); + */ + // int maxm = -10; + for (int XX = Xo; XX < Xe; XX++) { //first quarter superior + int m = ceil (XX - Xo); + + if (m < 0) { + m = 0; + } + + radlim[m] = sqrt (SQR (XX) + SQR (Ye)); + + float tetacur = xatan2f (Ye, XX); + // float maxval = -10000.f; + float valedge = 8000.f; + + for (int r = 0; r < radlim[m]; r++) { + sincosval = xsincosf (tetacur); + float xcur = r * sincosval.y; + float ycur = r * sincosval.x; + + int xxcur = ceil (lp.xc) + ceil (xcur) - begx; + xxcur = LIM (xxcur, 0, bfw - 1); + + int yycur = ceil (lp.yc) - ceil (ycur) - begy;// - before ceil(ycur) to convert YY ==> y + yycur = LIM (yycur, 0, bfh - 1); + valm = tmpsob->L[yycur][xxcur]; + + if (valm > valedge) { + // if(m > maxm) maxm = m; + val[m][r] = valm; + + if (XX == 0 || XX == 2) { + printf ("XX=%i m=%i r=%i val=%f \n", XX, m, r, val[m][r]); + } + } + + + + // val[maxm][r] = valedge; + + + } + } + + /* + for (int XX = Xo; XX < Xe; XX++) { //first quarter superior + int m = ceil (XX - Xo); + + if (m < 0) { + m = 0; + } + + radlim[m] = sqrt (SQR (XX) + SQR (Ye)); + + float tetacur = xatan2f (Ye, XX); + + int rf = -10; + for (int r = 0; r < radlim[m]; r++) { + sincosval = xsincosf (tetacur); + float xcur = r * sincosval.y; + float ycur = r * sincosval.x; + + int xxcur = ceil (lp.xc) + ceil (xcur) - begx; + xxcur = LIM (xxcur, 0, bfw - 1); + + int yycur = ceil (lp.yc) - ceil (ycur) - begy; + yycur = LIM (yycur, 0, bfh - 1); + float lect = tmpsob->L[yycur][xxcur]; + + if (lect == val[m][r]) { + if(r > rf) rf = r; + rad[m] = (float) rf; + } + } + } + + + for (int XX = Xo; XX < Xe; XX++) { //first quarter superior + int m = ceil (XX - Xo); + + if (m < 0) { + m = 0; + } + + radlim[m] = sqrt (SQR (XX) + SQR (Ye)); + + float tetacur = xatan2f (Ye, XX); + + + for (int r = 0; r < radlim[m]; r++) { + sincosval = xsincosf (tetacur); + float xcur = r * sincosval.y; + float ycur = r * sincosval.x; + + int xxcur = ceil (lp.xc) + ceil (xcur) - begx; + xxcur = LIM (xxcur, 0, bfw - 1); + + int yycur = ceil (lp.yc) - ceil (ycur) - begy; + yycur = LIM (yycur, 0, bfh - 1); + + if ((float) r <= rad[m]) { + deltasobelL->L[yycur][xxcur] = 1.f; + } else { + deltasobelL->L[yycur][xxcur] = 0.f; + } + } + } + */ + /* + + for (int YY = Yo; YY < Ye; YY++) { //second quarter left + int m = ceil (YY - Yo); + + if (m < 0) { + m = 0; + } + + radlimL[m] = sqrt (SQR (YY) + SQR (Xo)); + + float tetacur = xatan2f (YY, Xo); + float maxval = -10000.f; + + for (int r = 0; r < radlimL[m]; r++) { + sincosval = xsincosf (tetacur); + float xcur = r * sincosval.y; + float ycur = r * sincosval.x; + + int xxcur = ceil (lp.xc) + ceil (xcur) - begx; + xxcur = LIM (xxcur, 0, bfw - 1); + + int yycur = ceil (lp.yc) - ceil (ycur) - begy; + yycur = LIM (yycur, 0, bfh - 1); + valm = tmpsob->L[yycur][xxcur]; + + + if (valm > maxval) { + maxval = valm; + } + + valL[m] = maxval; + + + + } + } + + + for (int YY = Yo; YY < Ye; YY++) { //second quarter left + int m = ceil (YY - Yo); + + if (m < 0) { + m = 0; + } + + radlimL[m] = sqrt (SQR (YY) + SQR (Xo)); + + float tetacur = xatan2f (YY, Xo); + + + + for (int r = 0; r < radlimL[m]; r++) { + sincosval = xsincosf (tetacur); + float xcur = r * sincosval.y; + float ycur = r * sincosval.x; + + int xxcur = ceil (lp.xc) + ceil (xcur) - begx; + xxcur = LIM (xxcur, 0, bfw - 1); + + int yycur = ceil (lp.yc) - ceil (ycur) - begy; + yycur = LIM (yycur, 0, bfh - 1); + float lect = tmpsob->L[yycur][xxcur]; + + if (lect == valL[m]) { + radL[m] = (float) r; + } + } + } + + for (int YY = Yo; YY < Ye; YY++) { //second quarter left + int m = ceil (YY - Yo); + + if (m < 0) { + m = 0; + } + + radlimL[m] = sqrt (SQR (YY) + SQR (Xo)); + + float tetacur = xatan2f (YY, Xo); + + for (int r = 0; r < radlimL[m]; r++) { + sincosval = xsincosf (tetacur); + float xcur = r * sincosval.y; + float ycur = r * sincosval.x; + + int xxcur = ceil (lp.xc) + ceil (xcur) - begx; + xxcur = LIM (xxcur, 0, bfw - 1); + + int yycur = ceil (lp.yc) - ceil (ycur) - begy; + yycur = LIM (yycur, 0, bfh - 1); + + if ((float) r <= radL[m]) { + deltasobelL->L[yycur][xxcur] = 1.f; + } else { + deltasobelL->L[yycur][xxcur] = 0.f; + } + } + } + */ + + delete[] radlimL; + delete[] radL; + delete[] valL; + + delete[] radlim; + delete[] rad; + + for (int i = 0; i < (xEn - begx + 3); i++) { + delete [] val[i]; + } + + delete [] val; + + + } //then restore non modified area + + + #ifdef _OPENMP #pragma omp parallel for schedule(dynamic,16) #endif @@ -6197,7 +6551,7 @@ void ImProcFunctions::Lab_Local (int call, float** shbuffer, LabImage * original bufchro[ir][jr] = rch; } - Exclude_Local (1, buflight, bufchro, hueplus, huemoins, hueref, dhueex, chromaref, lumaref, lp, original, transformed, bufreserv, cx, cy); + Exclude_Local (1, deltasobelL->L, buflight, bufchro, hueplus, huemoins, hueref, dhueex, chromaref, lumaref, lp, original, transformed, bufreserv, cx, cy); delete deltasobelL; @@ -7427,8 +7781,8 @@ void ImProcFunctions::Lab_Local (int call, float** shbuffer, LabImage * original buflight[loy - begy][lox - begx] = rL; - float chp; - chp = CLIPRET ((sqrt (SQR (bufexpfin->a[loy - begy][lox - begx]) + SQR (bufexpfin->b[loy - begy][lox - begx])) - sqrt (SQR (bufexporig->a[loy - begy][lox - begx]) + SQR (bufexporig->b[loy - begy][lox - begx]))) / 250.f); + // float chp; + // chp = CLIPRET ((sqrt (SQR (bufexpfin->a[loy - begy][lox - begx]) + SQR (bufexpfin->b[loy - begy][lox - begx])) - sqrt (SQR (bufexporig->a[loy - begy][lox - begx]) + SQR (bufexporig->b[loy - begy][lox - begx]))) / 250.f); /* if (chp > maxc) { maxc = chp; @@ -7441,7 +7795,7 @@ void ImProcFunctions::Lab_Local (int call, float** shbuffer, LabImage * original // chpro = CLIPCHRO (amplil * ra - amplil); //ampli = 25.f arbitrary empirical coefficient between 5 and 50 //ra = 1.f; - bufl_ab[loy - begy][lox - begx] = chp; + // bufl_ab[loy - begy][lox - begx] = chp; } } diff --git a/rtengine/simpleprocess.cc b/rtengine/simpleprocess.cc index 2819c0662..1ab248925 100644 --- a/rtengine/simpleprocess.cc +++ b/rtengine/simpleprocess.cc @@ -1986,15 +1986,15 @@ private: double huere, chromare, lumare; double sobelre; - ipf.calc_ref (labView, labView, 0, 0, fw, fh, 1, huere, chromare, lumare, sobelre); + params.locallab.hueref = huere; params.locallab.chromaref = chromare; params.locallab.lumaref = lumare; params.locallab.sobelref = sobelre; ipf.Lab_Local (2, (float**)shbuffer, labView, labView, reservView, 0, 0, fw, fh, 1, locRETgainCurve, lllocalcurve, loclhCurve, lochhCurve, - LHutili, HHutili, cclocalcurve, localskutili, sklocalcurve, localexutili, exlocalcurve, hltonecurveloc, shtonecurveloc, tonecurveloc, params.locallab.hueref, params.locallab.chromaref, params.locallab.lumaref); + LHutili, HHutili, cclocalcurve, localskutili, sklocalcurve, localexutili, exlocalcurve, hltonecurveloc, shtonecurveloc, tonecurveloc, params.locallab.hueref, params.locallab.chromaref, params.locallab.lumaref, params.locallab.sobelref); lllocalcurve.clear(); cclocalcurve.clear(); sklocalcurve.clear(); @@ -2040,7 +2040,7 @@ private: } } - + delete reservView; reservView = nullptr; @@ -2298,8 +2298,8 @@ private: delete labView; labView = nullptr; - // delete reservView; - // reservView = nullptr; +// delete reservView; +// reservView = nullptr; if (bwonly) { //force BW r=g=b diff --git a/rtgui/locallab.cc b/rtgui/locallab.cc index cc32328e3..4c0d6c7da 100644 --- a/rtgui/locallab.cc +++ b/rtgui/locallab.cc @@ -58,16 +58,16 @@ Locallab::Locallab (): anbspot (Gtk::manage (new Adjuster (M ("TP_LOCALLAB_ANBSPOT"), 0, 1, 1, 0))), - locX (Gtk::manage (new Adjuster (M ("TP_LOCAL_WIDTH"), 0, 1500, 1, 250))), - locXL (Gtk::manage (new Adjuster (M ("TP_LOCAL_WIDTH_L"), 0, 1500, 1, 250))), + locX (Gtk::manage (new Adjuster (M ("TP_LOCAL_WIDTH"), 0, 2250, 1, 250))), + locXL (Gtk::manage (new Adjuster (M ("TP_LOCAL_WIDTH_L"), 0, 2250, 1, 250))), degree (Gtk::manage (new Adjuster (M ("TP_LOCAL_DEGREE"), -180, 180, 1, 0))), - locY (Gtk::manage (new Adjuster (M ("TP_LOCAL_HEIGHT"), 0, 1500, 1, 250))), - locYT (Gtk::manage (new Adjuster (M ("TP_LOCAL_HEIGHT_T"), 0, 1500, 1, 250))), + locY (Gtk::manage (new Adjuster (M ("TP_LOCAL_HEIGHT"), 0, 2250, 1, 250))), + locYT (Gtk::manage (new Adjuster (M ("TP_LOCAL_HEIGHT_T"), 0, 2250, 1, 250))), centerX (Gtk::manage (new Adjuster (M ("TP_LOCALLAB_CENTER_X"), -1000, 1000, 1, 0))), centerY (Gtk::manage (new Adjuster (M ("TP_LOCALLAB_CENTER_Y"), -1000, 1000, 1, 0))), circrad (Gtk::manage (new Adjuster (M ("TP_LOCALLAB_CIRCRADIUS"), 2, 150, 1, 18))), sensiexclu (Gtk::manage (new Adjuster (M ("TP_LOCALLAB_SENSIEXCLU"), 0, 100, 1, 19))), - struc (Gtk::manage (new Adjuster (M ("TP_LOCALLAB_STRUC"), 0, 100, 1, 0))), + struc (Gtk::manage (new Adjuster (M ("TP_LOCALLAB_STRUC"), 0, 400, 1, 0))), thres (Gtk::manage (new Adjuster (M ("TP_LOCALLAB_THRES"), 1, 35, 1, 18))), proxi (Gtk::manage (new Adjuster (M ("TP_LOCALLAB_PROXI"), 0, 60, 1, 0))), lightness (Gtk::manage (new Adjuster (M ("TP_LOCALLAB_LIGHTNESS"), -100, 100, 1, 0))), @@ -240,7 +240,7 @@ Locallab::Locallab (): sensiexclu->set_tooltip_text (M ("TP_LOCALLAB_SENSIEXCLU_TOOLTIP")); sensiexclu->setAdjusterListener (this); - // struc->set_tooltip_text (M ("TP_LOCALLAB_STRUC_TOOLTIP")); + struc->set_tooltip_text (M ("TP_LOCALLAB_STRUC_TOOLTIP")); struc->setAdjusterListener (this); ctboxS->pack_start (*labmS, Gtk::PACK_SHRINK, 4); @@ -4074,7 +4074,7 @@ void Locallab::adjusterChanged (Adjuster * a, double newval) } else if (a == sensiexclu) { listener->panelChanged (Evlocallabsensiexclu, sensiexclu->getTextValue()); } else if (a == struc) { -// listener->panelChanged (Evlocallabstruc, struc->getTextValue()); + listener->panelChanged (Evlocallabstruc, struc->getTextValue()); } else if (a == sensibn) { listener->panelChanged (Evlocallabsensibn, sensibn->getTextValue()); } else if (a == proxi) {