From 3715bf42e3d6acd2b0f5fe2e630dcab49033aa7f Mon Sep 17 00:00:00 2001 From: Emil Martinec Date: Tue, 19 Oct 2010 01:10:54 -0500 Subject: [PATCH] Bugfixes for tone curves. --- rtdata/languages/default | 3 ++- rtengine/curves.cc | 45 ++++++++++++++++++++++++---------------- rtengine/dcrop.cc | 2 +- rtgui/tonecurve.cc | 2 +- 4 files changed, 31 insertions(+), 21 deletions(-) diff --git a/rtdata/languages/default b/rtdata/languages/default index 483cb6ec3..7fdcc4cd1 100644 --- a/rtdata/languages/default +++ b/rtdata/languages/default @@ -368,6 +368,7 @@ PARTIALPASTE_ICMSETTINGS;ICM settings PARTIALPASTE_IPTCINFO;IPTC info PARTIALPASTE_LABCURVE;Luminance curve PARTIALPASTE_LENSGROUP;Lens related settings +PARTIALPASTE_LABCURVE;Lab curve PARTIALPASTE_LUMADENOISE;Luminance noise reduction PARTIALPASTE_LUMINANCEGROUP;Luminance related settings PARTIALPASTE_METAICMGROUP;Metadata/ICM settings @@ -626,7 +627,7 @@ TP_IMPULSEDENOISE_THRESH;Threshold TP_LABCURVE_BRIGHTNESS;Brightness TP_LABCURVE_CONTRAST;Contrast TP_LABCURVE_CURVEEDITOR;Luminance Curve -TP_LABCURVE_LABEL;Luminance Curve +TP_LABCURVE_LABEL;Lab Curves TP_LABCURVE_SATURATION;Saturation TP_LENSGEOM_AUTOCROP;Auto Crop TP_LENSGEOM_FILL;Auto Fill diff --git a/rtengine/curves.cc b/rtengine/curves.cc index c1c1eded2..86ef021f7 100644 --- a/rtengine/curves.cc +++ b/rtengine/curves.cc @@ -730,12 +730,12 @@ void CurveFactory::complexCurve (double ecomp, double black, double hlcompr, dou std::vector basecurvePoints; basecurvePoints.push_back((double)((CurveType)NURBS)); - float toex = black/a; - float toey = black*(1-shcompr/100.0); - float shoulderx = toex+(1-toey)/a; + float toex = MIN(1,black/a); + float toey = toex*a*(1-shcompr/100.0); + float shoulderx = toex+(1-toey)/a;//point in x at which line of slope a starting at toe point reaches y=1 float shouldery; if (shoulderx<1) { - shouldery = 1-(1-shoulderx)*(1-hlcompr/100.0); + shouldery = MAX(2*toey, 1-(1-shoulderx)*(1-hlcompr/100.0)); shoulderx = shoulderx - (1-shouldery)/a; } else { shoulderx = 1; @@ -748,15 +748,17 @@ void CurveFactory::complexCurve (double ecomp, double black, double hlcompr, dou basecurvePoints.push_back(toex); //toe point basecurvePoints.push_back(toey); //value at toe point - basecurvePoints.push_back(0.25*toex+0.75*shoulderx); //toe point - basecurvePoints.push_back(0.25*toey+0.75*shouldery); //value at toe point - - basecurvePoints.push_back(shoulderx); //shoulder point - basecurvePoints.push_back(shouldery); //value at shoulder point - - basecurvePoints.push_back(1); // white point - basecurvePoints.push_back(1); // value at white point - + if (toex<1) { + basecurvePoints.push_back(0.25*toex+0.75*shoulderx); //toe point + basecurvePoints.push_back(0.25*toey+0.75*shouldery); //value at toe point + + basecurvePoints.push_back(shoulderx); //shoulder point + basecurvePoints.push_back(shouldery); //value at shoulder point + if (shoulderx<1) { + basecurvePoints.push_back(1); // white point + basecurvePoints.push_back(1); // value at white point + } + } Curve* basecurve = NULL; basecurve = new Curve (basecurvePoints, CURVES_MIN_POLY_POINTS/skip); // Actually, CURVES_MIN_POLY_POINTS = 1000, //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -767,12 +769,19 @@ void CurveFactory::complexCurve (double ecomp, double black, double hlcompr, dou brightcurvePoints.push_back(0); //black point. Value in [0 ; 1] range brightcurvePoints.push_back(0); //black point. Value in [0 ; 1] range - brightcurvePoints.push_back(0.1); //toe point - brightcurvePoints.push_back(0.1+br/150.0); //value at toe point - - brightcurvePoints.push_back(0.7); //shoulder point - brightcurvePoints.push_back(MIN(1.0,0.7+br/300.0)); //value at shoulder point + if(br>0) { + brightcurvePoints.push_back(0.1); //toe point + brightcurvePoints.push_back(0.1+br/150.0); //value at toe point + brightcurvePoints.push_back(0.7); //shoulder point + brightcurvePoints.push_back(MIN(1.0,0.7+br/300.0)); //value at shoulder point + } else { + brightcurvePoints.push_back(0.1+br/150.0); //toe point + brightcurvePoints.push_back(0.1); //value at toe point + + brightcurvePoints.push_back(MIN(1.0,0.7+br/300.0)); //shoulder point + brightcurvePoints.push_back(0.7); //value at shoulder point + } brightcurvePoints.push_back(1); // white point brightcurvePoints.push_back(1); // value at white point diff --git a/rtengine/dcrop.cc b/rtengine/dcrop.cc index 41a5d929f..8c9d67a10 100644 --- a/rtengine/dcrop.cc +++ b/rtengine/dcrop.cc @@ -167,7 +167,7 @@ void Crop::update (int todo, bool internal) { parent->ipf.chrominanceCurve (laboCrop, labnCrop, 0, parent->chroma_acurve, 0, croph); parent->ipf.chrominanceCurve (laboCrop, labnCrop, 1, parent->chroma_bcurve, 0, croph); - parent->ipf.colorCurve (laboCrop, labnCrop); + parent->ipf.colorCurve (labnCrop, labnCrop); if (skip==1) { parent->ipf.impulsedenoise (labnCrop); diff --git a/rtgui/tonecurve.cc b/rtgui/tonecurve.cc index fd5dd1efe..5ac382870 100644 --- a/rtgui/tonecurve.cc +++ b/rtgui/tonecurve.cc @@ -55,7 +55,7 @@ ToneCurve::ToneCurve () : ToolPanel(), expAdd(false), blackAdd(false), brAdd(fal pack_start (*hlcompr); //----------- Black Level ---------------------------------- - black = Gtk::manage (new Adjuster (M("TP_EXPOSURE_BLACKLEVEL"), 0, 32768, 1, 0)); + black = Gtk::manage (new Adjuster (M("TP_EXPOSURE_BLACKLEVEL"), 0, 16384, 1, 0)); pack_start (*black); shcompr = Gtk::manage (new Adjuster (M("TP_EXPOSURE_COMPRSHADOWS"), -100, 100, 1, 0)); pack_start (*shcompr);