diff --git a/rtengine/amaze_interpolate_RT.cc b/rtengine/amaze_interpolate_RT.cc index fc3af8a95..3bb819ee6 100644 --- a/rtengine/amaze_interpolate_RT.cc +++ b/rtengine/amaze_interpolate_RT.cc @@ -69,7 +69,7 @@ void RawImageSource::amaze_demosaic_RT() { static const float eps=1e-5, epssq=1e-10; //tolerance to avoid dividing by zero //adaptive ratios threshold - static const float arthresh=-0.75; + static const float arthresh=0.75; //nyquist texture test threshold static const float nyqthresh=0.5; //diagonal interpolation test threshold @@ -798,16 +798,19 @@ void RawImageSource::amaze_demosaic_RT() { ve=fabs(0.5-hvwtalt); if (vo0.75) hvwt[indx]=1.0; + Dgrb[indx][0] = (hcd[indx]*(1-hvwt[indx]) + vcd[indx]*hvwt[indx]);//evaluate color differences + //if (hvwt[indx]<0.5) Dgrb[indx][0]=hcd[indx]; + //if (hvwt[indx]>0.5) Dgrb[indx][0]=vcd[indx]; rgb[indx][1] = cfa[indx] + Dgrb[indx][0];//evaluate G (finally!) //local curvature in G (preparation for nyquist refinement step) if (nyquist[indx]) { Dgrbh2[indx] = SQR(rgb[indx][1] - 0.5*(rgb[indx-1][1]+rgb[indx+1][1])); Dgrbv2[indx] = SQR(rgb[indx][1] - 0.5*(rgb[indx-v1][1]+rgb[indx+v1][1])); + } else { + Dgrbh2[indx] = Dgrbv2[indx] = 0; } } diff --git a/rtengine/curves.cc b/rtengine/curves.cc index 2c0c206b3..1a40d635b 100644 --- a/rtengine/curves.cc +++ b/rtengine/curves.cc @@ -446,6 +446,9 @@ void CurveFactory::complexCurve (double ecomp, double black, double hlcompr, dou // clear array that stores histogram valid before applying the custom curve if (outBeforeCCurveHistogram) memset (outBeforeCCurveHistogram, 0, 256*sizeof(int)); + + //float atmp=a; + //a = 1; for (int i=0; i<=0xffff; i+= i<0xffff-skip ? skip : 1 ) { @@ -454,13 +457,20 @@ void CurveFactory::complexCurve (double ecomp, double black, double hlcompr, dou // apply default multiplier (that is >1 if highlight recovery is on) val *= def_mul; + + //exposure compensation + //val *= atmp; + //black *= atmp; + //D *= atmp; - // gamma correction - if (gamma_>0) - val = gamma (val, gamma_, start, slope, mul, add); + // 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); diff --git a/rtengine/improcfun.cc b/rtengine/improcfun.cc index bbf36de66..0d8d459c5 100644 --- a/rtengine/improcfun.cc +++ b/rtengine/improcfun.cc @@ -490,6 +490,8 @@ void ImProcFunctions::getAutoExp (unsigned int* histogram, int histcompr, doubl if (awg < maxaw) awg = maxaw; } + + awg = CurveFactory::igamma2 (awg); //need to inverse gamma transform to get correct exposure compensation parameter br = log(65535.0 / (awg-bl)) / log(2.0); if (br<0)