diff --git a/rtdata/languages/default b/rtdata/languages/default index 800db3dac..3b50d32c8 100644 --- a/rtdata/languages/default +++ b/rtdata/languages/default @@ -2733,9 +2733,9 @@ TP_LOCALLAB_LAPLACC;ΔØ Mask Laplacian solve PDE TP_LOCALLAB_LAPLACE;Laplacian threshold ΔE TP_LOCALLAB_LAPLACEXP;Laplacian threshold TP_LOCALLAB_LAPMASKCOL;Laplacian threshold -TP_LOCALLAB_LAPRAD1_TOOLTIP;Avoid using “Smooth radius” and “Laplacian threshold” (advanced) together.\nTransforms the mask to eliminate values lower than the threshold.\nReduces artifacts and noise, and allows local contrast to be modified. +TP_LOCALLAB_LAPRAD1_TOOLTIP;Increases the contrast of the mask by increasing the luminance values of the lighter areas. Can be used in conjunction with the L(L) and LC(H) curves. TP_LOCALLAB_LAPRAD2_TOOLTIP;Smooth radius uses a guided filter to decrease artifacts and smooth out the transition -TP_LOCALLAB_LAPRAD_TOOLTIP;Avoid using “Smooth radius” and “Laplacian threshold” (advanced) together.\nSmooth radius uses a guided filter to decrease artifacts and smooth out the transition +TP_LOCALLAB_LAPRAD_TOOLTIP;Smooth radius uses a guided filter to decrease artifacts and smooth out the transition TP_LOCALLAB_LAP_MASK_TOOLTIP;Solve PDE for all Laplacian masks.\nIf enabled Laplacian threshold mask reduce artifacts and smooth result.\nIf disabled linear response. TP_LOCALLAB_LC_FFTW_TOOLTIP;FFT improves quality and allows the use of large radii, but increases processing time (depends on the area to be processed). Preferable to use only for large radii. The size of the area can be reduced by a few pixels to optimize the FFTW. This can reduce the processing time by a factor of 1.5 to 10. TP_LOCALLAB_LC_TOOLNAME;Local Contrast & Wavelets - 7 diff --git a/rtengine/improcfun.h b/rtengine/improcfun.h index 4915e04e6..4436c2f1e 100644 --- a/rtengine/improcfun.h +++ b/rtengine/improcfun.h @@ -251,6 +251,8 @@ public: void deltaEforMask(float **rdE, int bfw, int bfh, LabImage* bufcolorig, const float hueref, const float chromaref, const float lumaref, float maxdE, float mindE, float maxdElim, float mindElim, float iterat, float limscope, int scope, float balance, float balanceh); void discrete_laplacian_threshold(float * data_out, const float * data_in, size_t nx, size_t ny, float t); + void laplacian(const array2D &src, array2D &dst, int bfw, int bfh, float threshold, float ceiling, float factor, bool multiThread); + 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); float *cos_table(size_t size); diff --git a/rtengine/iplocallab.cc b/rtengine/iplocallab.cc index c3cfd7e3d..6e6ab0a1b 100644 --- a/rtengine/iplocallab.cc +++ b/rtengine/iplocallab.cc @@ -4087,7 +4087,7 @@ static void showmask(int lumask, const local_params& lp, int xstart, int ystart, } } //from A.Griggio...very similar to discrete_laplacian_threhold...some differences with ceiling and data format -void laplacian(const array2D &src, array2D &dst, int bfw, int bfh, float threshold, float ceiling, float factor, bool multiThread) +void ImProcFunctions::laplacian(const array2D &src, array2D &dst, int bfw, int bfh, float threshold, float ceiling, float factor, bool multiThread) { const int W = bfw; const int H = bfh; @@ -4739,6 +4739,32 @@ void ImProcFunctions::maskcalccol(bool invmask, bool pde, int bfw, int bfh, int } } } + if (lap > 0.f && pde) { + array2D mask; + mask(bfw, bfh); + float amount = LIM01(float(lap)/100.f); + array2D LL(bfw, bfh, bufcolorig->L, ARRAY2D_BYREFERENCE); + laplacian(LL, mask, bfw, bfh, 25.f, 20000.f, amount, false); +#ifdef _OPENMP + #pragma omp parallel for schedule(dynamic,16) if (multiThread) +#endif + for (int i = 0; i < bfh; ++i) { + for (int j = 0; j < bfw; ++j) { + mask[i][j] = LIM01(mask[i][j]); + } + } + for (int i = 0; i < 3; ++i) { + boxblur(static_cast(mask), static_cast(mask), 5 / sk, bfw, bfh, false); + } +#ifdef _OPENMP + #pragma omp parallel for schedule(dynamic,16) if (multiThread) +#endif + for (int i = 0; i < bfh; ++i) { + for (int j = 0; j < bfw; ++j) { + bufmaskblurcol->L[i][j] += clipLoc(100000.f * (mask[i][j]));//increase strongly result + } + } + } std::unique_ptr bufprov; if (delt) { @@ -5019,7 +5045,7 @@ void ImProcFunctions::maskcalccol(bool invmask, bool pde, int bfw, int bfh, int } } } - +/* if (lap > 0.f) { const float *datain = bufmaskblurcol->L[0]; const std::unique_ptr data_tmp(new float[bfh * bfw]); @@ -5039,6 +5065,7 @@ void ImProcFunctions::maskcalccol(bool invmask, bool pde, int bfw, int bfh, int } } } + */ } const float radiusb = 1.f / sk; diff --git a/rtengine/ipretinex.cc b/rtengine/ipretinex.cc index b3b28d3ad..67db52e55 100644 --- a/rtengine/ipretinex.cc +++ b/rtengine/ipretinex.cc @@ -55,6 +55,7 @@ #define BENCHMARK #include "StopWatch.h" #include "guidedfilter.h" +#include "boxblur.h" #define clipretinex( val, minv, maxv ) (( val = (val < minv ? minv : val ) ) > maxv ? maxv : val ) #define CLIPLOC(x) LIM(x,0.f,32767.f) @@ -963,6 +964,33 @@ void ImProcFunctions::maskforretinex(int sp, int before, float ** luminance, flo } } + if (lap > 0.f && pde) { + array2D mask; + mask(W_L, H_L); + float amount = LIM01(float(lap)/100.f); + array2D LL(W_L, H_L, bufreti->L, ARRAY2D_BYREFERENCE); + ImProcFunctions::laplacian(LL, mask, W_L, H_L, 25.f, 20000.f, amount, false); +#ifdef _OPENMP + #pragma omp parallel for schedule(dynamic,16) if (multiThread) +#endif + for (int i = 0; i < H_L; ++i) { + for (int j = 0; j < W_L; ++j) { + mask[i][j] = LIM01(mask[i][j]); + } + } + for (int i = 0; i < 3; ++i) { + boxblur(static_cast(mask), static_cast(mask), 5 / skip, W_L, H_L, false); + } +#ifdef _OPENMP + #pragma omp parallel for schedule(dynamic,16) if (multiThread) +#endif + for (int i = 0; i < H_L; ++i) { + for (int j = 0; j < W_L; ++j) { + bufmaskblurreti->L[i][j] += CLIPLOC(100000.f * (mask[i][j]));//increase strongly result + } + } + } + if (delt) { float *rdE[H_L] ALIGNED16; @@ -994,7 +1022,7 @@ void ImProcFunctions::maskforretinex(int sp, int before, float ** luminance, flo } - +/* if (lap > 0.f) { float *datain = new float[H_L * W_L]; float *data_tmp = new float[H_L * W_L]; @@ -1029,7 +1057,7 @@ void ImProcFunctions::maskforretinex(int sp, int before, float ** luminance, flo delete [] data_tmp; } - +*/ //blend #ifdef _OPENMP #pragma omp parallel