diff --git a/rtengine/procparams.cc b/rtengine/procparams.cc index 92db5f34a..8e25f50bf 100644 --- a/rtengine/procparams.cc +++ b/rtengine/procparams.cc @@ -349,86 +349,119 @@ bool operator ==(const rtengine::procparams::DirPyrEqualizerParams& a, const rte return a.threshold == b.threshold; } -ToneCurveParams::ToneCurveParams() +ToneCurveParams::ToneCurveParams() : + autoexp(false), + clip(0.02), + hrenabled(false), + method("Blend"), + expcomp(0), + curve{ + DCT_Linear + }, + curve2{ + DCT_Linear + }, + curveMode(ToneCurveParams::TcMode::STD), + curveMode2(ToneCurveParams::TcMode::STD), + brightness(0), + black(0), + contrast(0), + saturation(0), + shcompr(50), + hlcompr(0), + hlcomprthresh(33) { - setDefaults(); } -void ToneCurveParams::setDefaults() +bool ToneCurveParams::HLReconstructionNecessary(const LUTu& histRedRaw, const LUTu& histGreenRaw, const LUTu& histBlueRaw) { - autoexp = false; - clip = 0.02; - expcomp = 0; - brightness = 0; - contrast = 0; - saturation = 0; - black = 0; - hlcompr = 0; - hlcomprthresh = 33; - shcompr = 50; - curve.clear (); - curve.push_back (DCT_Linear); - curve2.clear (); - curve2.push_back (DCT_Linear); - curveMode = ToneCurveParams::TcMode::STD; - curveMode2 = ToneCurveParams::TcMode::STD; - hrenabled = false; - method = "Blend"; -} - -bool ToneCurveParams::HLReconstructionNecessary (LUTu &histRedRaw, LUTu &histGreenRaw, LUTu &histBlueRaw) -{ - if (options.rtSettings.verbose) - printf ("histRedRaw[ 0]=%07d, histGreenRaw[ 0]=%07d, histBlueRaw[ 0]=%07d\nhistRedRaw[255]=%07d, histGreenRaw[255]=%07d, histBlueRaw[255]=%07d\n", + if (options.rtSettings.verbose) { + printf("histRedRaw[ 0]=%07d, histGreenRaw[ 0]=%07d, histBlueRaw[ 0]=%07d\nhistRedRaw[255]=%07d, histGreenRaw[255]=%07d, histBlueRaw[255]=%07d\n", histRedRaw[0], histGreenRaw[0], histBlueRaw[0], histRedRaw[255], histGreenRaw[255], histBlueRaw[255]); + } - return histRedRaw[255] > 50 || histGreenRaw[255] > 50 || histBlueRaw[255] > 50 || histRedRaw[0] > 50 || histGreenRaw[0] > 50 || histBlueRaw[0] > 50; + return + histRedRaw[255] > 50 + || histGreenRaw[255] > 50 + || histBlueRaw[255] > 50 + || histRedRaw[0] > 50 + || histGreenRaw[0] > 50 + || histBlueRaw[0] > 50; } -RetinexParams::RetinexParams () +RetinexParams::RetinexParams() : + enabled(false), + cdcurve{ + DCT_Linear + }, + cdHcurve{ + DCT_Linear + }, + lhcurve{ + DCT_Linear + }, + transmissionCurve{ + FCT_MinMaxCPoints, + 0.00, + 0.50, + 0.35, + 0.35, + 0.60, + 0.75, + 0.35, + 0.35, + 1.00, + 0.50, + 0.35, + 0.35 + }, + gaintransmissionCurve{ + FCT_MinMaxCPoints, + 0.00, + 0.1, + 0.35, + 0.00, + 0.25, + 0.25, + 0.35, + 0.35, + 0.70, + 0.25, + 0.35, + 0.35, + 1.00, + 0.1, + 0.00, + 0.00 + }, + mapcurve{ + DCT_Linear + }, + str(20), + scal(3), + iter(1), + grad(1), + grads(1), + gam(1.30), + slope(3.), + neigh(80), + offs(0), + highlights(0), + htonalwidth(80), + shadows(0), + stonalwidth(80), + radius(40), + retinexMethod("high"), + retinexcolorspace("Lab"), + gammaretinex("none"), + mapMethod("none"), + viewMethod("none"), + vart(200), + limd(8), + highl(4), + skal(3), + medianmap(false) { - setDefaults (); -} - -void RetinexParams::setDefaults() -{ - enabled = false; - str = 20; - scal = 3; - iter = 1; - grad = 1; - grads = 1; - gam = 1.30; - slope = 3.; - neigh = 80; - offs = 0; - vart = 200; - limd = 8; - highl = 4; - highlights = 0; - htonalwidth = 80; - shadows = 0; - stonalwidth = 80; - radius = 40; - - skal = 3; - retinexMethod = "high"; - mapMethod = "none"; - viewMethod = "none"; - retinexcolorspace = "Lab"; - gammaretinex = "none"; - medianmap = false; - cdcurve.clear(); - cdcurve.push_back (DCT_Linear); - cdHcurve.clear(); - cdHcurve.push_back (DCT_Linear); - lhcurve.clear(); - lhcurve.push_back (DCT_Linear); - mapcurve.clear(); - mapcurve.push_back (DCT_Linear); - getDefaultgaintransmissionCurve (gaintransmissionCurve); - - getDefaulttransmissionCurve (transmissionCurve); } void RetinexParams::getCurves (RetinextransmissionCurve &transmissionCurveLUT, RetinexgaintransmissionCurve &gaintransmissionCurveLUT) const @@ -438,73 +471,115 @@ void RetinexParams::getCurves (RetinextransmissionCurve &transmissionCurveLUT, R } -void RetinexParams::getDefaultgaintransmissionCurve (std::vector &curve) +LCurveParams::LCurveParams() : + lcurve{ + DCT_Linear + }, + acurve{ + DCT_Linear + }, + bcurve{ + DCT_Linear + }, + cccurve{ + DCT_Linear + }, + chcurve{ + FCT_Linear + }, + lhcurve{ + FCT_Linear + }, + hhcurve{ + FCT_Linear + }, + lccurve{ + DCT_Linear + }, + clcurve{ + DCT_Linear + }, + brightness(0), + contrast(0), + chromaticity(0), + avoidcolorshift(false), + rstprotection(0), + lcredsk(true) { - double v[16] = { 0.00, 0.1, 0.35, 0.00, - 0.25, 0.25, 0.35, 0.35, - 0.70, 0.25, 0.35, 0.35, - 1.00, 0.1, 0.00, 0.00 - }; - - curve.resize (17); - curve.at (0 ) = double (FCT_MinMaxCPoints); - - for (size_t i = 1; i < curve.size(); ++i) { - curve.at (i) = v[i - 1]; - } } -void RetinexParams::getDefaulttransmissionCurve (std::vector &curve) +ColorToningParams::ColorToningParams () : + enabled(false), + autosat(true), + opacityCurve{ + FCT_MinMaxCPoints, + 0.00, + 0.3, + 0.35, + 0.00, + 0.25, + 0.8, + 0.35, + 0.35, + 0.70, + 0.8, + 0.35, + 0.35, + 1.00, + 0.3, + 0.00, + 0.00 + }, + colorCurve{ + FCT_MinMaxCPoints, + 0.050, + 0.62, + 0.25, + 0.25, + 0.585, + 0.11, + 0.25, + 0.25 + }, + satProtectionThreshold(30), + saturatedOpacity(80), + strength(50), + balance(0), + hlColSat(60, 80, false), + shadowsColSat (80, 208, false), + clcurve{ + DCT_NURBS, + 0.00, + 0.00, + 0.35, + 0.65, + 1.00, + 1.00 + }, + cl2curve{ + DCT_NURBS, + 0.00, + 0.00, + 0.35, + 0.65, + 1.00, + 1.00 + }, + method("Lab"), + twocolor("Std"), + redlow(0.0), + greenlow(0.0), + bluelow(0.0), + redmed(0.0), + greenmed(0.0), + bluemed(0.0), + redhigh(0.0), + greenhigh(0.0), + bluehigh(0.0), + satlow(0.0), + sathigh(0.0), + lumamode(true) { - double v[12] = { 0.00, 0.50, 0.35, 0.35, - 0.60, 0.75, 0.35, 0.35, - 1.00, 0.50, 0.35, 0.35, - }; - - curve.resize (13); - curve.at (0 ) = double (FCT_MinMaxCPoints); - - for (size_t i = 1; i < curve.size(); ++i) { - curve.at (i) = v[i - 1]; - } -} - -// Maps crop to resized width (e.g. smaller previews) -ColorToningParams::ColorToningParams () : hlColSat (60, 80, false), shadowsColSat (80, 208, false) -{ - setDefaults(); -} - -void ColorToningParams::setDefaults() -{ - enabled = false; - autosat = true; - method = "Lab"; - - getDefaultColorCurve (colorCurve); - getDefaultOpacityCurve (opacityCurve); - getDefaultCLCurve (clcurve); - getDefaultCL2Curve (cl2curve); - - hlColSat.setValues (60, 80); - shadowsColSat.setValues (80, 208); - balance = 0; - satProtectionThreshold = 30; - saturatedOpacity = 80; - strength = 50; - lumamode = true; - twocolor = "Std"; - redlow = 0.0; - greenlow = 0.0; - bluelow = 0.0; - satlow = 0.0; - sathigh = 0.0; - redmed = 0.0; - greenmed = 0.0; - bluemed = 0.0; - redhigh = 0.0; - greenhigh = 0.0; - bluehigh = 0.0; } void ColorToningParams::mixerToCurve (std::vector &colorCurve, std::vector &opacityCurve) const @@ -786,65 +861,6 @@ void ColorToningParams::getCurves (ColorGradientCurve &colorCurveLUT, OpacityCur } } -void ColorToningParams::getDefaultColorCurve (std::vector &curve) -{ - double v[8] = { 0.050, 0.62, 0.25, 0.25, - 0.585, 0.11, 0.25, 0.25 - }; - - curve.resize (9); - curve.at (0) = double (FCT_MinMaxCPoints); - - for (size_t i = 1; i < curve.size(); ++i) { - curve.at (i) = v[i - 1]; - } -} - -void ColorToningParams::getDefaultOpacityCurve (std::vector &curve) -{ - double v[16] = { 0.00, 0.3, 0.35, 0.00, - 0.25, 0.8, 0.35, 0.35, - 0.70, 0.8, 0.35, 0.35, - 1.00, 0.3, 0.00, 0.00 - }; - curve.resize (17); - curve.at (0 ) = double (FCT_MinMaxCPoints); - - for (size_t i = 1; i < curve.size(); ++i) { - curve.at (i) = v[i - 1]; - } -} - -void ColorToningParams::getDefaultCLCurve (std::vector &curve) -{ - double v[6] = { 0.00, 0.00, - 0.35, 0.65, - 1.00, 1.00 - }; - - curve.resize (7); - curve.at (0) = double (DCT_NURBS); - - for (size_t i = 1; i < curve.size(); ++i) { - curve.at (i) = v[i - 1]; - } -} - -void ColorToningParams::getDefaultCL2Curve (std::vector &curve) -{ - double v[6] = { 0.00, 0.00, - 0.35, 0.65, - 1.00, 1.00 - }; - - curve.resize (7); - curve.at (0) = double (DCT_NURBS); - - for (size_t i = 1; i < curve.size(); ++i) { - curve.at (i) = v[i - 1]; - } -} - SharpeningParams::SharpeningParams() : enabled (false), radius (0.5), @@ -1481,34 +1497,9 @@ ProcParams::ProcParams () void ProcParams::setDefaults () { + toneCurve = ToneCurveParams(); - toneCurve.setDefaults(); - - labCurve.brightness = 0; - labCurve.contrast = 0; - labCurve.chromaticity = 0; - labCurve.avoidcolorshift = false; - labCurve.lcredsk = true; - labCurve.rstprotection = 0; - labCurve.lcurve.clear (); - labCurve.lcurve.push_back (DCT_Linear); - labCurve.acurve.clear (); - labCurve.acurve.push_back (DCT_Linear); - labCurve.bcurve.clear (); - labCurve.bcurve.push_back (DCT_Linear); - labCurve.cccurve.clear (); - labCurve.cccurve.push_back (DCT_Linear); - labCurve.chcurve.clear (); - labCurve.chcurve.push_back (FCT_Linear); - labCurve.lhcurve.clear (); - labCurve.lhcurve.push_back (FCT_Linear); - labCurve.hhcurve.clear (); - labCurve.hhcurve.push_back (FCT_Linear); - - labCurve.lccurve.clear (); - labCurve.lccurve.push_back (DCT_Linear); - labCurve.clcurve.clear (); - labCurve.clcurve.push_back (DCT_Linear); + labCurve = LCurveParams(); rgbCurves.lumamode = false; rgbCurves.rcurve.clear (); @@ -1518,7 +1509,7 @@ void ProcParams::setDefaults () rgbCurves.bcurve.clear (); rgbCurves.bcurve.push_back (DCT_Linear); - colorToning.setDefaults(); + colorToning = ColorToningParams(); sharpenEdge.enabled = false; sharpenEdge.passes = 2; diff --git a/rtengine/procparams.h b/rtengine/procparams.h index 09dc6b07d..77965156f 100644 --- a/rtengine/procparams.h +++ b/rtengine/procparams.h @@ -283,8 +283,7 @@ struct ToneCurveParams { ToneCurveParams(); - void setDefaults(); - static bool HLReconstructionNecessary(LUTu& histRedRaw, LUTu& histGreenRaw, LUTu& histBlueRaw); + static bool HLReconstructionNecessary(const LUTu& histRedRaw, const LUTu& histGreenRaw, const LUTu& histBlueRaw); }; /** @@ -326,12 +325,8 @@ struct RetinexParams bool medianmap; RetinexParams(); - void setDefaults(); + void getCurves(RetinextransmissionCurve& transmissionCurveLUT, RetinexgaintransmissionCurve& gaintransmissionCurveLUT) const; - - static void getDefaultgaintransmissionCurve (std::vector& curve); - - static void getDefaulttransmissionCurve (std::vector& curve); }; @@ -355,6 +350,8 @@ struct LCurveParams bool avoidcolorshift; double rstprotection; bool lcredsk; + + LCurveParams(); }; /** @@ -417,7 +414,6 @@ struct ColorToningParams { bool lumamode; ColorToningParams(); - void setDefaults(); // SHOULD BE GENERALIZED TO ALL CLASSES! /// @brief Transform the mixer values to their curve equivalences void mixerToCurve(std::vector& colorCurve, std::vector& opacityCurve) const; @@ -425,11 +421,6 @@ struct ColorToningParams { void slidersToCurve(std::vector& colorCurve, std::vector& opacityCurve) const; /// @brief Fill the ColorGradientCurve and OpacityCurve LUTf from the control points curve or sliders value void getCurves(ColorGradientCurve& colorCurveLUT, OpacityCurve& opacityCurveLUT, const double xyz_rgb[3][3], const double rgb_xyz[3][3], bool& opautili) const; - - static void getDefaultColorCurve(std::vector& curve); - static void getDefaultOpacityCurve(std::vector& curve); - static void getDefaultCLCurve(std::vector& curve); - static void getDefaultCL2Curve(std::vector& curve); }; /** diff --git a/rtgui/colortoning.cc b/rtgui/colortoning.cc index 786030a73..c5d9252cd 100644 --- a/rtgui/colortoning.cc +++ b/rtgui/colortoning.cc @@ -54,14 +54,14 @@ ColorToning::ColorToning () : FoldableToolPanel(this, "colortoning", M("TP_COLOR colorShape->setLeftBarBgGradient(milestones); + const ColorToningParams default_params; + // luminance gradient milestones.clear(); milestones.push_back( GradientMilestone(0., 0., 0., 0.) ); milestones.push_back( GradientMilestone(1., 1., 1., 1.) ); colorShape->setBottomBarBgGradient(milestones); - std::vector defaultCurve; - rtengine::ColorToningParams::getDefaultColorCurve(defaultCurve); - colorShape->setResetCurve(FCT_MinMaxCPoints, defaultCurve); + colorShape->setResetCurve(FCT_MinMaxCPoints, default_params.colorCurve); // This will add the reset button at the end of the curveType buttons colorCurveEditorG->curveListComplete(); @@ -88,10 +88,9 @@ ColorToning::ColorToning () : FoldableToolPanel(this, "colortoning", M("TP_COLOR opacityCurveEditorG = new CurveEditorGroup (options.lastColorToningCurvesDir, M("TP_COLORTONING_OPACITY")); opacityCurveEditorG->setCurveListener (this); - rtengine::ColorToningParams::getDefaultOpacityCurve(defaultCurve); opacityShape = static_cast(opacityCurveEditorG->addCurve(CT_Flat, "", nullptr, false, false)); opacityShape->setIdentityValue(0.); - opacityShape->setResetCurve(FlatCurveType(defaultCurve.at(0)), defaultCurve); + opacityShape->setResetCurve(FlatCurveType(default_params.opacityCurve.at(0)), default_params.opacityCurve); opacityShape->setBottomBarBgGradient(milestones); // This will add the reset button at the end of the curveType buttons @@ -107,9 +106,8 @@ ColorToning::ColorToning () : FoldableToolPanel(this, "colortoning", M("TP_COLOR clCurveEditorG = new CurveEditorGroup (options.lastColorToningCurvesDir, M("TP_COLORTONING_CHROMAC")); clCurveEditorG->setCurveListener (this); - rtengine::ColorToningParams::getDefaultCLCurve(defaultCurve); clshape = static_cast(clCurveEditorG->addCurve(CT_Diagonal, M("TP_COLORTONING_AB"), irg, false)); - clshape->setResetCurve(DiagonalCurveType(defaultCurve.at(0)), defaultCurve); + clshape->setResetCurve(DiagonalCurveType(default_params.clcurve.at(0)), default_params.clcurve); clshape->setTooltip(M("TP_COLORTONING_CURVEEDITOR_CL_TOOLTIP")); clshape->setLeftBarColorProvider(this, 1); @@ -127,9 +125,8 @@ ColorToning::ColorToning () : FoldableToolPanel(this, "colortoning", M("TP_COLOR cl2CurveEditorG = new CurveEditorGroup (options.lastColorToningCurvesDir, M("TP_COLORTONING_CHROMAC")); cl2CurveEditorG->setCurveListener (this); - rtengine::ColorToningParams::getDefaultCL2Curve(defaultCurve); cl2shape = static_cast(cl2CurveEditorG->addCurve(CT_Diagonal, M("TP_COLORTONING_BY"), iby, false)); - cl2shape->setResetCurve(DiagonalCurveType(defaultCurve.at(0)), defaultCurve); + cl2shape->setResetCurve(DiagonalCurveType(default_params.cl2curve.at(0)), default_params.cl2curve); cl2shape->setTooltip(M("TP_COLORTONING_CURVEEDITOR_CL_TOOLTIP")); cl2shape->setLeftBarColorProvider(this, 1); diff --git a/rtgui/retinex.cc b/rtgui/retinex.cc index bf88a85e4..320c91fd5 100644 --- a/rtgui/retinex.cc +++ b/rtgui/retinex.cc @@ -380,14 +380,15 @@ Retinex::Retinex () : FoldableToolPanel (this, "retinex", M ("TP_RETINEX_LABEL") Gtk::Grid *tranGrid = Gtk::manage (new Gtk::Grid()); setExpandAlignProperties (tranGrid, true, false, Gtk::ALIGN_FILL, Gtk::ALIGN_START); + const RetinexParams default_params; + // Transmission map curve transmissionCurveEditorG = new CurveEditorGroup (options.lastRetinexDir, M ("TP_RETINEX_TRANSMISSION")); setExpandAlignProperties (transmissionCurveEditorG, true, false, Gtk::ALIGN_FILL, Gtk::ALIGN_START); transmissionCurveEditorG->setCurveListener (this); - rtengine::RetinexParams::getDefaulttransmissionCurve (defaultCurve); transmissionShape = static_cast (transmissionCurveEditorG->addCurve (CT_Flat, "", nullptr, false, false)); transmissionShape->setIdentityValue (0.); - transmissionShape->setResetCurve (FlatCurveType (defaultCurve.at (0)), defaultCurve); + transmissionShape->setResetCurve (FlatCurveType (default_params.transmissionCurve.at (0)), default_params.transmissionCurve); // transmissionShape->setBottomBarBgGradient(milestones); transmissionCurveEditorG->curveListComplete(); transmissionCurveEditorG->set_tooltip_markup (M ("TP_RETINEX_TRANSMISSION_TOOLTIP")); @@ -439,10 +440,9 @@ Retinex::Retinex () : FoldableToolPanel (this, "retinex", M ("TP_RETINEX_LABEL") gaintransmissionCurve = new CurveEditorGroup (options.lastRetinexDir, M ("TP_RETINEX_GAINTRANSMISSION")); setExpandAlignProperties (gaintransmissionCurve, true, false, Gtk::ALIGN_FILL, Gtk::ALIGN_START); gaintransmissionCurve->setCurveListener (this); - rtengine::RetinexParams::getDefaultgaintransmissionCurve (defaultCurve); gaintransmissionShape = static_cast (gaintransmissionCurve->addCurve (CT_Flat, "", nullptr, false, false)); gaintransmissionShape->setIdentityValue (0.); - gaintransmissionShape->setResetCurve (FlatCurveType (defaultCurve.at (0)), defaultCurve); + gaintransmissionShape->setResetCurve (FlatCurveType (default_params.gaintransmissionCurve.at (0)), default_params.gaintransmissionCurve); //gaintransmissionShape->setBottomBarBgGradient(milestones); gaintransmissionCurve->set_tooltip_markup (M ("TP_RETINEX_GAINTRANSMISSION_TOOLTIP")); gaintransmissionCurve->curveListComplete();