Allow black slider to take negative values, allows shadow lifting.

This commit is contained in:
Emil Martinec
2010-11-08 00:05:56 -06:00
parent 2ecabc628a
commit 0118793c0d
3 changed files with 33 additions and 13 deletions

View File

@@ -27,6 +27,8 @@
#define CURVES_MIN_POLY_POINTS 1000 #define CURVES_MIN_POLY_POINTS 1000
#define SQR(x) ((x)*(x))
namespace rtengine { namespace rtengine {
class CurveFactory { class CurveFactory {
@@ -82,17 +84,35 @@ class CurveFactory {
if (x<x1) return x*m; if (x<x1) return x*m;
return 1.0 - hr + hr*baseu((x-x1)/hr, m, 0.3*hr); return 1.0 - hr + hr*baseu((x-x1)/hr, m, 0.3*hr);
} }
static inline double clower2 (double x, double m, double sr) {
float x1 = sr/1.5 + 0.00001;
float y1 = 1-(1-x1)*m;
if (x>x1 || sr<0.001)
return 1-(1-x)*m;
else
return y1+m*(x-x1)-(1-m)*SQR(SQR(1-x/x1));
}
// tone curve base. a: slope (from exp.comp.), b: black, D: max. x value (can be>1), hr,sr: highlight,shadow recovery // tone curve base. a: slope (from exp.comp.), b: black, D: max. x value (can be>1), hr,sr: highlight,shadow recovery
static inline double basecurve (double x, double a, double b, double D, double hr, double sr) { static inline double basecurve (double x, double a, double b, double D, double hr, double sr) {
double m = a>1 ? b+0.25*(1-b)/a : b+(1-b)/4; if (b<0) {
double y = a>1 ? 0.25 : 0.25*a; double m = 0.5;
double slope = a/(1-b); double slope = 1+b;
if (x<=m) double y = -b+m*slope;
return b==0 ? x*a : clower (x/m, slope*m/y, sr) * y; if (x>m)
else if (a>1) return y + (x - m)*slope;
return y+(1.0-y)*cupper2((x-m)/(1-m), slope*(1-m)/(1.0-y), hr); else
else return y*clower2(x/m, slope*m/y, 2.0-sr);
return y+(x-m)*slope; } else {
double m = a>1 ? b+0.25*(1-b)/a : b+(1-b)/4;
double y = a>1 ? 0.25 : 0.25*a;
double slope = a/(1-b);
if (x<=m)
return b==0 ? x*a : clower (x/m, slope*m/y, sr) * y;
else if (a>1)
return y+(1.0-y)*cupper2((x-m)/(1-m), slope*(1-m)/(1.0-y), hr);
else
return y+(x-m)*slope;
}
} }
// brightness curve at point x, only positive amount it supported // brightness curve at point x, only positive amount it supported
static inline double brightnessbase (double x, double amount) { static inline double brightnessbase (double x, double amount) {

View File

@@ -346,9 +346,9 @@ void ImProcFunctions::rgbProc (Image16* working, LabImage* lab, int* hltonecurve
b *= tonefactor; b *= tonefactor;
//brightness/contrast and user tone curve //brightness/contrast and user tone curve
r = tonecurve[r]; r = tonecurve[CLIP(r)];
g = tonecurve[g]; g = tonecurve[CLIP(g)];
b = tonecurve[b]; b = tonecurve[CLIP(b)];
if (abs(sat)>0.5) { if (abs(sat)>0.5) {
float h, s, v; float h, s, v;

View File

@@ -55,7 +55,7 @@ ToneCurve::ToneCurve () : ToolPanel(), expAdd(false), blackAdd(false), brAdd(fal
pack_start (*hlcompr); pack_start (*hlcompr);
//----------- Black Level ---------------------------------- //----------- Black Level ----------------------------------
black = Gtk::manage (new Adjuster (M("TP_EXPOSURE_BLACKLEVEL"), 0, 32768, 1, 0)); black = Gtk::manage (new Adjuster (M("TP_EXPOSURE_BLACKLEVEL"), -16384, 32768, 1, 0));
pack_start (*black); pack_start (*black);
shcompr = Gtk::manage (new Adjuster (M("TP_EXPOSURE_COMPRSHADOWS"), 0, 100, 1, 50)); shcompr = Gtk::manage (new Adjuster (M("TP_EXPOSURE_COMPRSHADOWS"), 0, 100, 1, 50));
pack_start (*shcompr); pack_start (*shcompr);