diff --git a/rtengine/color.cc b/rtengine/color.cc index c0d52a7d6..13d320cc5 100644 --- a/rtengine/color.cc +++ b/rtengine/color.cc @@ -1593,7 +1593,7 @@ void Color::calcGamma (double pwr, double ts, int mode, GammaValues &gamma) bnd[g[1] >= 1.] = 1.; if (g[1] && (g[1] - 1.) * (g[0] - 1.) <= 0.) { - for (i = 0; i < 48; i++) { + for (i = 0; i < 99; i++) { g[2] = (bnd[0] + bnd[1]) / 2.; if (g[0]) { diff --git a/rtengine/color.h b/rtengine/color.h index 5b863d735..edcc02cb4 100644 --- a/rtengine/color.h +++ b/rtengine/color.h @@ -1073,25 +1073,29 @@ public: /** * @brief sRGB gamma - * See also calcGamma above with the following values: pwr=2.4 ts=12.92 mode=0.003041 imax=0.055011 + * See also calcGamma above with the following values: pwr=2.399 ts=12.92 mode=0.003041 imax=0.055 * @param x red, green or blue channel's value [0 ; 1] * @return the gamma modified's value [0 ; 1] */ static inline double gamma2 (double x) // g3 1+g4 { - return x <= 0.003041 ? x * 12.92 : 1.055011 * exp(log(x) / sRGBGammaCurve) - 0.055011; + // return x <= 0.003041 ? x * 12.92 : 1.055 * exp(log(x) / 2.39990) - 0.055;//calculate with calcgamma + return x <= 0.0031308 ? x * 12.92 : 1.055 * exp(log(x) / sRGBGammaCurve) - 0.055; + //very small differences between the 2 } /** * @brief Inverse sRGB gamma - * See also calcGamma above with the following values: pwr=2.4 ts=12.92 mode=0.003041 imax=0.055011 + * See also calcGamma above with the following values: pwr=2.3999 ts=12.92 mode=0.003041 imax=0.055 * @param x red, green or blue channel's value [0 ; 1] * @return the inverse gamma modified's value [0 ; 1] */ static inline double igamma2 (double x) //g2 { - return x <= 0.039293 ? x / 12.92 : exp(log((x + 0.055011) / 1.055011) * sRGBGammaCurve); + // return x <= 0.039289 ? x / 12.92 : exp(log((x + 0.055) / 1.055) * 2.39990);//calculate with calcgamma + return x <= 0.04045 ? x / 12.92 : exp(log((x + 0.055) / 1.055) * sRGBGammaCurve); + //very small differences between the 2 } diff --git a/rtengine/iccstore.cc b/rtengine/iccstore.cc index 50ff58878..15fb366a0 100644 --- a/rtengine/iccstore.cc +++ b/rtengine/iccstore.cc @@ -1083,7 +1083,7 @@ void rtengine::ICCStore::getGammaArray(const procparams::ColorManagementParams & ga[3] = 1. / slope; ga[5] = 0.0; ga[6] = 0.0; - //printf("ga[0]=%f ga[1]=%f ga[2]=%f ga[3]=%f ga[4]=%f\n", ga[0],ga[1],ga[2],ga[3],ga[4]); + printf("ga[0]=%f ga[1]=%f ga[2]=%f ga[3]=%f ga[4]=%f\n", ga[0],ga[1],ga[2],ga[3],ga[4]); } } diff --git a/rtengine/improccoordinator.cc b/rtengine/improccoordinator.cc index 3edca9f45..be8aa2533 100644 --- a/rtengine/improccoordinator.cc +++ b/rtengine/improccoordinator.cc @@ -27,6 +27,7 @@ #include #include #include +#include "color.h" #ifdef _OPENMP #include @@ -316,6 +317,16 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) awbListener->WBChanged (params.wb.temperature, params.wb.green); } +/* + GammaValues g_a; + double pwr = 1.0 / params.icm.gampos; + double ts = params.icm.slpos; + + + int mode = 0; + Color::calcGamma(pwr, ts, mode, g_a); // call to calcGamma with selected gamma and slope + printf("ga[0]=%f ga[1]=%f ga[2]=%f ga[3]=%f ga[4]=%f\n", g_a[0],g_a[1],g_a[2],g_a[3],g_a[4]); + Glib::ustring datal; datal = "lutsrgb.txt"; ofstream fou(datal, ios::out | ios::trunc); @@ -323,13 +334,13 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) for(int i=0; i < 212; i++) { //printf("igamma2=%i\n", (int) 65535.f*Color::igamma2(i/212.0)); float gam = Color::igamma2(i/211.0); - int lutga = 65535.f* gam; + int lutga = nearbyint(65535.f* gam); // fou << 65535*(int)Color::igamma2(i/212.0) << endl; fou << i << " " << lutga << endl; } fou.close(); - +*/ int tr = getCoarseBitMask (params.coarse); imgsrc->getFullSize (fw, fh, tr); diff --git a/rtengine/rawimagesource.cc b/rtengine/rawimagesource.cc index a89cfc1bf..653c4294f 100644 --- a/rtengine/rawimagesource.cc +++ b/rtengine/rawimagesource.cc @@ -2103,7 +2103,7 @@ void RawImageSource::retinexPrepareBuffers(const ColorManagementParams& cmp, con int mode = 0; Color::calcGamma(pwr, ts, mode, g_a); // call to calcGamma with selected gamma and slope - // printf("g_a0=%f g_a1=%f g_a2=%f g_a3=%f g_a4=%f\n", g_a0,g_a1,g_a2,g_a3,g_a4); + // printf("g_a0=%f g_a1=%f g_a2=%f g_a3=%f g_a4=%f\n", g_a0,g_a1,g_a2,g_a3,g_a4); double start; double add; diff --git a/rtgui/icmpanel.cc b/rtgui/icmpanel.cc index f71ff354b..ce0c6a8f7 100644 --- a/rtgui/icmpanel.cc +++ b/rtgui/icmpanel.cc @@ -243,7 +243,7 @@ ICMPanel::ICMPanel () : FoldableToolPanel(this, "icm", M("TP_ICM_LABEL")), iunch freegamma->set_active (false); fgFrame->set_label_widget(*freegamma); - gampos = Gtk::manage(new Adjuster (M("TP_GAMMA_CURV"), 1, 3.5, 0.01, 2.22)); + gampos = Gtk::manage(new Adjuster (M("TP_GAMMA_CURV"), 1, 3.5, 0.00001, 2.22)); gampos->setAdjusterListener (this); if (gampos->delay < options.adjusterMaxDelay) {