From 6770a2c4a0ded30e64c56e1c7549cc39d039ca3c Mon Sep 17 00:00:00 2001 From: Emil Martinec Date: Wed, 27 Oct 2010 20:53:52 -0500 Subject: [PATCH] Changed behavior of "Shadow compression" to shadow recovery; now 0 on the slider is black clipping, 50 is no compression, 100 is shadow expansion. Implemented a rudimentary highlight desaturation to prevent color shifts under exposure compensation, along the lines of relative colorimetric rendering intent. --- rtdata/languages/default | 6 +++--- rtengine/curves.cc | 6 +++--- rtengine/improcfun.cc | 28 ++++++++++++++++++++++++++-- rtgui/tonecurve.cc | 2 +- 4 files changed, 33 insertions(+), 9 deletions(-) diff --git a/rtdata/languages/default b/rtdata/languages/default index 06246bdda..76e929483 100644 --- a/rtdata/languages/default +++ b/rtdata/languages/default @@ -603,15 +603,15 @@ TP_EXPOSURE_AUTOLEVELS;Auto Levels TP_EXPOSURE_BLACKLEVEL;Black TP_EXPOSURE_BRIGHTNESS;Brightness TP_EXPOSURE_CLIP;Clip -TP_EXPOSURE_COMPRHIGHLIGHTS;Highlight rolloff -TP_EXPOSURE_COMPRSHADOWS;Shadow compression +TP_EXPOSURE_COMPRHIGHLIGHTS;Highlight recovery +TP_EXPOSURE_COMPRSHADOWS;Shadow recovery TP_EXPOSURE_CONTRAST;Contrast TP_EXPOSURE_CURVEEDITOR;Tone Curve TP_EXPOSURE_EXPCOMP;Exp. Comp. TP_EXPOSURE_LABEL;Exposure TP_HLREC_CIELAB;CIELab Blending TP_HLREC_COLOR;Color Propagation -TP_HLREC_LABEL;Highlight Recovery +TP_HLREC_LABEL;Highlight Reconstruction TP_HLREC_LUMINANCE;Luminance Recovery TP_HLREC_METHOD;Method: TP_ICM_FILEDLGFILTERANY;Any files diff --git a/rtengine/curves.cc b/rtengine/curves.cc index cf7735e13..7bf6e19e7 100644 --- a/rtengine/curves.cc +++ b/rtengine/curves.cc @@ -694,7 +694,7 @@ void CurveFactory::complexCurve (double ecomp, double black, double hlcompr, dou double def_mul = pow (2.0, defmul); - printf ("def_mul= %f ecomp= %f black= %f hlcompr= %f shcompr= %f br= %f contr= %f defmul= %f gamma= %f, skip= %d \n",def_mul,ecomp,black,hlcompr,shcompr,br,contr,defmul,gamma_,skip); + //printf ("def_mul= %f ecomp= %f black= %f hlcompr= %f shcompr= %f br= %f contr= %f defmul= %f gamma= %f, skip= %d \n",def_mul,ecomp,black,hlcompr,shcompr,br,contr,defmul,gamma_,skip); // compute parameters of the gamma curve double start = exp(gamma_*log( -0.099 / ((1.0/gamma_-1.0)*1.099 ))); @@ -729,7 +729,7 @@ void CurveFactory::complexCurve (double ecomp, double black, double hlcompr, dou std::vector basecurvePoints; basecurvePoints.push_back((double)((CurveType)NURBS)); float toex = MIN(1,black/(a*def_mul)); - float toey = MAX(0,toex*a*def_mul*(1-shcompr/50.0)); + float toey = MAX(0,toex*a*def_mul*(shcompr/25.0-1)); float shoulderx = 1/(a*def_mul);//point in x at which line of slope a starting at (0,0) reaches y=1 float shouldery=1; float toneslope=(shouldery-toey)/(shoulderx-toex); @@ -752,7 +752,7 @@ void CurveFactory::complexCurve (double ecomp, double black, double hlcompr, dou shouldery = toey + (1-toex)*a; }*/ - basecurvePoints.push_back(MAX(0,0.99*toex*(shcompr/50.0-1))); //black point. Value in [0 ; 1] range + basecurvePoints.push_back(MAX(0,0.99*toex*(1-shcompr/25.0))); //black point. Value in [0 ; 1] range basecurvePoints.push_back(0); //black point. Value in [0 ; 1] range basecurvePoints.push_back(toex); //toe point diff --git a/rtengine/improcfun.cc b/rtengine/improcfun.cc index 82e79b54f..8b9a2f527 100644 --- a/rtengine/improcfun.cc +++ b/rtengine/improcfun.cc @@ -324,15 +324,39 @@ void ImProcFunctions::rgbProc (Image16* working, LabImage* lab, int* tonecurve1, /*r = tonecurve[r]; g = tonecurve[g]; b = tonecurve[b];*/ - int Y = (int)(0.299*r + 0.587*g + 0.114*b); - float tonefactor = (Y>0 ? (float)tonecurve1[Y]/Y : 1); + int Y = (0.299*r + 0.587*g + 0.114*b); + int Ynew = tonecurve1[Y]; + float tonefactor = (Y>0 ? (float)Ynew/Y : 1); r *= tonefactor; g *= tonefactor; b *= tonefactor; + float maxfactor = 1; + if (r>65535) + maxfactor = MIN(maxfactor, (float)(65535.0f-Ynew)/(r-Ynew)); + if (g>65535) + maxfactor = MIN(maxfactor, (float)(65535.0f-Ynew)/(g-Ynew)); + if (b>65535) + maxfactor = MIN(maxfactor, (float)(65535.0f-Ynew)/(b-Ynew)); + + if (r<0) + maxfactor = MIN(maxfactor, ((float)Ynew)/(Ynew-r)); + if (g<0) + maxfactor = MIN(maxfactor, ((float)Ynew)/(Ynew-g)); + if (b<0) + maxfactor = MIN(maxfactor, ((float)Ynew)/(Ynew-b)); + + float U = (float)(-0.14713*r - 0.28886*g + 0.436*b)*maxfactor; + float V = (float)(0.615*r - 0.51499*g - 0.10001*b)*maxfactor; + + r = CLIP(Ynew + 1.13983*V); + g = CLIP(Ynew - 0.39465*U - 0.58060*V); + b = CLIP(Ynew + 2.03211*U); + r = tonecurve2[CLIP(r)]; g = tonecurve2[CLIP(g)]; b = tonecurve2[CLIP(b)]; + int x = (toxyz[0][0] * r + toxyz[1][0] * g + toxyz[2][0] * b) >> 15; int y = (toxyz[0][1] * r + toxyz[1][1] * g + toxyz[2][1] * b) >> 15; diff --git a/rtgui/tonecurve.cc b/rtgui/tonecurve.cc index e68690dec..f0f194844 100644 --- a/rtgui/tonecurve.cc +++ b/rtgui/tonecurve.cc @@ -57,7 +57,7 @@ ToneCurve::ToneCurve () : ToolPanel(), expAdd(false), blackAdd(false), brAdd(fal //----------- Black Level ---------------------------------- 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, 50)); + shcompr = Gtk::manage (new Adjuster (M("TP_EXPOSURE_COMPRSHADOWS"), 0, 100, 1, 25)); pack_start (*shcompr); pack_start (*Gtk::manage (new Gtk::HSeparator()));