From 29aa60c5fdd49dd507dab8692fb38d6835cf5d78 Mon Sep 17 00:00:00 2001 From: Desmis Date: Tue, 5 Nov 2019 17:58:48 +0100 Subject: [PATCH] format iplocallab locallab and memory for rgb curves --- rtengine/iplocallab.cc | 57 ++++++++++++++++++++++-------------------- rtgui/locallab.cc | 51 ++++++++++++++++++------------------- rtgui/locallab.h | 2 +- 3 files changed, 56 insertions(+), 54 deletions(-) diff --git a/rtengine/iplocallab.cc b/rtengine/iplocallab.cc index 42ed6c99b..5c12b7892 100644 --- a/rtengine/iplocallab.cc +++ b/rtengine/iplocallab.cc @@ -7414,7 +7414,7 @@ float triangle(float a, float a1, float b) return a1; } -void rgbtone (float& maxval, float& medval, float& minval, LUTf & lutToneCurve) +void rgbtone(float& maxval, float& medval, float& minval, LUTf & lutToneCurve) { float minvalold = minval, medvalold = medval, maxvalold = maxval; @@ -11780,27 +11780,28 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o chprosl = CLIPCHRO(ampli * ch - ampli); } } - + //RGB Curves - Imagefloat *tmpImage = nullptr; - tmpImage = new Imagefloat(bfw, bfh); + if (rgblocalcurve && localrgbutili && lp.qualcurvemet != 0) { - float *rtemp = new float[bfw * bfh]; - float *gtemp = new float[bfw * bfh]; - float *btemp = new float[bfw * bfh]; + Imagefloat *tmpImage = nullptr; + tmpImage = new Imagefloat(bfw, bfh); - lab2rgb(*bufcolorig, *tmpImage, params->icm.workingProfile); + float *rtemp = new float[bfw * bfh]; + float *gtemp = new float[bfw * bfh]; + float *btemp = new float[bfw * bfh]; + + lab2rgb(*bufcolorig, *tmpImage, params->icm.workingProfile); #ifdef _OPENMP - #pragma omp parallel for schedule(dynamic,16) + #pragma omp parallel for schedule(dynamic,16) #endif - for (int y = 0; y < bfh; y++) - for (int x = 0; x < bfw; x++) { - rtemp[y * bfw + x] = tmpImage->r(y, x); - gtemp[y * bfw + x] = tmpImage->g(y, x); - btemp[y * bfw + x] = tmpImage->b(y, x); + for (int y = 0; y < bfh; y++) + for (int x = 0; x < bfw; x++) { + rtemp[y * bfw + x] = tmpImage->r(y, x); + gtemp[y * bfw + x] = tmpImage->g(y, x); + btemp[y * bfw + x] = tmpImage->b(y, x); - if (rgblocalcurve && localrgbutili && lp.qualcurvemet != 0) { assert(rgblocalcurve); //std @@ -11840,6 +11841,7 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o g = CLIP (g1 * 0.25f + g2 * 0.50f + g3 * 0.25f); b = CLIP (b1 * 0.25f + b2 * 0.25f + b3 * 0.50f); } + //Film like Adobe if (tonemod == 3) { @@ -11865,24 +11867,25 @@ void ImProcFunctions::Lab_Local(int call, int sp, float** shbuffer, LabImage * o } } } - + setUnlessOOG(rtemp[y * bfw + x], gtemp[y * bfw + x], btemp[y * bfw + x], r, g, b); } + + + tmpImage->r(y, x) = rtemp[y * bfw + x]; + tmpImage->g(y, x) = gtemp[y * bfw + x]; + tmpImage->b(y, x) = btemp[y * bfw + x]; } - tmpImage->r(y, x) = rtemp[y * bfw + x]; - tmpImage->g(y, x) = gtemp[y * bfw + x]; - tmpImage->b(y, x) = btemp[y * bfw + x]; - } + rgb2lab(*tmpImage, *bufcolorig, params->icm.workingProfile); - rgb2lab(*tmpImage, *bufcolorig, params->icm.workingProfile); - - delete tmpImage; - delete [] rtemp; - delete [] gtemp; - delete [] btemp; - // end rgb curves + delete tmpImage; + delete [] rtemp; + delete [] gtemp; + delete [] btemp; + // end rgb curves + } //others curves diff --git a/rtgui/locallab.cc b/rtgui/locallab.cc index fe4ad34cd..a8583b592 100644 --- a/rtgui/locallab.cc +++ b/rtgui/locallab.cc @@ -165,7 +165,7 @@ Locallab::Locallab(): llshape(static_cast(llCurveEditorG->addCurve(CT_Diagonal, "L(L)"))), ccshape(static_cast(llCurveEditorG->addCurve(CT_Diagonal, "C(C)"))), toneMethod(Gtk::manage(new MyComboBoxText())), - rgbshape(static_cast(rgbCurveEditorG->addCurve(CT_Diagonal,"",toneMethod))), + rgbshape(static_cast(rgbCurveEditorG->addCurve(CT_Diagonal, "", toneMethod))), LHshape(static_cast(HCurveEditorG->addCurve(CT_Flat, "L(H)", nullptr, false, true))), HHshape(static_cast(HCurveEditorG->addCurve(CT_Flat, "H(H)", nullptr, false, true))), CCmaskshape(static_cast(maskCurveEditorG->addCurve(CT_Flat, "C(C)", nullptr, false, false))), @@ -463,7 +463,7 @@ Locallab::Locallab(): // Color & Light qualitycurveMethod(Gtk::manage(new MyComboBoxText())), gridMethod(Gtk::manage(new MyComboBoxText())), - // toneMethod(Gtk::manage(new MyComboBoxText())), +// toneMethod(Gtk::manage(new MyComboBoxText())), showmaskcolMethod(Gtk::manage(new MyComboBoxText())), showmaskcolMethodinv(Gtk::manage(new MyComboBoxText())), mergecolMethod(Gtk::manage(new MyComboBoxText())), @@ -530,7 +530,7 @@ Locallab::Locallab(): // Others ctboxsoftmethod(Gtk::manage(new Gtk::HBox())), - ctboxexpmethod (Gtk::manage(new Gtk::HBox())), + ctboxexpmethod(Gtk::manage(new Gtk::HBox())), nextmin(0.), nextmax(0.), nextminiT(0.), @@ -624,7 +624,7 @@ Locallab::Locallab(): toneMethod->append(M("TP_EXPOSURE_TCMODE_WEIGHTEDSTD")); toneMethod->append(M("TP_EXPOSURE_TCMODE_LUMINANCE")); toneMethod->append(M("TP_EXPOSURE_TCMODE_FILMLIKE")); - + toneMethod->set_active(0); toneMethodConn = toneMethod->signal_changed().connect(sigc::mem_fun(*this, &Locallab::toneMethodChanged)); @@ -668,20 +668,20 @@ Locallab::Locallab(): LHshape->setCurveColorProvider(this, 1); const std::vector six_shape = - []() -> std::vector + []() -> std::vector { + std::vector res; + + float R, G, B; + + for (int i = 0; i < 7; ++i) { - std::vector res; + const float x = static_cast(i) * (1.f / 6.f); + Color::hsv2rgb01(x, 0.5f, 0.5f, R, G, B); + res.emplace_back(x, R, G, B); + } - float R, G, B; - - for (int i = 0; i < 7; ++i) { - const float x = static_cast(i) * (1.f / 6.f); - Color::hsv2rgb01(x, 0.5f, 0.5f, R, G, B); - res.emplace_back(x, R, G, B); - } - - return res; - }(); + return res; + }(); const std::vector& mLHshape = six_shape; LHshape->setBottomBarBgGradient(mLHshape); @@ -1377,18 +1377,17 @@ Locallab::Locallab(): } const std::vector mskinTonesCurve = - []() -> std::vector - { - std::vector res; + []() -> std::vector { + std::vector res; - float R, G, B; - Color::hsv2rgb01(0.92f, 0.45f, 0.6f, R, G, B); - res.emplace_back(0.0, R, G, B); - Color::hsv2rgb01(0.14056f, 0.45f, 0.6f, R, G, B); - res.emplace_back(1.0, R, G, B); + float R, G, B; + Color::hsv2rgb01(0.92f, 0.45f, 0.6f, R, G, B); + res.emplace_back(0.0, R, G, B); + Color::hsv2rgb01(0.14056f, 0.45f, 0.6f, R, G, B); + res.emplace_back(1.0, R, G, B); - return res; - }(); + return res; + }(); // -0.1 rad < Hue < 1.6 rad skinTonesCurve->setBottomBarBgGradient(mskinTonesCurve); skinTonesCurve->setLeftBarBgGradient(mskinTonesCurve); diff --git a/rtgui/locallab.h b/rtgui/locallab.h index e921a4860..9a6ad7646 100644 --- a/rtgui/locallab.h +++ b/rtgui/locallab.h @@ -403,7 +403,7 @@ private: sigc::connection showmaskcolMethodConninv; MyComboBoxText* const mergecolMethod; sigc::connection mergecolMethodConn; - + ThresholdAdjuster* const csThresholdcol; //Exposure MyComboBoxText* const showmaskexpMethod;