New highlight recovery tool, including highlight recovery threshold.

This commit is contained in:
Emil Martinec
2011-01-05 20:11:32 -06:00
parent 13dc744e9b
commit ac9f1c7b09
19 changed files with 110 additions and 416 deletions

View File

@@ -319,191 +319,7 @@ double CurveFactory::centercontrast (double x, double b, double m) {
}
}
/*
void CurveFactory::complexCurve (double ecomp, double black, double hlcompr, double shcompr, double br, double contr, double defmul, double gamma_, bool igamma, const std::vector<double>& curvePoints, unsigned int* histogram, int* outCurve, unsigned int* outBeforeCCurveHistogram, int skip) {
printf ("ecomp= %f black= %f hlcompr= %f shcompr= %f br= %f contr= %f defmul= %f gamma= %f, skip= %d \n",ecomp,black,hlcompr,shcompr,br,contr,defmul,gamma_,skip);
double def_mul = pow (2.0, defmul);
// compute parameters of the gamma curve
double start = exp(gamma_*log( -0.099 / ((1.0/gamma_-1.0)*1.099 )));
double slope = 1.099 * pow (start, 1.0/gamma_-1) - 0.099/start;
double mul = 1.099;
double add = 0.099;
// theoretical maximum of the curve
double D = def_mul;
// a: slope of the curve, black: starting point at the x axis
double a = pow (2.0, ecomp);
// curve without contrast
double* dcurve = new double[65536];
// check if contrast curve is needed
bool needcontrast = contr>0.00001 || contr<-0.00001;
// check if inverse gamma is needed at the end
bool needigamma = !needcontrast && igamma && gamma_>0;
// create a curve if needed
Curve* tcurve = NULL;
if (curvePoints.size()>0 && curvePoints[0]!=0)
tcurve = new Curve (curvePoints, CURVES_MIN_POLY_POINTS/skip);
// clear array that stores histogram valid before applying the custom curve
if (outBeforeCCurveHistogram)
memset (outBeforeCCurveHistogram, 0, 256*sizeof(int));
for (int i=0; i<=0xffff; i+= i<0xffff-skip ? skip : 1 ) {
// change to [0,1] range
double val = (double)i / 65535.0;
// apply default multiplier (that is >1 if highlight recovery is on)
val *= def_mul;
// apply base curve, thus, exposure compensation and black point with shadow and highlight protection
val = basecurve (val, a, black, D, hlcompr/100.0, shcompr/100.0);
// gamma correction
if (gamma_>0)
val = gamma (val, gamma_, start, slope, mul, add);
// apply brightness curve
val = brightness (val, br/100.0);
// apply custom/parametric/NURBS curve, if any
if (tcurve) {
if (outBeforeCCurveHistogram) {
double hval = val;
// if (needigamma)
// hval = igamma2 (hval);
int hi = (int)(255.0*CLIPD(hval));
outBeforeCCurveHistogram[hi]+=histogram[i] ;
}
val = tcurve->getVal (val);
}
// if inverse gamma is needed, do it (standard sRGB inverse gamma is applied)
if (needigamma)
val = igamma2 (val);
// store result in a temporary array
dcurve[i] = CLIPD(val);
}
delete tcurve;
// if skip>1, let apply linear interpolation in the skipped points of the curve
int prev = 0;
for (int i=1; i<=0xffff-skip; i++) {
if (i%skip==0) {
prev+=skip;
continue;
}
dcurve[i] = ( dcurve[prev] * (skip - i%skip) + dcurve[prev+skip] * (i%skip) ) / skip;
}
if (needcontrast) {
// compute mean luminance of the image with the curve applied
int sum = 0;
double avg = 0;
for (int i=0; i<=0xffff; i++) {
avg += dcurve[i] * histogram[i];
sum += histogram[i];
}
avg /= sum;
// compute contrast parameter
double contr_b = contr / 20;
if (contr_b>=0 && contr_b < 0.00001)
contr_b = 0.00001;
else if (contr_b<0 && contr_b > -0.00001)
contr_b = -0.00001;
// apply contrast enhancement
for (int i=0; i<=0xffff; i++) {
double val = centercontrast (dcurve[i], contr_b, avg);
if (igamma && gamma_>0)
val = igamma2 (val);
outCurve[i] = (int) (65535.0 * CLIPD(val));
}
}
else
for (int i=0; i<=0xffff; i++)
outCurve[i] = (int) (65535.0 * dcurve[i]);
delete [] dcurve;
}
*/
/*
void CurveFactory::complexsgnCurve (double satclip, double satcompr, double saturation, double colormult, const std::vector<double>& curvePoints, int* outCurve, int skip) {
//colormult = chroma_scale for Lab manipulations
bool needsaturation = (saturation<-0.0001 || saturation>0.0001);
// curve without contrast
double* dcurve = new double[65536];
// create a curve if needed
Curve* tcurve = NULL;
if (curvePoints.size()>0 && curvePoints[0]!=0)
tcurve = new Curve (curvePoints, CURVES_MIN_POLY_POINTS/skip);
for (int i=0; i<=0xffff; i+= i<0xffff-skip ? skip : 1 ) {
// change to [0,1] range
double val = (double)i / 65535.0;
// apply default multiplier (that is >1 if highlight recovery is on)
val *= colormult;
// apply base curve, thus, exposure compensation and black point with shadow and highlight protection
//val = basecurve (val, 1.0, 0, colormult, satcompr/100.0, satcompr/100.0);
// apply custom/parametric/NURBS curve, if any
if (tcurve) {
val = tcurve->getVal (val);
}
// store result in a temporary array
dcurve[i] = CLIPD(val);
}
delete tcurve;
// if skip>1, let apply linear interpolation in the skipped points of the curve
int prev = 0;
for (int i=1; i<=0xffff-skip; i++) {
if (i%skip==0) {
prev+=skip;
continue;
}
dcurve[i] = ( dcurve[prev] * (skip - i%skip) + dcurve[prev+skip] * (i%skip) ) / skip;
}
if (needsaturation) {
float avg = 0.5;
// compute contrast parameter
double saturation_b = saturation / 20;
if (saturation_b>=0 && saturation_b < 0.00001)
saturation_b = 0.00001;
else if (saturation_b<0 && saturation_b > -0.00001)
saturation_b = -0.00001;
// apply contrast enhancement
for (int i=0; i<=0xffff; i++) {
double val = centercontrast (dcurve[i], saturation_b, avg);
outCurve[i] = (int) (65535.0 * CLIPD(val));
}
}
else
for (int i=0; i<=0xffff; i++)
outCurve[i] = (int) (65535.0 * dcurve[i]);
delete [] dcurve;
}
*/
void CurveFactory::complexsgnCurve (double satclip, double satcompr, double saturation, double colormult, const std::vector<double>& curvePoints, int* outCurve, int skip) {
@@ -586,195 +402,14 @@ void CurveFactory::complexCurve (double ecomp, double black, double hlcompr, dou
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
/*
void CurveFactory::complexCurve (double ecomp, double black, double hlcompr, double shcompr, double br, double contr, double defmul, double gamma_, bool igamma, const std::vector<double>& curvePoints, unsigned int* histogram, float* hlCurve, float* shCurve, int* outCurve, unsigned int* outBeforeCCurveHistogram, int skip) {
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);
// compute parameters of the gamma curve
double start = exp(gamma_*log( -0.099 / ((1.0/gamma_-1.0)*1.099 )));
double slope = 1.099 * pow (start, 1.0/gamma_-1) - 0.099/start;
double mul = 1.099;
double add = 0.099;
// a: slope of the curve, black: starting point at the x axis
double a = pow (2.0, ecomp);
// curve without contrast
double* dcurve = new double[65536];
// check if contrast curve is needed
bool needcontrast = contr>0.00001 || contr<-0.00001;
// check if inverse gamma is needed at the end
bool needigamma = !needcontrast && igamma && gamma_>0;
// create a curve if needed
Curve* tcurve = NULL;
if (curvePoints.size()>0 && curvePoints[0]!=0)
tcurve = new Curve (curvePoints, CURVES_MIN_POLY_POINTS/skip);
// clear array that stores histogram valid before applying the custom curve
if (outBeforeCCurveHistogram)
memset (outBeforeCCurveHistogram, 0, 256*sizeof(int));
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// tone curve base. a: slope (from exp.comp.), b: black, def_mul: max. x value (can be>1), hr,sr: highlight,shadow recovery
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
std::vector<double> brightcurvePoints;
brightcurvePoints.push_back((double)((CurveType)NURBS));
brightcurvePoints.push_back(0); //black point. Value in [0 ; 1] range
brightcurvePoints.push_back(0); //black point. Value in [0 ; 1] range
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
Curve* brightcurve = NULL;
brightcurve = new Curve (brightcurvePoints, CURVES_MIN_POLY_POINTS/skip); // Actually, CURVES_MIN_POLY_POINTS = 1000,
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for (int i=0; i<=0xffff; i++) {
// change to [0,1] range
double val = (double)i / 65535.0;
// apply default multiplier (that is >1 if highlight recovery is on)
// val *= def_mul;
// apply base curve, thus, exposure compensation and black point with shadow and highlight protection
val = basecurve (val*def_mul, a, 0, def_mul, hlcompr/100.0, 0);
//val = basecurve (val*def_mul, a, black, def_mul, hlcompr/100.0, 1.5*shcompr/100.0);
hlCurve[i] = (65535.0 * CLIPD(val));
//%%%%%%%%%%%%%%%%%%%%%%%%%%
// change to [0,1] range
val = (double)i / 65535.0;
val = basecurve (val, 1, black, 1, 0, 1.5*shcompr/100.0);
shCurve[i] = (65535.0 * CLIPD(val));
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%
for (int i=0; i<=0xffff; i+= i<0xffff-skip ? skip : 1 ) {
// change to [0,1] range
double val = (double)i / 65535.0;
float val0 = val;
// gamma correction
if (gamma_>0)
val = gamma (val, gamma_, start, slope, mul, add);
// apply brightness curve
//val = brightness (val, br/100.0);
val = brightcurve->getVal (val);
// apply custom/parametric/NURBS curve, if any
if (tcurve) {
if (outBeforeCCurveHistogram) {
float hval = shCurve[(int)(hlCurve[i])]*(float)val/(65535*val0);
//if (needigamma)
// hval = igamma2 (hval);
int hi = (int)(255.0*CLIPD(hval));
outBeforeCCurveHistogram[hi]+=histogram[i] ;
}
val = tcurve->getVal (val);
}
// if inverse gamma is needed, do it (standard sRGB inverse gamma is applied)
if (needigamma)
val = igamma2 (val);
// store result in a temporary array
dcurve[i] = CLIPD(val);
}
delete tcurve;
delete brightcurve;
// if skip>1, let apply linear interpolation in the skipped points of the curve
int prev = 0;
for (int i=1; i<=0xffff-skip; i++) {
if (i%skip==0) {
prev+=skip;
continue;
}
dcurve[i] = ( dcurve[prev] * (skip - i%skip) + dcurve[prev+skip] * (i%skip) ) / skip;
}
if (needcontrast) {
// compute mean luminance of the image with the curve applied
int sum = 0;
double avg = 0;
//double sqavg = 0;
for (int i=0; i<=0xffff; i++) {
avg += dcurve[(int)shCurve[(int)hlCurve[i]]] * histogram[i];
//sqavg += dcurve[i]*dcurve[i] * histogram[i];
sum += histogram[i];
}
avg /= sum;
//sqavg /= sum;
//double stddev = sqrt(sqavg-avg*avg);
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
std::vector<double> contrastcurvePoints;
contrastcurvePoints.push_back((double)((CurveType)NURBS));
contrastcurvePoints.push_back(0); //black point. Value in [0 ; 1] range
contrastcurvePoints.push_back(0); //black point. Value in [0 ; 1] range
contrastcurvePoints.push_back(avg-avg*(0.6-contr/250.0)); //toe point
contrastcurvePoints.push_back(avg-avg*(0.6+contr/250.0)); //value at toe point
contrastcurvePoints.push_back(avg+(1-avg)*(0.6-contr/250.0)); //shoulder point
contrastcurvePoints.push_back(avg+(1-avg)*(0.6+contr/250.0)); //value at shoulder point
contrastcurvePoints.push_back(1); // white point
contrastcurvePoints.push_back(1); // value at white point
Curve* contrastcurve = NULL;
contrastcurve = new Curve (contrastcurvePoints, CURVES_MIN_POLY_POINTS/skip); // Actually, CURVES_MIN_POLY_POINTS = 1000,
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// apply contrast enhancement
for (int i=0; i<=0xffff; i++) {
//double val = centercontrast (dcurve[i], contr_b, avg);
double val = contrastcurve->getVal (dcurve[i]);
if (igamma && gamma_>0)
val = igamma2 (val);
outCurve[i] = (int) (65535.0 * CLIPD(val));
}
delete contrastcurve;
}
else
for (int i=0; i<=0xffff; i++)
outCurve[i] = (int) (65535.0 * dcurve[i]);
delete [] dcurve;
}
*/
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void CurveFactory::complexCurve (double ecomp, double black, double hlcompr, double shcompr, double br, double contr, double defmul, double gamma_, bool igamma, const std::vector<double>& curvePoints, unsigned int* histogram, float* hlCurve, float* shCurve, int* outCurve, unsigned int* outBeforeCCurveHistogram, int skip) {
void CurveFactory::complexCurve (double ecomp, double black, double hlcompr, double hlcomprthresh, \
double shcompr, double br, double contr, double defmul, double gamma_, bool igamma, \
const std::vector<double>& curvePoints, unsigned int* histogram, \
float* hlCurve, float* shCurve, int* outCurve, \
unsigned int* outBeforeCCurveHistogram, int skip) {
double def_mul = pow (2.0, defmul);
@@ -837,6 +472,11 @@ void CurveFactory::complexCurve (double ecomp, double black, double hlcompr, dou
brightcurve = new Curve (brightcurvePoints, CURVES_MIN_POLY_POINTS/skip); // Actually, CURVES_MIN_POLY_POINTS = 1000,
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
float exp_scale = a*def_mul ;
float scale = 65536.0;
float comp = (ecomp + defmul)*hlcompr/100.0;
int shoulder = (int)((scale/exp_scale)*(hlcomprthresh/200.0));
for (int i=0; i<=0xffff; i++) {
// change to [0,1] range
@@ -846,10 +486,22 @@ void CurveFactory::complexCurve (double ecomp, double black, double hlcompr, dou
// val *= def_mul;
// apply base curve, thus, exposure compensation and black point with shadow and highlight protection
val = basecurve (val*def_mul, a, 0, def_mul, hlcompr/100.0, 0);
//val = basecurve (val*def_mul, a, black, def_mul, hlcompr/100.0, 1.5*shcompr/100.0);
//val = basecurve (val*def_mul, a, 0, def_mul, hlcompr/100.0, 0);
hlCurve[i] = (65535.0 * CLIPD(val));
//hlCurve[i] = (65535.0 * CLIPD(val));
if ((hlcompr>0)&&(exp_scale>1.0))
{
if (i>shoulder) {
float Y = (float)(i-shoulder)*exp_scale/(scale-shoulder);
float R = (float)(i-shoulder)*comp/(scale-shoulder);
hlCurve[i] = log(1+Y*comp)/R;
} else {
hlCurve[i]=exp_scale;
}
} else {
hlCurve[i]=exp_scale;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%
// change to [0,1] range
@@ -885,7 +537,7 @@ void CurveFactory::complexCurve (double ecomp, double black, double hlcompr, dou
double avg = 0;
//double sqavg = 0;
for (int i=0; i<=0xffff; i++) {
avg += dcurve[(int)shCurve[(int)hlCurve[i]]] * histogram[i];
avg += dcurve[(int)shCurve[(int)hlCurve[i]*i]] * histogram[i];
//sqavg += dcurve[i]*dcurve[i] * histogram[i];
sum += histogram[i];
}

View File

@@ -158,7 +158,7 @@ class CurveFactory {
public:
// static void updateCurve3 (int* curve, int* ohistogram, const std::vector<double>& cpoints, double defmul, double ecomp, int black, double hlcompr, double shcompr, double br, double contr, double gamma_, bool igamma, int skip=1);
static void complexCurve (double ecomp, double black, double hlcompr, double shcompr, double br, double contr, double defmul, double gamma_, bool igamma, const std::vector<double>& curvePoints, unsigned int* histogram, float* hlCurve, float* shCurve, int* outCurve, unsigned int* outBeforeCCurveHistogram, int skip=1);
static void complexCurve (double ecomp, double black, double hlcompr, double hlcomprthresh, double shcompr, double br, double contr, double defmul, double gamma_, bool igamma, const std::vector<double>& curvePoints, unsigned int* histogram, float* hlCurve, float* shCurve, int* outCurve, unsigned int* outBeforeCCurveHistogram, int skip=1);
static void complexsgnCurve (double satclip, double satcompr, double saturation, double colormult, const std::vector<double>& curvePoints, int* outCurve, int skip=1);
};

View File

@@ -203,7 +203,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) {
progress ("Exposure curve & CIELAB conversion...",100*readyphase/numofphases);
if (todo & M_RGBCURVE) {
CurveFactory::complexCurve (params.toneCurve.expcomp, params.toneCurve.black/65535.0, params.toneCurve.hlcompr, params.toneCurve.shcompr, params.toneCurve.brightness, params.toneCurve.contrast, imgsrc->getDefGain(), imgsrc->getGamma(), true, params.toneCurve.curve, vhist16, hltonecurve, shtonecurve, tonecurve, bcrgbhist, scale==1 ? 1 : 1);
CurveFactory::complexCurve (params.toneCurve.expcomp, params.toneCurve.black/65535.0, params.toneCurve.hlcompr, params.toneCurve.hlcomprthresh, params.toneCurve.shcompr, params.toneCurve.brightness, params.toneCurve.contrast, imgsrc->getDefGain(), imgsrc->getGamma(), true, params.toneCurve.curve, vhist16, hltonecurve, shtonecurve, tonecurve, bcrgbhist, scale==1 ? 1 : 1);
ipf.rgbProc (oprevi, oprevl, hltonecurve, shtonecurve, tonecurve, shmap, params.toneCurve.saturation);
// recompute luminance histogram
@@ -215,7 +215,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) {
readyphase++;
if (todo & M_LUMACURVE) {
CurveFactory::complexCurve (0.0, 0.0, 0.0, 0.0, params.labCurve.brightness, params.labCurve.contrast, 0.0, 0.0, false, params.labCurve.lcurve, lhist16, dummy1, dummy2, lumacurve, bcLhist, scale==1 ? 1 : 16);
CurveFactory::complexCurve (0.0, 0.0, 0.0, 0.0, 0.0, params.labCurve.brightness, params.labCurve.contrast, 0.0, 0.0, false, params.labCurve.lcurve, lhist16, dummy1, dummy2, lumacurve, bcLhist, scale==1 ? 1 : 16);
CurveFactory::complexsgnCurve (0.0, 100.0, params.labCurve.saturation, 1.0, params.labCurve.acurve, chroma_acurve, scale==1 ? 1 : 16);
CurveFactory::complexsgnCurve (0.0, 100.0, params.labCurve.saturation, 1.0, params.labCurve.bcurve, chroma_bcurve, scale==1 ? 1 : 16);
}

View File

@@ -257,7 +257,7 @@ void ImProcFunctions::firstAnalysis (Image16* original, const ProcParams* params
delete [] hist;
}
void ImProcFunctions::rgbProc (Image16* working, LabImage* lab, float* hltonecurve, float* shtonecurve, int* tonecurve, SHMap* shmap, int sat) {
void ImProcFunctions::rgbProc (Image16* working, LabImage* lab, float* hltonecurve, float* shtonecurve, int* tonecurve, SHMap* shmap, /*float defmul,*/ int sat) {
int h_th, s_th;
if (shmap) {
@@ -343,34 +343,28 @@ void ImProcFunctions::rgbProc (Image16* working, LabImage* lab, float* hltonecur
b = CLIP((int)(factor*b));
}
}
//float h, s, v;
//rgb2hsv(r,g,b,h,s,v);
//highlight tone curve
//v = (float)hltonecurve[(int)(65535*v)]/65535;
float rtonefactor = (r>0 ? (float)hltonecurve[r]/r : (float)hltonecurve[1]);
float gtonefactor = (g>0 ? (float)hltonecurve[g]/g : (float)hltonecurve[1]);
float btonefactor = (b>0 ? (float)hltonecurve[b]/b : (float)hltonecurve[1]);
//float tonefactor = MIN(rtonefactor, MIN(gtonefactor,btonefactor));
float tonefactor = (rtonefactor+gtonefactor+btonefactor)/3;
//float rtonefactor = (r>0 ? (float)hltonecurve[r]/r : (float)hltonecurve[1]);
//float gtonefactor = (g>0 ? (float)hltonecurve[g]/g : (float)hltonecurve[1]);
//float btonefactor = (b>0 ? (float)hltonecurve[b]/b : (float)hltonecurve[1]);
//float tonefactor = (rtonefactor+gtonefactor+btonefactor)/3;
//float tonefactor = (0.299*rtonefactor+0.587*gtonefactor+0.114*btonefactor);
r = CLIP(r*tonefactor);
g = CLIP(g*tonefactor);
b = CLIP(b*tonefactor);
//float tonefactor=(my_tonecurve[r]+my_tonecurve[g]+my_tonecurve[b])/3;
float tonefactor=(hltonecurve[r]+hltonecurve[g]+hltonecurve[b])/3;
r = (r*tonefactor);
g = (g*tonefactor);
b = (b*tonefactor);
//shadow tone curve
int Y = (int)(0.299*r + 0.587*g + 0.114*b);
int Y = CLIP((int)(0.299*r + 0.587*g + 0.114*b));
tonefactor = (Y>0 ? (float)shtonecurve[Y]/Y : 1);
r *= tonefactor;
g *= tonefactor;
b *= tonefactor;
//brightness/contrast and user tone curve
//Y = (int)(0.299*r + 0.587*g + 0.114*b);
//tonefactor = (Y>0 ? (float)tonecurve[Y]/Y : 1);
//r *= tonefactor;
//g *= tonefactor;
//b *= tonefactor;
r = tonecurve[CLIP(r)];
g = tonecurve[CLIP(g)];
b = tonecurve[CLIP(b)];
@@ -438,7 +432,7 @@ void ImProcFunctions::rgbProc (Image16* working, LabImage* lab, float* hltonecur
}
delete [] cossq;
//delete [] my_tonecurve;
}
void ImProcFunctions::luminanceCurve (LabImage* lold, LabImage* lnew, int* curve, int row_from, int row_to) {

View File

@@ -55,6 +55,7 @@ void ProcParams::setDefaults () {
toneCurve.saturation = 0;
toneCurve.black = 0;
toneCurve.hlcompr = 70;
toneCurve.hlcomprthresh = 0;
toneCurve.shcompr = 25;
toneCurve.curve.clear ();
@@ -236,6 +237,7 @@ int ProcParams::save (Glib::ustring fname) const {
keyFile.set_integer ("Exposure", "Saturation", toneCurve.saturation);
keyFile.set_integer ("Exposure", "Black", toneCurve.black);
keyFile.set_integer ("Exposure", "HighlightCompr", toneCurve.hlcompr);
keyFile.set_integer ("Exposure", "HighlightComprThreshold", toneCurve.hlcomprthresh);
keyFile.set_integer ("Exposure", "ShadowCompr", toneCurve.shcompr);
Glib::ArrayHandle<double> tcurve = toneCurve.curve;
keyFile.set_double_list("Exposure", "Curve", tcurve);
@@ -502,6 +504,7 @@ if (keyFile.has_group ("Exposure")) {
if (keyFile.has_key ("Exposure", "Black")) toneCurve.black = keyFile.get_integer ("Exposure", "Black");
if (keyFile.has_key ("Exposure", "HighlightCompr")) toneCurve.hlcompr = keyFile.get_integer ("Exposure", "HighlightCompr");
if (toneCurve.hlcompr > 100) toneCurve.hlcompr = 100; // older pp3 files can have values above 100.
if (keyFile.has_key ("Exposure", "HighlightComprThreshold")) toneCurve.hlcomprthresh = keyFile.get_integer ("Exposure", "HighlightComprThreshold");
if (keyFile.has_key ("Exposure", "ShadowCompr")) toneCurve.shcompr = keyFile.get_integer ("Exposure", "ShadowCompr");
if (toneCurve.shcompr > 100) toneCurve.shcompr = 100; // older pp3 files can have values above 100.
if (version>200)
@@ -854,6 +857,7 @@ bool ProcParams::operator== (const ProcParams& other) {
&& toneCurve.saturation == other.toneCurve.saturation
&& toneCurve.shcompr == other.toneCurve.shcompr
&& toneCurve.hlcompr == other.toneCurve.hlcompr
&& toneCurve.hlcomprthresh == other.toneCurve.hlcomprthresh
&& toneCurve.autoexp == other.toneCurve.autoexp
&& toneCurve.clip == other.toneCurve.clip
&& toneCurve.expcomp == other.toneCurve.expcomp

View File

@@ -41,6 +41,7 @@ class ToneCurveParams {
int saturation;
int shcompr;
int hlcompr;
int hlcomprthresh;
};
/**

View File

@@ -701,7 +701,7 @@ IImage8* Thumbnail::processImage (const procparams::ProcParams& params, int rhei
float* curve1 = new float [65536];
float* curve2 = new float [65536];
int* curve = new int [65536];
CurveFactory::complexCurve (br, bl/65535.0, params.toneCurve.hlcompr, params.toneCurve.shcompr, params.toneCurve.brightness, params.toneCurve.contrast, logDefGain, isRaw ? 2.2 : 0, true, params.toneCurve.curve, hist16, curve1, curve2, curve, NULL, 16);
CurveFactory::complexCurve (br, bl/65535.0, params.toneCurve.hlcompr, params.toneCurve.hlcomprthresh, params.toneCurve.shcompr, params.toneCurve.brightness, params.toneCurve.contrast, logDefGain, isRaw ? 2.2 : 0, true, params.toneCurve.curve, hist16, curve1, curve2, curve, NULL, 16);
LabImage* labView = new LabImage (baseImg);
ipf.rgbProc (baseImg, labView, curve1, curve2, curve, shmap, params.toneCurve.saturation);
@@ -716,7 +716,7 @@ IImage8* Thumbnail::processImage (const procparams::ProcParams& params, int rhei
hist16[labView->L[i][j]]++;
// luminance processing
CurveFactory::complexCurve (0.0, 0.0, 0.0, 0.0, params.labCurve.brightness, params.labCurve.contrast, 0.0, 0.0, false, params.labCurve.lcurve, hist16, curve1, curve2, curve, NULL, 16);
CurveFactory::complexCurve (0.0, 0.0, 0.0, 0.0, 0.0, params.labCurve.brightness, params.labCurve.contrast, 0.0, 0.0, false, params.labCurve.lcurve, hist16, curve1, curve2, curve, NULL, 16);
ipf.luminanceCurve (labView, labView, curve, 0, fh);
CurveFactory::complexsgnCurve (0.0, 100.0, params.labCurve.saturation, 1.0, params.labCurve.acurve, curve, 16);
ipf.chrominanceCurve (labView, labView, 0, curve, 0, fh);

View File

@@ -146,10 +146,10 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
float* curve2 = new float [65536];
int* curve = new int [65536];
CurveFactory::complexCurve (br, bl/65535.0, params.toneCurve.hlcompr, params.toneCurve.shcompr, params.toneCurve.brightness, params.toneCurve.contrast, imgsrc->getDefGain(), imgsrc->getGamma(), true, params.toneCurve.curve, hist16, curve1, curve2, curve, NULL);
CurveFactory::complexCurve (br, bl/65535.0, params.toneCurve.hlcompr, params.toneCurve.hlcomprthresh, params.toneCurve.shcompr, params.toneCurve.brightness, params.toneCurve.contrast, imgsrc->getDefGain(), imgsrc->getGamma(), true, params.toneCurve.curve, hist16, curve1, curve2, curve, NULL);
LabImage* labView = new LabImage (baseImg);
ipf.rgbProc (baseImg, labView, curve1, curve2, curve, shmap, params.toneCurve.saturation);
ipf.rgbProc (baseImg, labView, curve1, curve2, curve, shmap, params.toneCurve.saturation);
if (shmap)
delete shmap;
@@ -165,7 +165,7 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
hist16[labView->L[i][j]]++;
// luminance processing
CurveFactory::complexCurve (0.0, 0.0, 0.0, 0.0, params.labCurve.brightness, params.labCurve.contrast, 0.0, 0.0, false, params.labCurve.lcurve, hist16, curve1, curve2, curve, NULL);
CurveFactory::complexCurve (0.0, 0.0, 0.0, 0.0, 0.0, params.labCurve.brightness, params.labCurve.contrast, 0.0, 0.0, false, params.labCurve.lcurve, hist16, curve1, curve2, curve, NULL);
ipf.luminanceCurve (labView, labView, curve, 0, fh);
CurveFactory::complexsgnCurve (0.0, 100.0, params.labCurve.saturation, 1.0, params.labCurve.acurve, curve, 1);
ipf.chrominanceCurve (labView, labView, 0, curve, 0, fh);