diff --git a/rtengine/improcfun.cc b/rtengine/improcfun.cc index c68158634..96920c3da 100644 --- a/rtengine/improcfun.cc +++ b/rtengine/improcfun.cc @@ -78,6 +78,7 @@ void ImProcFunctions::updateColorProfiles (const Glib::ustring& monitorProfile, monitorTransform = nullptr; cmsHPROFILE monitor = nullptr; + if (!monitorProfile.empty()) { #if !defined(__APPLE__) // No support for monitor profiles on OS X, all data is sRGB monitor = ICCStore::getInstance()->getProfile (monitorProfile); @@ -90,32 +91,37 @@ void ImProcFunctions::updateColorProfiles (const Glib::ustring& monitorProfile, MyMutex::MyLock lcmsLock (*lcmsMutex); cmsUInt32Number flags; - cmsHPROFILE iprof = cmsCreateLab4Profile(nullptr); + cmsHPROFILE iprof = cmsCreateLab4Profile (nullptr); bool softProofCreated = false; if (softProof) { cmsHPROFILE oprof = nullptr; + if (!settings->printerProfile.empty()) { - oprof = ICCStore::getInstance()->getProfile(settings->printerProfile); + oprof = ICCStore::getInstance()->getProfile (settings->printerProfile); } if (oprof) { // NOCACHE is for thread safety, NOOPTIMIZE for precision flags = cmsFLAGS_SOFTPROOFING | cmsFLAGS_NOOPTIMIZE | cmsFLAGS_NOCACHE; + if (settings->printerBPC) { flags |= cmsFLAGS_BLACKPOINTCOMPENSATION; } + if (gamutCheck) { flags |= cmsFLAGS_GAMUTCHECK; } - monitorTransform = cmsCreateProofingTransform( - iprof, TYPE_Lab_FLT, - monitor, TYPE_RGB_8, - oprof, - monitorIntent, settings->printerIntent, - flags - ); + + monitorTransform = cmsCreateProofingTransform ( + iprof, TYPE_Lab_FLT, + monitor, TYPE_RGB_8, + oprof, + monitorIntent, settings->printerIntent, + flags + ); + if (monitorTransform) { softProofCreated = true; } @@ -124,13 +130,15 @@ void ImProcFunctions::updateColorProfiles (const Glib::ustring& monitorProfile, if (!softProofCreated) { flags = cmsFLAGS_NOOPTIMIZE | cmsFLAGS_NOCACHE; + if (settings->monitorBPC) { flags |= cmsFLAGS_BLACKPOINTCOMPENSATION; } + monitorTransform = cmsCreateTransform (iprof, TYPE_Lab_FLT, monitor, TYPE_RGB_8, monitorIntent, flags); } - cmsCloseProfile(iprof); + cmsCloseProfile (iprof); } } @@ -145,19 +153,19 @@ void ImProcFunctions::firstAnalysis (const Imagefloat* const original, const Pro int W = original->getWidth(); int H = original->getHeight(); - float lumimulf[3] = {static_cast(lumimul[0]), static_cast(lumimul[1]), static_cast(lumimul[2])}; + float lumimulf[3] = {static_cast (lumimul[0]), static_cast (lumimul[1]), static_cast (lumimul[2])}; // calculate histogram of the y channel needed for contrast curve calculation in exposure adjustments histogram.clear(); - if(multiThread) { + if (multiThread) { #ifdef _OPENMP - const int numThreads = min(max(W * H / (int)histogram.getSize(), 1), omp_get_max_threads()); + const int numThreads = min (max (W * H / (int)histogram.getSize(), 1), omp_get_max_threads()); #pragma omp parallel num_threads(numThreads) if(numThreads>1) #endif { - LUTu hist(histogram.getSize()); + LUTu hist (histogram.getSize()); hist.clear(); #ifdef _OPENMP #pragma omp for nowait @@ -166,9 +174,9 @@ void ImProcFunctions::firstAnalysis (const Imagefloat* const original, const Pro for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) { - float r = original->r(i, j); - float g = original->g(i, j); - float b = original->b(i, j); + float r = original->r (i, j); + float g = original->g (i, j); + float b = original->b (i, j); int y = (lumimulf[0] * r + lumimulf[1] * g + lumimulf[2] * b); hist[y]++; @@ -182,15 +190,15 @@ void ImProcFunctions::firstAnalysis (const Imagefloat* const original, const Pro } #ifdef _OPENMP - static_cast(numThreads); // to silence cppcheck warning + static_cast (numThreads); // to silence cppcheck warning #endif } else { for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) { - float r = original->r(i, j); - float g = original->g(i, j); - float b = original->b(i, j); + float r = original->r (i, j); + float g = original->g (i, j); + float b = original->b (i, j); int y = (lumimulf[0] * r + lumimulf[1] * g + lumimulf[2] * b); histogram[y]++; @@ -204,7 +212,7 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh const ColorAppearance & customColCurve1, const ColorAppearance & customColCurve2, const ColorAppearance & customColCurve3, LUTu & histLCAM, LUTu & histCCAM, LUTf & CAMBrightCurveJ, LUTf & CAMBrightCurveQ, float &mean, int Iterates, int scale, bool execsharp, double &d, int scalecd, int rtt) { - if(params->colorappearance.enabled) { + if (params->colorappearance.enabled) { //int lastskip; //if(rtt==1) {lastskip=scalecd;} //not for Rtthumbnail @@ -217,15 +225,15 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh bool jp = false; //preparate for histograms CIECAM - if(pW != 1) { //only with improccoordinator - dLcurve(65536, 0); + if (pW != 1) { //only with improccoordinator + dLcurve (65536, 0); dLcurve.clear(); - hist16JCAM(65536, 0); + hist16JCAM (65536, 0); hist16JCAM.clear(); for (int i = 0; i < 32768; i++) { //# 32768*1.414 approximation maxi for chroma float val = (double)i / 32767.0; - dLcurve[i] = CLIPD(val); + dLcurve[i] = CLIPD (val); } } @@ -233,14 +241,14 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh LUTu hist16_CCAM; bool chropC = false; - if(pW != 1) { //only with improccoordinator - dCcurve(65536, 0); - hist16_CCAM(65536); + if (pW != 1) { //only with improccoordinator + dCcurve (65536, 0); + hist16_CCAM (65536); hist16_CCAM.clear(); for (int i = 0; i < 48000; i++) { //# 32768*1.414 approximation maxi for chroma float valc = (double)i / 47999.0; - dCcurve[i] = CLIPD(valc); + dCcurve[i] = CLIPD (valc); } } @@ -267,22 +275,22 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh ColorTemp::temp2mulxyz (params->wb.temperature, params->wb.green, params->wb.method, Xw, Zw); //compute white Xw Yw Zw : white current WB //viewing condition for surround - if(params->colorappearance.surround == "Average") { + if (params->colorappearance.surround == "Average") { f = 1.00; c = 0.69; nc = 1.00; f2 = 1.0, c2 = 0.69, nc2 = 1.0; - } else if(params->colorappearance.surround == "Dim") { + } else if (params->colorappearance.surround == "Dim") { f2 = 0.9; c2 = 0.59; nc2 = 0.9; f = 1.0, c = 0.69, nc = 1.0; - } else if(params->colorappearance.surround == "Dark") { + } else if (params->colorappearance.surround == "Dark") { f2 = 0.8; c2 = 0.525; nc2 = 0.8; f = 1.0, c = 0.69, nc = 1.0; - } else if(params->colorappearance.surround == "ExtremelyDark") { + } else if (params->colorappearance.surround == "ExtremelyDark") { f2 = 0.8; c2 = 0.41; nc2 = 0.8; @@ -290,7 +298,7 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh } //scene condition for surround - if(params->colorappearance.surrsource) { + if (params->colorappearance.surrsource) { f = 0.85; // if user => source image has surround very dark c = 0.55; nc = 0.85; @@ -299,12 +307,12 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh //with which algorithme if (params->colorappearance.algo == "JC") { alg = 0; - } else if(params->colorappearance.algo == "JS") { + } else if (params->colorappearance.algo == "JS") { alg = 1; - } else if(params->colorappearance.algo == "QM") { + } else if (params->colorappearance.algo == "QM") { alg = 2; algepd = true; - } else if(params->colorappearance.algo == "ALL") { + } else if (params->colorappearance.algo == "ALL") { alg = 3; algepd = true; } @@ -313,35 +321,35 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh bool needQ = (alg == 2 || alg == 3); //settings white point of output device - or illuminant viewing - if(settings->viewingdevice == 0) { + if (settings->viewingdevice == 0) { xwd = 96.42; //5000K ywd = 100.0; zwd = 82.52; - } else if(settings->viewingdevice == 1) { + } else if (settings->viewingdevice == 1) { xwd = 95.68; //5500 ywd = 100.0; zwd = 92.15; - } else if(settings->viewingdevice == 2) { + } else if (settings->viewingdevice == 2) { xwd = 95.24; //6000 ywd = 100.0; zwd = 100.81; - } else if(settings->viewingdevice == 3) { + } else if (settings->viewingdevice == 3) { xwd = 95.04; //6500 ywd = 100.0; zwd = 108.88; - } else if(settings->viewingdevice == 4) { + } else if (settings->viewingdevice == 4) { xwd = 109.85; //tungsten ywd = 100.0; zwd = 35.58; - } else if(settings->viewingdevice == 5) { + } else if (settings->viewingdevice == 5) { xwd = 99.18; //fluo F2 ywd = 100.0; zwd = 67.39; - } else if(settings->viewingdevice == 6) { + } else if (settings->viewingdevice == 6) { xwd = 95.04; //fluo F7 ywd = 100.0; zwd = 108.75; - } else if(settings->viewingdevice == 7) { + } else if (settings->viewingdevice == 7) { xwd = 100.96; //fluo F11 ywd = 100.0; zwd = 64.35; @@ -349,32 +357,32 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh //settings mean Luminance Y of output device or viewing - if(settings->viewingdevicegrey == 0) { + if (settings->viewingdevicegrey == 0) { yb2 = 5.0; - } else if(settings->viewingdevicegrey == 1) { + } else if (settings->viewingdevicegrey == 1) { yb2 = 10.0; - } else if(settings->viewingdevicegrey == 2) { + } else if (settings->viewingdevicegrey == 2) { yb2 = 15.0; - } else if(settings->viewingdevicegrey == 3) { + } else if (settings->viewingdevicegrey == 3) { yb2 = 18.0; - } else if(settings->viewingdevicegrey == 4) { + } else if (settings->viewingdevicegrey == 4) { yb2 = 23.0; - } else if(settings->viewingdevicegrey == 5) { + } else if (settings->viewingdevicegrey == 5) { yb2 = 30.0; - } else if(settings->viewingdevicegrey == 6) { + } else if (settings->viewingdevicegrey == 6) { yb2 = 40.0; } //La and la2 = ambiant luminosity scene and viewing - la = double(params->colorappearance.adapscen); + la = double (params->colorappearance.adapscen); - if(pwb == 2) { - if(params->colorappearance.autoadapscen) { + if (pwb == 2) { + if (params->colorappearance.autoadapscen) { la = adap; } } - la2 = double(params->colorappearance.adaplum); + la2 = double (params->colorappearance.adaplum); // level of adaptation double deg = (params->colorappearance.degree) / 100.0; @@ -391,20 +399,20 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh float hue = params->colorappearance.colorh; double rstprotection = 100. - params->colorappearance.rstprotection; - if(schr > 0.0) { + if (schr > 0.0) { schr = schr / 2.0f; //divide sensibility for saturation } // extracting datas from 'params' to avoid cache flush (to be confirmed) ColorAppearanceParams::eTCModeId curveMode = params->colorappearance.curveMode; ColorAppearanceParams::eTCModeId curveMode2 = params->colorappearance.curveMode2; - bool hasColCurve1 = bool(customColCurve1); - bool hasColCurve2 = bool(customColCurve2); + bool hasColCurve1 = bool (customColCurve1); + bool hasColCurve2 = bool (customColCurve2); ColorAppearanceParams::eCTCModeId curveMode3 = params->colorappearance.curveMode3; - bool hasColCurve3 = bool(customColCurve3); + bool hasColCurve3 = bool (customColCurve3); - if(CAMBrightCurveJ.dirty || CAMBrightCurveQ.dirty) { + if (CAMBrightCurveJ.dirty || CAMBrightCurveQ.dirty) { LUTu hist16J; LUTu hist16Q; @@ -428,34 +436,34 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh if (currL > 95.) { koef = 1.f; - } else if(currL > 85.) { + } else if (currL > 85.) { koef = 0.97f; - } else if(currL > 80.) { + } else if (currL > 80.) { koef = 0.93f; - } else if(currL > 70.) { + } else if (currL > 70.) { koef = 0.87f; - } else if(currL > 60.) { + } else if (currL > 60.) { koef = 0.85f; - } else if(currL > 50.) { + } else if (currL > 50.) { koef = 0.8f; - } else if(currL > 40.) { + } else if (currL > 40.) { koef = 0.75f; - } else if(currL > 30.) { + } else if (currL > 30.) { koef = 0.7f; - } else if(currL > 20.) { + } else if (currL > 20.) { koef = 0.7f; - } else if(currL > 10.) { + } else if (currL > 10.) { koef = 0.9f; - } else if(currL > 0.) { + } else if (currL > 0.) { koef = 1.0f; } if (needJ) { - hist16J[CLIP((int)((koef * lab->L[i][j])))]++; //evaluate histogram luminance L # J + hist16J[CLIP ((int) ((koef * lab->L[i][j])))]++; //evaluate histogram luminance L # J } if (needQ) { - hist16Q[CLIP((int) (32768.f * sqrt((koef * (lab->L[i][j])) / 32768.f)))]++; //for brightness Q : approximation for Q=wh*sqrt(J/100) J not equal L + hist16Q[CLIP ((int) (32768.f * sqrt ((koef * (lab->L[i][j])) / 32768.f)))]++; //for brightness Q : approximation for Q=wh*sqrt(J/100) J not equal L } sum += koef * lab->L[i][j]; //evaluate mean J to calcualte Yb @@ -467,7 +475,7 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh //evaluate lightness, contrast if (needJ) { if (!CAMBrightCurveJ) { - CAMBrightCurveJ(65536, 0); + CAMBrightCurveJ (65536, 0); CAMBrightCurveJ.dirty = false; } @@ -476,7 +484,7 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh if (needQ) { if (!CAMBrightCurveQ) { - CAMBrightCurveQ(65536, 0); + CAMBrightCurveQ (65536, 0); CAMBrightCurveQ.dirty = false; } @@ -484,40 +492,40 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh } } - if(settings->viewinggreySc == 0) { //auto + if (settings->viewinggreySc == 0) { //auto if (mean < 15.f) { yb = 3.0; - } else if(mean < 30.f) { + } else if (mean < 30.f) { yb = 5.0; - } else if(mean < 40.f) { + } else if (mean < 40.f) { yb = 10.0; - } else if(mean < 45.f) { + } else if (mean < 45.f) { yb = 15.0; - } else if(mean < 50.f) { + } else if (mean < 50.f) { yb = 18.0; - } else if(mean < 55.f) { + } else if (mean < 55.f) { yb = 23.0; - } else if(mean < 60.f) { + } else if (mean < 60.f) { yb = 30.0; - } else if(mean < 70.f) { + } else if (mean < 70.f) { yb = 40.0; - } else if(mean < 80.f) { + } else if (mean < 80.f) { yb = 60.0; - } else if(mean < 90.f) { + } else if (mean < 90.f) { yb = 80.0; } else { yb = 90.0; } } - if(settings->viewinggreySc == 1) { + if (settings->viewinggreySc == 1) { yb = 18.0; } int gamu = 0; bool highlight = params->toneCurve.hrenabled; //Get the value if "highlight reconstruction" is activated - if(params->colorappearance.gamut) { + if (params->colorappearance.gamut) { gamu = 1; //enabled gamut control } @@ -527,14 +535,14 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh double xw1, yw1, zw1, xw2, yw2, zw2; // settings of WB: scene and viewing - if(params->colorappearance.wbmodel == "RawT") { + if (params->colorappearance.wbmodel == "RawT") { xw1 = 96.46; //use RT WB; CAT 02 is used for output device (see prefreneces) yw1 = 100.0; zw1 = 82.445; xw2 = xwd; yw2 = ywd; zw2 = zwd; - } else /*if(params->colorappearance.wbmodel == "RawTCAT02")*/ { + } else { /*if(params->colorappearance.wbmodel == "RawTCAT02")*/ xw1 = xw; // Settings RT WB are used for CAT02 => mix , CAT02 is use for output device (screen: D50 D65, projector: lamp, LED) see preferences yw1 = yw; zw1 = zw; @@ -544,9 +552,9 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh } double cz, wh, pfl; - Ciecam02::initcam1(gamu, yb, pilot, f, la, xw, yw, zw, n, d, nbb, ncb, cz, aw, wh, pfl, fl, c); + Ciecam02::initcam1 (gamu, yb, pilot, f, la, xw, yw, zw, n, d, nbb, ncb, cz, aw, wh, pfl, fl, c); double nj, dj, nbbj, ncbj, czj, awj, flj; - Ciecam02::initcam2(gamu, yb2, f2, la2, xw2, yw2, zw2, nj, dj, nbbj, ncbj, czj, awj, flj); + Ciecam02::initcam2 (gamu, yb2, f2, la2, xw2, yw2, zw2, nj, dj, nbbj, ncbj, czj, awj, flj); @@ -579,7 +587,7 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh double x, y, z; double epsil = 0.0001; //convert Lab => XYZ - Color::Lab2XYZ(L, a, b, x1, y1, z1); + Color::Lab2XYZ (L, a, b, x1, y1, z1); // double J, C, h, Q, M, s, aw, fl, wh; double J, C, h, Q, M, s; @@ -594,12 +602,12 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh y = (double)y1 / 655.35; z = (double)z1 / 655.35; //process source==> normal - Ciecam02::xyz2jchqms_ciecam02( J, C, h, - Q, M, s, aw, fl, wh, - x, y, z, - xw1, yw1, zw1, - yb, la, - f, c, nc, pilot, gamu , n, nbb, ncb, pfl, cz, d ); + Ciecam02::xyz2jchqms_ciecam02 ( J, C, h, + Q, M, s, aw, fl, wh, + x, y, z, + xw1, yw1, zw1, + yb, la, + f, c, nc, pilot, gamu , n, nbb, ncb, pfl, cz, d ); Jpro = J; Cpro = C; hpro = h; @@ -612,60 +620,60 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh f_l = fl; // we cannot have all algoritms with all chroma curves - if(alg == 1) { + if (alg == 1) { // Lightness saturation - if(Jpro > 99.9f) { + if (Jpro > 99.9f) { Jpro = 99.9f; } - Jpro = (CAMBrightCurveJ[(float)(Jpro * 327.68)]) / 327.68; //ligthness CIECAM02 + contrast + Jpro = (CAMBrightCurveJ[ (float) (Jpro * 327.68)]) / 327.68; //ligthness CIECAM02 + contrast double sres; double Sp = spro / 100.0; double parsat = 1.5; //parsat=1.5 =>saturation ; 1.8 => chroma ; 2.5 => colorfullness (personal evaluation) - if(schr == -100.0) { + if (schr == -100.0) { schr = -99.8; } - Ciecam02::curvecolor(schr, Sp , sres, parsat); - double coe = pow(fl, 0.25); + Ciecam02::curvecolor (schr, Sp , sres, parsat); + double coe = pow (fl, 0.25); float dred = 100.f; // in C mode float protect_red = 80.0f; // in C mode - dred = 100.0 * sqrt((dred * coe) / Qpro); - protect_red = 100.0 * sqrt((protect_red * coe) / Qpro); + dred = 100.0 * sqrt ((dred * coe) / Qpro); + protect_red = 100.0 * sqrt ((protect_red * coe) / Qpro); int sk = 0; float ko = 100.f; - Color::skinred(Jpro, hpro, sres, Sp, dred, protect_red, sk, rstprotection, ko, spro); - Qpro = ( 4.0 / c ) * sqrt( Jpro / 100.0 ) * ( aw + 4.0 ) ; + Color::skinred (Jpro, hpro, sres, Sp, dred, protect_red, sk, rstprotection, ko, spro); + Qpro = ( 4.0 / c ) * sqrt ( Jpro / 100.0 ) * ( aw + 4.0 ) ; Cpro = (spro * spro * Qpro) / (10000.0); - } else if(alg == 3 || alg == 0 || alg == 2) { + } else if (alg == 3 || alg == 0 || alg == 2) { double coef = 32760. / wh; - if(alg == 3 || alg == 2) { - if(Qpro * coef > 32767.0f) { - Qpro = (CAMBrightCurveQ[(float)32767.0f]) / coef; //brightness and contrast + if (alg == 3 || alg == 2) { + if (Qpro * coef > 32767.0f) { + Qpro = (CAMBrightCurveQ[ (float)32767.0f]) / coef; //brightness and contrast } else { - Qpro = (CAMBrightCurveQ[(float)(Qpro * coef)]) / coef; //brightness and contrast + Qpro = (CAMBrightCurveQ[ (float) (Qpro * coef)]) / coef; //brightness and contrast } } double Mp, sres; - double coe = pow(fl, 0.25); + double coe = pow (fl, 0.25); Mp = Mpro / 100.0; double parsat = 2.5; - if(mchr == -100.0) { + if (mchr == -100.0) { mchr = -99.8 ; } - if(mchr == 100.0) { + if (mchr == 100.0) { mchr = 99.9; } - if(alg == 3 || alg == 2) { - Ciecam02::curvecolor(mchr, Mp , sres, parsat); + if (alg == 3 || alg == 2) { + Ciecam02::curvecolor (mchr, Mp , sres, parsat); } else { - Ciecam02::curvecolor(0.0, Mp , sres, parsat); //colorfullness + Ciecam02::curvecolor (0.0, Mp , sres, parsat); //colorfullness } float dred = 100.f; //in C mode @@ -674,77 +682,77 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh protect_red *= coe; //M mode int sk = 0; float ko = 100.f; - Color::skinred(Jpro, hpro, sres, Mp, dred, protect_red, sk, rstprotection, ko, Mpro); + Color::skinred (Jpro, hpro, sres, Mp, dred, protect_red, sk, rstprotection, ko, Mpro); Jpro = (100.0 * Qpro * Qpro) / (wh * wh); Cpro = Mpro / coe; - spro = 100.0 * sqrt( Mpro / Qpro ); + spro = 100.0 * sqrt ( Mpro / Qpro ); - if(alg != 2) { - if(Jpro > 99.9f) { + if (alg != 2) { + if (Jpro > 99.9f) { Jpro = 99.9f; } - Jpro = (CAMBrightCurveJ[(float)(Jpro * 327.68f)]) / 327.68f; //ligthness CIECAM02 + contrast + Jpro = (CAMBrightCurveJ[ (float) (Jpro * 327.68f)]) / 327.68f; //ligthness CIECAM02 + contrast } double Cp; double Sp = spro / 100.0; parsat = 1.5; - if(schr == -100.0) { + if (schr == -100.0) { schr = -99.; } - if(schr == 100.0) { + if (schr == 100.0) { schr = 98.; } - if(alg == 3) { - Ciecam02::curvecolor(schr, Sp , sres, parsat); + if (alg == 3) { + Ciecam02::curvecolor (schr, Sp , sres, parsat); } else { - Ciecam02::curvecolor(0.0, Sp , sres, parsat); //saturation + Ciecam02::curvecolor (0.0, Sp , sres, parsat); //saturation } dred = 100.f; // in C mode protect_red = 80.0f; // in C mode - dred = 100.0 * sqrt((dred * coe) / Q); - protect_red = 100.0 * sqrt((protect_red * coe) / Q); + dred = 100.0 * sqrt ((dred * coe) / Q); + protect_red = 100.0 * sqrt ((protect_red * coe) / Q); sk = 0; - Color::skinred(Jpro, hpro, sres, Sp, dred, protect_red, sk, rstprotection, ko, spro); + Color::skinred (Jpro, hpro, sres, Sp, dred, protect_red, sk, rstprotection, ko, spro); //double Q1; - Qpro = ( 4.0 / c ) * sqrt( Jpro / 100.0 ) * ( aw + 4.0 ) ; + Qpro = ( 4.0 / c ) * sqrt ( Jpro / 100.0 ) * ( aw + 4.0 ) ; Cpro = (spro * spro * Qpro) / (10000.0); Cp = Cpro / 100.0; parsat = 1.8; //parsat=1.5 =>saturation ; 1.8 => chroma ; 2.5 => colorfullness (personal evaluation : for not) - if(chr == -100.0) { + if (chr == -100.0) { chr = -99.8; } - if(alg != 2) { - Ciecam02::curvecolor(chr, Cp , sres, parsat); + if (alg != 2) { + Ciecam02::curvecolor (chr, Cp , sres, parsat); } else { - Ciecam02::curvecolor(0.0, Cp , sres, parsat); //chroma + Ciecam02::curvecolor (0.0, Cp , sres, parsat); //chroma } dred = 55.f; protect_red = 30.0f; sk = 1; - Color::skinred(Jpro, hpro, sres, Cp, dred, protect_red, sk, rstprotection, ko, Cpro); + Color::skinred (Jpro, hpro, sres, Cp, dred, protect_red, sk, rstprotection, ko, Cpro); - if(Jpro < 1. && Cpro > 12.) { + if (Jpro < 1. && Cpro > 12.) { Cpro = 12.; //reduce artifacts by "pseudo gamut control CIECAM" - } else if(Jpro < 2. && Cpro > 15.) { + } else if (Jpro < 2. && Cpro > 15.) { Cpro = 15.; - } else if(Jpro < 4. && Cpro > 30.) { + } else if (Jpro < 4. && Cpro > 30.) { Cpro = 30.; - } else if(Jpro < 7. && Cpro > 50.) { + } else if (Jpro < 7. && Cpro > 50.) { Cpro = 50.; } hpro = hpro + hue; - if( hpro < 0.0 ) { + if ( hpro < 0.0 ) { hpro += 360.0; //hue } } @@ -762,28 +770,28 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh float Jold100 = (float) Jpro; float redu = 25.f; float reduc = 1.f; - const Lightcurve& userColCurveJ1 = static_cast(customColCurve1); - userColCurveJ1.Apply(Jj); + const Lightcurve& userColCurveJ1 = static_cast (customColCurve1); + userColCurveJ1.Apply (Jj); - if(Jj > Jold) { - if(Jj < 65535.f) { - if(Jold < 327.68f * redu) { + if (Jj > Jold) { + if (Jj < 65535.f) { + if (Jold < 327.68f * redu) { Jj = 0.3f * (Jj - Jold) + Jold; //divide sensibility } else { - reduc = LIM((100.f - Jold100) / (100.f - redu), 0.f, 1.f); + reduc = LIM ((100.f - Jold100) / (100.f - redu), 0.f, 1.f); Jj = 0.3f * reduc * (Jj - Jold) + Jold; //reduct sensibility in highlights } } - } else if(Jj > 10.f) { + } else if (Jj > 10.f) { Jj = 0.8f * (Jj - Jold) + Jold; } else if (Jj >= 0.f) { Jj = 0.90f * (Jj - Jold) + Jold; // not zero ==>artifacts } - Jpro = (double)(Jj / 327.68f); + Jpro = (double) (Jj / 327.68f); - if(Jpro < 1.) { + if (Jpro < 1.) { Jpro = 1.; } @@ -798,29 +806,29 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh float redu = 20.f; float reduc = 1.f; - const Brightcurve& userColCurveB1 = static_cast(customColCurve1); - userColCurveB1.Apply(Qq); + const Brightcurve& userColCurveB1 = static_cast (customColCurve1); + userColCurveB1.Apply (Qq); - if(Qq > Qold) { - if(Qq < 65535.f) { - if(Qold < 327.68f * redu) { + if (Qq > Qold) { + if (Qq < 65535.f) { + if (Qold < 327.68f * redu) { Qq = 0.25f * (Qq - Qold) + Qold; //divide sensibility } else { - reduc = LIM((100.f - Qold100) / (100.f - redu), 0.f, 1.f); + reduc = LIM ((100.f - Qold100) / (100.f - redu), 0.f, 1.f); Qq = 0.25f * reduc * (Qq - Qold) + Qold; //reduct sensibility in highlights } } - } else if(Qq > 10.f) { + } else if (Qq > 10.f) { Qq = 0.5f * (Qq - Qold) + Qold; } else if (Qq >= 0.f) { Qq = 0.7f * (Qq - Qold) + Qold; // not zero ==>artifacts } - Qpro = (double)(Qq * (coef) / 327.68f); - Jpro = 100.*(Qpro * Qpro) / ((4.0 / c) * (4.0 / c) * (aw + 4.0) * (aw + 4.0)); + Qpro = (double) (Qq * (coef) / 327.68f); + Jpro = 100.* (Qpro * Qpro) / ((4.0 / c) * (4.0 / c) * (aw + 4.0) * (aw + 4.0)); t1B = true; - if(Jpro < 1.) { + if (Jpro < 1.) { Jpro = 1.; } @@ -839,35 +847,35 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh float Jold100 = (float) Jpro; float redu = 25.f; float reduc = 1.f; - const Lightcurve& userColCurveJ2 = static_cast(customColCurve2); - userColCurveJ2.Apply(Jj); + const Lightcurve& userColCurveJ2 = static_cast (customColCurve2); + userColCurveJ2.Apply (Jj); - if(Jj > Jold) { - if(Jj < 65535.f) { - if(Jold < 327.68f * redu) { + if (Jj > Jold) { + if (Jj < 65535.f) { + if (Jold < 327.68f * redu) { Jj = 0.3f * (Jj - Jold) + Jold; //divide sensibility } else { - reduc = LIM((100.f - Jold100) / (100.f - redu), 0.f, 1.f); + reduc = LIM ((100.f - Jold100) / (100.f - redu), 0.f, 1.f); Jj = 0.3f * reduc * (Jj - Jold) + Jold; //reduct sensibility in highlights } } - } else if(Jj > 10.f) { - if(!t1L) { + } else if (Jj > 10.f) { + if (!t1L) { Jj = 0.8f * (Jj - Jold) + Jold; } else { Jj = 0.4f * (Jj - Jold) + Jold; } } else if (Jj >= 0.f) { - if(!t1L) { + if (!t1L) { Jj = 0.90f * (Jj - Jold) + Jold; // not zero ==>artifacts } else { Jj = 0.5f * (Jj - Jold) + Jold; } } - Jpro = (double)(Jj / 327.68f); + Jpro = (double) (Jj / 327.68f); - if(Jpro < 1.) { + if (Jpro < 1.) { Jpro = 1.; } @@ -880,40 +888,40 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh float redu = 20.f; float reduc = 1.f; - const Brightcurve& userColCurveB2 = static_cast(customColCurve2); - userColCurveB2.Apply(Qq); + const Brightcurve& userColCurveB2 = static_cast (customColCurve2); + userColCurveB2.Apply (Qq); - if(Qq > Qold) { - if(Qq < 65535.f) { - if(Qold < 327.68f * redu) { + if (Qq > Qold) { + if (Qq < 65535.f) { + if (Qold < 327.68f * redu) { Qq = 0.25f * (Qq - Qold) + Qold; //divide sensibility } else { - reduc = LIM((100.f - Qold100) / (100.f - redu), 0.f, 1.f); + reduc = LIM ((100.f - Qold100) / (100.f - redu), 0.f, 1.f); Qq = 0.25f * reduc * (Qq - Qold) + Qold; //reduct sensibility in highlights } } - } else if(Qq > 10.f) { + } else if (Qq > 10.f) { Qq = 0.5f * (Qq - Qold) + Qold; } else if (Qq >= 0.f) { Qq = 0.7f * (Qq - Qold) + Qold; // not zero ==>artifacts } - Qpro = (double)(Qq * (coef) / 327.68f); - Jpro = 100.*(Qpro * Qpro) / ((4.0 / c) * (4.0 / c) * (aw + 4.0) * (aw + 4.0)); + Qpro = (double) (Qq * (coef) / 327.68f); + Jpro = 100.* (Qpro * Qpro) / ((4.0 / c) * (4.0 / c) * (aw + 4.0) * (aw + 4.0)); t2B = true; - if(t1L) { //to workaround the problem if we modify curve1-lightnees after curve2 brightness(the cat that bites its own tail!) in fact it's another type of curve only for this case + if (t1L) { //to workaround the problem if we modify curve1-lightnees after curve2 brightness(the cat that bites its own tail!) in fact it's another type of curve only for this case coef = 2.f; //adapt Q to J approximation Qq = (float) Qpro * coef; Qold = Qq; - const Lightcurve& userColCurveJ1 = static_cast(customColCurve1); - userColCurveJ1.Apply(Qq); + const Lightcurve& userColCurveJ1 = static_cast (customColCurve1); + userColCurveJ1.Apply (Qq); Qq = 0.1f * (Qq - Qold) + Qold; //approximative adaptation - Qpro = (double)(Qq / coef); - Jpro = 100.*(Qpro * Qpro) / ((4.0 / c) * (4.0 / c) * (aw + 4.0) * (aw + 4.0)); + Qpro = (double) (Qq / coef); + Jpro = 100.* (Qpro * Qpro) / ((4.0 / c) * (4.0 / c) * (aw + 4.0) * (aw + 4.0)); } - if(Jpro < 1.) { + if (Jpro < 1.) { Jpro = 1.; } } @@ -925,21 +933,21 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh double coef = 327.68 / parsat; float Cc = (float) Cpro * coef; float Ccold = Cc; - const Chromacurve& userColCurve = static_cast(customColCurve3); - userColCurve.Apply(Cc); + const Chromacurve& userColCurve = static_cast (customColCurve3); + userColCurve.Apply (Cc); float dred = 55.f; float protect_red = 30.0f; float sk = 1; float ko = 1.f / coef; - Color::skinred(Jpro, hpro, Cc, Ccold, dred, protect_red, sk, rstprotection, ko, Cpro); + Color::skinred (Jpro, hpro, Cc, Ccold, dred, protect_red, sk, rstprotection, ko, Cpro); - if(Jpro < 1. && Cpro > 12.) { + if (Jpro < 1. && Cpro > 12.) { Cpro = 12.; //reduce artifacts by "pseudo gamut control CIECAM" - } else if(Jpro < 2. && Cpro > 15.) { + } else if (Jpro < 2. && Cpro > 15.) { Cpro = 15.; - } else if(Jpro < 4. && Cpro > 30.) { + } else if (Jpro < 4. && Cpro > 30.) { Cpro = 30.; - } else if(Jpro < 7. && Cpro > 50.) { + } else if (Jpro < 7. && Cpro > 50.) { Cpro = 50.; } @@ -949,18 +957,18 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh double coef = 327.68 / parsat; float Ss = (float) spro * coef; float Sold = Ss; - const Saturcurve& userColCurve = static_cast(customColCurve3); - userColCurve.Apply(Ss); + const Saturcurve& userColCurve = static_cast (customColCurve3); + userColCurve.Apply (Ss); Ss = 0.6f * (Ss - Sold) + Sold; //divide sensibility saturation - double coe = pow(fl, 0.25); + double coe = pow (fl, 0.25); float dred = 100.f; // in C mode float protect_red = 80.0f; // in C mode - dred = 100.0 * sqrt((dred * coe) / Qpro); - protect_red = 100.0 * sqrt((protect_red * coe) / Qpro); + dred = 100.0 * sqrt ((dred * coe) / Qpro); + protect_red = 100.0 * sqrt ((protect_red * coe) / Qpro); int sk = 0; float ko = 1.f / coef; - Color::skinred(Jpro, hpro, Ss, Sold, dred, protect_red, sk, rstprotection, ko, spro); - Qpro = ( 4.0 / c ) * sqrt( Jpro / 100.0 ) * ( aw + 4.0 ) ; + Color::skinred (Jpro, hpro, Ss, Sold, dred, protect_red, sk, rstprotection, ko, spro); + Qpro = ( 4.0 / c ) * sqrt ( Jpro / 100.0 ) * ( aw + 4.0 ) ; Cpro = (spro * spro * Qpro) / (10000.0); c1s = 1; @@ -969,25 +977,25 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh double coef = 327.68 / parsat; float Mm = (float) Mpro * coef; float Mold = Mm; - const Colorfcurve& userColCurve = static_cast(customColCurve3); - userColCurve.Apply(Mm); - double coe = pow(fl, 0.25); + const Colorfcurve& userColCurve = static_cast (customColCurve3); + userColCurve.Apply (Mm); + double coe = pow (fl, 0.25); float dred = 100.f; //in C mode float protect_red = 80.0f; // in C mode dred *= coe; //in M mode protect_red *= coe; int sk = 0; float ko = 1.f / coef; - Color::skinred(Jpro, hpro, Mm, Mold, dred, protect_red, sk, rstprotection, ko, Mpro); + Color::skinred (Jpro, hpro, Mm, Mold, dred, protect_red, sk, rstprotection, ko, Mpro); Cpro = Mpro / coe; - if(Jpro < 1. && Mpro > 12.*coe) { + if (Jpro < 1. && Mpro > 12.*coe) { Mpro = 12.*coe; //reduce artifacts by "pseudo gamut control CIECAM" - } else if(Jpro < 2. && Mpro > 15.*coe) { + } else if (Jpro < 2. && Mpro > 15.*coe) { Mpro = 15.*coe; - } else if(Jpro < 4. && Mpro > 30.*coe) { + } else if (Jpro < 4. && Mpro > 30.*coe) { Mpro = 30.*coe; - } else if(Jpro < 7. && Mpro > 50.*coe) { + } else if (Jpro < 7. && Mpro > 50.*coe) { Mpro = 50.*coe; } @@ -997,17 +1005,17 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh } //to retrieve the correct values of variables - if(t2B && t1B) { + if (t2B && t1B) { Jpro = (100.0 * Qpro * Qpro) / (wh * wh); // for brightness curve } - if(c1s == 1) { - Qpro = ( 4.0 / c ) * sqrt( Jpro / 100.0 ) * ( aw + 4.0 ) ; //for saturation curve + if (c1s == 1) { + Qpro = ( 4.0 / c ) * sqrt ( Jpro / 100.0 ) * ( aw + 4.0 ) ; //for saturation curve Cpro = (spro * spro * Qpro) / (10000.0); } - if(c1co == 1) { - double coe = pow(fl, 0.25); // for colorfullness curve + if (c1co == 1) { + double coe = pow (fl, 0.25); // for colorfullness curve Cpro = Mpro / coe; } @@ -1019,7 +1027,7 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh h = hpro; s = spro; - if(params->colorappearance.tonecie || settings->autocielab) { //use pointer for tonemapping with CIECAM and also sharpening , defringe, contrast detail + if (params->colorappearance.tonecie || settings->autocielab) { //use pointer for tonemapping with CIECAM and also sharpening , defringe, contrast detail // if(params->colorappearance.tonecie || params->colorappearance.sharpcie){//use pointer for tonemapping with CIECAM and also sharpening , defringe, contrast detail float Qred = ( 4.0 / c) * ( aw + 4.0 ); //estimate Q max if J=100.0 ncie->Q_p[i][j] = (float)Q + epsil; //epsil to avoid Q=0 @@ -1028,19 +1036,19 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh ncie->h_p[i][j] = (float)h; ncie->C_p[i][j] = (float)C + epsil; // ncie->s_p[i][j]=(float)s; - ncie->sh_p[i][j] = (float) 32768.*(( 4.0 / c ) * sqrt( J / 100.0 ) * ( aw + 4.0 )) / Qred ; + ncie->sh_p[i][j] = (float) 32768.* (( 4.0 / c ) * sqrt ( J / 100.0 ) * ( aw + 4.0 )) / Qred ; // ncie->ch_p[i][j]=(float) 327.68*C; - if(ncie->Q_p[i][j] < minQ) { + if (ncie->Q_p[i][j] < minQ) { minQ = ncie->Q_p[i][j]; //minima } - if(ncie->Q_p[i][j] > maxQ) { + if (ncie->Q_p[i][j] > maxQ) { maxQ = ncie->Q_p[i][j]; //maxima } } - if(!params->colorappearance.tonecie || !settings->autocielab || !params->epd.enabled ) { + if (!params->colorappearance.tonecie || !settings->autocielab || !params->epd.enabled ) { // if(!params->epd.enabled || !params->colorappearance.tonecie || !settings->autocielab){ // if(!params->epd.enabled || !params->colorappearance.tonecie || !params->colorappearance.sharpcie){ @@ -1049,10 +1057,10 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh int libr = 0; int colch = 0; - if(curveMode == ColorAppearanceParams::TC_MODE_BRIGHT) { + if (curveMode == ColorAppearanceParams::TC_MODE_BRIGHT) { brli = 70.0; libr = 1; - } else if(curveMode == ColorAppearanceParams::TC_MODE_LIGHT) { + } else if (curveMode == ColorAppearanceParams::TC_MODE_LIGHT) { brli = 327.; libr = 0; } @@ -1060,25 +1068,26 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh if (curveMode3 == ColorAppearanceParams::TC_MODE_CHROMA) { chsacol = 327.; colch = 0; - } else if(curveMode3 == ColorAppearanceParams::TC_MODE_SATUR) { + } else if (curveMode3 == ColorAppearanceParams::TC_MODE_SATUR) { chsacol = 450.0; colch = 1; - } else if(curveMode3 == ColorAppearanceParams::TC_MODE_COLORF) { + } else if (curveMode3 == ColorAppearanceParams::TC_MODE_COLORF) { chsacol = 327.0; colch = 2; } - if(ciedata) { + if (ciedata) { // Data for J Q M s and C histograms //update histogram jp = true; - if(pW != 1) { //only with improccoordinator + if (pW != 1) { //only with improccoordinator int posl; - if(libr == 1) { - posl = CLIP((int)(Q * brli)); //40.0 to 100.0 approximative factor for Q - 327 for J - } else /*if(libr == 0)*/ { - posl = CLIP((int)(J * brli)); //327 for J + + if (libr == 1) { + posl = CLIP ((int) (Q * brli)); //40.0 to 100.0 approximative factor for Q - 327 for J + } else { /*if(libr == 0)*/ + posl = CLIP ((int) (J * brli)); //327 for J } hist16JCAM[posl]++; @@ -1086,14 +1095,15 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh chropC = true; - if(pW != 1) { //only with improccoordinator + if (pW != 1) { //only with improccoordinator int posc; - if(colch == 0) { - posc = CLIP((int)(C * chsacol)); //450.0 approximative factor for s 320 for M - } else if(colch == 1) { - posc = CLIP((int)(s * chsacol)); - } else /*if(colch == 2)*/ { - posc = CLIP((int)(M * chsacol)); + + if (colch == 0) { + posc = CLIP ((int) (C * chsacol)); //450.0 approximative factor for s 320 for M + } else if (colch == 1) { + posc = CLIP ((int) (s * chsacol)); + } else { /*if(colch == 2)*/ + posc = CLIP ((int) (M * chsacol)); } hist16_CCAM[posc]++; @@ -1103,42 +1113,42 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh double xx, yy, zz; //double nj, nbbj, ncbj, flj, czj, dj, awj; //process normal==> viewing - Ciecam02::jch2xyz_ciecam02( xx, yy, zz, - J, C, h, - xw2, yw2, zw2, - yb2, la2, - f2, c2, nc2, gamu, nj, nbbj, ncbj, flj, czj, dj, awj); + Ciecam02::jch2xyz_ciecam02 ( xx, yy, zz, + J, C, h, + xw2, yw2, zw2, + yb2, la2, + f2, c2, nc2, gamu, nj, nbbj, ncbj, flj, czj, dj, awj); x = (float)xx * 655.35; y = (float)yy * 655.35; z = (float)zz * 655.35; float Ll, aa, bb; //convert xyz=>lab - Color::XYZ2Lab(x, y, z, Ll, aa, bb); + Color::XYZ2Lab (x, y, z, Ll, aa, bb); lab->L[i][j] = Ll; lab->a[i][j] = aa; lab->b[i][j] = bb; // gamut control in Lab mode; I must study how to do with cIECAM only - if(gamu == 1) { + if (gamu == 1) { float R, G, B; float HH, Lprov1, Chprov1; Lprov1 = lab->L[i][j] / 327.68f; - Chprov1 = sqrt(SQR(lab->a[i][j] / 327.68f) + SQR(lab->b[i][j] / 327.68f)); - HH = atan2(lab->b[i][j], lab->a[i][j]); + Chprov1 = sqrt (SQR (lab->a[i][j] / 327.68f) + SQR (lab->b[i][j] / 327.68f)); + HH = atan2 (lab->b[i][j], lab->a[i][j]); #ifdef _DEBUG bool neg = false; bool more_rgb = false; //gamut control : Lab values are in gamut - Color::gamutLchonly(HH, Lprov1, Chprov1, R, G, B, wip, highlight, 0.15f, 0.96f, neg, more_rgb); + Color::gamutLchonly (HH, Lprov1, Chprov1, R, G, B, wip, highlight, 0.15f, 0.96f, neg, more_rgb); #else //gamut control : Lab values are in gamut - Color::gamutLchonly(HH, Lprov1, Chprov1, R, G, B, wip, highlight, 0.15f, 0.96f); + Color::gamutLchonly (HH, Lprov1, Chprov1, R, G, B, wip, highlight, 0.15f, 0.96f); #endif lab->L[i][j] = Lprov1 * 327.68f; - lab->a[i][j] = 327.68f * Chprov1 * cos(HH); - lab->b[i][j] = 327.68f * Chprov1 * sin(HH); + lab->a[i][j] = 327.68f * Chprov1 * cos (HH); + lab->b[i][j] = 327.68f * Chprov1 * sin (HH); } } @@ -1146,26 +1156,26 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh } // End of parallelization - if(!params->epd.enabled || !params->colorappearance.tonecie || !settings->autocielab) { //normal + if (!params->epd.enabled || !params->colorappearance.tonecie || !settings->autocielab) { //normal //if(!params->epd.enabled || !params->colorappearance.tonecie || !params->colorappearance.sharpcie){//normal - if(ciedata) { + if (ciedata) { //update histogram J - if(pW != 1) { //only with improccoordinator + if (pW != 1) { //only with improccoordinator for (int i = 0; i < 32768; i++) { // if (jp) { float hval = dLcurve[i]; - int hi = (int)(255.0 * CLIPD(hval)); // + int hi = (int) (255.0 * CLIPD (hval)); // histLCAM[hi] += hist16JCAM[i] ; } } } - if(pW != 1) { //only with improccoordinator + if (pW != 1) { //only with improccoordinator for (int i = 0; i < 48000; i++) { // if (chropC) { float hvalc = dCcurve[i]; - int hic = (int)(255.0 * CLIPD(hvalc)); // + int hic = (int) (255.0 * CLIPD (hvalc)); // histCCAM[hic] += hist16_CCAM[i] ; } } @@ -1177,35 +1187,35 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh if (settings->verbose) { t2e.set(); - printf("CIECAM02 performed in %d usec:\n", t2e.etime(t1e)); + printf ("CIECAM02 performed in %d usec:\n", t2e.etime (t1e)); // printf("minc=%f maxc=%f minj=%f maxj=%f\n",minc,maxc,minj,maxj); } #endif - if(settings->autocielab) { + if (settings->autocielab) { //if(params->colorappearance.sharpcie) { //all this treatments reduce artifacts, but can lead to slightly different results - if(params->defringe.enabled) if(execsharp) { + if (params->defringe.enabled) if (execsharp) { ImProcFunctions::defringecam (ncie); // } //if(params->dirpyrequalizer.enabled) if(execsharp) { - if(params->dirpyrequalizer.enabled) { - if(params->dirpyrequalizer.gamutlab /*&& execsharp*/) { - float b_l = static_cast(params->dirpyrequalizer.hueskin.value[0]) / 100.0f; - float t_l = static_cast(params->dirpyrequalizer.hueskin.value[1]) / 100.0f; - float b_r = static_cast(params->dirpyrequalizer.hueskin.value[2]) / 100.0f; - float t_r = static_cast(params->dirpyrequalizer.hueskin.value[3]) / 100.0f; + if (params->dirpyrequalizer.enabled) { + if (params->dirpyrequalizer.gamutlab /*&& execsharp*/) { + float b_l = static_cast (params->dirpyrequalizer.hueskin.value[0]) / 100.0f; + float t_l = static_cast (params->dirpyrequalizer.hueskin.value[1]) / 100.0f; + float b_r = static_cast (params->dirpyrequalizer.hueskin.value[2]) / 100.0f; + float t_r = static_cast (params->dirpyrequalizer.hueskin.value[3]) / 100.0f; float artifact = (float) settings->artifact_cbdl; - if(artifact > 6.f) { + if (artifact > 6.f) { artifact = 6.f; } - if(artifact < 0.f) { + if (artifact < 0.f) { artifact = 1.f; } @@ -1217,38 +1227,38 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh } } - if(params->colorappearance.badpixsl > 0) if(execsharp) { + if (params->colorappearance.badpixsl > 0) if (execsharp) { int mode = params->colorappearance.badpixsl; ImProcFunctions::badpixcam (ncie, 3.4, 5, mode, 0, 0, 0, 0, 0, 0, 1);//for bad pixels CIECAM } - if (params->sharpenMicro.enabled)if(execsharp) { - ImProcFunctions::MLmicrocontrastcam(ncie); + if (params->sharpenMicro.enabled)if (execsharp) { + ImProcFunctions::MLmicrocontrastcam (ncie); } - if(params->sharpening.enabled) - if(execsharp) { + if (params->sharpening.enabled) + if (execsharp) { float **buffer = lab->L; // We can use the L-buffer from lab as buffer to save some memory ImProcFunctions::sharpeningcam (ncie, buffer); // sharpening adapted to CIECAM } //if(params->dirpyrequalizer.enabled) if(execsharp) { - if(params->dirpyrequalizer.enabled /*&& (execsharp)*/) { + if (params->dirpyrequalizer.enabled /*&& (execsharp)*/) { // if (params->dirpyrequalizer.algo=="FI") choice=0; // else if(params->dirpyrequalizer.algo=="LA") choice=1; - if(rtt == 1) { - float b_l = static_cast(params->dirpyrequalizer.hueskin.value[0]) / 100.0f; - float t_l = static_cast(params->dirpyrequalizer.hueskin.value[1]) / 100.0f; - float b_r = static_cast(params->dirpyrequalizer.hueskin.value[2]) / 100.0f; - float t_r = static_cast(params->dirpyrequalizer.hueskin.value[3]) / 100.0f; + if (rtt == 1) { + float b_l = static_cast (params->dirpyrequalizer.hueskin.value[0]) / 100.0f; + float t_l = static_cast (params->dirpyrequalizer.hueskin.value[1]) / 100.0f; + float b_r = static_cast (params->dirpyrequalizer.hueskin.value[2]) / 100.0f; + float t_r = static_cast (params->dirpyrequalizer.hueskin.value[3]) / 100.0f; int choice = 0; //not disabled in case of ! always 0 - dirpyr_equalizercam(ncie, ncie->sh_p, ncie->sh_p, ncie->W, ncie->H, ncie->h_p, ncie->C_p, params->dirpyrequalizer.mult, params->dirpyrequalizer.threshold, params->dirpyrequalizer.skinprotect, true, params->dirpyrequalizer.gamutlab, b_l, t_l, t_r, b_r, choice, scalecd); //contrast by detail adapted to CIECAM + dirpyr_equalizercam (ncie, ncie->sh_p, ncie->sh_p, ncie->W, ncie->H, ncie->h_p, ncie->C_p, params->dirpyrequalizer.mult, params->dirpyrequalizer.threshold, params->dirpyrequalizer.skinprotect, true, params->dirpyrequalizer.gamutlab, b_l, t_l, t_r, b_r, choice, scalecd); //contrast by detail adapted to CIECAM } } float Qredi = ( 4.0 / c_) * ( a_w + 4.0 ); - float co_e = (pow(f_l, 0.25f)); + float co_e = (pow (f_l, 0.25f)); #ifndef _DEBUG #pragma omp parallel default(shared) firstprivate(height,width, Qredi,a_w,c_) @@ -1262,18 +1272,18 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh for (int j = 0; j < width; j++) { float interm = Qredi * ncie->sh_p[i][j] / (32768.f); ncie->J_p[i][j] = 100.0 * interm * interm / ((a_w + 4.) * (a_w + 4.) * (4. / c_) * (4. / c_)); - ncie->Q_p[i][j] = ( 4.0 / c_) * ( a_w + 4.0 ) * sqrt(ncie->J_p[i][j] / 100.f); + ncie->Q_p[i][j] = ( 4.0 / c_) * ( a_w + 4.0 ) * sqrt (ncie->J_p[i][j] / 100.f); ncie->M_p[i][j] = ncie->C_p[i][j] * co_e; } } } - if((params->colorappearance.tonecie || (params->colorappearance.tonecie && params->epd.enabled)) || (params->sharpening.enabled && settings->autocielab) + if ((params->colorappearance.tonecie || (params->colorappearance.tonecie && params->epd.enabled)) || (params->sharpening.enabled && settings->autocielab) || (params->dirpyrequalizer.enabled && settings->autocielab) || (params->defringe.enabled && settings->autocielab) || (params->sharpenMicro.enabled && settings->autocielab) || (params->colorappearance.badpixsl > 0 && settings->autocielab)) { - if(params->epd.enabled && params->colorappearance.tonecie && algepd) { - ImProcFunctions::EPDToneMapCIE(ncie, a_w, c_, w_h, width, height, begh, endh, minQ, maxQ, Iterates, scale ); + if (params->epd.enabled && params->colorappearance.tonecie && algepd) { + ImProcFunctions::EPDToneMapCIE (ncie, a_w, c_, w_h, width, height, begh, endh, minQ, maxQ, Iterates, scale ); } //EPDToneMapCIE adapted to CIECAM @@ -1302,11 +1312,11 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh double xx, yy, zz; float x, y, z; const float eps = 0.0001; - float co_e = (pow(f_l, 0.25f)) + eps; + float co_e = (pow (f_l, 0.25f)) + eps; // if(params->epd.enabled) ncie->J_p[i][j]=(100.0* ncie->Q_p[i][j]*ncie->Q_p[i][j])/(w_h*w_h); - if(params->epd.enabled) { - ncie->J_p[i][j] = (100.0 * ncie->Q_p[i][j] * ncie->Q_p[i][j]) / SQR((4. / c) * (aw + 4.)); + if (params->epd.enabled) { + ncie->J_p[i][j] = (100.0 * ncie->Q_p[i][j] * ncie->Q_p[i][j]) / SQR ((4. / c) * (aw + 4.)); } ncie->C_p[i][j] = (ncie->M_p[i][j]) / co_e; @@ -1316,10 +1326,10 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh int libr = 0; int colch = 0; - if(curveMode == ColorAppearanceParams::TC_MODE_BRIGHT) { + if (curveMode == ColorAppearanceParams::TC_MODE_BRIGHT) { brli = 70.0; libr = 1; - } else if(curveMode == ColorAppearanceParams::TC_MODE_LIGHT) { + } else if (curveMode == ColorAppearanceParams::TC_MODE_LIGHT) { brli = 327.; libr = 0; } @@ -1327,25 +1337,26 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh if (curveMode3 == ColorAppearanceParams::TC_MODE_CHROMA) { chsacol = 327.; colch = 0; - } else if(curveMode3 == ColorAppearanceParams::TC_MODE_SATUR) { + } else if (curveMode3 == ColorAppearanceParams::TC_MODE_SATUR) { chsacol = 450.0; colch = 1; - } else if(curveMode3 == ColorAppearanceParams::TC_MODE_COLORF) { + } else if (curveMode3 == ColorAppearanceParams::TC_MODE_COLORF) { chsacol = 327.0; colch = 2; } - if(ciedata) { + if (ciedata) { // Data for J Q M s and C histograms //update histogram jp = true; - if(pW != 1) { //only with improccoordinator + if (pW != 1) { //only with improccoordinator int posl; - if(libr == 1) { - posl = CLIP((int)(ncie->Q_p[i][j] * brli)); //40.0 to 100.0 approximative factor for Q - 327 for J - } else /*if(libr == 0)*/ { - posl = CLIP((int)(ncie->J_p[i][j] * brli)); //327 for J + + if (libr == 1) { + posl = CLIP ((int) (ncie->Q_p[i][j] * brli)); //40.0 to 100.0 approximative factor for Q - 327 for J + } else { /*if(libr == 0)*/ + posl = CLIP ((int) (ncie->J_p[i][j] * brli)); //327 for J } hist16JCAM[posl]++; @@ -1353,15 +1364,16 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh chropC = true; - if(pW != 1) { //only with improccoordinator + if (pW != 1) { //only with improccoordinator int posc; - if(colch == 0) { - posc = CLIP((int)(ncie->C_p[i][j] * chsacol)); //450.0 approximative factor for s 320 for M - } else if(colch == 1) { - float sa_t = 100.f * sqrt(ncie->C_p[i][j] / ncie->Q_p[i][j]); //Q_p always > 0 - posc = CLIP((int)(sa_t * chsacol)); - } else /*if(colch == 2)*/ { - posc = CLIP((int)(ncie->M_p[i][j] * chsacol)); + + if (colch == 0) { + posc = CLIP ((int) (ncie->C_p[i][j] * chsacol)); //450.0 approximative factor for s 320 for M + } else if (colch == 1) { + float sa_t = 100.f * sqrt (ncie->C_p[i][j] / ncie->Q_p[i][j]); //Q_p always > 0 + posc = CLIP ((int) (sa_t * chsacol)); + } else { /*if(colch == 2)*/ + posc = CLIP ((int) (ncie->M_p[i][j] * chsacol)); } hist16_CCAM[posc]++; @@ -1370,41 +1382,41 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh //end histograms // double nd, nbbd, ncbd, fld, czd, dd, awd; - Ciecam02::jch2xyz_ciecam02( xx, yy, zz, - ncie->J_p[i][j], ncie->C_p[i][j], ncie->h_p[i][j], - xw2, yw2, zw2, - yb2, la2, - f2, c2, nc2, gamu, nj, nbbj, ncbj, flj, czj, dj, awj); + Ciecam02::jch2xyz_ciecam02 ( xx, yy, zz, + ncie->J_p[i][j], ncie->C_p[i][j], ncie->h_p[i][j], + xw2, yw2, zw2, + yb2, la2, + f2, c2, nc2, gamu, nj, nbbj, ncbj, flj, czj, dj, awj); x = (float)xx * 655.35; y = (float)yy * 655.35; z = (float)zz * 655.35; float Ll, aa, bb; //convert xyz=>lab - Color::XYZ2Lab(x, y, z, Ll, aa, bb); + Color::XYZ2Lab (x, y, z, Ll, aa, bb); lab->L[i][j] = Ll; lab->a[i][j] = aa; lab->b[i][j] = bb; - if(gamu == 1) { + if (gamu == 1) { float R, G, B; float HH, Lprov1, Chprov1; Lprov1 = lab->L[i][j] / 327.68f; - Chprov1 = sqrt(SQR(lab->a[i][j] / 327.68f) + SQR(lab->b[i][j] / 327.68f)); - HH = atan2(lab->b[i][j], lab->a[i][j]); + Chprov1 = sqrt (SQR (lab->a[i][j] / 327.68f) + SQR (lab->b[i][j] / 327.68f)); + HH = atan2 (lab->b[i][j], lab->a[i][j]); #ifdef _DEBUG bool neg = false; bool more_rgb = false; //gamut control : Lab values are in gamut - Color::gamutLchonly(HH, Lprov1, Chprov1, R, G, B, wipa, highlight, 0.15f, 0.96f, neg, more_rgb); + Color::gamutLchonly (HH, Lprov1, Chprov1, R, G, B, wipa, highlight, 0.15f, 0.96f, neg, more_rgb); #else //gamut control : Lab values are in gamut - Color::gamutLchonly(HH, Lprov1, Chprov1, R, G, B, wipa, highlight, 0.15f, 0.96f); + Color::gamutLchonly (HH, Lprov1, Chprov1, R, G, B, wipa, highlight, 0.15f, 0.96f); #endif lab->L[i][j] = Lprov1 * 327.68f; - lab->a[i][j] = 327.68f * Chprov1 * cos(HH); - lab->b[i][j] = 327.68f * Chprov1 * sin(HH); + lab->a[i][j] = 327.68f * Chprov1 * cos (HH); + lab->b[i][j] = 327.68f * Chprov1 * sin (HH); } } @@ -1413,24 +1425,24 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh //end parallelization //show CIECAM histograms - if(ciedata) { + if (ciedata) { //update histogram J and Q - if(pW != 1) { //only with improccoordinator + if (pW != 1) { //only with improccoordinator for (int i = 0; i < 32768; i++) { // if (jp) { float hval = dLcurve[i]; - int hi = (int)(255.0 * CLIPD(hval)); // + int hi = (int) (255.0 * CLIPD (hval)); // histLCAM[hi] += hist16JCAM[i] ; } } } //update color histogram M,s,C - if(pW != 1) { //only with improccoordinator + if (pW != 1) { //only with improccoordinator for (int i = 0; i < 48000; i++) { // if (chropC) { float hvalc = dCcurve[i]; - int hic = (int)(255.0 * CLIPD(hvalc)); // + int hic = (int) (255.0 * CLIPD (hvalc)); // histCCAM[hic] += hist16_CCAM[i] ; } } @@ -1449,7 +1461,7 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int begh, int const ColorAppearance & customColCurve1, const ColorAppearance & customColCurve2, const ColorAppearance & customColCurve3, LUTu & histLCAM, LUTu & histCCAM, LUTf & CAMBrightCurveJ, LUTf & CAMBrightCurveQ, float &mean, int Iterates, int scale, bool execsharp, float &d, int scalecd, int rtt) { - if(params->colorappearance.enabled) { + if (params->colorappearance.enabled) { #ifdef _DEBUG MyTime t1e, t2e; @@ -1460,10 +1472,10 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int begh, int LUTu hist16JCAM; LUTu hist16_CCAM; - if(pW != 1 && params->colorappearance.datacie) { //only with improccoordinator - hist16JCAM(32768); + if (pW != 1 && params->colorappearance.datacie) { //only with improccoordinator + hist16JCAM (32768); hist16JCAM.clear(); - hist16_CCAM(48000); + hist16_CCAM (48000); hist16_CCAM.clear(); } @@ -1481,29 +1493,29 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int begh, int bool algepd = false; const bool epdEnabled = params->epd.enabled; - bool ciedata = (params->colorappearance.datacie && pW != 1) && !((params->colorappearance.tonecie && (epdEnabled)) || (params->sharpening.enabled && settings->autocielab && execsharp) + bool ciedata = (params->colorappearance.datacie && pW != 1) && ! ((params->colorappearance.tonecie && (epdEnabled)) || (params->sharpening.enabled && settings->autocielab && execsharp) || (params->dirpyrequalizer.enabled && settings->autocielab) || (params->defringe.enabled && settings->autocielab) || (params->sharpenMicro.enabled && settings->autocielab) || (params->impulseDenoise.enabled && settings->autocielab) || (params->colorappearance.badpixsl > 0 && settings->autocielab)); ColorTemp::temp2mulxyz (params->wb.temperature, params->wb.green, params->wb.method, Xw, Zw); //compute white Xw Yw Zw : white current WB //viewing condition for surround - if(params->colorappearance.surround == "Average") { + if (params->colorappearance.surround == "Average") { f = 1.00f; c = 0.69f; nc = 1.00f; f2 = 1.0f, c2 = 0.69f, nc2 = 1.0f; - } else if(params->colorappearance.surround == "Dim") { + } else if (params->colorappearance.surround == "Dim") { f2 = 0.9f; c2 = 0.59f; nc2 = 0.9f; f = 1.0f, c = 0.69f, nc = 1.0f; - } else if(params->colorappearance.surround == "Dark") { + } else if (params->colorappearance.surround == "Dark") { f2 = 0.8f; c2 = 0.525f; nc2 = 0.8f; f = 1.0f, c = 0.69f, nc = 1.0f; - } else if(params->colorappearance.surround == "ExtremelyDark") { + } else if (params->colorappearance.surround == "ExtremelyDark") { f2 = 0.8f; c2 = 0.41f; nc2 = 0.8f; @@ -1511,7 +1523,7 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int begh, int } //scene condition for surround - if(params->colorappearance.surrsource) { + if (params->colorappearance.surrsource) { f = 0.85f; // if user => source image has surround very dark c = 0.55f; nc = 0.85f; @@ -1520,9 +1532,9 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int begh, int //with which algorithm if (params->colorappearance.algo == "JC") { alg = 0; - } else if(params->colorappearance.algo == "JS") { + } else if (params->colorappearance.algo == "JS") { alg = 1; - } else if(params->colorappearance.algo == "QM") { + } else if (params->colorappearance.algo == "QM") { alg = 2; algepd = true; } else { /*if(params->colorappearance.algo == "ALL")*/ @@ -1531,31 +1543,31 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int begh, int } //settings white point of output device - or illuminant viewing - if(settings->viewingdevice == 0) { + if (settings->viewingdevice == 0) { xwd = 96.42f; //5000K ywd = 100.0f; zwd = 82.52f; - } else if(settings->viewingdevice == 1) { + } else if (settings->viewingdevice == 1) { xwd = 95.68f; //5500 ywd = 100.0f; zwd = 92.15f; - } else if(settings->viewingdevice == 2) { + } else if (settings->viewingdevice == 2) { xwd = 95.24f; //6000 ywd = 100.0f; zwd = 100.81f; - } else if(settings->viewingdevice == 3) { + } else if (settings->viewingdevice == 3) { xwd = 95.04f; //6500 ywd = 100.0f; zwd = 108.88f; - } else if(settings->viewingdevice == 4) { + } else if (settings->viewingdevice == 4) { xwd = 109.85f; //tungsten ywd = 100.0f; zwd = 35.58f; - } else if(settings->viewingdevice == 5) { + } else if (settings->viewingdevice == 5) { xwd = 99.18f; //fluo F2 ywd = 100.0f; zwd = 67.39f; - } else if(settings->viewingdevice == 6) { + } else if (settings->viewingdevice == 6) { xwd = 95.04f; //fluo F7 ywd = 100.0f; zwd = 108.75f; @@ -1567,32 +1579,36 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int begh, int //settings mean Luminance Y of output device or viewing - if(settings->viewingdevicegrey == 0) { + if (settings->viewingdevicegrey == 0) { yb2 = 5.0f; - } else if(settings->viewingdevicegrey == 1) { + } else if (settings->viewingdevicegrey == 1) { yb2 = 10.0f; - } else if(settings->viewingdevicegrey == 2) { + } else if (settings->viewingdevicegrey == 2) { yb2 = 15.0f; - } else if(settings->viewingdevicegrey == 3) { + } else if (settings->viewingdevicegrey == 3) { yb2 = 18.0f; - } else if(settings->viewingdevicegrey == 4) { + } else if (settings->viewingdevicegrey == 4) { yb2 = 23.0f; - } else if(settings->viewingdevicegrey == 5) { + } else if (settings->viewingdevicegrey == 5) { yb2 = 30.0f; } else { /* if(settings->viewingdevicegrey == 6)*/ yb2 = 40.0f; } //La and la2 = ambiant luminosity scene and viewing - la = float(params->colorappearance.adapscen); + la = float (params->colorappearance.adapscen); - if(pwb == 2) { - if(params->colorappearance.autoadapscen) { + if (pwb == 2) { + if (params->colorappearance.autoadapscen) { la = adap; } } - const float la2 = float(params->colorappearance.adaplum); + if (alg >= 2 && la < 200.f) { + la = 200.f; + } + + const float la2 = float (params->colorappearance.adaplum); // level of adaptation const float deg = (params->colorappearance.degree) / 100.0f; @@ -1601,33 +1617,33 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int begh, int //algoritm's params float chr = 0.f; - if(alg == 0 || alg == 3) { + if (alg == 0 || alg == 3) { chr = params->colorappearance.chroma; - if(chr == -100.0f) { + if (chr == -100.0f) { chr = -99.8f; } } float schr = 0.f; - if(alg == 3 || alg == 1) { + if (alg == 3 || alg == 1) { schr = params->colorappearance.schroma; - if(schr > 0.0) { + if (schr > 0.0) { schr = schr / 2.0f; //divide sensibility for saturation } - if(alg == 3) { - if(schr == -100.0f) { + if (alg == 3) { + if (schr == -100.0f) { schr = -99.f; } - if(schr == 100.0f) { + if (schr == 100.0f) { schr = 98.f; } } else { - if(schr == -100.0f) { + if (schr == -100.0f) { schr = -99.8f; } } @@ -1635,14 +1651,14 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int begh, int float mchr = 0.f; - if(alg == 3 || alg == 2) { + if (alg == 3 || alg == 2) { mchr = params->colorappearance.mchroma; - if(mchr == -100.0f) { + if (mchr == -100.0f) { mchr = -99.8f ; } - if(mchr == 100.0f) { + if (mchr == 100.0f) { mchr = 99.9f; } } @@ -1652,21 +1668,21 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int begh, int // extracting datas from 'params' to avoid cache flush (to be confirmed) const ColorAppearanceParams::eTCModeId curveMode = params->colorappearance.curveMode; - const bool hasColCurve1 = bool(customColCurve1); + const bool hasColCurve1 = bool (customColCurve1); const bool t1L = hasColCurve1 && curveMode == ColorAppearanceParams::TC_MODE_LIGHT; const ColorAppearanceParams::eTCModeId curveMode2 = params->colorappearance.curveMode2; - const bool hasColCurve2 = bool(customColCurve2); + const bool hasColCurve2 = bool (customColCurve2); const ColorAppearanceParams::eCTCModeId curveMode3 = params->colorappearance.curveMode3; - const bool hasColCurve3 = bool(customColCurve3); + const bool hasColCurve3 = bool (customColCurve3); bool needJ = (alg == 0 || alg == 1 || alg == 3); bool needQ = (alg == 2 || alg == 3); LUTu hist16J; LUTu hist16Q; - if((needJ && CAMBrightCurveJ.dirty) || (needQ && CAMBrightCurveQ.dirty) || (std::isnan(mean) && settings->viewinggreySc != 0)) { + if ((needJ && CAMBrightCurveJ.dirty) || (needQ && CAMBrightCurveQ.dirty) || (std::isnan (mean) && settings->viewinggreySc != 0)) { if (needJ) { hist16J (32768); @@ -1681,7 +1697,7 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int begh, int float sum = 0.f; #ifdef _OPENMP - const int numThreads = min(max(width * height / 65536, 1), omp_get_max_threads()); + const int numThreads = min (max (width * height / 65536, 1), omp_get_max_threads()); #pragma omp parallel num_threads(numThreads) if(numThreads>1) #endif { @@ -1689,12 +1705,12 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int begh, int LUTu hist16Qthr; if (needJ) { - hist16Jthr(hist16J.getSize()); + hist16Jthr (hist16J.getSize()); hist16Jthr.clear(); } if (needQ) { - hist16Qthr(hist16Q.getSize()); + hist16Qthr (hist16Q.getSize()); hist16Qthr.clear(); } @@ -1705,10 +1721,10 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int begh, int float currL = lab->L[i][j] / 327.68f; float koef; //rough correspondence between L and J - if(currL > 50.f) { - if(currL > 70.f) { - if(currL > 80.f) { - if(currL > 85.f) { + if (currL > 50.f) { + if (currL > 70.f) { + if (currL > 80.f) { + if (currL > 85.f) { koef = 0.97f; } else { koef = 0.93f; @@ -1724,9 +1740,9 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int begh, int } } } else { - if(currL > 10.f) { - if(currL > 20.f) { - if(currL > 40.f) { + if (currL > 10.f) { + if (currL > 20.f) { + if (currL > 40.f) { koef = 0.75f; } else { koef = 0.7f; @@ -1740,11 +1756,11 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int begh, int } if (needJ) { - hist16Jthr[(int)((koef * lab->L[i][j]))]++; //evaluate histogram luminance L # J + hist16Jthr[ (int) ((koef * lab->L[i][j]))]++; //evaluate histogram luminance L # J } if (needQ) { - hist16Qthr[(int) (sqrtf((koef * (lab->L[i][j])) * 32768.f))]++; //for brightness Q : approximation for Q=wh*sqrt(J/100) J not equal L + hist16Qthr[ (int) (sqrtf ((koef * (lab->L[i][j])) * 32768.f))]++; //for brightness Q : approximation for Q=wh*sqrt(J/100) J not equal L } sum += koef * lab->L[i][j]; //evaluate mean J to calculate Yb @@ -1752,17 +1768,17 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int begh, int #pragma omp critical { - if(needJ) { + if (needJ) { hist16J += hist16Jthr; } - if(needQ) { + if (needQ) { hist16Q += hist16Qthr; } } - if(std::isnan(mean)) { + if (std::isnan (mean)) { mean = (sum / ((height) * width)) / 327.68f; //for Yb for all image...if one day "pipette" we can adapt Yb for each zone } } @@ -1772,31 +1788,31 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int begh, int //evaluate lightness, contrast } - if(settings->viewinggreySc == 0) { //auto + if (settings->viewinggreySc == 0) { //auto if (mean < 15.f) { yb = 3.0f; - } else if(mean < 30.f) { + } else if (mean < 30.f) { yb = 5.0f; - } else if(mean < 40.f) { + } else if (mean < 40.f) { yb = 10.0f; - } else if(mean < 45.f) { + } else if (mean < 45.f) { yb = 15.0f; - } else if(mean < 50.f) { + } else if (mean < 50.f) { yb = 18.0f; - } else if(mean < 55.f) { + } else if (mean < 55.f) { yb = 23.0f; - } else if(mean < 60.f) { + } else if (mean < 60.f) { yb = 30.0f; - } else if(mean < 70.f) { + } else if (mean < 70.f) { yb = 40.0f; - } else if(mean < 80.f) { + } else if (mean < 80.f) { yb = 60.0f; - } else if(mean < 90.f) { + } else if (mean < 90.f) { yb = 80.0f; } else { yb = 90.0f; } - } else if(settings->viewinggreySc == 1) { + } else if (settings->viewinggreySc == 1) { yb = 18.0f; //fixed } @@ -1809,14 +1825,14 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int begh, int float xw1, yw1, zw1, xw2, yw2, zw2; // settings of WB: scene and viewing - if(params->colorappearance.wbmodel == "RawT") { + if (params->colorappearance.wbmodel == "RawT") { xw1 = 96.46f; //use RT WB; CAT 02 is used for output device (see prefreneces) yw1 = 100.0f; zw1 = 82.445f; xw2 = xwd; yw2 = ywd; zw2 = zwd; - } else /*if(params->colorappearance.wbmodel == "RawTCAT02")*/ { + } else { /*if(params->colorappearance.wbmodel == "RawTCAT02")*/ xw1 = xw; // Settings RT WB are used for CAT02 => mix , CAT02 is use for output device (screen: D50 D65, projector: lamp, LED) see preferences yw1 = yw; zw1 = zw; @@ -1826,12 +1842,12 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int begh, int } float cz, wh, pfl; - Ciecam02::initcam1float(gamu, yb, pilot, f, la, xw, yw, zw, n, d, nbb, ncb, cz, aw, wh, pfl, fl, c); - const float pow1 = pow_F( 1.64f - pow_F( 0.29f, n ), 0.73f ); + Ciecam02::initcam1float (gamu, yb, pilot, f, la, xw, yw, zw, n, d, nbb, ncb, cz, aw, wh, pfl, fl, c); + const float pow1 = pow_F ( 1.64f - pow_F ( 0.29f, n ), 0.73f ); float nj, dj, nbbj, ncbj, czj, awj, flj; - Ciecam02::initcam2float(gamu, yb2, f2, la2, xw2, yw2, zw2, nj, dj, nbbj, ncbj, czj, awj, flj); + Ciecam02::initcam2float (gamu, yb2, f2, la2, xw2, yw2, zw2, nj, dj, nbbj, ncbj, czj, awj, flj); const float reccmcz = 1.f / (c2 * czj); - const float pow1n = pow_F( 1.64f - pow_F( 0.29f, nj ), 0.73f ); + const float pow1n = pow_F ( 1.64f - pow_F ( 0.29f, nj ), 0.73f ); const float epsil = 0.0001f; const float w_h = wh + epsil; @@ -1839,19 +1855,19 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int begh, int const float a_w = aw; const float c_ = c; const float f_l = fl; - const float coe = pow_F(fl, 0.25f); + const float coe = pow_F (fl, 0.25f); const float QproFactor = ( 0.4f / c ) * ( aw + 4.0f ) ; - const bool LabPassOne = !((params->colorappearance.tonecie && (epdEnabled)) || (params->sharpening.enabled && settings->autocielab && execsharp) - || (params->dirpyrequalizer.enabled && settings->autocielab) || (params->defringe.enabled && settings->autocielab) || (params->sharpenMicro.enabled && settings->autocielab) - || (params->impulseDenoise.enabled && settings->autocielab) || (params->colorappearance.badpixsl > 0 && settings->autocielab)); + const bool LabPassOne = ! ((params->colorappearance.tonecie && (epdEnabled)) || (params->sharpening.enabled && settings->autocielab && execsharp) + || (params->dirpyrequalizer.enabled && settings->autocielab) || (params->defringe.enabled && settings->autocielab) || (params->sharpenMicro.enabled && settings->autocielab) + || (params->impulseDenoise.enabled && settings->autocielab) || (params->colorappearance.badpixsl > 0 && settings->autocielab)); if (needJ) { if (!CAMBrightCurveJ) { - CAMBrightCurveJ(32768, LUT_CLIP_ABOVE); + CAMBrightCurveJ (32768, LUT_CLIP_ABOVE); } - if(CAMBrightCurveJ.dirty) { + if (CAMBrightCurveJ.dirty) { Ciecam02::curveJfloat (params->colorappearance.jlight, params->colorappearance.contrast, hist16J, CAMBrightCurveJ);//lightness and contrast J CAMBrightCurveJ /= 327.68f; CAMBrightCurveJ.dirty = false; @@ -1860,10 +1876,10 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int begh, int if (needQ) { if (!CAMBrightCurveQ) { - CAMBrightCurveQ(32768, LUT_CLIP_ABOVE); + CAMBrightCurveQ (32768, LUT_CLIP_ABOVE); } - if(CAMBrightCurveQ.dirty) { + if (CAMBrightCurveQ.dirty) { Ciecam02::curveJfloat (params->colorappearance.qbright, params->colorappearance.qcontrast, hist16Q, CAMBrightCurveQ);//brightness and contrast Q CAMBrightCurveQ /= coefQ; CAMBrightCurveQ.dirty = false; @@ -1874,9 +1890,9 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int begh, int //matrix for current working space TMatrix wiprof = ICCStore::getInstance()->workingSpaceInverseMatrix (params->icm.working); const float wip[3][3] = { - {(float)wiprof[0][0], (float)wiprof[0][1], (float)wiprof[0][2]}, - {(float)wiprof[1][0], (float)wiprof[1][1], (float)wiprof[1][2]}, - {(float)wiprof[2][0], (float)wiprof[2][1], (float)wiprof[2][2]} + { (float)wiprof[0][0], (float)wiprof[0][1], (float)wiprof[0][2]}, + { (float)wiprof[1][0], (float)wiprof[1][1], (float)wiprof[1][2]}, + { (float)wiprof[2][0], (float)wiprof[2][1], (float)wiprof[2][2]} }; #ifdef __SSE2__ @@ -1908,42 +1924,42 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int begh, int vfloat x, y, z; vfloat J, C, h, Q, M, s; - vfloat c655d35 = F2V(655.35f); + vfloat c655d35 = F2V (655.35f); - for(k = 0; k < width - 3; k += 4) { - Color::Lab2XYZ(LVFU(lab->L[i][k]), LVFU(lab->a[i][k]), LVFU(lab->b[i][k]), x, y, z); + for (k = 0; k < width - 3; k += 4) { + Color::Lab2XYZ (LVFU (lab->L[i][k]), LVFU (lab->a[i][k]), LVFU (lab->b[i][k]), x, y, z); x = x / c655d35; y = y / c655d35; z = z / c655d35; - Ciecam02::xyz2jchqms_ciecam02float( J, C, h, - Q, M, s, F2V(aw), F2V(fl), F2V(wh), - x, y, z, - F2V(xw1), F2V(yw1), F2V(zw1), - F2V(c), F2V(nc), F2V(pow1), F2V(nbb), F2V(ncb), F2V(pfl), F2V(cz), F2V(d)); - STVF(Jbuffer[k], J); - STVF(Cbuffer[k], C); - STVF(hbuffer[k], h); - STVF(Qbuffer[k], Q); - STVF(Mbuffer[k], M); - STVF(sbuffer[k], s); + Ciecam02::xyz2jchqms_ciecam02float ( J, C, h, + Q, M, s, F2V (aw), F2V (fl), F2V (wh), + x, y, z, + F2V (xw1), F2V (yw1), F2V (zw1), + F2V (c), F2V (nc), F2V (pow1), F2V (nbb), F2V (ncb), F2V (pfl), F2V (cz), F2V (d)); + STVF (Jbuffer[k], J); + STVF (Cbuffer[k], C); + STVF (hbuffer[k], h); + STVF (Qbuffer[k], Q); + STVF (Mbuffer[k], M); + STVF (sbuffer[k], s); } - for(; k < width; k++) { + for (; k < width; k++) { float L = lab->L[i][k]; float a = lab->a[i][k]; float b = lab->b[i][k]; float x, y, z; //convert Lab => XYZ - Color::Lab2XYZ(L, a, b, x, y, z); + Color::Lab2XYZ (L, a, b, x, y, z); x = x / 655.35f; y = y / 655.35f; z = z / 655.35f; float J, C, h, Q, M, s; - Ciecam02::xyz2jchqms_ciecam02float( J, C, h, - Q, M, s, aw, fl, wh, - x, y, z, - xw1, yw1, zw1, - c, nc, gamu, pow1, nbb, ncb, pfl, cz, d); + Ciecam02::xyz2jchqms_ciecam02float ( J, C, h, + Q, M, s, aw, fl, wh, + x, y, z, + xw1, yw1, zw1, + c, nc, gamu, pow1, nbb, ncb, pfl, cz, d); Jbuffer[k] = J; Cbuffer[k] = C; hbuffer[k] = h; @@ -1972,16 +1988,16 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int begh, int float b = lab->b[i][j]; float x1, y1, z1; //convert Lab => XYZ - Color::Lab2XYZ(L, a, b, x1, y1, z1); + Color::Lab2XYZ (L, a, b, x1, y1, z1); x = (float)x1 / 655.35f; y = (float)y1 / 655.35f; z = (float)z1 / 655.35f; //process source==> normal - Ciecam02::xyz2jchqms_ciecam02float( J, C, h, - Q, M, s, aw, fl, wh, - x, y, z, - xw1, yw1, zw1, - c, nc, gamu, pow1, nbb, ncb, pfl, cz, d); + Ciecam02::xyz2jchqms_ciecam02float ( J, C, h, + Q, M, s, aw, fl, wh, + x, y, z, + xw1, yw1, zw1, + c, nc, gamu, pow1, nbb, ncb, pfl, cz, d); #endif float Jpro, Cpro, hpro, Qpro, Mpro, spro; Jpro = J; @@ -1992,75 +2008,75 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int begh, int spro = s; // we cannot have all algorithms with all chroma curves - if(alg == 0) { + if (alg == 0) { Jpro = CAMBrightCurveJ[Jpro * 327.68f]; //lightness CIECAM02 + contrast - Qpro = QproFactor * sqrtf(Jpro); + Qpro = QproFactor * sqrtf (Jpro); float Cp = (spro * spro * Qpro) / (1000000.f); Cpro = Cp * 100.f; float sres; - Ciecam02::curvecolorfloat(chr, Cp , sres, 1.8f); - Color::skinredfloat(Jpro, hpro, sres, Cp, 55.f, 30.f, 1, rstprotection, 100.f, Cpro); - } else if(alg == 1) { + Ciecam02::curvecolorfloat (chr, Cp , sres, 1.8f); + Color::skinredfloat (Jpro, hpro, sres, Cp, 55.f, 30.f, 1, rstprotection, 100.f, Cpro); + } else if (alg == 1) { // Lightness saturation Jpro = CAMBrightCurveJ[Jpro * 327.68f]; //lightness CIECAM02 + contrast float sres; float Sp = spro / 100.0f; float parsat = 1.5f; //parsat=1.5 =>saturation ; 1.8 => chroma ; 2.5 => colorfullness (personal evaluation) - Ciecam02::curvecolorfloat(schr, Sp , sres, parsat); + Ciecam02::curvecolorfloat (schr, Sp , sres, parsat); float dred = 100.f; // in C mode float protect_red = 80.0f; // in C mode - dred = 100.0f * sqrtf((dred * coe) / Qpro); - protect_red = 100.0f * sqrtf((protect_red * coe) / Qpro); - Color::skinredfloat(Jpro, hpro, sres, Sp, dred, protect_red, 0, rstprotection, 100.f, spro); - Qpro = QproFactor * sqrtf(Jpro); + dred = 100.0f * sqrtf ((dred * coe) / Qpro); + protect_red = 100.0f * sqrtf ((protect_red * coe) / Qpro); + Color::skinredfloat (Jpro, hpro, sres, Sp, dred, protect_red, 0, rstprotection, 100.f, spro); + Qpro = QproFactor * sqrtf (Jpro); Cpro = (spro * spro * Qpro) / (10000.0f); - } else if(alg == 2) { - Qpro = CAMBrightCurveQ[(float)(Qpro * coefQ)]; //brightness and contrast + } else if (alg == 2) { + Qpro = CAMBrightCurveQ[ (float) (Qpro * coefQ)]; //brightness and contrast float Mp, sres; Mp = Mpro / 100.0f; - Ciecam02::curvecolorfloat(mchr, Mp , sres, 2.5f); + Ciecam02::curvecolorfloat (mchr, Mp , sres, 2.5f); float dred = 100.f; //in C mode float protect_red = 80.0f; // in C mode dred *= coe; //in M mode protect_red *= coe; //M mode - Color::skinredfloat(Jpro, hpro, sres, Mp, dred, protect_red, 0, rstprotection, 100.f, Mpro); - Jpro = SQR((10.f * Qpro) / wh); + Color::skinredfloat (Jpro, hpro, sres, Mp, dred, protect_red, 0, rstprotection, 100.f, Mpro); + Jpro = SQR ((10.f * Qpro) / wh); Cpro = Mpro / coe; Qpro = (Qpro == 0.f ? epsil : Qpro); // avoid division by zero - spro = 100.0f * sqrtf( Mpro / Qpro ); + spro = 100.0f * sqrtf ( Mpro / Qpro ); } else { /*if(alg == 3) */ - Qpro = CAMBrightCurveQ[(float)(Qpro * coefQ)]; //brightness and contrast + Qpro = CAMBrightCurveQ[ (float) (Qpro * coefQ)]; //brightness and contrast float Mp, sres; Mp = Mpro / 100.0f; - Ciecam02::curvecolorfloat(mchr, Mp , sres, 2.5f); + Ciecam02::curvecolorfloat (mchr, Mp , sres, 2.5f); float dred = 100.f; //in C mode float protect_red = 80.0f; // in C mode dred *= coe; //in M mode protect_red *= coe; //M mode - Color::skinredfloat(Jpro, hpro, sres, Mp, dred, protect_red, 0, rstprotection, 100.f, Mpro); - Jpro = SQR((10.f * Qpro) / wh); + Color::skinredfloat (Jpro, hpro, sres, Mp, dred, protect_red, 0, rstprotection, 100.f, Mpro); + Jpro = SQR ((10.f * Qpro) / wh); Cpro = Mpro / coe; Qpro = (Qpro == 0.f ? epsil : Qpro); // avoid division by zero - spro = 100.0f * sqrtf( Mpro / Qpro ); + spro = 100.0f * sqrtf ( Mpro / Qpro ); - if(Jpro > 99.9f) { + if (Jpro > 99.9f) { Jpro = 99.9f; } - Jpro = CAMBrightCurveJ[(float)(Jpro * 327.68f)]; //lightness CIECAM02 + contrast + Jpro = CAMBrightCurveJ[ (float) (Jpro * 327.68f)]; //lightness CIECAM02 + contrast float Sp = spro / 100.0f; - Ciecam02::curvecolorfloat(schr, Sp , sres, 1.5f); + Ciecam02::curvecolorfloat (schr, Sp , sres, 1.5f); dred = 100.f; // in C mode protect_red = 80.0f; // in C mode - dred = 100.0f * sqrtf((dred * coe) / Q); - protect_red = 100.0f * sqrtf((protect_red * coe) / Q); - Color::skinredfloat(Jpro, hpro, sres, Sp, dred, protect_red, 0, rstprotection, 100.f, spro); - Qpro = QproFactor * sqrtf(Jpro); + dred = 100.0f * sqrtf ((dred * coe) / Q); + protect_red = 100.0f * sqrtf ((protect_red * coe) / Q); + Color::skinredfloat (Jpro, hpro, sres, Sp, dred, protect_red, 0, rstprotection, 100.f, spro); + Qpro = QproFactor * sqrtf (Jpro); float Cp = (spro * spro * Qpro) / (1000000.f); Cpro = Cp * 100.f; - Ciecam02::curvecolorfloat(chr, Cp , sres, 1.8f); - Color::skinredfloat(Jpro, hpro, sres, Cp, 55.f, 30.f, 1, rstprotection, 100.f, Cpro); + Ciecam02::curvecolorfloat (chr, Cp , sres, 1.8f); + Color::skinredfloat (Jpro, hpro, sres, Cp, 55.f, 30.f, 1, rstprotection, 100.f, Cpro); // disabled this code, Issue 2690 // if(Jpro < 1.f && Cpro > 12.f) Cpro=12.f;//reduce artifacts by "pseudo gamut control CIECAM" // else if(Jpro < 2.f && Cpro > 15.f) Cpro=15.f; @@ -2068,7 +2084,7 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int begh, int // else if(Jpro < 7.f && Cpro > 50.f) Cpro=50.f; hpro = hpro + hue; - if( hpro < 0.0f ) { + if ( hpro < 0.0f ) { hpro += 360.0f; //hue } } @@ -2080,27 +2096,27 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int begh, int float Jold100 = (float) Jpro; float redu = 25.f; float reduc = 1.f; - const Lightcurve& userColCurveJ1 = static_cast(customColCurve1); - userColCurveJ1.Apply(Jj); + const Lightcurve& userColCurveJ1 = static_cast (customColCurve1); + userColCurveJ1.Apply (Jj); - if(Jj > Jold) { - if(Jj < 65535.f) { - if(Jold < 327.68f * redu) { + if (Jj > Jold) { + if (Jj < 65535.f) { + if (Jold < 327.68f * redu) { Jj = 0.3f * (Jj - Jold) + Jold; //divide sensibility } else { - reduc = LIM((100.f - Jold100) / (100.f - redu), 0.f, 1.f); + reduc = LIM ((100.f - Jold100) / (100.f - redu), 0.f, 1.f); Jj = 0.3f * reduc * (Jj - Jold) + Jold; //reduct sensibility in highlights } } - } else if(Jj > 10.f) { + } else if (Jj > 10.f) { Jj = 0.8f * (Jj - Jold) + Jold; } else if (Jj >= 0.f) { Jj = 0.90f * (Jj - Jold) + Jold; // not zero ==>artifacts } - Jpro = (float)(Jj / 327.68f); + Jpro = (float) (Jj / 327.68f); - if(Jpro < 1.f) { + if (Jpro < 1.f) { Jpro = 1.f; } } else if (curveMode == ColorAppearanceParams::TC_MODE_BRIGHT) { @@ -2113,28 +2129,28 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int begh, int float redu = 20.f; float reduc = 1.f; - const Brightcurve& userColCurveB1 = static_cast(customColCurve1); - userColCurveB1.Apply(Qq); + const Brightcurve& userColCurveB1 = static_cast (customColCurve1); + userColCurveB1.Apply (Qq); - if(Qq > Qold) { - if(Qq < 65535.f) { - if(Qold < 327.68f * redu) { + if (Qq > Qold) { + if (Qq < 65535.f) { + if (Qold < 327.68f * redu) { Qq = 0.25f * (Qq - Qold) + Qold; //divide sensibility } else { - reduc = LIM((100.f - Qold100) / (100.f - redu), 0.f, 1.f); + reduc = LIM ((100.f - Qold100) / (100.f - redu), 0.f, 1.f); Qq = 0.25f * reduc * (Qq - Qold) + Qold; //reduct sensibility in highlights } } - } else if(Qq > 10.f) { + } else if (Qq > 10.f) { Qq = 0.5f * (Qq - Qold) + Qold; } else if (Qq >= 0.f) { Qq = 0.7f * (Qq - Qold) + Qold; // not zero ==>artifacts } - Qpro = (float)(Qq * (coef) / 327.68f); + Qpro = (float) (Qq * (coef) / 327.68f); Jpro = 100.f * (Qpro * Qpro) / ((4.0f / c) * (4.0f / c) * (aw + 4.0f) * (aw + 4.0f)); - if(Jpro < 1.f) { + if (Jpro < 1.f) { Jpro = 1.f; } } @@ -2147,35 +2163,35 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int begh, int float Jold100 = (float) Jpro; float redu = 25.f; float reduc = 1.f; - const Lightcurve& userColCurveJ2 = static_cast(customColCurve2); - userColCurveJ2.Apply(Jj); + const Lightcurve& userColCurveJ2 = static_cast (customColCurve2); + userColCurveJ2.Apply (Jj); - if(Jj > Jold) { - if(Jj < 65535.f) { - if(Jold < 327.68f * redu) { + if (Jj > Jold) { + if (Jj < 65535.f) { + if (Jold < 327.68f * redu) { Jj = 0.3f * (Jj - Jold) + Jold; //divide sensibility } else { - reduc = LIM((100.f - Jold100) / (100.f - redu), 0.f, 1.f); + reduc = LIM ((100.f - Jold100) / (100.f - redu), 0.f, 1.f); Jj = 0.3f * reduc * (Jj - Jold) + Jold; //reduct sensibility in highlights } } - } else if(Jj > 10.f) { - if(!t1L) { + } else if (Jj > 10.f) { + if (!t1L) { Jj = 0.8f * (Jj - Jold) + Jold; } else { Jj = 0.4f * (Jj - Jold) + Jold; } } else if (Jj >= 0.f) { - if(!t1L) { + if (!t1L) { Jj = 0.90f * (Jj - Jold) + Jold; // not zero ==>artifacts } else { Jj = 0.5f * (Jj - Jold) + Jold; } } - Jpro = (float)(Jj / 327.68f); + Jpro = (float) (Jj / 327.68f); - if(Jpro < 1.f) { + if (Jpro < 1.f) { Jpro = 1.f; } @@ -2188,39 +2204,39 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int begh, int float redu = 20.f; float reduc = 1.f; - const Brightcurve& userColCurveB2 = static_cast(customColCurve2); - userColCurveB2.Apply(Qq); + const Brightcurve& userColCurveB2 = static_cast (customColCurve2); + userColCurveB2.Apply (Qq); - if(Qq > Qold) { - if(Qq < 65535.f) { - if(Qold < 327.68f * redu) { + if (Qq > Qold) { + if (Qq < 65535.f) { + if (Qold < 327.68f * redu) { Qq = 0.25f * (Qq - Qold) + Qold; //divide sensibility } else { - reduc = LIM((100.f - Qold100) / (100.f - redu), 0.f, 1.f); + reduc = LIM ((100.f - Qold100) / (100.f - redu), 0.f, 1.f); Qq = 0.25f * reduc * (Qq - Qold) + Qold; //reduct sensibility in highlights } } - } else if(Qq > 10.f) { + } else if (Qq > 10.f) { Qq = 0.5f * (Qq - Qold) + Qold; } else if (Qq >= 0.f) { Qq = 0.7f * (Qq - Qold) + Qold; // not zero ==>artifacts } - Qpro = (float)(Qq * (coef) / 327.68f); + Qpro = (float) (Qq * (coef) / 327.68f); Jpro = 100.f * (Qpro * Qpro) / ((4.0f / c) * (4.0f / c) * (aw + 4.0f) * (aw + 4.0f)); - if(t1L) { //to workaround the problem if we modify curve1-lightnees after curve2 brightness(the cat that bites its own tail!) in fact it's another type of curve only for this case + if (t1L) { //to workaround the problem if we modify curve1-lightnees after curve2 brightness(the cat that bites its own tail!) in fact it's another type of curve only for this case coef = 2.f; //adapt Q to J approximation Qq = (float) Qpro * coef; Qold = Qq; - const Lightcurve& userColCurveJ1 = static_cast(customColCurve1); - userColCurveJ1.Apply(Qq); + const Lightcurve& userColCurveJ1 = static_cast (customColCurve1); + userColCurveJ1.Apply (Qq); Qq = 0.05f * (Qq - Qold) + Qold; //approximative adaptation - Qpro = (float)(Qq / coef); + Qpro = (float) (Qq / coef); Jpro = 100.f * (Qpro * Qpro) / ((4.0f / c) * (4.0f / c) * (aw + 4.0f) * (aw + 4.0f)); } - if(Jpro < 1.f) { + if (Jpro < 1.f) { Jpro = 1.f; } } @@ -2232,13 +2248,13 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int begh, int float coef = 327.68f / parsat; float Cc = (float) Cpro * coef; float Ccold = Cc; - const Chromacurve& userColCurve = static_cast(customColCurve3); - userColCurve.Apply(Cc); + const Chromacurve& userColCurve = static_cast (customColCurve3); + userColCurve.Apply (Cc); float dred = 55.f; float protect_red = 30.0f; int sk = 1; float ko = 1.f / coef; - Color::skinredfloat(Jpro, hpro, Cc, Ccold, dred, protect_red, sk, rstprotection, ko, Cpro); + Color::skinredfloat (Jpro, hpro, Cc, Ccold, dred, protect_red, sk, rstprotection, ko, Cpro); /* if(Jpro < 1.f && Cpro > 12.f) { Cpro = 12.f; //reduce artifacts by "pseudo gamut control CIECAM" @@ -2255,32 +2271,32 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int begh, int float coef = 327.68f / parsat; float Ss = (float) spro * coef; float Sold = Ss; - const Saturcurve& userColCurve = static_cast(customColCurve3); - userColCurve.Apply(Ss); + const Saturcurve& userColCurve = static_cast (customColCurve3); + userColCurve.Apply (Ss); Ss = 0.6f * (Ss - Sold) + Sold; //divide sensibility saturation float dred = 100.f; // in C mode float protect_red = 80.0f; // in C mode - dred = 100.0f * sqrtf((dred * coe) / Qpro); - protect_red = 100.0f * sqrtf((protect_red * coe) / Qpro); + dred = 100.0f * sqrtf ((dred * coe) / Qpro); + protect_red = 100.0f * sqrtf ((protect_red * coe) / Qpro); int sk = 0; float ko = 1.f / coef; - Color::skinredfloat(Jpro, hpro, Ss, Sold, dred, protect_red, sk, rstprotection, ko, spro); - Qpro = ( 4.0f / c ) * sqrtf( Jpro / 100.0f ) * ( aw + 4.0f ) ; + Color::skinredfloat (Jpro, hpro, Ss, Sold, dred, protect_red, sk, rstprotection, ko, spro); + Qpro = ( 4.0f / c ) * sqrtf ( Jpro / 100.0f ) * ( aw + 4.0f ) ; Cpro = (spro * spro * Qpro) / (10000.0f); } else if (curveMode3 == ColorAppearanceParams::TC_MODE_COLORF) { // float parsat = 0.8f; //0.68; float coef = 327.68f / parsat; float Mm = (float) Mpro * coef; float Mold = Mm; - const Colorfcurve& userColCurve = static_cast(customColCurve3); - userColCurve.Apply(Mm); + const Colorfcurve& userColCurve = static_cast (customColCurve3); + userColCurve.Apply (Mm); float dred = 100.f; //in C mode float protect_red = 80.0f; // in C mode dred *= coe; //in M mode protect_red *= coe; int sk = 0; float ko = 1.f / coef; - Color::skinredfloat(Jpro, hpro, Mm, Mold, dred, protect_red, sk, rstprotection, ko, Mpro); + Color::skinredfloat (Jpro, hpro, Mm, Mold, dred, protect_red, sk, rstprotection, ko, Mpro); /* if(Jpro < 1.f && Mpro > 12.f * coe) { Mpro = 12.f * coe; //reduce artifacts by "pseudo gamut control CIECAM" @@ -2307,28 +2323,28 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int begh, int h = hpro; s = spro; - if(params->colorappearance.tonecie || settings->autocielab) { //use pointer for tonemapping with CIECAM and also sharpening , defringe, contrast detail + if (params->colorappearance.tonecie || settings->autocielab) { //use pointer for tonemapping with CIECAM and also sharpening , defringe, contrast detail ncie->Q_p[i][j] = (float)Q + epsil; //epsil to avoid Q=0 ncie->M_p[i][j] = (float)M + epsil; ncie->J_p[i][j] = (float)J + epsil; ncie->h_p[i][j] = (float)h; ncie->C_p[i][j] = (float)C + epsil; - ncie->sh_p[i][j] = (float) 3276.8f * (sqrtf( J ) ) ; + ncie->sh_p[i][j] = (float) 3276.8f * (sqrtf ( J ) ) ; - if(epdEnabled) { - if(ncie->Q_p[i][j] < minQThr) { + if (epdEnabled) { + if (ncie->Q_p[i][j] < minQThr) { minQThr = ncie->Q_p[i][j]; //minima } - if(ncie->Q_p[i][j] > maxQThr) { + if (ncie->Q_p[i][j] > maxQThr) { maxQThr = ncie->Q_p[i][j]; //maxima } } } - if(!params->colorappearance.tonecie || !settings->autocielab || !epdEnabled) { + if (!params->colorappearance.tonecie || !settings->autocielab || !epdEnabled) { - if(ciedata) { //only with improccoordinator + if (ciedata) { //only with improccoordinator // Data for J Q M s and C histograms int posl, posc; float brli = 327.f; @@ -2337,7 +2353,7 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int begh, int float colch; //update histogram - if(curveMode == ColorAppearanceParams::TC_MODE_BRIGHT) { + if (curveMode == ColorAppearanceParams::TC_MODE_BRIGHT) { brli = 70.0f; libr = Q; //40.0 to 100.0 approximative factor for Q - 327 for J } else { /*if(curveMode == ColorAppearanceParams::TC_MODE_LIGHT)*/ @@ -2345,13 +2361,13 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int begh, int libr = J; //327 for J } - posl = (int)(libr * brli); + posl = (int) (libr * brli); hist16JCAM[posl]++; if (curveMode3 == ColorAppearanceParams::TC_MODE_CHROMA) { chsacol = 327.f; colch = C; //450.0 approximative factor for s 320 for M - } else if(curveMode3 == ColorAppearanceParams::TC_MODE_SATUR) { + } else if (curveMode3 == ColorAppearanceParams::TC_MODE_SATUR) { chsacol = 450.0f; colch = s; } else { /*if(curveMode3 == ColorAppearanceParams::TC_MODE_COLORF)*/ @@ -2359,12 +2375,12 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int begh, int colch = M; } - posc = (int)(colch * chsacol); + posc = (int) (colch * chsacol); hist16_CCAM[posc]++; } - if(LabPassOne) { + if (LabPassOne) { #ifdef __SSE2__ // write to line buffers Jbuffer[j] = J; @@ -2374,27 +2390,27 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int begh, int float xx, yy, zz; //process normal==> viewing - Ciecam02::jch2xyz_ciecam02float( xx, yy, zz, - J, C, h, - xw2, yw2, zw2, - f2, c2, nc2, gamu, pow1n, nbbj, ncbj, flj, czj, dj, awj); + Ciecam02::jch2xyz_ciecam02float ( xx, yy, zz, + J, C, h, + xw2, yw2, zw2, + f2, c2, nc2, gamu, pow1n, nbbj, ncbj, flj, czj, dj, awj); float x, y, z; x = xx * 655.35f; y = yy * 655.35f; z = zz * 655.35f; float Ll, aa, bb; //convert xyz=>lab - Color::XYZ2Lab(x, y, z, Ll, aa, bb); + Color::XYZ2Lab (x, y, z, Ll, aa, bb); // gamut control in Lab mode; I must study how to do with cIECAM only - if(gamu == 1) { + if (gamu == 1) { float HH, Lprov1, Chprov1; Lprov1 = Ll / 327.68f; - Chprov1 = sqrtf(SQR(aa) + SQR(bb)) / 327.68f; - HH = xatan2f(bb, aa); + Chprov1 = sqrtf (SQR (aa) + SQR (bb)) / 327.68f; + HH = xatan2f (bb, aa); float2 sincosval; - if(Chprov1 == 0.0f) { + if (Chprov1 == 0.0f) { sincosval.y = 1.f; sincosval.x = 0.0f; } else { @@ -2407,10 +2423,10 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int begh, int bool neg = false; bool more_rgb = false; //gamut control : Lab values are in gamut - Color::gamutLchonly(sincosval, Lprov1, Chprov1, wip, highlight, 0.15f, 0.96f, neg, more_rgb); + Color::gamutLchonly (sincosval, Lprov1, Chprov1, wip, highlight, 0.15f, 0.96f, neg, more_rgb); #else //gamut control : Lab values are in gamut - Color::gamutLchonly(sincosval, Lprov1, Chprov1, wip, highlight, 0.15f, 0.96f); + Color::gamutLchonly (sincosval, Lprov1, Chprov1, wip, highlight, 0.15f, 0.96f); #endif lab->L[i][j] = Lprov1 * 327.68f; @@ -2434,31 +2450,31 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int begh, int float *ybuffer = Mbuffer; float *zbuffer = sbuffer; - for(k = 0; k < bufferLength; k += 4) { - Ciecam02::jch2xyz_ciecam02float( x, y, z, - LVF(Jbuffer[k]), LVF(Cbuffer[k]), LVF(hbuffer[k]), - F2V(xw2), F2V(yw2), F2V(zw2), - F2V(f2), F2V(nc2), F2V(pow1n), F2V(nbbj), F2V(ncbj), F2V(flj), F2V(dj), F2V(awj), F2V(reccmcz)); - STVF(xbuffer[k], x * c655d35); - STVF(ybuffer[k], y * c655d35); - STVF(zbuffer[k], z * c655d35); + for (k = 0; k < bufferLength; k += 4) { + Ciecam02::jch2xyz_ciecam02float ( x, y, z, + LVF (Jbuffer[k]), LVF (Cbuffer[k]), LVF (hbuffer[k]), + F2V (xw2), F2V (yw2), F2V (zw2), + F2V (f2), F2V (nc2), F2V (pow1n), F2V (nbbj), F2V (ncbj), F2V (flj), F2V (dj), F2V (awj), F2V (reccmcz)); + STVF (xbuffer[k], x * c655d35); + STVF (ybuffer[k], y * c655d35); + STVF (zbuffer[k], z * c655d35); } // XYZ2Lab uses a lookup table. The function behind that lut is a cube root. // SSE can't beat the speed of that lut, so it doesn't make sense to use SSE - for(int j = 0; j < width; j++) { + for (int j = 0; j < width; j++) { float Ll, aa, bb; //convert xyz=>lab - Color::XYZ2Lab(xbuffer[j], ybuffer[j], zbuffer[j], Ll, aa, bb); + Color::XYZ2Lab (xbuffer[j], ybuffer[j], zbuffer[j], Ll, aa, bb); // gamut control in Lab mode; I must study how to do with cIECAM only - if(gamu == 1) { + if (gamu == 1) { float Lprov1, Chprov1; Lprov1 = Ll / 327.68f; - Chprov1 = sqrtf(SQR(aa) + SQR(bb)) / 327.68f; + Chprov1 = sqrtf (SQR (aa) + SQR (bb)) / 327.68f; float2 sincosval; - if(Chprov1 == 0.0f) { + if (Chprov1 == 0.0f) { sincosval.y = 1.f; sincosval.x = 0.0f; } else { @@ -2470,10 +2486,10 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int begh, int bool neg = false; bool more_rgb = false; //gamut control : Lab values are in gamut - Color::gamutLchonly(sincosval, Lprov1, Chprov1, wip, highlight, 0.15f, 0.96f, neg, more_rgb); + Color::gamutLchonly (sincosval, Lprov1, Chprov1, wip, highlight, 0.15f, 0.96f, neg, more_rgb); #else //gamut control : Lab values are in gamut - Color::gamutLchonly(sincosval, Lprov1, Chprov1, wip, highlight, 0.15f, 0.96f); + Color::gamutLchonly (sincosval, Lprov1, Chprov1, wip, highlight, 0.15f, 0.96f); #endif lab->L[i][j] = Lprov1 * 327.68f; lab->a[i][j] = 327.68f * Chprov1 * sincosval.y; @@ -2490,24 +2506,24 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int begh, int #pragma omp critical { - if(minQThr < minQ) { + if (minQThr < minQ) { minQ = minQThr; } - if(maxQThr > maxQ) { + if (maxQThr > maxQ) { maxQ = maxQThr; } } } // End of parallelization - if(!params->colorappearance.tonecie || !settings->autocielab) { //normal + if (!params->colorappearance.tonecie || !settings->autocielab) { //normal - if(ciedata) { + if (ciedata) { //update histogram J - hist16JCAM.compressTo(histLCAM); + hist16JCAM.compressTo (histLCAM); //update histogram C - hist16_CCAM.compressTo(histCCAM); + hist16_CCAM.compressTo (histCCAM); } } @@ -2515,14 +2531,14 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int begh, int if (settings->verbose) { t2e.set(); - printf("CIECAM02 performed in %d usec:\n", t2e.etime(t1e)); + printf ("CIECAM02 performed in %d usec:\n", t2e.etime (t1e)); // printf("minc=%f maxc=%f minj=%f maxj=%f\n",minc,maxc,minj,maxj); } #endif - if(settings->autocielab) { - if((params->colorappearance.tonecie && (epdEnabled)) || (params->sharpening.enabled && settings->autocielab && execsharp) + if (settings->autocielab) { + if ((params->colorappearance.tonecie && (epdEnabled)) || (params->sharpening.enabled && settings->autocielab && execsharp) || (params->dirpyrequalizer.enabled && settings->autocielab) || (params->defringe.enabled && settings->autocielab) || (params->sharpenMicro.enabled && settings->autocielab) || (params->impulseDenoise.enabled && settings->autocielab) || (params->colorappearance.badpixsl > 0 && settings->autocielab)) { @@ -2530,27 +2546,27 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int begh, int //all this treatments reduce artefacts, but can leed to slighty different results - if(params->defringe.enabled) - if(execsharp) { + if (params->defringe.enabled) + if (execsharp) { lab->deleteLab(); ImProcFunctions::defringecam (ncie);//defringe adapted to CIECAM lab->reallocLab(); } //if(params->dirpyrequalizer.enabled) if(execsharp) { - if(params->dirpyrequalizer.enabled) { - if(params->dirpyrequalizer.gamutlab /*&& execsharp*/) {//remove artifacts by gaussian blur - skin control - float b_l = static_cast(params->dirpyrequalizer.hueskin.value[0]) / 100.0f; - float t_l = static_cast(params->dirpyrequalizer.hueskin.value[1]) / 100.0f; - float b_r = static_cast(params->dirpyrequalizer.hueskin.value[2]) / 100.0f; - float t_r = static_cast(params->dirpyrequalizer.hueskin.value[3]) / 100.0f; + if (params->dirpyrequalizer.enabled) { + if (params->dirpyrequalizer.gamutlab /*&& execsharp*/) { //remove artifacts by gaussian blur - skin control + float b_l = static_cast (params->dirpyrequalizer.hueskin.value[0]) / 100.0f; + float t_l = static_cast (params->dirpyrequalizer.hueskin.value[1]) / 100.0f; + float b_r = static_cast (params->dirpyrequalizer.hueskin.value[2]) / 100.0f; + float t_r = static_cast (params->dirpyrequalizer.hueskin.value[3]) / 100.0f; float artifact = (float) settings->artifact_cbdl; - if(artifact > 6.f) { + if (artifact > 6.f) { artifact = 6.f; } - if(artifact < 0.f) { + if (artifact < 0.f) { artifact = 1.f; } @@ -2563,14 +2579,14 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int begh, int } //if(params->colorappearance.badpixsl > 0) { int mode=params->colorappearance.badpixsl; - if(params->colorappearance.badpixsl > 0) if(execsharp) { + if (params->colorappearance.badpixsl > 0) if (execsharp) { int mode = params->colorappearance.badpixsl; lab->deleteLab(); ImProcFunctions::badpixcam (ncie, 3.0, 10, mode, 0, 0, 0, 0, 0, 0, 1);//for bad pixels CIECAM lab->reallocLab(); } - if(params->impulseDenoise.enabled) if(execsharp) { + if (params->impulseDenoise.enabled) if (execsharp) { float **buffers[3]; buffers[0] = lab->L; buffers[1] = lab->a; @@ -2578,29 +2594,29 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int begh, int ImProcFunctions::impulsedenoisecam (ncie, buffers); //impulse adapted to CIECAM } - if (params->sharpenMicro.enabled)if(execsharp) { - ImProcFunctions::MLmicrocontrastcam(ncie); + if (params->sharpenMicro.enabled)if (execsharp) { + ImProcFunctions::MLmicrocontrastcam (ncie); } - if(params->sharpening.enabled) - if(execsharp) { + if (params->sharpening.enabled) + if (execsharp) { float **buffer = lab->L; // We can use the L-buffer from lab as buffer to save some memory ImProcFunctions::sharpeningcam (ncie, buffer); // sharpening adapted to CIECAM } //if(params->dirpyrequalizer.enabled) if(execsharp) { - if(params->dirpyrequalizer.enabled /*&& execsharp*/) { + if (params->dirpyrequalizer.enabled /*&& execsharp*/) { // if(params->dirpyrequalizer.algo=="FI") choice=0; // else if(params->dirpyrequalizer.algo=="LA") choice=1; - if(rtt == 1) { - float b_l = static_cast(params->dirpyrequalizer.hueskin.value[0]) / 100.0f; - float t_l = static_cast(params->dirpyrequalizer.hueskin.value[1]) / 100.0f; - float b_r = static_cast(params->dirpyrequalizer.hueskin.value[2]) / 100.0f; - float t_r = static_cast(params->dirpyrequalizer.hueskin.value[3]) / 100.0f; + if (rtt == 1) { + float b_l = static_cast (params->dirpyrequalizer.hueskin.value[0]) / 100.0f; + float t_l = static_cast (params->dirpyrequalizer.hueskin.value[1]) / 100.0f; + float b_r = static_cast (params->dirpyrequalizer.hueskin.value[2]) / 100.0f; + float t_r = static_cast (params->dirpyrequalizer.hueskin.value[3]) / 100.0f; int choice = 0; // I have not suppress this statement in case of !! always to 0 lab->deleteLab(); - dirpyr_equalizercam(ncie, ncie->sh_p, ncie->sh_p, ncie->W, ncie->H, ncie->h_p, ncie->C_p, params->dirpyrequalizer.mult, params->dirpyrequalizer.threshold, params->dirpyrequalizer.skinprotect, true, params->dirpyrequalizer.gamutlab, b_l, t_l, t_r, b_r, choice, scalecd); //contrast by detail adapted to CIECAM + dirpyr_equalizercam (ncie, ncie->sh_p, ncie->sh_p, ncie->W, ncie->H, ncie->h_p, ncie->C_p, params->dirpyrequalizer.mult, params->dirpyrequalizer.threshold, params->dirpyrequalizer.skinprotect, true, params->dirpyrequalizer.gamutlab, b_l, t_l, t_r, b_r, choice, scalecd); //contrast by detail adapted to CIECAM lab->reallocLab(); } @@ -2613,7 +2629,7 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int begh, int } const float Qredi = ( 4.0f / c_) * ( a_w + 4.0f ); - const float co_e = (pow_F(f_l, 0.25f)); + const float co_e = (pow_F (f_l, 0.25f)); #ifndef _DEBUG @@ -2626,8 +2642,8 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int begh, int for (int i = 0; i < height; i++) // update CieImages with new values after sharpening, defringe, contrast by detail level for (int j = 0; j < width; j++) { - float interm = fabsf(ncie->sh_p[i][j] / (32768.f)); - ncie->J_p[i][j] = 100.0f * SQR(interm); + float interm = fabsf (ncie->sh_p[i][j] / (32768.f)); + ncie->J_p[i][j] = 100.0f * SQR (interm); ncie->Q_p[i][j] = interm * Qredi; ncie->M_p[i][j] = ncie->C_p[i][j] * co_e; } @@ -2635,15 +2651,15 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int begh, int } } - if((params->colorappearance.tonecie && (epdEnabled)) || (params->sharpening.enabled && settings->autocielab && execsharp) + if ((params->colorappearance.tonecie && (epdEnabled)) || (params->sharpening.enabled && settings->autocielab && execsharp) || (params->dirpyrequalizer.enabled && settings->autocielab) || (params->defringe.enabled && settings->autocielab) || (params->sharpenMicro.enabled && settings->autocielab) || (params->impulseDenoise.enabled && settings->autocielab) || (params->colorappearance.badpixsl > 0 && settings->autocielab)) { ciedata = (params->colorappearance.datacie && pW != 1); - if(epdEnabled && params->colorappearance.tonecie && algepd) { + if (epdEnabled && params->colorappearance.tonecie && algepd) { lab->deleteLab(); - ImProcFunctions::EPDToneMapCIE(ncie, a_w, c_, w_h, width, height, begh, endh, minQ, maxQ, Iterates, scale ); + ImProcFunctions::EPDToneMapCIE (ncie, a_w, c_, w_h, width, height, begh, endh, minQ, maxQ, Iterates, scale ); lab->reallocLab(); } @@ -2651,7 +2667,7 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int begh, int constexpr float eps = 0.0001f; - const float co_e = (pow_F(f_l, 0.25f)) + eps; + const float co_e = (pow_F (f_l, 0.25f)) + eps; #ifndef _DEBUG #pragma omp parallel @@ -2675,14 +2691,14 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int begh, int for (int j = 0; j < width; j++) { // if(epdEnabled) ncie->J_p[i][j]=(100.0f* ncie->Q_p[i][j]*ncie->Q_p[i][j])/(w_h*w_h); - if(epdEnabled) { - ncie->J_p[i][j] = (100.0f * ncie->Q_p[i][j] * ncie->Q_p[i][j]) / SQR((4.f / c) * (aw + 4.f)); + if (epdEnabled) { + ncie->J_p[i][j] = (100.0f * ncie->Q_p[i][j] * ncie->Q_p[i][j]) / SQR ((4.f / c) * (aw + 4.f)); } const float ncie_C_p = (ncie->M_p[i][j]) / co_e; //show histogram in CIECAM mode (Q,J, M,s,C) - if(ciedata) { + if (ciedata) { // Data for J Q M s and C histograms int posl, posc; float brli = 327.f; @@ -2690,7 +2706,7 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int begh, int float libr; float colch; - if(curveMode == ColorAppearanceParams::TC_MODE_BRIGHT) { + if (curveMode == ColorAppearanceParams::TC_MODE_BRIGHT) { brli = 70.0f; libr = ncie->Q_p[i][j]; //40.0 to 100.0 approximative factor for Q - 327 for J } else { /*if(curveMode == ColorAppearanceParams::TC_MODE_LIGHT)*/ @@ -2698,21 +2714,21 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int begh, int libr = ncie->J_p[i][j]; //327 for J } - posl = (int)(libr * brli); + posl = (int) (libr * brli); hist16JCAM[posl]++; if (curveMode3 == ColorAppearanceParams::TC_MODE_CHROMA) { chsacol = 327.f; colch = ncie_C_p; - } else if(curveMode3 == ColorAppearanceParams::TC_MODE_SATUR) { + } else if (curveMode3 == ColorAppearanceParams::TC_MODE_SATUR) { chsacol = 450.0f; - colch = 100.f * sqrtf(ncie_C_p / ncie->Q_p[i][j]); + colch = 100.f * sqrtf (ncie_C_p / ncie->Q_p[i][j]); } else { /*if(curveMode3 == ColorAppearanceParams::TC_MODE_COLORF)*/ chsacol = 327.0f; colch = ncie->M_p[i][j]; } - posc = (int)(colch * chsacol); + posc = (int) (colch * chsacol); hist16_CCAM[posc]++; } @@ -2724,24 +2740,24 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int begh, int hbuffer[j] = ncie->h_p[i][j]; #else float xx, yy, zz; - Ciecam02::jch2xyz_ciecam02float( xx, yy, zz, - ncie->J_p[i][j], ncie_C_p, ncie->h_p[i][j], - xw2, yw2, zw2, - f2, c2, nc2, gamu, pow1n, nbbj, ncbj, flj, czj, dj, awj); + Ciecam02::jch2xyz_ciecam02float ( xx, yy, zz, + ncie->J_p[i][j], ncie_C_p, ncie->h_p[i][j], + xw2, yw2, zw2, + f2, c2, nc2, gamu, pow1n, nbbj, ncbj, flj, czj, dj, awj); float x = (float)xx * 655.35f; float y = (float)yy * 655.35f; float z = (float)zz * 655.35f; float Ll, aa, bb; //convert xyz=>lab - Color::XYZ2Lab(x, y, z, Ll, aa, bb); + Color::XYZ2Lab (x, y, z, Ll, aa, bb); - if(gamu == 1) { + if (gamu == 1) { float Lprov1, Chprov1; Lprov1 = Ll / 327.68f; - Chprov1 = sqrtf(SQR(aa) + SQR(bb)) / 327.68f; + Chprov1 = sqrtf (SQR (aa) + SQR (bb)) / 327.68f; float2 sincosval; - if(Chprov1 == 0.0f) { + if (Chprov1 == 0.0f) { sincosval.y = 1.f; sincosval.x = 0.0f; } else { @@ -2754,10 +2770,10 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int begh, int bool neg = false; bool more_rgb = false; //gamut control : Lab values are in gamut - Color::gamutLchonly(sincosval, Lprov1, Chprov1, wip, highlight, 0.15f, 0.96f, neg, more_rgb); + Color::gamutLchonly (sincosval, Lprov1, Chprov1, wip, highlight, 0.15f, 0.96f, neg, more_rgb); #else //gamut control : Lab values are in gamut - Color::gamutLchonly(sincosval, Lprov1, Chprov1, wip, highlight, 0.15f, 0.96f); + Color::gamutLchonly (sincosval, Lprov1, Chprov1, wip, highlight, 0.15f, 0.96f); #endif lab->L[i][j] = Lprov1 * 327.68f; @@ -2776,35 +2792,35 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int begh, int // process line buffers int k; vfloat x, y, z; - vfloat c655d35 = F2V(655.35f); + vfloat c655d35 = F2V (655.35f); - for(k = 0; k < bufferLength; k += 4) { - Ciecam02::jch2xyz_ciecam02float( x, y, z, - LVF(Jbuffer[k]), LVF(Cbuffer[k]), LVF(hbuffer[k]), - F2V(xw2), F2V(yw2), F2V(zw2), - F2V(f2), F2V(nc2), F2V(pow1n), F2V(nbbj), F2V(ncbj), F2V(flj), F2V(dj), F2V(awj), F2V(reccmcz)); + for (k = 0; k < bufferLength; k += 4) { + Ciecam02::jch2xyz_ciecam02float ( x, y, z, + LVF (Jbuffer[k]), LVF (Cbuffer[k]), LVF (hbuffer[k]), + F2V (xw2), F2V (yw2), F2V (zw2), + F2V (f2), F2V (nc2), F2V (pow1n), F2V (nbbj), F2V (ncbj), F2V (flj), F2V (dj), F2V (awj), F2V (reccmcz)); x *= c655d35; y *= c655d35; z *= c655d35; - STVF(xbuffer[k], x); - STVF(ybuffer[k], y); - STVF(zbuffer[k], z); + STVF (xbuffer[k], x); + STVF (ybuffer[k], y); + STVF (zbuffer[k], z); } // XYZ2Lab uses a lookup table. The function behind that lut is a cube root. // SSE can't beat the speed of that lut, so it doesn't make sense to use SSE - for(int j = 0; j < width; j++) { + for (int j = 0; j < width; j++) { float Ll, aa, bb; //convert xyz=>lab - Color::XYZ2Lab(xbuffer[j], ybuffer[j], zbuffer[j], Ll, aa, bb); + Color::XYZ2Lab (xbuffer[j], ybuffer[j], zbuffer[j], Ll, aa, bb); - if(gamu == 1) { + if (gamu == 1) { float Lprov1, Chprov1; Lprov1 = Ll / 327.68f; - Chprov1 = sqrtf(SQR(aa) + SQR(bb)) / 327.68f; + Chprov1 = sqrtf (SQR (aa) + SQR (bb)) / 327.68f; float2 sincosval; - if(Chprov1 == 0.0f) { + if (Chprov1 == 0.0f) { sincosval.y = 1.f; sincosval.x = 0.0f; } else { @@ -2816,10 +2832,10 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int begh, int bool neg = false; bool more_rgb = false; //gamut control : Lab values are in gamut - Color::gamutLchonly(sincosval, Lprov1, Chprov1, wip, highlight, 0.15f, 0.96f, neg, more_rgb); + Color::gamutLchonly (sincosval, Lprov1, Chprov1, wip, highlight, 0.15f, 0.96f, neg, more_rgb); #else //gamut control : Lab values are in gamut - Color::gamutLchonly(sincosval, Lprov1, Chprov1, wip, highlight, 0.15f, 0.96f); + Color::gamutLchonly (sincosval, Lprov1, Chprov1, wip, highlight, 0.15f, 0.96f); #endif lab->L[i][j] = Lprov1 * 327.68f; lab->a[i][j] = 327.68f * Chprov1 * sincosval.y; @@ -2838,13 +2854,13 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int begh, int } //end parallelization //show CIECAM histograms - if(ciedata) { + if (ciedata) { //update histogram J and Q //update histogram J - hist16JCAM.compressTo(histLCAM); + hist16JCAM.compressTo (histLCAM); //update color histogram M,s,C - hist16_CCAM.compressTo(histCCAM); + hist16_CCAM.compressTo (histCCAM); } } } @@ -2866,20 +2882,20 @@ void ImProcFunctions::moyeqt (Imagefloat* working, float &moyS, float &eqty) for (int i = 0; i < tHh; i++) { for (int j = 0; j < tWw; j++) { - float s = Color::rgb2s(CLIP(working->r(i, j)), CLIP(working->g(i, j)), CLIP(working->b(i, j))); + float s = Color::rgb2s (CLIP (working->r (i, j)), CLIP (working->g (i, j)), CLIP (working->b (i, j))); moy += s; - sqrs += SQR(s); + sqrs += SQR (s); } } moy /= (tHh * tWw); sqrs /= (tHh * tWw); - eqty = sqrt(sqrs - SQR(moy)); + eqty = sqrt (sqrs - SQR (moy)); moyS = moy; } static inline void -filmlike_clip_rgb_tone(float *r, float *g, float *b, const float L) +filmlike_clip_rgb_tone (float *r, float *g, float *b, const float L) { float r_ = *r > L ? L : *r; float b_ = *b > L ? L : *b; @@ -2890,18 +2906,18 @@ filmlike_clip_rgb_tone(float *r, float *g, float *b, const float L) } static void -filmlike_clip(float *r, float *g, float *b) +filmlike_clip (float *r, float *g, float *b) { // This is Adobe's hue-stable film-like curve with a diagonal, ie only used for clipping. Can probably be further optimized. const float L = 65535.0; if (*r >= *g) { if (*g > *b) { // Case 1: r >= g > b - filmlike_clip_rgb_tone(r, g, b, L); + filmlike_clip_rgb_tone (r, g, b, L); } else if (*b > *r) { // Case 2: b > r >= g - filmlike_clip_rgb_tone(b, r, g, L); + filmlike_clip_rgb_tone (b, r, g, L); } else if (*b > *g) { // Case 3: r >= b > g - filmlike_clip_rgb_tone(r, b, g, L); + filmlike_clip_rgb_tone (r, b, g, L); } else { // Case 4: r >= g == b *r = *r > L ? L : *r; *g = *g > L ? L : *g; @@ -2909,11 +2925,11 @@ filmlike_clip(float *r, float *g, float *b) } } else { if (*r >= *b) { // Case 5: g > r >= b - filmlike_clip_rgb_tone(g, r, b, L); + filmlike_clip_rgb_tone (g, r, b, L); } else if (*b > *g) { // Case 6: b > g > r - filmlike_clip_rgb_tone(b, g, r, L); + filmlike_clip_rgb_tone (b, g, r, L); } else { // Case 7: g >= b > r - filmlike_clip_rgb_tone(g, b, r, L); + filmlike_clip_rgb_tone (g, b, r, L); } } } @@ -2968,20 +2984,20 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer float toxyz[3][3] = { { - static_cast( wprof[0][0] / Color::D50x), - static_cast( wprof[0][1] / Color::D50x), - static_cast( wprof[0][2] / Color::D50x) + static_cast ( wprof[0][0] / Color::D50x), + static_cast ( wprof[0][1] / Color::D50x), + static_cast ( wprof[0][2] / Color::D50x) }, { - static_cast( wprof[1][0]), - static_cast( wprof[1][1]), - static_cast( wprof[1][2]) + static_cast ( wprof[1][0]), + static_cast ( wprof[1][1]), + static_cast ( wprof[1][2]) }, { - static_cast( wprof[2][0] / Color::D50z), - static_cast( wprof[2][1] / Color::D50z), - static_cast( wprof[2][2] / Color::D50z) + static_cast ( wprof[2][0] / Color::D50z), + static_cast ( wprof[2][1] / Color::D50z), + static_cast ( wprof[2][2] / Color::D50z) } }; - float maxFactorToxyz = max(toxyz[1][0],toxyz[1][1],toxyz[1][2]); + float maxFactorToxyz = max (toxyz[1][0], toxyz[1][1], toxyz[1][2]); float equalR = maxFactorToxyz / toxyz[1][0]; float equalG = maxFactorToxyz / toxyz[1][1]; float equalB = maxFactorToxyz / toxyz[1][2]; @@ -3008,10 +3024,10 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer FlatCurve* vCurve = nullptr; FlatCurve* bwlCurve = nullptr; - FlatCurveType hCurveType = (FlatCurveType)params->hsvequalizer.hcurve.at(0); - FlatCurveType sCurveType = (FlatCurveType)params->hsvequalizer.scurve.at(0); - FlatCurveType vCurveType = (FlatCurveType)params->hsvequalizer.vcurve.at(0); - FlatCurveType bwlCurveType = (FlatCurveType)params->blackwhite.luminanceCurve.at(0); + FlatCurveType hCurveType = (FlatCurveType)params->hsvequalizer.hcurve.at (0); + FlatCurveType sCurveType = (FlatCurveType)params->hsvequalizer.scurve.at (0); + FlatCurveType vCurveType = (FlatCurveType)params->hsvequalizer.vcurve.at (0); + FlatCurveType bwlCurveType = (FlatCurveType)params->blackwhite.luminanceCurve.at (0); bool hCurveEnabled = hCurveType > FCT_Linear; bool sCurveEnabled = sCurveType > FCT_Linear; bool vCurveEnabled = vCurveType > FCT_Linear; @@ -3019,7 +3035,7 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer // TODO: We should create a 'skip' value like for CurveFactory::complexsgnCurve (rtengine/curves.cc) if (hCurveEnabled) { - hCurve = new FlatCurve(params->hsvequalizer.hcurve); + hCurve = new FlatCurve (params->hsvequalizer.hcurve); if (hCurve->isIdentity()) { delete hCurve; @@ -3029,7 +3045,7 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer } if (sCurveEnabled) { - sCurve = new FlatCurve(params->hsvequalizer.scurve); + sCurve = new FlatCurve (params->hsvequalizer.scurve); if (sCurve->isIdentity()) { delete sCurve; @@ -3039,7 +3055,7 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer } if (vCurveEnabled) { - vCurve = new FlatCurve(params->hsvequalizer.vcurve); + vCurve = new FlatCurve (params->hsvequalizer.vcurve); if (vCurve->isIdentity()) { delete vCurve; @@ -3049,7 +3065,7 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer } if (bwlCurveEnabled) { - bwlCurve = new FlatCurve(params->blackwhite.luminanceCurve); + bwlCurve = new FlatCurve (params->blackwhite.luminanceCurve); if (bwlCurve->isIdentity()) { delete bwlCurve; @@ -3069,23 +3085,23 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer #endif if ( params->filmSimulation.enabled && !params->filmSimulation.clutFilename.empty() ) { - hald_clut = CLUTStore::getInstance().getClut( params->filmSimulation.clutFilename ); + hald_clut = CLUTStore::getInstance().getClut ( params->filmSimulation.clutFilename ); if ( hald_clut ) { clutAndWorkingProfilesAreSame = hald_clut->getProfile() == params->icm.working; if ( !clutAndWorkingProfilesAreSame ) { - xyz2clut = ICCStore::getInstance()->workingSpaceInverseMatrix( hald_clut->getProfile() ); - clut2xyz = ICCStore::getInstance()->workingSpaceMatrix( hald_clut->getProfile() ); + xyz2clut = ICCStore::getInstance()->workingSpaceInverseMatrix ( hald_clut->getProfile() ); + clut2xyz = ICCStore::getInstance()->workingSpaceMatrix ( hald_clut->getProfile() ); #ifdef __SSE2__ for (int i = 0; i < 3; ++i) { for (int j = 0; j < 3; ++j) { - v_work2xyz[i][j] = F2V(wprof[i][j]); - v_xyz2clut[i][j] = F2V(xyz2clut[i][j]); - v_xyz2work[i][j] = F2V(wiprof[i][j]); - v_clut2xyz[i][j] = F2V(clut2xyz[i][j]); + v_work2xyz[i][j] = F2V (wprof[i][j]); + v_xyz2clut[i][j] = F2V (xyz2clut[i][j]); + v_xyz2work[i][j] = F2V (wiprof[i][j]); + v_clut2xyz[i][j] = F2V (clut2xyz[i][j]); } } @@ -3095,41 +3111,41 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer } } - const float film_simulation_strength = static_cast(params->filmSimulation.strength) / 100.0f; + const float film_simulation_strength = static_cast (params->filmSimulation.strength) / 100.0f; const float exp_scale = pow (2.0, expcomp); - const float comp = (max(0.0, expcomp) + 1.0) * hlcompr / 100.0; - const float shoulder = ((65536.0 / max(1.0f, exp_scale)) * (hlcomprthresh / 200.0)) + 0.1; + const float comp = (max (0.0, expcomp) + 1.0) * hlcompr / 100.0; + const float shoulder = ((65536.0 / max (1.0f, exp_scale)) * (hlcomprthresh / 200.0)) + 0.1; const float hlrange = 65536.0 - shoulder; const bool isProPhoto = (params->icm.working == "ProPhoto"); // extracting datas from 'params' to avoid cache flush (to be confirmed) ToneCurveParams::eTCModeId curveMode = params->toneCurve.curveMode; ToneCurveParams::eTCModeId curveMode2 = params->toneCurve.curveMode2; bool highlight = params->toneCurve.hrenabled;//Get the value if "highlight reconstruction" is activated - bool hasToneCurve1 = bool(customToneCurve1); - bool hasToneCurve2 = bool(customToneCurve2); + bool hasToneCurve1 = bool (customToneCurve1); + bool hasToneCurve2 = bool (customToneCurve2); BlackWhiteParams::eTCModeId beforeCurveMode = params->blackwhite.beforeCurveMode; BlackWhiteParams::eTCModeId afterCurveMode = params->blackwhite.afterCurveMode; - bool hasToneCurvebw1 = bool(customToneCurvebw1); - bool hasToneCurvebw2 = bool(customToneCurvebw2); + bool hasToneCurvebw1 = bool (customToneCurvebw1); + bool hasToneCurvebw2 = bool (customToneCurvebw2); PerceptualToneCurveState ptc1ApplyState, ptc2ApplyState; if (hasToneCurve1 && curveMode == ToneCurveParams::TC_MODE_PERCEPTUAL) { - const PerceptualToneCurve& userToneCurve = static_cast(customToneCurve1); - userToneCurve.initApplyState(ptc1ApplyState, params->icm.working); + const PerceptualToneCurve& userToneCurve = static_cast (customToneCurve1); + userToneCurve.initApplyState (ptc1ApplyState, params->icm.working); } if (hasToneCurve2 && curveMode2 == ToneCurveParams::TC_MODE_PERCEPTUAL) { - const PerceptualToneCurve& userToneCurve = static_cast(customToneCurve2); - userToneCurve.initApplyState(ptc2ApplyState, params->icm.working); + const PerceptualToneCurve& userToneCurve = static_cast (customToneCurve2); + userToneCurve.initApplyState (ptc2ApplyState, params->icm.working); } - bool hasColorToning = params->colorToning.enabled && bool(ctOpacityCurve) && bool(ctColorCurve); + bool hasColorToning = params->colorToning.enabled && bool (ctOpacityCurve) && bool (ctColorCurve); // float satLimit = float(params->colorToning.satProtectionThreshold)/100.f*0.7f+0.3f; // float satLimitOpacity = 1.f-(float(params->colorToning.saturatedOpacity)/100.f); - float strProtect = (float(params->colorToning.strength) / 100.f); + float strProtect = (float (params->colorToning.strength) / 100.f); /* // Debug output - Color LUTf points @@ -3161,52 +3177,52 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer } */ - float RedLow = (100.f + float(params->colorToning.redlow)) / 100.f; //printf("Rel=%f\n",RedLow); - float GreenLow = (100.f + float(params->colorToning.greenlow)) / 100.f; //printf("Gre=%f\n",GreenLow); - float BlueLow = (100.f + float(params->colorToning.bluelow)) / 100.f; //printf("Blu=%f\n",BlueLow); - float RedMed = (100.f + float(params->colorToning.redmed)) / 100.f; - float GreenMed = (100.f + float(params->colorToning.greenmed)) / 100.f; - float BlueMed = (100.f + float(params->colorToning.bluemed)) / 100.f; - float RedHigh = (100.f + float(params->colorToning.redhigh)) / 100.f; //printf("RedH=%f\n",RedHigh); - float GreenHigh = (100.f + float(params->colorToning.greenhigh)) / 100.f; - float BlueHigh = (100.f + float(params->colorToning.bluehigh)) / 100.f; - float SatLow = float(params->colorToning.shadowsColSat.value[0]) / 100.f; - float SatHigh = float(params->colorToning.hlColSat.value[0]) / 100.f; + float RedLow = (100.f + float (params->colorToning.redlow)) / 100.f; //printf("Rel=%f\n",RedLow); + float GreenLow = (100.f + float (params->colorToning.greenlow)) / 100.f; //printf("Gre=%f\n",GreenLow); + float BlueLow = (100.f + float (params->colorToning.bluelow)) / 100.f; //printf("Blu=%f\n",BlueLow); + float RedMed = (100.f + float (params->colorToning.redmed)) / 100.f; + float GreenMed = (100.f + float (params->colorToning.greenmed)) / 100.f; + float BlueMed = (100.f + float (params->colorToning.bluemed)) / 100.f; + float RedHigh = (100.f + float (params->colorToning.redhigh)) / 100.f; //printf("RedH=%f\n",RedHigh); + float GreenHigh = (100.f + float (params->colorToning.greenhigh)) / 100.f; + float BlueHigh = (100.f + float (params->colorToning.bluehigh)) / 100.f; + float SatLow = float (params->colorToning.shadowsColSat.value[0]) / 100.f; + float SatHigh = float (params->colorToning.hlColSat.value[0]) / 100.f; - float Balan = float(params->colorToning.balance); + float Balan = float (params->colorToning.balance); - float chMixRR = float(params->chmixer.red[0]); - float chMixRG = float(params->chmixer.red[1]); - float chMixRB = float(params->chmixer.red[2]); - float chMixGR = float(params->chmixer.green[0]); - float chMixGG = float(params->chmixer.green[1]); - float chMixGB = float(params->chmixer.green[2]); - float chMixBR = float(params->chmixer.blue[0]); - float chMixBG = float(params->chmixer.blue[1]); - float chMixBB = float(params->chmixer.blue[2]); + float chMixRR = float (params->chmixer.red[0]); + float chMixRG = float (params->chmixer.red[1]); + float chMixRB = float (params->chmixer.red[2]); + float chMixGR = float (params->chmixer.green[0]); + float chMixGG = float (params->chmixer.green[1]); + float chMixGB = float (params->chmixer.green[2]); + float chMixBR = float (params->chmixer.blue[0]); + float chMixBG = float (params->chmixer.blue[1]); + float chMixBB = float (params->chmixer.blue[2]); int shHighlights = params->sh.highlights; int shShadows = params->sh.shadows; bool blackwhite = params->blackwhite.enabled; bool complem = params->blackwhite.enabledcc; - float bwr = float(params->blackwhite.mixerRed); - float bwg = float(params->blackwhite.mixerGreen); - float bwb = float(params->blackwhite.mixerBlue); - float bwrgam = float(params->blackwhite.gammaRed); - float bwggam = float(params->blackwhite.gammaGreen); - float bwbgam = float(params->blackwhite.gammaBlue); - float mixerOrange = float(params->blackwhite.mixerOrange); - float mixerYellow = float(params->blackwhite.mixerYellow); - float mixerCyan = float(params->blackwhite.mixerCyan); - float mixerMagenta = float(params->blackwhite.mixerMagenta); - float mixerPurple = float(params->blackwhite.mixerPurple); + float bwr = float (params->blackwhite.mixerRed); + float bwg = float (params->blackwhite.mixerGreen); + float bwb = float (params->blackwhite.mixerBlue); + float bwrgam = float (params->blackwhite.gammaRed); + float bwggam = float (params->blackwhite.gammaGreen); + float bwbgam = float (params->blackwhite.gammaBlue); + float mixerOrange = float (params->blackwhite.mixerOrange); + float mixerYellow = float (params->blackwhite.mixerYellow); + float mixerCyan = float (params->blackwhite.mixerCyan); + float mixerMagenta = float (params->blackwhite.mixerMagenta); + float mixerPurple = float (params->blackwhite.mixerPurple); int algm = 0; if (params->blackwhite.method == "Desaturation") { algm = 0; - } else if(params->blackwhite.method == "LumEqualizer") { + } else if (params->blackwhite.method == "LumEqualizer") { algm = 1; - } else if(params->blackwhite.method == "ChannelMixer") { + } else if (params->blackwhite.method == "ChannelMixer") { algm = 2; } @@ -3217,15 +3233,15 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer float gamvalb = 125.f; bool computeMixerAuto = params->blackwhite.autoc && (autor < -5000.f); - if(bwrgam < 0) { + if (bwrgam < 0) { gamvalr = 100.f; } - if(bwggam < 0) { + if (bwggam < 0) { gamvalg = 100.f; } - if(bwbgam < 0) { + if (bwbgam < 0) { gamvalb = 100.f; } @@ -3241,20 +3257,20 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer bool hasgammabw = gammabwr != 1.f || gammabwg != 1.f || gammabwb != 1.f; if (hasColorToning || blackwhite || (params->dirpyrequalizer.cbdlMethod == "bef" && params->dirpyrequalizer.enabled)) { - tmpImage = new Imagefloat(working->getWidth(), working->getHeight()); + tmpImage = new Imagefloat (working->getWidth(), working->getHeight()); } // For tonecurve histogram int toneCurveHistSize = histToneCurve ? histToneCurve.getSize() : 0; int histToneCurveCompression = 0; - if(toneCurveHistSize > 0) { + if (toneCurveHistSize > 0) { histToneCurve.clear(); - histToneCurveCompression = log2(65536 / toneCurveHistSize); + histToneCurveCompression = log2 (65536 / toneCurveHistSize); } // For tonecurve histogram - const float lumimulf[3] = {static_cast(lumimul[0]), static_cast(lumimul[1]), static_cast(lumimul[2])}; + const float lumimulf[3] = {static_cast (lumimul[0]), static_cast (lumimul[1]), static_cast (lumimul[2])}; #define TS 112 @@ -3267,13 +3283,13 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer char *editIFloatBuffer = nullptr; char *editWhateverBuffer = nullptr; - buffer = (char *) malloc(3 * sizeof(float) * TS * TS + 20 * 64 + 63); + buffer = (char *) malloc (3 * sizeof (float) * TS * TS + 20 * 64 + 63); char *data; - data = (char*)( ( uintptr_t(buffer) + uintptr_t(63)) / 64 * 64); + data = (char*) ( ( uintptr_t (buffer) + uintptr_t (63)) / 64 * 64); - float *rtemp = (float(*))data; - float *gtemp = (float (*)) ((char*)rtemp + sizeof(float) * TS * TS + 4 * 64); - float *btemp = (float (*)) ((char*)gtemp + sizeof(float) * TS * TS + 8 * 64); + float *rtemp = (float (*))data; + float *gtemp = (float (*)) ((char*)rtemp + sizeof (float) * TS * TS + 4 * 64); + float *btemp = (float (*)) ((char*)gtemp + sizeof (float) * TS * TS + 8 * 64); int istart; int jstart; int tW; @@ -3283,26 +3299,27 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer float *editIFloatTmpR = nullptr, *editIFloatTmpG = nullptr, *editIFloatTmpB = nullptr, *editWhateverTmp = nullptr; if (editImgFloat) { - editIFloatBuffer = (char *) malloc(3 * sizeof(float) * TS * TS + 20 * 64 + 63); - data = (char*)( ( uintptr_t(editIFloatBuffer) + uintptr_t(63)) / 64 * 64); + editIFloatBuffer = (char *) malloc (3 * sizeof (float) * TS * TS + 20 * 64 + 63); + data = (char*) ( ( uintptr_t (editIFloatBuffer) + uintptr_t (63)) / 64 * 64); - editIFloatTmpR = (float(*))data; - editIFloatTmpG = (float (*)) ((char*)editIFloatTmpR + sizeof(float) * TS * TS + 4 * 64); - editIFloatTmpB = (float (*)) ((char*)editIFloatTmpG + sizeof(float) * TS * TS + 8 * 64); + editIFloatTmpR = (float (*))data; + editIFloatTmpG = (float (*)) ((char*)editIFloatTmpR + sizeof (float) * TS * TS + 4 * 64); + editIFloatTmpB = (float (*)) ((char*)editIFloatTmpG + sizeof (float) * TS * TS + 8 * 64); } if (editWhatever) { - editWhateverBuffer = (char *) malloc(sizeof(float) * TS * TS + 20 * 64 + 63); - data = (char*)( ( uintptr_t(editWhateverBuffer) + uintptr_t(63)) / 64 * 64); + editWhateverBuffer = (char *) malloc (sizeof (float) * TS * TS + 20 * 64 + 63); + data = (char*) ( ( uintptr_t (editWhateverBuffer) + uintptr_t (63)) / 64 * 64); - editWhateverTmp = (float(*))data; + editWhateverTmp = (float (*))data; } float out_rgbx[4 * TS] ALIGNED16; // Line buffer for CLUT LUTu histToneCurveThr; - if(toneCurveHistSize > 0) { - histToneCurveThr(toneCurveHistSize); + + if (toneCurveHistSize > 0) { + histToneCurveThr (toneCurveHistSize); histToneCurveThr.clear(); } @@ -3310,19 +3327,19 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer #pragma omp for schedule(dynamic) collapse(2) #endif - for(int ii = 0; ii < working->getHeight(); ii += TS) - for(int jj = 0; jj < working->getWidth(); jj += TS) { + for (int ii = 0; ii < working->getHeight(); ii += TS) + for (int jj = 0; jj < working->getWidth(); jj += TS) { istart = ii; jstart = jj; - tH = min(ii + TS, working->getHeight()); - tW = min(jj + TS, working->getWidth()); + tH = min (ii + TS, working->getHeight()); + tW = min (jj + TS, working->getWidth()); for (int i = istart, ti = 0; i < tH; i++, ti++) { for (int j = jstart, tj = 0; j < tW; j++, tj++) { - rtemp[ti * TS + tj] = working->r(i, j); - gtemp[ti * TS + tj] = working->g(i, j); - btemp[ti * TS + tj] = working->b(i, j); + rtemp[ti * TS + tj] = working->r (i, j); + gtemp[ti * TS + tj] = working->g (i, j); + btemp[ti * TS + tj] = working->b (i, j); } } @@ -3415,7 +3432,7 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer } if (dcpProf) { - dcpProf->step2ApplyTile(rtemp, gtemp, btemp, tW - jstart, tH - istart, TS, asIn); + dcpProf->step2ApplyTile (rtemp, gtemp, btemp, tW - jstart, tH - istart, TS, asIn); } for (int i = istart, ti = 0; i < tH; i++, ti++) { @@ -3438,7 +3455,7 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer } if (r > 65535 || g > 65535 || b > 65535) { - filmlike_clip(&r, &g, &b); + filmlike_clip (&r, &g, &b); } rtemp[ti * TS + tj] = r; @@ -3454,9 +3471,10 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer rtemp[ti * TS + tj] = tonecurve[ rtemp[ti * TS + tj] ]; gtemp[ti * TS + tj] = tonecurve[ gtemp[ti * TS + tj] ]; btemp[ti * TS + tj] = tonecurve[ btemp[ti * TS + tj] ]; - if(histToneCurveThr) { - int y = CLIP(lumimulf[0] * Color::gamma2curve[rtemp[ti * TS + tj]] + lumimulf[1] * Color::gamma2curve[gtemp[ti * TS + tj]] + lumimulf[2] * Color::gamma2curve[btemp[ti * TS + tj]]); - histToneCurveThr[y>>histToneCurveCompression]++; + + if (histToneCurveThr) { + int y = CLIP (lumimulf[0] * Color::gamma2curve[rtemp[ti * TS + tj]] + lumimulf[1] * Color::gamma2curve[gtemp[ti * TS + tj]] + lumimulf[2] * Color::gamma2curve[btemp[ti * TS + tj]]); + histToneCurveThr[y >> histToneCurveCompression]++; } } } @@ -3475,58 +3493,58 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer if (curveMode == ToneCurveParams::TC_MODE_STD) { // Standard for (int i = istart, ti = 0; i < tH; i++, ti++) { for (int j = jstart, tj = 0; j < tW; j++, tj++) { - const StandardToneCurve& userToneCurve = static_cast(customToneCurve1); - userToneCurve.Apply(rtemp[ti * TS + tj], gtemp[ti * TS + tj], btemp[ti * TS + tj]); + const StandardToneCurve& userToneCurve = static_cast (customToneCurve1); + userToneCurve.Apply (rtemp[ti * TS + tj], gtemp[ti * TS + tj], btemp[ti * TS + tj]); } } } else if (curveMode == ToneCurveParams::TC_MODE_FILMLIKE) { // Adobe like for (int i = istart, ti = 0; i < tH; i++, ti++) { for (int j = jstart, tj = 0; j < tW; j++, tj++) { - const AdobeToneCurve& userToneCurve = static_cast(customToneCurve1); - userToneCurve.Apply(rtemp[ti * TS + tj], gtemp[ti * TS + tj], btemp[ti * TS + tj]); + const AdobeToneCurve& userToneCurve = static_cast (customToneCurve1); + userToneCurve.Apply (rtemp[ti * TS + tj], gtemp[ti * TS + tj], btemp[ti * TS + tj]); } } } else if (curveMode == ToneCurveParams::TC_MODE_SATANDVALBLENDING) { // apply the curve on the saturation and value channels for (int i = istart, ti = 0; i < tH; i++, ti++) { for (int j = jstart, tj = 0; j < tW; j++, tj++) { - const SatAndValueBlendingToneCurve& userToneCurve = static_cast(customToneCurve1); - rtemp[ti * TS + tj] = CLIP(rtemp[ti * TS + tj]); - gtemp[ti * TS + tj] = CLIP(gtemp[ti * TS + tj]); - btemp[ti * TS + tj] = CLIP(btemp[ti * TS + tj]); - userToneCurve.Apply(rtemp[ti * TS + tj], gtemp[ti * TS + tj], btemp[ti * TS + tj]); + const SatAndValueBlendingToneCurve& userToneCurve = static_cast (customToneCurve1); + rtemp[ti * TS + tj] = CLIP (rtemp[ti * TS + tj]); + gtemp[ti * TS + tj] = CLIP (gtemp[ti * TS + tj]); + btemp[ti * TS + tj] = CLIP (btemp[ti * TS + tj]); + userToneCurve.Apply (rtemp[ti * TS + tj], gtemp[ti * TS + tj], btemp[ti * TS + tj]); } } } else if (curveMode == ToneCurveParams::TC_MODE_WEIGHTEDSTD) { // apply the curve to the rgb channels, weighted - const WeightedStdToneCurve& userToneCurve = static_cast(customToneCurve1); + const WeightedStdToneCurve& userToneCurve = static_cast (customToneCurve1); for (int i = istart, ti = 0; i < tH; i++, ti++) { for (int j = jstart, tj = 0; j < tW; j++, tj++) { - rtemp[ti * TS + tj] = CLIP(rtemp[ti * TS + tj]); - gtemp[ti * TS + tj] = CLIP(gtemp[ti * TS + tj]); - btemp[ti * TS + tj] = CLIP(btemp[ti * TS + tj]); - userToneCurve.Apply(rtemp[ti * TS + tj], gtemp[ti * TS + tj], btemp[ti * TS + tj]); + rtemp[ti * TS + tj] = CLIP (rtemp[ti * TS + tj]); + gtemp[ti * TS + tj] = CLIP (gtemp[ti * TS + tj]); + btemp[ti * TS + tj] = CLIP (btemp[ti * TS + tj]); + userToneCurve.Apply (rtemp[ti * TS + tj], gtemp[ti * TS + tj], btemp[ti * TS + tj]); } } } else if (curveMode == ToneCurveParams::TC_MODE_LUMINANCE) { // apply the curve to the luminance channel - const LuminanceToneCurve& userToneCurve = static_cast(customToneCurve1); + const LuminanceToneCurve& userToneCurve = static_cast (customToneCurve1); for (int i = istart, ti = 0; i < tH; i++, ti++) { for (int j = jstart, tj = 0; j < tW; j++, tj++) { - rtemp[ti * TS + tj] = CLIP(rtemp[ti * TS + tj]); - gtemp[ti * TS + tj] = CLIP(gtemp[ti * TS + tj]); - btemp[ti * TS + tj] = CLIP(btemp[ti * TS + tj]); - userToneCurve.Apply(rtemp[ti * TS + tj], gtemp[ti * TS + tj], btemp[ti * TS + tj]); + rtemp[ti * TS + tj] = CLIP (rtemp[ti * TS + tj]); + gtemp[ti * TS + tj] = CLIP (gtemp[ti * TS + tj]); + btemp[ti * TS + tj] = CLIP (btemp[ti * TS + tj]); + userToneCurve.Apply (rtemp[ti * TS + tj], gtemp[ti * TS + tj], btemp[ti * TS + tj]); } } } else if (curveMode == ToneCurveParams::TC_MODE_PERCEPTUAL) { // apply curve while keeping color appearance constant - const PerceptualToneCurve& userToneCurve = static_cast(customToneCurve1); + const PerceptualToneCurve& userToneCurve = static_cast (customToneCurve1); for (int i = istart, ti = 0; i < tH; i++, ti++) { for (int j = jstart, tj = 0; j < tW; j++, tj++) { - rtemp[ti * TS + tj] = CLIP(rtemp[ti * TS + tj]); - gtemp[ti * TS + tj] = CLIP(gtemp[ti * TS + tj]); - btemp[ti * TS + tj] = CLIP(btemp[ti * TS + tj]); - userToneCurve.Apply(rtemp[ti * TS + tj], gtemp[ti * TS + tj], btemp[ti * TS + tj], ptc1ApplyState); + rtemp[ti * TS + tj] = CLIP (rtemp[ti * TS + tj]); + gtemp[ti * TS + tj] = CLIP (gtemp[ti * TS + tj]); + btemp[ti * TS + tj] = CLIP (btemp[ti * TS + tj]); + userToneCurve.Apply (rtemp[ti * TS + tj], gtemp[ti * TS + tj], btemp[ti * TS + tj], ptc1ApplyState); } } } @@ -3546,46 +3564,46 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer if (curveMode2 == ToneCurveParams::TC_MODE_STD) { // Standard for (int i = istart, ti = 0; i < tH; i++, ti++) { for (int j = jstart, tj = 0; j < tW; j++, tj++) { - const StandardToneCurve& userToneCurve = static_cast(customToneCurve2); - userToneCurve.Apply(rtemp[ti * TS + tj], gtemp[ti * TS + tj], btemp[ti * TS + tj]); + const StandardToneCurve& userToneCurve = static_cast (customToneCurve2); + userToneCurve.Apply (rtemp[ti * TS + tj], gtemp[ti * TS + tj], btemp[ti * TS + tj]); } } } else if (curveMode2 == ToneCurveParams::TC_MODE_FILMLIKE) { // Adobe like for (int i = istart, ti = 0; i < tH; i++, ti++) { for (int j = jstart, tj = 0; j < tW; j++, tj++) { - const AdobeToneCurve& userToneCurve = static_cast(customToneCurve2); - userToneCurve.Apply(rtemp[ti * TS + tj], gtemp[ti * TS + tj], btemp[ti * TS + tj]); + const AdobeToneCurve& userToneCurve = static_cast (customToneCurve2); + userToneCurve.Apply (rtemp[ti * TS + tj], gtemp[ti * TS + tj], btemp[ti * TS + tj]); } } } else if (curveMode2 == ToneCurveParams::TC_MODE_SATANDVALBLENDING) { // apply the curve on the saturation and value channels for (int i = istart, ti = 0; i < tH; i++, ti++) { for (int j = jstart, tj = 0; j < tW; j++, tj++) { - const SatAndValueBlendingToneCurve& userToneCurve = static_cast(customToneCurve2); - userToneCurve.Apply(rtemp[ti * TS + tj], gtemp[ti * TS + tj], btemp[ti * TS + tj]); + const SatAndValueBlendingToneCurve& userToneCurve = static_cast (customToneCurve2); + userToneCurve.Apply (rtemp[ti * TS + tj], gtemp[ti * TS + tj], btemp[ti * TS + tj]); } } } else if (curveMode2 == ToneCurveParams::TC_MODE_WEIGHTEDSTD) { // apply the curve to the rgb channels, weighted - const WeightedStdToneCurve& userToneCurve = static_cast(customToneCurve2); + const WeightedStdToneCurve& userToneCurve = static_cast (customToneCurve2); for (int i = istart, ti = 0; i < tH; i++, ti++) { for (int j = jstart, tj = 0; j < tW; j++, tj++) { - userToneCurve.Apply(rtemp[ti * TS + tj], gtemp[ti * TS + tj], btemp[ti * TS + tj]); + userToneCurve.Apply (rtemp[ti * TS + tj], gtemp[ti * TS + tj], btemp[ti * TS + tj]); } } } else if (curveMode2 == ToneCurveParams::TC_MODE_LUMINANCE) { // apply the curve to the luminance channel - const LuminanceToneCurve& userToneCurve = static_cast(customToneCurve2); + const LuminanceToneCurve& userToneCurve = static_cast (customToneCurve2); for (int i = istart, ti = 0; i < tH; i++, ti++) { for (int j = jstart, tj = 0; j < tW; j++, tj++) { - userToneCurve.Apply(rtemp[ti * TS + tj], gtemp[ti * TS + tj], btemp[ti * TS + tj]); + userToneCurve.Apply (rtemp[ti * TS + tj], gtemp[ti * TS + tj], btemp[ti * TS + tj]); } } } else if (curveMode2 == ToneCurveParams::TC_MODE_PERCEPTUAL) { // apply curve while keeping color appearance constant - const PerceptualToneCurve& userToneCurve = static_cast(customToneCurve2); + const PerceptualToneCurve& userToneCurve = static_cast (customToneCurve2); for (int i = istart, ti = 0; i < tH; i++, ti++) { for (int j = jstart, tj = 0; j < tW; j++, tj++) { - userToneCurve.Apply(rtemp[ti * TS + tj], gtemp[ti * TS + tj], btemp[ti * TS + tj], ptc2ApplyState); + userToneCurve.Apply (rtemp[ti * TS + tj], gtemp[ti * TS + tj], btemp[ti * TS + tj], ptc2ApplyState); } } } @@ -3646,9 +3664,9 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer float y = toxyz[1][0] * r + toxyz[1][1] * g + toxyz[1][2] * b; float z = toxyz[2][0] * r + toxyz[2][1] * g + toxyz[2][2] * b; - float fx = x < MAXVALF ? Color::cachef[x] : 327.68f * std::cbrt(x / MAXVALF); - float fy = y < MAXVALF ? Color::cachef[y] : 327.68f * std::cbrt(y / MAXVALF); - float fz = z < MAXVALF ? Color::cachef[z] : 327.68f * std::cbrt(z / MAXVALF); + float fx = x < MAXVALF ? Color::cachef[x] : 327.68f * std::cbrt (x / MAXVALF); + float fy = y < MAXVALF ? Color::cachef[y] : 327.68f * std::cbrt (y / MAXVALF); + float fz = z < MAXVALF ? Color::cachef[z] : 327.68f * std::cbrt (z / MAXVALF); float a_1 = 500.0f * (fx - fy); float b_1 = 200.0f * (fy - fz); @@ -3672,19 +3690,19 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer // Luminosity after // only Luminance in Lab float newy = toxyz[1][0] * r + toxyz[1][1] * g + toxyz[1][2] * b; - float newfy = newy < MAXVALF ? Color::cachef[newy] : 327.68f * std::cbrt(newy / MAXVALF); + float newfy = newy < MAXVALF ? Color::cachef[newy] : 327.68f * std::cbrt (newy / MAXVALF); float L_2 = 116.0f * newfy - 5242.88f; //gamut control - if(settings->rgbcurveslumamode_gamut) { + if (settings->rgbcurveslumamode_gamut) { float Lpro = L_2 / 327.68f; - float Chpro = sqrtf(SQR(a_1) + SQR(b_1)) / 327.68f; + float Chpro = sqrtf (SQR (a_1) + SQR (b_1)) / 327.68f; float HH = NAN; // we set HH to NAN, because then it will be calculated in Color::gamutLchonly only if needed // float HH = xatan2f(b_1, a_1); // According to mathematical laws we can get the sin and cos of HH by simple operations even if we don't calculate HH float2 sincosval; - if(Chpro == 0.0f) { + if (Chpro == 0.0f) { sincosval.y = 1.0f; sincosval.x = 0.0f; } else { @@ -3696,17 +3714,17 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer bool neg = false; bool more_rgb = false; //gamut control : Lab values are in gamut - Color::gamutLchonly(HH, sincosval, Lpro, Chpro, rtemp[ti * TS + tj], gtemp[ti * TS + tj], btemp[ti * TS + tj], wip, highlight, 0.15f, 0.96f, neg, more_rgb); + Color::gamutLchonly (HH, sincosval, Lpro, Chpro, rtemp[ti * TS + tj], gtemp[ti * TS + tj], btemp[ti * TS + tj], wip, highlight, 0.15f, 0.96f, neg, more_rgb); #else //gamut control : Lab values are in gamut - Color::gamutLchonly(HH, sincosval, Lpro, Chpro, rtemp[ti * TS + tj], gtemp[ti * TS + tj], btemp[ti * TS + tj], wip, highlight, 0.15f, 0.96f); + Color::gamutLchonly (HH, sincosval, Lpro, Chpro, rtemp[ti * TS + tj], gtemp[ti * TS + tj], btemp[ti * TS + tj], wip, highlight, 0.15f, 0.96f); #endif - //end of gamut control + //end of gamut control } else { float x_, y_, z_; //calculate RGB with L_2 and old value of a and b - Color::Lab2XYZ(L_2, a_1, b_1, x_, y_, z_) ; - Color::xyz2rgb(x_, y_, z_, rtemp[ti * TS + tj], gtemp[ti * TS + tj], btemp[ti * TS + tj], wip); + Color::Lab2XYZ (L_2, a_1, b_1, x_, y_, z_) ; + Color::xyz2rgb (x_, y_, z_, rtemp[ti * TS + tj], gtemp[ti * TS + tj], btemp[ti * TS + tj], wip); } } } @@ -3717,7 +3735,7 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer for (int i = istart, ti = 0; i < tH; i++, ti++) { for (int j = jstart, tj = 0; j < tW; j++, tj++) { float h, s, v; - Color::rgb2hsv(rtemp[ti * TS + tj], gtemp[ti * TS + tj], btemp[ti * TS + tj], h, s, v); + Color::rgb2hsv (rtemp[ti * TS + tj], gtemp[ti * TS + tj], btemp[ti * TS + tj], h, s, v); editWhateverTmp[ti * TS + tj] = h; } } @@ -3732,10 +3750,10 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer float g = gtemp[ti * TS + tj]; float b = btemp[ti * TS + tj]; float h, s, v; - Color::rgb2hsv(r, g, b, h, s, v); + Color::rgb2hsv (r, g, b, h, s, v); if (sat > 0) { - s = (1.f - satby100) * s + satby100 * (1.f - SQR(SQR(1.f - min(s, 1.0f)))); + s = (1.f - satby100) * s + satby100 * (1.f - SQR (SQR (1.f - min (s, 1.0f)))); if (s < 0.f) { s = 0.f; @@ -3746,7 +3764,7 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer //HSV equalizer if (hCurveEnabled) { - h = (hCurve->getVal(double(h)) - 0.5) * 2.f + h; + h = (hCurve->getVal (double (h)) - 0.5) * 2.f + h; if (h > 1.0f) { h -= 1.0f; @@ -3757,10 +3775,10 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer if (sCurveEnabled) { //shift saturation - float satparam = (sCurve->getVal(double(h)) - 0.5) * 2; + float satparam = (sCurve->getVal (double (h)) - 0.5) * 2; if (satparam > 0.00001f) { - s = (1.f - satparam) * s + satparam * (1.f - SQR(1.f - min(s, 1.0f))); + s = (1.f - satparam) * s + satparam * (1.f - SQR (1.f - min (s, 1.0f))); if (s < 0.f) { s = 0.f; @@ -3777,11 +3795,11 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer } //shift value - float valparam = vCurve->getVal((double)h) - 0.5f; - valparam *= (1.f - SQR(SQR(1.f - min(s, 1.0f)))); + float valparam = vCurve->getVal ((double)h) - 0.5f; + valparam *= (1.f - SQR (SQR (1.f - min (s, 1.0f)))); if (valparam > 0.00001f) { - v = (1.f - valparam) * v + valparam * (1.f - SQR(1.f - min(v, 1.0f))); // SQR (SQR to increase action and avoid artefacts + v = (1.f - valparam) * v + valparam * (1.f - SQR (1.f - min (v, 1.0f))); // SQR (SQR to increase action and avoid artefacts if (v < 0) { v = 0; @@ -3794,7 +3812,7 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer } - Color::hsv2rgb(h, s, v, rtemp[ti * TS + tj], gtemp[ti * TS + tj], btemp[ti * TS + tj]); + Color::hsv2rgb (h, s, v, rtemp[ti * TS + tj], gtemp[ti * TS + tj], btemp[ti * TS + tj]); } } } @@ -3805,12 +3823,12 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer float r = rtemp[ti * TS + tj]; float g = gtemp[ti * TS + tj]; - if(r == 0.0f || g == 0.0f) { + if (r == 0.0f || g == 0.0f) { float b = btemp[ti * TS + tj]; float h, s, v; - Color::rgb2hsv(r, g, b, h, s, v); + Color::rgb2hsv (r, g, b, h, s, v); s *= 0.99f; - Color::hsv2rgb(h, s, v, rtemp[ti * TS + tj], gtemp[ti * TS + tj], btemp[ti * TS + tj]); + Color::hsv2rgb (h, s, v, rtemp[ti * TS + tj], gtemp[ti * TS + tj], btemp[ti * TS + tj]); } } } @@ -3822,7 +3840,7 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer float reducac = 0.4f; int preser = 0; - if(params->colorToning.lumamode) { + if (params->colorToning.lumamode) { preser = 1; } @@ -3836,14 +3854,14 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer iplow = (float)ctColorCurve.low; iphigh = (float)ctColorCurve.high; //2 colours - ctColorCurve.getVal(iphigh, xh, yh, zh); - ctColorCurve.getVal(iplow, xl, yl, zl); + ctColorCurve.getVal (iphigh, xh, yh, zh); + ctColorCurve.getVal (iplow, xl, yl, zl); - Color::xyz2rgb(xh, yh, zh, rh, gh, bh, wip); - Color::xyz2rgb(xl, yl, zl, rl, gl, bl, wip); + Color::xyz2rgb (xh, yh, zh, rh, gh, bh, wip); + Color::xyz2rgb (xl, yl, zl, rl, gl, bl, wip); //reteave rgb value with s and l =1 - retreavergb(rl, gl, bl); - retreavergb(rh, gh, bh); + retreavergb (rl, gl, bl); + retreavergb (rh, gh, bh); //printf("rl=%f gl=%f bl=%f\n",rl,gl,bl); for (int i = istart, ti = 0; i < tH; i++, ti++) { @@ -3883,7 +3901,7 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer int preser = 0; //bool execbal = params->colorToning.method=="Splitbal"; - if(params->colorToning.lumamode) { + if (params->colorToning.lumamode) { preser = 1; } @@ -3899,16 +3917,16 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer float lumafter = 0.299f * ro + 0.587f * go + 0.114f * bo; float preserv = 1.f; - if(preser == 1) { + if (preser == 1) { preserv = lumbefore / lumafter; } ro *= preserv; go *= preserv; bo *= preserv; - ro = CLIP(ro); - go = CLIP(go); - bo = CLIP(bo); + ro = CLIP (ro); + go = CLIP (go); + bo = CLIP (bo); rtemp[ti * TS + tj] = ro; gtemp[ti * TS + tj] = go; btemp[ti * TS + tj] = bo; @@ -3934,13 +3952,13 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer metchrom = 3; } - if(metchrom == 3) { + if (metchrom == 3) { twocol = false; } float iplow = 0.f, iphigh = 0.f; - if(!twocol) { + if (!twocol) { iplow = (float)ctColorCurve.low; iphigh = (float)ctColorCurve.high; } @@ -3967,13 +3985,13 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer float b = btemp[ti * TS + tj]; float ro, go, bo; labtoning (r, g, b, ro, go, bo, algm, metchrom, twoc, satLimit, satLimitOpacity, ctColorCurve, ctOpacityCurve, clToningcurve, cl2Toningcurve, iplow, iphigh, wp, wip); - rtemp[ti * TS + tj] = CLIP(ro); //I used CLIP because there is a little bug in gamutLchonly that return 65536.ii intead of 65535 ==> crash - gtemp[ti * TS + tj] = CLIP(go); - btemp[ti * TS + tj] = CLIP(bo); + rtemp[ti * TS + tj] = CLIP (ro); //I used CLIP because there is a little bug in gamutLchonly that return 65536.ii intead of 65535 ==> crash + gtemp[ti * TS + tj] = CLIP (go); + btemp[ti * TS + tj] = CLIP (bo); } } } - } else if (params->colorToning.method.substr(0, 3) == "RGB" && opautili) { + } else if (params->colorToning.method.substr (0, 3) == "RGB" && opautili) { // color toning for (int i = istart, ti = 0; i < tH; i++, ti++) { for (int j = jstart, tj = 0; j < tW; j++, tj++) { @@ -3984,28 +4002,28 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer // Luminance = (0.299f*r + 0.587f*g + 0.114f*b) float h, s, l; - Color::rgb2hsl(r, g, b, h, s, l); + Color::rgb2hsl (r, g, b, h, s, l); - float l_ = Color::gamma_srgb(l * 65535.f) / 65535.f; + float l_ = Color::gamma_srgb (l * 65535.f) / 65535.f; // get the opacity and tweak it to preserve saturated colors float opacity; - if(ctOpacityCurve) { - opacity = (1.f - min(s / satLimit, 1.f) * (1.f - satLimitOpacity)) * ctOpacityCurve.lutOpacityCurve[l_ * 500.f]; + if (ctOpacityCurve) { + opacity = (1.f - min (s / satLimit, 1.f) * (1.f - satLimitOpacity)) * ctOpacityCurve.lutOpacityCurve[l_ * 500.f]; } - if(!ctOpacityCurve) { + if (!ctOpacityCurve) { opacity = 0.f; } float r2, g2, b2; - ctColorCurve.getVal(l_, r2, g2, b2); // get the color from the color curve + ctColorCurve.getVal (l_, r2, g2, b2); // get the color from the color curve float h2, s2, l2; - Color::rgb2hsl(r2, g2, b2, h2, s2, l2); // transform this new color to hsl + Color::rgb2hsl (r2, g2, b2, h2, s2, l2); // transform this new color to hsl - Color::hsl2rgb(h2, s + ((1.f - s) * (1.f - l) * 0.7f), l, r2, g2, b2); + Color::hsl2rgb (h2, s + ((1.f - s) * (1.f - l) * 0.7f), l, r2, g2, b2); rtemp[ti * TS + tj] = r + (r2 - r) * opacity; // merge the color to the old color, depending on the opacity gtemp[ti * TS + tj] = g + (g2 - g) * opacity; @@ -4029,53 +4047,53 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer for (int j = jstart, tj = 0; j < tW; j++, tj++) { float X, Y, Z, L, aa, bb; //rgb=>lab - Color::rgbxyz(rtemp[ti * TS + tj], gtemp[ti * TS + tj], btemp[ti * TS + tj], X, Y, Z, wp); + Color::rgbxyz (rtemp[ti * TS + tj], gtemp[ti * TS + tj], btemp[ti * TS + tj], X, Y, Z, wp); //convert Lab - Color::XYZ2Lab(X, Y, Z, L, aa, bb); + Color::XYZ2Lab (X, Y, Z, L, aa, bb); //end rgb=>lab - float HH = xatan2f(bb, aa); // HH hue in -3.141 +3.141 + float HH = xatan2f (bb, aa); // HH hue in -3.141 +3.141 - editWhateverTmp[ti * TS + tj] = float(Color::huelab_to_huehsv2(HH)); + editWhateverTmp[ti * TS + tj] = float (Color::huelab_to_huehsv2 (HH)); } } } //black and white - if(blackwhite) { + if (blackwhite) { if (hasToneCurvebw1) { if (beforeCurveMode == BlackWhiteParams::TC_MODE_STD_BW) { // Standard for (int i = istart, ti = 0; i < tH; i++, ti++) { for (int j = jstart, tj = 0; j < tW; j++, tj++) { - const StandardToneCurvebw& userToneCurvebw = static_cast(customToneCurvebw1); - userToneCurvebw.Apply(rtemp[ti * TS + tj], gtemp[ti * TS + tj], btemp[ti * TS + tj]); + const StandardToneCurvebw& userToneCurvebw = static_cast (customToneCurvebw1); + userToneCurvebw.Apply (rtemp[ti * TS + tj], gtemp[ti * TS + tj], btemp[ti * TS + tj]); } } } else if (beforeCurveMode == BlackWhiteParams::TC_MODE_FILMLIKE_BW) { // Adobe like for (int i = istart, ti = 0; i < tH; i++, ti++) { for (int j = jstart, tj = 0; j < tW; j++, tj++) { - const AdobeToneCurvebw& userToneCurvebw = static_cast(customToneCurvebw1); - userToneCurvebw.Apply(rtemp[ti * TS + tj], gtemp[ti * TS + tj], btemp[ti * TS + tj]); + const AdobeToneCurvebw& userToneCurvebw = static_cast (customToneCurvebw1); + userToneCurvebw.Apply (rtemp[ti * TS + tj], gtemp[ti * TS + tj], btemp[ti * TS + tj]); } } } else if (beforeCurveMode == BlackWhiteParams::TC_MODE_SATANDVALBLENDING_BW) { // apply the curve on the saturation and value channels for (int i = istart, ti = 0; i < tH; i++, ti++) { for (int j = jstart, tj = 0; j < tW; j++, tj++) { - const SatAndValueBlendingToneCurvebw& userToneCurvebw = static_cast(customToneCurvebw1); - rtemp[ti * TS + tj] = CLIP(rtemp[ti * TS + tj]); - gtemp[ti * TS + tj] = CLIP(gtemp[ti * TS + tj]); - btemp[ti * TS + tj] = CLIP(btemp[ti * TS + tj]); - userToneCurvebw.Apply(rtemp[ti * TS + tj], gtemp[ti * TS + tj], btemp[ti * TS + tj]); + const SatAndValueBlendingToneCurvebw& userToneCurvebw = static_cast (customToneCurvebw1); + rtemp[ti * TS + tj] = CLIP (rtemp[ti * TS + tj]); + gtemp[ti * TS + tj] = CLIP (gtemp[ti * TS + tj]); + btemp[ti * TS + tj] = CLIP (btemp[ti * TS + tj]); + userToneCurvebw.Apply (rtemp[ti * TS + tj], gtemp[ti * TS + tj], btemp[ti * TS + tj]); } } } else if (beforeCurveMode == BlackWhiteParams::TC_MODE_WEIGHTEDSTD_BW) { // apply the curve to the rgb channels, weighted for (int i = istart, ti = 0; i < tH; i++, ti++) { for (int j = jstart, tj = 0; j < tW; j++, tj++) { - const WeightedStdToneCurvebw& userToneCurvebw = static_cast(customToneCurvebw1); - rtemp[ti * TS + tj] = CLIP(rtemp[ti * TS + tj]); - gtemp[ti * TS + tj] = CLIP(gtemp[ti * TS + tj]); - btemp[ti * TS + tj] = CLIP(btemp[ti * TS + tj]); + const WeightedStdToneCurvebw& userToneCurvebw = static_cast (customToneCurvebw1); + rtemp[ti * TS + tj] = CLIP (rtemp[ti * TS + tj]); + gtemp[ti * TS + tj] = CLIP (gtemp[ti * TS + tj]); + btemp[ti * TS + tj] = CLIP (btemp[ti * TS + tj]); - userToneCurvebw.Apply(rtemp[ti * TS + tj], gtemp[ti * TS + tj], btemp[ti * TS + tj]); + userToneCurvebw.Apply (rtemp[ti * TS + tj], gtemp[ti * TS + tj], btemp[ti * TS + tj]); } } } @@ -4104,20 +4122,25 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer // -------------------------------------------------- #ifndef __SSE2__ + //gamma correction: pseudo TRC curve if (hasgammabw) { Color::trcGammaBW (r, g, b, gammabwr, gammabwg, gammabwb); } + #endif rtemp[ti * TS + tj] = r; gtemp[ti * TS + tj] = g; btemp[ti * TS + tj] = b; } + #ifdef __SSE2__ + if (hasgammabw) { //gamma correction: pseudo TRC curve Color::trcGammaBWRow (&rtemp[ti * TS], >emp[ti * TS], &btemp[ti * TS], tW - jstart, gammabwr, gammabwg, gammabwb); } + #endif } @@ -4126,15 +4149,15 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer for (int j = jstart, tj = 0; j < tW; j++, tj++) { //rgb => xyz float X, Y, Z; - Color::rgbxyz(rtemp[ti * TS + tj], gtemp[ti * TS + tj], btemp[ti * TS + tj], X, Y, Z, wp); + Color::rgbxyz (rtemp[ti * TS + tj], gtemp[ti * TS + tj], btemp[ti * TS + tj], X, Y, Z, wp); //xyz => Lab float L, aa, bb; - Color::XYZ2Lab(X, Y, Z, L, aa, bb); - float CC = sqrtf(SQR(aa) + SQR(bb)) / 327.68f; //CC chromaticity in 0..180 or more - float HH = xatan2f(bb, aa); // HH hue in -3.141 +3.141 + Color::XYZ2Lab (X, Y, Z, L, aa, bb); + float CC = sqrtf (SQR (aa) + SQR (bb)) / 327.68f; //CC chromaticity in 0..180 or more + float HH = xatan2f (bb, aa); // HH hue in -3.141 +3.141 float2 sincosval; - if(CC == 0.0f) { + if (CC == 0.0f) { sincosval.y = 1.f; sincosval.x = 0.0f; } else { @@ -4144,17 +4167,18 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer if (bwlCurveEnabled) { L /= 32768.f; - double hr = Color::huelab_to_huehsv2(HH); - float valparam = float((bwlCurve->getVal(hr) - 0.5f) * 2.0f); //get l_r=f(H) + double hr = Color::huelab_to_huehsv2 (HH); + float valparam = float ((bwlCurve->getVal (hr) - 0.5f) * 2.0f); //get l_r=f(H) float kcc = (CC / 70.f); //take Chroma into account...70 "middle" of chromaticity (arbitrary and simple), one can imagine other algorithme //reduct action for low chroma and increase action for high chroma valparam *= kcc; - if(valparam > 0.f) { - L = (1.f - valparam) * L + valparam * (1.f - SQR(SQR(SQR(SQR(1.f - min(L, 1.0f)))))); // SQR (SQR((SQR) to increase action in low light + if (valparam > 0.f) { + L = (1.f - valparam) * L + valparam * (1.f - SQR (SQR (SQR (SQR (1.f - min (L, 1.0f)))))); // SQR (SQR((SQR) to increase action in low light } else { L *= (1.f + valparam); //for negative } + L *= 32768.f; } @@ -4164,29 +4188,34 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer bool neg = false; bool more_rgb = false; //gamut control : Lab values are in gamut - Color::gamutLchonly(HH, sincosval, L, CC, RR, GG, BB, wip, highlight, 0.15f, 0.96f, neg, more_rgb); + Color::gamutLchonly (HH, sincosval, L, CC, RR, GG, BB, wip, highlight, 0.15f, 0.96f, neg, more_rgb); #else //gamut control : Lab values are in gamut - Color::gamutLchonly(HH, sincosval, L, CC, RR, GG, BB, wip, highlight, 0.15f, 0.96f); + Color::gamutLchonly (HH, sincosval, L, CC, RR, GG, BB, wip, highlight, 0.15f, 0.96f); #endif L *= 327.68f; //convert l => rgb - Color::L2XYZ(L, X, Y, Z); + Color::L2XYZ (L, X, Y, Z); float newRed; // We use the red channel for bw - Color::xyz2r(X, Y, Z, newRed, wip); + Color::xyz2r (X, Y, Z, newRed, wip); rtemp[ti * TS + tj] = gtemp[ti * TS + tj] = btemp[ti * TS + tj] = newRed; #ifndef __SSE2__ + if (hasgammabw) { //gamma correction: pseudo TRC curve Color::trcGammaBW (rtemp[ti * TS + tj], gtemp[ti * TS + tj], btemp[ti * TS + tj], gammabwr, gammabwg, gammabwb); } + #endif } + #ifdef __SSE2__ + if (hasgammabw) { //gamma correction: pseudo TRC curve Color::trcGammaBWRow (&rtemp[ti * TS], >emp[ti * TS], &btemp[ti * TS], tW - jstart, gammabwr, gammabwg, gammabwb); } + #endif } } @@ -4205,19 +4234,19 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer #ifdef __SSE2__ for (; j < tW - 3; j += 4, tj += 4) { - vfloat sourceR = LVF(rtemp[ti * TS + tj]); - vfloat sourceG = LVF(gtemp[ti * TS + tj]); - vfloat sourceB = LVF(btemp[ti * TS + tj]); + vfloat sourceR = LVF (rtemp[ti * TS + tj]); + vfloat sourceG = LVF (gtemp[ti * TS + tj]); + vfloat sourceB = LVF (btemp[ti * TS + tj]); vfloat x; vfloat y; vfloat z; - Color::rgbxyz(sourceR, sourceG, sourceB, x, y, z, v_work2xyz); - Color::xyz2rgb(x, y, z, sourceR, sourceG, sourceB, v_xyz2clut); + Color::rgbxyz (sourceR, sourceG, sourceB, x, y, z, v_work2xyz); + Color::xyz2rgb (x, y, z, sourceR, sourceG, sourceB, v_xyz2clut); - STVF(rtemp[ti * TS + tj], sourceR); - STVF(gtemp[ti * TS + tj], sourceG); - STVF(btemp[ti * TS + tj], sourceB); + STVF (rtemp[ti * TS + tj], sourceR); + STVF (gtemp[ti * TS + tj], sourceG); + STVF (btemp[ti * TS + tj], sourceB); } #endif @@ -4228,8 +4257,8 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer float &sourceB = btemp[ti * TS + tj]; float x, y, z; - Color::rgbxyz( sourceR, sourceG, sourceB, x, y, z, wprof ); - Color::xyz2rgb(x, y, z, sourceR, sourceG, sourceB, xyz2clut); + Color::rgbxyz ( sourceR, sourceG, sourceB, x, y, z, wprof ); + Color::xyz2rgb (x, y, z, sourceR, sourceG, sourceB, xyz2clut); } } @@ -4239,15 +4268,15 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer float &sourceB = btemp[ti * TS + tj]; // Apply gamma sRGB (default RT) - sourceR = Color::gamma_srgbclipped(sourceR); - sourceG = Color::gamma_srgbclipped(sourceG); - sourceB = Color::gamma_srgbclipped(sourceB); + sourceR = Color::gamma_srgbclipped (sourceR); + sourceG = Color::gamma_srgbclipped (sourceG); + sourceB = Color::gamma_srgbclipped (sourceB); } const std::size_t line_offset = ti * TS; - hald_clut->getRGB( + hald_clut->getRGB ( film_simulation_strength, - std::min(TS, tW - jstart), + std::min (TS, tW - jstart), rtemp + line_offset, gtemp + line_offset, btemp + line_offset, @@ -4260,9 +4289,9 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer float &sourceB = btemp[ti * TS + tj]; // Apply inverse gamma sRGB - sourceR = Color::igamma_srgb(out_rgbx[tj * 4 + 0]); - sourceG = Color::igamma_srgb(out_rgbx[tj * 4 + 1]); - sourceB = Color::igamma_srgb(out_rgbx[tj * 4 + 2]); + sourceR = Color::igamma_srgb (out_rgbx[tj * 4 + 0]); + sourceG = Color::igamma_srgb (out_rgbx[tj * 4 + 1]); + sourceB = Color::igamma_srgb (out_rgbx[tj * 4 + 2]); } if (!clutAndWorkingProfilesAreSame) { @@ -4273,19 +4302,19 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer #ifdef __SSE2__ for (; j < tW - 3; j += 4, tj += 4) { - vfloat sourceR = LVF(rtemp[ti * TS + tj]); - vfloat sourceG = LVF(gtemp[ti * TS + tj]); - vfloat sourceB = LVF(btemp[ti * TS + tj]); + vfloat sourceR = LVF (rtemp[ti * TS + tj]); + vfloat sourceG = LVF (gtemp[ti * TS + tj]); + vfloat sourceB = LVF (btemp[ti * TS + tj]); vfloat x; vfloat y; vfloat z; - Color::rgbxyz(sourceR, sourceG, sourceB, x, y, z, v_clut2xyz); - Color::xyz2rgb(x, y, z, sourceR, sourceG, sourceB, v_xyz2work); + Color::rgbxyz (sourceR, sourceG, sourceB, x, y, z, v_clut2xyz); + Color::xyz2rgb (x, y, z, sourceR, sourceG, sourceB, v_xyz2work); - STVF(rtemp[ti * TS + tj], sourceR); - STVF(gtemp[ti * TS + tj], sourceG); - STVF(btemp[ti * TS + tj], sourceB); + STVF (rtemp[ti * TS + tj], sourceR); + STVF (gtemp[ti * TS + tj], sourceG); + STVF (btemp[ti * TS + tj], sourceB); } #endif @@ -4296,8 +4325,8 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer float &sourceB = btemp[ti * TS + tj]; float x, y, z; - Color::rgbxyz(sourceR, sourceG, sourceB, x, y, z, clut2xyz); - Color::xyz2rgb( x, y, z, sourceR, sourceG, sourceB, wiprof ); + Color::rgbxyz (sourceR, sourceG, sourceB, x, y, z, clut2xyz); + Color::xyz2rgb ( x, y, z, sourceR, sourceG, sourceB, wiprof ); } } } @@ -4311,11 +4340,11 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer // filling the pipette buffer by the content of the temp pipette buffers if (editImgFloat) { - editImgFloat->r(i, j) = editIFloatTmpR[ti * TS + tj]; - editImgFloat->g(i, j) = editIFloatTmpG[ti * TS + tj]; - editImgFloat->b(i, j) = editIFloatTmpB[ti * TS + tj]; + editImgFloat->r (i, j) = editIFloatTmpR[ti * TS + tj]; + editImgFloat->g (i, j) = editIFloatTmpG[ti * TS + tj]; + editImgFloat->b (i, j) = editIFloatTmpB[ti * TS + tj]; } else if (editWhatever) { - editWhatever->v(i, j) = editWhateverTmp[ti * TS + tj]; + editWhatever->v (i, j) = editWhateverTmp[ti * TS + tj]; } float r = rtemp[ti * TS + tj]; @@ -4328,9 +4357,9 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer float fx, fy, fz; - fx = (x < 65535.0f ? Color::cachef[x] : 327.68f * std::cbrt(x / MAXVALF)); - fy = (y < 65535.0f ? Color::cachef[y] : 327.68f * std::cbrt(y / MAXVALF)); - fz = (z < 65535.0f ? Color::cachef[z] : 327.68f * std::cbrt(z / MAXVALF)); + fx = (x < 65535.0f ? Color::cachef[x] : 327.68f * std::cbrt (x / MAXVALF)); + fy = (y < 65535.0f ? Color::cachef[y] : 327.68f * std::cbrt (y / MAXVALF)); + fz = (z < 65535.0f ? Color::cachef[z] : 327.68f * std::cbrt (z / MAXVALF)); lab->L[i][j] = (116.0f * fy - 5242.88f); //5242.88=16.0*327.68; lab->a[i][j] = (500.0f * (fx - fy) ); @@ -4359,22 +4388,22 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer for (int j = jstart, tj = 0; j < tW; j++, tj++) { // filling the pipette buffer by the content of the temp pipette buffers if (editImgFloat) { - editImgFloat->r(i, j) = editIFloatTmpR[ti * TS + tj]; - editImgFloat->g(i, j) = editIFloatTmpG[ti * TS + tj]; - editImgFloat->b(i, j) = editIFloatTmpB[ti * TS + tj]; + editImgFloat->r (i, j) = editIFloatTmpR[ti * TS + tj]; + editImgFloat->g (i, j) = editIFloatTmpG[ti * TS + tj]; + editImgFloat->b (i, j) = editIFloatTmpB[ti * TS + tj]; } else if (editWhatever) { - editWhatever->v(i, j) = editWhateverTmp[ti * TS + tj]; + editWhatever->v (i, j) = editWhateverTmp[ti * TS + tj]; } - tmpImage->r(i, j) = rtemp[ti * TS + tj]; - tmpImage->g(i, j) = gtemp[ti * TS + tj]; - tmpImage->b(i, j) = btemp[ti * TS + tj]; + tmpImage->r (i, j) = rtemp[ti * TS + tj]; + tmpImage->g (i, j) = gtemp[ti * TS + tj]; + tmpImage->b (i, j) = btemp[ti * TS + tj]; } } } } - free(buffer); + free (buffer); if (editIFloatBuffer) { free (editIFloatBuffer); @@ -4383,13 +4412,14 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer if (editWhateverBuffer) { free (editWhateverBuffer); } + #ifdef _OPENMP -#pragma omp critical -{ - if(toneCurveHistSize > 0) { - histToneCurve += histToneCurveThr; - } -} + #pragma omp critical + { + if (toneCurveHistSize > 0) { + histToneCurve += histToneCurveThr; + } + } #endif // _OPENMP } @@ -4412,9 +4442,9 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer for (int i = 0; i < tH; i++) { for (int j = 0; j < tW; j++) { - nr += tmpImage->r(i, j); - ng += tmpImage->g(i, j); - nb += tmpImage->b(i, j); + nr += tmpImage->r (i, j); + ng += tmpImage->g (i, j); + nb += tmpImage->b (i, j); } } @@ -4423,9 +4453,9 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer double kng = srgb / ng; double knb = srgb / nb; double sk = knr + kng + knb; - autor = (float)(100.0 * knr / sk); - autog = (float)(100.0 * kng / sk); - autob = (float)(100.0 * knb / sk); + autor = (float) (100.0 * knr / sk); + autog = (float) (100.0 * kng / sk); + autob = (float) (100.0 * knb / sk); } @@ -4442,9 +4472,9 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer } float filcor; - Color::computeBWMixerConstants(params->blackwhite.setting, params->blackwhite.filter, params->blackwhite.algo, filcor, - bwr, bwg, bwb, mixerOrange, mixerYellow, mixerCyan, mixerPurple, mixerMagenta, - params->blackwhite.autoc, complem, kcorec, rrm, ggm, bbm); + Color::computeBWMixerConstants (params->blackwhite.setting, params->blackwhite.filter, params->blackwhite.algo, filcor, + bwr, bwg, bwb, mixerOrange, mixerYellow, mixerCyan, mixerPurple, mixerMagenta, + params->blackwhite.autoc, complem, kcorec, rrm, ggm, bbm); #ifdef _OPENMP #pragma omp parallel for schedule(dynamic, 16) @@ -4454,20 +4484,25 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer for (int j = 0; j < tW; j++) { //mix channel - tmpImage->r(i, j) = tmpImage->g(i, j) = tmpImage->b(i, j) = CLIP((bwr * tmpImage->r(i, j) + bwg * tmpImage->g(i, j) + bwb * tmpImage->b(i, j)) * kcorec); + tmpImage->r (i, j) = tmpImage->g (i, j) = tmpImage->b (i, j) = CLIP ((bwr * tmpImage->r (i, j) + bwg * tmpImage->g (i, j) + bwb * tmpImage->b (i, j)) * kcorec); #ifndef __SSE2__ + //gamma correction: pseudo TRC curve if (hasgammabw) { - Color::trcGammaBW (tmpImage->r(i, j), tmpImage->g(i, j), tmpImage->b(i, j), gammabwr, gammabwg, gammabwb); + Color::trcGammaBW (tmpImage->r (i, j), tmpImage->g (i, j), tmpImage->b (i, j), gammabwr, gammabwg, gammabwb); } + #endif } + #ifdef __SSE2__ + if (hasgammabw) { //gamma correction: pseudo TRC curve - Color::trcGammaBWRow (tmpImage->r(i), tmpImage->g(i), tmpImage->b(i), tW, gammabwr, gammabwg, gammabwb); + Color::trcGammaBWRow (tmpImage->r (i), tmpImage->g (i), tmpImage->b (i), tW, gammabwr, gammabwg, gammabwb); } + #endif } } @@ -4479,7 +4514,7 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer for (int i = 0; i < tH; i++) { for (int j = 0; j < tW; j++) { - editWhatever->v(i, j) = Color::gamma2curve[tmpImage->r(i, j)] / 65535.f; // assuming that r=g=b + editWhatever->v (i, j) = Color::gamma2curve[tmpImage->r (i, j)] / 65535.f; // assuming that r=g=b } } } @@ -4493,8 +4528,8 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer for (int i = 0; i < tH; i++) { for (int j = 0; j < tW; j++) { - const StandardToneCurvebw& userToneCurve = static_cast(customToneCurvebw2); - userToneCurve.Apply(tmpImage->r(i, j), tmpImage->g(i, j), tmpImage->b(i, j)); + const StandardToneCurvebw& userToneCurve = static_cast (customToneCurvebw2); + userToneCurve.Apply (tmpImage->r (i, j), tmpImage->g (i, j), tmpImage->b (i, j)); } } } else if (afterCurveMode == BlackWhiteParams::TC_MODE_WEIGHTEDSTD_BW) { // apply the curve to the rgb channels, weighted @@ -4504,13 +4539,13 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer for (int i = 0; i < tH; i++) { //for ulterior usage if bw data modified for (int j = 0; j < tW; j++) { - const WeightedStdToneCurvebw& userToneCurve = static_cast(customToneCurvebw2); + const WeightedStdToneCurvebw& userToneCurve = static_cast (customToneCurvebw2); - tmpImage->r(i, j) = CLIP(tmpImage->r(i, j)); - tmpImage->g(i, j) = CLIP(tmpImage->g(i, j)); - tmpImage->b(i, j) = CLIP(tmpImage->b(i, j)); + tmpImage->r (i, j) = CLIP (tmpImage->r (i, j)); + tmpImage->g (i, j) = CLIP (tmpImage->g (i, j)); + tmpImage->b (i, j) = CLIP (tmpImage->b (i, j)); - userToneCurve.Apply(tmpImage->r(i, j), tmpImage->g(i, j), tmpImage->b(i, j)); + userToneCurve.Apply (tmpImage->r (i, j), tmpImage->g (i, j), tmpImage->b (i, j)); } } } @@ -4518,7 +4553,7 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer //colortoning with black and white if (hasColorToning) { - if(params->colorToning.method == "Splitco") { + if (params->colorToning.method == "Splitco") { /* #if 1 for (int i=istart,ti=0; icolorToning.lumamode) { + if (params->colorToning.lumamode) { preser = 1; } @@ -4548,32 +4583,32 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer for (int i = 0; i < tH; i++) { for (int j = 0; j < tW; j++) { - float r = tmpImage->r(i, j); - float g = tmpImage->g(i, j); - float b = tmpImage->b(i, j); + float r = tmpImage->r (i, j); + float g = tmpImage->g (i, j); + float b = tmpImage->b (i, j); float lumbefore = 0.299f * r + 0.587f * g + 0.114f * b; - if(lumbefore < 65000.f && lumbefore > 500.f) { //reduct artifacts for highlights an extrem shadows + if (lumbefore < 65000.f && lumbefore > 500.f) { //reduct artifacts for highlights an extrem shadows float ro, go, bo; int mode = 1; toningsmh (r, g, b, ro, go, bo, RedLow, GreenLow, BlueLow, RedMed, GreenMed, BlueMed, RedHigh, GreenHigh, BlueHigh, reducac, mode, preser, strProtect); float lumafter = 0.299f * ro + 0.587f * go + 0.114f * bo; float preserv = 1.f; - if(preser == 1) { + if (preser == 1) { preserv = lumbefore / lumafter; } ro *= preserv; go *= preserv; bo *= preserv; - ro = CLIP(ro); - go = CLIP(go); - bo = CLIP(bo); - tmpImage->r(i, j) = ro; - tmpImage->g(i, j) = go; - tmpImage->b(i, j) = bo; + ro = CLIP (ro); + go = CLIP (go); + bo = CLIP (bo); + tmpImage->r (i, j) = ro; + tmpImage->g (i, j) = go; + tmpImage->b (i, j) = bo; } } } @@ -4586,7 +4621,7 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer float reducac = 0.4f; int preser = 0; - if(params->colorToning.lumamode) { + if (params->colorToning.lumamode) { preser = 1; } @@ -4601,31 +4636,31 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer iphigh = (float)ctColorCurve.high; //2 colours - ctColorCurve.getVal(iphigh, xh, yh, zh); - ctColorCurve.getVal(iplow, xl, yl, zl); + ctColorCurve.getVal (iphigh, xh, yh, zh); + ctColorCurve.getVal (iplow, xl, yl, zl); - Color::xyz2rgb(xh, yh, zh, rh, gh, bh, wip); - Color::xyz2rgb(xl, yl, zl, rl, gl, bl, wip); + Color::xyz2rgb (xh, yh, zh, rh, gh, bh, wip); + Color::xyz2rgb (xl, yl, zl, rl, gl, bl, wip); //retrieve rgb value with s and l =1 - retreavergb(rl, gl, bl); - retreavergb(rh, gh, bh); + retreavergb (rl, gl, bl); + retreavergb (rh, gh, bh); #ifdef _OPENMP #pragma omp parallel for schedule(dynamic, 5) #endif for (int i = 0; i < tH; i++) { for (int j = 0; j < tW; j++) { - float r = tmpImage->r(i, j); - float g = tmpImage->g(i, j); - float b = tmpImage->b(i, j); + float r = tmpImage->r (i, j); + float g = tmpImage->g (i, j); + float b = tmpImage->b (i, j); float ro, go, bo; int mode = 1; toning2col (r, g, b, ro, go, bo, iplow, iphigh, rl, gl, bl, rh, gh, bh, SatLow, SatHigh, balanS, balanH, reducac, mode, preser, strProtect); - tmpImage->r(i, j) = ro; - tmpImage->g(i, j) = go; - tmpImage->b(i, j) = bo; + tmpImage->r (i, j) = ro; + tmpImage->g (i, j) = go; + tmpImage->b (i, j) = bo; } } } @@ -4646,13 +4681,13 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer metchrom = 3; } - if(metchrom == 3) { + if (metchrom == 3) { twocol = false; } float iplow = 0.f, iphigh = 0.f; - if(!twocol) { + if (!twocol) { iplow = (float)ctColorCurve.low; iphigh = (float)ctColorCurve.high; @@ -4660,7 +4695,7 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer int twoc = 0; //integer instead of bool to let more possible choice...other than 2 and 500. - if(!twocol) { + if (!twocol) { twoc = 0; // 2 colours } else { twoc = 1; // 500 colours @@ -4668,32 +4703,32 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer if (params->colorToning.method == "Lab") { algm = 1; - } else if(params->colorToning.method == "Lch") { + } else if (params->colorToning.method == "Lch") { algm = 2; //in case of } - if(algm <= 2) { + if (algm <= 2) { #ifdef _OPENMP #pragma omp parallel for schedule(dynamic, 5) #endif for (int i = 0; i < tH; i++) { for (int j = 0; j < tW; j++) { - float r = tmpImage->r(i, j); - float g = tmpImage->g(i, j); - float b = tmpImage->b(i, j); + float r = tmpImage->r (i, j); + float g = tmpImage->g (i, j); + float b = tmpImage->b (i, j); float ro, bo, go; labtoning (r, g, b, ro, go, bo, algm, metchrom, twoc, satLimit, satLimitOpacity, ctColorCurve, ctOpacityCurve, clToningcurve, cl2Toningcurve, iplow, iphigh, wp, wip); - tmpImage->r(i, j) = CLIP(ro); - tmpImage->g(i, j) = CLIP(go); - tmpImage->b(i, j) = CLIP(bo); + tmpImage->r (i, j) = CLIP (ro); + tmpImage->g (i, j) = CLIP (go); + tmpImage->b (i, j) = CLIP (bo); } } } } - else if (params->colorToning.method.substr(0, 3) == "RGB" && opautili) { + else if (params->colorToning.method.substr (0, 3) == "RGB" && opautili) { // color toning #ifdef _OPENMP #pragma omp parallel for schedule(dynamic, 5) @@ -4701,31 +4736,31 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer for (int i = 0; i < tH; i++) { for (int j = 0; j < tW; j++) { - float r = tmpImage->r(i, j); - float g = tmpImage->g(i, j); - float b = tmpImage->b(i, j); + float r = tmpImage->r (i, j); + float g = tmpImage->g (i, j); + float b = tmpImage->b (i, j); // Luminance = (0.299f*r + 0.587f*g + 0.114f*b) float h, s, l; - Color::rgb2hsl(r, g, b, h, s, l); + Color::rgb2hsl (r, g, b, h, s, l); - float l_ = Color::gamma_srgb(l * 65535.f) / 65535.f; + float l_ = Color::gamma_srgb (l * 65535.f) / 65535.f; // get the opacity and tweak it to preserve saturated colors float opacity = ctOpacityCurve.lutOpacityCurve[l_ * 500.f] / 4.f; float r2, g2, b2; - ctColorCurve.getVal(l_, r2, g2, b2); // get the color from the color curve + ctColorCurve.getVal (l_, r2, g2, b2); // get the color from the color curve float h2, s2, l2; - Color::rgb2hsl(r2, g2, b2, h2, s2, l2); // transform this new color to hsl + Color::rgb2hsl (r2, g2, b2, h2, s2, l2); // transform this new color to hsl - Color::hsl2rgb(h2, s2, l, r2, g2, b2); + Color::hsl2rgb (h2, s2, l, r2, g2, b2); - tmpImage->r(i, j) = r + (r2 - r) * opacity; - tmpImage->g(i, j) = g + (g2 - g) * opacity; - tmpImage->b(i, j) = b + (b2 - b) * opacity; + tmpImage->r (i, j) = r + (r2 - r) * opacity; + tmpImage->g (i, j) = g + (g2 - g) * opacity; + tmpImage->b (i, j) = b + (b2 - b) * opacity; } } } @@ -4760,9 +4795,9 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer for (int i = 0; i < tH; i++) { for (int j = 0; j < tW; j++) { - float r = tmpImage->r(i, j); - float g = tmpImage->g(i, j); - float b = tmpImage->b(i, j); + float r = tmpImage->r (i, j); + float g = tmpImage->g (i, j); + float b = tmpImage->b (i, j); float x = toxyz[0][0] * r + toxyz[0][1] * g + toxyz[0][2] * b; float y = toxyz[1][0] * r + toxyz[1][1] * g + toxyz[1][2] * b; @@ -4770,9 +4805,9 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer float fx, fy, fz; - fx = (x < MAXVALF ? Color::cachef[x] : 327.68f * std::cbrt(x / MAXVALF)); - fy = (y < MAXVALF ? Color::cachef[y] : 327.68f * std::cbrt(y / MAXVALF)); - fz = (z < MAXVALF ? Color::cachef[z] : 327.68f * std::cbrt(z / MAXVALF)); + fx = (x < MAXVALF ? Color::cachef[x] : 327.68f * std::cbrt (x / MAXVALF)); + fy = (y < MAXVALF ? Color::cachef[y] : 327.68f * std::cbrt (y / MAXVALF)); + fz = (z < MAXVALF ? Color::cachef[z] : 327.68f * std::cbrt (z / MAXVALF)); lab->L[i][j] = 116.0f * fy - 5242.88f; //5242.88=16.0*327.68; lab->a[i][j] = 500.0f * (fx - fy); @@ -4808,31 +4843,31 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer **/ void ImProcFunctions::retreavergb (float &r, float &g, float &b) { - float mini = min(r, g, b); - float maxi = max(r, g, b); + float mini = min (r, g, b); + float maxi = max (r, g, b); float kkm = 65535.f / maxi; - if(b == mini && r == maxi) { + if (b == mini && r == maxi) { r = 65535.f; g = kkm * (g - b); b = 0.f; - } else if(b == mini && g == maxi) { + } else if (b == mini && g == maxi) { g = 65535.f; r = kkm * (r - b); b = 0.f; - } else if(g == mini && r == maxi) { + } else if (g == mini && r == maxi) { r = 65535.f; b = kkm * (b - g); g = 0.f; - } else if(g == mini && b == maxi) { + } else if (g == mini && b == maxi) { b = 65535.f; r = kkm * (r - g); g = 0.f; - } else if(r == mini && b == maxi) { + } else if (r == mini && b == maxi) { b = 65535.f; g = kkm * (g - r); r = 0.f; - } else if(r == mini && g == maxi) { + } else if (r == mini && g == maxi) { g = 65535.f; b = kkm * (b - r); r = 0.f; @@ -4857,7 +4892,7 @@ void ImProcFunctions::secondeg_end (float reducac, float vinf, float &aa, float float a3 = 1.f - v0 * v0; float a4 = me * me - v0 * v0; aa = (1.f + (zrd - 1.f) * (1 - v0) / a2) / (a4 * (1.f - v0) / a2 - a3); - bb = -(1.f + a3 * aa) / (1.f - v0); + bb = - (1.f + a3 * aa) / (1.f - v0); cc = - (aa + bb); } @@ -4906,7 +4941,7 @@ void ImProcFunctions::toningsmh (float r, float g, float b, float &ro, float &go float GreenL = 1.f + (GreenLow - 1.f) * 0.4f; float BlueL = 1.f + (BlueLow - 1.f) * bmu; float h, s, v; - Color::rgb2hsv(r, g, b, h, s, v); + Color::rgb2hsv (r, g, b, h, s, v); float ksat = 1.f; float ksatlow = 1.f; // float s_0=0.55f; @@ -4923,10 +4958,10 @@ void ImProcFunctions::toningsmh (float r, float g, float b, float &ro, float &go float rlh = 2.2f; //1.1 float rlob = bmu; //for BW old mode - if(mode == 0) { //color - rlo *= pow_F(strProtect, 0.4f); //0.5 ==> 0.75 - rlh *= pow_F(strProtect, 0.4f); - rlm *= pow_F(strProtect, 0.4f); + if (mode == 0) { //color + rlo *= pow_F (strProtect, 0.4f); //0.5 ==> 0.75 + rlh *= pow_F (strProtect, 0.4f); + rlm *= pow_F (strProtect, 0.4f); } else { //bw coefficient to preserve same results as before for satlimtopacity = 0.5 (default) rlo = strProtect * 0.8f; //0.4 rlob = strProtect; //0.5 @@ -4934,17 +4969,17 @@ void ImProcFunctions::toningsmh (float r, float g, float b, float &ro, float &go rlh = strProtect * 2.4f; //1.2 } - if(mode == 0) { + if (mode == 0) { rlob = rlo; } //fixed value of reducac=0.3 //secondeg_end (reducac, v0, aa, bb, cc); - if(mode == 1) { + if (mode == 1) { reducac = 0.5f; //black and white mode - if(v > 0.15f) { + if (v > 0.15f) { kl = (-1.f / 0.85f) * v + (1.f) / 0.85f; //Low light ==> decrease action after v=0.15 } } else { //color @@ -4955,63 +4990,63 @@ void ImProcFunctions::toningsmh (float r, float g, float b, float &ro, float &go float aab, bbb; secondeg_begin (0.7f, v0, aab, bbb); - if(v > v0) { + if (v > v0) { kl = aa * v * v + bb * v + cc; //verified ==> exact } else if (mode == 0) { kl = aab * v * v + bbb * v; //ksatlow=ksat; } } - if(RedLow != 1.f) { + if (RedLow != 1.f) { RedL = 1.f + (RedLow - 1.f) * kl * ksat * rlo; //0.4 - if(RedLow >= 1.f) { + if (RedLow >= 1.f) { g -= 20000.f * (RedL - 1.f) * ksatlow; b -= 20000.f * (RedL - 1.f) * ksatlow; } else { r += 20000.f * (RedL - 1.f) * ksatlow; } - r = CLIP(r); - g = CLIP(g); - b = CLIP(b); + r = CLIP (r); + g = CLIP (g); + b = CLIP (b); } - if(GreenLow != 1.f) { + if (GreenLow != 1.f) { GreenL = 1.f + (GreenLow - 1.f) * kl * ksat * rlo; //0.4 - if(GreenLow >= 1.f) { + if (GreenLow >= 1.f) { r -= 20000.f * (GreenL - 1.f) * ksatlow; b -= 20000.f * (GreenL - 1.f) * ksatlow; } else { g += 20000.f * (GreenL - 1.f) * ksatlow; } - r = CLIP(r); - b = CLIP(b); - g = CLIP(g); + r = CLIP (r); + b = CLIP (b); + g = CLIP (g); } - if(BlueLow != 1.f) { + if (BlueLow != 1.f) { BlueL = 1.f + (BlueLow - 1.f) * kl * ksat * rlob; - if(BlueLow >= 1.f) { + if (BlueLow >= 1.f) { r -= 20000.f * (BlueL - 1.f) * ksatlow; g -= 20000.f * (BlueL - 1.f) * ksatlow; } else { b += 20000.f * (BlueL - 1.f) * ksatlow; } - r = CLIP(r); - g = CLIP(g); - b = CLIP(b); + r = CLIP (r); + g = CLIP (g); + b = CLIP (b); } // mid tones float km; float v0m = 0.5f; //max action - if(v < v0m) { + if (v < v0m) { float aam, bbm; float vend = v0m; secondeg_begin (reducac, vend, aam, bbm); @@ -5025,67 +5060,67 @@ void ImProcFunctions::toningsmh (float r, float g, float b, float &ro, float &go float RedM = 1.f + (RedMed - 1.f) * rlm; - if(RedMed != 1.f) { + if (RedMed != 1.f) { RedM = 1.f + (RedMed - 1.f) * km * rlm; - if(RedMed >= 1.f) { + if (RedMed >= 1.f) { r += 20000.f * (RedM - 1.f); g -= 10000.f * (RedM - 1.f); b -= 10000.f * (RedM - 1.f); - r = CLIP(r); - g = CLIP(g); - b = CLIP(b); + r = CLIP (r); + g = CLIP (g); + b = CLIP (b); } else { r += 10000.f * (RedM - 1.f); g -= 20000.f * (RedM - 1.f); b -= 20000.f * (RedM - 1.f); - r = CLIP(r); - g = CLIP(g); - b = CLIP(b); + r = CLIP (r); + g = CLIP (g); + b = CLIP (b); } } float GreenM = 1.f + (GreenMed - 1.f) * rlm; - if(GreenMed != 1.f) { + if (GreenMed != 1.f) { GreenM = 1.f + (GreenMed - 1.f) * km * rlm; - if(GreenMed >= 1.f) { + if (GreenMed >= 1.f) { r -= 10000.f * (GreenM - 1.f); g += 20000.f * (GreenM - 1.f); b -= 10000.f * (GreenM - 1.f); - r = CLIP(r); - g = CLIP(g); - b = CLIP(b); + r = CLIP (r); + g = CLIP (g); + b = CLIP (b); } else { r -= 20000.f * (GreenM - 1.f); g += 10000.f * (GreenM - 1.f); b -= 20000.f * (GreenM - 1.f); - r = CLIP(r); - g = CLIP(g); - b = CLIP(b); + r = CLIP (r); + g = CLIP (g); + b = CLIP (b); } } float BlueM = 1.f + (BlueMed - 1.f) * rlm; - if(BlueMed != 1.f) { + if (BlueMed != 1.f) { BlueM = 1.f + (BlueMed - 1.f) * km * rlm; - if(BlueMed >= 1.f) { + if (BlueMed >= 1.f) { r -= 10000.f * (BlueM - 1.f); g -= 10000.f * (BlueM - 1.f); b += 20000.f * (BlueM - 1.f); - r = CLIP(r); - g = CLIP(g); - b = CLIP(b); + r = CLIP (r); + g = CLIP (g); + b = CLIP (b); } else { r -= 20000.f * (BlueM - 1.f); g -= 20000.f * (BlueM - 1.f); b += 10000.f * (BlueM - 1.f); - r = CLIP(r); - g = CLIP(g); - b = CLIP(b); + r = CLIP (r); + g = CLIP (g); + b = CLIP (b); } } @@ -5098,7 +5133,7 @@ void ImProcFunctions::toningsmh (float r, float g, float b, float &ro, float &go // float hmu=1.5f; // if(mode==1) hmu=1.2f;//for BW old mode - if(v > v00) { + if (v > v00) { kh = (-1.f / (1.f - v00)) * v + (1.f) / (1.f - v00); //High tones } else { kh = aa0 * v * v + bb0 * v; //verification = good @@ -5108,49 +5143,49 @@ void ImProcFunctions::toningsmh (float r, float g, float b, float &ro, float &go float GreenH = 1.f + (GreenHigh - 1.f) * rlh; float BlueH = 1.f + (BlueHigh - 1.f) * rlh; //1.2 - if(RedHigh != 1.f) { + if (RedHigh != 1.f) { RedH = 1.f + (RedHigh - 1.f) * kh * rlh; //1.2 - if(RedHigh >= 1.f) { + if (RedHigh >= 1.f) { r += 20000.f * (RedH - 1.f); - r = CLIP(r); + r = CLIP (r); } else { g -= 20000.f * (RedH - 1.f); b -= 20000.f * (RedH - 1.f); } - g = CLIP(g); - b = CLIP(b); + g = CLIP (g); + b = CLIP (b); } - if(GreenHigh != 1.f) { + if (GreenHigh != 1.f) { GreenH = 1.f + (GreenHigh - 1.f) * kh * rlh; //1.2 - if(GreenHigh >= 1.f) { + if (GreenHigh >= 1.f) { g += 20000.f * (GreenH - 1.f); - g = CLIP(g); + g = CLIP (g); } else { r -= 20000.f * (GreenH - 1.f); b -= 20000.f * (GreenH - 1.f); } - r = CLIP(r); - b = CLIP(b); + r = CLIP (r); + b = CLIP (b); } - if(BlueHigh != 1.f) { + if (BlueHigh != 1.f) { BlueH = 1.f + (BlueHigh - 1.f) * kh * rlh; //1.2 - if(BlueHigh >= 1.f) { + if (BlueHigh >= 1.f) { b += 20000.f * (BlueH - 1.f); - b = CLIP(b); + b = CLIP (b); } else { r -= 20000.f * (BlueH - 1.f); g -= 20000.f * (BlueH - 1.f); } - r = CLIP(r); - g = CLIP(g); + r = CLIP (r); + g = CLIP (g); } ro = r; @@ -5174,9 +5209,9 @@ void ImProcFunctions::toning2col (float r, float g, float b, float &ro, float &g { float lumbefore = 0.299f * r + 0.587f * g + 0.114f * b; float h, s, l; - Color::rgb2hsl(r, g, b, h, s, l); + Color::rgb2hsl (r, g, b, h, s, l); float v; - Color::rgb2hsv(r, g, b, h, s, v); + Color::rgb2hsv (r, g, b, h, s, v); float ksat = 1.f; float ksatlow = 1.f; /* @@ -5188,8 +5223,8 @@ void ImProcFunctions::toning2col (float r, float g, float b, float &ro, float &g float kl = 1.f; float rlo = 1.f; float rlh = 2.2f; - rlo *= pow_F(strProtect, 0.4f); //0.5 ==> 0.75 transfered value for more action - rlh *= pow_F(strProtect, 0.4f); + rlo *= pow_F (strProtect, 0.4f); //0.5 ==> 0.75 transfered value for more action + rlh *= pow_F (strProtect, 0.4f); //low tones //second degree float aa, bb, cc; @@ -5199,54 +5234,54 @@ void ImProcFunctions::toning2col (float r, float g, float b, float &ro, float &g secondeg_begin (0.7f, iplow, aab, bbb); - if(v > iplow) { + if (v > iplow) { kl = aa * v * v + bb * v + cc; } else if (mode == 0) { kl = aab * v * v + bbb * v; } - if(SatLow > 0.f) { + if (SatLow > 0.f) { //rl gl bl float krl = rl / (rl + gl + bl); float kgl = gl / (rl + gl + bl); float kbl = bl / (rl + gl + bl); float RedL, GreenL, BlueL; - if(g < 20000.f || b < 20000.f || r < 20000.f) { - float kmgb = min(r, g, b); //I have tested ...0.85 compromise... - kl *= pow((kmgb / 20000.f), 0.85f); + if (g < 20000.f || b < 20000.f || r < 20000.f) { + float kmgb = min (r, g, b); //I have tested ...0.85 compromise... + kl *= pow ((kmgb / 20000.f), 0.85f); } RedL = 1.f + (SatLow * krl) * kl * ksat * rlo * balanS; //0.4 - if(krl > 0.f) { + if (krl > 0.f) { g -= 20000.f * (RedL - 1.f) * ksatlow; b -= 20000.f * (RedL - 1.f) * ksatlow; } - g = CLIP(g); - b = CLIP(b); + g = CLIP (g); + b = CLIP (b); GreenL = 1.f + (SatLow * kgl) * kl * ksat * rlo * balanS; //0.4 - if(kgl > 0.f) { + if (kgl > 0.f) { r -= 20000.f * (GreenL - 1.f) * ksatlow; b -= 20000.f * (GreenL - 1.f) * ksatlow; } - r = CLIP(r); - b = CLIP(b); + r = CLIP (r); + b = CLIP (b); BlueL = 1.f + (SatLow * kbl) * kl * ksat * rlo * balanS; //0.4 - if(kbl > 0.f) { + if (kbl > 0.f) { r -= 20000.f * (BlueL - 1.f) * ksatlow; g -= 20000.f * (BlueL - 1.f) * ksatlow; } - r = CLIP(r); - g = CLIP(g); + r = CLIP (r); + g = CLIP (g); } //high tones @@ -5255,15 +5290,15 @@ void ImProcFunctions::toning2col (float r, float g, float b, float &ro, float &g //fixed value of reducac ==0.4; secondeg_begin (reducac, iphigh, aa0, bb0); - if(v > iphigh) { + if (v > iphigh) { kh = (-1.f / (1.f - iphigh)) * v + (1.f) / (1.f - iphigh); //Low light ==> decrease action after iplow } else { kh = aa0 * v * v + bb0 * v; } - if(g > 45535.f || b > 45535.f || r > 45535.f) { - float kmgb = max(r, g, b); + if (g > 45535.f || b > 45535.f || r > 45535.f) { + float kmgb = max (r, g, b); float cora = 1.f / (45535.f - 65535.f); float corb = 1.f - cora * 45535.f; float cor = kmgb * cora + corb; @@ -5276,45 +5311,45 @@ void ImProcFunctions::toning2col (float r, float g, float b, float &ro, float &g } - if(SatHigh > 0.f) { + if (SatHigh > 0.f) { float RedH, GreenH, BlueH; float krh = rh / (rh + gh + bh); float kgh = gh / (rh + gh + bh); float kbh = bh / (rh + gh + bh); RedH = 1.f + (SatHigh * krh) * kh * rlh * balanH; //1.2 - if(krh > 0.f) { + if (krh > 0.f) { r += 20000.f * (RedH - 1.f); - r = CLIP(r); + r = CLIP (r); } - g = CLIP(g); - b = CLIP(b); + g = CLIP (g); + b = CLIP (b); GreenH = 1.f + (SatHigh * kgh) * kh * rlh * balanH; //1.2 - if(kgh > 0.f) { + if (kgh > 0.f) { g += 20000.f * (GreenH - 1.f); - g = CLIP(g); + g = CLIP (g); } - r = CLIP(r); - b = CLIP(b); + r = CLIP (r); + b = CLIP (b); BlueH = 1.f + (SatHigh * kbh) * kh * rlh * balanH; //1.2 - if(kbh > 0.f) { + if (kbh > 0.f) { b += 20000.f * (BlueH - 1.f); - b = CLIP(b); + b = CLIP (b); } - r = CLIP(r); - g = CLIP(g); + r = CLIP (r); + g = CLIP (g); } float lumafter = 0.299f * r + 0.587f * g + 0.114f * b; float preserv = 1.f; - if(preser == 1) { + if (preser == 1) { preserv = lumbefore / lumafter; } @@ -5325,9 +5360,9 @@ void ImProcFunctions::toning2col (float r, float g, float b, float &ro, float &g ro *= preserv; go *= preserv; bo *= preserv; - ro = CLIP(ro); - go = CLIP(go); - bo = CLIP(bo); + ro = CLIP (ro); + go = CLIP (go); + bo = CLIP (bo); } /** @@ -5346,21 +5381,21 @@ void ImProcFunctions::labtoning (float r, float g, float b, float &ro, float &go { float realL; float h, s, l; - Color::rgb2hsl(r, g, b, h, s, l); + Color::rgb2hsl (r, g, b, h, s, l); float x2, y2, z2; float xl, yl, zl; - if(twoc != 1) { + if (twoc != 1) { l = (Color::gammatab_13_2[ l * 65535.f]) / 65535.f; //to compensate L from Lab iphigh = (Color::gammatab_13_2[iphigh * 65535.f]) / 65535.f; iplow = (Color::gammatab_13_2[ iplow * 65535.f]) / 65535.f; } - if(twoc == 1) { - ctColorCurve.getVal(l, x2, y2, z2); + if (twoc == 1) { + ctColorCurve.getVal (l, x2, y2, z2); } else { - ctColorCurve.getVal(iphigh, x2, y2, z2); - ctColorCurve.getVal(iplow, xl, yl, zl); + ctColorCurve.getVal (iphigh, x2, y2, z2); + ctColorCurve.getVal (iplow, xl, yl, zl); } realL = l; @@ -5372,8 +5407,8 @@ void ImProcFunctions::labtoning (float r, float g, float b, float &ro, float &go // get the opacity and tweak it to preserve saturated colors //float l_ = Color::gamma_srgb(l*65535.f)/65535.f; float opacity; - opacity = (1.f - min(s / satLimit, 1.f) * (1.f - satLimitOpacity)) * ctOpacityCurve.lutOpacityCurve[l * 500.f]; - float opacity2 = (1.f - min(s / satLimit, 1.f) * (1.f - satLimitOpacity)); + opacity = (1.f - min (s / satLimit, 1.f) * (1.f - satLimitOpacity)) * ctOpacityCurve.lutOpacityCurve[l * 500.f]; + float opacity2 = (1.f - min (s / satLimit, 1.f) * (1.f - satLimitOpacity)); //float ro, go, bo; bool chr = true; @@ -5382,23 +5417,23 @@ void ImProcFunctions::labtoning (float r, float g, float b, float &ro, float &go float chromat, luma; if (clToningcurve[lm * 65535.f] / (lm * 65535.f) < 1.f) { - chromat = (clToningcurve[(lm) * 65535.f] / (lm * 65535.f)) - 1.f; //special effect + chromat = (clToningcurve[ (lm) * 65535.f] / (lm * 65535.f)) - 1.f; //special effect } else { - chromat = 1.f - SQR(SQR((lm * 65535.f) / clToningcurve[(lm) * 65535.f])); //apply C=f(L) acts on 'a' and 'b' + chromat = 1.f - SQR (SQR ((lm * 65535.f) / clToningcurve[ (lm) * 65535.f])); //apply C=f(L) acts on 'a' and 'b' } if (cl2Toningcurve[lm * 65535.f] / (lm * 65535.f) < 1.f) { - luma = (cl2Toningcurve[(lm) * 65535.f] / (lm * 65535.f)) - 1.f; //special effect + luma = (cl2Toningcurve[ (lm) * 65535.f] / (lm * 65535.f)) - 1.f; //special effect } else { - luma = 1.f - SQR(SQR((lm * 65535.f) / (cl2Toningcurve[(lm) * 65535.f]))); //apply C2=f(L) acts only on 'b' + luma = 1.f - SQR (SQR ((lm * 65535.f) / (cl2Toningcurve[ (lm) * 65535.f]))); //apply C2=f(L) acts only on 'b' } int todo = 1; if (algm == 1) { - Color::interpolateRGBColor(realL, iplow, iphigh, algm, opacity, twoc, metchrom, chr, lum, chromat, luma, r, g, b, xl, yl, zl, x2, y2, z2, todo, wp, wip, ro, go, bo); + Color::interpolateRGBColor (realL, iplow, iphigh, algm, opacity, twoc, metchrom, chr, lum, chromat, luma, r, g, b, xl, yl, zl, x2, y2, z2, todo, wp, wip, ro, go, bo); } else { - Color::interpolateRGBColor(realL, iplow, iphigh, algm, opacity2, twoc, metchrom, chr, lum, chromat, luma, r, g, b, xl, yl, zl, x2, y2, z2, todo, wp, wip, ro, go, bo); + Color::interpolateRGBColor (realL, iplow, iphigh, algm, opacity2, twoc, metchrom, chr, lum, chromat, luma, r, g, b, xl, yl, zl, x2, y2, z2, todo, wp, wip, ro, go, bo); } } @@ -5456,7 +5491,7 @@ SSEFUNCTION void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBu bool chutili = false; if (params->labCurve.chromaticity > -100) { - chCurve = new FlatCurve(params->labCurve.chcurve); + chCurve = new FlatCurve (params->labCurve.chcurve); if (!chCurve || chCurve->isIdentity()) { if (chCurve) { @@ -5473,7 +5508,7 @@ SSEFUNCTION void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBu bool lhutili = false; if (params->labCurve.chromaticity > -100) { - lhCurve = new FlatCurve(params->labCurve.lhcurve); + lhCurve = new FlatCurve (params->labCurve.lhcurve); if (!lhCurve || lhCurve->isIdentity()) { if (lhCurve) { @@ -5490,7 +5525,7 @@ SSEFUNCTION void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBu bool hhutili = false; if (params->labCurve.chromaticity > -100) { - hhCurve = new FlatCurve(params->labCurve.hhcurve); + hhCurve = new FlatCurve (params->labCurve.hhcurve); if (!hhCurve || hhCurve->isIdentity()) { if (hhCurve) { @@ -5508,10 +5543,10 @@ SSEFUNCTION void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBu LUTu hist16Llad; //preparate for histograms CIECAM - if(pW != 1) { //only with improccoordinator - hist16Clad(65536); + if (pW != 1) { //only with improccoordinator + hist16Clad (65536); hist16Clad.clear(); - hist16Llad(65536); + hist16Llad (65536); hist16Llad.clear(); } @@ -5565,38 +5600,38 @@ SSEFUNCTION void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBu float protect_red, protect_redh; protect_red = protectRed;//default=60 chroma: one can put more or less if necessary...in 'option' 40...160 - if(protect_red < 20.0f) { + if (protect_red < 20.0f) { protect_red = 20.0; // avoid too low value } - if(protect_red > 180.0f) { + if (protect_red > 180.0f) { protect_red = 180.0; // avoid too high value } - protect_redh = float(protectRedH); //default=0.4 rad : one can put more or less if necessary...in 'option' 0.2 ..1.0 + protect_redh = float (protectRedH); //default=0.4 rad : one can put more or less if necessary...in 'option' 0.2 ..1.0 - if(protect_redh < 0.1f) { + if (protect_redh < 0.1f) { protect_redh = 0.1f; //avoid divide by 0 and negatives values } - if(protect_redh > 1.0f) { + if (protect_redh > 1.0f) { protect_redh = 1.0f; //avoid too big values } float protect_redhcur = protectRedH;//default=0.4 rad : one can put more or less if necessary...in 'option' 0.2 ..1 - if(protect_redhcur < 0.1f) { + if (protect_redhcur < 0.1f) { protect_redhcur = 0.1f; //avoid divide by 0 and negatives values:minimal protection for transition } - if(protect_redhcur > 3.5f) { + if (protect_redhcur > 3.5f) { protect_redhcur = 3.5f; //avoid too big values } //increase saturation after denoise : ...approximation float factnoise = 1.f; - if(params->dirpyrDenoise.enabled) { + if (params->dirpyrDenoise.enabled) { factnoise = (1.f + params->dirpyrDenoise.chroma / 500.f); //levels=5 // if(yyyy) factnoise=(1.f+params->dirpyrDenoise.chroma/100.f);//levels=7 } @@ -5637,28 +5672,28 @@ SSEFUNCTION void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBu if (avoidColorShift) // only if user activate Lab adjustments - if(autili || butili || ccutili || cclutili || chutili || lhutili || hhutili || clcutili || utili || chromaticity) { - Color::LabGamutMunsell(lold->L[i], lold->a[i], lold->b[i], W, /*corMunsell*/true, /*lumaMuns*/false, params->toneCurve.hrenabled, /*gamut*/true, wip, multiThread); + if (autili || butili || ccutili || cclutili || chutili || lhutili || hhutili || clcutili || utili || chromaticity) { + Color::LabGamutMunsell (lold->L[i], lold->a[i], lold->b[i], W, /*corMunsell*/true, /*lumaMuns*/false, params->toneCurve.hrenabled, /*gamut*/true, wip, multiThread); } #ifdef __SSE2__ // precalculate some values using SSE - if(bwToning || (!autili && !butili)) { - __m128 c327d68v = _mm_set1_ps(327.68f); + if (bwToning || (!autili && !butili)) { + __m128 c327d68v = _mm_set1_ps (327.68f); __m128 av, bv; int k; for (k = 0; k < W - 3; k += 4) { - av = LVFU(lold->a[i][k]); - bv = LVFU(lold->b[i][k]); - STVF(HHBuffer[k], xatan2f(bv, av)); - STVF(CCBuffer[k], _mm_sqrt_ps(SQRV(av) + SQRV(bv)) / c327d68v); + av = LVFU (lold->a[i][k]); + bv = LVFU (lold->b[i][k]); + STVF (HHBuffer[k], xatan2f (bv, av)); + STVF (CCBuffer[k], _mm_sqrt_ps (SQRV (av) + SQRV (bv)) / c327d68v); } - for(; k < W; k++) { - HHBuffer[k] = xatan2f(lold->b[i][k], lold->a[i][k]); - CCBuffer[k] = sqrt(SQR(lold->a[i][k]) + SQR(lold->b[i][k])) / 327.68f; + for (; k < W; k++) { + HHBuffer[k] = xatan2f (lold->b[i][k], lold->a[i][k]); + CCBuffer[k] = sqrt (SQR (lold->a[i][k]) + SQR (lold->b[i][k])) / 327.68f; } } @@ -5674,18 +5709,18 @@ SSEFUNCTION void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBu float memChprov; float2 sincosval; - if(bwToning) { // this values will be also set when bwToning is false some lines down + if (bwToning) { // this values will be also set when bwToning is false some lines down #ifdef __SSE2__ // use precalculated values from above HH = HHBuffer[j]; CC = CCBuffer[j]; #else - HH = xatan2f(lold->b[i][j], lold->a[i][j]); - CC = sqrt(SQR(lold->a[i][j]) + SQR(lold->b[i][j])) / 327.68f; + HH = xatan2f (lold->b[i][j], lold->a[i][j]); + CC = sqrt (SQR (lold->a[i][j]) + SQR (lold->b[i][j])) / 327.68f; #endif // According to mathematical laws we can get the sin and cos of HH by simple operations - if(CC == 0.0f) { + if (CC == 0.0f) { sincosval.y = 1.0f; sincosval.x = 0.0f; } else { @@ -5699,20 +5734,20 @@ SSEFUNCTION void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBu } if (editPipette && editID == EUID_Lab_LCurve) { - editWhatever->v(i, j) = LIM01(Lin / 32768.0f); // Lab L pipette + editWhatever->v (i, j) = LIM01 (Lin / 32768.0f); // Lab L pipette } lnew->L[i][j] = curve[Lin]; float Lprov1 = (lnew->L[i][j]) / 327.68f; - if(editPipette) { + if (editPipette) { if (editID == EUID_Lab_aCurve) { // Lab a pipette float chromapipa = lold->a[i][j] + (32768.f * 1.28f); - editWhatever->v(i, j) = LIM01((chromapipa) / (65536.f * 1.28f)); + editWhatever->v (i, j) = LIM01 ((chromapipa) / (65536.f * 1.28f)); } else if (editID == EUID_Lab_bCurve) { //Lab b pipette float chromapipb = lold->b[i][j] + (32768.f * 1.28f); - editWhatever->v(i, j) = LIM01((chromapipb) / (65536.f * 1.28f)); + editWhatever->v (i, j) = LIM01 ((chromapipb) / (65536.f * 1.28f)); } } @@ -5720,35 +5755,35 @@ SSEFUNCTION void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBu atmp = lold->a[i][j]; - if(autili) { + if (autili) { atmp = acurve[atmp + 32768.0f] - 32768.0f; // curves Lab a } btmp = lold->b[i][j]; - if(butili) { + if (butili) { btmp = bcurve[btmp + 32768.0f] - 32768.0f; // curves Lab b } - if(!bwToning) { //take into account modification of 'a' and 'b' + if (!bwToning) { //take into account modification of 'a' and 'b' #ifdef __SSE2__ - if(!autili && !butili) { + if (!autili && !butili) { // use precalculated values from above HH = HHBuffer[j]; CC = CCBuffer[j]; } else { - CC = sqrt(SQR(atmp) + SQR(btmp)) / 327.68f; - HH = xatan2f(btmp, atmp); + CC = sqrt (SQR (atmp) + SQR (btmp)) / 327.68f; + HH = xatan2f (btmp, atmp); } #else - CC = sqrt(SQR(atmp) + SQR(btmp)) / 327.68f; - HH = xatan2f(btmp, atmp); + CC = sqrt (SQR (atmp) + SQR (btmp)) / 327.68f; + HH = xatan2f (btmp, atmp); #endif // According to mathematical laws we can get the sin and cos of HH by simple operations //float2 sincosval; - if(CC == 0.f) { + if (CC == 0.f) { sincosval.y = 1.f; sincosval.x = 0.f; } else { @@ -5761,10 +5796,10 @@ SSEFUNCTION void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBu memChprov = Chprov; } // now new values of lold with 'a' and 'b' - if(editPipette) + if (editPipette) if (editID == EUID_Lab_LHCurve || editID == EUID_Lab_CHCurve || editID == EUID_Lab_HHCurve) {//H pipette - float valpar = Color::huelab_to_huehsv2(HH); - editWhatever->v(i, j) = valpar; + float valpar = Color::huelab_to_huehsv2 (HH); + editWhatever->v (i, j) = valpar; } if (lhutili) { // L=f(H) @@ -5772,7 +5807,7 @@ SSEFUNCTION void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBu float l_r;//Luminance Lab in 0..1 l_r = Lprov1 / 100.f; { - float valparam = float((lhCurve->getVal(Color::huelab_to_huehsv2(HH)) - 0.5f)); //get l_r=f(H) + float valparam = float ((lhCurve->getVal (Color::huelab_to_huehsv2 (HH)) - 0.5f)); //get l_r=f(H) float valparamneg; valparamneg = valparam; float kcc = (CC / amountchroma); //take Chroma into account...40 "middle low" of chromaticity (arbitrary and simple), one can imagine other algorithme @@ -5780,8 +5815,8 @@ SSEFUNCTION void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBu valparam *= 2.f * kcc; valparamneg *= kcc; //slightly different for negative - if(valparam > 0.f) { - l_r = (1.f - valparam) * l_r + valparam * (1.f - SQR(((SQR(1.f - min(l_r, 1.0f)))))); + if (valparam > 0.f) { + l_r = (1.f - valparam) * l_r + valparam * (1.f - SQR (((SQR (1.f - min (l_r, 1.0f)))))); } else //for negative { @@ -5792,7 +5827,7 @@ SSEFUNCTION void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBu Lprov1 = l_r * 100.f; - float Chprov2 = sqrt(SQR(atmp) + SQR(btmp)) / 327.68f; + float Chprov2 = sqrt (SQR (atmp) + SQR (btmp)) / 327.68f; //Gamut control especialy fot negative values slightly different of gamutlchonly bool inRGB; @@ -5805,14 +5840,14 @@ SSEFUNCTION void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBu float fx = (0.002f * aprov1) + fy; float fz = fy - (0.005f * bprov1); - float x_ = 65535.0f * Color::f2xyz(fx) * Color::D50x; - float z_ = 65535.0f * Color::f2xyz(fz) * Color::D50z; + float x_ = 65535.0f * Color::f2xyz (fx) * Color::D50x; + float z_ = 65535.0f * Color::f2xyz (fz) * Color::D50z; float y_ = (Lprov1 > Color::epskap) ? 65535.0 * fy * fy * fy : 65535.0 * Lprov1 / Color::kappa; float R, G, B; - Color::xyz2rgb(x_, y_, z_, R, G, B, wip); + Color::xyz2rgb (x_, y_, z_, R, G, B, wip); if (R < 0.0f || G < 0.0f || B < 0.0f) { - if(Lprov1 < 0.1f) { + if (Lprov1 < 0.1f) { Lprov1 = 0.1f; } @@ -5834,8 +5869,8 @@ SSEFUNCTION void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBu // calculate C=f(H) if (chutili) { - double hr = Color::huelab_to_huehsv2(HH); - float chparam = float((chCurve->getVal(hr) - 0.5f) * 2.0f); //get C=f(H) + double hr = Color::huelab_to_huehsv2 (HH); + float chparam = float ((chCurve->getVal (hr) - 0.5f) * 2.0f); //get C=f(H) float chromaChfactor = 1.0f + chparam; atmp *= chromaChfactor;//apply C=f(H) btmp *= chromaChfactor; @@ -5843,15 +5878,15 @@ SSEFUNCTION void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBu if (hhutili) { // H=f(H) //hue Lab in -PI +PI - float valparam = float((hhCurve->getVal(Color::huelab_to_huehsv2(HH)) - 0.5f) * 1.7f) + HH; //get H=f(H) 1.7 optimisation ! + float valparam = float ((hhCurve->getVal (Color::huelab_to_huehsv2 (HH)) - 0.5f) * 1.7f) + HH; //get H=f(H) 1.7 optimisation ! HH = valparam; - sincosval = xsincosf(HH); + sincosval = xsincosf (HH); } - if(!bwToning) { + if (!bwToning) { float factorskin, factorsat, factorskinext; - if(chromapro > 1.f) { + if (chromapro > 1.f) { float scale = scaleConst;//reduction in normal zone float scaleext = 1.f;//reduction in transition zone Color::scalered ( rstprotection, chromapro, 0.0, HH, protect_redh, scale, scaleext);//1.0 @@ -5870,11 +5905,11 @@ SSEFUNCTION void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBu if (Lprov1 < 25.f) { dred = 40.f; - } else if(Lprov1 < 30.f) { + } else if (Lprov1 < 30.f) { dred = 3.f * Lprov1 - 35.f; - } else if(Lprov1 < 70.f) { + } else if (Lprov1 < 70.f) { dred = 55.f; - } else if(Lprov1 < 75.f) { + } else if (Lprov1 < 75.f) { dred = -3.f * Lprov1 + 265.f; } else { dred = 40.f; @@ -5888,7 +5923,7 @@ SSEFUNCTION void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBu btmp *= factorsat; if (editPipette && editID == EUID_Lab_CLCurve) { - editWhatever->v(i, j) = LIM01(LL / 100.f); // Lab C=f(L) pipette + editWhatever->v (i, j) = LIM01 (LL / 100.f); // Lab C=f(L) pipette } if (clut) { // begin C=f(L) @@ -5901,31 +5936,31 @@ SSEFUNCTION void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBu float deltaHH;//HH value transition for C curve protect_redcur = curf * protectRed; //default=60 chroma: one can put more or less if necessary...in 'option' 40...160==> curf =because curve is more progressive - if(protect_redcur < 20.0f) { + if (protect_redcur < 20.0f) { protect_redcur = 20.0; // avoid too low value } - if(protect_redcur > 180.0f) { + if (protect_redcur > 180.0f) { protect_redcur = 180.0; // avoid too high value } - protect_redhcur = curf * float(protectRedH); //default=0.4 rad : one can put more or less if necessary...in 'option' 0.2 ..1.0 ==> curf =because curve is more progressive + protect_redhcur = curf * float (protectRedH); //default=0.4 rad : one can put more or less if necessary...in 'option' 0.2 ..1.0 ==> curf =because curve is more progressive - if(protect_redhcur < 0.1f) { + if (protect_redhcur < 0.1f) { protect_redhcur = 0.1f; //avoid divide by 0 and negatives values } - if(protect_redhcur > 1.0f) { + if (protect_redhcur > 1.0f) { protect_redhcur = 1.0f; //avoid too big values } deltaHH = protect_redhcur; //transition hue - if(chromaCfactor > 0.0) { + if (chromaCfactor > 0.0) { Color::scalered ( rstprotection, chromaCfactor, 0.0, HH, deltaHH, scale, scaleext); //1.0 } - if(chromaCfactor > 1.0) { + if (chromaCfactor > 1.0) { float interm = (chromaCfactor - 1.0f) * 100.0f; factorskin = 1.0f + (interm * scale) / 100.0f; factorskinext = 1.0f + (interm * scaleext) / 100.0f; @@ -5947,13 +5982,13 @@ SSEFUNCTION void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBu // I have placed C=f(C) after all C treatments to assure maximum amplitude of "C" if (editPipette && editID == EUID_Lab_CCurve) { - float chromapip = sqrt(SQR(atmp) + SQR(btmp) + 0.001f); - editWhatever->v(i, j) = LIM01((chromapip) / (48000.f)); + float chromapip = sqrt (SQR (atmp) + SQR (btmp) + 0.001f); + editWhatever->v (i, j) = LIM01 ((chromapip) / (48000.f)); }//Lab C=f(C) pipette if (ccut) { float factorskin, factorsat, factor, factorskinext; - float chroma = sqrt(SQR(atmp) + SQR(btmp) + 0.001f); + float chroma = sqrt (SQR (atmp) + SQR (btmp) + 0.001f); float chromaCfactor = (satcurve[chroma * adjustr]) / (chroma * adjustr); //apply C=f(C) float curf = 0.7f; //empirical coeff because curve is more progressive float scale = 100.0f / 100.1f; //reduction in normal zone for curve CC @@ -5962,31 +5997,31 @@ SSEFUNCTION void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBu float deltaHH;//HH value transition for CC curve protect_redcur = curf * protectRed; //default=60 chroma: one can put more or less if necessary...in 'option' 40...160==> curf =because curve is more progressive - if(protect_redcur < 20.0f) { + if (protect_redcur < 20.0f) { protect_redcur = 20.0; // avoid too low value } - if(protect_redcur > 180.0f) { + if (protect_redcur > 180.0f) { protect_redcur = 180.0; // avoid too high value } - protect_redhcur = curf * float(protectRedH); //default=0.4 rad : one can put more or less if necessary...in 'option' 0.2 ..1.0 ==> curf =because curve is more progressive + protect_redhcur = curf * float (protectRedH); //default=0.4 rad : one can put more or less if necessary...in 'option' 0.2 ..1.0 ==> curf =because curve is more progressive - if(protect_redhcur < 0.1f) { + if (protect_redhcur < 0.1f) { protect_redhcur = 0.1f; //avoid divide by 0 and negatives values } - if(protect_redhcur > 1.0f) { + if (protect_redhcur > 1.0f) { protect_redhcur = 1.0f; //avoid too big values } deltaHH = protect_redhcur; //transition hue - if(chromaCfactor > 0.0) { + if (chromaCfactor > 0.0) { Color::scalered ( rstprotection, chromaCfactor, 0.0, HH, deltaHH, scale, scaleext); //1.0 } - if(chromaCfactor > 1.0) { + if (chromaCfactor > 1.0) { float interm = (chromaCfactor - 1.0f) * 100.0f; factorskin = 1.0f + (interm * scale) / 100.0f; factorskinext = 1.0f + (interm * scaleext) / 100.0f; @@ -6009,14 +6044,14 @@ SSEFUNCTION void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBu // end chroma C=f(C) //update histogram C - if(pW != 1) { //only with improccoordinator - int posp = (int)sqrt(atmp * atmp + btmp * btmp); + if (pW != 1) { //only with improccoordinator + int posp = (int)sqrt (atmp * atmp + btmp * btmp); hist16Clad[posp]++; } if (editPipette && editID == EUID_Lab_LCCurve) { - float chromapiplc = sqrt(SQR(atmp) + SQR(btmp) + 0.001f); - editWhatever->v(i, j) = LIM01((chromapiplc) / (48000.f)); + float chromapiplc = sqrt (SQR (atmp) + SQR (btmp) + 0.001f); + editWhatever->v (i, j) = LIM01 ((chromapiplc) / (48000.f)); }//Lab L=f(C) pipette @@ -6034,43 +6069,43 @@ SSEFUNCTION void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBu float zz = 0.0f; float yy = 0.0f; - if(Chprov1 < chrmin) { - yy = SQR(Chprov1 / chrmin) * xx; + if (Chprov1 < chrmin) { + yy = SQR (Chprov1 / chrmin) * xx; } else { yy = xx; //avoid artifact for low C } - if(!LCredsk) { + if (!LCredsk) { skbeg = -3.1415; skend = 3.14159; skdeltaHH = 0.001f; } - if(HH > skbeg && HH < skend ) { + if (HH > skbeg && HH < skend ) { zz = yy; - } else if(HH > skbeg - skdeltaHH && HH <= skbeg) { //transition + } else if (HH > skbeg - skdeltaHH && HH <= skbeg) { //transition aa = yy / skdeltaHH; bb = -aa * (skbeg - skdeltaHH); zz = aa * HH + bb; - } else if(HH >= skend && HH < skend + skdeltaHH) { //transition + } else if (HH >= skend && HH < skend + skdeltaHH) { //transition aa = -yy / skdeltaHH; bb = -aa * (skend + skdeltaHH); zz = aa * HH + bb; } - float chroma = sqrt(SQR(atmp) + SQR(btmp) + 0.001f); + float chroma = sqrt (SQR (atmp) + SQR (btmp) + 0.001f); float Lc = (lhskcurve[chroma * adjustr]) / (chroma * adjustr); //apply L=f(C) Lc = (Lc - 1.0f) * zz + 1.0f; //reduct action Lprov1 *= Lc; //adjust luminance } //update histo LC - if(pW != 1) { //only with improccoordinator + if (pW != 1) { //only with improccoordinator int posl = Lprov1 * 327.68f; hist16Llad[posl]++; } - Chprov1 = sqrt(SQR(atmp) + SQR(btmp)) / 327.68f; + Chprov1 = sqrt (SQR (atmp) + SQR (btmp)) / 327.68f; // labCurve.bwtoning option allows to decouple modulation of a & b curves by saturation // with bwtoning enabled the net effect of a & b curves is visible @@ -6081,17 +6116,17 @@ SSEFUNCTION void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBu if (avoidColorShift) { //gamutmap Lch ==> preserve Hue,but a little slower than gamutbdy for high values...and little faster for low values - if(gamutLch) { + if (gamutLch) { float R, G, B; #ifdef _DEBUG bool neg = false; bool more_rgb = false; //gamut control : Lab values are in gamut - Color::gamutLchonly(HH, sincosval, Lprov1, Chprov1, R, G, B, wip, highlight, 0.15f, 0.96f, neg, more_rgb); + Color::gamutLchonly (HH, sincosval, Lprov1, Chprov1, R, G, B, wip, highlight, 0.15f, 0.96f, neg, more_rgb); #else //gamut control : Lab values are in gamut - Color::gamutLchonly(HH, sincosval, Lprov1, Chprov1, R, G, B, wip, highlight, 0.15f, 0.96f); + Color::gamutLchonly (HH, sincosval, Lprov1, Chprov1, R, G, B, wip, highlight, 0.15f, 0.96f); #endif lnew->L[i][j] = Lprov1 * 327.68f; // float2 sincosval = xsincosf(HH); @@ -6101,9 +6136,9 @@ SSEFUNCTION void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBu //use gamutbdy //Luv limiter float Y, u, v; - Color::Lab2Yuv(lnew->L[i][j], atmp, btmp, Y, u, v); + Color::Lab2Yuv (lnew->L[i][j], atmp, btmp, Y, u, v); //Yuv2Lab includes gamut restriction map - Color::Yuv2Lab(Y, u, v, lnew->L[i][j], lnew->a[i][j], lnew->b[i][j], wp); + Color::Yuv2Lab (Y, u, v, lnew->L[i][j], lnew->a[i][j], lnew->b[i][j], wp); } if (utili || autili || butili || ccut || clut || cclutili || chutili || lhutili || hhutili || clcutili || chromaticity) { @@ -6111,16 +6146,16 @@ SSEFUNCTION void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBu float correctlum = 0.f; Lprov1 = lnew->L[i][j] / 327.68f; - Chprov = sqrt(SQR(lnew->a[i][j]) + SQR(lnew->b[i][j])) / 327.68f; + Chprov = sqrt (SQR (lnew->a[i][j]) + SQR (lnew->b[i][j])) / 327.68f; #ifdef _DEBUG - Color::AllMunsellLch(/*lumaMuns*/true, Lprov1, LL, HH, Chprov, memChprov, correctionHue, correctlum, MunsDebugInfo); + Color::AllMunsellLch (/*lumaMuns*/true, Lprov1, LL, HH, Chprov, memChprov, correctionHue, correctlum, MunsDebugInfo); #else - Color::AllMunsellLch(/*lumaMuns*/true, Lprov1, LL, HH, Chprov, memChprov, correctionHue, correctlum); + Color::AllMunsellLch (/*lumaMuns*/true, Lprov1, LL, HH, Chprov, memChprov, correctionHue, correctlum); #endif - if(correctionHue != 0.f || correctlum != 0.f) { - if(fabs(correctionHue) < 0.015f) { + if (correctionHue != 0.f || correctlum != 0.f) { + if (fabs (correctionHue) < 0.015f) { HH += correctlum; // correct only if correct Munsell chroma very little. } @@ -6130,7 +6165,7 @@ SSEFUNCTION void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBu else if(fabs(correctionHue) < 0.1f) HH+=0.35f*correctlum; else if(fabs(correctionHue) < 0.015f) HH+=correctlum; // correct only if correct Munsell chroma very little. */ - sincosval = xsincosf(HH + correctionHue); + sincosval = xsincosf (HH + correctionHue); } lnew->a[i][j] = 327.68f * Chprov * sincosval.y; // apply Munsell @@ -6139,7 +6174,7 @@ SSEFUNCTION void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBu } else { // if(Lprov1 > maxlp) maxlp=Lprov1; // if(Lprov1 < minlp) minlp=Lprov1; - if(!bwToning) { + if (!bwToning) { lnew->L[i][j] = Lprov1 * 327.68f; // float2 sincosval = xsincosf(HH); lnew->a[i][j] = 327.68f * Chprov1 * sincosval.y; @@ -6154,20 +6189,20 @@ SSEFUNCTION void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBu } } // end of parallelization - if(pW != 1) { //only with improccoordinator + if (pW != 1) { //only with improccoordinator //update histogram C with data chromaticity and not with CC curve - hist16Clad.compressTo(histCCurve); + hist16Clad.compressTo (histCCurve); //update histogram L with data luminance - hist16Llad.compressTo(histLCurve); + hist16Llad.compressTo (histLCurve); } #ifdef _DEBUG if (settings->verbose) { t2e.set(); - printf("Color::AllMunsellLch (correction performed in %d usec):\n", t2e.etime(t1e)); - printf(" Munsell chrominance: MaxBP=%1.2frad MaxRY=%1.2frad MaxGY=%1.2frad MaxRP=%1.2frad dep=%u\n", MunsDebugInfo->maxdhue[0], MunsDebugInfo->maxdhue[1], MunsDebugInfo->maxdhue[2], MunsDebugInfo->maxdhue[3], MunsDebugInfo->depass); - printf(" Munsell luminance : MaxBP=%1.2frad MaxRY=%1.2frad MaxGY=%1.2frad MaxRP=%1.2frad dep=%u\n", MunsDebugInfo->maxdhuelum[0], MunsDebugInfo->maxdhuelum[1], MunsDebugInfo->maxdhuelum[2], MunsDebugInfo->maxdhuelum[3], MunsDebugInfo->depassLum); + printf ("Color::AllMunsellLch (correction performed in %d usec):\n", t2e.etime (t1e)); + printf (" Munsell chrominance: MaxBP=%1.2frad MaxRY=%1.2frad MaxGY=%1.2frad MaxRP=%1.2frad dep=%u\n", MunsDebugInfo->maxdhue[0], MunsDebugInfo->maxdhue[1], MunsDebugInfo->maxdhue[2], MunsDebugInfo->maxdhue[3], MunsDebugInfo->depass); + printf (" Munsell luminance : MaxBP=%1.2frad MaxRY=%1.2frad MaxGY=%1.2frad MaxRP=%1.2frad dep=%u\n", MunsDebugInfo->maxdhuelum[0], MunsDebugInfo->maxdhuelum[1], MunsDebugInfo->maxdhuelum[2], MunsDebugInfo->maxdhuelum[3], MunsDebugInfo->depassLum); } delete MunsDebugInfo; @@ -6298,69 +6333,69 @@ void ImProcFunctions::defringe (LabImage* lab) if (params->defringe.enabled && lab->W >= 8 && lab->H >= 8) { - PF_correct_RT(lab, lab, params->defringe.radius, params->defringe.threshold); + PF_correct_RT (lab, lab, params->defringe.radius, params->defringe.threshold); } } void ImProcFunctions::defringecam (CieImage* ncie) { if (params->defringe.enabled && ncie->W >= 8 && ncie->H >= 8) { - PF_correct_RTcam(ncie, ncie, params->defringe.radius, params->defringe.threshold); + PF_correct_RTcam (ncie, ncie, params->defringe.radius, params->defringe.threshold); } } -void ImProcFunctions::badpixcam(CieImage* ncie, double rad, int thr, int mode, float b_l, float t_l, float t_r, float b_r, float skinprot, float chrom, int hotbad) +void ImProcFunctions::badpixcam (CieImage* ncie, double rad, int thr, int mode, float b_l, float t_l, float t_r, float b_r, float skinprot, float chrom, int hotbad) { - if(ncie->W >= 8 && ncie->H >= 8) { - Badpixelscam(ncie, ncie, rad, thr, mode, b_l, t_l, t_r, b_r, skinprot, chrom, hotbad); + if (ncie->W >= 8 && ncie->H >= 8) { + Badpixelscam (ncie, ncie, rad, thr, mode, b_l, t_l, t_r, b_r, skinprot, chrom, hotbad); } } -void ImProcFunctions::badpixlab(LabImage* lab, double rad, int thr, int mode, float b_l, float t_l, float t_r, float b_r, float skinprot, float chrom) +void ImProcFunctions::badpixlab (LabImage* lab, double rad, int thr, int mode, float b_l, float t_l, float t_r, float b_r, float skinprot, float chrom) { - if(lab->W >= 8 && lab->H >= 8) { - BadpixelsLab(lab, lab, rad, thr, mode, b_l, t_l, t_r, b_r, skinprot, chrom); + if (lab->W >= 8 && lab->H >= 8) { + BadpixelsLab (lab, lab, rad, thr, mode, b_l, t_l, t_r, b_r, skinprot, chrom); } } void ImProcFunctions::dirpyrequalizer (LabImage* lab, int scale) { if (params->dirpyrequalizer.enabled && lab->W >= 8 && lab->H >= 8) { - float b_l = static_cast(params->dirpyrequalizer.hueskin.value[0]) / 100.0f; - float t_l = static_cast(params->dirpyrequalizer.hueskin.value[1]) / 100.0f; - float b_r = static_cast(params->dirpyrequalizer.hueskin.value[2]) / 100.0f; - float t_r = static_cast(params->dirpyrequalizer.hueskin.value[3]) / 100.0f; + float b_l = static_cast (params->dirpyrequalizer.hueskin.value[0]) / 100.0f; + float t_l = static_cast (params->dirpyrequalizer.hueskin.value[1]) / 100.0f; + float b_r = static_cast (params->dirpyrequalizer.hueskin.value[2]) / 100.0f; + float t_r = static_cast (params->dirpyrequalizer.hueskin.value[3]) / 100.0f; int choice = 0; //I have not disabled this statement in case of ! always 0 // if (params->dirpyrequalizer.algo=="FI") choice=0; // else if(params->dirpyrequalizer.algo=="LA") choice=1; float artifact = (float) settings->artifact_cbdl; - if(artifact > 6.f) { + if (artifact > 6.f) { artifact = 6.f; } - if(artifact < 0.f) { + if (artifact < 0.f) { artifact = 1.f; } float chrom = 50.f; - if(params->dirpyrequalizer.gamutlab) { + if (params->dirpyrequalizer.gamutlab) { ImProcFunctions::badpixlab (lab, artifact, 5, 3, b_l, t_l, t_r, b_r, params->dirpyrequalizer.skinprotect, chrom); //for artifacts } //dirpyrLab_equalizer(lab, lab, params->dirpyrequalizer.mult); - dirpyr_equalizer(lab->L, lab->L, lab->W, lab->H, lab->a, lab->b, lab->a, lab->b, params->dirpyrequalizer.mult, params->dirpyrequalizer.threshold, params->dirpyrequalizer.skinprotect, params->dirpyrequalizer.gamutlab, b_l, t_l, t_r, b_r, choice, scale); + dirpyr_equalizer (lab->L, lab->L, lab->W, lab->H, lab->a, lab->b, lab->a, lab->b, params->dirpyrequalizer.mult, params->dirpyrequalizer.threshold, params->dirpyrequalizer.skinprotect, params->dirpyrequalizer.gamutlab, b_l, t_l, t_r, b_r, choice, scale); } } -void ImProcFunctions::EPDToneMapCIE(CieImage *ncie, float a_w, float c_, float w_h, int Wid, int Hei, int begh, int endh, float minQ, float maxQ, unsigned int Iterates, int skip) +void ImProcFunctions::EPDToneMapCIE (CieImage *ncie, float a_w, float c_, float w_h, int Wid, int Hei, int begh, int endh, float minQ, float maxQ, unsigned int Iterates, int skip) { - if(!params->epd.enabled) { + if (!params->epd.enabled) { return; } - if(params->wavelet.enabled && params->wavelet.tmrs != 0) { + if (params->wavelet.enabled && params->wavelet.tmrs != 0) { return; } @@ -6373,14 +6408,14 @@ void ImProcFunctions::EPDToneMapCIE(CieImage *ncie, float a_w, float c_, float w float *Qpr = ncie->Q_p[0]; if (settings->verbose) { - printf("minQ=%f maxQ=%f Qpro=%f\n", minQ, maxQ, Qpro); + printf ("minQ=%f maxQ=%f Qpro=%f\n", minQ, maxQ, Qpro); } - if(maxQ > Qpro) { + if (maxQ > Qpro) { Qpro = maxQ; } - EdgePreservingDecomposition epd(Wid, Hei); + EdgePreservingDecomposition epd (Wid, Hei); #pragma omp parallel for @@ -6389,24 +6424,24 @@ void ImProcFunctions::EPDToneMapCIE(CieImage *ncie, float a_w, float c_, float w ncie->Q_p[i][j] = gamm * ncie->Q_p[i][j] / (Qpro); } - float Compression = expf(-stren); //This modification turns numbers symmetric around 0 into exponents. + float Compression = expf (-stren); //This modification turns numbers symmetric around 0 into exponents. float DetailBoost = stren; - if(stren < 0.0f) { + if (stren < 0.0f) { DetailBoost = 0.0f; //Go with effect of exponent only if uncompressing. } //Auto select number of iterates. Note that p->EdgeStopping = 0 makes a Gaussian blur. - if(Iterates == 0) { - Iterates = (unsigned int)(edgest * 15.0); + if (Iterates == 0) { + Iterates = (unsigned int) (edgest * 15.0); } //Jacques Desmis : always Iterates=5 for compatibility images between preview and output - epd.CompressDynamicRange(Qpr, (float)sca / skip, (float)edgest, Compression, DetailBoost, Iterates, rew, Qpr); + epd.CompressDynamicRange (Qpr, (float)sca / skip, (float)edgest, Compression, DetailBoost, Iterates, rew, Qpr); //Restore past range, also desaturate a bit per Mantiuk's Color correction for tone mapping. - float s = (1.0f + 38.7889f) * powf(Compression, 1.5856f) / (1.0f + 38.7889f * powf(Compression, 1.5856f)); + float s = (1.0f + 38.7889f) * powf (Compression, 1.5856f) / (1.0f + 38.7889f * powf (Compression, 1.5856f)); #ifndef _DEBUG #pragma omp parallel for schedule(dynamic,10) #endif @@ -6459,18 +6494,18 @@ void ImProcFunctions::EPDToneMapCIE(CieImage *ncie, float a_w, float c_, float w //Map tones by way of edge preserving decomposition. Is this the right way to include source? //#include "EdgePreservingDecomposition.cc" -void ImProcFunctions::EPDToneMap(LabImage *lab, unsigned int Iterates, int skip) +void ImProcFunctions::EPDToneMap (LabImage *lab, unsigned int Iterates, int skip) { //Hasten access to the parameters. // EPDParams *p = (EPDParams *)(¶ms->epd); //Enabled? Leave now if not. // if(!p->enabled) return; - if(!params->epd.enabled) { + if (!params->epd.enabled) { return; } - if(params->wavelet.enabled && params->wavelet.tmrs != 0) { + if (params->wavelet.enabled && params->wavelet.tmrs != 0) { return; } @@ -6484,7 +6519,7 @@ void ImProcFunctions::EPDToneMap(LabImage *lab, unsigned int Iterates, int skip) float *a = lab->a[0]; float *b = lab->b[0]; size_t N = lab->W * lab->H; - EdgePreservingDecomposition epd(lab->W, lab->H); + EdgePreservingDecomposition epd (lab->W, lab->H); //Due to the taking of logarithms, L must be nonnegative. Further, scale to 0 to 1 using nominal range of L, 0 to 15 bit. float minL = FLT_MAX; @@ -6495,35 +6530,35 @@ void ImProcFunctions::EPDToneMap(LabImage *lab, unsigned int Iterates, int skip) float lmaxL = 0.f; #pragma omp for - for(size_t i = 0; i < N; i++) { - if(L[i] < lminL) { + for (size_t i = 0; i < N; i++) { + if (L[i] < lminL) { lminL = L[i]; } - if(L[i] > lmaxL) { + if (L[i] > lmaxL) { lmaxL = L[i]; } } #pragma omp critical { - if(lminL < minL) { + if (lminL < minL) { minL = lminL; } - if(lmaxL > maxL) { + if (lmaxL > maxL) { maxL = lmaxL; } } } - if(minL > 0.0f) { + if (minL > 0.0f) { minL = 0.0f; //Disable the shift if there are no negative numbers. I wish there were just no negative numbers to begin with. } #pragma omp parallel for - for(size_t i = 0; i < N; ++i) + for (size_t i = 0; i < N; ++i) //{L[i] = (L[i] - minL)/32767.0f; { L[i] = (L[i] - minL) / maxL; @@ -6531,16 +6566,16 @@ void ImProcFunctions::EPDToneMap(LabImage *lab, unsigned int Iterates, int skip) } //Some interpretations. - float Compression = expf(-stren); //This modification turns numbers symmetric around 0 into exponents. + float Compression = expf (-stren); //This modification turns numbers symmetric around 0 into exponents. float DetailBoost = stren; - if(stren < 0.0f) { + if (stren < 0.0f) { DetailBoost = 0.0f; //Go with effect of exponent only if uncompressing. } //Auto select number of iterates. Note that p->EdgeStopping = 0 makes a Gaussian blur. - if(Iterates == 0) { - Iterates = (unsigned int)(edgest * 15.0f); + if (Iterates == 0) { + Iterates = (unsigned int) (edgest * 15.0f); } /* Debuggery. Saves L for toying with outside of RT. @@ -6550,15 +6585,15 @@ void ImProcFunctions::EPDToneMap(LabImage *lab, unsigned int Iterates, int skip) fwrite(L, N, sizeof(float), f); fclose(f);*/ - epd.CompressDynamicRange(L, sca / float(skip), edgest, Compression, DetailBoost, Iterates, rew, L); + epd.CompressDynamicRange (L, sca / float (skip), edgest, Compression, DetailBoost, Iterates, rew, L); //Restore past range, also desaturate a bit per Mantiuk's Color correction for tone mapping. - float s = (1.0f + 38.7889f) * powf(Compression, 1.5856f) / (1.0f + 38.7889f * powf(Compression, 1.5856f)); + float s = (1.0f + 38.7889f) * powf (Compression, 1.5856f) / (1.0f + 38.7889f * powf (Compression, 1.5856f)); #ifdef _OPENMP #pragma omp parallel for // removed schedule(dynamic,10) #endif - for(size_t ii = 0; ii < N; ++ii) { + for (size_t ii = 0; ii < N; ++ii) { a[ii] *= s; b[ii] *= s; L[ii] = L[ii] * maxL * (1.f / gamm) + minL; @@ -6579,7 +6614,7 @@ void ImProcFunctions::getAutoExp (const LUTu &histogram, int histcompr, double float ave = 0.f, hidev = 0.f, lodev = 0.f; //find average luminance - histogram.getSumAndAverage(sum, ave); + histogram.getSumAndAverage (sum, ave); //find median of luminance int median = 0, count = histogram[0]; @@ -6606,18 +6641,18 @@ void ImProcFunctions::getAutoExp (const LUTu &histogram, int histcompr, double int i = 0; - for (; i < min((int)ave, imax); i++) { + for (; i < min ((int)ave, imax); i++) { if (count < 8) { octile[count] += histogram[i]; if (octile[count] > sum / 8.f || (count == 7 && octile[count] > sum / 16.f)) { - octile[count] = xlog(1. + (float)i) / log(2.f); + octile[count] = xlog (1. + (float)i) / log (2.f); count++;// = min(count+1,7); } } //lodev += SQR(ave-i)*histogram[i]; - lodev += (xlog(ave + 1.f) - xlog((float)i + 1.)) * histogram[i]; + lodev += (xlog (ave + 1.f) - xlog ((float)i + 1.)) * histogram[i]; losum += histogram[i]; } @@ -6626,13 +6661,13 @@ void ImProcFunctions::getAutoExp (const LUTu &histogram, int histcompr, double octile[count] += histogram[i]; if (octile[count] > sum / 8.f || (count == 7 && octile[count] > sum / 16.f)) { - octile[count] = xlog(1. + (float)i) / log(2.f); + octile[count] = xlog (1. + (float)i) / log (2.f); count++;// = min(count+1,7); } } //hidev += SQR(i-ave)*histogram[i]; - hidev += (xlog((float)i + 1.) - xlog(ave + 1.f)) * histogram[i]; + hidev += (xlog ((float)i + 1.) - xlog (ave + 1.f)) * histogram[i]; hisum += histogram[i]; } @@ -6650,12 +6685,12 @@ void ImProcFunctions::getAutoExp (const LUTu &histogram, int histcompr, double // lodev = (lodev / (log(2.f) * losum)); // hidev = (hidev / (log(2.f) * hisum)); - if (octile[6] > log1p((float)imax) / log2(2.f)) { //if very overxposed image + if (octile[6] > log1p ((float)imax) / log2 (2.f)) { //if very overxposed image octile[6] = 1.5f * octile[5] - 0.5f * octile[4]; overex = 2; } - if (octile[7] > log1p((float)imax) / log2(2.f)) { //if overexposed + if (octile[7] > log1p ((float)imax) / log2 (2.f)) { //if overexposed octile[7] = 1.5f * octile[6] - 0.5f * octile[5]; overex = 1; } @@ -6668,7 +6703,7 @@ void ImProcFunctions::getAutoExp (const LUTu &histogram, int histcompr, double oct7 = octile[7]; - for(int i = 1; i < 8; i++) { + for (int i = 1; i < 8; i++) { if (octile[i] == 0.0f) { octile[i] = octile[i - 1]; } @@ -6677,7 +6712,7 @@ void ImProcFunctions::getAutoExp (const LUTu &histogram, int histcompr, double // compute weighted average separation of octiles // for future use in contrast setting for (int i = 1; i < 6; i++) { - ospread += (octile[i + 1] - octile[i]) / max(0.5f, (i > 2 ? (octile[i + 1] - octile[3]) : (octile[3] - octile[i]))); + ospread += (octile[i + 1] - octile[i]) / max (0.5f, (i > 2 ? (octile[i + 1] - octile[3]) : (octile[3] - octile[i]))); } ospread /= 5.f; @@ -6703,7 +6738,7 @@ void ImProcFunctions::getAutoExp (const LUTu &histogram, int histcompr, double } //compute clipped white point - unsigned int clippable = (int)(sum * clip / 100.f ); + unsigned int clippable = (int) (sum * clip / 100.f ); clipped = 0; int whiteclip = (imax) - 1; @@ -6737,24 +6772,24 @@ void ImProcFunctions::getAutoExp (const LUTu &histogram, int histcompr, double //sets the mean or median at middle gray, and the amount that sets the estimated top //of the histogram at or near clipping. //float expcomp1 = (log(/*(median/ave)*//*(hidev/lodev)*/midgray*scale/(ave-shc+midgray*shc))+log((hidev/lodev)))/log(2.f); - float expcomp1 = (log(/*(median/ave)*//*(hidev/lodev)*/midgray * scale / (ave - shc + midgray * shc))) / log(2.f); + float expcomp1 = (log (/*(median/ave)*//*(hidev/lodev)*/midgray * scale / (ave - shc + midgray * shc))) / log (2.f); float expcomp2; - if(overex == 0) { // image is not overexposed - expcomp2 = 0.5f * ( (15.5f - histcompr - (2.f * oct7 - oct6)) + log(scale / rawmax) / log(2.f) ); + if (overex == 0) { // image is not overexposed + expcomp2 = 0.5f * ( (15.5f - histcompr - (2.f * oct7 - oct6)) + log (scale / rawmax) / log (2.f) ); } else { - expcomp2 = 0.5f * ( (15.5f - histcompr - (2.f * octile[7] - octile[6])) + log(scale / rawmax) / log(2.f) ); + expcomp2 = 0.5f * ( (15.5f - histcompr - (2.f * octile[7] - octile[6])) + log (scale / rawmax) / log (2.f) ); } - if(fabs(expcomp1) - fabs(expcomp2) > 1.f) { //for great expcomp - expcomp = (expcomp1 * fabs(expcomp2) + expcomp2 * fabs(expcomp1)) / (fabs(expcomp1) + fabs(expcomp2)); + if (fabs (expcomp1) - fabs (expcomp2) > 1.f) { //for great expcomp + expcomp = (expcomp1 * fabs (expcomp2) + expcomp2 * fabs (expcomp1)) / (fabs (expcomp1) + fabs (expcomp2)); } else { expcomp = 0.5 * (double)expcomp1 + 0.5 * (double) expcomp2; //for small expcomp } - float gain = exp((float)expcomp * log(2.f)); + float gain = exp ((float)expcomp * log (2.f)); - float corr = sqrt(gain * scale / rawmax); + float corr = sqrt (gain * scale / rawmax); black = (int) shc * corr; @@ -6763,12 +6798,12 @@ void ImProcFunctions::getAutoExp (const LUTu &histogram, int histcompr, double //this is a series approximation of the actual formula for comp, //which is a transcendental equation float comp = (gain * ((float)whiteclip) / scale - 1.f) * 2.3f; // 2.3 instead of 2 to increase slightly comp - hlcompr = (int)(100.*comp / (max(0.0, expcomp) + 1.0)); - hlcompr = max(0, min(100, hlcompr)); + hlcompr = (int) (100.*comp / (max (0.0, expcomp) + 1.0)); + hlcompr = max (0, min (100, hlcompr)); //now find brightness if gain didn't bring ave to midgray using //the envelope of the actual 'control cage' brightness curve for simplicity - float midtmp = gain * sqrt(median * ave) / scale; + float midtmp = gain * sqrt (median * ave) / scale; if (midtmp < 0.1f) { bright = (midgray - midtmp) * 15.0 / (midtmp); @@ -6776,13 +6811,13 @@ void ImProcFunctions::getAutoExp (const LUTu &histogram, int histcompr, double bright = (midgray - midtmp) * 15.0 / (0.10833 - 0.0833 * midtmp); } - bright = 0.25 */*(median/ave)*(hidev/lodev)*/max(0, bright); + bright = 0.25 */*(median/ave)*(hidev/lodev)*/max (0, bright); //compute contrast that spreads the average spacing of octiles contr = (int) 50.0f * (1.1f - ospread); - contr = max(0, min(100, contr)); + contr = max (0, min (100, contr)); //take gamma into account - double whiteclipg = (int)(CurveFactory::gamma2 (whiteclip * corr / 65536.0) * 65536.0); + double whiteclipg = (int) (CurveFactory::gamma2 (whiteclip * corr / 65536.0) * 65536.0); float gavg = 0.; @@ -6804,10 +6839,10 @@ void ImProcFunctions::getAutoExp (const LUTu &histogram, int histcompr, double } } - whiteclipg = CurveFactory::igamma2 ((float)(whiteclipg / 65535.0)) * 65535.0; //need to inverse gamma transform to get correct exposure compensation parameter + whiteclipg = CurveFactory::igamma2 ((float) (whiteclipg / 65535.0)) * 65535.0; //need to inverse gamma transform to get correct exposure compensation parameter //corection with gamma - black = (int)((65535 * black) / whiteclipg); + black = (int) ((65535 * black) / whiteclipg); //expcomp = log(65535.0 / (whiteclipg)) / log(2.0); //diagnostics @@ -6863,7 +6898,7 @@ void ImProcFunctions::getAutoExp (const LUTu &histogram, int histcompr, double expcomp = 12.0; } - bright = max(-100, min(bright, 100)); + bright = max (-100, min (bright, 100)); } @@ -6926,7 +6961,7 @@ double ImProcFunctions::getAutoDistor (const Glib::ustring &fname, int thumb_si double dist_amount; int dist_result = calcDistortion (thumbGray, rawGray, width, h_thumb, 1, dist_amount); - if(dist_result == -1) { // not enough features found, try increasing max. number of features by factor 4 + if (dist_result == -1) { // not enough features found, try increasing max. number of features by factor 4 calcDistortion (thumbGray, rawGray, width, h_thumb, 4, dist_amount); } @@ -6940,13 +6975,13 @@ double ImProcFunctions::getAutoDistor (const Glib::ustring &fname, int thumb_si } } -void ImProcFunctions::rgb2lab(const Imagefloat &src, LabImage &dst, const Glib::ustring &workingSpace) +void ImProcFunctions::rgb2lab (const Imagefloat &src, LabImage &dst, const Glib::ustring &workingSpace) { - TMatrix wprof = ICCStore::getInstance()->workingSpaceMatrix( workingSpace ); + TMatrix wprof = ICCStore::getInstance()->workingSpaceMatrix ( workingSpace ); const float wp[3][3] = { - {static_cast(wprof[0][0]), static_cast(wprof[0][1]), static_cast(wprof[0][2])}, - {static_cast(wprof[1][0]), static_cast(wprof[1][1]), static_cast(wprof[1][2])}, - {static_cast(wprof[2][0]), static_cast(wprof[2][1]), static_cast(wprof[2][2])} + {static_cast (wprof[0][0]), static_cast (wprof[0][1]), static_cast (wprof[0][2])}, + {static_cast (wprof[1][0]), static_cast (wprof[1][1]), static_cast (wprof[1][2])}, + {static_cast (wprof[2][0]), static_cast (wprof[2][1]), static_cast (wprof[2][2])} }; const int W = src.getWidth(); @@ -6956,23 +6991,23 @@ void ImProcFunctions::rgb2lab(const Imagefloat &src, LabImage &dst, const Glib:: #pragma omp parallel for schedule(dynamic,16) #endif - for(int i = 0; i < H; i++) { - for(int j = 0; j < W; j++) { + for (int i = 0; i < H; i++) { + for (int j = 0; j < W; j++) { float X, Y, Z; - Color::rgbxyz(src.r(i, j), src.g(i, j), src.b(i, j), X, Y, Z, wp); + Color::rgbxyz (src.r (i, j), src.g (i, j), src.b (i, j), X, Y, Z, wp); //convert Lab - Color::XYZ2Lab(X, Y, Z, dst.L[i][j], dst.a[i][j], dst.b[i][j]); + Color::XYZ2Lab (X, Y, Z, dst.L[i][j], dst.a[i][j], dst.b[i][j]); } } } -SSEFUNCTION void ImProcFunctions::lab2rgb(const LabImage &src, Imagefloat &dst, const Glib::ustring &workingSpace) +SSEFUNCTION void ImProcFunctions::lab2rgb (const LabImage &src, Imagefloat &dst, const Glib::ustring &workingSpace) { - TMatrix wiprof = ICCStore::getInstance()->workingSpaceInverseMatrix( workingSpace ); + TMatrix wiprof = ICCStore::getInstance()->workingSpaceInverseMatrix ( workingSpace ); const float wip[3][3] = { - {static_cast(wiprof[0][0]), static_cast(wiprof[0][1]), static_cast(wiprof[0][2])}, - {static_cast(wiprof[1][0]), static_cast(wiprof[1][1]), static_cast(wiprof[1][2])}, - {static_cast(wiprof[2][0]), static_cast(wiprof[2][1]), static_cast(wiprof[2][2])} + {static_cast (wiprof[0][0]), static_cast (wiprof[0][1]), static_cast (wiprof[0][2])}, + {static_cast (wiprof[1][0]), static_cast (wiprof[1][1]), static_cast (wiprof[1][2])}, + {static_cast (wiprof[2][0]), static_cast (wiprof[2][1]), static_cast (wiprof[2][2])} }; const int W = dst.getWidth(); @@ -6980,9 +7015,9 @@ SSEFUNCTION void ImProcFunctions::lab2rgb(const LabImage &src, Imagefloat &dst, #ifdef __SSE2__ vfloat wipv[3][3]; - for(int i = 0; i < 3; i++) { - for(int j = 0; j < 3; j++) { - wipv[i][j] = F2V(wiprof[i][j]); + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 3; j++) { + wipv[i][j] = F2V (wiprof[i][j]); } } @@ -6992,26 +7027,26 @@ SSEFUNCTION void ImProcFunctions::lab2rgb(const LabImage &src, Imagefloat &dst, #pragma omp parallel for schedule(dynamic,16) #endif - for(int i = 0; i < H; i++) { + for (int i = 0; i < H; i++) { int j = 0; #ifdef __SSE2__ - for(; j < W - 3; j += 4) { + for (; j < W - 3; j += 4) { vfloat X, Y, Z; vfloat R, G, B; - Color::Lab2XYZ(LVFU(src.L[i][j]), LVFU(src.a[i][j]), LVFU(src.b[i][j]), X, Y, Z); - Color::xyz2rgb(X, Y, Z, R, G, B, wipv); - STVFU(dst.r(i, j), R); - STVFU(dst.g(i, j), G); - STVFU(dst.b(i, j), B); + Color::Lab2XYZ (LVFU (src.L[i][j]), LVFU (src.a[i][j]), LVFU (src.b[i][j]), X, Y, Z); + Color::xyz2rgb (X, Y, Z, R, G, B, wipv); + STVFU (dst.r (i, j), R); + STVFU (dst.g (i, j), G); + STVFU (dst.b (i, j), B); } #endif - for(; j < W; j++) { + for (; j < W; j++) { float X, Y, Z; - Color::Lab2XYZ(src.L[i][j], src.a[i][j], src.b[i][j], X, Y, Z); - Color::xyz2rgb(X, Y, Z, dst.r(i, j), dst.g(i, j), dst.b(i, j), wip); + Color::Lab2XYZ (src.L[i][j], src.a[i][j], src.b[i][j], X, Y, Z); + Color::xyz2rgb (X, Y, Z, dst.r (i, j), dst.g (i, j), dst.b (i, j), wip); } } } diff --git a/rtgui/colorappearance.cc b/rtgui/colorappearance.cc index cdcfb10f2..59bdb4b31 100644 --- a/rtgui/colorappearance.cc +++ b/rtgui/colorappearance.cc @@ -24,12 +24,12 @@ using namespace rtengine; using namespace rtengine::procparams; -ColorAppearance::ColorAppearance () : FoldableToolPanel(this, "colorappearance", M("TP_COLORAPP_LABEL"), false, true) +ColorAppearance::ColorAppearance () : FoldableToolPanel (this, "colorappearance", M ("TP_COLORAPP_LABEL"), false, true) { - CurveListener::setMulti(true); + CurveListener::setMulti (true); std::vector milestones; - milestones.push_back( GradientMilestone(0., 0., 0., 0.) ); - milestones.push_back( GradientMilestone(1., 1., 1., 1.) ); + milestones.push_back ( GradientMilestone (0., 0., 0., 0.) ); + milestones.push_back ( GradientMilestone (1., 1., 1., 1.) ); // ------------------------ Process #1: Converting to CIECAM @@ -40,51 +40,51 @@ ColorAppearance::ColorAppearance () : FoldableToolPanel(this, "colorappearance", // Vertical box container for the content of the Process 1 frame Gtk::VBox *p1VBox; - p1Frame = Gtk::manage (new Gtk::Frame(M("TP_COLORAPP_LABEL_SCENE")) ); - p1Frame->set_label_align(0.025, 0.5); + p1Frame = Gtk::manage (new Gtk::Frame (M ("TP_COLORAPP_LABEL_SCENE")) ); + p1Frame->set_label_align (0.025, 0.5); p1VBox = Gtk::manage ( new Gtk::VBox()); - p1VBox->set_spacing(2); + p1VBox->set_spacing (2); - degree = Gtk::manage (new Adjuster (M("TP_COLORAPP_CIECAT_DEGREE"), 0., 100., 1., 100.)); + degree = Gtk::manage (new Adjuster (M ("TP_COLORAPP_CIECAT_DEGREE"), 0., 100., 1., 100.)); if (degree->delay < options.adjusterMaxDelay) { degree->delay = options.adjusterMaxDelay; } degree->throwOnButtonRelease(); - degree->addAutoButton(M("TP_COLORAPP_DEGREE_AUTO_TOOLTIP")); - degree->set_tooltip_markup (M("TP_COLORAPP_DEGREE_TOOLTIP")); + degree->addAutoButton (M ("TP_COLORAPP_DEGREE_AUTO_TOOLTIP")); + degree->set_tooltip_markup (M ("TP_COLORAPP_DEGREE_TOOLTIP")); p1VBox->pack_start (*degree); - surrsource = Gtk::manage (new Gtk::CheckButton (M("TP_COLORAPP_SURSOURCE"))); - surrsource->set_tooltip_markup (M("TP_COLORAPP_SURSOURCE_TOOLTIP")); + surrsource = Gtk::manage (new Gtk::CheckButton (M ("TP_COLORAPP_SURSOURCE"))); + surrsource->set_tooltip_markup (M ("TP_COLORAPP_SURSOURCE_TOOLTIP")); p1VBox->pack_start (*surrsource, Gtk::PACK_SHRINK); Gtk::HBox* wbmHBox = Gtk::manage (new Gtk::HBox ()); wbmHBox->set_spacing (2); - wbmHBox->set_tooltip_markup (M("TP_COLORAPP_MODEL_TOOLTIP")); - Gtk::Label* wbmLab = Gtk::manage (new Gtk::Label (M("TP_COLORAPP_MODEL") + ":")); + wbmHBox->set_tooltip_markup (M ("TP_COLORAPP_MODEL_TOOLTIP")); + Gtk::Label* wbmLab = Gtk::manage (new Gtk::Label (M ("TP_COLORAPP_MODEL") + ":")); wbmHBox->pack_start (*wbmLab, Gtk::PACK_SHRINK); wbmodel = Gtk::manage (new MyComboBoxText ()); - wbmodel->append (M("TP_COLORAPP_WBRT")); - wbmodel->append (M("TP_COLORAPP_WBCAM")); + wbmodel->append (M ("TP_COLORAPP_WBRT")); + wbmodel->append (M ("TP_COLORAPP_WBCAM")); wbmodel->set_active (0); wbmHBox->pack_start (*wbmodel); p1VBox->pack_start (*wbmHBox); - adapscen = Gtk::manage (new Adjuster (M("TP_COLORAPP_ADAPTSCENE"), 0.001, 16384., 0.001, 2000.));// EV -7 ==> EV 17 + adapscen = Gtk::manage (new Adjuster (M ("TP_COLORAPP_ADAPTSCENE"), 0.001, 16384., 0.001, 2000.)); // EV -7 ==> EV 17 if (adapscen->delay < options.adjusterMaxDelay) { adapscen->delay = options.adjusterMaxDelay; } adapscen->throwOnButtonRelease(); - adapscen->addAutoButton(M("TP_COLORAPP_ADAP_AUTO_TOOLTIP")); - adapscen->set_tooltip_markup (M("TP_COLORAPP_ADAPTSCENE_TOOLTIP")); + adapscen->addAutoButton (M ("TP_COLORAPP_ADAP_AUTO_TOOLTIP")); + adapscen->set_tooltip_markup (M ("TP_COLORAPP_ADAPTSCENE_TOOLTIP")); p1VBox->pack_start (*adapscen); - p1Frame->add(*p1VBox); + p1Frame->add (*p1VBox); pack_start (*p1Frame, Gtk::PACK_EXPAND_WIDGET, 4); @@ -96,123 +96,123 @@ ColorAppearance::ColorAppearance () : FoldableToolPanel(this, "colorappearance", // Vertical box container for the content of the Process 1 frame Gtk::VBox *p2VBox; - p2Frame = Gtk::manage (new Gtk::Frame(M("TP_COLORAPP_LABEL_CAM02")) ); - p2Frame->set_label_align(0.025, 0.5); + p2Frame = Gtk::manage (new Gtk::Frame (M ("TP_COLORAPP_LABEL_CAM02")) ); + p2Frame->set_label_align (0.025, 0.5); p2VBox = Gtk::manage ( new Gtk::VBox()); - p2VBox->set_spacing(2); + p2VBox->set_spacing (2); Gtk::HBox* alHBox = Gtk::manage (new Gtk::HBox ()); alHBox->set_spacing (2); - alHBox->set_tooltip_markup (M("TP_COLORAPP_ALGO_TOOLTIP")); - Gtk::Label* alLabel = Gtk::manage (new Gtk::Label (M("TP_COLORAPP_ALGO") + ":")); + alHBox->set_tooltip_markup (M ("TP_COLORAPP_ALGO_TOOLTIP")); + Gtk::Label* alLabel = Gtk::manage (new Gtk::Label (M ("TP_COLORAPP_ALGO") + ":")); alHBox->pack_start (*alLabel, Gtk::PACK_SHRINK); algo = Gtk::manage (new MyComboBoxText ()); - algo->append (M("TP_COLORAPP_ALGO_JC")); - algo->append (M("TP_COLORAPP_ALGO_JS")); - algo->append (M("TP_COLORAPP_ALGO_QM")); - algo->append (M("TP_COLORAPP_ALGO_ALL")); + algo->append (M ("TP_COLORAPP_ALGO_JC")); + algo->append (M ("TP_COLORAPP_ALGO_JS")); + algo->append (M ("TP_COLORAPP_ALGO_QM")); + algo->append (M ("TP_COLORAPP_ALGO_ALL")); algo->set_active (0); alHBox->pack_start (*algo); p2VBox->pack_start (*alHBox); p2VBox->pack_start (*Gtk::manage (new Gtk::HSeparator()), Gtk::PACK_EXPAND_WIDGET, 4); - jlight = Gtk::manage (new Adjuster (M("TP_COLORAPP_LIGHT"), -100.0, 100.0, 0.1, 0.)); + jlight = Gtk::manage (new Adjuster (M ("TP_COLORAPP_LIGHT"), -100.0, 100.0, 0.1, 0.)); if (jlight->delay < options.adjusterMaxDelay) { jlight->delay = options.adjusterMaxDelay; } jlight->throwOnButtonRelease(); - jlight->set_tooltip_markup (M("TP_COLORAPP_LIGHT_TOOLTIP")); + jlight->set_tooltip_markup (M ("TP_COLORAPP_LIGHT_TOOLTIP")); p2VBox->pack_start (*jlight); - qbright = Gtk::manage (new Adjuster (M("TP_COLORAPP_BRIGHT"), -100.0, 100.0, 0.1, 0.)); + qbright = Gtk::manage (new Adjuster (M ("TP_COLORAPP_BRIGHT"), -100.0, 100.0, 0.1, 0.)); if (qbright->delay < options.adjusterMaxDelay) { qbright->delay = options.adjusterMaxDelay; } qbright->throwOnButtonRelease(); - qbright->set_tooltip_markup (M("TP_COLORAPP_BRIGHT_TOOLTIP")); + qbright->set_tooltip_markup (M ("TP_COLORAPP_BRIGHT_TOOLTIP")); p2VBox->pack_start (*qbright); - chroma = Gtk::manage (new Adjuster (M("TP_COLORAPP_CHROMA"), -100.0, 100.0, 0.1, 0.)); + chroma = Gtk::manage (new Adjuster (M ("TP_COLORAPP_CHROMA"), -100.0, 100.0, 0.1, 0.)); if (chroma->delay < options.adjusterMaxDelay) { chroma->delay = options.adjusterMaxDelay; } chroma->throwOnButtonRelease(); - chroma->set_tooltip_markup (M("TP_COLORAPP_CHROMA_TOOLTIP")); + chroma->set_tooltip_markup (M ("TP_COLORAPP_CHROMA_TOOLTIP")); p2VBox->pack_start (*chroma); - schroma = Gtk::manage (new Adjuster (M("TP_COLORAPP_CHROMA_S"), -100.0, 100.0, 0.1, 0.)); + schroma = Gtk::manage (new Adjuster (M ("TP_COLORAPP_CHROMA_S"), -100.0, 100.0, 0.1, 0.)); if (schroma->delay < options.adjusterMaxDelay) { schroma->delay = options.adjusterMaxDelay; } schroma->throwOnButtonRelease(); - schroma->set_tooltip_markup (M("TP_COLORAPP_CHROMA_S_TOOLTIP")); + schroma->set_tooltip_markup (M ("TP_COLORAPP_CHROMA_S_TOOLTIP")); p2VBox->pack_start (*schroma); - mchroma = Gtk::manage (new Adjuster (M("TP_COLORAPP_CHROMA_M"), -100.0, 100.0, 0.1, 0.)); + mchroma = Gtk::manage (new Adjuster (M ("TP_COLORAPP_CHROMA_M"), -100.0, 100.0, 0.1, 0.)); if (mchroma->delay < options.adjusterMaxDelay) { mchroma->delay = options.adjusterMaxDelay; } mchroma->throwOnButtonRelease(); - mchroma->set_tooltip_markup (M("TP_COLORAPP_CHROMA_M_TOOLTIP")); + mchroma->set_tooltip_markup (M ("TP_COLORAPP_CHROMA_M_TOOLTIP")); p2VBox->pack_start (*mchroma); - rstprotection = Gtk::manage ( new Adjuster (M("TP_COLORAPP_RSTPRO"), 0., 100., 0.1, 0.) ); + rstprotection = Gtk::manage ( new Adjuster (M ("TP_COLORAPP_RSTPRO"), 0., 100., 0.1, 0.) ); if (rstprotection->delay < options.adjusterMaxDelay) { rstprotection->delay = options.adjusterMaxDelay; } rstprotection->throwOnButtonRelease(); - rstprotection->set_tooltip_markup (M("TP_COLORAPP_RSTPRO_TOOLTIP")); + rstprotection->set_tooltip_markup (M ("TP_COLORAPP_RSTPRO_TOOLTIP")); p2VBox->pack_start (*rstprotection); - contrast = Gtk::manage (new Adjuster (M("TP_COLORAPP_CONTRAST"), -100.0, 100.0, 0.1, 0.)); + contrast = Gtk::manage (new Adjuster (M ("TP_COLORAPP_CONTRAST"), -100.0, 100.0, 0.1, 0.)); if (contrast->delay < options.adjusterMaxDelay) { contrast->delay = options.adjusterMaxDelay; } contrast->throwOnButtonRelease(); - contrast->set_tooltip_markup (M("TP_COLORAPP_CONTRAST_TOOLTIP")); + contrast->set_tooltip_markup (M ("TP_COLORAPP_CONTRAST_TOOLTIP")); p2VBox->pack_start (*contrast); - qcontrast = Gtk::manage (new Adjuster (M("TP_COLORAPP_CONTRAST_Q"), -100.0, 100.0, 0.1, 0.)); + qcontrast = Gtk::manage (new Adjuster (M ("TP_COLORAPP_CONTRAST_Q"), -100.0, 100.0, 0.1, 0.)); if (qcontrast->delay < options.adjusterMaxDelay) { qcontrast->delay = options.adjusterMaxDelay; } qcontrast->throwOnButtonRelease(); - qcontrast->set_tooltip_markup (M("TP_COLORAPP_CONTRAST_Q_TOOLTIP")); + qcontrast->set_tooltip_markup (M ("TP_COLORAPP_CONTRAST_Q_TOOLTIP")); p2VBox->pack_start (*qcontrast); - colorh = Gtk::manage (new Adjuster (M("TP_COLORAPP_HUE"), -100.0, 100.0, 0.1, 0.)); + colorh = Gtk::manage (new Adjuster (M ("TP_COLORAPP_HUE"), -100.0, 100.0, 0.1, 0.)); if (colorh->delay < options.adjusterMaxDelay) { colorh->delay = options.adjusterMaxDelay; } colorh->throwOnButtonRelease(); - colorh->set_tooltip_markup (M("TP_COLORAPP_HUE_TOOLTIP")); + colorh->set_tooltip_markup (M ("TP_COLORAPP_HUE_TOOLTIP")); p2VBox->pack_start (*colorh); - tonecie = Gtk::manage (new Gtk::CheckButton (M("TP_COLORAPP_TONECIE"))); - tonecie->set_tooltip_markup (M("TP_COLORAPP_TONECIE_TOOLTIP")); - tonecieconn = tonecie->signal_toggled().connect( sigc::mem_fun(*this, &ColorAppearance::tonecie_toggled) ); + tonecie = Gtk::manage (new Gtk::CheckButton (M ("TP_COLORAPP_TONECIE"))); + tonecie->set_tooltip_markup (M ("TP_COLORAPP_TONECIE_TOOLTIP")); + tonecieconn = tonecie->signal_toggled().connect ( sigc::mem_fun (*this, &ColorAppearance::tonecie_toggled) ); p2VBox->pack_start (*tonecie); /* sharpcie = Gtk::manage (new Gtk::CheckButton (M("TP_COLORAPP_SHARPCIE"))); @@ -223,52 +223,52 @@ ColorAppearance::ColorAppearance () : FoldableToolPanel(this, "colorappearance", p2VBox->pack_start (*Gtk::manage (new Gtk::HSeparator()), Gtk::PACK_EXPAND_WIDGET, 4); toneCurveMode = Gtk::manage (new MyComboBoxText ()); - toneCurveMode->append (M("TP_COLORAPP_TCMODE_LIGHTNESS")); - toneCurveMode->append (M("TP_COLORAPP_TCMODE_BRIGHTNESS")); + toneCurveMode->append (M ("TP_COLORAPP_TCMODE_LIGHTNESS")); + toneCurveMode->append (M ("TP_COLORAPP_TCMODE_BRIGHTNESS")); toneCurveMode->set_active (0); - toneCurveMode->set_tooltip_text(M("TP_COLORAPP_TCMODE_LABEL1")); + toneCurveMode->set_tooltip_text (M ("TP_COLORAPP_TCMODE_LABEL1")); - curveEditorG = new CurveEditorGroup (options.lastToneCurvesDir, M("TP_COLORAPP_CURVEEDITOR1")); + curveEditorG = new CurveEditorGroup (options.lastToneCurvesDir, M ("TP_COLORAPP_CURVEEDITOR1")); curveEditorG->setCurveListener (this); - curveEditorG->setTooltip(M("TP_COLORAPP_CURVEEDITOR1_TOOLTIP")); + curveEditorG->setTooltip (M ("TP_COLORAPP_CURVEEDITOR1_TOOLTIP")); - shape = static_cast(curveEditorG->addCurve(CT_Diagonal, "", toneCurveMode)); + shape = static_cast (curveEditorG->addCurve (CT_Diagonal, "", toneCurveMode)); - tcmodeconn = toneCurveMode->signal_changed().connect( sigc::mem_fun(*this, &ColorAppearance::curveMode1Changed), true ); + tcmodeconn = toneCurveMode->signal_changed().connect ( sigc::mem_fun (*this, &ColorAppearance::curveMode1Changed), true ); toneCurveMode2 = Gtk::manage (new MyComboBoxText ()); - toneCurveMode2->append (M("TP_COLORAPP_TCMODE_LIGHTNESS")); - toneCurveMode2->append (M("TP_COLORAPP_TCMODE_BRIGHTNESS")); + toneCurveMode2->append (M ("TP_COLORAPP_TCMODE_LIGHTNESS")); + toneCurveMode2->append (M ("TP_COLORAPP_TCMODE_BRIGHTNESS")); toneCurveMode2->set_active (0); - toneCurveMode2->set_tooltip_text(M("TP_COLORAPP_TCMODE_LABEL2")); + toneCurveMode2->set_tooltip_text (M ("TP_COLORAPP_TCMODE_LABEL2")); - curveEditorG2 = new CurveEditorGroup (options.lastToneCurvesDir, M("TP_COLORAPP_CURVEEDITOR2")); + curveEditorG2 = new CurveEditorGroup (options.lastToneCurvesDir, M ("TP_COLORAPP_CURVEEDITOR2")); curveEditorG2->setCurveListener (this); - shape2 = static_cast(curveEditorG2->addCurve(CT_Diagonal, "", toneCurveMode2)); + shape2 = static_cast (curveEditorG2->addCurve (CT_Diagonal, "", toneCurveMode2)); - tcmode2conn = toneCurveMode2->signal_changed().connect( sigc::mem_fun(*this, &ColorAppearance::curveMode2Changed), true ); + tcmode2conn = toneCurveMode2->signal_changed().connect ( sigc::mem_fun (*this, &ColorAppearance::curveMode2Changed), true ); toneCurveMode3 = Gtk::manage (new MyComboBoxText ()); - toneCurveMode3->append (M("TP_COLORAPP_TCMODE_CHROMA")); - toneCurveMode3->append (M("TP_COLORAPP_TCMODE_SATUR")); - toneCurveMode3->append (M("TP_COLORAPP_TCMODE_COLORF")); + toneCurveMode3->append (M ("TP_COLORAPP_TCMODE_CHROMA")); + toneCurveMode3->append (M ("TP_COLORAPP_TCMODE_SATUR")); + toneCurveMode3->append (M ("TP_COLORAPP_TCMODE_COLORF")); toneCurveMode3->set_active (0); - toneCurveMode3->set_tooltip_text(M("TP_COLORAPP_TCMODE_LABEL3")); + toneCurveMode3->set_tooltip_text (M ("TP_COLORAPP_TCMODE_LABEL3")); - curveEditorG3 = new CurveEditorGroup (options.lastToneCurvesDir, M("TP_COLORAPP_CURVEEDITOR3")); + curveEditorG3 = new CurveEditorGroup (options.lastToneCurvesDir, M ("TP_COLORAPP_CURVEEDITOR3")); curveEditorG3->setCurveListener (this); - shape3 = static_cast(curveEditorG3->addCurve(CT_Diagonal, "", toneCurveMode3)); - shape3->setRangeLabels( - M("TP_LABCURVE_CURVEEDITOR_CC_RANGE1"), M("TP_LABCURVE_CURVEEDITOR_CC_RANGE2"), - M("TP_LABCURVE_CURVEEDITOR_CC_RANGE3"), M("TP_LABCURVE_CURVEEDITOR_CC_RANGE4") + shape3 = static_cast (curveEditorG3->addCurve (CT_Diagonal, "", toneCurveMode3)); + shape3->setRangeLabels ( + M ("TP_LABCURVE_CURVEEDITOR_CC_RANGE1"), M ("TP_LABCURVE_CURVEEDITOR_CC_RANGE2"), + M ("TP_LABCURVE_CURVEEDITOR_CC_RANGE3"), M ("TP_LABCURVE_CURVEEDITOR_CC_RANGE4") ); - shape3->setBottomBarColorProvider(this, 1); - shape3->setLeftBarColorProvider(this, 1); - shape3->setRangeDefaultMilestones(0.05, 0.2, 0.58); + shape3->setBottomBarColorProvider (this, 1); + shape3->setLeftBarColorProvider (this, 1); + shape3->setRangeDefaultMilestones (0.05, 0.2, 0.58); // shape3->setBottomBarColorProvider(this, 2); @@ -278,51 +278,51 @@ ColorAppearance::ColorAppearance () : FoldableToolPanel(this, "colorappearance", // The milestones are still the same than those define above //milestones.push_back( GradientMilestone(0., 0., 0., 0.) ); //milestones.push_back( GradientMilestone(1., 1., 1., 1.) ); - shape->setBottomBarBgGradient(milestones); - shape->setLeftBarBgGradient(milestones); - shape2->setBottomBarBgGradient(milestones); - shape2->setLeftBarBgGradient(milestones); + shape->setBottomBarBgGradient (milestones); + shape->setLeftBarBgGradient (milestones); + shape2->setBottomBarBgGradient (milestones); + shape2->setLeftBarBgGradient (milestones); std::vector shape3Milestones; float R, G, B; for (int i = 0; i < 7; i++) { - float x = float(i) * (1.0f / 6.0); - Color::hsv2rgb01(x, 0.5f, 0.5f, R, G, B); - shape3Milestones.push_back( GradientMilestone(double(x), double(R), double(G), double(B)) ); + float x = float (i) * (1.0f / 6.0); + Color::hsv2rgb01 (x, 0.5f, 0.5f, R, G, B); + shape3Milestones.push_back ( GradientMilestone (double (x), double (R), double (G), double (B)) ); } - shape3->setBottomBarBgGradient(shape3Milestones); - shape3->setLeftBarBgGradient(shape3Milestones); + shape3->setBottomBarBgGradient (shape3Milestones); + shape3->setLeftBarBgGradient (shape3Milestones); - shape3->setRangeDefaultMilestones(0.05, 0.2, 0.58); + shape3->setRangeDefaultMilestones (0.05, 0.2, 0.58); curveEditorG->curveListComplete(); curveEditorG2->curveListComplete(); - curveEditorG2->setTooltip(M("TP_COLORAPP_CURVEEDITOR2_TOOLTIP")); + curveEditorG2->setTooltip (M ("TP_COLORAPP_CURVEEDITOR2_TOOLTIP")); curveEditorG3->curveListComplete(); - curveEditorG3->setTooltip(M("TP_COLORAPP_CURVEEDITOR3_TOOLTIP")); - tcmode3conn = toneCurveMode3->signal_changed().connect( sigc::mem_fun(*this, &ColorAppearance::curveMode3Changed), true ); + curveEditorG3->setTooltip (M ("TP_COLORAPP_CURVEEDITOR3_TOOLTIP")); + tcmode3conn = toneCurveMode3->signal_changed().connect ( sigc::mem_fun (*this, &ColorAppearance::curveMode3Changed), true ); - p2VBox->pack_start( *curveEditorG, Gtk::PACK_SHRINK, 2); - p2VBox->pack_start( *curveEditorG2, Gtk::PACK_SHRINK, 2); - p2VBox->pack_start( *curveEditorG3, Gtk::PACK_SHRINK, 2); + p2VBox->pack_start ( *curveEditorG, Gtk::PACK_SHRINK, 2); + p2VBox->pack_start ( *curveEditorG2, Gtk::PACK_SHRINK, 2); + p2VBox->pack_start ( *curveEditorG3, Gtk::PACK_SHRINK, 2); // ------------------------ Choice CIECAM data - datacie = Gtk::manage (new Gtk::CheckButton (M("TP_COLORAPP_DATACIE"))); - datacie->set_tooltip_markup (M("TP_COLORAPP_DATACIE_TOOLTIP")); - datacieconn = datacie->signal_toggled().connect( sigc::mem_fun(*this, &ColorAppearance::datacie_toggled) ); + datacie = Gtk::manage (new Gtk::CheckButton (M ("TP_COLORAPP_DATACIE"))); + datacie->set_tooltip_markup (M ("TP_COLORAPP_DATACIE_TOOLTIP")); + datacieconn = datacie->signal_toggled().connect ( sigc::mem_fun (*this, &ColorAppearance::datacie_toggled) ); p2VBox->pack_start (*datacie); //------------------------- - p2Frame->add(*p2VBox); + p2Frame->add (*p2VBox); pack_start (*p2Frame, Gtk::PACK_EXPAND_WIDGET, 4); @@ -337,46 +337,46 @@ ColorAppearance::ColorAppearance () : FoldableToolPanel(this, "colorappearance", // Vertical box container for the content of the Process 3 frame Gtk::VBox *p3VBox; - p3Frame = Gtk::manage (new Gtk::Frame(M("TP_COLORAPP_LABEL_VIEWING")) ); // "Editing viewing conditions" ??? - p3Frame->set_label_align(0.025, 0.5); + p3Frame = Gtk::manage (new Gtk::Frame (M ("TP_COLORAPP_LABEL_VIEWING")) ); // "Editing viewing conditions" ??? + p3Frame->set_label_align (0.025, 0.5); p3VBox = Gtk::manage ( new Gtk::VBox()); - p3VBox->set_spacing(2); + p3VBox->set_spacing (2); - adaplum = Gtk::manage (new Adjuster (M("TP_COLORAPP_ADAPTVIEWING"), 0.1, 1000., 0.1, 16.)); + adaplum = Gtk::manage (new Adjuster (M ("TP_COLORAPP_ADAPTVIEWING"), 0.1, 1000., 0.1, 16.)); if (adaplum->delay < options.adjusterMaxDelay) { adaplum->delay = options.adjusterMaxDelay; } adaplum->throwOnButtonRelease(); - adaplum->set_tooltip_markup (M("TP_COLORAPP_ADAPTVIEWING_TOOLTIP")); + adaplum->set_tooltip_markup (M ("TP_COLORAPP_ADAPTVIEWING_TOOLTIP")); p3VBox->pack_start (*adaplum); Gtk::HBox* surrHBox = Gtk::manage (new Gtk::HBox ()); surrHBox->set_spacing (2); - surrHBox->set_tooltip_markup(M("TP_COLORAPP_SURROUND_TOOLTIP")); - Gtk::Label* surrLabel = Gtk::manage (new Gtk::Label (M("TP_COLORAPP_SURROUND") + ":")); + surrHBox->set_tooltip_markup (M ("TP_COLORAPP_SURROUND_TOOLTIP")); + Gtk::Label* surrLabel = Gtk::manage (new Gtk::Label (M ("TP_COLORAPP_SURROUND") + ":")); surrHBox->pack_start (*surrLabel, Gtk::PACK_SHRINK); surround = Gtk::manage (new MyComboBoxText ()); - surround->append (M("TP_COLORAPP_SURROUND_AVER")); - surround->append (M("TP_COLORAPP_SURROUND_DIM")); - surround->append (M("TP_COLORAPP_SURROUND_DARK")); - surround->append (M("TP_COLORAPP_SURROUND_EXDARK")); + surround->append (M ("TP_COLORAPP_SURROUND_AVER")); + surround->append (M ("TP_COLORAPP_SURROUND_DIM")); + surround->append (M ("TP_COLORAPP_SURROUND_DARK")); + surround->append (M ("TP_COLORAPP_SURROUND_EXDARK")); surround->set_active (1); surrHBox->pack_start (*surround); p3VBox->pack_start (*surrHBox); - p3Frame->add(*p3VBox); + p3Frame->add (*p3VBox); pack_start (*p3Frame, Gtk::PACK_EXPAND_WIDGET, 4); // ------------------------ Lab Gamut control - gamut = Gtk::manage (new Gtk::CheckButton (M("TP_COLORAPP_GAMUT"))); - gamut->set_tooltip_markup (M("TP_COLORAPP_GAMUT_TOOLTIP")); - gamutconn = gamut->signal_toggled().connect( sigc::mem_fun(*this, &ColorAppearance::gamut_toggled) ); + gamut = Gtk::manage (new Gtk::CheckButton (M ("TP_COLORAPP_GAMUT"))); + gamut->set_tooltip_markup (M ("TP_COLORAPP_GAMUT_TOOLTIP")); + gamutconn = gamut->signal_toggled().connect ( sigc::mem_fun (*this, &ColorAppearance::gamut_toggled) ); pack_start (*gamut, Gtk::PACK_SHRINK); // ------------------------ Bad pixel control @@ -387,23 +387,23 @@ ColorAppearance::ColorAppearance () : FoldableToolPanel(this, "colorappearance", badpixconn = badpix->signal_toggled().connect( sigc::mem_fun(*this, &ColorAppearance::badpix_toggled) ); pack_start (*badpix, Gtk::PACK_SHRINK); */ - badpixsl = Gtk::manage (new Adjuster (M("TP_COLORAPP_BADPIXSL"), 0, 2, 1, 0)); + badpixsl = Gtk::manage (new Adjuster (M ("TP_COLORAPP_BADPIXSL"), 0, 2, 1, 0)); if (badpixsl->delay < options.adjusterMaxDelay) { badpixsl->delay = options.adjusterMaxDelay; } badpixsl->throwOnButtonRelease(); - badpixsl->set_tooltip_markup (M("TP_COLORAPP_BADPIXSL_TOOLTIP")); + badpixsl->set_tooltip_markup (M ("TP_COLORAPP_BADPIXSL_TOOLTIP")); pack_start (*badpixsl, Gtk::PACK_SHRINK); // ------------------------ Listening events - surrconn = surrsource->signal_toggled().connect( sigc::mem_fun(*this, &ColorAppearance::surrsource_toggled) ); - wbmodelconn = wbmodel->signal_changed().connect ( sigc::mem_fun(*this, &ColorAppearance::wbmodelChanged) ); - algoconn = algo->signal_changed().connect ( sigc::mem_fun(*this, &ColorAppearance::algoChanged) ); - surroundconn = surround->signal_changed().connect ( sigc::mem_fun(*this, &ColorAppearance::surroundChanged) ); + surrconn = surrsource->signal_toggled().connect ( sigc::mem_fun (*this, &ColorAppearance::surrsource_toggled) ); + wbmodelconn = wbmodel->signal_changed().connect ( sigc::mem_fun (*this, &ColorAppearance::wbmodelChanged) ); + algoconn = algo->signal_changed().connect ( sigc::mem_fun (*this, &ColorAppearance::algoChanged) ); + surroundconn = surround->signal_changed().connect ( sigc::mem_fun (*this, &ColorAppearance::surroundChanged) ); degree->setAdjusterListener (this); adapscen->setAdjusterListener (this); @@ -433,12 +433,12 @@ ColorAppearance::~ColorAppearance () -bool ColorAppearance::bgTTipQuery(int x, int y, bool keyboard_tooltip, const Glib::RefPtr& tooltip) +bool ColorAppearance::bgTTipQuery (int x, int y, bool keyboard_tooltip, const Glib::RefPtr& tooltip) { return true; } -bool ColorAppearance::srTTipQuery(int x, int y, bool keyboard_tooltip, const Glib::RefPtr& tooltip) +bool ColorAppearance::srTTipQuery (int x, int y, bool keyboard_tooltip, const Glib::RefPtr& tooltip) { return true; } @@ -447,15 +447,15 @@ void ColorAppearance::read (const ProcParams* pp, const ParamsEdited* pedited) { disableListener (); - tcmodeconn.block(true); - tcmode2conn.block(true); - tcmode3conn.block(true); + tcmodeconn.block (true); + tcmode2conn.block (true); + tcmode3conn.block (true); shape->setCurve (pp->colorappearance.curve); shape2->setCurve (pp->colorappearance.curve2); shape3->setCurve (pp->colorappearance.curve3); - toneCurveMode->set_active(pp->colorappearance.curveMode); - toneCurveMode2->set_active(pp->colorappearance.curveMode2); - toneCurveMode3->set_active(pp->colorappearance.curveMode3); + toneCurveMode->set_active (pp->colorappearance.curveMode); + toneCurveMode2->set_active (pp->colorappearance.curveMode2); + toneCurveMode3->set_active (pp->colorappearance.curveMode3); curveMode3Changed(); // This will set the correct sensitive state of depending Adjusters if (pedited) { @@ -488,23 +488,23 @@ void ColorAppearance::read (const ProcParams* pp, const ParamsEdited* pedited) shape3->setUnChanged (!pedited->colorappearance.curve3); if (!pedited->colorappearance.curveMode) { - toneCurveMode->set_active(2); + toneCurveMode->set_active (2); } if (!pedited->colorappearance.curveMode2) { - toneCurveMode2->set_active(2); + toneCurveMode2->set_active (2); } if (!pedited->colorappearance.curveMode3) { - toneCurveMode3->set_active(3); + toneCurveMode3->set_active (3); } } - setEnabled(pp->colorappearance.enabled); + setEnabled (pp->colorappearance.enabled); - surroundconn.block(true); + surroundconn.block (true); if (pedited && !pedited->colorappearance.surround) { surround->set_active (4); @@ -518,11 +518,11 @@ void ColorAppearance::read (const ProcParams* pp, const ParamsEdited* pedited) surround->set_active (3); } - surroundconn.block(false); + surroundconn.block (false); // Have to be manually called to handle initial state update surroundChanged(); - wbmodelconn.block(true); + wbmodelconn.block (true); if (pedited && !pedited->colorappearance.wbmodel) { wbmodel->set_active (2); @@ -532,11 +532,11 @@ void ColorAppearance::read (const ProcParams* pp, const ParamsEdited* pedited) wbmodel->set_active (1); } - wbmodelconn.block(false); + wbmodelconn.block (false); // Have to be manually called to handle initial state update wbmodelChanged(); - algoconn.block(true); + algoconn.block (true); if (pedited && !pedited->colorappearance.algo) { algo->set_active (4); @@ -550,7 +550,7 @@ void ColorAppearance::read (const ProcParams* pp, const ParamsEdited* pedited) algo->set_active (3); } - algoconn.block(false); + algoconn.block (false); // Have to be manually called to handle initial state update algoChanged(); @@ -584,7 +584,7 @@ void ColorAppearance::read (const ProcParams* pp, const ParamsEdited* pedited) lastAutoAdapscen = pp->colorappearance.autoadapscen; degree->setValue (pp->colorappearance.degree); - degree->setAutoValue(pp->colorappearance.autodegree); + degree->setAutoValue (pp->colorappearance.autodegree); adapscen->setValue (pp->colorappearance.adapscen); adapscen->setAutoValue (pp->colorappearance.autoadapscen); @@ -600,9 +600,9 @@ void ColorAppearance::read (const ProcParams* pp, const ParamsEdited* pedited) qcontrast->setValue (pp->colorappearance.qcontrast); colorh->setValue (pp->colorappearance.colorh); - tcmode3conn.block(false); - tcmode2conn.block(false); - tcmodeconn.block(false); + tcmode3conn.block (false); + tcmode2conn.block (false); + tcmodeconn.block (false); enableListener (); } void ColorAppearance::autoOpenCurve () @@ -686,9 +686,9 @@ void ColorAppearance::write (ProcParams* pp, ParamsEdited* pedited) pedited->colorappearance.autodegree = !degree->getAutoInconsistent(); pedited->colorappearance.autoadapscen = !adapscen->getAutoInconsistent(); pedited->colorappearance.enabled = !get_inconsistent(); - pedited->colorappearance.surround = surround->get_active_text() != M("GENERAL_UNCHANGED"); - pedited->colorappearance.wbmodel = wbmodel->get_active_text() != M("GENERAL_UNCHANGED"); - pedited->colorappearance.algo = algo->get_active_text() != M("GENERAL_UNCHANGED"); + pedited->colorappearance.surround = surround->get_active_text() != M ("GENERAL_UNCHANGED"); + pedited->colorappearance.wbmodel = wbmodel->get_active_text() != M ("GENERAL_UNCHANGED"); + pedited->colorappearance.algo = algo->get_active_text() != M ("GENERAL_UNCHANGED"); pedited->colorappearance.surrsource = !surrsource->get_inconsistent(); pedited->colorappearance.gamut = !gamut->get_inconsistent(); // pedited->colorappearance.badpix = !badpix->get_inconsistent(); @@ -735,11 +735,11 @@ void ColorAppearance::curveChanged (CurveEditor* ce) if (listener) { if (ce == shape) { - listener->panelChanged (EvCATCurve1, M("HISTORY_CUSTOMCURVE")); + listener->panelChanged (EvCATCurve1, M ("HISTORY_CUSTOMCURVE")); } else if (ce == shape2) { - listener->panelChanged (EvCATCurve2, M("HISTORY_CUSTOMCURVE")); + listener->panelChanged (EvCATCurve2, M ("HISTORY_CUSTOMCURVE")); } else if (ce == shape3) { - listener->panelChanged (EvCATCurve3, M("HISTORY_CUSTOMCURVE")); + listener->panelChanged (EvCATCurve3, M ("HISTORY_CUSTOMCURVE")); } } } @@ -747,7 +747,7 @@ void ColorAppearance::curveChanged (CurveEditor* ce) void ColorAppearance::curveMode1Changed () { if (listener) { - Glib::signal_idle().connect (sigc::mem_fun(*this, &ColorAppearance::curveMode1Changed_)); + Glib::signal_idle().connect (sigc::mem_fun (*this, &ColorAppearance::curveMode1Changed_)); } } @@ -763,7 +763,7 @@ bool ColorAppearance::curveMode1Changed_ () void ColorAppearance::curveMode2Changed () { if (listener) { - Glib::signal_idle().connect (sigc::mem_fun(*this, &ColorAppearance::curveMode2Changed_)); + Glib::signal_idle().connect (sigc::mem_fun (*this, &ColorAppearance::curveMode2Changed_)); } } @@ -781,18 +781,18 @@ void ColorAppearance::curveMode3Changed () int tcMode3 = toneCurveMode3->get_active_row_number(); if (tcMode3 == 0) { - chroma->set_sensitive(true); - schroma->set_sensitive(true); + chroma->set_sensitive (true); + schroma->set_sensitive (true); } else if (tcMode3 == 2) { - chroma->set_sensitive(false); - schroma->set_sensitive(false); + chroma->set_sensitive (false); + schroma->set_sensitive (false); } else if (tcMode3 == 1) { - chroma->set_sensitive(false); - schroma->set_sensitive(true); + chroma->set_sensitive (false); + schroma->set_sensitive (true); } if (listener) { - Glib::signal_idle().connect (sigc::mem_fun(*this, &ColorAppearance::curveMode3Changed_)); + Glib::signal_idle().connect (sigc::mem_fun (*this, &ColorAppearance::curveMode3Changed_)); } } @@ -823,9 +823,9 @@ void ColorAppearance::surrsource_toggled () if (listener) { if (surrsource->get_active ()) { - listener->panelChanged (EvCATsurr, M("GENERAL_ENABLED")); + listener->panelChanged (EvCATsurr, M ("GENERAL_ENABLED")); } else { - listener->panelChanged (EvCATsurr, M("GENERAL_DISABLED")); + listener->panelChanged (EvCATsurr, M ("GENERAL_DISABLED")); } } } @@ -848,9 +848,9 @@ void ColorAppearance::gamut_toggled () if (listener) { if (gamut->get_active ()) { - listener->panelChanged (EvCATgamut, M("GENERAL_ENABLED")); + listener->panelChanged (EvCATgamut, M ("GENERAL_ENABLED")); } else { - listener->panelChanged (EvCATgamut, M("GENERAL_DISABLED")); + listener->panelChanged (EvCATgamut, M ("GENERAL_DISABLED")); } } @@ -899,9 +899,9 @@ void ColorAppearance::datacie_toggled () if (listener) { if (datacie->get_active ()) { - listener->panelChanged (EvCATdatacie, M("GENERAL_ENABLED")); + listener->panelChanged (EvCATdatacie, M ("GENERAL_ENABLED")); } else { - listener->panelChanged (EvCATdatacie, M("GENERAL_DISABLED")); + listener->panelChanged (EvCATdatacie, M ("GENERAL_DISABLED")); } } } @@ -923,9 +923,9 @@ void ColorAppearance::tonecie_toggled () if (listener) { if (tonecie->get_active ()) { - listener->panelChanged (EvCATtonecie, M("GENERAL_ENABLED")); + listener->panelChanged (EvCATtonecie, M ("GENERAL_ENABLED")); } else { - listener->panelChanged (EvCATtonecie, M("GENERAL_DISABLED")); + listener->panelChanged (EvCATtonecie, M ("GENERAL_DISABLED")); } } @@ -1009,12 +1009,12 @@ void ColorAppearance::autoCamChanged (double ccam) { nextCcam = ccam; - const auto func = [](gpointer data) -> gboolean { - static_cast(data)->autoCamComputed_(); + const auto func = [] (gpointer data) -> gboolean { + static_cast (data)->autoCamComputed_(); return FALSE; }; - idle_register.add(func, this); + idle_register.add (func, this); } bool ColorAppearance::autoCamComputed_ () @@ -1032,12 +1032,12 @@ void ColorAppearance::adapCamChanged (double cadap) { nextCadap = cadap; - const auto func = [](gpointer data) -> gboolean { - static_cast(data)->adapCamComputed_(); + const auto func = [] (gpointer data) -> gboolean { + static_cast (data)->adapCamComputed_(); return FALSE; }; - idle_register.add(func, this); + idle_register.add (func, this); } bool ColorAppearance::adapCamComputed_ () @@ -1063,46 +1063,46 @@ void ColorAppearance::colorForValue (double valX, double valY, enum ColorCaller: if (callerId == 1) { // cc - bottom bar - float value = (1.f - 0.7f) * float(valX) + 0.7f; + float value = (1.f - 0.7f) * float (valX) + 0.7f; // whole hue range // Y axis / from 0.15 up to 0.75 (arbitrary values; was 0.45 before) - Color::hsv2rgb01(float(valY), float(valX), value, R, G, B); + Color::hsv2rgb01 (float (valY), float (valX), value, R, G, B); } - caller->ccRed = double(R); - caller->ccGreen = double(G); - caller->ccBlue = double(B); + caller->ccRed = double (R); + caller->ccGreen = double (G); + caller->ccBlue = double (B); } void ColorAppearance::adjusterChanged (Adjuster* a, double newval) { if (listener && (multiImage || getEnabled()) ) { - if(a == degree) { + if (a == degree) { listener->panelChanged (EvCATDegree, a->getTextValue()); - } else if(a == adapscen) { + } else if (a == adapscen) { listener->panelChanged (EvCATAdapscen, a->getTextValue()); - } else if(a == adaplum) { + } else if (a == adaplum) { listener->panelChanged (EvCATAdapLum, a->getTextValue()); - } else if(a == badpixsl) { + } else if (a == badpixsl) { listener->panelChanged (EvCATbadpix, a->getTextValue()); - } else if(a == jlight) { + } else if (a == jlight) { listener->panelChanged (EvCATJLight, a->getTextValue()); - } else if(a == qbright) { + } else if (a == qbright) { listener->panelChanged (EvCATQbright, a->getTextValue()); - } else if(a == chroma) { + } else if (a == chroma) { listener->panelChanged (EvCATChroma, a->getTextValue()); - } else if(a == schroma) { + } else if (a == schroma) { listener->panelChanged (EvCATSChroma, a->getTextValue()); - } else if(a == mchroma) { + } else if (a == mchroma) { listener->panelChanged (EvCATMChroma, a->getTextValue()); - } else if(a == rstprotection) { + } else if (a == rstprotection) { listener->panelChanged (EvCATRstpro, a->getTextValue()); - } else if(a == contrast) { + } else if (a == contrast) { listener->panelChanged (EvCATContrast, a->getTextValue()); - } else if(a == colorh) { + } else if (a == colorh) { listener->panelChanged (EvCAThue, a->getTextValue()); - } else if(a == qcontrast) { + } else if (a == qcontrast) { listener->panelChanged (EvCATQContrast, a->getTextValue()); } @@ -1114,19 +1114,19 @@ void ColorAppearance::adjusterAutoToggled (Adjuster* a, bool newval) if (multiImage) { if (degree->getAutoInconsistent()) { - degree->setAutoInconsistent(false); - degree->setAutoValue(false); + degree->setAutoInconsistent (false); + degree->setAutoValue (false); } else if (lastAutoDegree) { - degree->setAutoInconsistent(true); + degree->setAutoInconsistent (true); } lastAutoDegree = degree->getAutoValue(); if (adapscen->getAutoInconsistent()) { - adapscen->setAutoInconsistent(false); - adapscen->setAutoValue(false); + adapscen->setAutoInconsistent (false); + adapscen->setAutoValue (false); } else if (lastAutoAdapscen) { - adapscen->setAutoInconsistent(true); + adapscen->setAutoInconsistent (true); } lastAutoAdapscen = adapscen->getAutoValue(); @@ -1135,23 +1135,23 @@ void ColorAppearance::adjusterAutoToggled (Adjuster* a, bool newval) if (listener && (multiImage || getEnabled()) ) { - if(a == degree) { + if (a == degree) { if (degree->getAutoInconsistent()) { - listener->panelChanged (EvCATAutoDegree, M("GENERAL_UNCHANGED")); + listener->panelChanged (EvCATAutoDegree, M ("GENERAL_UNCHANGED")); } else if (degree->getAutoValue()) { - listener->panelChanged (EvCATAutoDegree, M("GENERAL_ENABLED")); + listener->panelChanged (EvCATAutoDegree, M ("GENERAL_ENABLED")); } else { - listener->panelChanged (EvCATAutoDegree, M("GENERAL_DISABLED")); + listener->panelChanged (EvCATAutoDegree, M ("GENERAL_DISABLED")); } } - if(a == adapscen) { + if (a == adapscen) { if (adapscen->getAutoInconsistent()) { - listener->panelChanged (EvCATAutoAdap, M("GENERAL_UNCHANGED")); + listener->panelChanged (EvCATAutoAdap, M ("GENERAL_UNCHANGED")); } else if (adapscen->getAutoValue()) { - listener->panelChanged (EvCATAutoAdap, M("GENERAL_ENABLED")); + listener->panelChanged (EvCATAutoAdap, M ("GENERAL_ENABLED")); } else { - listener->panelChanged (EvCATAutoAdap, M("GENERAL_DISABLED")); + listener->panelChanged (EvCATAutoAdap, M ("GENERAL_DISABLED")); } } @@ -1163,13 +1163,13 @@ void ColorAppearance::enabledChanged () if (listener) { if (get_inconsistent()) { - listener->panelChanged (EvCATEnabled, M("GENERAL_UNCHANGED")); + listener->panelChanged (EvCATEnabled, M ("GENERAL_UNCHANGED")); } else if (getEnabled()) { - listener->panelChanged (EvCATEnabled, M("GENERAL_ENABLED")); + listener->panelChanged (EvCATEnabled, M ("GENERAL_ENABLED")); curveEditorG->set_sensitive (true); toneCurveMode->set_sensitive (true); } else { - listener->panelChanged (EvCATEnabled, M("GENERAL_DISABLED")); + listener->panelChanged (EvCATEnabled, M ("GENERAL_DISABLED")); } } } @@ -1282,12 +1282,12 @@ void ColorAppearance::setBatchMode (bool batchMode) qcontrast->showEditedCB (); colorh->showEditedCB (); - surround->append (M("GENERAL_UNCHANGED")); - wbmodel->append (M("GENERAL_UNCHANGED")); - algo->append (M("GENERAL_UNCHANGED")); - toneCurveMode->append (M("GENERAL_UNCHANGED")); - toneCurveMode2->append (M("GENERAL_UNCHANGED")); - toneCurveMode3->append (M("GENERAL_UNCHANGED")); + surround->append (M ("GENERAL_UNCHANGED")); + wbmodel->append (M ("GENERAL_UNCHANGED")); + algo->append (M ("GENERAL_UNCHANGED")); + toneCurveMode->append (M ("GENERAL_UNCHANGED")); + toneCurveMode2->append (M ("GENERAL_UNCHANGED")); + toneCurveMode3->append (M ("GENERAL_UNCHANGED")); curveEditorG->setBatchMode (batchMode); curveEditorG2->setBatchMode (batchMode); @@ -1306,35 +1306,35 @@ void ColorAppearance::updateCurveBackgroundHistogram (LUTu & histToneCurve, LUTu void ColorAppearance::setAdjusterBehavior (bool degreeadd, bool adapscenadd, bool adaplumadd, bool badpixsladd, bool jlightadd, bool chromaadd, bool contrastadd, bool rstprotectionadd, bool qbrightadd, bool qcontrastadd, bool schromaadd, bool mchromaadd, bool colorhadd) { - degree->setAddMode(degreeadd); - adapscen->setAddMode(adapscenadd); - adaplum->setAddMode(adaplumadd); - badpixsl->setAddMode(badpixsladd); - jlight->setAddMode(jlightadd); - qbright->setAddMode(qbrightadd); - chroma->setAddMode(chromaadd); - schroma->setAddMode(schromaadd); - mchroma->setAddMode(mchromaadd); - rstprotection->setAddMode(rstprotectionadd); - contrast->setAddMode(contrastadd); - qcontrast->setAddMode(qcontrastadd); - colorh->setAddMode(colorhadd); + degree->setAddMode (degreeadd); + adapscen->setAddMode (adapscenadd); + adaplum->setAddMode (adaplumadd); + badpixsl->setAddMode (badpixsladd); + jlight->setAddMode (jlightadd); + qbright->setAddMode (qbrightadd); + chroma->setAddMode (chromaadd); + schroma->setAddMode (schromaadd); + mchroma->setAddMode (mchromaadd); + rstprotection->setAddMode (rstprotectionadd); + contrast->setAddMode (contrastadd); + qcontrast->setAddMode (qcontrastadd); + colorh->setAddMode (colorhadd); } void ColorAppearance::trimValues (rtengine::procparams::ProcParams* pp) { - degree->trimValue(pp->colorappearance.degree); - adapscen->trimValue(pp->colorappearance.adapscen); - adaplum->trimValue(pp->colorappearance.adaplum); - badpixsl->trimValue(pp->colorappearance.badpixsl); - jlight->trimValue(pp->colorappearance.jlight); - qbright->trimValue(pp->colorappearance.qbright); - chroma->trimValue(pp->colorappearance.chroma); - schroma->trimValue(pp->colorappearance.schroma); - mchroma->trimValue(pp->colorappearance.mchroma); - rstprotection->trimValue(pp->colorappearance.rstprotection); - contrast->trimValue(pp->colorappearance.contrast); - qcontrast->trimValue(pp->colorappearance.qcontrast); - colorh->trimValue(pp->colorappearance.colorh); + degree->trimValue (pp->colorappearance.degree); + adapscen->trimValue (pp->colorappearance.adapscen); + adaplum->trimValue (pp->colorappearance.adaplum); + badpixsl->trimValue (pp->colorappearance.badpixsl); + jlight->trimValue (pp->colorappearance.jlight); + qbright->trimValue (pp->colorappearance.qbright); + chroma->trimValue (pp->colorappearance.chroma); + schroma->trimValue (pp->colorappearance.schroma); + mchroma->trimValue (pp->colorappearance.mchroma); + rstprotection->trimValue (pp->colorappearance.rstprotection); + contrast->trimValue (pp->colorappearance.contrast); + qcontrast->trimValue (pp->colorappearance.qcontrast); + colorh->trimValue (pp->colorappearance.colorh); }