diff --git a/rtengine/improcfun.cc b/rtengine/improcfun.cc index 7c83f54da..83da67776 100644 --- a/rtengine/improcfun.cc +++ b/rtengine/improcfun.cc @@ -621,7 +621,7 @@ void ImProcFunctions::colorCurve (LabImage* lold, LabImage* lnew) { double corr = 1;//pow(2.0, defgain);//defgain may be redundant legacy of superceded code??? float scale = 65536.0; - float midgray=0.18445f;//middle gray in linear gamma = 0.18445*65535 + float midgray=0.15;//0.18445f;//middle gray in linear gamma = 0.18445*65535 int imax=65536>>histcompr; @@ -630,7 +630,7 @@ void ImProcFunctions::colorCurve (LabImage* lold, LabImage* lnew) { //find average luminance for (int i=0; isum/8) { - octile[count]=log(1+i)/log(2); - count = MIN(count+1,7); + if (count<8) { + octile[count] += histogram[i]; + if (octile[count]>sum/8 || (count==7 && octile[count]>sum/16)) { + octile[count]=log(1+i)/log(2); + count++;// = MIN(count+1,7); + } } - if (ilog(imax+1)/log2(2)) { + octile[7]=1.5*octile[6]-0.5*octile[5]; + } // compute weighted average separation of octiles // for future use in contrast setting for (int i=1; i<6; i++) { @@ -680,7 +685,7 @@ void ImProcFunctions::colorCurve (LabImage* lold, LabImage* lnew) { } //compute clipped white point - int clippable = (int)(sum * clip); + int clippable = (int)(sum * clip ); clipped = 0; int whiteclip = (imax) - 1; while (whiteclip>1 && histogram[whiteclip]+clipped <= clippable) { @@ -702,85 +707,102 @@ void ImProcFunctions::colorCurve (LabImage* lold, LabImage* lnew) { ave = ave*(1<>histcompr; i++) + gavg += histogram[i] * CurveFactory::gamma2((int)(corr*(i<>histcompr; i++) - gavg += histogram[i] * CurveFactory::gamma2((int)(corr*(i<10.0) expcomp=10.0; + if (expcomp<-5.0) expcomp = -5.0; + if (expcomp>10.0) expcomp = 10.0; } + //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% #include "calc_distort.h" diff --git a/rtengine/rawimagesource.cc b/rtengine/rawimagesource.cc index c3e668cbf..f50e4112a 100644 --- a/rtengine/rawimagesource.cc +++ b/rtengine/rawimagesource.cc @@ -1921,10 +1921,11 @@ void RawImageSource::HLRecovery_blend(float* rin, float* gin, float* bin, int wi #define SQR(x) ((x)*(x)) - float minpt=MIN(MIN(hlmax[0],hlmax[1]),hlmax[2]); - //float maxpt=MAX(MAX(hlmax[0],hlmax[1]),hlmax[2]); - //float medpt=hlmax[0]+hlmax[1]+hlmax[2]-minpt-maxpt; - float maxave=(hlmax[0]+hlmax[1]+hlmax[2])/3; + float minpt=MIN(MIN(hlmax[0],hlmax[1]),hlmax[2]);//min of the raw clip points + //float maxpt=MAX(MAX(hlmax[0],hlmax[1]),hlmax[2]);//max of the raw clip points + //float medpt=hlmax[0]+hlmax[1]+hlmax[2]-minpt-maxpt;//median of the raw clip points + float maxave=(hlmax[0]+hlmax[1]+hlmax[2])/3;//ave of the raw clip points + //some thresholds: const float clipthresh = 0.95; const float fixthresh = 0.5; const float satthresh = 0.5; @@ -1940,7 +1941,7 @@ void RawImageSource::HLRecovery_blend(float* rin, float* gin, float* bin, int wi #pragma omp parallel for for (int col=0; col desatpt) { Lfrac = MAX(0,(maxave-L)/(maxave-desatpt)); C = Lfrac * 1.732050808 * (rin[col] - gin[col]);