Improvment to FFTW Retinex

This commit is contained in:
Desmis 2019-09-24 18:37:30 +02:00
parent bcc65a513a
commit 23bae76878
4 changed files with 95 additions and 59 deletions

View File

@ -2204,7 +2204,7 @@ TP_LOCALLAB_RETIFRA;Retinex
TP_LOCALLAB_RETI;Dehaze - Retinex Strong local contrast TP_LOCALLAB_RETI;Dehaze - Retinex Strong local contrast
TP_LOCALLAB_RETI_NEIGH_VART_TOOLTIP;Adapt these values according to images - if misty images and depending on whether you want to act on the front or the background TP_LOCALLAB_RETI_NEIGH_VART_TOOLTIP;Adapt these values according to images - if misty images and depending on whether you want to act on the front or the background
TP_LOCALLAB_LC_FFTW_TOOLTIP;FFT improve quality and allow big radius.\nThe treatment time depends on the surface to be treated.\nTo be used preferably for large radius.\n\nDimensions can be reduced by a few pixels to optimize FFTW.\nThis optimization can reduce the treatment time by a factor of 2 to 10. TP_LOCALLAB_LC_FFTW_TOOLTIP;FFT improve quality and allow big radius.\nThe treatment time depends on the surface to be treated.\nTo be used preferably for large radius.\n\nDimensions can be reduced by a few pixels to optimize FFTW.\nThis optimization can reduce the treatment time by a factor of 2 to 10.
TP_LOCALLAB_RETI_FFTW_TOOLTIP;FFT improve quality and allow big radius.\nThe treatment time depends on the surface to be treated\nThe treatment time depends on the value of scale (be carefull to high values).\nTo be used preferably for large radius.\n\nDimensions can be reduced by a few pixels to optimize FFTW.\nThis optimization can reduce the treatment time by a factor of 2 to 10.\nThis optimization is not possible if 2 delimiters of the Spot (1 vertical and 1 horizontal on four) are outside the image.\nif you want to select quasi all image, use 'shape RT-spot area = rectangle', transition=100., spot delimiters near boders images with 1 spot 'vertical' and 1 spot 'horizontal' inside image and the 2 others very slightly outside. TP_LOCALLAB_RETI_FFTW_TOOLTIP;FFT improve quality and allow big radius.\nThe treatment time depends on the surface to be treated\nThe treatment time depends on the value of scale (be carefull to high values).\nTo be used preferably for large radius.\n\nDimensions can be reduced by a few pixels to optimize FFTW.\nThis optimization can reduce the treatment time by a factor of 2 to 10.
TP_LOCALLAB_TRANSMISSIONGAIN;Transmission gain TP_LOCALLAB_TRANSMISSIONGAIN;Transmission gain
TP_LOCALLAB_STREN;Compression Strength TP_LOCALLAB_STREN;Compression Strength
TP_LOCALLAB_STRGRID;Strength TP_LOCALLAB_STRGRID;Strength

View File

@ -194,7 +194,7 @@ public:
void fftw_convol_blur2(float **input2, float **output2, int bfw, int bfh, float radius, int fftkern, int algo); 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 fftw_tile_blur(int GW, int GH, int tilssize , int max_numblox_W, int min_numblox_W, float **tmp1, int numThreads, double radius);
void MSRLocal(int sp, bool fftw, int lum, LabImage * bufreti, LabImage * bufmask, LabImage * buforig, LabImage * buforigmas, float** luminance, float** templ, const float* const *originalLuminance, const int width, const int height, const procparams::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 MSRLocal(int sp, bool fftw, int lum, 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 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); const LocCCmaskCurve & locccmasretiCurve, bool &lcmasretiutili, const LocLLmaskCurve & locllmasretiCurve, bool &llmasretiutili, const LocHHmaskCurve & lochhmasretiCurve, bool & lhmasretiutili, int llretiMask, LabImage * transformed, bool retiMasktmap, bool retiMask);
void calc_ref(int sp, LabImage* original, LabImage* transformed, int cx, int cy, int oW, int oH, int sk, double &huerefblur, double &chromarefblur, double &lumarefblur, double &hueref, double &chromaref, double &lumaref, double &sobelref, float &avg); void calc_ref(int sp, LabImage* original, LabImage* transformed, int cx, int cy, int oW, int oH, int sk, double &huerefblur, double &chromarefblur, double &lumarefblur, double &hueref, double &chromaref, double &lumaref, double &sobelref, float &avg);
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 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);

