diff --git a/rtengine/procparams.cc b/rtengine/procparams.cc index 8fbab7a8d..a8178dde5 100644 --- a/rtengine/procparams.cc +++ b/rtengine/procparams.cc @@ -1468,7 +1468,7 @@ bool EPDParams::operator !=(const EPDParams& other) const FattalToneMappingParams::FattalToneMappingParams() : enabled(false), threshold(0), - amount(1) + amount(30) { } diff --git a/rtengine/tmo_fattal02.cc b/rtengine/tmo_fattal02.cc index 645451905..1e3669882 100644 --- a/rtengine/tmo_fattal02.cc +++ b/rtengine/tmo_fattal02.cc @@ -1121,13 +1121,20 @@ void ImProcFunctions::ToneMapFattal02 (Imagefloat *rgb) const float min_luminance = 1.f; TMatrix ws = ICCStore::getInstance()->workingSpaceMatrix (params->icm.working); + float max_Y = 0.f; + int max_x = 0, max_y = 0; + #ifdef _OPENMP #pragma omp parallel for if (multiThread) #endif - for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++) { Yr (x, y) = std::max (luminance (rgb->r (y, x), rgb->g (y, x), rgb->b (y, x), ws), min_luminance); // clip really black pixels + if (Yr(x, y) > max_Y) { + max_Y = Yr(x, y); + max_x = x; + max_y = y; + } } } @@ -1170,6 +1177,8 @@ void ImProcFunctions::ToneMapFattal02 (Imagefloat *rgb) const float hr = float(h2) / float(h); const float wr = float(w2) / float(w); + + const float scale = std::max(L(max_x * wr + 1, max_y * hr + 1), epsilon) * (65535.f / Yr(max_x, max_y)); #ifdef _OPENMP #pragma omp parallel for if(multiThread) @@ -1181,7 +1190,7 @@ void ImProcFunctions::ToneMapFattal02 (Imagefloat *rgb) int xx = x * wr + 1; float Y = Yr (x, y); - float l = std::max (L (xx, yy), epsilon) * (65535.f / Y); + float l = std::max (L (xx, yy), epsilon) * (65535.f / Y) / scale; rgb->r (y, x) = std::max (rgb->r (y, x), 0.f) * l; rgb->g (y, x) = std::max (rgb->g (y, x), 0.f) * l; rgb->b (y, x) = std::max (rgb->b (y, x), 0.f) * l; diff --git a/rtgui/fattaltonemap.cc b/rtgui/fattaltonemap.cc index 10dba51cf..a6f4c5190 100644 --- a/rtgui/fattaltonemap.cc +++ b/rtgui/fattaltonemap.cc @@ -26,10 +26,7 @@ using namespace rtengine::procparams; FattalToneMapping::FattalToneMapping(): FoldableToolPanel(this, "fattal", M("TP_TM_FATTAL_LABEL"), true, true) { - -// setEnabledTooltipMarkup(M("TP_EPD_TOOLTIP")); - - amount = Gtk::manage(new Adjuster (M("TP_TM_FATTAL_AMOUNT"), 1., 100., 1., 0.0)); + amount = Gtk::manage(new Adjuster (M("TP_TM_FATTAL_AMOUNT"), 1., 100., 30., 0.0)); threshold = Gtk::manage(new Adjuster (M("TP_TM_FATTAL_THRESHOLD"), -100., 100., 1., 0.0)); amount->setAdjusterListener(this);