diff --git a/rtengine/improccoordinator.cc b/rtengine/improccoordinator.cc index c6800956d..9546d372c 100644 --- a/rtengine/improccoordinator.cc +++ b/rtengine/improccoordinator.cc @@ -720,24 +720,47 @@ void ImProcCoordinator::updatePreviewImage(int todo, bool panningRelatedChange) whiteev = new float[sizespot]; bool *Autogr = nullptr; Autogr = new bool[sizespot]; + + float *locx = nullptr; + locx = new float[sizespot]; + float *locy = nullptr; + locy = new float[sizespot]; + float *locxL = nullptr; + locxL = new float[sizespot]; + float *locyT = nullptr; + locyT = new float[sizespot]; + float *centx = nullptr; + centx = new float[sizespot]; + float *centy = nullptr; + centy = new float[sizespot]; + for (int sp = 0; sp < params->locallab.nbspot && sp < sizespot; sp++) { log[sp] = params->locallab.spots.at(sp).explog; autocomput[sp] = params->locallab.spots.at(sp).autocompute; - // sourcegray blackev, whitev blackev[sp] = params->locallab.spots.at(sp).blackEv; whiteev[sp] = params->locallab.spots.at(sp).whiteEv; sourceg[sp] = params->locallab.spots.at(sp).sourceGray; Autogr[sp] = params->locallab.spots.at(sp).Autogray; targetg[sp] = params->locallab.spots.at(sp).targetGray; + locx[sp] = params->locallab.spots.at(sp).locX / 2000.0; + locy[sp] = params->locallab.spots.at(sp).locY / 2000.0; + locxL[sp] = params->locallab.spots.at(sp).locXL / 2000.0; + locyT[sp] = params->locallab.spots.at(sp).locYT / 2000.0; + centx[sp] = params->locallab.spots.at(sp).centerX / 2000.0 + 0.5; + centy[sp] = params->locallab.spots.at(sp).centerY / 2000.0 + 0.5; if (log[sp] && autocomput[sp]) { constexpr int SCALE = 10; int fw, fh, tr = TR_NONE; imgsrc->getFullSize(fw, fh, tr); PreviewProps pp(0, 0, fw, fh, SCALE); + float ysta = std::max(static_cast(centy[sp] - locyT[sp]), 0.f); + float yend = std::min(static_cast(centy[sp] + locy[sp]), 1.f); + float xsta = std::max(static_cast(centx[sp] - locxL[sp]), 0.f); + float xend = std::min(static_cast(centx[sp] + locx[sp]), 1.f); - ipf.getAutoLogloc(sp, imgsrc, sourceg, blackev, whiteev, Autogr, fw, fh, SCALE); + ipf.getAutoLogloc(sp, imgsrc, sourceg, blackev, whiteev, Autogr, fw, fh, xsta, xend, ysta, yend, SCALE); params->locallab.spots.at(sp).blackEv = blackev[sp]; params->locallab.spots.at(sp).whiteEv = whiteev[sp]; params->locallab.spots.at(sp).sourceGray = sourceg[sp]; @@ -748,6 +771,12 @@ void ImProcCoordinator::updatePreviewImage(int todo, bool panningRelatedChange) } } + delete [] locx; + delete [] locy; + delete [] locxL; + delete [] locyT; + delete [] centx; + delete [] centy; delete [] Autogr; delete [] whiteev; diff --git a/rtengine/improcfun.h b/rtengine/improcfun.h index fbf8d96cb..cc1cb151a 100644 --- a/rtengine/improcfun.h +++ b/rtengine/improcfun.h @@ -256,9 +256,10 @@ public: bool delt, 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 lumask); + //3 functions from Alberto Griggio, adapted J.Desmis 2019 void filmGrain(Imagefloat *rgb, int isogr, int strengr, int scalegr, int bfw, int bfh); void log_encode(Imagefloat *rgb, struct local_params & lp, float scale, bool multiThread); - void getAutoLogloc(int sp, ImageSource *imgsrc, float *sourceg, float *blackev, float *whiteev, bool *Autogr, int fw, int fh, int SCALE); + void getAutoLogloc(int sp, ImageSource *imgsrc, float *sourceg, float *blackev, float *whiteev, bool *Autogr, int fw, int fh, float xsta, float xend, float ysta, float yend, int SCALE); void MSRLocal(int call, 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, diff --git a/rtengine/iplocallab.cc b/rtengine/iplocallab.cc index 394670acc..831fb9f06 100644 --- a/rtengine/iplocallab.cc +++ b/rtengine/iplocallab.cc @@ -1253,7 +1253,8 @@ float find_gray(float source_gray, float target_gray) // (as seen on pixls.us) void ImProcFunctions::log_encode(Imagefloat *rgb, struct local_params & lp, float scale, bool multiThread) { - //small adaptations to local adjustemnts J.Desmis 12 2019 + //small adaptations to local adjustements J.Desmis 12 2019 + BENCHFUN const float gray = lp.sourcegray / 100.f; const float shadows_range = lp.blackev; const float dynamic_range = lp.whiteev - lp.blackev; @@ -1391,9 +1392,10 @@ void ImProcFunctions::log_encode(Imagefloat *rgb, struct local_params & lp, floa -void ImProcFunctions::getAutoLogloc(int sp, ImageSource *imgsrc, float *sourceg, float *blackev, float *whiteev, bool *Autogr, int fw, int fh, int SCALE) +void ImProcFunctions::getAutoLogloc(int sp, ImageSource *imgsrc, float *sourceg, float *blackev, float *whiteev, bool *Autogr, int fw, int fh, float xsta, float xend, float ysta, float yend, int SCALE) { - + BENCHFUN +//adpatation to local adjustements Jacques Desmis 12 2019 PreviewProps pp(0, 0, fw, fh, SCALE); Imagefloat img(int(fw / SCALE + 0.5), int(fh / SCALE + 0.5)); @@ -1408,9 +1410,21 @@ void ImProcFunctions::getAutoLogloc(int sp, ImageSource *imgsrc, float *sourceg, const float ec = always ? std::pow(2.f, params->toneCurve.expcomp) : 1.f; constexpr float noise = 1e-5; + int h = fh / SCALE; + int w = fw / SCALE; + // printf("h=%d w=%d\n", h, w); + // printf("xsta=%f xend=%f ysta=%f yend=%f\n", xsta, xend, ysta, yend); + - for (int y = 0, h = fh / SCALE; y < h; ++y) { - for (int x = 0, w = fw / SCALE; x < w; ++x) { + int hsta = ysta * h; + int hend = yend * h; + + int wsta = xsta * w; + int wend = xend * w; + + //printf("h=%d w=%d hsta=%d hend=%d wsta=%d wend=%d\n", h, w, hsta, hend, wsta, wend); + for (int y = hsta; y < hend; ++y) { + for (int x = wsta; x < wend; ++x) { float r = img.r(y, x), g = img.g(y, x), b = img.b(y, x); float m = max(0.f, r, g, b) / 65535.f * ec; @@ -1441,8 +1455,8 @@ void ImProcFunctions::getAutoLogloc(int sp, ImageSource *imgsrc, float *sourceg, std::cout << " gray boundaries: " << gmin << ", " << gmax << std::endl; } - for (int y = 0, h = fh / SCALE; y < h; ++y) { - for (int x = 0, w = fw / SCALE; x < w; ++x) { + for (int y = ysta; y < yend; ++y) { + for (int x = wsta; x < wend; ++x) { float l = img.g(y, x) / 65535.f; if (l >= gmin && l <= gmax) { @@ -1460,7 +1474,6 @@ void ImProcFunctions::getAutoLogloc(int sp, ImageSource *imgsrc, float *sourceg, } } else if (settings->verbose) { std::cout << " no samples found in range, resorting to default gray point value" << std::endl; - // lp.sourcegray = LogEncodingParams().sourceGray; } } @@ -8416,7 +8429,6 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o //encoding lab at the beginning if (lp.logena) { - printf("OK log\n"); int ystart = std::max(static_cast(lp.yc - lp.lyT) - cy, 0); int yend = std::min(static_cast(lp.yc + lp.ly) - cy, original->H); int xstart = std::max(static_cast(lp.xc - lp.lxL) - cx, 0); diff --git a/rtgui/locallab.cc b/rtgui/locallab.cc index 06e2c8efa..faa445240 100644 --- a/rtgui/locallab.cc +++ b/rtgui/locallab.cc @@ -3322,7 +3322,7 @@ pe(nullptr) logBox->pack_start(*sensilog); -// panel->pack_start(*explog, false, false); + panel->pack_start(*explog, false, false); pack_start(*panel);