Auto Levels calculates wrong lightness value, which leads to crash of RT, Issue 2325 / Credits: Hombre, Ingo
This commit is contained in:
@@ -874,6 +874,8 @@ void CurveFactory::curveCL ( bool & clcutili,const std::vector<double>& clcurveP
|
||||
if (contr>0.00001 || contr<-0.00001) {
|
||||
utili=true;
|
||||
|
||||
DiagonalCurve* contrastcurve = NULL;
|
||||
|
||||
// compute mean luminance of the image with the curve applied
|
||||
int sum = 0;
|
||||
float avg = 0;
|
||||
@@ -883,6 +885,7 @@ void CurveFactory::curveCL ( bool & clcutili,const std::vector<double>& clcurveP
|
||||
//sqavg += dcurve[i]*dcurve[i] * histogram[i];
|
||||
sum += histogram[i];
|
||||
}
|
||||
if(sum) {
|
||||
avg /= sum;
|
||||
//sqavg /= sum;
|
||||
//float stddev = sqrt(sqavg-avg*avg);
|
||||
@@ -905,9 +908,24 @@ void CurveFactory::curveCL ( bool & clcutili,const std::vector<double>& clcurveP
|
||||
contrastcurvePoints.at(7) = 1.; // white point
|
||||
contrastcurvePoints.at(8) = 1.; // value at white point
|
||||
|
||||
DiagonalCurve* contrastcurve = new DiagonalCurve (contrastcurvePoints, CURVES_MIN_POLY_POINTS/skip);
|
||||
contrastcurve = new DiagonalCurve (contrastcurvePoints, CURVES_MIN_POLY_POINTS/skip);
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
} else {
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
// sum has an invalid value (next to 0, producing a division by zero, so we create a fake contrast curve, producing a white image
|
||||
std::vector<double> contrastcurvePoints;
|
||||
contrastcurvePoints.resize(5);
|
||||
contrastcurvePoints.at(0) = double(DCT_NURBS);
|
||||
|
||||
contrastcurvePoints.at(1) = 0.; // black point. Value in [0 ; 1] range
|
||||
contrastcurvePoints.at(2) = 1.; // black point. Value in [0 ; 1] range
|
||||
|
||||
contrastcurvePoints.at(3) = 1.; // white point
|
||||
contrastcurvePoints.at(4) = 1.; // value at white point
|
||||
|
||||
contrastcurve = new DiagonalCurve (contrastcurvePoints, CURVES_MIN_POLY_POINTS/skip);
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
}
|
||||
// apply contrast enhancement
|
||||
for (int i=0; i<32768; i++) {
|
||||
dcurve[i] = contrastcurve->getVal (dcurve[i]);
|
||||
|
@@ -4290,6 +4290,7 @@ fclose(f);*/
|
||||
if (expcomp<0.0) expcomp = 0.0;*/
|
||||
if (expcomp<-5.0) expcomp = -5.0;
|
||||
if (expcomp>12.0) expcomp = 12.0;
|
||||
bright = max(-100,min(bright,100));
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user