From fca98702e1ea17f88a13f34f0c1800bd738ac495 Mon Sep 17 00:00:00 2001 From: Desmis Date: Wed, 8 May 2019 07:53:28 +0200 Subject: [PATCH] Improve retinex transmission map with guidefilter --- rtdata/languages/default | 3 ++- rtengine/iplocallab.cc | 2 +- rtengine/ipretinex.cc | 24 ++++++++++++++++++++++++ rtengine/procparams.cc | 12 ++++++------ rtgui/locallab.cc | 12 ++++++------ 5 files changed, 39 insertions(+), 14 deletions(-) diff --git a/rtdata/languages/default b/rtdata/languages/default index 8187f6ea2..b2ea2ba35 100644 --- a/rtdata/languages/default +++ b/rtdata/languages/default @@ -901,7 +901,7 @@ HISTORY_MSG_653;Local - SH mask chroma HISTORY_MSG_654;Local - SH mask gamma HISTORY_MSG_655;Local - SH mask slope HISTORY_MSG_656;Local - Color soft radius -HISTORY_MSG_657;Local - Retinex soft radius +HISTORY_MSG_657;Local - Retinex Guide Filter radius HISTORY_MSG_658;Local - CBDL soft radius HISTORY_MSG_659;Local Spot transition-weakening HISTORY_MSG_660;Local - cbdl clarity @@ -2032,6 +2032,7 @@ TP_LOCALLAB_EXECLU;Excluding spot TP_LOCALLAB_EXPOSE;Exposure TP_LOCALLAB_EXPOSURE_TOOLTIP;In some cases (strong shadows ..) you can use the module "Shadows Highlights" TP_LOCALLAB_EXPCHROMA;Chroma compensation +TP_LOCALLAB_GUIDFILTER;Guide filter radius TP_LOCALLAB_LOC_CONTRAST;Local contrast TP_LOCALLAB_REFLABEL;Ref. (0..1) Chroma=%1 Luma=%2 Hue=%3 TP_LOCALLAB_NOISELUMFINE;Luminance fine 1 (Wav) diff --git a/rtengine/iplocallab.cc b/rtengine/iplocallab.cc index 60f705255..05199566c 100644 --- a/rtengine/iplocallab.cc +++ b/rtengine/iplocallab.cc @@ -5867,7 +5867,7 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o } if (lp.softradiusret > 0.f) { - softprocess(bufreti, buflight, lp.softradiusret, Hd, Wd, sk, multiThread); + // softprocess(bufreti, buflight, lp.softradiusret, Hd, Wd, sk, multiThread); } transit_shapedetect_retinex(4, bufreti, buflight, bufchro, hueref, chromaref, lumaref, lp, original, transformed, cx, cy, sk); diff --git a/rtengine/ipretinex.cc b/rtengine/ipretinex.cc index 4283ac50a..e2621d162 100644 --- a/rtengine/ipretinex.cc +++ b/rtengine/ipretinex.cc @@ -49,6 +49,7 @@ #include "rawimagesource.h" #include "rtengine.h" #include "StopWatch.h" +#include "guidedfilter.h" #define clipretinex( val, minv, maxv ) (( val = (val < minv ? minv : val ) ) > maxv ? maxv : val ) @@ -1016,6 +1017,29 @@ void ImProcFunctions::MSRLocal(int sp, float** luminance, float** templ, const f } } } +//here add GuidFilter for transmission map + array2D ble(W_L, H_L); + array2D guid(W_L, H_L); +#ifdef _OPENMP + #pragma omp parallel for +#endif + for (int i = 0; i < H_L; i ++) + for (int j = 0; j < W_L; j++) { + guid[i][j] = src[i][j]/32768.f; + ble[i][j] = luminance[i][j]/32768.f; + } + + if (loc.spots.at(sp).softradiusret > 0.f) { + guidedFilter(guid, ble, ble, loc.spots.at(sp).softradiusret * 10.f / skip, 1e-5, multiThread, 4); + } + +#ifdef _OPENMP + #pragma omp parallel for +#endif + for (int i = 0; i < H_L; i ++) + for (int j = 0; j < W_L; j++) { + luminance[i][j]= ble[i][j] * 32768.f; + } if (shmap) { delete shmap; diff --git a/rtengine/procparams.cc b/rtengine/procparams.cc index 62ecdce4b..b6f33ea25 100644 --- a/rtengine/procparams.cc +++ b/rtengine/procparams.cc @@ -2470,14 +2470,14 @@ LocallabParams::LocallabSpot::LocallabSpot() : expreti(false), retinexMethod("high"), str(0), - chrrt(0), - neigh(50), - vart(200), - dehaz(0), - sensih(15), + chrrt(40), + neigh(170), + vart(70), + dehaz(25), + sensih(70), localTgaincurve{(double)FCT_MinMaxCPoints, 0.0, 0.12, 0.35, 0.35, 0.70, 0.50, 0.35, 0.35, 1.00, 0.12, 0.35, 0.35}, inversret(false), - softradiusret(0.0), + softradiusret(70.0), // Sharpening expsharp(false), sharcontrast(20), diff --git a/rtgui/locallab.cc b/rtgui/locallab.cc index 1b9ef3a88..e0949140d 100644 --- a/rtgui/locallab.cc +++ b/rtgui/locallab.cc @@ -148,12 +148,12 @@ Locallab::Locallab(): satur(Gtk::manage(new Adjuster(M("TP_LOCALLAB_SATUR"), -100., 100., 0.1, 0.))),//by default satur = 0 ==> use Mantiuk value // Retinex str(Gtk::manage(new Adjuster(M("TP_LOCALLAB_STR"), 0, 100, 1, 0))), - chrrt(Gtk::manage(new Adjuster(M("TP_LOCALLAB_CHRRT"), 0, 100, 1, 0))), - neigh(Gtk::manage(new Adjuster(M("TP_LOCALLAB_NEIGH"), 14, 200, 1, 50))),//14, 150, 1, 50))), - vart(Gtk::manage(new Adjuster(M("TP_LOCALLAB_VART"), 50, 500, 1, 200))), - dehaz(Gtk::manage(new Adjuster(M("TP_LOCALLAB_DEHAZ"), 0, 100, 1, 0))), - sensih(Gtk::manage(new Adjuster(M("TP_LOCALLAB_SENSIH"), 0, 100, 1, 15))), - softradiusret(Gtk::manage(new Adjuster(M("TP_LOCALLAB_SOFTRADIUSCOL"), 0.0, 100.0, 0.1, 0.))), + chrrt(Gtk::manage(new Adjuster(M("TP_LOCALLAB_CHRRT"), 0, 100, 1, 40))), + neigh(Gtk::manage(new Adjuster(M("TP_LOCALLAB_NEIGH"), 14, 200, 1, 150))), + vart(Gtk::manage(new Adjuster(M("TP_LOCALLAB_VART"), 50, 500, 1, 70))), + dehaz(Gtk::manage(new Adjuster(M("TP_LOCALLAB_DEHAZ"), 0, 100, 1, 20))), + sensih(Gtk::manage(new Adjuster(M("TP_LOCALLAB_SENSIH"), 0, 100, 1, 70))), + softradiusret(Gtk::manage(new Adjuster(M("TP_LOCALLAB_GUIDFILTER"), 0.0, 100.0, 0.1, 70.))), // Sharpening sharcontrast(Gtk::manage(new Adjuster(M("TP_SHARPENING_CONTRAST"), 0, 200, 1, 20))), sharradius(Gtk::manage(new Adjuster(M("TP_LOCALLAB_SHARRADIUS"), 0.4, 2.5, 0.01, 0.75))),