diff --git a/rtengine/curves.cc b/rtengine/curves.cc index d05a9dd12..86f74c92f 100644 --- a/rtengine/curves.cc +++ b/rtengine/curves.cc @@ -526,28 +526,6 @@ void CurveFactory::curveDehaContL ( bool & dehacontlutili, const std::vector& dehaclcurvePoints, LUTf & dehaclCurve, int skip) -{ - bool needed = false; - DiagonalCurve* dCurve = NULL; - - if (!dehaclcurvePoints.empty() && dehaclcurvePoints[0] != 0) { - dCurve = new DiagonalCurve (dehaclcurvePoints, CURVES_MIN_POLY_POINTS / skip); - - if (dCurve && !dCurve->isIdentity()) { - needed = true; - dehaHcontlutili = true; - } - } - - fillCurveArray(dCurve, dehaclCurve, skip, needed); - - if (dCurve) { - delete dCurve; - dCurve = NULL; - } -} - // add curve Lab wavelet : Cont=f(L) void CurveFactory::curveWavContL ( bool & wavcontlutili, const std::vector& wavclcurvePoints, LUTf & wavclCurve, /*LUTu & histogramwavcl, LUTu & outBeforeWavCLurveHistogram,*/int skip) { diff --git a/rtengine/curves.h b/rtengine/curves.h index b85088143..264163b53 100644 --- a/rtengine/curves.h +++ b/rtengine/curves.h @@ -283,7 +283,6 @@ public: static void curveWavContL ( bool & wavcontlutili, const std::vector& wavclcurvePoints, LUTf & wavclCurve,/* LUTu & histogramwavcl, LUTu & outBeforeWavCLurveHistogram,*/int skip); static void curveDehaContL ( bool & dehacontlutili, const std::vector& dehaclcurvePoints, LUTf & dehaclCurve, int skip); - static void curveDehaHContL ( bool & dehaHcontlutili, const std::vector& dehaclcurvePoints, LUTf & dehaclCurve, int skip); static void curveToningCL ( bool & clctoningutili, const std::vector& clcurvePoints, LUTf & clToningCurve, int skip); static void curveToningLL ( bool & llctoningutili, const std::vector& llcurvePoints, LUTf & llToningCurve, int skip); diff --git a/rtengine/imagesource.h b/rtengine/imagesource.h index 98730ac1b..ff2c00161 100644 --- a/rtengine/imagesource.h +++ b/rtengine/imagesource.h @@ -69,17 +69,16 @@ public: virtual int load (Glib::ustring fname, bool batch = false) = 0; virtual void preprocess (const RAWParams &raw, const LensProfParams &lensProf, const CoarseTransformParams& coarse) {}; virtual void demosaic (const RAWParams &raw) {}; -// virtual void // retinex (RAWParams raw, ColorManagementParams cmp, RetinexParams lcur, LUTf & cdcurve, bool dehacontlutili) {}; - virtual void retinex (RAWParams raw, ColorManagementParams cmp, RetinexParams deh, LUTf & cdcurve, LUTf & cdHcurve, const RetinextransmissionCurve & dehatransmissionCurve, bool dehacontlutili, bool dehaHcontlutili, float &minCD, float &maxCD, float &mini, float &maxi, float &Tmean, float &Tsigma, float &Tmin, float &Tmax) {}; + virtual void retinex (ColorManagementParams cmp, RetinexParams deh, LUTf & cdcurve, const RetinextransmissionCurve & dehatransmissionCurve, multi_array2D &conversionBuffer, bool dehacontlutili, bool useHsl, float &minCD, float &maxCD, float &mini, float &maxi, float &Tmean, float &Tsigma, float &Tmin, float &Tmax) {}; + virtual void retinexPrepareCurves (RetinexParams retinexParams, LUTf &cdcurve, RetinextransmissionCurve &retinextransmissionCurve, bool &retinexcontlutili, bool &useHsl) {}; + virtual void retinexPrepareBuffers (ColorManagementParams cmp, RetinexParams retinexParams, multi_array2D &conversionBuffer) {}; virtual void flushRawData () {}; virtual void flushRGB () {}; virtual void HLRecovery_Global (ToneCurveParams hrp) {}; virtual void HLRecovery_inpaint (float** red, float** green, float** blue) {}; -// virtual void MSR(LabImage* lab, int width, int height, int skip, RetinexParams lcur) {}; virtual void MSR(LabImage* lab, int width, int height, int skip, RetinexParams deh, const RetinextransmissionCurve & dehatransmissionCurve, float &minCD, float &maxCD, float &mini, float &maxi, float &Tmean, float &Tsigma, float &Tmin, float &Tmax) {}; virtual bool IsrgbSourceModified() = 0; // tracks whether cached rgb output of demosaic has been modified - // virtual void MSR(LabImage* lab, int width, int height, int skip, const LCurveParams &lcur); // use right after demosaicing image, add coarse transformation and put the result in the provided Imagefloat* virtual void getImage (ColorTemp ctemp, int tran, Imagefloat* image, PreviewProps pp, ToneCurveParams hlp, ColorManagementParams cmp, RAWParams raw) {} diff --git a/rtengine/improccoordinator.cc b/rtengine/improccoordinator.cc index 6a0933d14..3fcc1e64b 100644 --- a/rtengine/improccoordinator.cc +++ b/rtengine/improccoordinator.cc @@ -46,8 +46,6 @@ ImProcCoordinator::ImProcCoordinator () satcurve(65536, 0), lhskcurve(65536, 0), clcurve(65536, 0), - cdcurve(65536, 0), - cdHcurve(65536, 0), wavclCurve(65536, 0), clToningcurve(65536, 0), cl2Toningcurve(65536, 0), @@ -89,7 +87,7 @@ ImProcCoordinator::ImProcCoordinator () pW(-1), pH(-1), plistener(NULL), imageListener(NULL), aeListener(NULL), acListener(NULL), abwListener(NULL), actListener(NULL), adnListener(NULL), awavListener(NULL), dehaListener(NULL), hListener(NULL), resultValid(false), changeSinceLast(0), updaterRunning(false), destroying(false), utili(false), autili(false), wavcontlutili(false), - butili(false), ccutili(false), cclutili(false), clcutili(false), opautili(false) + butili(false), ccutili(false), cclutili(false), clcutili(false), opautili(false), conversionBuffer(1, 1) {} @@ -237,22 +235,24 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) } if (params.retinex.enabled) { - bool dehacontlutili = false; - bool dehaHcontlutili = false; - CurveFactory::curveDehaContL (dehacontlutili, params.retinex.cdcurve, cdcurve, 1); - CurveFactory::curveDehaHContL (dehaHcontlutili, params.retinex.cdHcurve, cdHcurve, 1); - RetinexParams DehaParams = params.retinex; - DehaParams.getCurves(dehatransmissionCurve); - float minCD, maxCD, mini, maxi, Tmean, Tsigma, Tmin, Tmax; - imgsrc->retinex( params.raw, params.icm, params.retinex, cdcurve, cdHcurve, dehatransmissionCurve, dehacontlutili, dehaHcontlutili, minCD, maxCD, mini, maxi, Tmean, Tsigma, Tmin, Tmax);//enabled Retinex - - if(dehaListener) { - dehaListener->minmaxChanged(maxCD, minCD, mini, maxi, Tmean, Tsigma, Tmin, Tmax); - } - + imgsrc->retinexPrepareBuffers(params.icm, params.retinex, conversionBuffer); } } + if (params.retinex.enabled) { + bool dehacontlutili = false; + bool useHsl = false; + LUTf cdcurve (65536, 0); + imgsrc->retinexPrepareCurves(params.retinex, cdcurve, dehatransmissionCurve, dehacontlutili, useHsl); + float minCD, maxCD, mini, maxi, Tmean, Tsigma, Tmin, Tmax; + imgsrc->retinex( params.icm, params.retinex, cdcurve, dehatransmissionCurve, conversionBuffer, dehacontlutili, useHsl, minCD, maxCD, mini, maxi, Tmean, Tsigma, Tmin, Tmax);//enabled Retinex + + if(dehaListener) { + dehaListener->minmaxChanged(maxCD, minCD, mini, maxi, Tmean, Tsigma, Tmin, Tmax); + } + } + + // Updating toneCurve.hrenabled if necessary // It has to be done there, because the next 'if' statement will use the value computed here if (todo & M_AUTOEXP) { diff --git a/rtengine/improccoordinator.h b/rtengine/improccoordinator.h index 4ba9bc7c9..fb24b5632 100644 --- a/rtengine/improccoordinator.h +++ b/rtengine/improccoordinator.h @@ -94,8 +94,7 @@ protected: LUTf satcurve; LUTf lhskcurve; LUTf clcurve; - LUTf cdcurve; - LUTf cdHcurve; + multi_array2D conversionBuffer; LUTf wavclCurve; LUTf clToningcurve; LUTf cl2Toningcurve; diff --git a/rtengine/procevents.h b/rtengine/procevents.h index c71e8d9f1..1a6216750 100644 --- a/rtengine/procevents.h +++ b/rtengine/procevents.h @@ -444,7 +444,7 @@ enum ProcEvent { EvRetinexEnabled = 415, EvRetinexmedianmap = 416, EvLlimd = 417, - EvretinexColorSpace = 406, //change to 418 if we want a separate history entry "Retinex - Color space" + EvretinexColorSpace = 418, //change to 418 if we want a separate history entry "Retinex - Color space" EvLCDHCurve = 419, NUMOFEVENTS }; diff --git a/rtengine/rawimagesource.cc b/rtengine/rawimagesource.cc index a39fed126..76eb5bee5 100644 --- a/rtengine/rawimagesource.cc +++ b/rtengine/rawimagesource.cc @@ -1801,49 +1801,15 @@ void RawImageSource::demosaic(const RAWParams &raw) } } -void RawImageSource::retinex(RAWParams raw, ColorManagementParams cmp, RetinexParams deh, LUTf & cdcurve, LUTf & cdHcurve, const RetinextransmissionCurve & dehatransmissionCurve, bool dehacontlutili, bool dehaHcontlutili, float &minCD, float &maxCD, float &mini, float &maxi, float &Tmean, float &Tsigma, float &Tmin, float &Tmax) + +void RawImageSource::retinexPrepareBuffers(ColorManagementParams cmp, RetinexParams retinexParams, multi_array2D &conversionBuffer) { + bool useHsl = (retinexParams.retinexcolorspace == "HSLLOG" || retinexParams.retinexcolorspace == "HSLLIN"); + conversionBuffer[0] (W - 2 * border, H - 2 * border); + conversionBuffer[1] (W - 2 * border, H - 2 * border); + conversionBuffer[2] (W - 2 * border, H - 2 * border); - MyTime t4, t5; - t4.set(); - - if (settings->verbose) { - printf ("Applying Retinex\n"); - } - - TMatrix wprof = iccStore->workingSpaceMatrix (cmp.working); - TMatrix wiprof = iccStore->workingSpaceInverseMatrix (cmp.working); - - double wip[3][3] = { - {wiprof[0][0], wiprof[0][1], wiprof[0][2]}, - {wiprof[1][0], wiprof[1][1], wiprof[1][2]}, - {wiprof[2][0], wiprof[2][1], wiprof[2][2]} - }; - - double wp[3][3] = { - {wprof[0][0], wprof[0][1], wprof[0][2]}, - {wprof[1][0], wprof[1][1], wprof[1][2]}, - {wprof[2][0], wprof[2][1], wprof[2][2]} - }; - - // We need a buffer with original L data to allow correct blending - // red, green and blue still have original size of raw, but we can't use the borders - const int HNew = H - 2 * border; - const int WNew = W - 2 * border; - - LabImage * labdeha = new LabImage(WNew, HNew); - - float *labTmp[HNew] ALIGNED16; - float *labTmpBuffer = new float[HNew * WNew]; - - for (int i = 0; i < HNew; i++) { - labTmp[i] = &labTmpBuffer[i * WNew]; - } - - bool useHsl = deh.retinexcolorspace == "HSLLOG"; - bool useHslLin = deh.retinexcolorspace == "HSLLIN"; - - if(useHsl || useHslLin) { + if(useHsl) { #ifdef _OPENMP #pragma omp parallel #endif @@ -1863,18 +1829,10 @@ void RawImageSource::retinex(RAWParams raw, ColorManagementParams cmp, RetinexPa for (; j < W - border - 3; j += 4) { vfloat H, S, L; Color::rgb2hsl(LVFU(red[i][j]), LVFU(green[i][j]), LVFU(blue[i][j]), H, S, L); - _mm_storeu_ps(&labdeha->a[i - border][j - border], H); - _mm_storeu_ps(&labdeha->b[i - border][j - border], S); + _mm_storeu_ps(&conversionBuffer[0][i - border][j - border], H); + _mm_storeu_ps(&conversionBuffer[1][i - border][j - border], S); L *= c32768; - _mm_storeu_ps(&labTmp[i - border][j - border], L); - - if(dehaHcontlutili) { // curve is not vectorized - for (int k = 0; k < 4; k++) { - labdeha->L[i - border][j - border + k] = cdHcurve[2.f*labTmp[i - border][j - border + k]]/2.f; - } - } else { - _mm_storeu_ps(&labdeha->L[i - border][j - border], L); - } + _mm_storeu_ps(&conversionBuffer[2][i - border][j - border], L); } #endif @@ -1882,25 +1840,26 @@ void RawImageSource::retinex(RAWParams raw, ColorManagementParams cmp, RetinexPa for (; j < W - border; j++) { float H, S, L; //rgb=>lab - Color::rgb2hslfloat(red[i][j], green[i][j], blue[i][j], labdeha->a[i - border][j - border], labdeha->b[i - border][j - border], L); + Color::rgb2hslfloat(red[i][j], green[i][j], blue[i][j], conversionBuffer[0][i - border][j - border], conversionBuffer[1][i - border][j - border], L); L *= 32768.f; - labTmp[i - border][j - border] = L; - - if(dehaHcontlutili) { - labdeha->L[i - border][j - border] = cdHcurve[2.f*labTmp[i - border][j - border]]/2.f; - } else { - labdeha->L[i - border][j - border] = labTmp[i - border][j - border]; - } + conversionBuffer[2][i - border][j - border] = L; } } } } else { + TMatrix wprof = iccStore->workingSpaceMatrix (cmp.working); + double wp[3][3] = { + {wprof[0][0], wprof[0][1], wprof[0][2]}, + {wprof[1][0], wprof[1][1], wprof[1][2]}, + {wprof[2][0], wprof[2][1], wprof[2][2]} + }; // Conversion rgb -> lab is hard to vectorize because it uses a lut (that's not the main problem) // and it uses a condition inside XYZ2Lab which is almost impossible to vectorize without making it slower... #ifdef _OPENMP #pragma omp parallel for #endif + for (int i = border; i < H - border; i++ ) for (int j = border; j < W - border; j++) { float X, Y, Z, L, aa, bb; @@ -1908,23 +1867,60 @@ void RawImageSource::retinex(RAWParams raw, ColorManagementParams cmp, RetinexPa Color::rgbxyz(red[i][j], green[i][j], blue[i][j], X, Y, Z, wp); //convert Lab Color::XYZ2Lab(X, Y, Z, L, aa, bb); - labTmp[i - border][j - border] = L; - - if(dehacontlutili) { - L = cdcurve[L*2.f]/2.f; //apply curve to equalize histogram - } - - labdeha->L[i - border][j - border] = L; - labdeha->a[i - border][j - border] = aa; - labdeha->b[i - border][j - border] = bb; + conversionBuffer[0][i - border][j - border] = aa; + conversionBuffer[1][i - border][j - border] = bb; + conversionBuffer[2][i - border][j - border] = L; } } +} - MSR(labdeha->L, labTmp, WNew, HNew, deh, dehatransmissionCurve, minCD, maxCD, mini, maxi, Tmean, Tsigma, Tmin, Tmax); +void RawImageSource::retinexPrepareCurves(RetinexParams retinexParams, LUTf &cdcurve, RetinextransmissionCurve &retinextransmissionCurve, bool &retinexcontlutili, bool &useHsl) +{ + useHsl = (retinexParams.retinexcolorspace == "HSLLOG" || retinexParams.retinexcolorspace == "HSLLIN"); - delete [] labTmpBuffer; + if(useHsl) { + CurveFactory::curveDehaContL (retinexcontlutili, retinexParams.cdHcurve, cdcurve, 1); + } else { + CurveFactory::curveDehaContL (retinexcontlutili, retinexParams.cdcurve, cdcurve, 1); + } - if(useHsl || useHslLin) { + retinexParams.getCurves(retinextransmissionCurve); +} + +void RawImageSource::retinex(ColorManagementParams cmp, RetinexParams deh, LUTf & cdcurve, const RetinextransmissionCurve & dehatransmissionCurve, multi_array2D &conversionBuffer, bool dehacontlutili, bool useHsl, float &minCD, float &maxCD, float &mini, float &maxi, float &Tmean, float &Tsigma, float &Tmin, float &Tmax) +{ + + MyTime t4, t5; + t4.set(); + + if (settings->verbose) { + printf ("Applying Retinex\n"); + } + + // We need a buffer with original L data to allow correct blending + // red, green and blue still have original size of raw, but we can't use the borders + const int HNew = H - 2 * border; + const int WNew = W - 2 * border; + + array2D LBuffer (WNew, HNew); + float **temp = conversionBuffer[2]; // one less dereference +#ifdef _OPENMP + #pragma omp parallel for +#endif + + for (int i = 0; i < H - 2 * border; i++ ) + if(dehacontlutili) + for (int j = 0; j < W - 2 * border; j++) { + LBuffer[i][j] = cdcurve[2.f * temp[i][j]] / 2.f; + } + else + for (int j = 0; j < W - 2 * border; j++) { + LBuffer[i][j] = temp[i][j]; + } + + MSR(LBuffer, conversionBuffer[2], WNew, HNew, deh, dehatransmissionCurve, minCD, maxCD, mini, maxi, Tmean, Tsigma, Tmin, Tmax); + + if(useHsl) { #ifdef _OPENMP #pragma omp parallel for #endif @@ -1936,7 +1932,7 @@ void RawImageSource::retinex(RAWParams raw, ColorManagementParams cmp, RetinexPa for (; j < W - border - 3; j += 4) { vfloat R, G, B; - Color::hsl2rgb(LVFU(labdeha->a[i - border][j - border]), LVFU(labdeha->b[i - border][j - border]), LVFU(labdeha->L[i - border][j - border]) / c32768, R, G, B); + Color::hsl2rgb(LVFU(conversionBuffer[0][i - border][j - border]), LVFU(conversionBuffer[1][i - border][j - border]), LVFU(LBuffer[i - border][j - border]) / c32768, R, G, B); _mm_storeu_ps(&red[i][j], R); _mm_storeu_ps(&green[i][j], G); @@ -1946,11 +1942,19 @@ void RawImageSource::retinex(RAWParams raw, ColorManagementParams cmp, RetinexPa #endif for (; j < W - border; j++) { - Color::hsl2rgbfloat(labdeha->a[i - border][j - border], labdeha->b[i - border][j - border], labdeha->L[i - border][j - border] / 32768.f, red[i][j], green[i][j], blue[i][j]); + Color::hsl2rgbfloat(conversionBuffer[0][i - border][j - border], conversionBuffer[1][i - border][j - border], LBuffer[i - border][j - border] / 32768.f, red[i][j], green[i][j], blue[i][j]); } } } else { + TMatrix wiprof = iccStore->workingSpaceInverseMatrix (cmp.working); + + double wip[3][3] = { + {wiprof[0][0], wiprof[0][1], wiprof[0][2]}, + {wiprof[1][0], wiprof[1][1], wiprof[1][2]}, + {wiprof[2][0], wiprof[2][1], wiprof[2][2]} + }; + #ifdef __SSE2__ vfloat wipv[3][3]; @@ -1969,12 +1973,9 @@ void RawImageSource::retinex(RAWParams raw, ColorManagementParams cmp, RetinexPa #ifdef __SSE2__ for (; j < W - border - 3; j += 4) { - vfloat L2, a2, b2, x_, y_, z_; + vfloat x_, y_, z_; vfloat R, G, B; - L2 = LVFU(labdeha->L[i - border][j - border]); - a2 = LVFU(labdeha->a[i - border][j - border]); - b2 = LVFU(labdeha->b[i - border][j - border]); - Color::Lab2XYZ(L2, a2, b2, x_, y_, z_) ; + Color::Lab2XYZ(LVFU(LBuffer[i - border][j - border]), LVFU(conversionBuffer[0][i - border][j - border]), LVFU(conversionBuffer[1][i - border][j - border]), x_, y_, z_) ; Color::xyz2rgb(x_, y_, z_, R, G, B, wipv); _mm_storeu_ps(&red[i][j], R); _mm_storeu_ps(&green[i][j], G); @@ -1984,12 +1985,9 @@ void RawImageSource::retinex(RAWParams raw, ColorManagementParams cmp, RetinexPa #endif for (; j < W - border; j++) { - float L2, a2, b2, x_, y_, z_; + float x_, y_, z_; float R, G, B; - L2 = labdeha->L[i - border][j - border]; - a2 = labdeha->a[i - border][j - border]; - b2 = labdeha->b[i - border][j - border]; - Color::Lab2XYZ(L2, a2, b2, x_, y_, z_) ; + Color::Lab2XYZ(LBuffer[i - border][j - border], conversionBuffer[0][i - border][j - border], conversionBuffer[1][i - border][j - border], x_, y_, z_) ; Color::xyz2rgb(x_, y_, z_, R, G, B, wip); red[i][j] = R; green[i][j] = G; @@ -1998,8 +1996,6 @@ void RawImageSource::retinex(RAWParams raw, ColorManagementParams cmp, RetinexPa } } - delete labdeha; - t5.set(); if( settings->verbose ) { diff --git a/rtengine/rawimagesource.h b/rtengine/rawimagesource.h index 5cb0c74a5..2a2249630 100644 --- a/rtengine/rawimagesource.h +++ b/rtengine/rawimagesource.h @@ -152,7 +152,9 @@ public: void preprocess (const RAWParams &raw, const LensProfParams &lensProf, const CoarseTransformParams& coarse); void demosaic (const RAWParams &raw); // void retinex (RAWParams raw, ColorManagementParams cmp, RetinexParams lcur, LUTf & cdcurve, bool dehacontlutili); - void retinex (RAWParams raw, ColorManagementParams cmp, RetinexParams deh, LUTf & cdcurve, LUTf & cdHcurve, const RetinextransmissionCurve & dehatransmissionCurve, bool dehacontlutili, bool dehaHcontlutili, float &minCD, float &maxCD, float &mini, float &maxi, float &Tmean, float &Tsigma, float &Tmin, float &Tmax); + void retinex (ColorManagementParams cmp, RetinexParams deh, LUTf & cdcurve, const RetinextransmissionCurve & dehatransmissionCurve, multi_array2D &conversionBuffer, bool dehacontlutili, bool useHsl, float &minCD, float &maxCD, float &mini, float &maxi, float &Tmean, float &Tsigma, float &Tmin, float &Tmax); + void retinexPrepareCurves (RetinexParams retinexParams, LUTf &cdcurve, RetinextransmissionCurve &retinextransmissionCurve, bool &retinexcontlutili, bool &useHsl); + void retinexPrepareBuffers (ColorManagementParams cmp, RetinexParams retinexParams, multi_array2D &conversionBuffer); void flushRawData (); void flushRGB (); void HLRecovery_Global (ToneCurveParams hrp); diff --git a/rtengine/refreshmap.cc b/rtengine/refreshmap.cc index 0c4f9bf1d..9acea5dd6 100644 --- a/rtengine/refreshmap.cc +++ b/rtengine/refreshmap.cc @@ -428,21 +428,21 @@ int refreshmap[rtengine::NUMOFEVENTS] = { DIRPYREQUALIZER, // EvWavedgeampli DIRPYREQUALIZER, //EvWavlev3nois DIRPYREQUALIZER, //EvWavNPmet - DEMOSAIC, // EvretinexMethod - DEMOSAIC, // EvLneigh - DEMOSAIC, // EvLgain - DEMOSAIC, // EvLoffs - DEMOSAIC, // EvLstr - DEMOSAIC, // EvLscal - DEMOSAIC, // EvLvart - DEMOSAIC, // EvLCDCurve - DEMOSAIC, // EvRetinexOpacity - DEMOSAIC, // EvRetinexEnabled - DEMOSAIC, // EvRetinexretinex <-- TODO we can probably delete this - DEMOSAIC, // EvRetinexmedianmap - DEMOSAIC, // EvLlimd + DEMOSAIC, // Unused? + ALLNORAW, // EvretinexMethod + ALLNORAW, // EvLneigh + ALLNORAW, // EvLgain + ALLNORAW, // EvLoffs was EvLstr + ALLNORAW, // EvLstr was EvLscal + ALLNORAW, // EvLscal was EvLvart + ALLNORAW, // EvLvart was EvLCDCurve + ALLNORAW, // EvRetinexOpacity // not used + ALLNORAW, // EvRetinextransmission + DEMOSAIC, // EvRetinexEnabled was EvRetinexretinex <-- TODO we can probably delete this + ALLNORAW, // EvRetinexmedianmap + ALLNORAW, // EvLlimd DEMOSAIC, // Evretinexcolorspace - DEMOSAIC // EvLCDHCurve + ALLNORAW // EvLCDHCurve }; diff --git a/rtengine/simpleprocess.cc b/rtengine/simpleprocess.cc index a3f18f770..5a07e587f 100644 --- a/rtengine/simpleprocess.cc +++ b/rtengine/simpleprocess.cc @@ -118,17 +118,14 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p if(params.retinex.enabled) { //enabled Retinex LUTf cdcurve (65536, 0); - LUTf cdHcurve (65536, 0); RetinextransmissionCurve dehatransmissionCurve; - bool dehacontlutili = false; - bool dehaHcontlutili = false; - CurveFactory::curveDehaContL (dehacontlutili, params.retinex.cdcurve, cdcurve, 1); - CurveFactory::curveDehaHContL (dehaHcontlutili, params.retinex.cdHcurve, cdHcurve, 1); - RetinexParams DehaParams = params.retinex; - DehaParams.getCurves(dehatransmissionCurve); + bool useHsl = false; + multi_array2D conversionBuffer(1, 1); + imgsrc->retinexPrepareBuffers(params.icm, params.retinex, conversionBuffer); + imgsrc->retinexPrepareCurves(params.retinex, cdcurve, dehatransmissionCurve, dehacontlutili, useHsl); float minCD, maxCD, mini, maxi, Tmean, Tsigma, Tmin, Tmax; - imgsrc->retinex( params.raw, params.icm, params.retinex, cdcurve, cdHcurve, dehatransmissionCurve, dehacontlutili, dehaHcontlutili, minCD, maxCD, mini, maxi, Tmean, Tsigma, Tmin, Tmax); + imgsrc->retinex( params.icm, params.retinex, cdcurve, dehatransmissionCurve, conversionBuffer, dehacontlutili, useHsl, minCD, maxCD, mini, maxi, Tmean, Tsigma, Tmin, Tmax); } if (pl) {