From 9f8a2de75225d97daf33a99d19675b2901e50594 Mon Sep 17 00:00:00 2001 From: Desmis Date: Fri, 3 Jan 2020 17:54:19 +0100 Subject: [PATCH] Chnage to encoding --- rtdata/languages/default | 4 +-- rtengine/iplocallab.cc | 54 ++++++++-------------------------------- rtengine/procparams.cc | 4 +-- rtengine/procparams.h | 2 +- rtgui/locallab.cc | 6 ++--- 5 files changed, 18 insertions(+), 52 deletions(-) diff --git a/rtdata/languages/default b/rtdata/languages/default index c4e6e1920..f8ab3a3fa 100644 --- a/rtdata/languages/default +++ b/rtdata/languages/default @@ -1090,7 +1090,7 @@ HISTORY_MSG_849;Local - Auto Grayon HISTORY_MSG_850;Local - Black Ev HISTORY_MSG_851;Local - White Ev HISTORY_MSG_852;Local - Target Gray -HISTORY_MSG_853;Local - Detail +HISTORY_MSG_853;Local - Local contrast HISTORY_MSG_854;Local - Scope encoding log HISTORY_MSG_855;Local - Entire image HISTORY_MSG_856;Local - Base log @@ -2282,7 +2282,7 @@ TP_LOCALLAB_DEHAZ_TOOLTIP;Negative values add haze TP_LOCALLAB_DELTAEC;Mask ΔE Image TP_LOCALLAB_DENOIS;Ψ Denoise TP_LOCALLAB_DEPTH;Depth -TP_LOCALLAB_DETAIL;Detail (Guided Filter) +TP_LOCALLAB_DETAIL;Local contrast TP_LOCALLAB_DETAILSH;Details TP_LOCALLAB_DETAILTHR;Detail threshold Luminance Chroma (DCT ƒ) TP_LOCALLAB_DUPLSPOTNAME;Copy diff --git a/rtengine/iplocallab.cc b/rtengine/iplocallab.cc index 64af73588..34a267dc1 100644 --- a/rtengine/iplocallab.cc +++ b/rtengine/iplocallab.cc @@ -415,7 +415,7 @@ struct local_params { float targetgray; float blackev; float whiteev; - int detail; + float detail; int sensilog; bool Autogray; bool autocompute; @@ -1350,7 +1350,7 @@ void ImProcFunctions::log_encode(Imagefloat *rgb, struct local_params & lp, floa return x; } }; - + printf("sc=%f\n", scale); const auto norm = [&](float r, float g, float b) -> float { return Color::rgbLuminance(r, g, b, ws); @@ -1380,11 +1380,11 @@ void ImProcFunctions::log_encode(Imagefloat *rgb, struct local_params & lp, floa // } }; - const int detail2 = float(max(lp.detail, 0)) / scale + 0.5f; - const int detail = lp.detail; +// const int detail2 = float(max(lp.detail, 0)) / scale + 0.5f; + const float detail = lp.detail; const int W = rgb->getWidth(), H = rgb->getHeight(); - if (detail == 0) {//no preser contrast + if (detail == 0.f) {//no local contrast #ifdef _OPENMP # pragma omp parallel for if (multiThread) #endif @@ -1413,45 +1413,7 @@ void ImProcFunctions::log_encode(Imagefloat *rgb, struct local_params & lp, floa rgb->b(y, x) = b; } } - } else if (detail > 1) {//old process ==>2 - - const int W = rgb->getWidth(), H = rgb->getHeight(); - array2D tmp(W, H); -#ifdef _OPENMP - # pragma omp parallel for if (multiThread) -#endif - - for (int y = 0; y < H; ++y) { - for (int x = 0; x < W; ++x) { - tmp[y][x] = norm(rgb->r(y, x), rgb->g(y, x), rgb->b(y, x)) / 65535.f; - } - } - - const float epsilon = 0.01f + 0.002f * max(detail2 - 3, 0); - guidedFilterLog(10.f, tmp, detail2, epsilon, multiThread); - -#ifdef _OPENMP - # pragma omp parallel for if (multiThread) -#endif - - for (int y = 0; y < H; ++y) { - for (int x = 0; x < W; ++x) { - float &r = rgb->r(y, x); - float &g = rgb->g(y, x); - float &b = rgb->b(y, x); - float m = norm(r, g, b); - float t = intp(0.33f, m, tmp[y][x] * 65535.f); - - if (t > noise) { - float c = apply(t); - float f = c / t; - r *= f; - g *= f; - b *= f; - } - } - } - } else if (detail == 1) {//preserve local contrast + } else {//local contrast array2D Y(W, H); { @@ -1475,6 +1437,7 @@ void ImProcFunctions::log_encode(Imagefloat *rgb, struct local_params & lp, floa const float epsilon = 0.005f; rtengine::guidedFilter(Y2, Y, Y, radius, epsilon, multiThread); } + const float blend = detail; #ifdef _OPENMP # pragma omp parallel for if (multiThread) @@ -1490,6 +1453,9 @@ void ImProcFunctions::log_encode(Imagefloat *rgb, struct local_params & lp, floa if (t > noise) { float c = apply(t, false); float f = c / t; + float t2 = norm(r, g, b); + float f2 = apply(t2) / t2; + f = intp(blend, f, f2); r *= f; g *= f; b *= f; diff --git a/rtengine/procparams.cc b/rtengine/procparams.cc index 06c4e20b9..40ebfeed6 100644 --- a/rtengine/procparams.cc +++ b/rtengine/procparams.cc @@ -2802,13 +2802,13 @@ LocallabParams::LocallabSpot::LocallabSpot() : explog(false), autocompute(false), // autogray(true), - sourceGray(18.), + sourceGray(10.), targetGray(18.), Autogray(true), fullimage(true), blackEv(-5.0), whiteEv(10.0), - detail(1), + detail(0.6), sensilog(50), baselog(2.) diff --git a/rtengine/procparams.h b/rtengine/procparams.h index bdaa32bd6..070e4db25 100644 --- a/rtengine/procparams.h +++ b/rtengine/procparams.h @@ -1351,7 +1351,7 @@ struct LocallabParams { bool fullimage; double blackEv; double whiteEv; - int detail; + double detail; int sensilog; double baselog; diff --git a/rtgui/locallab.cc b/rtgui/locallab.cc index a0bb4b202..44a0fbe7c 100644 --- a/rtgui/locallab.cc +++ b/rtgui/locallab.cc @@ -640,11 +640,11 @@ bilateral(Gtk::manage(new Adjuster(M("TP_LOCALLAB_BILATERAL"), 0, 100, 1, 0))), sensiden(Gtk::manage(new Adjuster(M("TP_LOCALLAB_SENSIDEN"), 0, 100, 1, 20))), detailthr(Gtk::manage(new Adjuster(M("TP_LOCALLAB_DETAILTHR"), 0, 100, 1, 0))), //log encoding -sourceGray(Gtk::manage(new Adjuster(M("TP_LOCALLAB_SOURCE_GRAY"), 1.0, 100.0, 0.1, 18.0))), +sourceGray(Gtk::manage(new Adjuster(M("TP_LOCALLAB_SOURCE_GRAY"), 1.0, 100.0, 0.1, 10.0))), targetGray(Gtk::manage(new Adjuster(M("TP_LOCALLAB_TARGET_GRAY"), 5.0, 80.0, 0.1, 18.0))), blackEv(Gtk::manage(new Adjuster(M("TP_LOCALLAB_BLACK_EV"), -16.0, 0.0, 0.1, -5.0))), whiteEv(Gtk::manage(new Adjuster(M("TP_LOCALLAB_WHITE_EV"), 0.0, 32.0, 0.1, 10.0))), -detail(Gtk::manage(new Adjuster(M("TP_LOCALLAB_DETAIL"), 0, 2, 1, 1))), +detail(Gtk::manage(new Adjuster(M("TP_LOCALLAB_DETAIL"), 0., 1., 0.01, 0.6))), sensilog(Gtk::manage(new Adjuster(M("TP_LOCALLAB_SENSILOG"), 0, 100, 1, 50))), baselog(Gtk::manage(new Adjuster(M("TP_LOCALLAB_BASELOG"), 1.3, 8., 0.05, 2., Gtk::manage(new RTImage("circle-black-small.png")), Gtk::manage(new RTImage("circle-white-small.png"))))), @@ -5433,7 +5433,7 @@ void Locallab::write(rtengine::procparams::ProcParams* pp, ParamsEdited* pedited pp->locallab.spots.at(pp->locallab.selspot).blackEv = blackEv->getValue(); pp->locallab.spots.at(pp->locallab.selspot).whiteEv = whiteEv->getValue(); pp->locallab.spots.at(pp->locallab.selspot).targetGray = targetGray->getValue(); - pp->locallab.spots.at(pp->locallab.selspot).detail = detail->getIntValue(); + pp->locallab.spots.at(pp->locallab.selspot).detail = detail->getValue(); pp->locallab.spots.at(pp->locallab.selspot).sensilog = sensilog->getIntValue(); pp->locallab.spots.at(pp->locallab.selspot).baselog = baselog->getValue();