From 7f3fdb8f6c88b983d414e8b8e219c163daebcc54 Mon Sep 17 00:00:00 2001 From: heckflosse Date: Mon, 8 Apr 2019 15:08:26 +0200 Subject: [PATCH] locallab: dedup softlight code --- rtengine/dcrop.cc | 5 +---- rtengine/improccoordinator.cc | 2 +- rtengine/improcfun.h | 4 ++-- rtengine/iplocallab.cc | 9 ++++++--- rtengine/ipsoftlight.cc | 32 +++----------------------------- rtengine/rtthumbnail.cc | 2 +- rtengine/simpleprocess.cc | 2 +- 7 files changed, 15 insertions(+), 41 deletions(-) diff --git a/rtengine/dcrop.cc b/rtengine/dcrop.cc index d1eaf800c..56eda0159 100644 --- a/rtengine/dcrop.cc +++ b/rtengine/dcrop.cc @@ -1122,11 +1122,8 @@ void Crop::update(int todo) parent->ipf.ip_wavelet(labnCrop, labnCrop, kall, WaveParams, wavCLVCurve, waOpacityCurveRG, waOpacityCurveBY, waOpacityCurveW, waOpacityCurveWL, parent->wavclCurve, skip); } - parent->ipf.softLight(labnCrop); + parent->ipf.softLight(labnCrop, params.softlight); - // } - - // } if (params.colorappearance.enabled) { float fnum = parent->imgsrc->getMetaData()->getFNumber(); // F number float fiso = parent->imgsrc->getMetaData()->getISOSpeed() ; // ISO diff --git a/rtengine/improccoordinator.cc b/rtengine/improccoordinator.cc index 21d2f7681..0afc4df01 100644 --- a/rtengine/improccoordinator.cc +++ b/rtengine/improccoordinator.cc @@ -1050,7 +1050,7 @@ void ImProcCoordinator::updatePreviewImage(int todo, bool panningRelatedChange) } - ipf.softLight(nprevl); + ipf.softLight(nprevl, params->softlight); if (params->colorappearance.enabled) { //L histo and Chroma histo for ciecam diff --git a/rtengine/improcfun.h b/rtengine/improcfun.h index 6e522a5b1..bb2a4168b 100644 --- a/rtengine/improcfun.h +++ b/rtengine/improcfun.h @@ -48,6 +48,7 @@ struct DehazeParams; struct DirPyrDenoiseParams; struct LocallabParams; struct SharpeningParams; +struct SoftLightParams; struct VibranceParams; struct VignettingParams; struct WaveletParams; @@ -409,8 +410,7 @@ public: // void shadowsHighlights(LabImage *lab); void shadowsHighlights(LabImage *lab, bool ena, int labmode, int hightli, int shado, int rad, int scal, int hltonal, int shtonal); - void softLight(LabImage *lab); - void softLightloc(LabImage *lab, LabImage *dst, float blend); + void softLight(LabImage *lab, const SoftLightParams &softLightParams); void labColorCorrectionRegions(LabImage *lab); Image8* lab2rgb(LabImage* lab, int cx, int cy, int cw, int ch, const procparams::ColorManagementParams &icm, bool consider_histogram_settings = true); diff --git a/rtengine/iplocallab.cc b/rtengine/iplocallab.cc index 2c74652a1..b6ff074cd 100644 --- a/rtengine/iplocallab.cc +++ b/rtengine/iplocallab.cc @@ -361,7 +361,7 @@ static void calcLocalParams(int sp, int oW, int oH, const LocallabParams& locall float est = ((float)locallab.spots.at(sp).estop) / 100.f; float scal_tm = ((float)locallab.spots.at(sp).scaltm) / 10.f; float rewe = ((float)locallab.spots.at(sp).rewei); - float strlight = ((float)locallab.spots.at(sp).streng) / 100.f; + float strlight = ((float)locallab.spots.at(sp).streng); float strucc = locallab.spots.at(sp).struc; float thre = locallab.spots.at(sp).thresh; @@ -5870,8 +5870,11 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o bufexporig->b[y - ystart][x - xstart] = original->b[y][x]; } } - - ImProcFunctions::softLightloc(bufexporig.get(), bufexpfin.get(), lp.strng); + bufexpfin->CopyFrom(bufexporig.get()); + SoftLightParams softLightParams; + softLightParams.enabled = true; + softLightParams.strength = lp.strng; + ImProcFunctions::softLight(bufexpfin.get(), softLightParams); #ifdef _OPENMP #pragma omp parallel for schedule(dynamic,16) diff --git a/rtengine/ipsoftlight.cc b/rtengine/ipsoftlight.cc index 5ef9f6120..ada1563cd 100644 --- a/rtengine/ipsoftlight.cc +++ b/rtengine/ipsoftlight.cc @@ -48,16 +48,16 @@ inline float sl(float blend, float x) } // namespace -void ImProcFunctions::softLight(LabImage *lab) +void ImProcFunctions::softLight(LabImage *lab, const SoftLightParams &softLightParams) { - if (!params->softlight.enabled || !params->softlight.strength) { + if (!softLightParams.enabled || !softLightParams.strength) { return; } Imagefloat working(lab->W, lab->H); lab2rgb(*lab, working, params->icm.workingProfile); - const float blend = params->softlight.strength / 100.f; + const float blend = softLightParams.strength / 100.f; #ifdef _OPENMP #pragma omp parallel for @@ -73,30 +73,4 @@ void ImProcFunctions::softLight(LabImage *lab) rgb2lab(working, *lab, params->icm.workingProfile); } -void ImProcFunctions::softLightloc(LabImage *lab, LabImage *dst, float blend) -{ - // if (!params->softlight.enabled || !params->softlight.strength) { - // return; - // } - - Imagefloat working(lab->W, lab->H); - lab2rgb(*lab, working, params->icm.workingProfile); - - // const float blend = stre / 100.f; - -#ifdef _OPENMP - #pragma omp parallel for -#endif - for (int y = 0; y < working.getHeight(); ++y) { - for (int x = 0; x < working.getWidth(); ++x) { - working.r(y, x) = sl(blend, working.r(y, x)); - working.g(y, x) = sl(blend, working.g(y, x)); - working.b(y, x) = sl(blend, working.b(y, x)); - } - } - - rgb2lab(working, *dst, params->icm.workingProfile); -} - - } // namespace rtengine diff --git a/rtengine/rtthumbnail.cc b/rtengine/rtthumbnail.cc index ee0930618..887963aa2 100644 --- a/rtengine/rtthumbnail.cc +++ b/rtengine/rtthumbnail.cc @@ -1405,7 +1405,7 @@ IImage8* Thumbnail::processImage (const procparams::ProcParams& params, eSensorT ipf.EPDToneMap (labView, 5, 6); } - ipf.softLight(labView); + ipf.softLight(labView, params.softlight); if (params.colorappearance.enabled) { CurveFactory::curveLightBrightColor ( diff --git a/rtengine/simpleprocess.cc b/rtengine/simpleprocess.cc index f551d7ca6..f138483ae 100644 --- a/rtengine/simpleprocess.cc +++ b/rtengine/simpleprocess.cc @@ -1265,7 +1265,7 @@ private: wavCLVCurve.Reset(); - ipf.softLight(labView); + ipf.softLight(labView, params.softlight); //Colorappearance and tone-mapping associated