diff --git a/rtdata/languages/default b/rtdata/languages/default index 8523de48b..319a8689e 100644 --- a/rtdata/languages/default +++ b/rtdata/languages/default @@ -2101,7 +2101,7 @@ TP_LOCALLAB_CHROMASKCOL;Chroma mask TP_LOCALLAB_GAMMASKCOL;Gamma mask TP_LOCALLAB_SLOMASKCOL;Slope mask TP_LOCALLAB_LAPMASKCOL;Laplacian threshold mask -TP_LOCALLAB_LAPLACC;Mask Laplacian solve PDE (except Retinex) +TP_LOCALLAB_LAPLACC;Mask Laplacian solve PDE TP_LOCALLAB_CHRRT;Chroma TP_LOCALLAB_CIRCRADIUS;Spot size TP_LOCALLAB_COFR;Color & Light - Small defects : red eyes, dust diff --git a/rtengine/improcfun.h b/rtengine/improcfun.h index 2038ece9b..1b1260c27 100644 --- a/rtengine/improcfun.h +++ b/rtengine/improcfun.h @@ -191,6 +191,9 @@ public: const LocCCmaskCurve & locccmasCurve, bool & lcmasutili, const LocLLmaskCurve & locllmasCurve, bool & llmasutili, const LocHHmaskCurve & lochhmasCurve, bool &lhmasutili, bool multiThread, bool enaMask, bool showmaske, bool deltaE, bool modmask, bool zero, bool modif, float chrom, float rad, float lap, float gamma, float slope, float blendm); void discrete_laplacian_threshold(float * data_out, const float * data_in, size_t nx, size_t ny, float t); + void rex_poisson_dct(float * data, size_t nx, size_t ny, double m); + void mean_dt(const float * data, size_t size, double * mean_p, double * dt_p); + double *cos_table(size_t size); void normalize_mean_dt(float *data, const float *ref, size_t size, float mod); void retinex_pde(float *datain, float * dataout, int bfw, int bfh, float thresh, float multy, float *dE, int show, int dEenable, int normalize); @@ -199,7 +202,7 @@ public: void fftw_convol_blur2(float **input2, float **output2, int bfw, int bfh, float radius, int fftkern, int algo); void fftw_tile_blur(int GW, int GH, int tilssize , int max_numblox_W, int min_numblox_W, float **tmp1, int numThreads, double radius); void maskforretinex(int sp, int before, float ** luminance, float ** out, int W_L, int H_L, int skip, const LocCCmaskCurve & locccmasretiCurve, bool &lcmasretiutili, const LocLLmaskCurve & locllmasretiCurve, bool &llmasretiutili, const LocHHmaskCurve & lochhmasretiCurve, bool & lhmasretiutili, int llretiMask, bool retiMasktmap, bool retiMask, - float rad, float lap, float gamm, float slop, float chro, float blend, LabImage * bufreti, LabImage * bufmask, LabImage * buforig, LabImage * buforigmas, bool multiThread); + float rad, float lap, bool pde, float gamm, float slop, float chro, float blend, LabImage * bufreti, LabImage * bufmask, LabImage * buforig, LabImage * buforigmas, bool multiThread); void MSRLocal(int sp, bool fftw, int lum, float** reducDE, LabImage * bufreti, LabImage * bufmask, LabImage * buforig, LabImage * buforigmas, float** luminance, float** templ, const float* const *originalLuminance, const int width, const int height, int bfwr, int bfhr, const procparams::LocallabParams &loc, const int skip, const LocretigainCurve &locRETgainCcurve, const LocretitransCurve &locRETtransCcurve, 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, const LocCCmaskCurve & locccmasretiCurve, bool &lcmasretiutili, const LocLLmaskCurve & locllmasretiCurve, bool &llmasretiutili, const LocHHmaskCurve & lochhmasretiCurve, bool & lhmasretiutili, int llretiMask, LabImage * transformed, bool retiMasktmap, bool retiMask); diff --git a/rtengine/iplocallab.cc b/rtengine/iplocallab.cc index 5b18497f5..216ad7c2d 100644 --- a/rtengine/iplocallab.cc +++ b/rtengine/iplocallab.cc @@ -2523,10 +2523,9 @@ void ImProcFunctions::discrete_laplacian_threshold(float * data_out, const float } } -// return data_out; } -static double *cos_table(size_t size) +double *ImProcFunctions::cos_table(size_t size) { double *table = NULL; double pi_size; @@ -2552,8 +2551,7 @@ static double *cos_table(size_t size) } - -static float *rex_poisson_dct(float * data, size_t nx, size_t ny, double m) +void ImProcFunctions::rex_poisson_dct(float * data, size_t nx, size_t ny, double m) { /* * Copyright 2009-2011 IPOL Image Processing On Line http://www.ipol.im/ @@ -2576,6 +2574,7 @@ static float *rex_poisson_dct(float * data, size_t nx, size_t ny, double m) * cosx[i] = cos(i Pi / nx) for i in [0..nx[ * cosy[i] = cos(i Pi / ny) for i in [0..ny[ */ + cosx = cos_table(nx); cosy = cos_table(ny); @@ -2604,10 +2603,9 @@ static float *rex_poisson_dct(float * data, size_t nx, size_t ny, double m) free(cosx); free(cosy); - return data; } -static void mean_dt(const float * data, size_t size, double * mean_p, double * dt_p) +void ImProcFunctions::mean_dt(const float * data, size_t size, double * mean_p, double * dt_p) { double mean, dt; const float *ptr_data; @@ -2631,7 +2629,6 @@ static void mean_dt(const float * data, size_t size, double * mean_p, double * d *mean_p = mean; *dt_p = dt; - return; } void ImProcFunctions::normalize_mean_dt(float * data, const float * ref, size_t size, float mod) @@ -2675,7 +2672,6 @@ void ImProcFunctions::normalize_mean_dt(float * data, const float * ref, size_t ptr_data++; } - return; } void ImProcFunctions::retinex_pde(float * datain, float * dataout, int bfw, int bfh, float thresh, float multy, float * dE, int show, int dEenable, int normalize) @@ -2791,7 +2787,7 @@ void ImProcFunctions::retinex_pde(float * datain, float * dataout, int bfw, int /* solve the Poisson PDE in Fourier space */ /* 1. / (float) (bfw * bfh)) is the DCT normalisation term, see libfftw */ - (void) rex_poisson_dct(data_fft, bfw, bfh, 1. / (double)(bfw * bfh)); + ImProcFunctions::rex_poisson_dct(data_fft, bfw, bfh, 1. / (double)(bfw * bfh)); if (show == 3) { for (int y = 0; y < bfh ; y++) { @@ -4804,7 +4800,7 @@ void ImProcFunctions::exposure_pde(float * dataor, float * datain, float * datao /* solve the Poisson PDE in Fourier space */ /* 1. / (float) (bfw * bfh)) is the DCT normalisation term, see libfftw */ - (void) rex_poisson_dct(data_fft, bfw, bfh, 1. / (double)(bfw * bfh)); + ImProcFunctions::rex_poisson_dct(data_fft, bfw, bfh, 1. / (double)(bfw * bfh)); dct_bw = fftwf_plan_r2r_2d(bfh, bfw, data_fft, data, FFTW_REDFT01, FFTW_REDFT01, FFTW_ESTIMATE | FFTW_DESTROY_INPUT); fftwf_execute(dct_bw); @@ -6910,7 +6906,7 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o float lap = params->locallab.spots.at(sp).lapmaskbl; - float pde = params->locallab.spots.at(sp).laplac; + bool pde = params->locallab.spots.at(sp).laplac; if (lap > 0.f && (lp.enablMask || lp.showmaskblmet == 3)) { float *datain = new float[GH * GW]; diff --git a/rtengine/ipretinex.cc b/rtengine/ipretinex.cc index a54003b64..8f89477b1 100644 --- a/rtengine/ipretinex.cc +++ b/rtengine/ipretinex.cc @@ -851,7 +851,7 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e void ImProcFunctions::maskforretinex(int sp, int before, float ** luminance, float ** out, int W_L, int H_L, int skip, const LocCCmaskCurve & locccmasretiCurve, bool &lcmasretiutili, const LocLLmaskCurve & locllmasretiCurve, bool &llmasretiutili, const LocHHmaskCurve & lochhmasretiCurve, bool & lhmasretiutili, int llretiMask, bool retiMasktmap, bool retiMask, - float rad, float lap, float gamm, float slop, float chro, float blend, LabImage * bufreti, LabImage * bufmask, LabImage * buforig, LabImage * buforigmas, bool multiThread) + float rad, float lap, bool pde, float gamm, float slop, float chro, float blend, LabImage * bufreti, LabImage * bufmask, LabImage * buforig, LabImage * buforigmas, bool multiThread) { array2D loctemp(W_L, H_L); array2D ble(W_L, H_L); @@ -966,8 +966,12 @@ void ImProcFunctions::maskforretinex(int sp, int before, float ** luminance, flo } } - ImProcFunctions::discrete_laplacian_threshold(data_tmp, datain, W_L, H_L, 200.f * lap); - // (void) discrete_laplacian_threshold_reti(data_tmp, datain, W_L, H_L, 200.f * lap); + if (!pde) { + ImProcFunctions::discrete_laplacian_threshold(data_tmp, datain, W_L, H_L, 200.f * lap); + } else { + ImProcFunctions::retinex_pde(datain, data_tmp, W_L, H_L, 12.f * lap, 1.f, nullptr, 0, 0, 1); + } + #ifdef _OPENMP #pragma omp parallel for #endif @@ -1603,11 +1607,12 @@ void ImProcFunctions::MSRLocal(int sp, bool fftw, int lum, float** reducDE, LabI float blend = loc.spots.at(sp).blendmaskreti; float chro = loc.spots.at(sp).chromaskreti; float lap = loc.spots.at(sp).lapmaskreti; + bool pde = params->locallab.spots.at(sp).laplac; if (lum == 1 && (llretiMask == 3 || llretiMask == 0 || llretiMask == 2 || llretiMask == 4)) { //only mask with luminance on last scale int before = 1; maskforretinex(sp, before, luminance, nullptr, W_L, H_L, skip, locccmasretiCurve, lcmasretiutili, locllmasretiCurve, llmasretiutili, lochhmasretiCurve, lhmasretiutili, llretiMask, retiMasktmap, retiMask, - rad, lap, gamm, slop, chro, blend, bufreti, bufmask, buforig, buforigmas, multiThread); + rad, lap, pde, gamm, slop, chro, blend, bufreti, bufmask, buforig, buforigmas, multiThread); } //mask does not interfered with datas displayed