View File

@ -2916,6 +2916,14 @@ void ImProcFunctions::transit_shapedetect_retinex(int call, int senstype, LabIma
{ {
BENCHFUN { BENCHFUN {
const int ystart = std::max(static_cast<int>(lp.yc - lp.lyT) - cy, 0);
const int yend = std::min(static_cast<int>(lp.yc + lp.ly) - cy, original->H);
const int xstart = std::max(static_cast<int>(lp.xc - lp.lxL) - cx, 0);
const int xend = std::min(static_cast<int>(lp.xc + lp.lx) - cx, original->W);
const int bfw = xend - xstart;
const int bfh = yend - ystart;
const float ach = (float)lp.trans / 100.f; const float ach = (float)lp.trans / 100.f;
const float varsens = lp.sensh; const float varsens = lp.sensh;
@ -2971,20 +2979,21 @@ void ImProcFunctions::transit_shapedetect_retinex(int call, int senstype, LabIma
#pragma omp for schedule(dynamic,16) #pragma omp for schedule(dynamic,16)
#endif #endif
for (int y = 0; y < transformed->H; y++) for (int y = ystart; y < yend; y++)
{ {
const int loy = cy + y; const int loy = cy + y;
const bool isZone0 = loy > lp.yc + lp.ly || loy < lp.yc - lp.lyT; // whole line is zone 0 => we can skip a lot of processing
if (isZone0) { // outside selection and outside transition zone => no effect, keep original values /* const bool isZone0 = loy > lp.yc + lp.ly || loy < lp.yc - lp.lyT; // whole line is zone 0 => we can skip a lot of processing
continue;
}
for (int x = 0; x < transformed->W; x++) { if (isZone0) { // outside selection and outside transition zone => no effect, keep original values
continue;
}
*/
for (int x = xstart; x < xend; x++) {
const int lox = cx + x; const int lox = cx + x;
const int begx = int (lp.xc - lp.lxL); /* const int begx = int (lp.xc - lp.lxL);
const int begy = int (lp.yc - lp.lyT); const int begy = int (lp.yc - lp.lyT);
*/
int zone = 0; int zone = 0;
float localFactor = 1.f; float localFactor = 1.f;
@ -3006,7 +3015,7 @@ void ImProcFunctions::transit_shapedetect_retinex(int call, int senstype, LabIma
dE = sqrt(kab * SQR(refa - origblur->a[y][x] / 327.68f) + kab * SQR(refb - origblur->b[y][x] / 327.68f) + kL * SQR(lumaref - rL)); dE = sqrt(kab * SQR(refa - origblur->a[y][x] / 327.68f) + kab * SQR(refb - origblur->b[y][x] / 327.68f) + kL * SQR(lumaref - rL));
} else { } else {
if (call == 2) { if (call == 2) {
dE = sqrt(kab * SQR(refa - buforigmas->a[loy - begy][lox - begx] / 327.68f) + kab * SQR(refb - buforigmas->b[loy - begy][lox - begx] / 327.68f) + kL * SQR(lumaref - buforigmas->L[loy - begy][lox - begx] / 327.68f)); dE = sqrt(kab * SQR(refa - buforigmas->a[y - ystart][x - xstart] / 327.68f) + kab * SQR(refb - buforigmas->b[y - ystart][x - xstart] / 327.68f) + kL * SQR(lumaref - buforigmas->L[y - ystart][x - xstart] / 327.68f));
} else { } else {
dE = sqrt(kab * SQR(refa - buforigmas->a[y][x] / 327.68f) + kab * SQR(refb - buforigmas->b[y][x] / 327.68f) + kL * SQR(lumaref - buforigmas->L[y][x] / 327.68f)); dE = sqrt(kab * SQR(refa - buforigmas->a[y][x] / 327.68f) + kab * SQR(refb - buforigmas->b[y][x] / 327.68f) + kL * SQR(lumaref - buforigmas->L[y][x] / 327.68f));
} }
@ -3015,8 +3024,8 @@ void ImProcFunctions::transit_shapedetect_retinex(int call, int senstype, LabIma
float cli, clc; float cli, clc;
if (call == 2) { if (call == 2) {
cli = buflight[loy - begy][lox - begx]; cli = buflight[y - ystart][x - xstart];
clc = previewreti ? settings->previewselection * 100.f : bufchro[loy - begy][lox - begx]; clc = previewreti ? settings->previewselection * 100.f : bufchro[y - ystart][x - xstart];
} else { } else {
cli = buflight[y][x]; cli = buflight[y][x];
clc = previewreti ? settings->previewselection * 100.f : bufchro[y][x]; clc = previewreti ? settings->previewselection * 100.f : bufchro[y][x];
@ -3039,7 +3048,7 @@ void ImProcFunctions::transit_shapedetect_retinex(int call, int senstype, LabIma
float lightc; float lightc;
if (call == 2) { if (call == 2) {
lightc = bufexporig->L[loy - begy][lox - begx]; lightc = bufexporig->L[y - ystart][x - xstart];
} else { } else {
lightc = bufexporig->L[y][x]; lightc = bufexporig->L[y][x];
} }
@ -3055,7 +3064,7 @@ void ImProcFunctions::transit_shapedetect_retinex(int call, int senstype, LabIma
} else { } else {
if (call == 2) { if (call == 2) {
transformed->L[y][x] = bufmask->L[loy - begy][lox - begx]; transformed->L[y][x] = bufmask->L[y - ystart][x - xstart];
} else { } else {
transformed->L[y][x] = bufmask->L[y][x]; transformed->L[y][x] = bufmask->L[y][x];
} }
@ -3070,8 +3079,8 @@ void ImProcFunctions::transit_shapedetect_retinex(int call, int senstype, LabIma
float chra, chrb; float chra, chrb;
if (call == 2) { if (call == 2) {
chra = bufexporig->a[loy - begy][lox - begx]; chra = bufexporig->a[y - ystart][x - xstart];
chrb = bufexporig->b[loy - begy][lox - begx]; chrb = bufexporig->b[y - ystart][x - xstart];
} else { } else {
chra = bufexporig->a[y][x]; chra = bufexporig->a[y][x];
chrb = bufexporig->b[y][x]; chrb = bufexporig->b[y][x];
@ -3090,8 +3099,8 @@ void ImProcFunctions::transit_shapedetect_retinex(int call, int senstype, LabIma
if (showmas) { if (showmas) {
if (call == 2) { if (call == 2) {
transformed->a[y][x] = bufmask->a[loy - begy][lox - begx]; transformed->a[y][x] = bufmask->a[y - ystart][x - xstart];
transformed->b[y][x] = bufmask->b[loy - begy][lox - begx]; transformed->b[y][x] = bufmask->b[y - ystart][x - xstart];
} else { } else {
transformed->a[y][x] = bufmask->a[y][x]; transformed->a[y][x] = bufmask->a[y][x];
transformed->b[y][x] = bufmask->b[y][x]; transformed->b[y][x] = bufmask->b[y][x];
@ -8728,7 +8737,7 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o
buflight[ir][jr] /= coef; buflight[ir][jr] /= coef;
bufl_ab[ir][jr] /= coefC; bufl_ab[ir][jr] /= coefC;
// if(params->locallab.spots.at(sp).lumonly) { // if(params->locallab.spots.at(sp).lumonly) {
// if (lp.str >= 0.1f) { // if (lp.str >= 0.1f) {
// bufl_ab[ir][jr] = 0.f; // bufl_ab[ir][jr] = 0.f;
// } // }
} }
@ -8964,9 +8973,9 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o
float minCD, maxCD, mini, maxi, Tmean, Tsigma, Tmin, Tmax; float minCD, maxCD, mini, maxi, Tmean, Tsigma, Tmin, Tmax;
bool fftw = lp.ftwreti; bool fftw = lp.ftwreti;
// fftw = false; // fftw = false;
//for Retinex Mask are incorporated in MSR //for Retinex Mask are incorporated in MSR
ImProcFunctions::MSRLocal(sp, fftw, 1, bufreti, bufmask, buforig, buforigmas, orig, tmpl->L, orig1, Wd, Hd, params->locallab, sk, locRETgainCcurve, 0, 4, 1.f, minCD, maxCD, mini, maxi, Tmean, Tsigma, Tmin, Tmax, ImProcFunctions::MSRLocal(sp, fftw, 1, bufreti, bufmask, buforig, buforigmas, orig, tmpl->L, orig1, Wd, Hd, Wd, Hd, params->locallab, sk, locRETgainCcurve, 0, 4, 1.f, minCD, maxCD, mini, maxi, Tmean, Tsigma, Tmin, Tmax,
locccmasretiCurve, lcmasretiutili, locllmasretiCurve, llmasretiutili, lochhmasretiCurve, lhmasretiutili, llretiMask, transformed, lp.enaretiMasktmap, lp.enaretiMask); locccmasretiCurve, lcmasretiutili, locllmasretiCurve, llmasretiutili, lochhmasretiCurve, lhmasretiutili, llretiMask, transformed, lp.enaretiMasktmap, lp.enaretiMask);
#ifdef _OPENMP #ifdef _OPENMP
@ -9095,7 +9104,7 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o
bool fftw = false; bool fftw = false;
if (params->locallab.spots.at(sp).chrrt > 40.f) { //second step active Retinex Chroma if (params->locallab.spots.at(sp).chrrt > 40.f) { //second step active Retinex Chroma
ImProcFunctions::MSRLocal(sp, fftw, 0, bufreti, bufmask, buforig, buforigmas, orig, tmpl->L, orig1, Wd, Hd, params->locallab, sk, locRETgainCcurve, 1, 4, 0.8f, minCD, maxCD, mini, maxi, Tmean, Tsigma, Tmin, Tmax, ImProcFunctions::MSRLocal(sp, fftw, 0, bufreti, bufmask, buforig, buforigmas, orig, tmpl->L, orig1, Wd, Hd, Wd, Hd, params->locallab, sk, locRETgainCcurve, 1, 4, 0.8f, minCD, maxCD, mini, maxi, Tmean, Tsigma, Tmin, Tmax,
locccmasretiCurve, lcmasretiutili, locllmasretiCurve, llmasretiutili, lochhmasretiCurve, lhmasretiutili, llretiMask, transformed, lp.enaretiMasktmap, lp.enaretiMask); locccmasretiCurve, lcmasretiutili, locllmasretiCurve, llmasretiutili, lochhmasretiCurve, lhmasretiutili, llretiMask, transformed, lp.enaretiMasktmap, lp.enaretiMask);
} }
@ -9204,17 +9213,19 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o
int yend = std::min(static_cast<int>(lp.yc + lp.ly) - cy, original->H); int yend = std::min(static_cast<int>(lp.yc + lp.ly) - cy, original->H);
int xstart = std::max(static_cast<int>(lp.xc - lp.lxL) - cx, 0); int xstart = std::max(static_cast<int>(lp.xc - lp.lxL) - cx, 0);
int xend = std::min(static_cast<int>(lp.xc + lp.lx) - cx, original->W); int xend = std::min(static_cast<int>(lp.xc + lp.lx) - cx, original->W);
int bfhz = yend - ystart; int bfh = yend - ystart;
int bfwz = xend - xstart; int bfw = xend - xstart;
LabImage *bufreti = nullptr; LabImage *bufreti = nullptr;
LabImage *bufmask = nullptr; LabImage *bufmask = nullptr;
LabImage *buforig = nullptr; LabImage *buforig = nullptr;
LabImage *buforigmas = nullptr; LabImage *buforigmas = nullptr;
int bfh = int (lp.ly + lp.lyT) + del; //bfw bfh real size of square zone int bfhr = bfh;
int bfw = int (lp.lx + lp.lxL) + del; int bfwr = bfw;
bool reduH = false;
bool reduW = false;
if (bfwz > 2 && bfhz > 2) { if (bfw > 2 && bfh > 2) {
if (lp.ftwreti) { if (lp.ftwreti) {
int ftsizeH = 1; int ftsizeH = 1;
@ -9234,10 +9245,6 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o
} }
} }
int ystart = std::max(static_cast<int>(lp.yc - lp.lyT) - cy, 0);
int xstart = std::max(static_cast<int>(lp.xc - lp.lxL) - cx, 0);
int yend = std::min(static_cast<int>(lp.yc + lp.ly) - cy, original->H);
int xend = std::min(static_cast<int>(lp.xc + lp.lx) - cx, original->W);
if (ystart == 0 && yend < original->H) { if (ystart == 0 && yend < original->H) {
lp.ly -= (bfh - ftsizeH); lp.ly -= (bfh - ftsizeH);
@ -9249,6 +9256,9 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o
} else { } else {
lp.ly -= (bfh - ftsizeH); lp.ly -= (bfh - ftsizeH);
} }
} else if (ystart == 0 && yend == original->H) {
bfhr = ftsizeH;
reduH = true;
} }
if (xstart == 0 && xend < original->W) { if (xstart == 0 && xend < original->W) {
@ -9261,14 +9271,33 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o
} else { } else {
lp.lx -= (bfw - ftsizeW); lp.lx -= (bfw - ftsizeW);
} }
} else if (xstart == 0 && xend == original->W) {
bfwr = ftsizeW;
reduW = true;
} }
//new size bfw, bfh not optimized if spot H > high or spot W > width ==> TODO
bfh = int (lp.ly + lp.lyT) + del; //new values optimized
bfw = int (lp.lx + lp.lxL) + del; ystart = std::max(static_cast<int>(lp.yc - lp.lyT) - cy, 0);
yend = std::min(static_cast<int>(lp.yc + lp.ly) - cy, original->H);
xstart = std::max(static_cast<int>(lp.xc - lp.lxL) - cx, 0);
xend = std::min(static_cast<int>(lp.xc + lp.lx) - cx, original->W);
bfh = bfhr = yend - ystart;
bfw = bfwr = xend - xstart;
if (reduH) {
bfhr = ftsizeH;
}
if (reduW) {
bfwr = ftsizeW;
}
// printf("bfh1=%i bfw1=%i bfhr=%i bfwr=%i ftsiH=%i ftsiW=%i\n", bfh, bfw, bfhr, bfwr, ftsizeH, ftsizeW);
} }
array2D<float> buflight(bfw, bfh); array2D<float> buflight(bfw, bfh);
JaggedArray<float> bufchro(bfw, bfh); JaggedArray<float> bufchro(bfw, bfh);
@ -9306,32 +9335,33 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o
int yEn = lp.yc + lp.ly; int yEn = lp.yc + lp.ly;
int xEn = lp.xc + lp.lx; int xEn = lp.xc + lp.lx;
#ifdef _OPENMP #ifdef _OPENMP
#pragma omp parallel for schedule(dynamic,16) #pragma omp parallel for schedule(dynamic,16)
#endif #endif
for (int y = 0; y < transformed->H ; y++) //{ for (int y = ystart; y < yend; y++) {
for (int x = 0; x < transformed->W; x++) { for (int x = xstart; x < xend; x++) {
int lox = cx + x; bufreti->L[y - ystart][x - xstart] = original->L[y][x];
int loy = cy + y; bufreti->a[y - ystart][x - xstart] = original->a[y][x];
bufreti->b[y - ystart][x - xstart] = original->b[y][x];
bufmask->L[y - ystart][x - xstart] = original->L[y][x];
bufmask->a[y - ystart][x - xstart] = original->a[y][x];
bufmask->b[y - ystart][x - xstart] = original->b[y][x];
if (lox >= begx && lox < xEn && loy >= begy && loy < yEn) { if (!lp.enaretiMasktmap && lp.enaretiMask) {
bufreti->L[loy - begy][lox - begx] = original->L[y][x]; buforig->L[y - ystart][x - xstart] = original->L[y][x];
bufreti->a[loy - begy][lox - begx] = original->a[y][x]; buforig->a[y - ystart][x - xstart] = original->a[y][x];
bufreti->b[loy - begy][lox - begx] = original->b[y][x]; buforig->b[y - ystart][x - xstart] = original->b[y][x];
bufmask->L[loy - begy][lox - begx] = original->L[y][x];
bufmask->a[loy - begy][lox - begx] = original->a[y][x];
bufmask->b[loy - begy][lox - begx] = original->b[y][x];
if (!lp.enaretiMasktmap && lp.enaretiMask) {
buforig->L[loy - begy][lox - begx] = original->L[y][x];
buforig->a[loy - begy][lox - begx] = original->a[y][x];
buforig->b[loy - begy][lox - begx] = original->b[y][x];
}
} }
} }
}
} }
float *orig[Hd] ALIGNED16; float *orig[Hd] ALIGNED16;
float *origBuffer = new float[Hd * Wd]; float *origBuffer = new float[Hd * Wd];
@ -9418,7 +9448,8 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o
float minCD, maxCD, mini, maxi, Tmean, Tsigma, Tmin, Tmax; float minCD, maxCD, mini, maxi, Tmean, Tsigma, Tmin, Tmax;
bool fftw = lp.ftwreti; bool fftw = lp.ftwreti;
//for Retinex Mask are incorporated in MSR //for Retinex Mask are incorporated in MSR
ImProcFunctions::MSRLocal(sp, fftw, 1, bufreti, bufmask, buforig, buforigmas, orig, tmpl->L, orig1, Wd, Hd, params->locallab, sk, locRETgainCcurve, 0, 4, 1.f, minCD, maxCD, mini, maxi, Tmean, Tsigma, Tmin, Tmax,
ImProcFunctions::MSRLocal(sp, fftw, 1, bufreti, bufmask, buforig, buforigmas, orig, tmpl->L, orig1, Wd, Hd, bfwr, bfhr, params->locallab, sk, locRETgainCcurve, 0, 4, 1.f, minCD, maxCD, mini, maxi, Tmean, Tsigma, Tmin, Tmax,
locccmasretiCurve, lcmasretiutili, locllmasretiCurve, llmasretiutili, lochhmasretiCurve, lhmasretiutili, llretiMask, transformed, lp.enaretiMasktmap, lp.enaretiMask); locccmasretiCurve, lcmasretiutili, locllmasretiCurve, llmasretiutili, lochhmasretiCurve, lhmasretiutili, llretiMask, transformed, lp.enaretiMasktmap, lp.enaretiMask);
#ifdef _OPENMP #ifdef _OPENMP
@ -9430,6 +9461,7 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o
tmpl->L[ir][jr] = orig[ir][jr]; tmpl->L[ir][jr] = orig[ir][jr];
} }
if (lp.equret) { //equilibrate luminance before / after MSR if (lp.equret) { //equilibrate luminance before / after MSR
float *datain = new float[Hd * Wd]; float *datain = new float[Hd * Wd];
float *data = new float[Hd * Wd]; float *data = new float[Hd * Wd];
@ -9458,6 +9490,7 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o
} }
if (!lp.invret) { if (!lp.invret) {
float minL = tmpl->L[0][0] - bufreti->L[0][0]; float minL = tmpl->L[0][0] - bufreti->L[0][0];
float maxL = minL; float maxL = minL;
@ -9483,6 +9516,7 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o
} }
/* /*
if (lp.softradiusret > 0.f && lp.scalereti != 1) { if (lp.softradiusret > 0.f && lp.scalereti != 1) {
// softprocess(bufreti, buflight, lp.softradiusret, Hd, Wd, sk, 0.01, 0.001, 0.0001f, multiThread); // softprocess(bufreti, buflight, lp.softradiusret, Hd, Wd, sk, 0.01, 0.001, 0.0001f, multiThread);
@ -9553,7 +9587,7 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o
bool fftw = false; bool fftw = false;
if (params->locallab.spots.at(sp).chrrt > 40.f) { //second step active Retinex Chroma if (params->locallab.spots.at(sp).chrrt > 40.f) { //second step active Retinex Chroma
ImProcFunctions::MSRLocal(sp, fftw, 0, bufreti, bufmask, buforig, buforigmas, orig, tmpl->L, orig1, Wd, Hd, params->locallab, sk, locRETgainCcurve, 1, 4, 0.8f, minCD, maxCD, mini, maxi, Tmean, Tsigma, Tmin, Tmax, ImProcFunctions::MSRLocal(sp, fftw, 0, bufreti, bufmask, buforig, buforigmas, orig, tmpl->L, orig1, Wd, Hd, Wd, Hd, params->locallab, sk, locRETgainCcurve, 1, 4, 0.8f, minCD, maxCD, mini, maxi, Tmean, Tsigma, Tmin, Tmax,
locccmasretiCurve, lcmasretiutili, locllmasretiCurve, llmasretiutili, lochhmasretiCurve, lhmasretiutili, llretiMask, transformed, lp.enaretiMasktmap, lp.enaretiMask); locccmasretiCurve, lcmasretiutili, locllmasretiCurve, llmasretiutili, lochhmasretiCurve, lhmasretiutili, llretiMask, transformed, lp.enaretiMasktmap, lp.enaretiMask);
} }

View File

@ -48,6 +48,8 @@
#include "procparams.h" #include "procparams.h"
#include "rawimagesource.h" #include "rawimagesource.h"
#include "rtengine.h" #include "rtengine.h"
#define BENCHMARK
#include "StopWatch.h" #include "StopWatch.h"
#include "guidedfilter.h" #include "guidedfilter.h"
@ -848,7 +850,7 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e
} }
} }
void ImProcFunctions::MSRLocal(int sp, bool fftw, int lum, LabImage * bufreti, LabImage * bufmask, LabImage * buforig, LabImage * buforigmas, 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 ImProcFunctions::MSRLocal(int sp, bool fftw, int lum, 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 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,
const LocCCmaskCurve & locccmasretiCurve, bool &lcmasretiutili, const LocLLmaskCurve & locllmasretiCurve, bool &llmasretiutili, const LocHHmaskCurve & lochhmasretiCurve, bool & lhmasretiutili, int llretiMask, LabImage * transformed, bool retiMasktmap, bool retiMask) const LocCCmaskCurve & locccmasretiCurve, bool &lcmasretiutili, const LocLLmaskCurve & locllmasretiCurve, bool &llmasretiutili, const LocHHmaskCurve & lochhmasretiCurve, bool & lhmasretiutili, int llretiMask, LabImage * transformed, bool retiMasktmap, bool retiMask)
{ {
BENCHFUN BENCHFUN
@ -1018,16 +1020,16 @@ void ImProcFunctions::MSRLocal(int sp, bool fftw, int lum, LabImage * bufreti, L
} else { } else {
if (scale == scal - 1) { if (scale == scal - 1) {
if (settings->fftwsigma == false) { //empirical formula if (settings->fftwsigma == false) { //empirical formula
ImProcFunctions::fftw_convol_blur2(src, out, W_L, H_L, (kr * RetinexScales[scale]), 0, 0); ImProcFunctions::fftw_convol_blur2(src, out, bfwr, bfhr, (kr * RetinexScales[scale]), 0, 0);
} else { } else {
ImProcFunctions::fftw_convol_blur2(src, out, W_L, H_L, (SQR(RetinexScales[scale])), 0, 0); ImProcFunctions::fftw_convol_blur2(src, out, bfwr, bfhr, (SQR(RetinexScales[scale])), 0, 0);
} }
} else { // reuse result of last iteration } else { // reuse result of last iteration
// out was modified in last iteration => restore it // out was modified in last iteration => restore it
if (settings->fftwsigma == false) { //empirical formula if (settings->fftwsigma == false) { //empirical formula
ImProcFunctions::fftw_convol_blur2(out, out, W_L, H_L, sqrtf(SQR(kr * RetinexScales[scale]) - SQR(kr * RetinexScales[scale + 1])), 0, 0); ImProcFunctions::fftw_convol_blur2(out, out, bfwr, bfhr, sqrtf(SQR(kr * RetinexScales[scale]) - SQR(kr * RetinexScales[scale + 1])), 0, 0);
} else { } else {
ImProcFunctions::fftw_convol_blur2(out, out, W_L, H_L, (SQR(RetinexScales[scale]) - SQR(RetinexScales[scale + 1])), 0, 0); ImProcFunctions::fftw_convol_blur2(out, out, bfwr, bfhr, (SQR(RetinexScales[scale]) - SQR(RetinexScales[scale + 1])), 0, 0);
} }
} }
} }