From 7a714e5093d6b8cdac8f0ab4c8bd60cf88fb8aba Mon Sep 17 00:00:00 2001 From: Desmis Date: Wed, 3 Jan 2018 16:47:54 +0100 Subject: [PATCH] Add inverse to shapemethod - fixed crash retinex inverse --- rtengine/color.cc | 1652 ++++++++++++++-------------- rtengine/color.h | 474 ++++---- rtengine/curves.cc | 980 ++++++++--------- rtengine/curves.h | 467 ++++---- rtengine/dirpyr_equalizer.cc | 194 ++-- rtengine/imagedata.cc | 522 ++++----- rtengine/improcfun.cc | 126 ++- rtengine/iplocallab.cc | 28 +- rtengine/ipretinex.cc | 176 +-- rtengine/procparams.cc | 11 +- rtengine/rawimage.cc | 126 +-- rtengine/rawimage.h | 55 +- rtengine/rawimagesource.cc | 1963 +++++++++++++++++----------------- rtengine/rawimagesource.h | 162 +-- rtengine/simpleprocess.cc | 50 +- rtgui/locallab.cc | 2 +- rtgui/preferences.cc | 98 +- 17 files changed, 3583 insertions(+), 3503 deletions(-) diff --git a/rtengine/color.cc b/rtengine/color.cc index 21a76a07b..cea66f5c5 100644 --- a/rtengine/color.cc +++ b/rtengine/color.cc @@ -130,34 +130,34 @@ void MunsellDebugInfo::reinitValues() #endif -void Color::init () +void Color::init() { /*******************************************/ constexpr auto maxindex = 65536; - cachef (maxindex, LUT_CLIP_BELOW); - gammatab (maxindex, 0); - gammatabThumb (maxindex, 0); + cachef(maxindex, LUT_CLIP_BELOW); + gammatab(maxindex, 0); + gammatabThumb(maxindex, 0); - igammatab_srgb (maxindex, 0); - igammatab_srgb1 (maxindex, 0); - gammatab_srgb (maxindex, 0); - gammatab_srgb1 (maxindex, 0); - gammatab_srgb327 (32768, 0); + igammatab_srgb(maxindex, 0); + igammatab_srgb1(maxindex, 0); + gammatab_srgb(maxindex, 0); + gammatab_srgb1(maxindex, 0); + gammatab_srgb327(32768, 0); - denoiseGammaTab (maxindex, 0); - denoiseIGammaTab (maxindex, 0); + denoiseGammaTab(maxindex, 0); + denoiseIGammaTab(maxindex, 0); - igammatab_24_17 (maxindex, 0); - gammatab_24_17a (maxindex, LUT_CLIP_ABOVE | LUT_CLIP_BELOW); - gammatab_13_2 (maxindex, 0); - igammatab_13_2 (maxindex, 0); - gammatab_115_2 (maxindex, 0); - igammatab_115_2 (maxindex, 0); - gammatab_145_3 (maxindex, 0); - igammatab_145_3 (maxindex, 0); + igammatab_24_17(maxindex, 0); + gammatab_24_17a(maxindex, LUT_CLIP_ABOVE | LUT_CLIP_BELOW); + gammatab_13_2(maxindex, 0); + igammatab_13_2(maxindex, 0); + gammatab_115_2(maxindex, 0); + igammatab_115_2(maxindex, 0); + gammatab_145_3(maxindex, 0); + igammatab_145_3(maxindex, 0); #ifdef _OPENMP #pragma omp parallel sections @@ -177,7 +177,7 @@ void Color::init () for (; i < maxindex; i++) { - cachef[i] = 327.68 * std::cbrt ((double)i / MAXVALF); + cachef[i] = 327.68 * std::cbrt((double)i / MAXVALF); } } #ifdef _OPENMP @@ -186,11 +186,11 @@ void Color::init () { for (int i = 0; i < maxindex; i++) { - gammatab_srgb[i] = gammatab_srgb1[i] = gamma2 (i / 65535.0); + gammatab_srgb[i] = gammatab_srgb1[i] = gamma2(i / 65535.0); } gammatab_srgb *= 65535.f; - gamma2curve.share (gammatab_srgb, LUT_CLIP_BELOW | LUT_CLIP_ABOVE); // shares the buffer with gammatab_srgb but has different clip flags + gamma2curve.share(gammatab_srgb, LUT_CLIP_BELOW | LUT_CLIP_ABOVE); // shares the buffer with gammatab_srgb but has different clip flags } #ifdef _OPENMP #pragma omp section @@ -198,7 +198,7 @@ void Color::init () { for (int i = 0; i < 32768; i++) { - gammatab_srgb327[i] = gamma2 (i / 32767.0); + gammatab_srgb327[i] = gamma2(i / 32767.0); } gammatab_srgb327 *= 32767.f; @@ -211,7 +211,7 @@ void Color::init () { for (int i = 0; i < maxindex; i++) { - igammatab_srgb[i] = igammatab_srgb1[i] = igamma2 (i / 65535.0); + igammatab_srgb[i] = igammatab_srgb1[i] = igamma2(i / 65535.0); } igammatab_srgb *= 65535.f; @@ -224,9 +224,9 @@ void Color::init () for (int i = 0; i < maxindex; i++) { - double val = pow (i / 65535.0, rsRGBGamma); + double val = pow(i / 65535.0, rsRGBGamma); gammatab[i] = 65535.0 * val; - gammatabThumb[i] = (unsigned char) (255.0 * val); + gammatabThumb[i] = (unsigned char)(255.0 * val); } } @@ -241,21 +241,21 @@ void Color::init () switch (settings->denoiselabgamma) { case 0: for (int i = 0; i < maxindex; i++) { - denoiseGammaTab[i] = 65535.0 * gamma26_11 (i / 65535.0); + denoiseGammaTab[i] = 65535.0 * gamma26_11(i / 65535.0); } break; case 1: for (int i = 0; i < maxindex; i++) { - denoiseGammaTab[i] = 65535.0 * gamma4 (i / 65535.0); + denoiseGammaTab[i] = 65535.0 * gamma4(i / 65535.0); } break; default: for (int i = 0; i < maxindex; i++) { - denoiseGammaTab[i] = 65535.0 * gamma55 (i / 65535.0); + denoiseGammaTab[i] = 65535.0 * gamma55(i / 65535.0); } break; @@ -272,21 +272,21 @@ void Color::init () switch (settings->denoiselabgamma) { case 0: for (int i = 0; i < maxindex; i++) { - denoiseIGammaTab[i] = 65535.0 * igamma26_11 (i / 65535.0); + denoiseIGammaTab[i] = 65535.0 * igamma26_11(i / 65535.0); } break; case 1: for (int i = 0; i < maxindex; i++) { - denoiseIGammaTab[i] = 65535.0 * igamma4 (i / 65535.0); + denoiseIGammaTab[i] = 65535.0 * igamma4(i / 65535.0); } break; default: for (int i = 0; i < maxindex; i++) { - denoiseIGammaTab[i] = 65535.0 * igamma55 (i / 65535.0); + denoiseIGammaTab[i] = 65535.0 * igamma55(i / 65535.0); } break; @@ -297,7 +297,7 @@ void Color::init () #endif for (int i = 0; i < maxindex; i++) { - gammatab_13_2[i] = 65535.0 * gamma13_2 (i / 65535.0); + gammatab_13_2[i] = 65535.0 * gamma13_2(i / 65535.0); } #ifdef _OPENMP @@ -305,7 +305,7 @@ void Color::init () #endif for (int i = 0; i < maxindex; i++) { - igammatab_13_2[i] = 65535.0 * igamma13_2 (i / 65535.0); + igammatab_13_2[i] = 65535.0 * igamma13_2(i / 65535.0); } #ifdef _OPENMP @@ -313,7 +313,7 @@ void Color::init () #endif for (int i = 0; i < maxindex; i++) { - gammatab_115_2[i] = 65535.0 * gamma115_2 (i / 65535.0); + gammatab_115_2[i] = 65535.0 * gamma115_2(i / 65535.0); } #ifdef _OPENMP @@ -321,7 +321,7 @@ void Color::init () #endif for (int i = 0; i < maxindex; i++) { - igammatab_115_2[i] = 65535.0 * igamma115_2 (i / 65535.0); + igammatab_115_2[i] = 65535.0 * igamma115_2(i / 65535.0); } #ifdef _OPENMP @@ -329,7 +329,7 @@ void Color::init () #endif for (int i = 0; i < maxindex; i++) { - gammatab_145_3[i] = 65535.0 * gamma145_3 (i / 65535.0); + gammatab_145_3[i] = 65535.0 * gamma145_3(i / 65535.0); } #ifdef _OPENMP @@ -337,7 +337,7 @@ void Color::init () #endif for (int i = 0; i < maxindex; i++) { - igammatab_145_3[i] = 65535.0 * igamma145_3 (i / 65535.0); + igammatab_145_3[i] = 65535.0 * igamma145_3(i / 65535.0); } #ifdef _OPENMP @@ -345,7 +345,7 @@ void Color::init () #endif for (int i = 0; i < maxindex; i++) { - gammatab_24_17a[i] = gamma24_17 (i / 65535.0); + gammatab_24_17a[i] = gamma24_17(i / 65535.0); } #ifdef _OPENMP @@ -353,7 +353,7 @@ void Color::init () #endif for (int i = 0; i < maxindex; i++) { - igammatab_24_17[i] = 65535.0 * igamma24_17 (i / 65535.0); + igammatab_24_17[i] = 65535.0 * igamma24_17(i / 65535.0); } #ifdef _OPENMP @@ -364,18 +364,18 @@ void Color::init () #ifdef _OPENMP #pragma omp section #endif - linearGammaTRC = cmsBuildGamma (nullptr, 1.0); + linearGammaTRC = cmsBuildGamma(nullptr, 1.0); } } -void Color::cleanup () +void Color::cleanup() { if (linearGammaTRC) { - cmsFreeToneCurve (linearGammaTRC); + cmsFreeToneCurve(linearGammaTRC); } } -void Color::rgb2lab (Glib::ustring profile, Glib::ustring profileW, int r, int g, int b, float &LAB_l, float &LAB_a, float &LAB_b, bool workingSpace) +void Color::rgb2lab(Glib::ustring profile, Glib::ustring profileW, int r, int g, int b, float &LAB_l, float &LAB_a, float &LAB_b, bool workingSpace) { double xyz_rgb[3][3]; const double ep = 216.0 / 24389.0; @@ -413,95 +413,95 @@ void Color::rgb2lab (Glib::ustring profile, Glib::ustring profileW, int r, int g if (workingSpace) {//display working if (profileW == "sRGB") { //apply sRGB inverse gamma - if ( var_R > 0.04045 ) { - var_R = pow ( ( ( var_R + 0.055 ) / 1.055 ), rtengine::Color::sRGBGammaCurve); + if (var_R > 0.04045) { + var_R = pow(((var_R + 0.055) / 1.055), rtengine::Color::sRGBGammaCurve); } else { var_R = var_R / 12.92; } - if ( var_G > 0.04045 ) { - var_G = pow ( ( ( var_G + 0.055 ) / 1.055 ), rtengine::Color::sRGBGammaCurve); + if (var_G > 0.04045) { + var_G = pow(((var_G + 0.055) / 1.055), rtengine::Color::sRGBGammaCurve); } else { var_G = var_G / 12.92; } - if ( var_B > 0.04045 ) { - var_B = pow ( ( ( var_B + 0.055 ) / 1.055 ), rtengine::Color::sRGBGammaCurve); + if (var_B > 0.04045) { + var_B = pow(((var_B + 0.055) / 1.055), rtengine::Color::sRGBGammaCurve); } else { var_B = var_B / 12.92; } } else if (profileW == "ProPhoto") { // apply inverse gamma 1.8 - var_R = pow ( var_R, 1.8); - var_G = pow ( var_G, 1.8); - var_B = pow ( var_B, 1.8); + var_R = pow(var_R, 1.8); + var_G = pow(var_G, 1.8); + var_B = pow(var_B, 1.8); } else { // apply inverse gamma 2.2 - var_R = pow ( var_R, 2.2); - var_G = pow ( var_G, 2.2); - var_B = pow ( var_B, 2.2); + var_R = pow(var_R, 2.2); + var_G = pow(var_G, 2.2); + var_B = pow(var_B, 2.2); } } else { //display outout profile if (profile == "RT_sRGB" || profile == "RT_Large_gsRGB" || profile == "RT_Medium_gsRGB") { //apply sRGB inverse gamma - if ( var_R > 0.04045 ) { - var_R = pow ( ( ( var_R + 0.055 ) / 1.055 ), rtengine::Color::sRGBGammaCurve); + if (var_R > 0.04045) { + var_R = pow(((var_R + 0.055) / 1.055), rtengine::Color::sRGBGammaCurve); } else { var_R = var_R / 12.92; } - if ( var_G > 0.04045 ) { - var_G = pow ( ( ( var_G + 0.055 ) / 1.055 ), rtengine::Color::sRGBGammaCurve); + if (var_G > 0.04045) { + var_G = pow(((var_G + 0.055) / 1.055), rtengine::Color::sRGBGammaCurve); } else { var_G = var_G / 12.92; } - if ( var_B > 0.04045 ) { - var_B = pow ( ( ( var_B + 0.055 ) / 1.055 ), rtengine::Color::sRGBGammaCurve); + if (var_B > 0.04045) { + var_B = pow(((var_B + 0.055) / 1.055), rtengine::Color::sRGBGammaCurve); } else { var_B = var_B / 12.92; } } else if (profile == "RT_sRGB_gBT709" || profile == "RT_Large_gBT709") { // - if ( var_R > 0.0795 ) { - var_R = pow ( ( ( var_R + 0.0954 ) / 1.0954 ), 2.2); + if (var_R > 0.0795) { + var_R = pow(((var_R + 0.0954) / 1.0954), 2.2); } else { var_R = var_R / 4.5; } - if ( var_G > 0.0795 ) { - var_G = pow ( ( ( var_G + 0.0954 ) / 1.0954 ), 2.2); + if (var_G > 0.0795) { + var_G = pow(((var_G + 0.0954) / 1.0954), 2.2); } else { var_G = var_G / 4.5; } - if ( var_B > 0.0795 ) { - var_B = pow ( ( ( var_B + 0.0954 ) / 1.0954 ), 2.2); + if (var_B > 0.0795) { + var_B = pow(((var_B + 0.0954) / 1.0954), 2.2); } else { var_B = var_B / 4.5; } } else if (profile == "ProPhoto") { // apply inverse gamma 1.8 - var_R = pow ( var_R, 1.8); - var_G = pow ( var_G, 1.8); - var_B = pow ( var_B, 1.8); + var_R = pow(var_R, 1.8); + var_G = pow(var_G, 1.8); + var_B = pow(var_B, 1.8); } else if (profile == "RT_sRGB_g10" || profile == "RT_Large_g10") { // apply inverse gamma 1.8 - var_R = pow ( var_R, 1.); - var_G = pow ( var_G, 1.); - var_B = pow ( var_B, 1.); + var_R = pow(var_R, 1.); + var_G = pow(var_G, 1.); + var_B = pow(var_B, 1.); } else {// apply inverse gamma 2.2 - var_R = pow ( var_R, 2.2); - var_G = pow ( var_G, 2.2); - var_B = pow ( var_B, 2.2); + var_R = pow(var_R, 2.2); + var_G = pow(var_G, 2.2); + var_B = pow(var_B, 2.2); } } // TMatrix wprof = rtengine::ICCStore::getInstance()->workingSpaceMatrix (profileW); - TMatrix wprof = rtengine::ICCStore::getInstance()->workingSpaceMatrix (profileCalc); + TMatrix wprof = rtengine::ICCStore::getInstance()->workingSpaceMatrix(profileCalc); for (int m = 0; m < 3; m++) for (int n = 0; n < 3; n++) { @@ -509,28 +509,28 @@ void Color::rgb2lab (Glib::ustring profile, Glib::ustring profileW, int r, int g } double varxx, varyy, varzz; - double var_X = ( xyz_rgb[0][0] * var_R + xyz_rgb[0][1] * var_G + xyz_rgb[0][2] * var_B ) / Color::D50x; - double var_Y = ( xyz_rgb[1][0] * var_R + xyz_rgb[1][1] * var_G + xyz_rgb[1][2] * var_B ) ; - double var_Z = ( xyz_rgb[2][0] * var_R + xyz_rgb[2][1] * var_G + xyz_rgb[2][2] * var_B ) / Color::D50z; + double var_X = (xyz_rgb[0][0] * var_R + xyz_rgb[0][1] * var_G + xyz_rgb[0][2] * var_B) / Color::D50x; + double var_Y = (xyz_rgb[1][0] * var_R + xyz_rgb[1][1] * var_G + xyz_rgb[1][2] * var_B) ; + double var_Z = (xyz_rgb[2][0] * var_R + xyz_rgb[2][1] * var_G + xyz_rgb[2][2] * var_B) / Color::D50z; - varxx = var_X > ep ? cbrt (var_X) : ( ka * var_X + 16.0) / 116.0 ; - varyy = var_Y > ep ? cbrt (var_Y) : ( ka * var_Y + 16.0) / 116.0 ; - varzz = var_Z > ep ? cbrt (var_Z) : ( ka * var_Z + 16.0) / 116.0 ; - LAB_l = ( 116 * varyy ) - 16; - LAB_a = 500 * ( varxx - varyy ); - LAB_b = 200 * ( varyy - varzz ); + varxx = var_X > ep ? cbrt(var_X) : (ka * var_X + 16.0) / 116.0 ; + varyy = var_Y > ep ? cbrt(var_Y) : (ka * var_Y + 16.0) / 116.0 ; + varzz = var_Z > ep ? cbrt(var_Z) : (ka * var_Z + 16.0) / 116.0 ; + LAB_l = (116 * varyy) - 16; + LAB_a = 500 * (varxx - varyy); + LAB_b = 200 * (varyy - varzz); } -void Color::rgb2hsl (float r, float g, float b, float &h, float &s, float &l) +void Color::rgb2hsl(float r, float g, float b, float &h, float &s, float &l) { double var_R = double (r) / 65535.0; double var_G = double (g) / 65535.0; double var_B = double (b) / 65535.0; - double m = min (var_R, var_G, var_B); - double M = max (var_R, var_G, var_B); + double m = min(var_R, var_G, var_B); + double M = max(var_R, var_G, var_B); double C = M - m; double l_ = (M + m) / 2.; @@ -543,14 +543,14 @@ void Color::rgb2hsl (float r, float g, float b, float &h, float &s, float &l) double h_; if (l_ <= 0.5) { - s = float ( (M - m) / (M + m) ); + s = float ((M - m) / (M + m)); } else { - s = float ( (M - m) / (2.0 - M - m) ); + s = float ((M - m) / (2.0 - M - m)); } - if ( var_R == M ) { - h_ = (var_G - var_B) / C; - } else if ( var_G == M ) { + if (var_R == M) { + h_ = (var_G - var_B) / C; + } else if (var_G == M) { h_ = 2. + (var_B - var_R) / C; } else { h_ = 4. + (var_R - var_G) / C; @@ -558,26 +558,26 @@ void Color::rgb2hsl (float r, float g, float b, float &h, float &s, float &l) h = float (h_ / 6.0); - if ( h < 0.f ) { + if (h < 0.f) { h += 1.f; } - if ( h > 1.f ) { + if (h > 1.f) { h -= 1.f; } } } -void Color::rgb2hslfloat (float r, float g, float b, float &h, float &s, float &l) +void Color::rgb2hslfloat(float r, float g, float b, float &h, float &s, float &l) { - float m = min (r, g, b); - float M = max (r, g, b); + float m = min(r, g, b); + float M = max(r, g, b); float C = M - m; l = (M + m) * 7.6295109e-6f; // (0.5f / 65535.f) - if (fabsf (C) < 0.65535f) { // 0.00001f * 65535.f + if (fabsf(C) < 0.65535f) { // 0.00001f * 65535.f h = 0.f; s = 0.f; } else { @@ -588,9 +588,9 @@ void Color::rgb2hslfloat (float r, float g, float b, float &h, float &s, float & s = (M - m) / (131070.f - M - m); // 131070.f = 2.f * 65535.f } - if ( r == M ) { + if (r == M) { h = (g - b); - } else if ( g == M ) { + } else if (g == M) { h = (2.f * C) + (b - r); } else { h = (4.f * C) + (r - g); @@ -598,49 +598,49 @@ void Color::rgb2hslfloat (float r, float g, float b, float &h, float &s, float & h /= (6.f * C); - if ( h < 0.f ) { + if (h < 0.f) { h += 1.f; - } else if ( h > 1.f ) { + } else if (h > 1.f) { h -= 1.f; } } } #ifdef __SSE2__ -void Color::rgb2hsl (vfloat r, vfloat g, vfloat b, vfloat &h, vfloat &s, vfloat &l) +void Color::rgb2hsl(vfloat r, vfloat g, vfloat b, vfloat &h, vfloat &s, vfloat &l) { - vfloat maxv = _mm_max_ps (r, _mm_max_ps (g, b)); - vfloat minv = _mm_min_ps (r, _mm_min_ps (g, b)); + vfloat maxv = _mm_max_ps(r, _mm_max_ps(g, b)); + vfloat minv = _mm_min_ps(r, _mm_min_ps(g, b)); vfloat C = maxv - minv; vfloat tempv = maxv + minv; - l = (tempv) * F2V (7.6295109e-6f); + l = (tempv) * F2V(7.6295109e-6f); s = (maxv - minv); - s /= vself (vmaskf_gt (l, F2V (0.5f)), F2V (131070.f) - tempv, tempv); + s /= vself(vmaskf_gt(l, F2V(0.5f)), F2V(131070.f) - tempv, tempv); - h = F2V (4.f) * C + r - g; - h = vself (vmaskf_eq (g, maxv), F2V (2.f) * C + b - r, h); - h = vself (vmaskf_eq (r, maxv), g - b, h); + h = F2V(4.f) * C + r - g; + h = vself(vmaskf_eq(g, maxv), F2V(2.f) * C + b - r, h); + h = vself(vmaskf_eq(r, maxv), g - b, h); - h /= (F2V (6.f) * C); - vfloat onev = F2V (1.f); - h = vself (vmaskf_lt (h, ZEROV), h + onev, h); - h = vself (vmaskf_gt (h, onev), h - onev, h); + h /= (F2V(6.f) * C); + vfloat onev = F2V(1.f); + h = vself(vmaskf_lt(h, ZEROV), h + onev, h); + h = vself(vmaskf_gt(h, onev), h - onev, h); - vmask zeromask = vmaskf_lt (vabsf (C), F2V (0.65535f)); - h = vself (zeromask, ZEROV, h); - s = vself (zeromask, ZEROV, s); + vmask zeromask = vmaskf_lt(vabsf(C), F2V(0.65535f)); + h = vself(zeromask, ZEROV, h); + s = vself(zeromask, ZEROV, s); } #endif -double Color::hue2rgb (double p, double q, double t) +double Color::hue2rgb(double p, double q, double t) { if (t < 0.) { t += 6.; - } else if ( t > 6.) { + } else if (t > 6.) { t -= 6.; } - if (t < 1.) { + if (t < 1.) { return p + (q - p) * t; } else if (t < 3.) { return q; @@ -651,15 +651,15 @@ double Color::hue2rgb (double p, double q, double t) } } -float Color::hue2rgbfloat (float p, float q, float t) +float Color::hue2rgbfloat(float p, float q, float t) { if (t < 0.f) { t += 6.f; - } else if ( t > 6.f) { + } else if (t > 6.f) { t -= 6.f; } - if (t < 1.f) { + if (t < 1.f) { return p + (q - p) * t; } else if (t < 3.f) { return q; @@ -671,23 +671,23 @@ float Color::hue2rgbfloat (float p, float q, float t) } #ifdef __SSE2__ -vfloat Color::hue2rgb (vfloat p, vfloat q, vfloat t) +vfloat Color::hue2rgb(vfloat p, vfloat q, vfloat t) { - vfloat fourv = F2V (4.f); - vfloat threev = F2V (3.f); + vfloat fourv = F2V(4.f); + vfloat threev = F2V(3.f); vfloat sixv = threev + threev; - t = vself (vmaskf_lt (t, ZEROV), t + sixv, t); - t = vself (vmaskf_gt (t, sixv), t - sixv, t); + t = vself(vmaskf_lt(t, ZEROV), t + sixv, t); + t = vself(vmaskf_gt(t, sixv), t - sixv, t); vfloat temp1 = p + (q - p) * t; vfloat temp2 = p + (q - p) * (fourv - t); - vfloat result = vself (vmaskf_lt (t, fourv), temp2, p); - result = vself (vmaskf_lt (t, threev), q, result); - return vself (vmaskf_lt (t, fourv - threev), temp1, result); + vfloat result = vself(vmaskf_lt(t, fourv), temp2, p); + result = vself(vmaskf_lt(t, threev), q, result); + return vself(vmaskf_lt(t, fourv - threev), temp1, result); } #endif -void Color::hsl2rgb (float h, float s, float l, float &r, float &g, float &b) +void Color::hsl2rgb(float h, float s, float l, float &r, float &g, float &b) { if (s == 0) { @@ -706,13 +706,13 @@ void Color::hsl2rgb (float h, float s, float l, float &r, float &g, float &b) double m1 = 2.0 * l_ - m2; - r = float (65535.0 * hue2rgb (m1, m2, h_ * 6.0 + 2.0)); - g = float (65535.0 * hue2rgb (m1, m2, h_ * 6.0)); - b = float (65535.0 * hue2rgb (m1, m2, h_ * 6.0 - 2.0)); + r = float (65535.0 * hue2rgb(m1, m2, h_ * 6.0 + 2.0)); + g = float (65535.0 * hue2rgb(m1, m2, h_ * 6.0)); + b = float (65535.0 * hue2rgb(m1, m2, h_ * 6.0 - 2.0)); } } -void Color::hsl2rgbfloat (float h, float s, float l, float &r, float &g, float &b) +void Color::hsl2rgbfloat(float h, float s, float l, float &r, float &g, float &b) { if (s == 0.f) { @@ -728,38 +728,38 @@ void Color::hsl2rgbfloat (float h, float s, float l, float &r, float &g, float & float m1 = 2.f * l - m2; - r = 65535.f * hue2rgbfloat (m1, m2, h * 6.f + 2.f); - g = 65535.f * hue2rgbfloat (m1, m2, h * 6.f); - b = 65535.f * hue2rgbfloat (m1, m2, h * 6.f - 2.f); + r = 65535.f * hue2rgbfloat(m1, m2, h * 6.f + 2.f); + g = 65535.f * hue2rgbfloat(m1, m2, h * 6.f); + b = 65535.f * hue2rgbfloat(m1, m2, h * 6.f - 2.f); } } #ifdef __SSE2__ -void Color::hsl2rgb (vfloat h, vfloat s, vfloat l, vfloat &r, vfloat &g, vfloat &b) +void Color::hsl2rgb(vfloat h, vfloat s, vfloat l, vfloat &r, vfloat &g, vfloat &b) { vfloat m2 = s * l; - m2 = vself (vmaskf_gt (l, F2V (0.5f)), s - m2, m2); + m2 = vself(vmaskf_gt(l, F2V(0.5f)), s - m2, m2); m2 += l; - vfloat twov = F2V (2.f); - vfloat c65535v = F2V (65535.f); + vfloat twov = F2V(2.f); + vfloat c65535v = F2V(65535.f); vfloat m1 = l + l - m2; - h *= F2V (6.f); - r = c65535v * hue2rgb (m1, m2, h + twov); - g = c65535v * hue2rgb (m1, m2, h); - b = c65535v * hue2rgb (m1, m2, h - twov); + h *= F2V(6.f); + r = c65535v * hue2rgb(m1, m2, h + twov); + g = c65535v * hue2rgb(m1, m2, h); + b = c65535v * hue2rgb(m1, m2, h - twov); - vmask selectsMask = vmaskf_eq (ZEROV, s); + vmask selectsMask = vmaskf_eq(ZEROV, s); vfloat lc65535v = c65535v * l; - r = vself (selectsMask, lc65535v, r); - g = vself (selectsMask, lc65535v, g); - b = vself (selectsMask, lc65535v, b); + r = vself(selectsMask, lc65535v, r); + g = vself(selectsMask, lc65535v, g); + b = vself(selectsMask, lc65535v, b); } #endif -void Color::hsl2rgb01 (float h, float s, float l, float &r, float &g, float &b) +void Color::hsl2rgb01(float h, float s, float l, float &r, float &g, float &b) { if (s == 0) { @@ -778,20 +778,20 @@ void Color::hsl2rgb01 (float h, float s, float l, float &r, float &g, float &b) double m1 = 2.0 * l_ - m2; - r = float (hue2rgb (m1, m2, h_ * 6.0 + 2.0)); - g = float (hue2rgb (m1, m2, h_ * 6.0)); - b = float (hue2rgb (m1, m2, h_ * 6.0 - 2.0)); + r = float (hue2rgb(m1, m2, h_ * 6.0 + 2.0)); + g = float (hue2rgb(m1, m2, h_ * 6.0)); + b = float (hue2rgb(m1, m2, h_ * 6.0 - 2.0)); } } -void Color::rgb2hsv (float r, float g, float b, float &h, float &s, float &v) +void Color::rgb2hsv(float r, float g, float b, float &h, float &s, float &v) { const double var_R = r / 65535.0; const double var_G = g / 65535.0; const double var_B = b / 65535.0; - const double var_Min = min (var_R, var_G, var_B); - const double var_Max = max (var_R, var_G, var_B); + const double var_Min = min(var_R, var_G, var_B); + const double var_Max = max(var_R, var_G, var_B); const double del_Max = var_Max - var_Min; h = 0.f; @@ -822,20 +822,20 @@ void Color::rgb2hsv (float r, float g, float b, float &h, float &s, float &v) } } -void Color::hsv2rgb (float h, float s, float v, float &r, float &g, float &b) +void Color::hsv2rgb(float h, float s, float v, float &r, float &g, float &b) { float h1 = h * 6.f; // sector 0 to 5 int i = (int)h1; // floor() is very slow, and h1 is always >0 float f = h1 - i; // fractional part of h - float p = v * ( 1.f - s ); - float q = v * ( 1.f - s * f ); - float t = v * ( 1.f - s * ( 1.f - f ) ); + float p = v * (1.f - s); + float q = v * (1.f - s * f); + float t = v * (1.f - s * (1.f - f)); float r1, g1, b1; - if (i == 1) { + if (i == 1) { r1 = q; g1 = v; b1 = p; @@ -868,17 +868,17 @@ void Color::hsv2rgb (float h, float s, float v, float &r, float &g, float &b) // Function copied for speed concerns // Not exactly the same as above ; this one return a result in the [0.0 ; 1.0] range -void Color::hsv2rgb01 (float h, float s, float v, float &r, float &g, float &b) +void Color::hsv2rgb01(float h, float s, float v, float &r, float &g, float &b) { float h1 = h * 6; // sector 0 to 5 int i = int (h1); float f = h1 - i; // fractional part of h - float p = v * ( 1 - s ); - float q = v * ( 1 - s * f ); - float t = v * ( 1 - s * ( 1 - f ) ); + float p = v * (1 - s); + float q = v * (1 - s * f); + float t = v * (1 - s * (1 - f)); - if (i == 1) { + if (i == 1) { r = q; g = v; b = p; @@ -905,16 +905,16 @@ void Color::hsv2rgb01 (float h, float s, float v, float &r, float &g, float &b) } } -void Color::hsv2rgb (float h, float s, float v, int &r, int &g, int &b) +void Color::hsv2rgb(float h, float s, float v, int &r, int &g, int &b) { float h1 = h * 6; // sector 0 to 5 - int i = floor ( h1 ); + int i = floor(h1); float f = h1 - i; // fractional part of h - float p = v * ( 1 - s ); - float q = v * ( 1 - s * f ); - float t = v * ( 1 - s * ( 1 - f ) ); + float p = v * (1 - s); + float q = v * (1 - s * f); + float t = v * (1 - s * (1 - f)); float r1, g1, b1; @@ -944,14 +944,14 @@ void Color::hsv2rgb (float h, float s, float v, int &r, int &g, int &b) b1 = q; } - r = (int) ( r1 * 65535); - g = (int) ( g1 * 65535); - b = (int) ( b1 * 65535); + r = (int)(r1 * 65535); + g = (int)(g1 * 65535); + b = (int)(b1 * 65535); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -void Color::xyz2srgb (float x, float y, float z, float &r, float &g, float &b) +void Color::xyz2srgb(float x, float y, float z, float &r, float &g, float &b) { //Transform to output color. Standard sRGB is D65, but internal representation is D50 @@ -974,27 +974,27 @@ void Color::xyz2srgb (float x, float y, float z, float &r, float &g, float &b) b = ((sRGB_xyz[2][0] * x + sRGB_xyz[2][1] * y + sRGB_xyz[2][2] * z)) ; } -void Color::xyz2Prophoto (float x, float y, float z, float &r, float &g, float &b) +void Color::xyz2Prophoto(float x, float y, float z, float &r, float &g, float &b) { r = ((prophoto_xyz[0][0] * x + prophoto_xyz[0][1] * y + prophoto_xyz[0][2] * z)) ; g = ((prophoto_xyz[1][0] * x + prophoto_xyz[1][1] * y + prophoto_xyz[1][2] * z)) ; b = ((prophoto_xyz[2][0] * x + prophoto_xyz[2][1] * y + prophoto_xyz[2][2] * z)) ; } -void Color::Prophotoxyz (float r, float g, float b, float &x, float &y, float &z) +void Color::Prophotoxyz(float r, float g, float b, float &x, float &y, float &z) { x = ((xyz_prophoto[0][0] * r + xyz_prophoto[0][1] * g + xyz_prophoto[0][2] * b)) ; y = ((xyz_prophoto[1][0] * r + xyz_prophoto[1][1] * g + xyz_prophoto[1][2] * b)) ; z = ((xyz_prophoto[2][0] * r + xyz_prophoto[2][1] * g + xyz_prophoto[2][2] * b)) ; } -void Color::rgbxyz (float r, float g, float b, float &x, float &y, float &z, const double xyz_rgb[3][3]) +void Color::rgbxyz(float r, float g, float b, float &x, float &y, float &z, const double xyz_rgb[3][3]) { x = ((xyz_rgb[0][0] * r + xyz_rgb[0][1] * g + xyz_rgb[0][2] * b)) ; y = ((xyz_rgb[1][0] * r + xyz_rgb[1][1] * g + xyz_rgb[1][2] * b)) ; z = ((xyz_rgb[2][0] * r + xyz_rgb[2][1] * g + xyz_rgb[2][2] * b)) ; } -void Color::rgbxyz (float r, float g, float b, float &x, float &y, float &z, const float xyz_rgb[3][3]) +void Color::rgbxyz(float r, float g, float b, float &x, float &y, float &z, const float xyz_rgb[3][3]) { x = ((xyz_rgb[0][0] * r + xyz_rgb[0][1] * g + xyz_rgb[0][2] * b)) ; y = ((xyz_rgb[1][0] * r + xyz_rgb[1][1] * g + xyz_rgb[1][2] * b)) ; @@ -1002,7 +1002,7 @@ void Color::rgbxyz (float r, float g, float b, float &x, float &y, float &z, con } #ifdef __SSE2__ -void Color::rgbxyz (vfloat r, vfloat g, vfloat b, vfloat &x, vfloat &y, vfloat &z, const vfloat xyz_rgb[3][3]) +void Color::rgbxyz(vfloat r, vfloat g, vfloat b, vfloat &x, vfloat &y, vfloat &z, const vfloat xyz_rgb[3][3]) { x = ((xyz_rgb[0][0] * r + xyz_rgb[0][1] * g + xyz_rgb[0][2] * b)) ; y = ((xyz_rgb[1][0] * r + xyz_rgb[1][1] * g + xyz_rgb[1][2] * b)) ; @@ -1010,7 +1010,7 @@ void Color::rgbxyz (vfloat r, vfloat g, vfloat b, vfloat &x, vfloat &y, vfloat & } #endif -void Color::xyz2rgb (float x, float y, float z, float &r, float &g, float &b, const double rgb_xyz[3][3]) +void Color::xyz2rgb(float x, float y, float z, float &r, float &g, float &b, const double rgb_xyz[3][3]) { //Transform to output color. Standard sRGB is D65, but internal representation is D50 //Note that it is only at this point that we should have need of clipping color data @@ -1032,7 +1032,7 @@ void Color::xyz2rgb (float x, float y, float z, float &r, float &g, float &b, co b = ((rgb_xyz[2][0] * x + rgb_xyz[2][1] * y + rgb_xyz[2][2] * z)) ; } -void Color::xyz2r (float x, float y, float z, float &r, const double rgb_xyz[3][3]) // for black & white we need only r channel +void Color::xyz2r(float x, float y, float z, float &r, const double rgb_xyz[3][3]) // for black & white we need only r channel { //Transform to output color. Standard sRGB is D65, but internal representation is D50 //Note that it is only at this point that we should have need of clipping color data @@ -1041,7 +1041,7 @@ void Color::xyz2r (float x, float y, float z, float &r, const double rgb_xyz[3][ } // same for float -void Color::xyz2rgb (float x, float y, float z, float &r, float &g, float &b, const float rgb_xyz[3][3]) +void Color::xyz2rgb(float x, float y, float z, float &r, float &g, float &b, const float rgb_xyz[3][3]) { r = ((rgb_xyz[0][0] * x + rgb_xyz[0][1] * y + rgb_xyz[0][2] * z)) ; g = ((rgb_xyz[1][0] * x + rgb_xyz[1][1] * y + rgb_xyz[1][2] * z)) ; @@ -1049,7 +1049,7 @@ void Color::xyz2rgb (float x, float y, float z, float &r, float &g, float &b, co } #ifdef __SSE2__ -void Color::xyz2rgb (vfloat x, vfloat y, vfloat z, vfloat &r, vfloat &g, vfloat &b, const vfloat rgb_xyz[3][3]) +void Color::xyz2rgb(vfloat x, vfloat y, vfloat z, vfloat &r, vfloat &g, vfloat &b, const vfloat rgb_xyz[3][3]) { r = ((rgb_xyz[0][0] * x + rgb_xyz[0][1] * y + rgb_xyz[0][2] * z)) ; g = ((rgb_xyz[1][0] * x + rgb_xyz[1][1] * y + rgb_xyz[1][2] * z)) ; @@ -1058,63 +1058,63 @@ void Color::xyz2rgb (vfloat x, vfloat y, vfloat z, vfloat &r, vfloat &g, vfloat #endif // __SSE2__ #ifdef __SSE2__ -void Color::trcGammaBW (float &r, float &g, float &b, float gammabwr, float gammabwg, float gammabwb) +void Color::trcGammaBW(float &r, float &g, float &b, float gammabwr, float gammabwg, float gammabwb) { // correct gamma for black and white image : pseudo TRC curve of ICC profile - vfloat rgbv = _mm_set_ps (0.f, r, r, r); // input channel is always r - vfloat gammabwv = _mm_set_ps (0.f, gammabwb, gammabwg, gammabwr); - vfloat c65535v = F2V (65535.f); + vfloat rgbv = _mm_set_ps(0.f, r, r, r); // input channel is always r + vfloat gammabwv = _mm_set_ps(0.f, gammabwb, gammabwg, gammabwr); + vfloat c65535v = F2V(65535.f); rgbv /= c65535v; - rgbv = vmaxf (rgbv, ZEROV); - rgbv = pow_F (rgbv, gammabwv); + rgbv = vmaxf(rgbv, ZEROV); + rgbv = pow_F(rgbv, gammabwv); rgbv *= c65535v; float temp[4] ALIGNED16; - STVF (temp[0], rgbv); + STVF(temp[0], rgbv); r = temp[0]; g = temp[1]; b = temp[2]; } -void Color::trcGammaBWRow (float *r, float *g, float *b, int width, float gammabwr, float gammabwg, float gammabwb) +void Color::trcGammaBWRow(float *r, float *g, float *b, int width, float gammabwr, float gammabwg, float gammabwb) { // correct gamma for black and white image : pseudo TRC curve of ICC profile - vfloat c65535v = F2V (65535.f); - vfloat gammabwrv = F2V (gammabwr); - vfloat gammabwgv = F2V (gammabwg); - vfloat gammabwbv = F2V (gammabwb); + vfloat c65535v = F2V(65535.f); + vfloat gammabwrv = F2V(gammabwr); + vfloat gammabwgv = F2V(gammabwg); + vfloat gammabwbv = F2V(gammabwb); int i = 0; - for (; i < width - 3; i += 4 ) { - vfloat inv = _mm_loadu_ps (&r[i]); // input channel is always r + for (; i < width - 3; i += 4) { + vfloat inv = _mm_loadu_ps(&r[i]); // input channel is always r inv /= c65535v; - inv = vmaxf (inv, ZEROV); - vfloat rv = pow_F (inv, gammabwrv); - vfloat gv = pow_F (inv, gammabwgv); - vfloat bv = pow_F (inv, gammabwbv); + inv = vmaxf(inv, ZEROV); + vfloat rv = pow_F(inv, gammabwrv); + vfloat gv = pow_F(inv, gammabwgv); + vfloat bv = pow_F(inv, gammabwbv); rv *= c65535v; gv *= c65535v; bv *= c65535v; - _mm_storeu_ps (&r[i], rv); - _mm_storeu_ps (&g[i], gv); - _mm_storeu_ps (&b[i], bv); + _mm_storeu_ps(&r[i], rv); + _mm_storeu_ps(&g[i], gv); + _mm_storeu_ps(&b[i], bv); } for (; i < width; i++) { - trcGammaBW (r[i], g[i], b[i], gammabwr, gammabwg, gammabwb); + trcGammaBW(r[i], g[i], b[i], gammabwr, gammabwg, gammabwb); } } #else -void Color::trcGammaBW (float &r, float &g, float &b, float gammabwr, float gammabwg, float gammabwb) +void Color::trcGammaBW(float &r, float &g, float &b, float gammabwr, float gammabwg, float gammabwb) { // correct gamma for black and white image : pseudo TRC curve of ICC profile float in = r; // input channel is always r in /= 65535.0f; - in = max (in, 0.f); - b = pow_F (in, gammabwb); + in = max(in, 0.f); + b = pow_F(in, gammabwb); b *= 65535.0f; - r = pow_F (in, gammabwr); + r = pow_F(in, gammabwr); r *= 65535.0f; - g = pow_F (in, gammabwg); + g = pow_F(in, gammabwg); g *= 65535.0f; } #endif @@ -1124,9 +1124,9 @@ void Color::trcGammaBW (float &r, float &g, float &b, float gammabwr, float gamm * @param setting BlackWhite::setting * @param setting BlackWhite::filter */ -void Color::computeBWMixerConstants (const Glib::ustring &setting, const Glib::ustring &filter, const Glib::ustring &algo, float &filcor, float &mixerRed, float &mixerGreen, - float &mixerBlue, float mixerOrange, float mixerYellow, float mixerCyan, float mixerPurple, float mixerMagenta, - bool autoc, bool complement, float &kcorec, double &rrm, double &ggm, double &bbm) +void Color::computeBWMixerConstants(const Glib::ustring &setting, const Glib::ustring &filter, const Glib::ustring &algo, float &filcor, float &mixerRed, float &mixerGreen, + float &mixerBlue, float mixerOrange, float mixerYellow, float mixerCyan, float mixerPurple, float mixerMagenta, + bool autoc, bool complement, float &kcorec, double &rrm, double &ggm, double &bbm) { float somm; float som = mixerRed + mixerGreen + mixerBlue; @@ -1142,14 +1142,14 @@ void Color::computeBWMixerConstants (const Glib::ustring &setting, const Glib::u // rM = mixerRed, gM = mixerGreen, bM = mixerBlue ! //presets - if (setting == "RGB-Abs" || setting == "ROYGCBPM-Abs") { + if (setting == "RGB-Abs" || setting == "ROYGCBPM-Abs") { kcorec = som / 100.f; } if (!autoc) { //if (setting=="RGB-Abs" || setting=="ROYGCBPM-Abs") {} //Keep the RGB mixer values as is! //else if(setting=="RGB-Rel" || setting=="ROYGCBPM-Rel") {} //Keep the RGB mixer values as is! - if (setting == "NormalContrast") { + if (setting == "NormalContrast") { mixerRed = 43.f ; mixerGreen = 33.f; mixerBlue = 30.f; @@ -1284,7 +1284,7 @@ void Color::computeBWMixerConstants (const Glib::ustring &setting, const Glib::u yrM = fcompl * (0.5f * mixerYellow - 16.5f) / 100.f; //22.4 } - ygM = fcompl * (0.5f * mixerYellow - 16.5f ) / 100.f; + ygM = fcompl * (0.5f * mixerYellow - 16.5f) / 100.f; if (complement) { ybM = (-0.492f * mixerYellow + 16.236f) / 100.f; @@ -1299,7 +1299,7 @@ void Color::computeBWMixerConstants (const Glib::ustring &setting, const Glib::u if (mixerMagenta != 33) { if (algo == "SP") { if (mixerMagenta >= 33) { - mrM = fcompl * ( 0.67f * mixerMagenta - 22.11f) / 100.f; + mrM = fcompl * (0.67f * mixerMagenta - 22.11f) / 100.f; } else { mrM = fcompl * (-0.3f * mixerMagenta + 9.9f) / 100.f; } @@ -1307,7 +1307,7 @@ void Color::computeBWMixerConstants (const Glib::ustring &setting, const Glib::u if (mixerMagenta >= 33) { mbM = fcompl * (-0.164f * mixerMagenta + 5.412f) / 100.f; } else { - mbM = fcompl * ( 0.4f * mixerMagenta - 13.2f) / 100.f; + mbM = fcompl * (0.4f * mixerMagenta - 13.2f) / 100.f; } } else if (algo == "LI") { mrM = fcompl * (mixerMagenta - 33.f) / 100.f; @@ -1374,47 +1374,47 @@ void Color::computeBWMixerConstants (const Glib::ustring &setting, const Glib::u filblue = 1.f; filcor = 1.f; - if (filter == "None") { + if (filter == "None") { filred = 1.f; filgreen = 1.f; filblue = 1.f; filcor = 1.f; - } else if (filter == "Red") { + } else if (filter == "Red") { filred = 1.f; filgreen = 0.05f; filblue = 0.f; filcor = 1.08f; - } else if (filter == "Orange") { + } else if (filter == "Orange") { filred = 1.f; filgreen = 0.6f; filblue = 0.f; filcor = 1.35f; - } else if (filter == "Yellow") { + } else if (filter == "Yellow") { filred = 1.f; filgreen = 1.f; filblue = 0.05f; filcor = 1.23f; - } else if (filter == "YellowGreen") { + } else if (filter == "YellowGreen") { filred = 0.6f; filgreen = 1.f; filblue = 0.3f; filcor = 1.32f; - } else if (filter == "Green") { + } else if (filter == "Green") { filred = 0.2f; filgreen = 1.f; filblue = 0.3f; filcor = 1.41f; - } else if (filter == "Cyan") { + } else if (filter == "Cyan") { filred = 0.05f; filgreen = 1.f; filblue = 1.f; filcor = 1.23f; - } else if (filter == "Blue") { + } else if (filter == "Blue") { filred = 0.f; filgreen = 0.05f; filblue = 1.f; filcor = 1.20f; - } else if (filter == "Purple") { + } else if (filter == "Purple") { filred = 1.f; filgreen = 0.05f; filblue = 1.f; @@ -1451,7 +1451,7 @@ void Color::computeBWMixerConstants (const Glib::ustring &setting, const Glib::u } -void Color::interpolateRGBColor (const float balance, const float r1, const float g1, const float b1, const float r2, const float g2, const float b2, int toDo, const double xyz_rgb[3][3], const double rgb_xyz[3][3], float &ro, float &go, float &bo) +void Color::interpolateRGBColor(const float balance, const float r1, const float g1, const float b1, const float r2, const float g2, const float b2, int toDo, const double xyz_rgb[3][3], const double rgb_xyz[3][3], float &ro, float &go, float &bo) { float X1, Y1, Z1, X2, Y2, Z2, X, Y, Z; float L1, L2, a_1, b_1, a_2, b_2, a, b; @@ -1460,9 +1460,9 @@ void Color::interpolateRGBColor (const float balance, const float r1, const floa float Lr; // converting color 1 to Lch - Color::rgbxyz (r1, g1, b1, X1, Y1, Z1, xyz_rgb); - Color::XYZ2Lab (X1, Y1, Z1, L1, a_1, b_1); - Color::Lab2Lch (a_1, b_1, c1, h1); + Color::rgbxyz(r1, g1, b1, X1, Y1, Z1, xyz_rgb); + Color::XYZ2Lab(X1, Y1, Z1, L1, a_1, b_1); + Color::Lab2Lch(a_1, b_1, c1, h1); Lr = L1 / 327.68f; //for gamutlch //gamut control on r1 g1 b1 #ifndef NDEBUG @@ -1470,17 +1470,17 @@ void Color::interpolateRGBColor (const float balance, const float r1, const floa bool more_rgb = false; //gamut control : Lab values are in gamut - Color::gamutLchonly (h1, Lr, c1, RR, GG, BB, xyz_rgb, false, 0.15f, 0.96f, neg, more_rgb); + Color::gamutLchonly(h1, Lr, c1, RR, GG, BB, xyz_rgb, false, 0.15f, 0.96f, neg, more_rgb); #else - Color::gamutLchonly (h1, Lr, c1, RR, GG, BB, xyz_rgb, false, 0.15f, 0.96f); + Color::gamutLchonly(h1, Lr, c1, RR, GG, BB, xyz_rgb, false, 0.15f, 0.96f); #endif L1 = Lr * 327.68f; // converting color 2 to Lch - Color::rgbxyz (r2, g2, b2, X2, Y2, Z2, xyz_rgb); - Color::XYZ2Lab (X2, Y2, Z2, L2, a_2, b_2); - Color::Lab2Lch (a_2, b_2, c2, h2); + Color::rgbxyz(r2, g2, b2, X2, Y2, Z2, xyz_rgb); + Color::XYZ2Lab(X2, Y2, Z2, L2, a_2, b_2); + Color::Lab2Lch(a_2, b_2, c2, h2); Lr = L2 / 327.68f; //for gamutlch //gamut control on r2 g2 b2 @@ -1488,9 +1488,9 @@ void Color::interpolateRGBColor (const float balance, const float r1, const floa neg = false; more_rgb = false; //gamut control : Lab values are in gamut - Color::gamutLchonly (h2, Lr, c2, RR, GG, BB, xyz_rgb, false, 0.15f, 0.96f, neg, more_rgb); + Color::gamutLchonly(h2, Lr, c2, RR, GG, BB, xyz_rgb, false, 0.15f, 0.96f, neg, more_rgb); #else - Color::gamutLchonly (h2, Lr, c2, RR, GG, BB, xyz_rgb, false, 0.15f, 0.96f); + Color::gamutLchonly(h2, Lr, c2, RR, GG, BB, xyz_rgb, false, 0.15f, 0.96f); #endif L2 = Lr * 327.68f; @@ -1525,34 +1525,34 @@ void Color::interpolateRGBColor (const float balance, const float r1, const floa neg = false; more_rgb = false; //gamut control : Lab values are in gamut - Color::gamutLchonly (h1, Lr, c1, RR, GG, BB, xyz_rgb, false, 0.15f, 0.96f, neg, more_rgb); + Color::gamutLchonly(h1, Lr, c1, RR, GG, BB, xyz_rgb, false, 0.15f, 0.96f, neg, more_rgb); #else //gamut control : Lab values are in gamut - Color::gamutLchonly (h1, Lr, c1, RR, GG, BB, xyz_rgb, false, 0.15f, 0.96f); + Color::gamutLchonly(h1, Lr, c1, RR, GG, BB, xyz_rgb, false, 0.15f, 0.96f); #endif //convert CH ==> ab L1 = Lr * 327.68f; // converting back to rgb - Color::Lch2Lab (c1, h1, a, b); - Color::Lab2XYZ (L1, a, b, X, Y, Z); - Color::xyz2rgb (X, Y, Z, ro, go, bo, rgb_xyz); + Color::Lch2Lab(c1, h1, a, b); + Color::Lab2XYZ(L1, a, b, X, Y, Z); + Color::xyz2rgb(X, Y, Z, ro, go, bo, rgb_xyz); } -void Color::interpolateRGBColor (float realL, float iplow, float iphigh, int algm, const float balance, int twoc, int metchrom, - float chromat, float luma, const float r1, const float g1, const float b1, - const float xl, const float yl, const float zl, const float x2, const float y2, const float z2, - const double xyz_rgb[3][3], const double rgb_xyz[3][3], float &ro, float &go, float &bo) +void Color::interpolateRGBColor(float realL, float iplow, float iphigh, int algm, const float balance, int twoc, int metchrom, + float chromat, float luma, const float r1, const float g1, const float b1, + const float xl, const float yl, const float zl, const float x2, const float y2, const float z2, + const double xyz_rgb[3][3], const double rgb_xyz[3][3], float &ro, float &go, float &bo) { float X1, Y1, Z1, X2, Y2, Z2, X, Y, Z, XL, YL, ZL; float L1 = 0.f, L2, LL, a_1 = 0.f, b_1 = 0.f, a_2 = 0.f, b_2 = 0.f, a_L, b_L; // converting color 1 to Lab (image) - Color::rgbxyz (r1, g1, b1, X1, Y1, Z1, xyz_rgb); + Color::rgbxyz(r1, g1, b1, X1, Y1, Z1, xyz_rgb); if (algm == 1) { //use H interpolate - Color::XYZ2Lab (X1, Y1, Z1, L1, a_1, b_1); + Color::XYZ2Lab(X1, Y1, Z1, L1, a_1, b_1); //Color::Lab2Lch(a_1, b_1, c_1, h_1) ; } @@ -1564,7 +1564,7 @@ void Color::interpolateRGBColor (float realL, float iplow, float iphigh, int alg ZL = zl; if (algm <= 1) { //use H interpolate - Color::XYZ2Lab (XL, YL, ZL, LL, a_L, b_L); + Color::XYZ2Lab(XL, YL, ZL, LL, a_L, b_L); } } @@ -1573,8 +1573,8 @@ void Color::interpolateRGBColor (float realL, float iplow, float iphigh, int alg Y2 = y2; Z2 = z2; - if (algm == 1 ) { - Color::XYZ2Lab (X2, Y2, Z2, L2, a_2, b_2); + if (algm == 1) { + Color::XYZ2Lab(X2, Y2, Z2, L2, a_2, b_2); //Color::Lab2Lch(a_2, b_2, c_2, h_2) ; } @@ -1593,13 +1593,13 @@ void Color::interpolateRGBColor (float realL, float iplow, float iphigh, int alg calan = chromat; //calculate new balance chroma - if (realL > iplow && realL <= med) { + if (realL > iplow && realL <= med) { cal = realL * calan / (iplow - med) - med * calan / (iplow - med); } else if (realL <= iplow) { cal = realL * calan / iplow; } - if (realL > medH && realL <= iphigh) { + if (realL > medH && realL <= iphigh) { calH = realL * calan / (iphigh - medH) - medH * calan / (iphigh - medH); } else if (realL > iphigh) { calH = realL * calan; //*(iphigh-1.f) - calan*(iphigh-1.f);//it is better without transition in highlight @@ -1630,12 +1630,12 @@ void Color::interpolateRGBColor (float realL, float iplow, float iphigh, int alg } } - Color::Lab2XYZ (L1, a_1, b_1, X, Y, Z); + Color::Lab2XYZ(L1, a_1, b_1, X, Y, Z); - Color::xyz2rgb (X, Y, Z, ro, go, bo, rgb_xyz); // ro go bo in gamut + Color::xyz2rgb(X, Y, Z, ro, go, bo, rgb_xyz); // ro go bo in gamut } -void Color::calcGamma (double pwr, double ts, int mode, GammaValues &gamma) +void Color::calcGamma(double pwr, double ts, int mode, GammaValues &gamma) { //from Dcraw (D.Coffin) int i; @@ -1651,9 +1651,9 @@ void Color::calcGamma (double pwr, double ts, int mode, GammaValues &gamma) g[2] = (bnd[0] + bnd[1]) / 2.; if (g[0]) { - bnd[ (pow (g[2] / g[1], -g[0]) - 1.) / g[0] - 1. / g[2] > -1.] = g[2]; + bnd[(pow(g[2] / g[1], -g[0]) - 1.) / g[0] - 1. / g[2] > -1.] = g[2]; } else { - bnd[g[2] / exp (1. - 1. / g[2]) < g[1]] = g[2]; + bnd[g[2] / exp(1. - 1. / g[2]) < g[1]] = g[2]; } } @@ -1665,9 +1665,9 @@ void Color::calcGamma (double pwr, double ts, int mode, GammaValues &gamma) } if (g[0]) { - g[5] = 1. / (g[1] * SQR (g[3]) / 2. - g[4] * (1. - g[3]) + (1. - pow (g[3], 1. + g[0])) * (1. + g[4]) / (1. + g[0])) - 1.; + g[5] = 1. / (g[1] * SQR(g[3]) / 2. - g[4] * (1. - g[3]) + (1. - pow(g[3], 1. + g[0])) * (1. + g[4]) / (1. + g[0])) - 1.; } else { - g[5] = 1. / (g[1] * SQR (g[3]) / 2. + 1. - g[2] - g[3] - g[2] * g[3] * (log (g[3]) - 1.)) - 1.; + g[5] = 1. / (g[1] * SQR(g[3]) / 2. + 1. - g[2] - g[3] - g[2] * g[3] * (log(g[3]) - 1.)) - 1.; } if (!mode--) { @@ -1681,17 +1681,17 @@ void Color::calcGamma (double pwr, double ts, int mode, GammaValues &gamma) return; } } -void Color::gammaf2lut (LUTf &gammacurve, float gamma, float start, float slope, float divisor, float factor) +void Color::gammaf2lut(LUTf &gammacurve, float gamma, float start, float slope, float divisor, float factor) { #ifdef __SSE2__ // SSE2 version is more than 6 times faster than scalar version - vfloat iv = _mm_set_ps (3.f, 2.f, 1.f, 0.f); - vfloat fourv = F2V (4.f); - vfloat gammav = F2V (1.f / gamma); - vfloat slopev = F2V ((slope / divisor) * factor); - vfloat divisorv = F2V (xlogf (divisor)); - vfloat factorv = F2V (factor); - vfloat comparev = F2V (start * divisor); + vfloat iv = _mm_set_ps(3.f, 2.f, 1.f, 0.f); + vfloat fourv = F2V(4.f); + vfloat gammav = F2V(1.f / gamma); + vfloat slopev = F2V((slope / divisor) * factor); + vfloat divisorv = F2V(xlogf(divisor)); + vfloat factorv = F2V(factor); + vfloat comparev = F2V(start * divisor); int border = start * divisor; int border1 = border - (border & 3); int border2 = border1 + 4; @@ -1699,64 +1699,64 @@ void Color::gammaf2lut (LUTf &gammacurve, float gamma, float start, float slope, for (; i < border1; i += 4) { vfloat resultv = iv * slopev; - STVFU (gammacurve[i], resultv); + STVFU(gammacurve[i], resultv); iv += fourv; } for (; i < border2; i += 4) { vfloat result0v = iv * slopev; - vfloat result1v = xexpf ((xlogf (iv) - divisorv) * gammav) * factorv; - STVFU (gammacurve[i], vself (vmaskf_le (iv, comparev), result0v, result1v)); + vfloat result1v = xexpf((xlogf(iv) - divisorv) * gammav) * factorv; + STVFU(gammacurve[i], vself(vmaskf_le(iv, comparev), result0v, result1v)); iv += fourv; } for (; i < 65536; i += 4) { - vfloat resultv = xexpfNoCheck ((xlogfNoCheck (iv) - divisorv) * gammav) * factorv; - STVFU (gammacurve[i], resultv); + vfloat resultv = xexpfNoCheck((xlogfNoCheck(iv) - divisorv) * gammav) * factorv; + STVFU(gammacurve[i], resultv); iv += fourv; } #else for (int i = 0; i < 65536; ++i) { - gammacurve[i] = gammaf (static_cast (i) / divisor, gamma, start, slope) * factor; + gammacurve[i] = gammaf(static_cast(i) / divisor, gamma, start, slope) * factor; } #endif } -void Color::gammanf2lut (LUTf &gammacurve, float gamma, float divisor, float factor) //standard gamma without slope... +void Color::gammanf2lut(LUTf &gammacurve, float gamma, float divisor, float factor) //standard gamma without slope... { #ifdef __SSE2__ // SSE2 version is more than 6 times faster than scalar version - vfloat iv = _mm_set_ps (3.f, 2.f, 1.f, 0.f); - vfloat fourv = F2V (4.f); - vfloat gammav = F2V (1.f / gamma); - vfloat divisorv = F2V (xlogf (divisor)); - vfloat factorv = F2V (factor); + vfloat iv = _mm_set_ps(3.f, 2.f, 1.f, 0.f); + vfloat fourv = F2V(4.f); + vfloat gammav = F2V(1.f / gamma); + vfloat divisorv = F2V(xlogf(divisor)); + vfloat factorv = F2V(factor); // first input value is zero => we have to use the xlogf function which checks this - vfloat resultv = xexpf ((xlogf (iv) - divisorv) * gammav) * factorv; - STVFU (gammacurve[0], resultv); + vfloat resultv = xexpf((xlogf(iv) - divisorv) * gammav) * factorv; + STVFU(gammacurve[0], resultv); iv += fourv; // inside the loop we can use xlogfNoCheck and xexpfNoCheck because we know about the input values for (int i = 4; i < 65536; i += 4) { - resultv = xexpfNoCheck ((xlogfNoCheck (iv) - divisorv) * gammav) * factorv; - STVFU (gammacurve[i], resultv); + resultv = xexpfNoCheck((xlogfNoCheck(iv) - divisorv) * gammav) * factorv; + STVFU(gammacurve[i], resultv); iv += fourv; } #else for (int i = 0; i < 65536; ++i) { - gammacurve[i] = Color::gammanf (static_cast (i) / divisor, gamma) * factor; + gammacurve[i] = Color::gammanf(static_cast(i) / divisor, gamma) * factor; } #endif } -void Color::Lab2XYZ (float L, float a, float b, float &x, float &y, float &z) +void Color::Lab2XYZ(float L, float a, float b, float &x, float &y, float &z) { float LL = L / 327.68f; float aa = a / 327.68f; @@ -1764,16 +1764,16 @@ void Color::Lab2XYZ (float L, float a, float b, float &x, float &y, float &z) float fy = (0.00862069f * LL) + 0.137932f; // (L+16)/116 float fx = (0.002f * aa) + fy; float fz = fy - (0.005f * bb); - x = 65535.0f * f2xyz (fx) * D50x; - z = 65535.0f * f2xyz (fz) * D50z; + x = 65535.0f * f2xyz(fx) * D50x; + z = 65535.0f * f2xyz(fz) * D50z; y = (LL > epskap) ? 65535.0f * fy * fy * fy : 65535.0f * LL / kappa; } -void Color::L2XYZ (float L, float &x, float &y, float &z) // for black & white +void Color::L2XYZ(float L, float &x, float &y, float &z) // for black & white { float LL = L / 327.68f; float fy = (0.00862069f * LL) + 0.137932f; // (L+16)/116 - float fxz = 65535.f * f2xyz (fy); + float fxz = 65535.f * f2xyz(fy); x = fxz * D50x; z = fxz * D50z; y = (LL > epskap) ? 65535.0f * fy * fy * fy : 65535.0f * LL / kappa; @@ -1781,21 +1781,21 @@ void Color::L2XYZ (float L, float &x, float &y, float &z) // for black & white #ifdef __SSE2__ -void Color::Lab2XYZ (vfloat L, vfloat a, vfloat b, vfloat &x, vfloat &y, vfloat &z) +void Color::Lab2XYZ(vfloat L, vfloat a, vfloat b, vfloat &x, vfloat &y, vfloat &z) { - vfloat c327d68 = F2V (327.68f); + vfloat c327d68 = F2V(327.68f); L /= c327d68; a /= c327d68; b /= c327d68; - vfloat fy = F2V (0.00862069f) * L + F2V (0.137932f); - vfloat fx = F2V (0.002f) * a + fy; - vfloat fz = fy - (F2V (0.005f) * b); - vfloat c65535 = F2V (65535.f); - x = c65535 * f2xyz (fx) * F2V (D50x); - z = c65535 * f2xyz (fz) * F2V (D50z); + vfloat fy = F2V(0.00862069f) * L + F2V(0.137932f); + vfloat fx = F2V(0.002f) * a + fy; + vfloat fz = fy - (F2V(0.005f) * b); + vfloat c65535 = F2V(65535.f); + x = c65535 * f2xyz(fx) * F2V(D50x); + z = c65535 * f2xyz(fz) * F2V(D50z); vfloat res1 = fy * fy * fy; - vfloat res2 = L / F2V (kappa); - y = vself (vmaskf_gt (L, F2V (epskap)), res1, res2); + vfloat res2 = L / F2V(kappa); + y = vself(vmaskf_gt(L, F2V(epskap)), res1, res2); y *= c65535; } #endif // __SSE2__ @@ -1812,7 +1812,8 @@ void Color::RGB2Lab(float *R, float *G, float *B, float *L, float *a, float *b, #endif int i = 0; #ifdef __SSE2__ - for(;i < width - 3; i+=4) { + + for (; i < width - 3; i += 4) { const vfloat rv = LVFU(R[i]); const vfloat gv = LVFU(G[i]); const vfloat bv = LVFU(B[i]); @@ -1821,9 +1822,10 @@ void Color::RGB2Lab(float *R, float *G, float *B, float *L, float *a, float *b, const vfloat zv = F2V(wp[2][0]) * rv + F2V(wp[2][1]) * gv + F2V(wp[2][2]) * bv; vmask maxMask = vmaskf_gt(vmaxf(xv, vmaxf(yv, zv)), maxvalfv); + if (_mm_movemask_ps((vfloat)maxMask)) { // take slower code path for all 4 pixels if one of the values is > MAXVALF. Still faster than non SSE2 version - for(int k = 0; k < 4; ++k) { + for (int k = 0; k < 4; ++k) { float x = xv[k]; float y = yv[k]; float z = zv[k]; @@ -1832,8 +1834,8 @@ void Color::RGB2Lab(float *R, float *G, float *B, float *L, float *a, float *b, float fz = (z <= 65535.f ? cachef[z] : (327.68f * xcbrtf(z / MAXVALF))); L[i + k] = (116.f * fy - 5242.88f); //5242.88=16.0*327.68; - a[i + k] = (500.f * (fx - fy) ); - b[i + k] = (200.f * (fy - fz) ); + a[i + k] = (500.f * (fx - fy)); + b[i + k] = (200.f * (fy - fz)); } } else { const vfloat fx = cachef[xv]; @@ -1845,8 +1847,10 @@ void Color::RGB2Lab(float *R, float *G, float *B, float *L, float *a, float *b, STVFU(b[i], c200v * (fy - fz)); } } + #endif - for(;i < width; ++i) { + + for (; i < width; ++i) { const float rv = R[i]; const float gv = G[i]; const float bv = B[i]; @@ -1873,32 +1877,32 @@ void Color::XYZ2Lab(float X, float Y, float Z, float &L, float &a, float &b) float y = Y; float fx, fy, fz; - fx = (x <= 65535.0f ? cachef[x] : (327.68f * xcbrtf (x / MAXVALF))); - fy = (y <= 65535.0f ? cachef[y] : (327.68f * xcbrtf (y / MAXVALF))); - fz = (z <= 65535.0f ? cachef[z] : (327.68f * xcbrtf (z / MAXVALF))); + fx = (x <= 65535.0f ? cachef[x] : (327.68f * xcbrtf(x / MAXVALF))); + fy = (y <= 65535.0f ? cachef[y] : (327.68f * xcbrtf(y / MAXVALF))); + fz = (z <= 65535.0f ? cachef[z] : (327.68f * xcbrtf(z / MAXVALF))); L = (116.0f * fy - 5242.88f); //5242.88=16.0*327.68; - a = (500.0f * (fx - fy) ); - b = (200.0f * (fy - fz) ); + a = (500.0f * (fx - fy)); + b = (200.0f * (fy - fz)); } -void Color::Lab2Yuv (float L, float a, float b, float &Y, float &u, float &v) +void Color::Lab2Yuv(float L, float a, float b, float &Y, float &u, float &v) { float fy = (0.00862069 * L / 327.68) + 0.137932; // (L+16)/116 float fx = (0.002 * a / 327.68) + fy; float fz = fy - (0.005 * b / 327.68); float LL = L / 327.68; - float X = 65535.0 * f2xyz (fx) * D50x; + float X = 65535.0 * f2xyz(fx) * D50x; // Y = 65535.0*f2xyz(fy); - float Z = 65535.0 * f2xyz (fz) * D50z; + float Z = 65535.0 * f2xyz(fz) * D50z; Y = (LL / 327.68f > epskap) ? 65535.0 * fy * fy * fy : 65535.0 * LL / kappa; u = 4.0 * X / (X + 15 * Y + 3 * Z) - u0; v = 9.0 * Y / (X + 15 * Y + 3 * Z) - v0; } -void Color::Yuv2Lab (float Yin, float u, float v, float &L, float &a, float &b, const double wp[3][3]) +void Color::Yuv2Lab(float Yin, float u, float v, float &L, float &a, float &b, const double wp[3][3]) { float u1 = u + u0; float v1 = v + v0; @@ -1907,49 +1911,49 @@ void Color::Yuv2Lab (float Yin, float u, float v, float &L, float &a, float &b, float X = (9 * u1 * Y) / (4 * v1 * D50x); float Z = (12 - 3 * u1 - 20 * v1) * Y / (4 * v1 * D50z); - gamutmap (X, Y, Z, wp); + gamutmap(X, Y, Z, wp); - float fx = (X <= 65535.0 ? cachef[X] : (327.68 * std::cbrt (X / MAXVALF))); - float fy = (Y <= 65535.0 ? cachef[Y] : (327.68 * std::cbrt (Y / MAXVALF))); - float fz = (Z <= 65535.0 ? cachef[Z] : (327.68 * std::cbrt (Z / MAXVALF))); + float fx = (X <= 65535.0 ? cachef[X] : (327.68 * std::cbrt(X / MAXVALF))); + float fy = (Y <= 65535.0 ? cachef[Y] : (327.68 * std::cbrt(Y / MAXVALF))); + float fz = (Z <= 65535.0 ? cachef[Z] : (327.68 * std::cbrt(Z / MAXVALF))); L = (116.0 * fy - 5242.88); //5242.88=16.0*327.68; - a = (500.0 * (fx - fy) ); - b = (200.0 * (fy - fz) ); + a = (500.0 * (fx - fy)); + b = (200.0 * (fy - fz)); } -void Color::Lab2Lch (float a, float b, float &c, float &h) +void Color::Lab2Lch(float a, float b, float &c, float &h) { - c = (sqrtf (a * a + b * b)) / 327.68f; - h = xatan2f (b, a); + c = (sqrtf(a * a + b * b)) / 327.68f; + h = xatan2f(b, a); } -void Color::Lch2Lab (float c, float h, float &a, float &b) +void Color::Lch2Lab(float c, float h, float &a, float &b) { - float2 sincosval = xsincosf (h); + float2 sincosval = xsincosf(h); a = 327.68f * c * sincosval.y; b = 327.68f * c * sincosval.x; } -void Color::Luv2Lch (float u, float v, float &c, float &h) +void Color::Luv2Lch(float u, float v, float &c, float &h) { - c = sqrtf (u * u + v * v); - h = xatan2f (v, u); //WARNING: should we care of division by zero here? + c = sqrtf(u * u + v * v); + h = xatan2f(v, u); //WARNING: should we care of division by zero here? if (h < 0.f) { h += 1.f; } } -void Color::Lch2Luv (float c, float h, float &u, float &v) +void Color::Lch2Luv(float c, float h, float &u, float &v) { - float2 sincosval = xsincosf (h); + float2 sincosval = xsincosf(h); u = c * sincosval.x; v = c * sincosval.y; } // NOT TESTED -void Color::XYZ2Luv (float X, float Y, float Z, float &L, float &u, float &v) +void Color::XYZ2Luv(float X, float Y, float Z, float &L, float &u, float &v) { X /= 65535.f; @@ -1957,7 +1961,7 @@ void Color::XYZ2Luv (float X, float Y, float Z, float &L, float &u, float &v) Z /= 65535.f; if (Y > float (eps)) { - L = 116.f * std::cbrt (Y) - 16.f; + L = 116.f * std::cbrt(Y) - 16.f; } else { L = float (kappa) * Y; } @@ -1967,7 +1971,7 @@ void Color::XYZ2Luv (float X, float Y, float Z, float &L, float &u, float &v) } // NOT TESTED -void Color::Luv2XYZ (float L, float u, float v, float &X, float &Y, float &Z) +void Color::Luv2XYZ(float L, float u, float v, float &X, float &Y, float &Z) { if (L > float (epskap)) { float t = (L + 16.f) / 116.f; @@ -2008,7 +2012,7 @@ void Color::Luv2XYZ (float L, float u, float v, float &X, float &Y, float &Z) * columns of the matrix p=xyz_rgb are RGB tristimulus primaries in XYZ * c is the color fixed on the boundary; and m=0 for c=0, m=1 for c=255 */ -void Color::gamutmap (float &X, float &Y, float &Z, const double p[3][3]) +void Color::gamutmap(float &X, float &Y, float &Z, const double p[3][3]) { float u = 4 * X / (X + 15 * Y + 3 * Z) - u0; float v = 9 * Y / (X + 15 * Y + 3 * Z) - v0; @@ -2045,7 +2049,7 @@ void Color::gamutmap (float &X, float &Y, float &Z, const double p[3][3]) Z = (12 - 3 * u - 20 * v) * Y / (4 * v); } -void Color::skinred ( double J, double h, double sres, double Sp, float dred, float protect_red, int sk, float rstprotection, float ko, double &s) +void Color::skinred(double J, double h, double sres, double Sp, float dred, float protect_red, int sk, float rstprotection, float ko, double &s) { float factorskin, factorsat, factor, factorskinext, interm; float scale = 100.0f / 100.1f; //reduction in normal zone @@ -2055,16 +2059,16 @@ void Color::skinred ( double J, double h, double sres, double Sp, float dred, fl bool doskin = false; //rough correspondence between h (JC) and H (lab) that has relatively little importance because transitions that blur the correspondence is not linear - if ((float)h > 8.6f && (float)h <= 74.f ) { + if ((float)h > 8.6f && (float)h <= 74.f) { HH = (1.15f / 65.4f) * (float)h - 0.0012f; //H > 0.15 H<1.3 doskin = true; - } else if ((float)h > 0.f && (float)h <= 8.6f ) { - HH = (0.19f / 8.6f ) * (float)h - 0.04f; //H>-0.04 H < 0.15 + } else if ((float)h > 0.f && (float)h <= 8.6f) { + HH = (0.19f / 8.6f) * (float)h - 0.04f; //H>-0.04 H < 0.15 doskin = true; } else if ((float)h > 355.f && (float)h <= 360.f) { - HH = (0.11f / 5.0f ) * (float)h - 7.96f; //H>-0.15 <-0.04 + HH = (0.11f / 5.0f) * (float)h - 7.96f; //H>-0.15 <-0.04 doskin = true; - } else if ((float)h > 74.f && (float)h < 95.f ) { + } else if ((float)h > 74.f && (float)h < 95.f) { HH = (0.30f / 21.0f) * (float)h + 0.24285f; //H>1.3 H<1.6 doskin = true; } @@ -2073,7 +2077,7 @@ void Color::skinred ( double J, double h, double sres, double Sp, float dred, fl float chromapro = sres / Sp; if (sk == 1) { //in C mode to adapt dred to J - if (J < 16.0) { + if (J < 16.0) { dred = 40.0f; } else if (J < 22.0) { dred = 2.5f * (float)J; @@ -2087,7 +2091,7 @@ void Color::skinred ( double J, double h, double sres, double Sp, float dred, fl } if (chromapro > 0.0) { - Color::scalered ( rstprotection, chromapro, 0.0, HH, deltaHH, scale, scaleext); //Scale factor + Color::scalered(rstprotection, chromapro, 0.0, HH, deltaHH, scale, scaleext); //Scale factor } if (chromapro > 1.0) { @@ -2101,29 +2105,29 @@ void Color::skinred ( double J, double h, double sres, double Sp, float dred, fl factorsat = chromapro; factor = factorsat; - Color::transitred ( HH, s, dred, factorskin, protect_red, factorskinext, deltaHH, factorsat, factor); //transition + Color::transitred(HH, s, dred, factorskin, protect_red, factorskinext, deltaHH, factorsat, factor); //transition s *= factor; } else { s = ko * sres; } } -void Color::skinredfloat ( float J, float h, float sres, float Sp, float dred, float protect_red, int sk, float rstprotection, float ko, float &s) +void Color::skinredfloat(float J, float h, float sres, float Sp, float dred, float protect_red, int sk, float rstprotection, float ko, float &s) { float HH; bool doskin = false; //rough correspondence between h (JC) and H (lab) that has relatively little importance because transitions that blur the correspondence is not linear - if ((float)h > 8.6f && (float)h <= 74.f ) { + if ((float)h > 8.6f && (float)h <= 74.f) { HH = (1.15f / 65.4f) * (float)h - 0.0012f; //H > 0.15 H<1.3 doskin = true; - } else if ((float)h > 0.f && (float)h <= 8.6f ) { - HH = (0.19f / 8.6f ) * (float)h - 0.04f; //H>-0.04 H < 0.15 + } else if ((float)h > 0.f && (float)h <= 8.6f) { + HH = (0.19f / 8.6f) * (float)h - 0.04f; //H>-0.04 H < 0.15 doskin = true; } else if ((float)h > 355.f && (float)h <= 360.f) { - HH = (0.11f / 5.0f ) * (float)h - 7.96f; //H>-0.15 <-0.04 + HH = (0.11f / 5.0f) * (float)h - 7.96f; //H>-0.15 <-0.04 doskin = true; - } else if ((float)h > 74.f && (float)h < 95.f ) { + } else if ((float)h > 74.f && (float)h < 95.f) { HH = (0.30f / 21.0f) * (float)h + 0.24285f; //H>1.3 H<1.6 doskin = true; } @@ -2134,7 +2138,7 @@ void Color::skinredfloat ( float J, float h, float sres, float Sp, float dred, f float chromapro = sres / Sp; if (sk == 1) { //in C mode to adapt dred to J - if (J < 16.f) { + if (J < 16.f) { dred = 40.f; } else if (J < 22.f) { dred = 2.5f * J; @@ -2150,7 +2154,7 @@ void Color::skinredfloat ( float J, float h, float sres, float Sp, float dred, f if (chromapro > 1.0) { float scale = 0.999000999f; // 100.0f/100.1f; reduction in normal zone float scaleext = 1.0f; //reduction in transition zone - Color::scalered ( rstprotection, chromapro, 0.0, HH, deltaHH, scale, scaleext);//Scale factor + Color::scalered(rstprotection, chromapro, 0.0, HH, deltaHH, scale, scaleext); //Scale factor float interm = (chromapro - 1.0f); factorskin = 1.0f + (interm * scale); factorskinext = 1.0f + (interm * scaleext); @@ -2161,7 +2165,7 @@ void Color::skinredfloat ( float J, float h, float sres, float Sp, float dred, f factorsat = chromapro; factor = factorsat; - Color::transitred ( HH, s, dred, factorskin, protect_red, factorskinext, deltaHH, factorsat, factor); //transition + Color::transitred(HH, s, dred, factorskin, protect_red, factorskinext, deltaHH, factorsat, factor); //transition s *= factor; } else { s = ko * sres; @@ -2174,7 +2178,7 @@ void Color::skinredfloat ( float J, float h, float sres, float Sp, float dred, f -void Color::scalered ( const float rstprotection, const float param, const float limit, const float HH, const float deltaHH, float &scale, float &scaleext) +void Color::scalered(const float rstprotection, const float param, const float limit, const float HH, const float deltaHH, float &scale, float &scaleext) { if (rstprotection < 99.9999f) { if (param > limit) { @@ -2195,7 +2199,7 @@ void Color::scalered ( const float rstprotection, const float param, const float } } -void Color::transitred (const float HH, float const Chprov1, const float dred, const float factorskin, const float protect_red, const float factorskinext, const float deltaHH, const float factorsat, float &factor) +void Color::transitred(const float HH, float const Chprov1, const float dred, const float factorskin, const float protect_red, const float factorskinext, const float deltaHH, const float factorsat, float &factor) { if (HH >= 0.15f && HH < 1.3f) { if (Chprov1 < dred) { @@ -2203,7 +2207,7 @@ void Color::transitred (const float HH, float const Chprov1, const float dred, c } else if (Chprov1 < (dred + protect_red)) { factor = ((factorsat - factorskin) * Chprov1 + factorsat * protect_red - (dred + protect_red) * (factorsat - factorskin)) / protect_red; } - } else if ( HH > (0.15f - deltaHH) && HH < (1.3f + deltaHH) ) { // test if chroma is in the extended range + } else if (HH > (0.15f - deltaHH) && HH < (1.3f + deltaHH)) { // test if chroma is in the extended range if (Chprov1 < dred) { factor = factorskinext; // C=dred=55 => real max of skin tones } else if (Chprov1 < (dred + protect_red)) {// transition @@ -2229,9 +2233,9 @@ void Color::transitred (const float HH, float const Chprov1, const float dred, c * MunsellDebugInfo* munsDbgInfo: (Debug target only) object to collect information. */ #ifdef _DEBUG -void Color::AllMunsellLch (bool lumaMuns, float Lprov1, float Loldd, float HH, float Chprov1, float CC, float &correctionHuechroma, float &correctlum, MunsellDebugInfo* munsDbgInfo) +void Color::AllMunsellLch(bool lumaMuns, float Lprov1, float Loldd, float HH, float Chprov1, float CC, float &correctionHuechroma, float &correctlum, MunsellDebugInfo* munsDbgInfo) #else -void Color::AllMunsellLch (bool lumaMuns, float Lprov1, float Loldd, float HH, float Chprov1, float CC, float &correctionHuechroma, float &correctlum) +void Color::AllMunsellLch(bool lumaMuns, float Lprov1, float Loldd, float HH, float Chprov1, float CC, float &correctionHuechroma, float &correctlum) #endif { @@ -2255,15 +2259,15 @@ void Color::AllMunsellLch (bool lumaMuns, float Lprov1, float Loldd, float HH, f //zone=zo; contin1 = contin2 = false; correctL = false; - MunsellLch (Lprov1, HH, Chprov1, CC, correctionHue, zo, correctionHueLum, correctL); //munsell chroma correction + MunsellLch(Lprov1, HH, Chprov1, CC, correctionHue, zo, correctionHueLum, correctL); //munsell chroma correction #ifdef _DEBUG - float absCorrectionHue = fabs (correctionHue); + float absCorrectionHue = fabs(correctionHue); if (correctionHue != 0.0) { int idx = zo - 1; #pragma omp critical (maxdhue) { - munsDbgInfo->maxdhue[idx] = MAX (munsDbgInfo->maxdhue[idx], absCorrectionHue); + munsDbgInfo->maxdhue[idx] = MAX(munsDbgInfo->maxdhue[idx], absCorrectionHue); } } @@ -2288,9 +2292,9 @@ void Color::AllMunsellLch (bool lumaMuns, float Lprov1, float Loldd, float HH, f correctionHueLum = 0.0; correctionHue = 0.0; - if (fabs (Lprov1 - Loldd) > 6.0) { + if (fabs(Lprov1 - Loldd) > 6.0) { // correction if delta L significative..Munsell luminance - MunsellLch (Loldd, HH, Chprov1, Chprov1, correctionHue, zo, correctionHueLum, correctL); + MunsellLch(Loldd, HH, Chprov1, Chprov1, correctionHue, zo, correctionHueLum, correctL); if (correctL) { correctlumprov2 = correctionHueLum; @@ -2305,13 +2309,13 @@ void Color::AllMunsellLch (bool lumaMuns, float Lprov1, float Loldd, float HH, f } #ifdef _DEBUG - float absCorrectLum = fabs (correctlum); + float absCorrectLum = fabs(correctlum); if (correctlum != 0.0) { int idx = zo - 1; #pragma omp critical (maxdhuelum) { - munsDbgInfo->maxdhuelum[idx] = MAX (munsDbgInfo->maxdhuelum[idx], absCorrectLum); + munsDbgInfo->maxdhuelum[idx] = MAX(munsDbgInfo->maxdhuelum[idx], absCorrectLum); } } @@ -2329,13 +2333,13 @@ void Color::AllMunsellLch (bool lumaMuns, float Lprov1, float Loldd, float HH, f #ifdef _DEBUG - if (correctlum < -0.35f) { + if (correctlum < -0.35f) { correctlum = -0.35f; } else if (correctlum > 0.35f) { correctlum = 0.35f; } - if (correctionHuechroma < -0.45f) { + if (correctionHuechroma < -0.45f) { correctionHuechroma = -0.45f; } else if (correctionHuechroma > 0.45f) { correctionHuechroma = 0.45f; @@ -2362,9 +2366,9 @@ void Color::AllMunsellLch (bool lumaMuns, float Lprov1, float Loldd, float HH, f * bool neg and moreRGB : only in DEBUG mode to calculate iterations for negatives values and > 65535 */ #ifdef _DEBUG -void Color::gamutLchonly (float HH, float &Lprov1, float &Chprov1, float &R, float &G, float &B, const double wip[3][3], const bool isHLEnabled, const float lowerCoef, const float higherCoef, bool &neg, bool &more_rgb) +void Color::gamutLchonly(float HH, float &Lprov1, float &Chprov1, float &R, float &G, float &B, const double wip[3][3], const bool isHLEnabled, const float lowerCoef, const float higherCoef, bool &neg, bool &more_rgb) #else -void Color::gamutLchonly (float HH, float &Lprov1, float &Chprov1, float &R, float &G, float &B, const double wip[3][3], const bool isHLEnabled, const float lowerCoef, const float higherCoef) +void Color::gamutLchonly(float HH, float &Lprov1, float &Chprov1, float &R, float &G, float &B, const double wip[3][3], const bool isHLEnabled, const float lowerCoef, const float higherCoef) #endif { const float ClipLevel = 65535.0f; @@ -2372,7 +2376,7 @@ void Color::gamutLchonly (float HH, float &Lprov1, float &Chprov1, float &R, flo #ifdef _DEBUG neg = false, more_rgb = false; #endif - float2 sincosval = xsincosf (HH); + float2 sincosval = xsincosf(HH); do { inGamut = true; @@ -2382,16 +2386,16 @@ void Color::gamutLchonly (float HH, float &Lprov1, float &Chprov1, float &R, flo float bprov1 = Chprov1 * sincosval.x; //conversion Lab RGB to limit Lab values - this conversion is useful before Munsell correction - float fy = (0.00862069f * Lprov1 ) + 0.137932f; + float fy = (0.00862069f * Lprov1) + 0.137932f; float fx = (0.002f * aprov1) + fy; float fz = fy - (0.005f * bprov1); - float x_ = 65535.0f * f2xyz (fx) * D50x; + float x_ = 65535.0f * f2xyz(fx) * D50x; // float y_ = 65535.0f * f2xyz(fy); - float z_ = 65535.0f * f2xyz (fz) * D50z; + float z_ = 65535.0f * f2xyz(fz) * D50z; float y_ = (Lprov1 > epskap) ? 65535.0 * fy * fy * fy : 65535.0 * Lprov1 / kappa; - xyz2rgb (x_, y_, z_, R, G, B, wip); + xyz2rgb(x_, y_, z_, R, G, B, wip); // gamut control before saturation to put Lab values in future gamut, but not RGB if (R < 0.0f || G < 0.0f || B < 0.0f) { @@ -2404,7 +2408,7 @@ void Color::gamutLchonly (float HH, float &Lprov1, float &Chprov1, float &R, flo } //gamut for L with ultra blue : we can improve the algorithm ... thinner, and other color ??? - if (HH < -0.9f && HH > -1.55f ) { //ultra blue + if (HH < -0.9f && HH > -1.55f) { //ultra blue if (Chprov1 > 160.f) if (Lprov1 < 5.f) { Lprov1 = 5.f; //very very very very high chroma } @@ -2483,9 +2487,9 @@ void Color::gamutLchonly (float HH, float &Lprov1, float &Chprov1, float &R, flo * bool neg and moreRGB : only in DEBUG mode to calculate iterations for negatives values and > 65535 */ #ifdef _DEBUG -void Color::gamutLchonly (float HH, float2 sincosval, float &Lprov1, float &Chprov1, float &R, float &G, float &B, const double wip[3][3], const bool isHLEnabled, const float lowerCoef, const float higherCoef, bool &neg, bool &more_rgb) +void Color::gamutLchonly(float HH, float2 sincosval, float &Lprov1, float &Chprov1, float &R, float &G, float &B, const double wip[3][3], const bool isHLEnabled, const float lowerCoef, const float higherCoef, bool &neg, bool &more_rgb) #else -void Color::gamutLchonly (float HH, float2 sincosval, float &Lprov1, float &Chprov1, float &R, float &G, float &B, const double wip[3][3], const bool isHLEnabled, const float lowerCoef, const float higherCoef) +void Color::gamutLchonly(float HH, float2 sincosval, float &Lprov1, float &Chprov1, float &R, float &G, float &B, const double wip[3][3], const bool isHLEnabled, const float lowerCoef, const float higherCoef) #endif { constexpr float ClipLevel = 65535.0f; @@ -2502,15 +2506,15 @@ void Color::gamutLchonly (float HH, float2 sincosval, float &Lprov1, float &Chpr float bprov1 = Chprov1 * sincosval.x; //conversion Lab RGB to limit Lab values - this conversion is useful before Munsell correction - float fy = (0.00862069f * Lprov1 ) + 0.137932f; + float fy = (0.00862069f * Lprov1) + 0.137932f; float fx = (0.002f * aprov1) + fy; float fz = fy - (0.005f * bprov1); - float x_ = 65535.0f * f2xyz (fx) * D50x; - float z_ = 65535.0f * f2xyz (fz) * D50z; + float x_ = 65535.0f * f2xyz(fx) * D50x; + float z_ = 65535.0f * f2xyz(fz) * D50z; float y_ = (Lprov1 > epskap) ? 65535.0f * fy * fy * fy : 65535.0f * Lprov1 / kappa; - xyz2rgb (x_, y_, z_, R, G, B, wip); + xyz2rgb(x_, y_, z_, R, G, B, wip); // gamut control before saturation to put Lab values in future gamut, but not RGB if (R < 0.0f || G < 0.0f || B < 0.0f) { @@ -2518,10 +2522,10 @@ void Color::gamutLchonly (float HH, float2 sincosval, float &Lprov1, float &Chpr neg = true; #endif - if (isnan (HH)) { + if (isnan(HH)) { float atemp = ChprovSave * sincosval.y * 327.68; float btemp = ChprovSave * sincosval.x * 327.68; - HH = xatan2f (btemp, atemp); + HH = xatan2f(btemp, atemp); } if (Lprov1 < 0.1f) { @@ -2529,7 +2533,7 @@ void Color::gamutLchonly (float HH, float2 sincosval, float &Lprov1, float &Chpr } //gamut for L with ultra blue : we can improve the algorithm ... thinner, and other color ??? - if (HH < -0.9f && HH > -1.55f ) { //ultra blue + if (HH < -0.9f && HH > -1.55f) { //ultra blue if (Chprov1 > 160.f) if (Lprov1 < 5.f) { Lprov1 = 5.f; //very very very very high chroma } @@ -2592,9 +2596,9 @@ void Color::gamutLchonly (float HH, float2 sincosval, float &Lprov1, float &Chpr #ifdef _DEBUG -void Color::gamutLchonly (float2 sincosval, float &Lprov1, float &Chprov1, const float wip[3][3], const bool isHLEnabled, const float lowerCoef, const float higherCoef, bool &neg, bool &more_rgb) +void Color::gamutLchonly(float2 sincosval, float &Lprov1, float &Chprov1, const float wip[3][3], const bool isHLEnabled, const float lowerCoef, const float higherCoef, bool &neg, bool &more_rgb) #else -void Color::gamutLchonly (float2 sincosval, float &Lprov1, float &Chprov1, const float wip[3][3], const bool isHLEnabled, const float lowerCoef, const float higherCoef) +void Color::gamutLchonly(float2 sincosval, float &Lprov1, float &Chprov1, const float wip[3][3], const bool isHLEnabled, const float lowerCoef, const float higherCoef) #endif { const float ClipLevel = 65535.0f; @@ -2611,17 +2615,17 @@ void Color::gamutLchonly (float2 sincosval, float &Lprov1, float &Chprov1, const float bprov1 = Chprov1 * sincosval.x; //conversion Lab RGB to limit Lab values - this conversion is useful before Munsell correction - float fy = (0.00862069f * Lprov1 ) + 0.137932f; + float fy = (0.00862069f * Lprov1) + 0.137932f; float fx = (0.002f * aprov1) + fy; float fz = fy - (0.005f * bprov1); - float x_ = 65535.0f * f2xyz (fx) * D50x; + float x_ = 65535.0f * f2xyz(fx) * D50x; // float y_ = 65535.0f * f2xyz(fy); - float z_ = 65535.0f * f2xyz (fz) * D50z; + float z_ = 65535.0f * f2xyz(fz) * D50z; float y_ = (Lprov1 > epskap) ? 65535.0 * fy * fy * fy : 65535.0 * Lprov1 / kappa; float R, G, B; - xyz2rgb (x_, y_, z_, R, G, B, wip); + xyz2rgb(x_, y_, z_, R, G, B, wip); // gamut control before saturation to put Lab values in future gamut, but not RGB if (R < 0.0f || G < 0.0f || B < 0.0f) { @@ -2703,20 +2707,20 @@ SSEFUNCTION void Color::LabGamutMunsell(float *labL, float *laba, float *labb, // precalculate H and C using SSE float HHBuffer[N]; float CCBuffer[N]; - __m128 c327d68v = _mm_set1_ps (327.68f); + __m128 c327d68v = _mm_set1_ps(327.68f); __m128 av, bv; int k; for (k = 0; k < N - 3; k += 4) { - av = LVFU (laba[k]); - bv = LVFU (labb[k]); - _mm_storeu_ps (&HHBuffer[k], xatan2f (bv, av)); - _mm_storeu_ps (&CCBuffer[k], _mm_sqrt_ps (SQRV (av) + SQRV (bv)) / c327d68v); + av = LVFU(laba[k]); + bv = LVFU(labb[k]); + _mm_storeu_ps(&HHBuffer[k], xatan2f(bv, av)); + _mm_storeu_ps(&CCBuffer[k], _mm_sqrt_ps(SQRV(av) + SQRV(bv)) / c327d68v); } for (; k < N; k++) { - HHBuffer[k] = xatan2f (labb[k], laba[k]); - CCBuffer[k] = sqrt (SQR (laba[k]) + SQR (labb[k])) / 327.68f; + HHBuffer[k] = xatan2f(labb[k], laba[k]); + CCBuffer[k] = sqrt(SQR(laba[k]) + SQR(labb[k])) / 327.68f; } #endif // __SSE2__ @@ -2726,8 +2730,8 @@ SSEFUNCTION void Color::LabGamutMunsell(float *labL, float *laba, float *labb, float HH = HHBuffer[j]; float Chprov1 = CCBuffer[j]; #else - float HH = xatan2f (labb[j], laba[j]); - float Chprov1 = sqrtf (SQR (laba[j]) + SQR (labb[j])) / 327.68f; + float HH = xatan2f(labb[j], laba[j]); + float Chprov1 = sqrtf(SQR(laba[j]) + SQR(labb[j])) / 327.68f; #endif float Lprov1 = labL[j] / 327.68f; float Loldd = Lprov1; @@ -2751,9 +2755,9 @@ SSEFUNCTION void Color::LabGamutMunsell(float *labL, float *laba, float *labb, //gamut control : Lab values are in gamut #ifdef _DEBUG - gamutLchonly (HH, sincosval, Lprov1, Chprov1, R, G, B, wip, isHLEnabled, 0.15f, 0.96f, neg, more_rgb); + gamutLchonly(HH, sincosval, Lprov1, Chprov1, R, G, B, wip, isHLEnabled, 0.15f, 0.96f, neg, more_rgb); #else - gamutLchonly (HH, sincosval, Lprov1, Chprov1, R, G, B, wip, isHLEnabled, 0.15f, 0.96f); + gamutLchonly(HH, sincosval, Lprov1, Chprov1, R, G, B, wip, isHLEnabled, 0.15f, 0.96f); #endif #ifdef _DEBUG @@ -2775,10 +2779,10 @@ SSEFUNCTION void Color::LabGamutMunsell(float *labL, float *laba, float *labb, if (corMunsell) #ifdef _DEBUG - AllMunsellLch (lumaMuns, Lprov1, Loldd, HH, Chprov1, Coldd, correctionHuechroma, correctlum, MunsDebugInfo); + AllMunsellLch(lumaMuns, Lprov1, Loldd, HH, Chprov1, Coldd, correctionHuechroma, correctlum, MunsDebugInfo); #else - AllMunsellLch (lumaMuns, Lprov1, Loldd, HH, Chprov1, Coldd, correctionHuechroma, correctlum); + AllMunsellLch(lumaMuns, Lprov1, Loldd, HH, Chprov1, Coldd, correctionHuechroma, correctlum); #endif if (correctlum == 0.f && correctionHuechroma == 0.f) { @@ -2794,7 +2798,7 @@ SSEFUNCTION void Color::LabGamutMunsell(float *labL, float *laba, float *labb, } else { HH += correctlum; //hue Munsell luminance correction - sincosval = xsincosf (HH + correctionHuechroma); + sincosval = xsincosf(HH + correctionHuechroma); } laba[j] = Chprov1 * sincosval.y * 327.68f; @@ -2805,14 +2809,14 @@ SSEFUNCTION void Color::LabGamutMunsell(float *labL, float *laba, float *labb, t2e.set(); if (settings->verbose) { - printf ("Color::LabGamutMunsell (correction performed in %d usec):\n", t2e.etime (t1e)); - printf (" Gamut : G1negat=%iiter G165535=%iiter \n", negat, moreRGB); + printf("Color::LabGamutMunsell (correction performed in %d usec):\n", t2e.etime(t1e)); + printf(" Gamut : G1negat=%iiter G165535=%iiter \n", negat, moreRGB); if (MunsDebugInfo) { - printf (" Munsell chrominance: MaxBP=%1.2frad MaxRY=%1.2frad MaxGY=%1.2frad MaxRP=%1.2frad depass=%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 depass=%u\n", MunsDebugInfo->maxdhuelum[0] , MunsDebugInfo->maxdhuelum[1], MunsDebugInfo->maxdhuelum[2], MunsDebugInfo->maxdhuelum[3], MunsDebugInfo->depassLum); + printf(" Munsell chrominance: MaxBP=%1.2frad MaxRY=%1.2frad MaxGY=%1.2frad MaxRP=%1.2frad depass=%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 depass=%u\n", MunsDebugInfo->maxdhuelum[0], MunsDebugInfo->maxdhuelum[1], MunsDebugInfo->maxdhuelum[2], MunsDebugInfo->maxdhuelum[3], MunsDebugInfo->depassLum); } else { - printf (" Munsell correction wasn't requested\n"); + printf(" Munsell correction wasn't requested\n"); } } @@ -2830,7 +2834,7 @@ SSEFUNCTION void Color::LabGamutMunsell(float *labL, float *laba, float *labb, * * Find the right LUT and calculate the correction */ -void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, float &correction, int zone, float &lbe, bool &correctL) +void Color::MunsellLch(float lum, float hue, float chrom, float memChprov, float &correction, int zone, float &lbe, bool &correctL) { int x = int (memChprov); @@ -2840,7 +2844,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa if (zone == 1) { if (lum > 5.0) { if (lum < 15.0) { - if ( (hue >= (_15PB10[x] - 0.035)) && (hue < (_15PB10[x] + 0.052) && x <= 45)) { + if ((hue >= (_15PB10[x] - 0.035)) && (hue < (_15PB10[x] + 0.052) && x <= 45)) { if (y > 49) { y = 49; } @@ -2848,7 +2852,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _15PB10[y] - _15PB10[x] ; lbe = _15PB10[y]; correctL = true; - } else if (( hue >= ( _3PB10[x] - 0.052)) && (hue < (_45PB10[x] + _3PB10[x]) / 2.0) && x <= 85) { + } else if ((hue >= (_3PB10[x] - 0.052)) && (hue < (_45PB10[x] + _3PB10[x]) / 2.0) && x <= 85) { if (y > 89) { y = 89; } @@ -2856,7 +2860,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _3PB10[y] - _3PB10[x]; lbe = _3PB10[y]; correctL = true; - } else if (( hue >= (_45PB10[x] + _3PB10[x]) / 2.0) && (hue < (_45PB10[x] + 0.052)) && x <= 85) { + } else if ((hue >= (_45PB10[x] + _3PB10[x]) / 2.0) && (hue < (_45PB10[x] + 0.052)) && x <= 85) { if (y > 89) { y = 89; } @@ -2864,33 +2868,33 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _45PB10[y] - _45PB10[x] ; lbe = _45PB10[y]; correctL = true; - } else if (( hue >= (_6PB10[x] - 0.052) && (hue < (_6PB10[x] + _75PB10[x]) / 2.0))) { + } else if ((hue >= (_6PB10[x] - 0.052) && (hue < (_6PB10[x] + _75PB10[x]) / 2.0))) { correction = _6PB10[y] - _6PB10[x] ; lbe = _6PB10[y]; correctL = true; - } else if (( hue >= (_6PB10[x] + _75PB10[x]) / 2.0) && (hue < (_9PB10[x] + _75PB10[x]) / 2.0)) { + } else if ((hue >= (_6PB10[x] + _75PB10[x]) / 2.0) && (hue < (_9PB10[x] + _75PB10[x]) / 2.0)) { correction = _75PB10[y] - _75PB10[x] ; lbe = _75PB10[y]; correctL = true; - } else if (( hue >= (_9PB10[x] + _75PB10[x]) / 2.0) && (hue < (_9PB10[x] + _10PB10[x]) / 2.0)) { + } else if ((hue >= (_9PB10[x] + _75PB10[x]) / 2.0) && (hue < (_9PB10[x] + _10PB10[x]) / 2.0)) { correction = _9PB10[y] - _9PB10[x] ; lbe = _9PB10[y]; correctL = true; - } else if (( hue >= (_10PB10[x] + _9PB10[x]) / 2.0) && (hue < (_1P10[x] + _10PB10[x]) / 2.0)) { + } else if ((hue >= (_10PB10[x] + _9PB10[x]) / 2.0) && (hue < (_1P10[x] + _10PB10[x]) / 2.0)) { correction = _10PB10[y] - _10PB10[x] ; lbe = _10PB10[y]; correctL = true; - } else if (( hue >= (_10PB10[x] + _1P10[x]) / 2.0) && (hue < (_1P10[x] + _4P10[x]) / 2.0)) { + } else if ((hue >= (_10PB10[x] + _1P10[x]) / 2.0) && (hue < (_1P10[x] + _4P10[x]) / 2.0)) { correction = _1P10[y] - _1P10[x]; lbe = _1P10[y]; correctL = true; - } else if (( hue >= (_1P10[x] + _4P10[x]) / 2.0) && (hue < (0.035 + _4P10[x]) / 2.0)) { + } else if ((hue >= (_1P10[x] + _4P10[x]) / 2.0) && (hue < (0.035 + _4P10[x]) / 2.0)) { correction = _4P10[y] - _4P10[x] ; lbe = _4P10[y]; correctL = true; } } else if (lum < 25.0) { - if ( (hue >= (_15PB20[x] - 0.035)) && (hue < (_15PB20[x] + _3PB20[x]) / 2.0) && x <= 85) { + if ((hue >= (_15PB20[x] - 0.035)) && (hue < (_15PB20[x] + _3PB20[x]) / 2.0) && x <= 85) { if (y > 89) { y = 89; } @@ -2898,7 +2902,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _15PB20[y] - _15PB20[x] ; lbe = _15PB20[y]; correctL = true; - } else if (( hue >= (_15PB20[x] + _3PB20[x]) / 2.0) && (hue < (_45PB20[x] + _3PB20[x]) / 2.0) && x <= 85) { + } else if ((hue >= (_15PB20[x] + _3PB20[x]) / 2.0) && (hue < (_45PB20[x] + _3PB20[x]) / 2.0) && x <= 85) { if (y > 89) { y = 89; } @@ -2906,7 +2910,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _3PB20[y] - _3PB20[x] ; lbe = _3PB20[y]; correctL = true; - } else if (( hue >= (_45PB20[x] + _3PB20[x]) / 2.0) && (hue < ( _45PB20[x] + 0.052)) && x <= 85) { + } else if ((hue >= (_45PB20[x] + _3PB20[x]) / 2.0) && (hue < (_45PB20[x] + 0.052)) && x <= 85) { if (y > 89) { y = 89; } @@ -2914,33 +2918,33 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _45PB20[y] - _45PB20[x] ; lbe = _45PB20[y]; correctL = true; - } else if (( hue >= (_45PB20[x] + 0.052)) && (hue < (_6PB20[x] + _75PB20[x]) / 2.0)) { + } else if ((hue >= (_45PB20[x] + 0.052)) && (hue < (_6PB20[x] + _75PB20[x]) / 2.0)) { correction = _6PB20[y] - _6PB20[x]; lbe = _6PB20[y]; correctL = true; - } else if (( hue >= (_6PB20[x] + _75PB20[x]) / 2.0) && (hue < (_9PB20[x] + _75PB20[x]) / 2.0)) { + } else if ((hue >= (_6PB20[x] + _75PB20[x]) / 2.0) && (hue < (_9PB20[x] + _75PB20[x]) / 2.0)) { correction = _75PB20[y] - _75PB20[x] ; lbe = _75PB20[y]; correctL = true; - } else if (( hue >= (_9PB20[x] + _75PB20[x]) / 2.0) && (hue < (_9PB20[x] + _10PB20[x]) / 2.0)) { + } else if ((hue >= (_9PB20[x] + _75PB20[x]) / 2.0) && (hue < (_9PB20[x] + _10PB20[x]) / 2.0)) { correction = _9PB20[y] - _9PB20[x] ; lbe = _9PB20[y]; correctL = true; - } else if (( hue >= (_10PB20[x] + _9PB20[x]) / 2.0) && (hue < (_1P20[x] + _10PB20[x]) / 2.0)) { + } else if ((hue >= (_10PB20[x] + _9PB20[x]) / 2.0) && (hue < (_1P20[x] + _10PB20[x]) / 2.0)) { correction = _10PB20[y] - _10PB20[x] ; lbe = _10PB20[y]; correctL = true; - } else if (( hue >= (_10PB20[x] + _1P20[x]) / 2.0) && (hue < (_1P20[x] + _4P20[x]) / 2.0)) { + } else if ((hue >= (_10PB20[x] + _1P20[x]) / 2.0) && (hue < (_1P20[x] + _4P20[x]) / 2.0)) { correction = _1P20[y] - _1P20[x] ; lbe = _1P20[y]; correctL = true; - } else if (( hue >= (_1P20[x] + _4P20[x]) / 2.0) && (hue < (0.035 + _4P20[x]) / 2.0)) { + } else if ((hue >= (_1P20[x] + _4P20[x]) / 2.0) && (hue < (0.035 + _4P20[x]) / 2.0)) { correction = _4P20[y] - _4P20[x] ; lbe = _4P20[y]; correctL = true; } } else if (lum < 35.0) { - if ( (hue >= (_15PB30[x] - 0.035)) && (hue < (_15PB30[x] + _3PB30[x]) / 2.0) && x <= 85 ) { + if ((hue >= (_15PB30[x] - 0.035)) && (hue < (_15PB30[x] + _3PB30[x]) / 2.0) && x <= 85) { if (y > 89) { y = 89; } @@ -2948,7 +2952,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _15PB30[y] - _15PB30[x] ; lbe = _15PB30[y]; correctL = true; - } else if (( hue >= (_15PB30[x] + _3PB30[x]) / 2.0) && (hue < (_45PB30[x] + _3PB30[x]) / 2.0) && x <= 85) { + } else if ((hue >= (_15PB30[x] + _3PB30[x]) / 2.0) && (hue < (_45PB30[x] + _3PB30[x]) / 2.0) && x <= 85) { if (y > 89) { y = 89; } @@ -2956,7 +2960,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _3PB30[y] - _3PB30[x] ; lbe = _3PB30[y]; correctL = true; - } else if (( hue >= (_45PB30[x] + _3PB30[x]) / 2.0) && (hue < (_45PB30[x] + 0.052)) && x <= 85) { + } else if ((hue >= (_45PB30[x] + _3PB30[x]) / 2.0) && (hue < (_45PB30[x] + 0.052)) && x <= 85) { if (y > 89) { y = 89; } @@ -2964,33 +2968,33 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _45PB30[y] - _45PB30[x] ; lbe = _45PB30[y]; correctL = true; - } else if (( hue >= ( _45PB30[x] + 0.052)) && (hue < (_6PB30[x] + _75PB30[x]) / 2.0)) { + } else if ((hue >= (_45PB30[x] + 0.052)) && (hue < (_6PB30[x] + _75PB30[x]) / 2.0)) { correction = _6PB30[y] - _6PB30[x] ; lbe = _6PB30[y]; correctL = true; - } else if (( hue >= (_6PB30[x] + _75PB30[x]) / 2.0) && (hue < (_9PB30[x] + _75PB30[x]) / 2.0)) { + } else if ((hue >= (_6PB30[x] + _75PB30[x]) / 2.0) && (hue < (_9PB30[x] + _75PB30[x]) / 2.0)) { correction = _75PB30[y] - _75PB30[x] ; lbe = _75PB30[y] ; correctL = true; - } else if (( hue >= (_9PB30[x] + _75PB30[x]) / 2.0) && (hue < (_9PB30[x] + _10PB30[x]) / 2.0)) { + } else if ((hue >= (_9PB30[x] + _75PB30[x]) / 2.0) && (hue < (_9PB30[x] + _10PB30[x]) / 2.0)) { correction = _9PB30[y] - _9PB30[x] ; lbe = _9PB30[y]; correctL = true; - } else if (( hue >= (_10PB30[x] + _9PB30[x]) / 2.0) && (hue < (_1P30[x] + _10PB30[x]) / 2.0)) { + } else if ((hue >= (_10PB30[x] + _9PB30[x]) / 2.0) && (hue < (_1P30[x] + _10PB30[x]) / 2.0)) { correction = _10PB30[y] - _10PB30[x] ; lbe = _10PB30[y]; correctL = true; - } else if (( hue >= (_10PB30[x] + _1P30[x]) / 2.0) && (hue < (_1P30[x] + _4P30[x]) / 2.0)) { + } else if ((hue >= (_10PB30[x] + _1P30[x]) / 2.0) && (hue < (_1P30[x] + _4P30[x]) / 2.0)) { correction = _1P30[y] - _1P30[x] ; lbe = _1P30[y]; correctL = true; - } else if (( hue >= (_1P30[x] + _4P30[x]) / 2.0) && (hue < (0.035 + _4P30[x]) / 2.0)) { + } else if ((hue >= (_1P30[x] + _4P30[x]) / 2.0) && (hue < (0.035 + _4P30[x]) / 2.0)) { correction = _4P30[y] - _4P30[x] ; lbe = _4P30[y]; correctL = true; } } else if (lum < 45.0) { - if ( (hue <= (_05PB40[x] + _15PB40[x]) / 2.0) && (hue > (_05PB40[x] + _10B40[x]) / 2.0) && x < 75 ) { + if ((hue <= (_05PB40[x] + _15PB40[x]) / 2.0) && (hue > (_05PB40[x] + _10B40[x]) / 2.0) && x < 75) { if (y > 75) { y = 75; } @@ -2998,7 +3002,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _05PB40[y] - _05PB40[x] ; lbe = _05PB40[y]; correctL = true; - } else if ( (hue <= (_05PB40[x] + _10B40[x]) / 2.0) && (hue > (_10B40[x] + _9B40[x]) / 2.0) && x < 70 ) { + } else if ((hue <= (_05PB40[x] + _10B40[x]) / 2.0) && (hue > (_10B40[x] + _9B40[x]) / 2.0) && x < 70) { if (y > 70) { y = 70; } @@ -3006,7 +3010,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _10B40[y] - _10B40[x] ; lbe = _10B40[y]; correctL = true; - } else if ( (hue <= (_10B40[x] + _9B40[x]) / 2.0) && (hue > (_9B40[x] + _7B40[x]) / 2.0) && x < 70 ) { + } else if ((hue <= (_10B40[x] + _9B40[x]) / 2.0) && (hue > (_9B40[x] + _7B40[x]) / 2.0) && x < 70) { if (y > 70) { y = 70; } @@ -3014,7 +3018,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _9B40[y] - _9B40[x] ; lbe = _9B40[y]; correctL = true; - } else if ( (hue <= (_9B40[x] + _7B40[x]) / 2.0) && (hue > (_5B40[x] + _7B40[x]) / 2.0) && x < 70 ) { + } else if ((hue <= (_9B40[x] + _7B40[x]) / 2.0) && (hue > (_5B40[x] + _7B40[x]) / 2.0) && x < 70) { if (y > 70) { y = 70; } @@ -3022,7 +3026,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _7B40[y] - _7B40[x] ; lbe = _7B40[y]; correctL = true; - } else if (( hue <= (_5B40[x] + _7B40[x]) / 2.0) && (hue > (_5B40[x] - 0.035)) && x < 70) { + } else if ((hue <= (_5B40[x] + _7B40[x]) / 2.0) && (hue > (_5B40[x] - 0.035)) && x < 70) { if (y > 70) { y = 70; // } @@ -3032,7 +3036,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correctL = true; } - else if ( (hue >= (_15PB40[x] - 0.035)) && (hue < (_15PB40[x] + _3PB40[x]) / 2.0) && x <= 85 ) { + else if ((hue >= (_15PB40[x] - 0.035)) && (hue < (_15PB40[x] + _3PB40[x]) / 2.0) && x <= 85) { if (y > 89) { y = 89; } @@ -3040,7 +3044,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _15PB40[y] - _15PB40[x] ; lbe = _15PB40[y]; correctL = true; - } else if (( hue >= (_15PB40[x] + _3PB40[x]) / 2.0) && (hue < (_45PB40[x] + _3PB40[x]) / 2.0) && x <= 85) { + } else if ((hue >= (_15PB40[x] + _3PB40[x]) / 2.0) && (hue < (_45PB40[x] + _3PB40[x]) / 2.0) && x <= 85) { if (y > 89) { y = 89; } @@ -3048,7 +3052,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _3PB40[y] - _3PB40[x] ; lbe = _3PB40[y]; correctL = true; - } else if (( hue >= (_45PB40[x] + _3PB40[x]) / 2.0) && (hue < (_45PB40[x] + 0.052)) && x <= 85) { + } else if ((hue >= (_45PB40[x] + _3PB40[x]) / 2.0) && (hue < (_45PB40[x] + 0.052)) && x <= 85) { if (y > 89) { y = 89; } @@ -3056,33 +3060,33 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _45PB40[y] - _45PB40[x] ; lbe = _45PB40[y] ; correctL = true; - } else if (( hue >= (_45PB40[x] + 0.052)) && (hue < (_6PB40[x] + _75PB40[x]) / 2.0)) { + } else if ((hue >= (_45PB40[x] + 0.052)) && (hue < (_6PB40[x] + _75PB40[x]) / 2.0)) { correction = _6PB40[y] - _6PB40[x] ; lbe = _6PB40[y]; correctL = true; - } else if (( hue >= (_6PB40[x] + _75PB40[x]) / 2.0) && (hue < (_9PB40[x] + _75PB40[x]) / 2.0)) { + } else if ((hue >= (_6PB40[x] + _75PB40[x]) / 2.0) && (hue < (_9PB40[x] + _75PB40[x]) / 2.0)) { correction = _75PB40[y] - _75PB40[x] ; lbe = _75PB40[y]; correctL = true; - } else if (( hue >= (_9PB40[x] + _75PB40[x]) / 2.0) && (hue < (_9PB40[x] + _10PB40[x]) / 2.0)) { + } else if ((hue >= (_9PB40[x] + _75PB40[x]) / 2.0) && (hue < (_9PB40[x] + _10PB40[x]) / 2.0)) { correction = _9PB40[y] - _9PB40[x] ; lbe = _9PB40[y]; correctL = true; - } else if (( hue >= (_10PB40[x] + _9PB40[x]) / 2.0) && (hue < (_1P40[x] + _10PB40[x]) / 2.0)) { + } else if ((hue >= (_10PB40[x] + _9PB40[x]) / 2.0) && (hue < (_1P40[x] + _10PB40[x]) / 2.0)) { correction = _10PB40[y] - _10PB40[x] ; lbe = _10PB40[y]; correctL = true; - } else if (( hue >= (_10PB40[x] + _1P40[x]) / 2.0) && (hue < (_1P40[x] + _4P40[x]) / 2.0)) { + } else if ((hue >= (_10PB40[x] + _1P40[x]) / 2.0) && (hue < (_1P40[x] + _4P40[x]) / 2.0)) { correction = _1P40[y] - _1P40[x] ; lbe = _1P40[y]; correctL = true; - } else if (( hue >= (_1P40[x] + _4P40[x]) / 2.0) && (hue < (0.035 + _4P40[x]) / 2.0)) { + } else if ((hue >= (_1P40[x] + _4P40[x]) / 2.0) && (hue < (0.035 + _4P40[x]) / 2.0)) { correction = _4P40[y] - _4P40[x] ; lbe = _4P40[y]; correctL = true; } } else if (lum < 55.0) { - if ( (hue <= (_05PB50[x] + _15PB50[x]) / 2.0) && (hue > (_05PB50[x] + _10B50[x]) / 2.0) && x < 79 ) { + if ((hue <= (_05PB50[x] + _15PB50[x]) / 2.0) && (hue > (_05PB50[x] + _10B50[x]) / 2.0) && x < 79) { if (y > 79) { y = 79; } @@ -3090,7 +3094,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _05PB50[y] - _05PB50[x] ; lbe = _05PB50[y]; correctL = true; - } else if ( (hue <= (_05PB50[x] + _10B50[x]) / 2.0) && (hue > (_10B50[x] + _9B50[x]) / 2.0) && x < 79 ) { + } else if ((hue <= (_05PB50[x] + _10B50[x]) / 2.0) && (hue > (_10B50[x] + _9B50[x]) / 2.0) && x < 79) { if (y > 79) { y = 79; } @@ -3098,7 +3102,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _10B50[y] - _10B50[x] ; lbe = _10B50[y]; correctL = true; - } else if ( (hue <= (_10B50[x] + _9B50[x]) / 2.0) && (hue > (_9B50[x] + _7B50[x]) / 2.0) && x < 79 ) { + } else if ((hue <= (_10B50[x] + _9B50[x]) / 2.0) && (hue > (_9B50[x] + _7B50[x]) / 2.0) && x < 79) { if (y > 79) { y = 79; } @@ -3106,7 +3110,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _9B50[y] - _9B50[x] ; lbe = _9B50[y]; correctL = true; - } else if ( (hue <= (_9B50[x] + _7B50[x]) / 2.0) && (hue > (_5B50[x] + _7B50[x]) / 2.0) && x < 79 ) { + } else if ((hue <= (_9B50[x] + _7B50[x]) / 2.0) && (hue > (_5B50[x] + _7B50[x]) / 2.0) && x < 79) { if (y > 79) { y = 79; } @@ -3114,7 +3118,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _7B50[y] - _7B50[x] ; lbe = _7B50[y]; correctL = true; - } else if (( hue <= (_5B50[x] + _7B50[x]) / 2.0) && (hue > (_5B50[x] - 0.035)) && x < 79) { + } else if ((hue <= (_5B50[x] + _7B50[x]) / 2.0) && (hue > (_5B50[x] - 0.035)) && x < 79) { if (y > 79) { y = 79; // } @@ -3124,7 +3128,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correctL = true; } - else if ( (hue >= (_15PB50[x] - 0.035)) && (hue < (_15PB50[x] + _3PB50[x]) / 2.0) && x <= 85 ) { + else if ((hue >= (_15PB50[x] - 0.035)) && (hue < (_15PB50[x] + _3PB50[x]) / 2.0) && x <= 85) { if (y > 89) { y = 89; } @@ -3132,7 +3136,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _15PB50[y] - _15PB50[x] ; lbe = _15PB50[y]; correctL = true; - } else if (( hue >= (_15PB50[x] + _3PB50[x]) / 2.0) && (hue < (_45PB50[x] + _3PB50[x]) / 2.0) && x <= 85) { + } else if ((hue >= (_15PB50[x] + _3PB50[x]) / 2.0) && (hue < (_45PB50[x] + _3PB50[x]) / 2.0) && x <= 85) { if (y > 89) { y = 89; } @@ -3140,7 +3144,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _3PB50[y] - _3PB50[x] ; lbe = _3PB50[y]; correctL = true; - } else if (( hue >= (_45PB50[x] + _3PB50[x]) / 2.0) && (hue < (_6PB50[x] + _45PB50[x]) / 2.0) && x <= 85) { + } else if ((hue >= (_45PB50[x] + _3PB50[x]) / 2.0) && (hue < (_6PB50[x] + _45PB50[x]) / 2.0) && x <= 85) { if (y > 89) { y = 89; } @@ -3148,7 +3152,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _45PB50[y] - _45PB50[x] ; lbe = _45PB50[y]; correctL = true; - } else if (( hue >= (_6PB50[x] + _45PB50[x]) / 2.0) && (hue < (_6PB50[x] + _75PB50[x]) / 2.0) && x <= 85) { + } else if ((hue >= (_6PB50[x] + _45PB50[x]) / 2.0) && (hue < (_6PB50[x] + _75PB50[x]) / 2.0) && x <= 85) { if (y > 89) { y = 89; } @@ -3156,7 +3160,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _6PB50[y] - _6PB50[x] ; lbe = _6PB50[y]; correctL = true; - } else if (( hue >= (_6PB50[x] + _75PB50[x]) / 2.0) && (hue < (_9PB50[x] + _75PB50[x]) / 2.0) && x <= 85) { + } else if ((hue >= (_6PB50[x] + _75PB50[x]) / 2.0) && (hue < (_9PB50[x] + _75PB50[x]) / 2.0) && x <= 85) { if (y > 89) { y = 89; } @@ -3164,7 +3168,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _75PB50[y] - _75PB50[x] ; lbe = _75PB50[y]; correctL = true; - } else if (( hue >= (_9PB50[x] + _75PB50[x]) / 2.0) && (hue < (_9PB50[x] + _10PB50[x]) / 2.0) && x <= 85) { + } else if ((hue >= (_9PB50[x] + _75PB50[x]) / 2.0) && (hue < (_9PB50[x] + _10PB50[x]) / 2.0) && x <= 85) { if (y > 89) { y = 89; } @@ -3172,7 +3176,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _9PB50[y] - _9PB50[x] ; lbe = _9PB50[y]; correctL = true; - } else if (( hue >= (_10PB50[x] + _9PB50[x]) / 2.0) && (hue < (_1P50[x] + _10PB50[x]) / 2.0) && x <= 85) { + } else if ((hue >= (_10PB50[x] + _9PB50[x]) / 2.0) && (hue < (_1P50[x] + _10PB50[x]) / 2.0) && x <= 85) { if (y > 89) { y = 89; } @@ -3180,7 +3184,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _10PB50[y] - _10PB50[x] ; lbe = _10PB50[y]; correctL = true; - } else if (( hue >= (_10PB50[x] + _1P50[x]) / 2.0) && (hue < (_1P50[x] + _4P50[x]) / 2.0) && x <= 85) { + } else if ((hue >= (_10PB50[x] + _1P50[x]) / 2.0) && (hue < (_1P50[x] + _4P50[x]) / 2.0) && x <= 85) { if (y > 89) { y = 89; } @@ -3188,7 +3192,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _1P50[y] - _1P50[x] ; lbe = _1P50[y]; correctL = true; - } else if (( hue >= (_1P50[x] + _4P50[x]) / 2.0) && (hue < (0.035 + _4P50[x]) / 2.0) && x <= 85) { + } else if ((hue >= (_1P50[x] + _4P50[x]) / 2.0) && (hue < (0.035 + _4P50[x]) / 2.0) && x <= 85) { if (y > 89) { y = 89; } @@ -3198,7 +3202,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correctL = true; } } else if (lum < 65.0) { - if ( (hue <= (_05PB60[x] + _15PB60[x]) / 2.0) && (hue > (_05PB60[x] + _10B60[x]) / 2.0) && x < 79 ) { + if ((hue <= (_05PB60[x] + _15PB60[x]) / 2.0) && (hue > (_05PB60[x] + _10B60[x]) / 2.0) && x < 79) { if (y > 79) { y = 79; } @@ -3206,7 +3210,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _05PB60[y] - _05PB60[x] ; lbe = _05PB60[y]; correctL = true; - } else if ( (hue <= (_05PB60[x] + _10B60[x]) / 2.0) && (hue > (_10B60[x] + _9B60[x]) / 2.0) && x < 79 ) { + } else if ((hue <= (_05PB60[x] + _10B60[x]) / 2.0) && (hue > (_10B60[x] + _9B60[x]) / 2.0) && x < 79) { if (y > 79) { y = 79; } @@ -3214,7 +3218,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _10B60[y] - _10B60[x] ; lbe = _10B60[y]; correctL = true; - } else if ( (hue <= (_10B60[x] + _9B60[x]) / 2.0) && (hue > (_9B60[x] + _7B60[x]) / 2.0) && x < 79 ) { + } else if ((hue <= (_10B60[x] + _9B60[x]) / 2.0) && (hue > (_9B60[x] + _7B60[x]) / 2.0) && x < 79) { if (y > 79) { y = 79; } @@ -3222,7 +3226,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _9B60[y] - _9B60[x] ; lbe = _9B60[y]; correctL = true; - } else if ( (hue <= (_9B60[x] + _7B60[x]) / 2.0) && (hue > (_5B60[x] + _7B60[x]) / 2.0) && x < 79 ) { + } else if ((hue <= (_9B60[x] + _7B60[x]) / 2.0) && (hue > (_5B60[x] + _7B60[x]) / 2.0) && x < 79) { if (y > 79) { y = 79; } @@ -3230,7 +3234,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _7B60[y] - _7B60[x] ; lbe = _7B60[y]; correctL = true; - } else if (( hue <= (_5B60[x] + _7B60[x]) / 2.0) && (hue > (_5B60[x] - 0.035)) && x < 79) { + } else if ((hue <= (_5B60[x] + _7B60[x]) / 2.0) && (hue > (_5B60[x] - 0.035)) && x < 79) { if (y > 79) { y = 79; // } @@ -3240,7 +3244,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correctL = true; } - else if ( (hue >= (_15PB60[x] - 0.035)) && (hue < (_15PB60[x] + _3PB60[x]) / 2.0) && x <= 85 ) { + else if ((hue >= (_15PB60[x] - 0.035)) && (hue < (_15PB60[x] + _3PB60[x]) / 2.0) && x <= 85) { if (y > 89) { y = 89; } @@ -3248,7 +3252,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _15PB60[y] - _15PB60[x] ; lbe = _15PB60[y]; correctL = true; - } else if (( hue >= (_15PB60[x] + _3PB60[x]) / 2.0) && (hue < (_45PB60[x] + _3PB60[x]) / 2.0) && x <= 85) { + } else if ((hue >= (_15PB60[x] + _3PB60[x]) / 2.0) && (hue < (_45PB60[x] + _3PB60[x]) / 2.0) && x <= 85) { if (y > 89) { y = 89; } @@ -3256,7 +3260,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _3PB60[y] - _3PB60[x] ; lbe = _3PB60[y]; correctL = true; - } else if (( hue >= (_45PB60[x] + _3PB60[x]) / 2.0) && (hue < (_6PB60[x] + _45PB60[x]) / 2.0) && x <= 85) { + } else if ((hue >= (_45PB60[x] + _3PB60[x]) / 2.0) && (hue < (_6PB60[x] + _45PB60[x]) / 2.0) && x <= 85) { if (y > 89) { y = 89; } @@ -3264,7 +3268,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _45PB60[y] - _45PB60[x] ; lbe = _45PB60[y]; correctL = true; - } else if (( hue >= (_6PB60[x] + _45PB60[x]) / 2.0) && (hue < (_6PB60[x] + _75PB60[x]) / 2.0) && x <= 85) { + } else if ((hue >= (_6PB60[x] + _45PB60[x]) / 2.0) && (hue < (_6PB60[x] + _75PB60[x]) / 2.0) && x <= 85) { if (y > 89) { y = 89; } @@ -3272,7 +3276,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _6PB60[y] - _6PB60[x] ; lbe = _6PB60[y]; correctL = true; - } else if (( hue >= (_6PB60[x] + _75PB60[x]) / 2.0) && (hue < (_9PB60[x] + _75PB60[x]) / 2.0) && x <= 85) { + } else if ((hue >= (_6PB60[x] + _75PB60[x]) / 2.0) && (hue < (_9PB60[x] + _75PB60[x]) / 2.0) && x <= 85) { if (y > 89) { y = 89; } @@ -3280,7 +3284,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _75PB60[y] - _75PB60[x] ; lbe = _75PB60[y]; correctL = true; - } else if (( hue >= (_9PB60[x] + _75PB60[x]) / 2.0) && (hue < (_9PB60[x] + _10PB60[x]) / 2.0) && x <= 85) { + } else if ((hue >= (_9PB60[x] + _75PB60[x]) / 2.0) && (hue < (_9PB60[x] + _10PB60[x]) / 2.0) && x <= 85) { if (y > 89) { y = 89; } @@ -3288,7 +3292,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _9PB60[y] - _9PB60[x] ; lbe = _9PB60[y]; correctL = true; - } else if (( hue >= (_10PB60[x] + _9PB60[x]) / 2.0) && (hue < (_1P60[x] + _10PB60[x]) / 2.0) && x <= 85) { + } else if ((hue >= (_10PB60[x] + _9PB60[x]) / 2.0) && (hue < (_1P60[x] + _10PB60[x]) / 2.0) && x <= 85) { if (y > 89) { y = 89; } @@ -3296,7 +3300,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _10PB60[y] - _10PB60[x] ; lbe = _10PB60[y]; correctL = true; - } else if (( hue >= (_10PB60[x] + _1P60[x]) / 2.0) && (hue < (_1P60[x] + _4P60[x]) / 2.0) && x <= 85) { + } else if ((hue >= (_10PB60[x] + _1P60[x]) / 2.0) && (hue < (_1P60[x] + _4P60[x]) / 2.0) && x <= 85) { if (y > 89) { y = 89; } @@ -3304,7 +3308,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _1P60[y] - _1P60[x] ; lbe = _1P60[y]; correctL = true; - } else if (( hue >= (_1P60[x] + _4P60[x]) / 2.0) && (hue < (0.035 + _4P60[x]) / 2.0) && x <= 85) { + } else if ((hue >= (_1P60[x] + _4P60[x]) / 2.0) && (hue < (0.035 + _4P60[x]) / 2.0) && x <= 85) { if (y > 89) { y = 89; } @@ -3314,7 +3318,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correctL = true; } } else if (lum < 75.0) { - if ( (hue <= (_05PB70[x] + _15PB70[x]) / 2.0) && (hue > (_05PB70[x] + _10B70[x]) / 2.0) && x < 50 ) { + if ((hue <= (_05PB70[x] + _15PB70[x]) / 2.0) && (hue > (_05PB70[x] + _10B70[x]) / 2.0) && x < 50) { if (y > 49) { y = 49; } @@ -3322,7 +3326,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _05PB70[y] - _05PB70[x] ; lbe = _05PB70[y]; correctL = true; - } else if ( (hue <= (_05PB70[x] + _10B70[x]) / 2.0) && (hue > (_10B70[x] + _9B70[x]) / 2.0) && x < 50 ) { + } else if ((hue <= (_05PB70[x] + _10B70[x]) / 2.0) && (hue > (_10B70[x] + _9B70[x]) / 2.0) && x < 50) { if (y > 49) { y = 49; } @@ -3330,7 +3334,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _10B70[y] - _10B70[x] ; lbe = _10B70[y]; correctL = true; - } else if ( (hue <= (_10B70[x] + _9B70[x]) / 2.0) && (hue > (_9B70[x] + _7B70[x]) / 2.0) && x < 50 ) { + } else if ((hue <= (_10B70[x] + _9B70[x]) / 2.0) && (hue > (_9B70[x] + _7B70[x]) / 2.0) && x < 50) { if (y > 49) { y = 49; } @@ -3338,7 +3342,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _9B70[y] - _9B70[x] ; lbe = _9B70[y]; correctL = true; - } else if ( (hue <= (_9B70[x] + _7B70[x]) / 2.0) && (hue > (_5B70[x] + _7B70[x]) / 2.0) && x < 50 ) { + } else if ((hue <= (_9B70[x] + _7B70[x]) / 2.0) && (hue > (_5B70[x] + _7B70[x]) / 2.0) && x < 50) { if (y > 49) { y = 49; } @@ -3346,7 +3350,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _7B70[y] - _7B70[x] ; lbe = _7B70[y]; correctL = true; - } else if (( hue <= (_5B70[x] + _7B70[x]) / 2.0) && (hue > (_5B70[x] - 0.035)) && x < 50) { + } else if ((hue <= (_5B70[x] + _7B70[x]) / 2.0) && (hue > (_5B70[x] - 0.035)) && x < 50) { if (y > 49) { y = 49; // } @@ -3356,7 +3360,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correctL = true; } - else if ( (hue >= (_15PB70[x] - 0.035)) && (hue < (_15PB70[x] + _3PB70[x]) / 2.0) && x < 50 ) { + else if ((hue >= (_15PB70[x] - 0.035)) && (hue < (_15PB70[x] + _3PB70[x]) / 2.0) && x < 50) { if (y > 49) { y = 49; } @@ -3364,7 +3368,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _15PB70[y] - _15PB70[x] ; lbe = _15PB70[y]; correctL = true; - } else if (( hue >= (_45PB70[x] + _3PB70[x]) / 2.0) && (hue < (_6PB70[x] + _45PB70[x]) / 2.0) && x < 50) { + } else if ((hue >= (_45PB70[x] + _3PB70[x]) / 2.0) && (hue < (_6PB70[x] + _45PB70[x]) / 2.0) && x < 50) { if (y > 49) { y = 49; } @@ -3372,7 +3376,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _45PB70[y] - _45PB70[x] ; lbe = _45PB70[y]; correctL = true; - } else if (( hue >= (_6PB70[x] + _45PB70[x]) / 2.0) && (hue < (_6PB70[x] + _75PB70[x]) / 2.0) && x < 50) { + } else if ((hue >= (_6PB70[x] + _45PB70[x]) / 2.0) && (hue < (_6PB70[x] + _75PB70[x]) / 2.0) && x < 50) { if (y > 49) { y = 49; } @@ -3380,7 +3384,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _6PB70[y] - _6PB70[x] ; lbe = _6PB70[y]; correctL = true; - } else if (( hue >= (_6PB70[x] + _75PB70[x]) / 2.0) && (hue < (_9PB70[x] + _75PB70[x]) / 2.0) && x < 50) { + } else if ((hue >= (_6PB70[x] + _75PB70[x]) / 2.0) && (hue < (_9PB70[x] + _75PB70[x]) / 2.0) && x < 50) { if (y > 49) { y = 49; } @@ -3388,7 +3392,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _75PB70[y] - _75PB70[x] ; lbe = _75PB70[y]; correctL = true; - } else if (( hue >= (_9PB70[x] + _75PB70[x]) / 2.0) && (hue < (_9PB70[x] + 0.035)) && x < 50) { + } else if ((hue >= (_9PB70[x] + _75PB70[x]) / 2.0) && (hue < (_9PB70[x] + 0.035)) && x < 50) { if (y > 49) { y = 49; } @@ -3398,7 +3402,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correctL = true; } } else if (lum < 85.0) { - if ( (hue <= (_05PB80[x] + _15PB80[x]) / 2.0) && (hue > (_05PB80[x] + _10B80[x]) / 2.0) && x < 40 ) { + if ((hue <= (_05PB80[x] + _15PB80[x]) / 2.0) && (hue > (_05PB80[x] + _10B80[x]) / 2.0) && x < 40) { if (y > 39) { y = 39; } @@ -3406,7 +3410,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _05PB80[y] - _05PB80[x] ; lbe = _05PB80[y] ; correctL = true; - } else if ( (hue <= (_05PB80[x] + _10B80[x]) / 2.0) && (hue > (_10B80[x] + _9B80[x]) / 2.0) && x < 40 ) { + } else if ((hue <= (_05PB80[x] + _10B80[x]) / 2.0) && (hue > (_10B80[x] + _9B80[x]) / 2.0) && x < 40) { if (y > 39) { y = 39; } @@ -3414,7 +3418,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _10B80[y] - _10B80[x] ; lbe = _10B80[y]; correctL = true; - } else if ( (hue <= (_10B80[x] + _9B80[x]) / 2.0) && (hue > (_9B80[x] + _7B80[x]) / 2.0) && x < 40 ) { + } else if ((hue <= (_10B80[x] + _9B80[x]) / 2.0) && (hue > (_9B80[x] + _7B80[x]) / 2.0) && x < 40) { if (y > 39) { y = 39; } @@ -3422,7 +3426,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _9B80[y] - _9B80[x] ; lbe = _9B80[y]; correctL = true; - } else if ( (hue <= (_9B80[x] + _7B80[x]) / 2.0) && (hue > (_5B80[x] + _7B80[x]) / 2.0) && x < 50 ) { + } else if ((hue <= (_9B80[x] + _7B80[x]) / 2.0) && (hue > (_5B80[x] + _7B80[x]) / 2.0) && x < 50) { if (y > 49) { y = 49; } @@ -3430,7 +3434,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _7B80[y] - _7B80[x] ; lbe = _7B80[y]; correctL = true; - } else if (( hue <= (_5B80[x] + _7B80[x]) / 2.0) && (hue > (_5B80[x] - 0.035)) && x < 50) { + } else if ((hue <= (_5B80[x] + _7B80[x]) / 2.0) && (hue > (_5B80[x] - 0.035)) && x < 50) { if (y > 49) { y = 49; // } @@ -3440,7 +3444,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correctL = true; } - else if ( (hue >= (_15PB80[x] - 0.035)) && (hue < (_15PB80[x] + _3PB80[x]) / 2.0) && x < 50 ) { + else if ((hue >= (_15PB80[x] - 0.035)) && (hue < (_15PB80[x] + _3PB80[x]) / 2.0) && x < 50) { if (y > 49) { y = 49; } @@ -3448,7 +3452,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _15PB80[y] - _15PB80[x] ; lbe = _15PB80[y]; correctL = true; - } else if (( hue >= (_45PB80[x] + _3PB80[x]) / 2.0) && (hue < (_6PB80[x] + _45PB80[x]) / 2.0) && x < 50) { + } else if ((hue >= (_45PB80[x] + _3PB80[x]) / 2.0) && (hue < (_6PB80[x] + _45PB80[x]) / 2.0) && x < 50) { if (y > 49) { y = 49; } @@ -3456,7 +3460,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _45PB80[y] - _45PB80[x] ; lbe = _45PB80[y]; correctL = true; - } else if (( hue >= (_6PB80[x] + _45PB80[x]) / 2.0) && (hue < (_6PB80[x] + _75PB80[x]) / 2.0) && x < 50) { + } else if ((hue >= (_6PB80[x] + _45PB80[x]) / 2.0) && (hue < (_6PB80[x] + _75PB80[x]) / 2.0) && x < 50) { if (y > 49) { y = 49; } @@ -3464,7 +3468,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _6PB80[y] - _6PB80[x] ; lbe = _6PB80[y]; correctL = true; - } else if (( hue >= (_6PB80[x] + _75PB80[x]) / 2.0) && (hue < (_9PB80[x] + _75PB80[x]) / 2.0) && x < 50) { + } else if ((hue >= (_6PB80[x] + _75PB80[x]) / 2.0) && (hue < (_9PB80[x] + _75PB80[x]) / 2.0) && x < 50) { if (y > 49) { y = 49; } @@ -3472,7 +3476,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _75PB80[y] - _75PB80[x] ; lbe = _75PB80[y]; correctL = true; - } else if (( hue >= (_9PB80[x] + _75PB80[x]) / 2.0) && (hue < (_9PB80[x] + 0.035)) && x < 50) { + } else if ((hue >= (_9PB80[x] + _75PB80[x]) / 2.0) && (hue < (_9PB80[x] + 0.035)) && x < 50) { if (y > 49) { y = 49; } @@ -3490,7 +3494,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa else if (zone == 2) { if (lum > 15.0) { if (lum < 25.0) { - if ( (hue <= (_10YR20[x] + 0.035)) && (hue > (_10YR20[x] + _85YR20[x]) / 2.0) && x <= 45) { + if ((hue <= (_10YR20[x] + 0.035)) && (hue > (_10YR20[x] + _85YR20[x]) / 2.0) && x <= 45) { if (y > 49) { y = 49; } @@ -3498,7 +3502,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _10YR20[y] - _10YR20[x] ; lbe = _10YR20[y]; correctL = true; - } else if (( hue <= (_85YR20[x] + _10YR20[x]) / 2.0) && (hue > (_85YR20[x] + 0.035) && x <= 45)) { + } else if ((hue <= (_85YR20[x] + _10YR20[x]) / 2.0) && (hue > (_85YR20[x] + 0.035) && x <= 45)) { if (y > 49) { y = 49; } @@ -3508,7 +3512,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correctL = true; } } else if (lum < 35.0) { - if ( (hue <= (_10YR30[x] + 0.035)) && (hue > (_10YR30[x] + _85YR30[x]) / 2.0) && x < 85) { + if ((hue <= (_10YR30[x] + 0.035)) && (hue > (_10YR30[x] + _85YR30[x]) / 2.0) && x < 85) { if (y > 89) { y = 89; } @@ -3516,7 +3520,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _10YR30[y] - _10YR30[x] ; lbe = _10YR30[y]; correctL = true; - } else if ( (hue <= (_10YR30[x] + _85YR30[x]) / 2.0) && (hue > (_85YR30[x] + _7YR30[x]) / 2.0) && x < 85) { + } else if ((hue <= (_10YR30[x] + _85YR30[x]) / 2.0) && (hue > (_85YR30[x] + _7YR30[x]) / 2.0) && x < 85) { if (y > 89) { y = 89; } @@ -3524,7 +3528,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _85YR30[y] - _85YR30[x] ; lbe = _85YR30[y]; correctL = true; - } else if (( hue <= (_85YR30[x] + _7YR30[x]) / 2.0) && (hue > (_7YR30[x] + _55YR30[x]) / 2.0) && x < 85) { + } else if ((hue <= (_85YR30[x] + _7YR30[x]) / 2.0) && (hue > (_7YR30[x] + _55YR30[x]) / 2.0) && x < 85) { if (y > 89) { y = 89; } @@ -3532,7 +3536,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _7YR30[y] - _7YR30[x] ; lbe = _7YR30[y]; correctL = true; - } else if (( hue <= (_7YR30[x] + _55YR30[x]) / 2.0) && (hue > (_55YR30[x] + _4YR30[x]) / 2.0) && x < 85) { + } else if ((hue <= (_7YR30[x] + _55YR30[x]) / 2.0) && (hue > (_55YR30[x] + _4YR30[x]) / 2.0) && x < 85) { if (y > 89) { y = 89; } @@ -3540,7 +3544,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _55YR30[y] - _55YR30[x] ; lbe = _55YR30[y]; correctL = true; - } else if (( hue <= (_55YR30[x] + _4YR30[x]) / 2.0) && (hue > (_4YR30[x] + _25YR30[x]) / 2.0) && x < 85) { + } else if ((hue <= (_55YR30[x] + _4YR30[x]) / 2.0) && (hue > (_4YR30[x] + _25YR30[x]) / 2.0) && x < 85) { if (y > 89) { y = 89; } @@ -3548,7 +3552,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _4YR30[y] - _4YR30[x] ; lbe = _4YR30[y]; correctL = true; - } else if (( hue <= (_4YR30[x] + _25YR30[x]) / 2.0) && (hue > (_25YR30[x] + _10R30[x]) / 2.0) && x < 85) { + } else if ((hue <= (_4YR30[x] + _25YR30[x]) / 2.0) && (hue > (_25YR30[x] + _10R30[x]) / 2.0) && x < 85) { if (y > 89) { y = 89; } @@ -3556,7 +3560,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _25YR30[y] - _25YR30[x] ; lbe = _25YR30[y]; correctL = true; - } else if (( hue <= (_25YR30[x] + _10R30[x]) / 2.0) && (hue > (_10R30[x] + _9R30[x]) / 2.0) && x < 85) { + } else if ((hue <= (_25YR30[x] + _10R30[x]) / 2.0) && (hue > (_10R30[x] + _9R30[x]) / 2.0) && x < 85) { if (y > 89) { y = 89; } @@ -3564,7 +3568,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _10R30[y] - _10R30[x] ; lbe = _10R30[y]; correctL = true; - } else if (( hue <= (_10R30[x] + _9R30[x]) / 2.0) && (hue > (_9R30[x] + _7R30[x]) / 2.0) && x < 85) { + } else if ((hue <= (_10R30[x] + _9R30[x]) / 2.0) && (hue > (_9R30[x] + _7R30[x]) / 2.0) && x < 85) { if (y > 89) { y = 89; } @@ -3572,7 +3576,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _9R30[y] - _9R30[x] ; lbe = _9R30[y]; correctL = true; - } else if (( hue <= (_9R30[x] + _7R30[x]) / 2.0) && (hue > (_7R30[x] - 0.035)) && x < 85) { + } else if ((hue <= (_9R30[x] + _7R30[x]) / 2.0) && (hue > (_7R30[x] - 0.035)) && x < 85) { if (y > 89) { y = 89; } @@ -3582,7 +3586,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correctL = true; } } else if (lum < 45.0) { - if ( (hue <= (_10YR40[x] + 0.035)) && (hue > (_10YR40[x] + _85YR40[x]) / 2.0) && x < 85) { + if ((hue <= (_10YR40[x] + 0.035)) && (hue > (_10YR40[x] + _85YR40[x]) / 2.0) && x < 85) { if (y > 89) { y = 89; } @@ -3590,7 +3594,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _10YR40[y] - _10YR40[x] ; lbe = _10YR40[y]; correctL = true; - } else if ( (hue <= (_10YR40[x] + _85YR40[x]) / 2.0) && (hue > (_85YR40[x] + _7YR40[x]) / 2.0) && x < 85 ) { + } else if ((hue <= (_10YR40[x] + _85YR40[x]) / 2.0) && (hue > (_85YR40[x] + _7YR40[x]) / 2.0) && x < 85) { if (y > 89) { y = 89; } @@ -3598,7 +3602,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _85YR40[y] - _85YR40[x] ; lbe = _85YR40[y]; correctL = true; - } else if (( hue <= (_85YR40[x] + _7YR40[x]) / 2.0) && (hue > (_7YR40[x] + _55YR40[x]) / 2.0) && x < 85) { + } else if ((hue <= (_85YR40[x] + _7YR40[x]) / 2.0) && (hue > (_7YR40[x] + _55YR40[x]) / 2.0) && x < 85) { if (y > 89) { y = 89; } @@ -3606,7 +3610,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _7YR40[y] - _7YR40[x] ; lbe = _7YR40[y]; correctL = true; - } else if (( hue <= (_7YR40[x] + _55YR40[x]) / 2.0) && (hue > (_55YR40[x] + _4YR40[x]) / 2.0) && x < 85 ) { + } else if ((hue <= (_7YR40[x] + _55YR40[x]) / 2.0) && (hue > (_55YR40[x] + _4YR40[x]) / 2.0) && x < 85) { if (y > 89) { y = 89; } @@ -3614,7 +3618,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _55YR40[y] - _55YR40[x] ; lbe = _55YR40[y]; correctL = true; - } else if (( hue <= (_55YR40[x] + _4YR40[x]) / 2.0) && (hue > (_4YR40[x] + _25YR40[x]) / 2.0) && x < 85 ) { + } else if ((hue <= (_55YR40[x] + _4YR40[x]) / 2.0) && (hue > (_4YR40[x] + _25YR40[x]) / 2.0) && x < 85) { if (y > 89) { y = 89; } @@ -3622,7 +3626,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _4YR40[y] - _4YR40[x] ; lbe = _4YR40[y]; correctL = true; - } else if (( hue <= (_4YR40[x] + _25YR40[x]) / 2.0) && (hue > (_25YR40[x] + _10R40[x]) / 2.0) && x < 85) { + } else if ((hue <= (_4YR40[x] + _25YR40[x]) / 2.0) && (hue > (_25YR40[x] + _10R40[x]) / 2.0) && x < 85) { if (y > 89) { y = 89; } @@ -3630,7 +3634,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _25YR40[y] - _25YR40[x] ; lbe = _25YR40[y] ; correctL = true; - } else if (( hue <= (_25YR40[x] + _10R40[x]) / 2.0) && (hue > (_10R40[x] + _9R40[x]) / 2.0) && x < 85) { + } else if ((hue <= (_25YR40[x] + _10R40[x]) / 2.0) && (hue > (_10R40[x] + _9R40[x]) / 2.0) && x < 85) { if (y > 89) { y = 89; } @@ -3638,7 +3642,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _10R40[y] - _10R40[x] ; lbe = _10R40[y]; correctL = true; - } else if (( hue <= (_10R40[x] + _9R40[x]) / 2.0) && (hue > (_9R40[x] + _7R40[x]) / 2.0) && x < 85 ) { + } else if ((hue <= (_10R40[x] + _9R40[x]) / 2.0) && (hue > (_9R40[x] + _7R40[x]) / 2.0) && x < 85) { if (y > 89) { y = 89; } @@ -3646,7 +3650,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _9R40[y] - _9R40[x] ; lbe = _9R40[y]; correctL = true; - } else if (( hue <= (_9R40[x] + _7R40[x]) / 2.0) && (hue > (_7R40[x] - 0.035)) && x < 85 ) { + } else if ((hue <= (_9R40[x] + _7R40[x]) / 2.0) && (hue > (_7R40[x] - 0.035)) && x < 85) { if (y > 89) { y = 89; } @@ -3656,7 +3660,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correctL = true; } } else if (lum < 55.0) { - if ( (hue <= (_10YR50[x] + 0.035)) && (hue > (_10YR50[x] + _85YR50[x]) / 2.0) && x < 85) { + if ((hue <= (_10YR50[x] + 0.035)) && (hue > (_10YR50[x] + _85YR50[x]) / 2.0) && x < 85) { if (y > 89) { y = 89; } @@ -3664,7 +3668,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _10YR50[y] - _10YR50[x] ; lbe = _10YR50[y]; correctL = true; - } else if ( (hue <= (_10YR50[x] + _85YR50[x]) / 2.0) && (hue > (_85YR50[x] + _7YR50[x]) / 2.0) && x < 85 ) { + } else if ((hue <= (_10YR50[x] + _85YR50[x]) / 2.0) && (hue > (_85YR50[x] + _7YR50[x]) / 2.0) && x < 85) { if (y > 89) { y = 89; } @@ -3672,7 +3676,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _85YR50[y] - _85YR50[x] ; lbe = _85YR50[y]; correctL = true; - } else if (( hue <= (_85YR50[x] + _7YR50[x]) / 2.0) && (hue > (_7YR50[x] + _55YR50[x]) / 2.0) && x < 85) { + } else if ((hue <= (_85YR50[x] + _7YR50[x]) / 2.0) && (hue > (_7YR50[x] + _55YR50[x]) / 2.0) && x < 85) { if (y > 89) { y = 89; } @@ -3680,7 +3684,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _7YR50[y] - _7YR50[x] ; lbe = _7YR50[y]; correctL = true; - } else if (( hue <= (_7YR50[x] + _55YR50[x]) / 2.0) && (hue > (_55YR50[x] + _4YR50[x]) / 2.0) && x < 85) { + } else if ((hue <= (_7YR50[x] + _55YR50[x]) / 2.0) && (hue > (_55YR50[x] + _4YR50[x]) / 2.0) && x < 85) { if (y > 89) { y = 89; } @@ -3688,7 +3692,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _55YR50[y] - _55YR50[x] ; lbe = _55YR50[y]; correctL = true; - } else if (( hue <= (_55YR50[x] + _4YR50[x]) / 2.0) && (hue > (_4YR50[x] + _25YR50[x]) / 2.0) && x < 85) { + } else if ((hue <= (_55YR50[x] + _4YR50[x]) / 2.0) && (hue > (_4YR50[x] + _25YR50[x]) / 2.0) && x < 85) { if (y > 89) { y = 89; } @@ -3696,7 +3700,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _4YR50[y] - _4YR50[x] ; lbe = _4YR50[y]; correctL = true; - } else if (( hue <= (_4YR50[x] + _25YR50[x]) / 2.0) && (hue > (_25YR50[x] + _10R50[x]) / 2.0) && x < 85) { + } else if ((hue <= (_4YR50[x] + _25YR50[x]) / 2.0) && (hue > (_25YR50[x] + _10R50[x]) / 2.0) && x < 85) { if (y > 89) { y = 89; } @@ -3704,7 +3708,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _25YR50[y] - _25YR50[x] ; lbe = _25YR50[y]; correctL = true; - } else if (( hue <= (_25YR50[x] + _10R50[x]) / 2.0) && (hue > (_10R50[x] + _9R50[x]) / 2.0) && x < 85) { + } else if ((hue <= (_25YR50[x] + _10R50[x]) / 2.0) && (hue > (_10R50[x] + _9R50[x]) / 2.0) && x < 85) { if (y > 89) { y = 89; } @@ -3712,7 +3716,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _10R50[y] - _10R50[x] ; lbe = _10R50[y]; correctL = true; - } else if (( hue <= (_10R50[x] + _9R50[x]) / 2.0) && (hue > (_9R50[x] + _7R50[x]) / 2.0) && x < 85) { + } else if ((hue <= (_10R50[x] + _9R50[x]) / 2.0) && (hue > (_9R50[x] + _7R50[x]) / 2.0) && x < 85) { if (y > 89) { y = 89; } @@ -3720,7 +3724,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _9R50[y] - _9R50[x] ; lbe = _9R50[y]; correctL = true; - } else if (( hue <= (_9R50[x] + _7R50[x]) / 2.0) && (hue > (_7R50[x] - 0.035)) && x < 85) { + } else if ((hue <= (_9R50[x] + _7R50[x]) / 2.0) && (hue > (_7R50[x] - 0.035)) && x < 85) { if (y > 89) { y = 89; } @@ -3730,29 +3734,29 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correctL = true; } } else if (lum < 65.0) { - if ( (hue <= (_10YR60[x] + 0.035)) && (hue > (_10YR60[x] + _85YR60[x]) / 2.0)) { + if ((hue <= (_10YR60[x] + 0.035)) && (hue > (_10YR60[x] + _85YR60[x]) / 2.0)) { ; correction = _10YR60[y] - _10YR60[x] ; lbe = _10YR60[y]; correctL = true; - } else if ( (hue <= (_10YR60[x] + _85YR60[x]) / 2.0) && (hue > (_85YR60[x] + _7YR60[x]) / 2.0) ) { + } else if ((hue <= (_10YR60[x] + _85YR60[x]) / 2.0) && (hue > (_85YR60[x] + _7YR60[x]) / 2.0)) { ; correction = _85YR60[y] - _85YR60[x] ; lbe = _85YR60[y]; correctL = true; - } else if (( hue <= (_85YR60[x] + _7YR60[x]) / 2.0) && (hue > (_7YR60[x] + _55YR60[x]) / 2.0)) { + } else if ((hue <= (_85YR60[x] + _7YR60[x]) / 2.0) && (hue > (_7YR60[x] + _55YR60[x]) / 2.0)) { correction = _7YR60[y] - _7YR60[x] ; lbe = _7YR60[y]; correctL = true; - } else if (( hue <= (_7YR60[x] + _55YR60[x]) / 2.0) && (hue > (_55YR60[x] + _4YR60[x]) / 2.0)) { + } else if ((hue <= (_7YR60[x] + _55YR60[x]) / 2.0) && (hue > (_55YR60[x] + _4YR60[x]) / 2.0)) { correction = _55YR60[y] - _55YR60[x] ; lbe = _55YR60[y]; correctL = true; - } else if (( hue <= (_55YR60[x] + _4YR60[x]) / 2.0) && (hue > (_4YR60[x] + _25YR60[x]) / 2.0)) { + } else if ((hue <= (_55YR60[x] + _4YR60[x]) / 2.0) && (hue > (_4YR60[x] + _25YR60[x]) / 2.0)) { correction = _4YR60[y] - _4YR60[x] ; lbe = _4YR60[y]; correctL = true; - } else if (( hue <= (_4YR60[x] + _25YR60[x]) / 2.0) && (hue > (_25YR60[x] + _10R60[x]) / 2.0) && x < 85) { + } else if ((hue <= (_4YR60[x] + _25YR60[x]) / 2.0) && (hue > (_25YR60[x] + _10R60[x]) / 2.0) && x < 85) { if (y > 89) { y = 89; } @@ -3760,7 +3764,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _25YR60[y] - _25YR60[x] ; lbe = _25YR60[y]; correctL = true; - } else if (( hue <= (_25YR60[x] + _10R60[x]) / 2.0) && (hue > (_10R60[x] + _9R60[x]) / 2.0) && x < 85) { + } else if ((hue <= (_25YR60[x] + _10R60[x]) / 2.0) && (hue > (_10R60[x] + _9R60[x]) / 2.0) && x < 85) { if (y > 89) { y = 89; } @@ -3768,7 +3772,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _10R60[y] - _10R60[x] ; lbe = _10R60[y]; correctL = true; - } else if (( hue <= (_10R60[x] + _9R60[x]) / 2.0) && (hue > (_9R60[x] + _7R60[x]) / 2.0) && x < 85) { + } else if ((hue <= (_10R60[x] + _9R60[x]) / 2.0) && (hue > (_9R60[x] + _7R60[x]) / 2.0) && x < 85) { if (y > 89) { y = 89; } @@ -3776,7 +3780,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _9R60[y] - _9R60[x] ; lbe = _9R60[y]; correctL = true; - } else if (( hue <= (_9R60[x] + _7R60[x]) / 2.0) && (hue > (_7R60[x] - 0.035)) && x < 85) { + } else if ((hue <= (_9R60[x] + _7R60[x]) / 2.0) && (hue > (_7R60[x] - 0.035)) && x < 85) { if (y > 89) { y = 89; } @@ -3786,29 +3790,29 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correctL = true; } } else if (lum < 75.0) { - if ( (hue <= (_10YR70[x] + 0.035)) && (hue > (_10YR70[x] + _85YR70[x]) / 2.0)) { + if ((hue <= (_10YR70[x] + 0.035)) && (hue > (_10YR70[x] + _85YR70[x]) / 2.0)) { correction = _10YR70[y] - _10YR70[x] ; lbe = _10YR70[y]; correctL = true; - } else if ( (hue <= (_10YR70[x] + _85YR70[x]) / 2.0) && (hue > (_85YR70[x] + _7YR70[x]) / 2.0)) { + } else if ((hue <= (_10YR70[x] + _85YR70[x]) / 2.0) && (hue > (_85YR70[x] + _7YR70[x]) / 2.0)) { correction = _85YR70[y] - _85YR70[x] ; lbe = _85YR70[y]; correctL = true; } - if (( hue <= (_85YR70[x] + _7YR70[x]) / 2.0) && (hue > (_7YR70[x] + _55YR70[x]) / 2.0)) { + if ((hue <= (_85YR70[x] + _7YR70[x]) / 2.0) && (hue > (_7YR70[x] + _55YR70[x]) / 2.0)) { correction = _7YR70[y] - _7YR70[x] ; lbe = _7YR70[y]; correctL = true; - } else if (( hue <= (_7YR70[x] + _55YR70[x]) / 2.0) && (hue > (_55YR70[x] + _4YR70[x]) / 2.0)) { + } else if ((hue <= (_7YR70[x] + _55YR70[x]) / 2.0) && (hue > (_55YR70[x] + _4YR70[x]) / 2.0)) { correction = _55YR70[y] - _55YR70[x] ; lbe = _55YR70[y]; correctL = true; - } else if (( hue <= (_55YR70[x] + _4YR70[x]) / 2.0) && (hue > (_4YR70[x] + _25YR70[x]) / 2.0)) { + } else if ((hue <= (_55YR70[x] + _4YR70[x]) / 2.0) && (hue > (_4YR70[x] + _25YR70[x]) / 2.0)) { correction = _4YR70[y] - _4YR70[x] ; lbe = _4YR70[y]; correctL = true; - } else if (( hue <= (_4YR70[x] + _25YR70[x]) / 2.0) && (hue > (_25YR70[x] + _10R70[x]) / 2.0) && x < 85) { + } else if ((hue <= (_4YR70[x] + _25YR70[x]) / 2.0) && (hue > (_25YR70[x] + _10R70[x]) / 2.0) && x < 85) { if (y > 89) { y = 89; } @@ -3816,7 +3820,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _25YR70[y] - _25YR70[x] ; lbe = _25YR70[y]; correctL = true; - } else if (( hue <= (_25YR70[x] + _10R70[x]) / 2.0) && (hue > (_10R70[x] + _9R70[x]) / 2.0) && x < 85) { + } else if ((hue <= (_25YR70[x] + _10R70[x]) / 2.0) && (hue > (_10R70[x] + _9R70[x]) / 2.0) && x < 85) { if (y > 89) { y = 89; } @@ -3824,7 +3828,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _10R70[y] - _10R70[x] ; lbe = _10R70[y]; correctL = true; - } else if (( hue <= (_10R70[x] + _9R70[x]) / 2.0) && (hue > (_9R70[x] + _7R70[x]) / 2.0) && x < 85) { + } else if ((hue <= (_10R70[x] + _9R70[x]) / 2.0) && (hue > (_9R70[x] + _7R70[x]) / 2.0) && x < 85) { if (y > 89) { y = 89; } @@ -3832,7 +3836,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _9R70[y] - _9R70[x] ; lbe = _9R70[y] ; correctL = true; - } else if (( hue <= (_9R70[x] + _7R70[x]) / 2.0) && (hue > (_7R70[x] - 0.035)) && x < 85) { + } else if ((hue <= (_9R70[x] + _7R70[x]) / 2.0) && (hue > (_7R70[x] - 0.035)) && x < 85) { if (y > 89) { y = 89; } @@ -3842,14 +3846,14 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correctL = true; } } else if (lum < 85.0) { - if ( (hue <= (_10YR80[x] + 0.035)) && (hue > (_10YR80[x] + _85YR80[x]) / 2.0)) { + if ((hue <= (_10YR80[x] + 0.035)) && (hue > (_10YR80[x] + _85YR80[x]) / 2.0)) { correction = _10YR80[y] - _10YR80[x] ; lbe = _10YR80[y]; correctL = true; - } else if ( (hue <= (_10YR80[x] + _85YR80[x]) / 2.0) && (hue > (_85YR80[x] + _7YR80[x]) / 2.0)) { + } else if ((hue <= (_10YR80[x] + _85YR80[x]) / 2.0) && (hue > (_85YR80[x] + _7YR80[x]) / 2.0)) { correction = _85YR80[y] - _85YR80[x] ; lbe = _85YR80[y]; - } else if (( hue <= (_85YR80[x] + _7YR80[x]) / 2.0) && (hue > (_7YR80[x] + _55YR80[x]) / 2.0) && x < 85) { + } else if ((hue <= (_85YR80[x] + _7YR80[x]) / 2.0) && (hue > (_7YR80[x] + _55YR80[x]) / 2.0) && x < 85) { if (y > 89) { y = 89; } @@ -3857,11 +3861,11 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _7YR80[y] - _7YR80[x] ; lbe = _7YR80[y]; correctL = true; - } else if (( hue <= (_7YR80[x] + _55YR80[x]) / 2.0) && (hue > (_55YR80[x] + _4YR80[x]) / 2.0) && x < 45) { + } else if ((hue <= (_7YR80[x] + _55YR80[x]) / 2.0) && (hue > (_55YR80[x] + _4YR80[x]) / 2.0) && x < 45) { correction = _55YR80[y] - _55YR80[x] ; lbe = _55YR80[y]; correctL = true; - } else if (( hue <= (_55YR80[x] + _4YR80[x]) / 2.0) && (hue > (_4YR80[x] - 0.035) && x < 45)) { + } else if ((hue <= (_55YR80[x] + _4YR80[x]) / 2.0) && (hue > (_4YR80[x] - 0.035) && x < 45)) { if (y > 49) { y = 49; } @@ -3871,7 +3875,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correctL = true; } } else if (lum < 95.0) { - if ( (hue <= (_10YR90[x] + 0.035)) && (hue > (_10YR90[x] - 0.035) && x < 85)) { + if ((hue <= (_10YR90[x] + 0.035)) && (hue > (_10YR90[x] - 0.035) && x < 85)) { if (y > 89) { y = 89; } @@ -3879,7 +3883,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _10YR90[y] - _10YR90[x] ; lbe = _10YR90[y]; correctL = true; - } else if ( hue <= (_85YR90[x] + 0.035) && hue > (_85YR90[x] - 0.035) && x < 85) { + } else if (hue <= (_85YR90[x] + 0.035) && hue > (_85YR90[x] - 0.035) && x < 85) { if (y > 89) { y = 89; } @@ -3887,7 +3891,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _85YR90[y] - _85YR90[x] ; lbe = _85YR90[y]; correctL = true; - } else if (( hue <= (_55YR90[x] + 0.035) && (hue > (_55YR90[x] - 0.035) && x < 45))) { + } else if ((hue <= (_55YR90[x] + 0.035) && (hue > (_55YR90[x] - 0.035) && x < 45))) { if (y > 49) { y = 49; } @@ -3905,23 +3909,23 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa else if (zone == 3) { if (lum >= 25.0) { if (lum < 35.0) { - if ( (hue <= (_7G30[x] + 0.035)) && (hue > (_7G30[x] + _5G30[x]) / 2.0) ) { + if ((hue <= (_7G30[x] + 0.035)) && (hue > (_7G30[x] + _5G30[x]) / 2.0)) { correction = _7G30[y] - _7G30[x] ; lbe = _7G30[y]; correctL = true; - } else if ( (hue <= (_7G30[x] + _5G30[x]) / 2.0) && (hue > (_5G30[x] + _25G30[x]) / 2.0)) { + } else if ((hue <= (_7G30[x] + _5G30[x]) / 2.0) && (hue > (_5G30[x] + _25G30[x]) / 2.0)) { correction = _5G30[y] - _5G30[x] ; lbe = _5G30[y]; correctL = true; - } else if (( hue <= (_25G30[x] + _5G30[x]) / 2.0) && (hue > (_25G30[x] + _1G30[x]) / 2.0)) { + } else if ((hue <= (_25G30[x] + _5G30[x]) / 2.0) && (hue > (_25G30[x] + _1G30[x]) / 2.0)) { correction = _25G30[y] - _25G30[x] ; lbe = _25G30[y]; correctL = true; - } else if (( hue <= (_1G30[x] + _25G30[x]) / 2.0) && (hue > (_1G30[x] + _10GY30[x]) / 2.0)) { + } else if ((hue <= (_1G30[x] + _25G30[x]) / 2.0) && (hue > (_1G30[x] + _10GY30[x]) / 2.0)) { correction = _1G30[y] - _1G30[x] ; lbe = _1G30[y]; correctL = true; - } else if (( hue <= (_1G30[x] + _10GY30[x]) / 2.0) && (hue > (_10GY30[x] + _75GY30[x]) / 2.0) && x < 85) { + } else if ((hue <= (_1G30[x] + _10GY30[x]) / 2.0) && (hue > (_10GY30[x] + _75GY30[x]) / 2.0) && x < 85) { if (y > 89) { y = 89; } @@ -3929,7 +3933,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _10GY30[y] - _10GY30[x] ; lbe = _10GY30[y]; correctL = true; - } else if (( hue <= (_10GY30[x] + _75GY30[x]) / 2.0) && (hue > (_75GY30[x] + _5GY30[x]) / 2.0) && x < 85) { + } else if ((hue <= (_10GY30[x] + _75GY30[x]) / 2.0) && (hue > (_75GY30[x] + _5GY30[x]) / 2.0) && x < 85) { if (y > 89) { y = 89; } @@ -3937,7 +3941,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _75GY30[y] - _75GY30[x] ; lbe = _75GY30[y]; correctL = true; - } else if (( hue <= (_5GY30[x] + _75GY30[x]) / 2.0) && (hue > (_5GY30[x] - 0.035)) && x < 85) { + } else if ((hue <= (_5GY30[x] + _75GY30[x]) / 2.0) && (hue > (_5GY30[x] - 0.035)) && x < 85) { if (y > 89) { y = 89; } @@ -3947,23 +3951,23 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correctL = true; } } else if (lum < 45.0) { - if ( (hue <= (_7G40[x] + 0.035)) && (hue > (_7G40[x] + _5G40[x]) / 2.0) ) { + if ((hue <= (_7G40[x] + 0.035)) && (hue > (_7G40[x] + _5G40[x]) / 2.0)) { correction = _7G40[y] - _7G40[x] ; lbe = _7G40[y]; correctL = true; - } else if ( (hue <= (_7G40[x] + _5G40[x]) / 2.0) && (hue > (_5G40[x] + _25G40[x]) / 2.0)) { + } else if ((hue <= (_7G40[x] + _5G40[x]) / 2.0) && (hue > (_5G40[x] + _25G40[x]) / 2.0)) { correction = _5G40[y] - _5G40[x] ; lbe = _5G40[y]; correctL = true; - } else if (( hue <= (_25G40[x] + _5G40[x]) / 2.0) && (hue > (_25G40[x] + _1G40[x]) / 2.0)) { + } else if ((hue <= (_25G40[x] + _5G40[x]) / 2.0) && (hue > (_25G40[x] + _1G40[x]) / 2.0)) { correction = _25G40[y] - _25G40[x] ; lbe = _25G40[y]; correctL = true; - } else if (( hue <= (_1G40[x] + _25G40[x]) / 2.0) && (hue > (_1G40[x] + _10GY40[x]) / 2.0)) { + } else if ((hue <= (_1G40[x] + _25G40[x]) / 2.0) && (hue > (_1G40[x] + _10GY40[x]) / 2.0)) { correction = _1G40[y] - _1G40[x] ; lbe = _1G40[y]; correctL = true; - } else if (( hue <= (_1G40[x] + _10GY40[x]) / 2.0) && (hue > (_10GY40[x] + _75GY40[x]) / 2.0) && x < 85) { + } else if ((hue <= (_1G40[x] + _10GY40[x]) / 2.0) && (hue > (_10GY40[x] + _75GY40[x]) / 2.0) && x < 85) { if (y > 89) { y = 89; } @@ -3971,7 +3975,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _10GY40[y] - _10GY40[x] ; lbe = _10GY40[y]; correctL = true; - } else if (( hue <= (_10GY40[x] + _75GY40[x]) / 2.0) && (hue > (_75GY40[x] + _5GY40[x]) / 2.0) && x < 85) { + } else if ((hue <= (_10GY40[x] + _75GY40[x]) / 2.0) && (hue > (_75GY40[x] + _5GY40[x]) / 2.0) && x < 85) { if (y > 89) { y = 89; } @@ -3979,7 +3983,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _75GY40[y] - _75GY40[x] ; lbe = _75GY40[y]; correctL = true; - } else if (( hue <= (_5GY40[x] + _75GY40[x]) / 2.0) && (hue > (_5GY40[x] - 0.035)) && x < 85) { + } else if ((hue <= (_5GY40[x] + _75GY40[x]) / 2.0) && (hue > (_5GY40[x] - 0.035)) && x < 85) { if (y > 89) { y = 89; // } @@ -3989,121 +3993,121 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correctL = true; } } else if (lum < 55.0) { - if ( (hue <= (_7G50[x] + 0.035)) && (hue > (_7G50[x] + _5G50[x]) / 2.0) ) { + if ((hue <= (_7G50[x] + 0.035)) && (hue > (_7G50[x] + _5G50[x]) / 2.0)) { correction = _7G50[y] - _7G50[x] ; lbe = _7G50[y]; correctL = true; - } else if ( (hue <= (_7G50[x] + _5G50[x]) / 2.0) && (hue > (_5G50[x] + _25G50[x]) / 2.0)) { + } else if ((hue <= (_7G50[x] + _5G50[x]) / 2.0) && (hue > (_5G50[x] + _25G50[x]) / 2.0)) { correction = _5G50[y] - _5G50[x] ; lbe = _5G50[y]; correctL = true; - } else if (( hue <= (_25G50[x] + _5G50[x]) / 2.0) && (hue > (_25G50[x] + _1G50[x]) / 2.0)) { + } else if ((hue <= (_25G50[x] + _5G50[x]) / 2.0) && (hue > (_25G50[x] + _1G50[x]) / 2.0)) { correction = _25G50[y] - _25G50[x] ; lbe = _25G50[y]; correctL = true; - } else if (( hue <= (_1G50[x] + _25G50[x]) / 2.0) && (hue > (_1G50[x] + _10GY50[x]) / 2.0)) { + } else if ((hue <= (_1G50[x] + _25G50[x]) / 2.0) && (hue > (_1G50[x] + _10GY50[x]) / 2.0)) { correction = _1G50[y] - _1G50[x] ; lbe = _1G50[y]; correctL = true; - } else if (( hue <= (_1G50[x] + _10GY50[x]) / 2.0) && (hue > (_10GY50[x] + _75GY50[x]) / 2.0)) { + } else if ((hue <= (_1G50[x] + _10GY50[x]) / 2.0) && (hue > (_10GY50[x] + _75GY50[x]) / 2.0)) { correction = _10GY50[y] - _10GY50[x] ; lbe = _10GY50[y]; correctL = true; - } else if (( hue <= (_10GY50[x] + _75GY50[x]) / 2.0) && (hue > (_75GY50[x] + _5GY50[x]) / 2.0)) { + } else if ((hue <= (_10GY50[x] + _75GY50[x]) / 2.0) && (hue > (_75GY50[x] + _5GY50[x]) / 2.0)) { correction = _75GY50[y] - _75GY50[x] ; lbe = _75GY50[y]; correctL = true; - } else if (( hue <= (_5GY50[x] + _75GY50[x]) / 2.0) && (hue > (_5GY50[x] - 0.035))) { + } else if ((hue <= (_5GY50[x] + _75GY50[x]) / 2.0) && (hue > (_5GY50[x] - 0.035))) { correction = _5GY50[y] - _5GY50[x] ; lbe = _5GY50[y]; correctL = true; } } else if (lum < 65.0) { - if ( (hue <= (_7G60[x] + 0.035)) && (hue > (_7G60[x] + _5G60[x]) / 2.0) ) { + if ((hue <= (_7G60[x] + 0.035)) && (hue > (_7G60[x] + _5G60[x]) / 2.0)) { correction = _7G60[y] - _7G60[x] ; lbe = _7G60[y]; correctL = true; - } else if ( (hue <= (_7G60[x] + _5G60[x]) / 2.0) && (hue > (_5G60[x] + _25G60[x]) / 2.0)) { + } else if ((hue <= (_7G60[x] + _5G60[x]) / 2.0) && (hue > (_5G60[x] + _25G60[x]) / 2.0)) { correction = _5G60[y] - _5G60[x] ; lbe = _5G60[y]; correctL = true; - } else if (( hue <= (_25G60[x] + _5G60[x]) / 2.0) && (hue > (_25G60[x] + _1G60[x]) / 2.0)) { + } else if ((hue <= (_25G60[x] + _5G60[x]) / 2.0) && (hue > (_25G60[x] + _1G60[x]) / 2.0)) { correction = _25G60[y] - _25G60[x] ; lbe = _25G60[y]; correctL = true; - } else if (( hue <= (_1G60[x] + _25G60[x]) / 2.0) && (hue > (_1G60[x] + _10GY60[x]) / 2.0)) { + } else if ((hue <= (_1G60[x] + _25G60[x]) / 2.0) && (hue > (_1G60[x] + _10GY60[x]) / 2.0)) { correction = _1G60[y] - _1G60[x] ; lbe = _1G60[y]; correctL = true; - } else if (( hue <= (_1G60[x] + _10GY60[x]) / 2.0) && (hue > (_10GY60[x] + _75GY60[x]) / 2.0)) { + } else if ((hue <= (_1G60[x] + _10GY60[x]) / 2.0) && (hue > (_10GY60[x] + _75GY60[x]) / 2.0)) { correction = _10GY60[y] - _10GY60[x] ; lbe = _10GY60[y]; correctL = true; - } else if (( hue <= (_10GY60[x] + _75GY60[x]) / 2.0) && (hue > (_75GY60[x] + _5GY60[x]) / 2.0)) { + } else if ((hue <= (_10GY60[x] + _75GY60[x]) / 2.0) && (hue > (_75GY60[x] + _5GY60[x]) / 2.0)) { correction = _75GY60[y] - _75GY60[x] ; lbe = _75GY60[y] ; correctL = true; - } else if (( hue <= (_5GY60[x] + _75GY60[x]) / 2.0) && (hue > (_5GY60[x] - 0.035))) { + } else if ((hue <= (_5GY60[x] + _75GY60[x]) / 2.0) && (hue > (_5GY60[x] - 0.035))) { correction = _5GY60[y] - _5GY60[x] ; lbe = _5GY60[y]; correctL = true; } } else if (lum < 75.0) { - if ( (hue <= (_7G70[x] + 0.035)) && (hue > (_7G70[x] + _5G70[x]) / 2.0) ) { + if ((hue <= (_7G70[x] + 0.035)) && (hue > (_7G70[x] + _5G70[x]) / 2.0)) { correction = _7G70[y] - _7G70[x] ; lbe = _7G70[y]; correctL = true; - } else if ( (hue <= (_7G70[x] + _5G70[x]) / 2.0) && (hue > (_5G70[x] + _25G70[x]) / 2.0)) { + } else if ((hue <= (_7G70[x] + _5G70[x]) / 2.0) && (hue > (_5G70[x] + _25G70[x]) / 2.0)) { correction = _5G70[y] - _5G70[x] ; lbe = _5G70[y]; correctL = true; - } else if (( hue <= (_25G70[x] + _5G70[x]) / 2.0) && (hue > (_25G70[x] + _1G70[x]) / 2.0)) { + } else if ((hue <= (_25G70[x] + _5G70[x]) / 2.0) && (hue > (_25G70[x] + _1G70[x]) / 2.0)) { correction = _25G70[y] - _25G70[x] ; lbe = _25G70[y]; correctL = true; - } else if (( hue <= (_1G70[x] + _25G70[x]) / 2.0) && (hue > (_1G70[x] + _10GY70[x]) / 2.0)) { + } else if ((hue <= (_1G70[x] + _25G70[x]) / 2.0) && (hue > (_1G70[x] + _10GY70[x]) / 2.0)) { correction = _1G70[y] - _1G70[x] ; lbe = _1G70[y] ; correctL = true; - } else if (( hue <= (_1G70[x] + _10GY70[x]) / 2.0) && (hue > (_10GY70[x] + _75GY70[x]) / 2.0)) { + } else if ((hue <= (_1G70[x] + _10GY70[x]) / 2.0) && (hue > (_10GY70[x] + _75GY70[x]) / 2.0)) { correction = _10GY70[y] - _10GY70[x] ; lbe = _10GY70[y]; correctL = true; - } else if (( hue <= (_10GY70[x] + _75GY70[x]) / 2.0) && (hue > (_75GY70[x] + _5GY70[x]) / 2.0)) { + } else if ((hue <= (_10GY70[x] + _75GY70[x]) / 2.0) && (hue > (_75GY70[x] + _5GY70[x]) / 2.0)) { correction = _75GY70[y] - _75GY70[x] ; lbe = _75GY70[y]; correctL = true; - } else if (( hue <= (_5GY70[x] + _75GY70[x]) / 2.0) && (hue > (_5GY70[x] - 0.035))) { + } else if ((hue <= (_5GY70[x] + _75GY70[x]) / 2.0) && (hue > (_5GY70[x] - 0.035))) { correction = _5GY70[y] - _5GY70[x] ; lbe = _5GY70[y]; correctL = true; } } else if (lum < 85.0) { - if ( (hue <= (_7G80[x] + 0.035)) && (hue > (_7G80[x] + _5G80[x]) / 2.0) ) { + if ((hue <= (_7G80[x] + 0.035)) && (hue > (_7G80[x] + _5G80[x]) / 2.0)) { correction = _7G80[y] - _7G80[x] ; lbe = _7G80[y]; correctL = true; - } else if ( (hue <= (_7G80[x] + _5G80[x]) / 2.0) && (hue > (_5G80[x] + _25G80[x]) / 2.0)) { + } else if ((hue <= (_7G80[x] + _5G80[x]) / 2.0) && (hue > (_5G80[x] + _25G80[x]) / 2.0)) { correction = _5G80[y] - _5G80[x] ; lbe = _5G80[y]; correctL = true; - } else if (( hue <= (_25G80[x] + _5G80[x]) / 2.0) && (hue > (_25G80[x] + _1G80[x]) / 2.0)) { + } else if ((hue <= (_25G80[x] + _5G80[x]) / 2.0) && (hue > (_25G80[x] + _1G80[x]) / 2.0)) { correction = _25G80[y] - _25G80[x] ; lbe = _25G80[y]; correctL = true; - } else if (( hue <= (_1G80[x] + _25G80[x]) / 2.0) && (hue > (_1G80[x] + _10GY80[x]) / 2.0)) { + } else if ((hue <= (_1G80[x] + _25G80[x]) / 2.0) && (hue > (_1G80[x] + _10GY80[x]) / 2.0)) { correction = _1G80[y] - _1G80[x] ; lbe = _1G80[y]; correctL = true; - } else if (( hue <= (_1G80[x] + _10GY80[x]) / 2.0) && (hue > (_10GY80[x] + _75GY80[x]) / 2.0)) { + } else if ((hue <= (_1G80[x] + _10GY80[x]) / 2.0) && (hue > (_10GY80[x] + _75GY80[x]) / 2.0)) { correction = _10GY80[y] - _10GY80[x] ; lbe = _10GY80[y]; correctL = true; - } else if (( hue <= (_10GY80[x] + _75GY80[x]) / 2.0) && (hue > (_75GY80[x] + _5GY80[x]) / 2.0)) { + } else if ((hue <= (_10GY80[x] + _75GY80[x]) / 2.0) && (hue > (_75GY80[x] + _5GY80[x]) / 2.0)) { correction = _75GY80[y] - _75GY80[x] ; lbe = _75GY80[y]; correctL = true; - } else if (( hue <= (_5GY80[x] + _75GY80[x]) / 2.0) && (hue > (_5GY80[x] - 0.035))) { + } else if ((hue <= (_5GY80[x] + _75GY80[x]) / 2.0) && (hue > (_5GY80[x] - 0.035))) { correction = _5GY80[y] - _5GY80[x] ; lbe = _5GY80[y]; correctL = true; @@ -4117,7 +4121,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa else if (zone == 4) { if (lum > 5.0) { if (lum < 15.0) { - if ( (hue <= (_5R10[x] + 0.035)) && (hue > (_5R10[x] - 0.043)) && x < 45) { + if ((hue <= (_5R10[x] + 0.035)) && (hue > (_5R10[x] - 0.043)) && x < 45) { if (y > 44) { y = 44; } @@ -4125,7 +4129,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _5R10[y] - _5R10[x] ; lbe = _5R10[y]; correctL = true; - } else if ( (hue <= (_25R10[x] + 0.043)) && (hue > (_25R10[x] + _10RP10[x]) / 2.0) && x < 45 ) { + } else if ((hue <= (_25R10[x] + 0.043)) && (hue > (_25R10[x] + _10RP10[x]) / 2.0) && x < 45) { if (y > 44) { y = 44; } @@ -4133,7 +4137,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _25R10[y] - _25R10[x] ; lbe = _25R10[y]; correctL = true; - } else if ( (hue <= (_25R10[x] + _10RP10[x]) / 2.0) && (hue > (_10RP10[x] - 0.035) ) && x < 45) { + } else if ((hue <= (_25R10[x] + _10RP10[x]) / 2.0) && (hue > (_10RP10[x] - 0.035)) && x < 45) { if (y > 44) { y = 44; } @@ -4143,7 +4147,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correctL = true; } } else if (lum < 25.0) { - if ( (hue <= (_5R20[x] + 0.035)) && (hue > (_5R20[x] + _25R20[x]) / 2.0) && x < 70 ) { + if ((hue <= (_5R20[x] + 0.035)) && (hue > (_5R20[x] + _25R20[x]) / 2.0) && x < 70) { if (y > 70) { y = 70; } @@ -4151,7 +4155,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _5R20[y] - _5R20[x] ; lbe = _5R20[y]; correctL = true; - } else if ( (hue <= (_5R20[x] + _25R20[x]) / 2.0) && (hue > (_10RP20[x] + _25R20[x]) / 2.0) && x < 70) { + } else if ((hue <= (_5R20[x] + _25R20[x]) / 2.0) && (hue > (_10RP20[x] + _25R20[x]) / 2.0) && x < 70) { if (y > 70) { y = 70; } @@ -4159,7 +4163,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _25R20[y] - _25R20[x] ; lbe = _25R20[y]; correctL = true; - } else if (( hue <= (_10RP20[x] + _25R20[x]) / 2.0) && (hue > (_10RP20[x] - 0.035)) && x < 70) { + } else if ((hue <= (_10RP20[x] + _25R20[x]) / 2.0) && (hue > (_10RP20[x] - 0.035)) && x < 70) { if (y > 70) { y = 70; } @@ -4169,7 +4173,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correctL = true; } } else if (lum < 35.0) { - if ( (hue <= (_5R30[x] + 0.035)) && (hue > (_5R30[x] + _25R30[x]) / 2.0) && x < 85 ) { + if ((hue <= (_5R30[x] + 0.035)) && (hue > (_5R30[x] + _25R30[x]) / 2.0) && x < 85) { if (y > 85) { y = 85; } @@ -4177,7 +4181,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _5R30[y] - _5R30[x] ; lbe = _5R30[y]; correctL = true; - } else if ( (hue <= (_5R30[x] + _25R30[x]) / 2.0) && (hue > (_10RP30[x] + _25R30[x]) / 2.0) && x < 85) { + } else if ((hue <= (_5R30[x] + _25R30[x]) / 2.0) && (hue > (_10RP30[x] + _25R30[x]) / 2.0) && x < 85) { if (y > 85) { y = 85; } @@ -4185,7 +4189,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa correction = _25R30[y] - _25R30[x] ; lbe = _25R30[y]; correctL = true; - } else if (( hue <= (_10RP30[x] + _25R30[x]) / 2.0) && (hue > (_10RP30[x] - 0.035)) && x < 85) { + } else if ((hue <= (_10RP30[x] + _25R30[x]) / 2.0) && (hue > (_10RP30[x] - 0.035)) && x < 85) { if (y > 85) { y = 85; } @@ -4211,7 +4215,7 @@ void Color::MunsellLch (float lum, float hue, float chrom, float memChprov, floa * pay attention to white balance, and do not change hue and saturation, upstream of the modification * */ -void Color::SkinSat (float lum, float hue, float chrom, float &satreduc) +void Color::SkinSat(float lum, float hue, float chrom, float &satreduc) { // to be adapted...by tests @@ -4239,49 +4243,49 @@ void Color::SkinSat (float lum, float hue, float chrom, float &satreduc) } else if (lum >= 70.f) { if ((hue > 0.4f && hue < (1.04f + H8)) && (chrom > 8.f && chrom < (35.f + C8))) { satreduc = reduction; - } else if ((hue > (0.02f + H11) && hue < 1.5f) && (chrom > 7.0f && chrom < (48.f + C9) )) { + } else if ((hue > (0.02f + H11) && hue < 1.5f) && (chrom > 7.0f && chrom < (48.f + C9))) { satreduc = extendedreduction; - } else if ((hue > (0.02f + H11) && hue < 1.65f) && (chrom > 7.f && chrom < (55.f + C9) )) { + } else if ((hue > (0.02f + H11) && hue < 1.65f) && (chrom > 7.f && chrom < (55.f + C9))) { satreduc = extendedreduction2; } } else if (lum >= 52.f) { if ((hue > 0.3f && hue < (1.27f + H7)) && (chrom > 11.f && chrom < (35.f + C7))) { satreduc = reduction; - } else if ((hue > (0.02f + H11) && hue < 1.5f) && (chrom > 7.0f && chrom < (48.f + C9) )) { + } else if ((hue > (0.02f + H11) && hue < 1.5f) && (chrom > 7.0f && chrom < (48.f + C9))) { satreduc = extendedreduction; - } else if ((hue > (0.02f + H11) && hue < 1.65f) && (chrom > 7.f && chrom < (55.f + C9) )) { + } else if ((hue > (0.02f + H11) && hue < 1.65f) && (chrom > 7.f && chrom < (55.f + C9))) { satreduc = extendedreduction2; } } else if (lum >= 35.f) { if ((hue > 0.3f && hue < (1.25f + H4)) && (chrom > 13.f && chrom < (37.f + C4))) { satreduc = reduction; - } else if ((hue > (0.02f + H11) && hue < 1.5f) && (chrom > 7.0f && chrom < (48.f + C9) )) { + } else if ((hue > (0.02f + H11) && hue < 1.5f) && (chrom > 7.0f && chrom < (48.f + C9))) { satreduc = extendedreduction; - } else if ((hue > (0.02f + H11) && hue < 1.65f) && (chrom > 7.f && chrom < (55.f + C9) )) { + } else if ((hue > (0.02f + H11) && hue < 1.65f) && (chrom > 7.f && chrom < (55.f + C9))) { satreduc = extendedreduction2; } } else if (lum >= 20.f) { - if ((hue > 0.3f && hue < (1.2f + H3)) && (chrom > 7.f && chrom < (35.f + C3) )) { + if ((hue > 0.3f && hue < (1.2f + H3)) && (chrom > 7.f && chrom < (35.f + C3))) { satreduc = reduction; - } else if ((hue > (0.02f + H11) && hue < 1.5f) && (chrom > 7.0f && chrom < (48.f + C9) )) { + } else if ((hue > (0.02f + H11) && hue < 1.5f) && (chrom > 7.0f && chrom < (48.f + C9))) { satreduc = extendedreduction; - } else if ((hue > (0.02f + H11) && hue < 1.65f) && (chrom > 7.f && chrom < (55.f + C9) )) { + } else if ((hue > (0.02f + H11) && hue < 1.65f) && (chrom > 7.f && chrom < (55.f + C9))) { satreduc = extendedreduction2; } } else if (lum > 10.f) { if ((hue > (0.f + H10) && hue < (0.95f + H2)) && (chrom > 8.f && chrom < (23.f + C2))) { satreduc = reduction; - } else if ((hue > (0.02f + H11) && hue < 1.f) && (chrom > 7.f && chrom < (35.f + C1) )) { + } else if ((hue > (0.02f + H11) && hue < 1.f) && (chrom > 7.f && chrom < (35.f + C1))) { satreduc = extendedreduction; - } else if ((hue > (0.02f + H11) && hue < 1.6f) && (chrom > 7.f && chrom < (45.f + C1) )) { + } else if ((hue > (0.02f + H11) && hue < 1.6f) && (chrom > 7.f && chrom < (45.f + C1))) { satreduc = extendedreduction2; } } else { if ((hue > (0.02f + H10) && hue < (0.9f + H1)) && (chrom > 8.f && chrom < (23.f + C1))) { satreduc = reduction; // no data : extrapolate - } else if ((hue > (0.02f + H11) && hue < 1.f) && (chrom > 7.f && chrom < (35.f + C1) )) { + } else if ((hue > (0.02f + H11) && hue < 1.f) && (chrom > 7.f && chrom < (35.f + C1))) { satreduc = extendedreduction; - } else if ((hue > (0.02f + H11) && hue < 1.6f) && (chrom > 7.f && chrom < (45.f + C1) )) { + } else if ((hue > (0.02f + H11) && hue < 1.6f) && (chrom > 7.f && chrom < (45.f + C1))) { satreduc = extendedreduction2; } @@ -4302,7 +4306,7 @@ void Color::SkinSat (float lum, float hue, float chrom, float &satreduc) * errors due to a different illuminant "Daylight" than "C" are low, about 10%. For example, a theoretical correction of 0.1 radian will be made with a real correction of 0.09 or 0.11 depending on the color illuminant D50 * errors due to the use of a very different illuminant "C", for example illuminant "A" (tungsten) are higher, about 20%. Theoretical correction of 0.52 radians will be made with a real correction of 0.42 */ -void Color::initMunsell () +void Color::initMunsell() { #ifdef _DEBUG MyTime t1e, t2e; @@ -4314,7 +4318,7 @@ void Color::initMunsell () const int maxInd3 = 50; //blue for sky - _5B40 (maxInd2); + _5B40(maxInd2); _5B40.clear(); for (int i = 0; i < maxInd2; i++) { @@ -4326,7 +4330,7 @@ void Color::initMunsell () } //printf("5B %1.2f %1.2f\n",_5B40[44],_5B40[89]); - _5B50 (maxInd2); + _5B50(maxInd2); _5B50.clear(); for (int i = 0; i < maxInd2; i++) { @@ -4338,7 +4342,7 @@ void Color::initMunsell () } //printf("5B %1.2f %1.2f\n",_5B50[44],_5B50[89]); - _5B60 (maxInd2); + _5B60(maxInd2); _5B60.clear(); for (int i = 0; i < maxInd2; i++) { @@ -4350,7 +4354,7 @@ void Color::initMunsell () } //printf("5B %1.2f %1.2f\n",_5B60[44],_5B60[89]); - _5B70 (maxInd2); + _5B70(maxInd2); _5B70.clear(); for (int i = 0; i < maxInd2; i++) { @@ -4362,7 +4366,7 @@ void Color::initMunsell () } //printf("5B %1.2f %1.2f\n",_5B70[44],_5B70[89]); - _5B80 (maxInd3); + _5B80(maxInd3); _5B80.clear(); for (int i = 0; i < maxInd3; i++) { @@ -4373,7 +4377,7 @@ void Color::initMunsell () //printf("5B %1.2f\n",_5B80[49]); - _7B40 (maxInd2); + _7B40(maxInd2); _7B40.clear(); for (int i = 0; i < maxInd2; i++) { @@ -4385,7 +4389,7 @@ void Color::initMunsell () } //printf("7B %1.2f %1.2f\n",_7B40[44],_7B40[89]); - _7B50 (maxInd2); + _7B50(maxInd2); _7B50.clear(); for (int i = 0; i < maxInd2; i++) { @@ -4397,7 +4401,7 @@ void Color::initMunsell () } //printf("7B %1.2f %1.2f\n",_7B50[44],_7B50[79]); - _7B60 (maxInd2); + _7B60(maxInd2); _7B60.clear(); for (int i = 0; i < maxInd2; i++) { @@ -4409,7 +4413,7 @@ void Color::initMunsell () } //printf("7B %1.2f %1.2f\n",_7B60[44],_7B60[79]); - _7B70 (maxInd2); + _7B70(maxInd2); _7B70.clear(); for (int i = 0; i < maxInd2; i++) { @@ -4421,7 +4425,7 @@ void Color::initMunsell () } //printf("7B %1.2f %1.2f\n",_7B70[44],_7B70[64]); - _7B80 (maxInd3); + _7B80(maxInd3); _7B80.clear(); for (int i = 0; i < maxInd3; i++) { @@ -4432,7 +4436,7 @@ void Color::initMunsell () //printf("5B %1.2f\n",_7B80[49]); - _9B40 (maxInd2); + _9B40(maxInd2); _9B40.clear(); for (int i = 0; i < maxInd2; i++) { @@ -4444,7 +4448,7 @@ void Color::initMunsell () } //printf("9B %1.2f %1.2f\n",_9B40[44],_9B40[69]); - _9B50 (maxInd2); + _9B50(maxInd2); _9B50.clear(); for (int i = 0; i < maxInd2; i++) { @@ -4456,7 +4460,7 @@ void Color::initMunsell () } //printf("9B %1.2f %1.2f\n",_9B50[44],_9B50[77]); - _9B60 (maxInd2); + _9B60(maxInd2); _9B60.clear(); for (int i = 0; i < maxInd2; i++) { @@ -4468,7 +4472,7 @@ void Color::initMunsell () } //printf("9B %1.2f %1.2f\n",_9B60[44],_9B60[79]); - _9B70 (maxInd2); + _9B70(maxInd2); _9B70.clear(); for (int i = 0; i < maxInd2; i++) { @@ -4480,7 +4484,7 @@ void Color::initMunsell () } //printf("9B %1.2f %1.2f\n",_9B70[44],_9B70[54]); - _9B80 (maxInd3); + _9B80(maxInd3); _9B80.clear(); for (int i = 0; i < maxInd3; i++) { @@ -4491,7 +4495,7 @@ void Color::initMunsell () //printf("9B %1.2f\n",_9B80[49]); - _10B40 (maxInd2); + _10B40(maxInd2); _10B40.clear(); for (int i = 0; i < maxInd2; i++) { @@ -4503,7 +4507,7 @@ void Color::initMunsell () } //printf("10B %1.2f %1.2f\n",_10B40[44],_10B40[76]); - _10B50 (maxInd2); + _10B50(maxInd2); _10B50.clear(); for (int i = 0; i < maxInd2; i++) { @@ -4515,7 +4519,7 @@ void Color::initMunsell () } //printf("10B %1.2f %1.2f\n",_10B50[44],_10B50[85]); - _10B60 (maxInd2); + _10B60(maxInd2); _10B60.clear(); for (int i = 0; i < maxInd2; i++) { @@ -4527,7 +4531,7 @@ void Color::initMunsell () } //printf("10B %1.2f %1.2f\n",_10B60[44],_10B60[70]); - _10B70 (maxInd3); + _10B70(maxInd3); _10B70.clear(); for (int i = 0; i < maxInd3; i++) { @@ -4537,7 +4541,7 @@ void Color::initMunsell () } //printf("10B %1.2f\n",_10B70[49]); - _10B80 (maxInd3); + _10B80(maxInd3); _10B80.clear(); for (int i = 0; i < maxInd3; i++) { @@ -4548,7 +4552,7 @@ void Color::initMunsell () //printf("10B %1.2f\n",_10B80[39]); - _05PB40 (maxInd2); + _05PB40(maxInd2); _05PB40.clear(); for (int i = 0; i < maxInd2; i++) { @@ -4560,7 +4564,7 @@ void Color::initMunsell () } //printf("05PB %1.2f %1.2f\n",_05PB40[44],_05PB40[74]); - _05PB50 (maxInd2); + _05PB50(maxInd2); _05PB50.clear(); for (int i = 0; i < maxInd2; i++) { @@ -4572,7 +4576,7 @@ void Color::initMunsell () } //printf("05PB %1.2f %1.2f\n",_05PB50[44],_05PB50[85]); - _05PB60 (maxInd2); + _05PB60(maxInd2); _05PB60.clear(); for (int i = 0; i < maxInd2; i++) { @@ -4584,7 +4588,7 @@ void Color::initMunsell () } //printf("05PB %1.2f %1.2f\n",_05PB60[44],_05PB60[70]); - _05PB70 (maxInd2); + _05PB70(maxInd2); _05PB70.clear(); for (int i = 0; i < maxInd2; i++) { @@ -4596,7 +4600,7 @@ void Color::initMunsell () } //printf("05PB %1.2f %1.2f\n",_05PB70[44],_05PB70[54]); - _05PB80 (maxInd3); + _05PB80(maxInd3); _05PB80.clear(); for (int i = 0; i < maxInd3; i++) { @@ -4614,7 +4618,7 @@ void Color::initMunsell () //maximum deviation 75PB //15PB - _15PB10 (maxInd3); + _15PB10(maxInd3); _15PB10.clear(); for (int i = 0; i < maxInd3; i++) { @@ -4624,7 +4628,7 @@ void Color::initMunsell () } //printf("15 %1.2f\n",_15PB10[49]); - _15PB20 (maxInd2); + _15PB20(maxInd2); _15PB20.clear(); for (int i = 0; i < maxInd2; i++) { @@ -4637,7 +4641,7 @@ void Color::initMunsell () //printf("15 %1.2f %1.2f\n",_15PB20[44],_15PB20[89]); - _15PB30 (maxInd2); + _15PB30(maxInd2); _15PB30.clear(); for (int i = 0; i < maxInd2; i++) { @@ -4650,7 +4654,7 @@ void Color::initMunsell () //printf("15 %1.2f %1.2f\n",_15PB30[44],_15PB30[89]); - _15PB40 (maxInd2); + _15PB40(maxInd2); _15PB40.clear(); for (int i = 0; i < maxInd2; i++) { @@ -4663,7 +4667,7 @@ void Color::initMunsell () //printf("15 %1.2f %1.2f\n",_15PB40[44],_15PB40[89]); - _15PB50 (maxInd2); + _15PB50(maxInd2); _15PB50.clear(); for (int i = 0; i < maxInd2; i++) { @@ -4676,7 +4680,7 @@ void Color::initMunsell () //printf("15 %1.2f %1.2f\n",_15PB50[44],_15PB50[89]); - _15PB60 (maxInd2); + _15PB60(maxInd2); _15PB60.clear(); for (int i = 0; i < maxInd2; i++) { @@ -4688,7 +4692,7 @@ void Color::initMunsell () } //printf("15 %1.2f %1.2f\n",_15PB60[44],_15PB60[89]); - _15PB70 (maxInd3); + _15PB70(maxInd3); _15PB70.clear(); for (int i = 0; i < maxInd3; i++) { @@ -4698,7 +4702,7 @@ void Color::initMunsell () } // printf("15 %1.2f\n",_15PB70[49]); - _15PB80 (maxInd3); + _15PB80(maxInd3); _15PB80.clear(); for (int i = 0; i < maxInd3; i++) { @@ -4710,7 +4714,7 @@ void Color::initMunsell () //printf("15 %1.2f %1.2f\n",_15PB80[38], _15PB80[49]); //3PB - _3PB10 (maxInd2); + _3PB10(maxInd2); _3PB10.clear(); for (int i = 0; i < maxInd2; i++) { @@ -4723,7 +4727,7 @@ void Color::initMunsell () //printf("30 %1.2f %1.2f\n",_3PB10[44],_3PB10[89]); - _3PB20 (maxInd2); + _3PB20(maxInd2); _3PB20.clear(); for (int i = 0; i < maxInd2; i++) { @@ -4736,7 +4740,7 @@ void Color::initMunsell () //printf("30 %1.2f %1.2f\n",_3PB20[44],_3PB20[89]); - _3PB30 (maxInd2); + _3PB30(maxInd2); _3PB30.clear(); for (int i = 0; i < maxInd2; i++) { @@ -4749,7 +4753,7 @@ void Color::initMunsell () //printf("30 %1.2f %1.2f\n",_3PB30[44],_3PB30[89]); - _3PB40 (maxInd2); + _3PB40(maxInd2); _3PB40.clear(); for (int i = 0; i < maxInd2; i++) { @@ -4762,7 +4766,7 @@ void Color::initMunsell () //printf("30 %1.2f %1.2f\n",_3PB40[44],_3PB40[89]); - _3PB50 (maxInd2); + _3PB50(maxInd2); _3PB50.clear(); for (int i = 0; i < maxInd2; i++) { @@ -4775,7 +4779,7 @@ void Color::initMunsell () //printf("30 %1.2f %1.2f\n",_3PB50[44],_3PB50[89]); - _3PB60 (maxInd2); + _3PB60(maxInd2); _3PB60.clear(); for (int i = 0; i < maxInd2; i++) { @@ -4787,7 +4791,7 @@ void Color::initMunsell () } //printf("30 %1.2f %1.2f\n",_3PB60[44],_3PB60[89]); - _3PB70 (maxInd3); + _3PB70(maxInd3); _3PB70.clear(); for (int i = 0; i < maxInd3; i++) { @@ -4797,7 +4801,7 @@ void Color::initMunsell () } //printf("30 %1.2f\n",_3PB70[49]); - _3PB80 (maxInd3); + _3PB80(maxInd3); _3PB80.clear(); for (int i = 0; i < maxInd3; i++) { @@ -4809,7 +4813,7 @@ void Color::initMunsell () //printf("30 %1.2f %1.2f\n",_3PB80[38], _3PB80[49]); //45PB - _45PB10 (maxInd2); + _45PB10(maxInd2); _45PB10.clear(); for (int i = 0; i < maxInd2; i++) { @@ -4822,7 +4826,7 @@ void Color::initMunsell () //printf("45 %1.2f %1.2f\n",_45PB10[44],_45PB10[89]); - _45PB20 (maxInd2); + _45PB20(maxInd2); _45PB20.clear(); for (int i = 0; i < maxInd2; i++) { @@ -4835,7 +4839,7 @@ void Color::initMunsell () //printf("45 %1.2f %1.2f\n",_45PB20[44],_45PB20[89]); - _45PB30 (maxInd2); + _45PB30(maxInd2); _45PB30.clear(); for (int i = 0; i < maxInd2; i++) { @@ -4848,7 +4852,7 @@ void Color::initMunsell () //printf("45 %1.2f %1.2f\n",_45PB30[44],_45PB30[89]); - _45PB40 (maxInd2); + _45PB40(maxInd2); _45PB40.clear(); for (int i = 0; i < maxInd2; i++) { @@ -4861,7 +4865,7 @@ void Color::initMunsell () //printf("45 %1.2f %1.2f\n",_45PB40[44],_45PB40[89]); - _45PB50 (maxInd2); + _45PB50(maxInd2); _45PB50.clear(); for (int i = 0; i < maxInd2; i++) { @@ -4874,7 +4878,7 @@ void Color::initMunsell () //printf("45 %1.2f %1.2f\n",_45PB50[44],_45PB50[89]); - _45PB60 (maxInd2); + _45PB60(maxInd2); _45PB60.clear(); for (int i = 0; i < maxInd2; i++) { @@ -4886,7 +4890,7 @@ void Color::initMunsell () } //printf("45 %1.2f %1.2f\n",_45PB60[44],_45PB60[89]); - _45PB70 (maxInd3); + _45PB70(maxInd3); _45PB70.clear(); for (int i = 0; i < maxInd3; i++) { @@ -4896,7 +4900,7 @@ void Color::initMunsell () } //printf("45 %1.2f\n",_45PB70[49]); - _45PB80 (maxInd3); + _45PB80(maxInd3); _45PB80.clear(); for (int i = 0; i < maxInd3; i++) { @@ -4908,7 +4912,7 @@ void Color::initMunsell () //printf("45 %1.2f %1.2f\n",_45PB80[38], _45PB80[49]); //_6PB - _6PB10 (maxInd); + _6PB10(maxInd); _6PB10.clear(); for (int i = 0; i < maxInd; i++) { //i = chromaticity 0==>140 @@ -4923,7 +4927,7 @@ void Color::initMunsell () //printf("60 %1.2f %1.2f %1.2f\n",_6PB10[44],_6PB10[84],_6PB10[139]); - _6PB20 (maxInd); + _6PB20(maxInd); _6PB20.clear(); for (int i = 0; i < maxInd; i++) { //i = chromaticity 0==>140 @@ -4938,7 +4942,7 @@ void Color::initMunsell () //printf("60 %1.2f %1.2f %1.2f\n",_6PB20[44],_6PB20[84],_6PB20[139]); - _6PB30 (maxInd); + _6PB30(maxInd); _6PB30.clear(); for (int i = 0; i < maxInd; i++) { //i = chromaticity 0==>140 @@ -4953,7 +4957,7 @@ void Color::initMunsell () //printf("60 %1.2f %1.2f %1.2f\n",_6PB30[44],_6PB30[84],_6PB30[139]); - _6PB40 (maxInd); + _6PB40(maxInd); _6PB40.clear(); for (int i = 0; i < maxInd; i++) { //i = chromaticity 0==>140 @@ -4968,7 +4972,7 @@ void Color::initMunsell () //printf("60 %1.2f %1.2f %1.2f\n",_6PB40[44],_6PB40[84],_6PB40[139]); - _6PB50 (maxInd2); //limits -1.3 -1.11 + _6PB50(maxInd2); //limits -1.3 -1.11 _6PB50.clear(); for (int i = 0; i < maxInd2; i++) { @@ -4981,7 +4985,7 @@ void Color::initMunsell () //printf("60 %1.2f %1.2f \n",_6PB50[44],_6PB50[89]); - _6PB60 (maxInd2); //limits -1.3 -1.11 + _6PB60(maxInd2); //limits -1.3 -1.11 _6PB60.clear(); for (int i = 0; i < maxInd2; i++) { @@ -4993,7 +4997,7 @@ void Color::initMunsell () } //printf("60 %1.2f %1.2f\n",_6PB60[44],_6PB60[89]); - _6PB70 (maxInd3); + _6PB70(maxInd3); _6PB70.clear(); for (int i = 0; i < maxInd3; i++) { @@ -5003,7 +5007,7 @@ void Color::initMunsell () } //printf("6 %1.2f\n",_6PB70[49]); - _6PB80 (maxInd3); + _6PB80(maxInd3); _6PB80.clear(); for (int i = 0; i < maxInd3; i++) { @@ -5016,7 +5020,7 @@ void Color::initMunsell () //_75PB : notation Munsell for maximum deviation blue purple - _75PB10 (maxInd); //limits hue -1.23 -0.71 _75PBx x=Luminance eg_75PB10 for L >5 and L<=15 + _75PB10(maxInd); //limits hue -1.23 -0.71 _75PBx x=Luminance eg_75PB10 for L >5 and L<=15 _75PB10.clear(); for (int i = 0; i < maxInd; i++) { //i = chromaticity 0==>140 @@ -5031,7 +5035,7 @@ void Color::initMunsell () //printf("75 %1.2f %1.2f %1.2f\n",_75PB10[44],_75PB10[84],_75PB10[139]); - _75PB20 (maxInd); //limits -1.24 -0.79 for L>15 <=25 + _75PB20(maxInd); //limits -1.24 -0.79 for L>15 <=25 _75PB20.clear(); for (int i = 0; i < maxInd; i++) { @@ -5046,7 +5050,7 @@ void Color::initMunsell () //printf("75 %1.2f %1.2f %1.2f\n",_75PB20[44],_75PB20[84],_75PB20[139]); - _75PB30 (maxInd); //limits -1.25 -0.85 + _75PB30(maxInd); //limits -1.25 -0.85 _75PB30.clear(); for (int i = 0; i < maxInd; i++) { @@ -5061,7 +5065,7 @@ void Color::initMunsell () //printf("75 %1.2f %1.2f %1.2f\n",_75PB30[44],_75PB30[84],_75PB30[139]); - _75PB40 (maxInd); //limits -1.27 -0.92 + _75PB40(maxInd); //limits -1.27 -0.92 _75PB40.clear(); for (int i = 0; i < maxInd; i++) { @@ -5076,7 +5080,7 @@ void Color::initMunsell () //printf("75 %1.2f %1.2f %1.2f\n",_75PB40[44],_75PB40[84],_75PB40[139]); - _75PB50 (maxInd2); //limits -1.3 -1.11 + _75PB50(maxInd2); //limits -1.3 -1.11 _75PB50.clear(); for (int i = 0; i < maxInd2; i++) { @@ -5089,7 +5093,7 @@ void Color::initMunsell () //printf("75 %1.2f %1.2f\n",_75PB50[44],_75PB50[89]); - _75PB60 (maxInd2); + _75PB60(maxInd2); _75PB60.clear(); for (int i = 0; i < maxInd2; i++) { //limits -1.32 -1.17 @@ -5102,7 +5106,7 @@ void Color::initMunsell () //printf("75 %1.2f %1.2f \n",_75PB60[44],_75PB60[89]); - _75PB70 (maxInd3); + _75PB70(maxInd3); _75PB70.clear(); for (int i = 0; i < maxInd3; i++) { //limits -1.34 -1.27 @@ -5111,7 +5115,7 @@ void Color::initMunsell () } } - _75PB80 (maxInd3); + _75PB80(maxInd3); _75PB80.clear(); for (int i = 0; i < maxInd3; i++) { //limits -1.35 -1.29 @@ -5121,7 +5125,7 @@ void Color::initMunsell () } - _9PB10 (maxInd); + _9PB10(maxInd); _9PB10.clear(); for (int i = 0; i < maxInd; i++) { //i = chromaticity 0==>140 @@ -5136,7 +5140,7 @@ void Color::initMunsell () //printf("90 %1.2f %1.2f %1.2f\n",_9PB10[44],_9PB10[84],_9PB10[139]); - _9PB20 (maxInd); + _9PB20(maxInd); _9PB20.clear(); for (int i = 0; i < maxInd; i++) { //i = chromaticity 0==>140 @@ -5151,7 +5155,7 @@ void Color::initMunsell () //printf("90 %1.2f %1.2f %1.2f\n",_9PB20[44],_9PB20[84],_9PB20[139]); - _9PB30 (maxInd); + _9PB30(maxInd); _9PB30.clear(); for (int i = 0; i < maxInd; i++) { //i = chromaticity 0==>140 @@ -5166,7 +5170,7 @@ void Color::initMunsell () //printf("90 %1.2f %1.2f %1.2f\n",_9PB30[44],_9PB30[84],_9PB30[139]); - _9PB40 (maxInd); + _9PB40(maxInd); _9PB40.clear(); for (int i = 0; i < maxInd; i++) { //i = chromaticity 0==>140 @@ -5181,7 +5185,7 @@ void Color::initMunsell () //printf("90 %1.2f %1.2f %1.2f\n",_9PB40[44],_9PB40[84],_9PB40[139]); - _9PB50 (maxInd2); + _9PB50(maxInd2); _9PB50.clear(); for (int i = 0; i < maxInd2; i++) { @@ -5194,7 +5198,7 @@ void Color::initMunsell () //printf("90 %1.2f %1.2f \n",_9PB50[44],_9PB50[84]); - _9PB60 (maxInd2); + _9PB60(maxInd2); _9PB60.clear(); for (int i = 0; i < maxInd2; i++) { @@ -5206,7 +5210,7 @@ void Color::initMunsell () } //printf("90 %1.2f %1.2f \n",_9PB60[44],_9PB60[89]); - _9PB70 (maxInd3); + _9PB70(maxInd3); _9PB70.clear(); for (int i = 0; i < maxInd3; i++) { @@ -5216,7 +5220,7 @@ void Color::initMunsell () } //printf("9 %1.2f\n",_9PB70[49]); - _9PB80 (maxInd3); + _9PB80(maxInd3); _9PB80.clear(); for (int i = 0; i < maxInd3; i++) { @@ -5229,7 +5233,7 @@ void Color::initMunsell () //10PB - _10PB10 (maxInd); + _10PB10(maxInd); _10PB10.clear(); for (int i = 0; i < maxInd; i++) { @@ -5244,7 +5248,7 @@ void Color::initMunsell () //printf("10 %1.2f %1.2f %1.2f\n",_10PB10[44],_10PB10[84],_10PB10[139]); - _10PB20 (maxInd); + _10PB20(maxInd); _10PB20.clear(); for (int i = 0; i < maxInd; i++) { @@ -5259,7 +5263,7 @@ void Color::initMunsell () //printf("10 %1.2f %1.2f %1.2f\n",_10PB20[44],_10PB20[84],_10PB20[139]); - _10PB30 (maxInd); + _10PB30(maxInd); _10PB30.clear(); for (int i = 0; i < maxInd; i++) { @@ -5274,7 +5278,7 @@ void Color::initMunsell () //printf("10 %1.2f %1.2f %1.2f\n",_10PB30[44],_10PB30[84],_10PB30[139]); - _10PB40 (maxInd); + _10PB40(maxInd); _10PB40.clear(); for (int i = 0; i < maxInd; i++) { @@ -5289,7 +5293,7 @@ void Color::initMunsell () //printf("10 %1.2f %1.2f %1.2f\n",_10PB40[44],_10PB40[84],_10PB40[139]); - _10PB50 (maxInd2); + _10PB50(maxInd2); _10PB50.clear(); for (int i = 0; i < maxInd2; i++) { @@ -5302,7 +5306,7 @@ void Color::initMunsell () //printf("10 %1.2f %1.2f\n",_10PB50[44],_10PB50[84]); - _10PB60 (maxInd2); + _10PB60(maxInd2); _10PB60.clear(); for (int i = 0; i < maxInd2; i++) { @@ -5317,7 +5321,7 @@ void Color::initMunsell () //1P - _1P10 (maxInd); + _1P10(maxInd); _1P10.clear(); for (int i = 0; i < maxInd; i++) { @@ -5332,7 +5336,7 @@ void Color::initMunsell () //printf("1P %1.2f %1.2f %1.2f\n",_1P10[44],_1P10[84],_1P10[139]); - _1P20 (maxInd); + _1P20(maxInd); _1P20.clear(); for (int i = 0; i < maxInd; i++) { @@ -5347,7 +5351,7 @@ void Color::initMunsell () //printf("1P %1.2f %1.2f %1.2f\n",_1P20[44],_1P20[84],_1P20[139]); - _1P30 (maxInd); + _1P30(maxInd); _1P30.clear(); for (int i = 0; i < maxInd; i++) { @@ -5362,7 +5366,7 @@ void Color::initMunsell () //printf("1P %1.2f %1.2f %1.2f\n",_1P30[44],_1P30[84],_1P30[139]); - _1P40 (maxInd); + _1P40(maxInd); _1P40.clear(); for (int i = 0; i < maxInd; i++) { @@ -5377,7 +5381,7 @@ void Color::initMunsell () //printf("1P %1.2f %1.2f %1.2f\n",_1P40[44],_1P40[84],_1P40[139]); - _1P50 (maxInd2); + _1P50(maxInd2); _1P50.clear(); for (int i = 0; i < maxInd2; i++) { @@ -5390,7 +5394,7 @@ void Color::initMunsell () //printf("1P %1.2f %1.2f \n",_1P50[44],_1P50[89]); - _1P60 (maxInd2); + _1P60(maxInd2); _1P60.clear(); for (int i = 0; i < maxInd2; i++) { @@ -5404,7 +5408,7 @@ void Color::initMunsell () //printf("1P %1.2f %1.2f \n",_1P60[44],_1P60[84],_1P60[139]); //4P - _4P10 (maxInd); + _4P10(maxInd); _4P10.clear(); for (int i = 0; i < maxInd; i++) { @@ -5419,7 +5423,7 @@ void Color::initMunsell () //printf("4P %1.2f %1.2f %1.2f\n",_4P10[44],_4P10[84],_4P10[139]); - _4P20 (maxInd); + _4P20(maxInd); _4P20.clear(); for (int i = 0; i < maxInd; i++) { @@ -5434,7 +5438,7 @@ void Color::initMunsell () //printf("4P %1.2f %1.2f %1.2f\n",_4P20[44],_4P20[84],_4P20[139]); - _4P30 (maxInd); + _4P30(maxInd); _4P30.clear(); for (int i = 0; i < maxInd; i++) { @@ -5449,7 +5453,7 @@ void Color::initMunsell () //printf("4P %1.2f %1.2f %1.2f\n",_4P30[44],_4P30[84],_4P30[139]); - _4P40 (maxInd); + _4P40(maxInd); _4P40.clear(); for (int i = 0; i < maxInd; i++) { @@ -5464,7 +5468,7 @@ void Color::initMunsell () //printf("4P %1.2f %1.2f %1.2f\n",_4P40[44],_4P40[84],_4P40[139]); - _4P50 (maxInd2); + _4P50(maxInd2); _4P50.clear(); for (int i = 0; i < maxInd2; i++) { @@ -5477,7 +5481,7 @@ void Color::initMunsell () //printf("4P %1.2f %1.2f \n",_4P50[44],_4P50[89]); - _4P60 (maxInd2); + _4P60(maxInd2); _4P60.clear(); for (int i = 0; i < maxInd2; i++) { @@ -5492,7 +5496,7 @@ void Color::initMunsell () //red yellow correction - _10YR20 (maxInd2); + _10YR20(maxInd2); _10YR20.clear(); for (int i = 0; i < maxInd2; i++) { @@ -5504,7 +5508,7 @@ void Color::initMunsell () } //printf("10YR %1.2f %1.2f\n",_10YR20[44],_10YR20[56]); - _10YR30 (maxInd2); + _10YR30(maxInd2); _10YR30.clear(); for (int i = 0; i < maxInd2; i++) { @@ -5516,7 +5520,7 @@ void Color::initMunsell () } //printf("10YR %1.2f %1.2f\n",_10YR30[44],_10YR30[75]); - _10YR40 (maxInd2); + _10YR40(maxInd2); _10YR40.clear(); for (int i = 0; i < maxInd2; i++) { @@ -5528,7 +5532,7 @@ void Color::initMunsell () } //printf("10YR %1.2f %1.2f\n",_10YR40[44],_10YR40[85]); - _10YR50 (maxInd2); + _10YR50(maxInd2); _10YR50.clear(); for (int i = 0; i < maxInd2; i++) { @@ -5540,7 +5544,7 @@ void Color::initMunsell () } //printf("10YR %1.2f %1.2f\n",_10YR50[44],_10YR50[80]); - _10YR60 (maxInd); + _10YR60(maxInd); _10YR60.clear(); for (int i = 0; i < maxInd; i++) { @@ -5554,7 +5558,7 @@ void Color::initMunsell () } //printf("10YR %1.2f %1.2f %1.2f\n",_10YR60[44],_10YR60[85],_10YR60[139] ); - _10YR70 (maxInd); + _10YR70(maxInd); _10YR70.clear(); for (int i = 0; i < maxInd; i++) { @@ -5568,7 +5572,7 @@ void Color::initMunsell () } //printf("10YR %1.2f %1.2f %1.2f\n",_10YR70[44],_10YR70[85],_10YR70[139] ); - _10YR80 (maxInd); + _10YR80(maxInd); _10YR80.clear(); for (int i = 0; i < maxInd; i++) { @@ -5582,7 +5586,7 @@ void Color::initMunsell () } //printf("10YR %1.2f %1.2f %1.2f\n",_10YR80[44],_10YR80[84],_10YR80[139] ); - _10YR90 (maxInd2); + _10YR90(maxInd2); _10YR90.clear(); for (int i = 0; i < maxInd2; i++) { @@ -5594,7 +5598,7 @@ void Color::initMunsell () } //printf("10YR %1.2f %1.2f\n",_10YR90[45],_10YR90[80]); - _85YR20 (maxInd3); + _85YR20(maxInd3); _85YR20.clear(); for (int i = 0; i < maxInd3; i++) { @@ -5604,7 +5608,7 @@ void Color::initMunsell () } //printf("85YR %1.2f \n",_85YR20[44]); - _85YR30 (maxInd2); + _85YR30(maxInd2); _85YR30.clear(); for (int i = 0; i < maxInd2; i++) { @@ -5616,7 +5620,7 @@ void Color::initMunsell () } //printf("85YR %1.2f %1.2f\n",_85YR30[44],_85YR30[75]); - _85YR40 (maxInd2); + _85YR40(maxInd2); _85YR40.clear(); for (int i = 0; i < maxInd2; i++) { @@ -5628,7 +5632,7 @@ void Color::initMunsell () } //printf("85YR %1.2f %1.2f\n",_85YR40[44],_85YR40[75]); - _85YR50 (maxInd); + _85YR50(maxInd); _85YR50.clear(); for (int i = 0; i < maxInd; i++) { @@ -5642,7 +5646,7 @@ void Color::initMunsell () } //printf("85YR %1.2f %1.2f %1.2f\n",_85YR50[44],_85YR50[85],_85YR50[110] ); - _85YR60 (maxInd); + _85YR60(maxInd); _85YR60.clear(); for (int i = 0; i < maxInd; i++) { @@ -5657,7 +5661,7 @@ void Color::initMunsell () //printf("85YR %1.2f %1.2f %1.2f\n",_85YR60[44],_85YR60[85],_85YR60[139] ); - _85YR70 (maxInd); + _85YR70(maxInd); _85YR70.clear(); for (int i = 0; i < maxInd; i++) { @@ -5671,7 +5675,7 @@ void Color::initMunsell () } //printf("85YR %1.2f %1.2f %1.2f\n",_85YR70[44],_85YR70[85],_85YR70[139] ); - _85YR80 (maxInd); + _85YR80(maxInd); _85YR80.clear(); for (int i = 0; i < maxInd; i++) { @@ -5685,7 +5689,7 @@ void Color::initMunsell () } //printf("85YR %1.2f %1.2f %1.2f\n",_85YR80[44],_85YR80[85],_85YR80[139] ); - _85YR90 (maxInd2); + _85YR90(maxInd2); _85YR90.clear(); for (int i = 0; i < maxInd; i++) { @@ -5699,7 +5703,7 @@ void Color::initMunsell () //printf("85YR %1.2f %1.2f\n",_85YR90[44],_85YR90[85]); //7YR - _7YR30 (maxInd2); + _7YR30(maxInd2); _7YR30.clear(); for (int i = 0; i < maxInd2; i++) { @@ -5711,7 +5715,7 @@ void Color::initMunsell () } //printf("7YR %1.2f %1.2f\n",_7YR30[44],_7YR30[66]); - _7YR40 (maxInd2); + _7YR40(maxInd2); _7YR40.clear(); for (int i = 0; i < maxInd2; i++) { @@ -5723,7 +5727,7 @@ void Color::initMunsell () } //printf("7YR %1.2f %1.2f\n",_7YR40[44],_7YR40[89]); - _7YR50 (maxInd2); + _7YR50(maxInd2); _7YR50.clear(); for (int i = 0; i < maxInd2; i++) { @@ -5735,7 +5739,7 @@ void Color::initMunsell () } //printf("7YR %1.2f %1.2f\n",_7YR50[44],_7YR50[89] ); - _7YR60 (maxInd); + _7YR60(maxInd); _7YR60.clear(); for (int i = 0; i < maxInd; i++) { @@ -5750,7 +5754,7 @@ void Color::initMunsell () //printf("7YR %1.2f %1.2f %1.2f\n",_7YR60[44],_7YR60[84],_7YR60[125] ); - _7YR70 (maxInd); + _7YR70(maxInd); _7YR70.clear(); for (int i = 0; i < maxInd; i++) { @@ -5764,7 +5768,7 @@ void Color::initMunsell () } //printf("7YR %1.2f %1.2f %1.2f\n",_7YR70[44],_7YR70[84],_7YR70[125] ); - _7YR80 (maxInd3); + _7YR80(maxInd3); _7YR80.clear(); for (int i = 0; i < maxInd3; i++) { @@ -5774,7 +5778,7 @@ void Color::initMunsell () } //printf("7YR %1.2f \n",_7YR80[44] ); - _55YR30 (maxInd3); + _55YR30(maxInd3); _55YR30.clear(); for (int i = 0; i < maxInd3; i++) { @@ -5784,7 +5788,7 @@ void Color::initMunsell () } //printf("55YR %1.2f \n",_55YR30[44] ); - _55YR40 (maxInd2); + _55YR40(maxInd2); _55YR40.clear(); for (int i = 0; i < maxInd2; i++) { @@ -5796,7 +5800,7 @@ void Color::initMunsell () } //printf("55YR %1.2f %1.2f\n",_55YR40[44],_55YR40[89] ); - _55YR50 (maxInd); + _55YR50(maxInd); _55YR50.clear(); for (int i = 0; i < maxInd; i++) { @@ -5810,7 +5814,7 @@ void Color::initMunsell () } //printf("55YR %1.2f %1.2f %1.2f\n",_55YR50[44],_55YR50[84],_55YR50[125] ); - _55YR60 (maxInd); + _55YR60(maxInd); _55YR60.clear(); for (int i = 0; i < maxInd; i++) { @@ -5824,7 +5828,7 @@ void Color::initMunsell () } //printf("55YR %1.2f %1.2f %1.2f\n",_55YR60[44],_55YR60[84],_55YR60[125] ); - _55YR70 (maxInd); + _55YR70(maxInd); _55YR70.clear(); for (int i = 0; i < maxInd; i++) { @@ -5838,7 +5842,7 @@ void Color::initMunsell () } //printf("55YR %1.2f %1.2f %1.2f\n",_55YR70[44],_55YR70[84],_55YR70[125] ); - _55YR80 (maxInd); + _55YR80(maxInd); _55YR80.clear(); for (int i = 0; i < maxInd; i++) { @@ -5852,7 +5856,7 @@ void Color::initMunsell () } //printf("55YR %1.2f %1.2f %1.2f\n",_55YR80[44],_55YR80[84],_55YR80[125] ); - _55YR90 (maxInd3); + _55YR90(maxInd3); _55YR90.clear(); for (int i = 0; i < maxInd3; i++) { @@ -5863,7 +5867,7 @@ void Color::initMunsell () //printf("55YR %1.2f \n",_55YR90[44] ); - _4YR30 (maxInd2); + _4YR30(maxInd2); _4YR30.clear(); for (int i = 0; i < maxInd2; i++) { @@ -5875,7 +5879,7 @@ void Color::initMunsell () } //printf("4YR %1.2f %1.2f\n",_4YR30[44],_4YR30[78] ); - _4YR40 (maxInd2); + _4YR40(maxInd2); _4YR40.clear(); for (int i = 0; i < maxInd2; i++) { @@ -5887,7 +5891,7 @@ void Color::initMunsell () } //printf("4YR %1.2f %1.2f\n",_4YR40[44],_4YR40[74] ); - _4YR50 (maxInd2); + _4YR50(maxInd2); _4YR50.clear(); for (int i = 0; i < maxInd2; i++) { @@ -5899,7 +5903,7 @@ void Color::initMunsell () } //printf("4YR %1.2f %1.2f\n",_4YR50[44],_4YR50[85] ); - _4YR60 (maxInd); + _4YR60(maxInd); _4YR60.clear(); for (int i = 0; i < maxInd; i++) { @@ -5913,7 +5917,7 @@ void Color::initMunsell () } //printf("4YR %1.2f %1.2f %1.2f\n",_4YR60[44],_4YR60[84],_4YR60[125] ); - _4YR70 (maxInd); + _4YR70(maxInd); _4YR70.clear(); for (int i = 0; i < maxInd; i++) { @@ -5927,7 +5931,7 @@ void Color::initMunsell () } //printf("4YR %1.2f %1.2f %1.2f\n",_4YR70[44],_4YR70[84],_4YR70[125] ); - _4YR80 (maxInd3); + _4YR80(maxInd3); _4YR80.clear(); for (int i = 0; i < maxInd3; i++) { @@ -5938,7 +5942,7 @@ void Color::initMunsell () //printf("4YR %1.2f \n",_4YR80[41] ); - _25YR30 (maxInd2); + _25YR30(maxInd2); _25YR30.clear(); for (int i = 0; i < maxInd2; i++) { @@ -5950,7 +5954,7 @@ void Color::initMunsell () } //printf("25YR %1.2f %1.2f\n",_25YR30[44],_25YR30[74] ); - _25YR40 (maxInd2); + _25YR40(maxInd2); _25YR40.clear(); for (int i = 0; i < maxInd2; i++) { @@ -5962,7 +5966,7 @@ void Color::initMunsell () } //printf("25YR %1.2f %1.2f\n",_25YR40[44],_25YR40[84] ); - _25YR50 (maxInd2); + _25YR50(maxInd2); _25YR50.clear(); for (int i = 0; i < maxInd2; i++) { @@ -5974,7 +5978,7 @@ void Color::initMunsell () } //printf("25YR %1.2f %1.2f\n",_25YR50[44],_25YR50[84] ); - _25YR60 (maxInd2); + _25YR60(maxInd2); _25YR60.clear(); for (int i = 0; i < maxInd2; i++) { @@ -5986,7 +5990,7 @@ void Color::initMunsell () } //printf("25YR %1.2f %1.2f\n",_25YR60[44],_25YR60[84] ); - _25YR70 (maxInd2); + _25YR70(maxInd2); _25YR70.clear(); for (int i = 0; i < maxInd2; i++) { @@ -5999,7 +6003,7 @@ void Color::initMunsell () //printf("25YR %1.2f %1.2f\n",_25YR70[44],_25YR70[84] ); - _10R30 (maxInd2); + _10R30(maxInd2); _10R30.clear(); for (int i = 0; i < maxInd2; i++) { @@ -6011,7 +6015,7 @@ void Color::initMunsell () } //printf("10R %1.2f %1.2f\n",_10R30[44],_10R30[84] ); - _10R40 (maxInd2); + _10R40(maxInd2); _10R40.clear(); for (int i = 0; i < maxInd2; i++) { @@ -6023,7 +6027,7 @@ void Color::initMunsell () } //printf("10R %1.2f %1.2f\n",_10R40[44],_10R40[84] ); - _10R50 (maxInd2); + _10R50(maxInd2); _10R50.clear(); for (int i = 0; i < maxInd2; i++) { @@ -6035,7 +6039,7 @@ void Color::initMunsell () } //printf("10R %1.2f %1.2f\n",_10R50[44],_10R50[84] ); - _10R60 (maxInd); + _10R60(maxInd); _10R60.clear(); for (int i = 0; i < maxInd; i++) { @@ -6049,7 +6053,7 @@ void Color::initMunsell () } //printf("10R %1.2f %1.2f %1.2f\n",_10R60[44],_10R60[84],_10R60[125] ); - _10R70 (maxInd); + _10R70(maxInd); _10R70.clear(); for (int i = 0; i < maxInd; i++) { @@ -6064,7 +6068,7 @@ void Color::initMunsell () //printf("10R %1.2f %1.2f %1.2f\n",_10R70[44],_10R70[84],_10R70[125] ); - _9R30 (maxInd2); + _9R30(maxInd2); _9R30.clear(); for (int i = 0; i < maxInd2; i++) { @@ -6076,7 +6080,7 @@ void Color::initMunsell () } //printf("9R %1.2f %1.2f\n",_9R30[44],_9R30[84] ); - _9R40 (maxInd2); + _9R40(maxInd2); _9R40.clear(); for (int i = 0; i < maxInd2; i++) { @@ -6088,7 +6092,7 @@ void Color::initMunsell () } //printf("9R %1.2f %1.2f\n",_9R40[44],_9R40[84] ); - _9R50 (maxInd); + _9R50(maxInd); _9R50.clear(); for (int i = 0; i < maxInd; i++) { @@ -6102,7 +6106,7 @@ void Color::initMunsell () } //printf("9R %1.2f %1.2f %1.2f\n",_9R50[44],_9R50[84],_9R50[125] ); - _9R60 (maxInd); + _9R60(maxInd); _9R60.clear(); for (int i = 0; i < maxInd; i++) { @@ -6116,7 +6120,7 @@ void Color::initMunsell () } //printf("9R %1.2f %1.2f %1.2f\n",_9R60[44],_9R60[84],_9R60[125] ); - _9R70 (maxInd2); + _9R70(maxInd2); _9R70.clear(); for (int i = 0; i < maxInd2; i++) { @@ -6129,7 +6133,7 @@ void Color::initMunsell () //printf("9R %1.2f %1.2f\n",_9R70[44],_9R70[84] ); - _7R30 (maxInd2); + _7R30(maxInd2); _7R30.clear(); for (int i = 0; i < maxInd2; i++) { @@ -6141,7 +6145,7 @@ void Color::initMunsell () } //printf("7R %1.2f %1.2f\n",_7R30[44],_7R30[84] ); - _7R40 (maxInd2); + _7R40(maxInd2); _7R40.clear(); for (int i = 0; i < maxInd2; i++) { @@ -6153,7 +6157,7 @@ void Color::initMunsell () } //printf("7R %1.2f %1.2f\n",_7R40[44],_7R40[84] ); - _7R50 (maxInd); + _7R50(maxInd); _7R50.clear(); for (int i = 0; i < maxInd; i++) { @@ -6167,7 +6171,7 @@ void Color::initMunsell () } //printf("7R %1.2f %1.2f %1.2f\n",_7R50[44],_7R50[84],_7R50[125] ); - _7R60 (maxInd); + _7R60(maxInd); _7R60.clear(); for (int i = 0; i < maxInd; i++) { @@ -6181,7 +6185,7 @@ void Color::initMunsell () } //printf("7R %1.2f %1.2f %1.2f\n",_7R60[44],_7R60[84],_7R60[107] ); - _7R70 (maxInd2); + _7R70(maxInd2); _7R70.clear(); for (int i = 0; i < maxInd2; i++) { @@ -6197,7 +6201,7 @@ void Color::initMunsell () //5R 1 2 3 //5R - _5R10 (maxInd2); + _5R10(maxInd2); _5R10.clear(); for (int i = 0; i < maxInd2; i++) { @@ -6209,7 +6213,7 @@ void Color::initMunsell () } //printf("5R %1.2f %1.2f\n",_5R10[44],_5R10[51] ); - _5R20 (maxInd2); + _5R20(maxInd2); _5R20.clear(); for (int i = 0; i < maxInd2; i++) { @@ -6221,7 +6225,7 @@ void Color::initMunsell () } //printf("5R %1.2f %1.2f\n",_5R20[44],_5R20[70] ); - _5R30 (maxInd2); + _5R30(maxInd2); _5R30.clear(); for (int i = 0; i < maxInd2; i++) { @@ -6235,7 +6239,7 @@ void Color::initMunsell () //printf("5R %1.2f %1.2f\n",_5R30[44],_5R30[85] ); //25R - _25R10 (maxInd3); + _25R10(maxInd3); _25R10.clear(); for (int i = 0; i < maxInd3; i++) { @@ -6245,7 +6249,7 @@ void Color::initMunsell () } //printf("25R %1.2f \n",_25R10[44]); - _25R20 (maxInd2); + _25R20(maxInd2); _25R20.clear(); for (int i = 0; i < maxInd2; i++) { @@ -6258,7 +6262,7 @@ void Color::initMunsell () //printf("25R %1.2f %1.2f\n",_25R20[44],_25R20[69] ); //25R30: 0.28, 0.26, 0.22 - _25R30 (maxInd2); + _25R30(maxInd2); _25R30.clear(); for (int i = 0; i < maxInd2; i++) { @@ -6272,7 +6276,7 @@ void Color::initMunsell () //printf("25R %1.2f %1.2f\n",_25R30[44],_25R30[85] ); - _10RP10 (maxInd3); + _10RP10(maxInd3); _10RP10.clear(); for (int i = 0; i < maxInd3; i++) { @@ -6282,7 +6286,7 @@ void Color::initMunsell () } //printf("10RP %1.2f \n",_10RP10[44]); - _10RP20 (maxInd2); + _10RP20(maxInd2); _10RP20.clear(); for (int i = 0; i < maxInd2; i++) { @@ -6294,7 +6298,7 @@ void Color::initMunsell () } //printf("10RP %1.2f %1.2f\n",_10RP20[44],_10RP20[69] ); - _10RP30 (maxInd2); + _10RP30(maxInd2); _10RP30.clear(); for (int i = 0; i < maxInd2; i++) { @@ -6308,7 +6312,7 @@ void Color::initMunsell () //printf("10RP %1.2f %1.2f\n",_10RP30[44],_10RP30[85] ); //7G - _7G30 (maxInd); + _7G30(maxInd); _7G30.clear(); for (int i = 0; i < maxInd; i++) { @@ -6322,7 +6326,7 @@ void Color::initMunsell () } //printf("7G %1.2f %1.2f %1.2f\n",_7G30[44],_7G30[84],_7G30[125] ); - _7G40 (maxInd); + _7G40(maxInd); _7G40.clear(); for (int i = 0; i < maxInd; i++) { @@ -6336,7 +6340,7 @@ void Color::initMunsell () } //printf("7G %1.2f %1.2f %1.2f\n",_7G40[44],_7G40[84],_7G40[125] ); - _7G50 (maxInd); + _7G50(maxInd); _7G50.clear(); for (int i = 0; i < maxInd; i++) { @@ -6350,7 +6354,7 @@ void Color::initMunsell () } //printf("7G %1.2f %1.2f %1.2f\n",_7G50[44],_7G50[84],_7G50[125] ); - _7G60 (maxInd); + _7G60(maxInd); _7G60.clear(); for (int i = 0; i < maxInd; i++) { @@ -6364,7 +6368,7 @@ void Color::initMunsell () } //printf("7G %1.2f %1.2f %1.2f\n",_7G60[44],_7G60[84],_7G60[125] ); - _7G70 (maxInd); + _7G70(maxInd); _7G70.clear(); for (int i = 0; i < maxInd; i++) { @@ -6378,7 +6382,7 @@ void Color::initMunsell () } //printf("7G %1.2f %1.2f %1.2f\n",_7G70[44],_7G70[84],_7G70[125] ); - _7G80 (maxInd); + _7G80(maxInd); _7G80.clear(); for (int i = 0; i < maxInd; i++) { @@ -6395,7 +6399,7 @@ void Color::initMunsell () //5G - _5G30 (maxInd); + _5G30(maxInd); _5G30.clear(); for (int i = 0; i < maxInd; i++) { @@ -6409,7 +6413,7 @@ void Color::initMunsell () } //printf("5G %1.2f %1.2f %1.2f\n",_5G30[44],_5G30[84],_5G30[125] ); - _5G40 (maxInd); + _5G40(maxInd); _5G40.clear(); for (int i = 0; i < maxInd; i++) { @@ -6423,7 +6427,7 @@ void Color::initMunsell () } //printf("5G %1.2f %1.2f %1.2f\n",_5G40[44],_5G40[84],_5G40[125] ); - _5G50 (maxInd); + _5G50(maxInd); _5G50.clear(); for (int i = 0; i < maxInd; i++) { @@ -6437,7 +6441,7 @@ void Color::initMunsell () } //printf("5G %1.2f %1.2f %1.2f\n",_5G50[44],_5G50[84],_5G50[125] ); - _5G60 (maxInd); + _5G60(maxInd); _5G60.clear(); for (int i = 0; i < maxInd; i++) { @@ -6451,7 +6455,7 @@ void Color::initMunsell () } //printf("5G %1.2f %1.2f %1.2f\n",_5G60[44],_5G60[84],_5G60[125] ); - _5G70 (maxInd); + _5G70(maxInd); _5G70.clear(); for (int i = 0; i < maxInd; i++) { @@ -6465,7 +6469,7 @@ void Color::initMunsell () } //printf("5G %1.2f %1.2f %1.2f\n",_5G70[44],_5G70[84],_5G70[125] ); - _5G80 (maxInd); + _5G80(maxInd); _5G80.clear(); for (int i = 0; i < maxInd; i++) { @@ -6481,7 +6485,7 @@ void Color::initMunsell () //printf("5G %1.2f %1.2f %1.2f\n",_5G80[44],_5G80[84],_5G80[125] ); //25G - _25G30 (maxInd); + _25G30(maxInd); _25G30.clear(); for (int i = 0; i < maxInd; i++) { @@ -6495,7 +6499,7 @@ void Color::initMunsell () } //printf("25G %1.2f %1.2f %1.2f\n",_25G30[44],_25G30[84],_25G30[125] ); - _25G40 (maxInd); + _25G40(maxInd); _25G40.clear(); for (int i = 0; i < maxInd; i++) { @@ -6509,7 +6513,7 @@ void Color::initMunsell () } //printf("25G %1.2f %1.2f %1.2f\n",_25G40[44],_25G40[84],_25G40[125] ); - _25G50 (maxInd); + _25G50(maxInd); _25G50.clear(); for (int i = 0; i < maxInd; i++) { @@ -6523,7 +6527,7 @@ void Color::initMunsell () } //printf("25G %1.2f %1.2f %1.2f\n",_25G50[44],_25G50[84],_25G50[125] ); - _25G60 (maxInd); + _25G60(maxInd); _25G60.clear(); for (int i = 0; i < maxInd; i++) { @@ -6537,7 +6541,7 @@ void Color::initMunsell () } //printf("25G %1.2f %1.2f %1.2f\n",_25G60[44],_25G60[84],_25G60[125] ); - _25G70 (maxInd); + _25G70(maxInd); _25G70.clear(); for (int i = 0; i < maxInd; i++) { @@ -6551,7 +6555,7 @@ void Color::initMunsell () } //printf("25G %1.2f %1.2f %1.2f\n",_25G70[44],_25G70[84],_25G70[125] ); - _25G80 (maxInd); + _25G80(maxInd); _25G80.clear(); for (int i = 0; i < maxInd; i++) { @@ -6568,7 +6572,7 @@ void Color::initMunsell () //1G - _1G30 (maxInd); + _1G30(maxInd); _1G30.clear(); for (int i = 0; i < maxInd; i++) { @@ -6582,7 +6586,7 @@ void Color::initMunsell () } //printf("1G %1.2f %1.2f %1.2f\n",_1G30[44],_1G30[84],_1G30[125] ); - _1G40 (maxInd); + _1G40(maxInd); _1G40.clear(); for (int i = 0; i < maxInd; i++) { @@ -6596,7 +6600,7 @@ void Color::initMunsell () } //printf("1G %1.2f %1.2f %1.2f\n",_1G40[44],_1G40[84],_1G40[125] ); - _1G50 (maxInd); + _1G50(maxInd); _1G50.clear(); for (int i = 0; i < maxInd; i++) { @@ -6610,7 +6614,7 @@ void Color::initMunsell () } //printf("1G %1.2f %1.2f %1.2f\n",_1G50[44],_1G50[84],_1G50[125] ); - _1G60 (maxInd); + _1G60(maxInd); _1G60.clear(); for (int i = 0; i < maxInd; i++) { @@ -6624,7 +6628,7 @@ void Color::initMunsell () } //printf("1G %1.2f %1.2f %1.2f\n",_1G60[44],_1G60[84],_1G60[125] ); - _1G70 (maxInd); + _1G70(maxInd); _1G70.clear(); for (int i = 0; i < maxInd; i++) { @@ -6638,7 +6642,7 @@ void Color::initMunsell () } //printf("1G %1.2f %1.2f %1.2f\n",_1G70[44],_1G70[84],_1G70[125] ); - _1G80 (maxInd); + _1G80(maxInd); _1G80.clear(); for (int i = 0; i < maxInd; i++) { @@ -6655,7 +6659,7 @@ void Color::initMunsell () //10GY - _10GY30 (maxInd); + _10GY30(maxInd); _10GY30.clear(); for (int i = 0; i < maxInd; i++) { @@ -6669,7 +6673,7 @@ void Color::initMunsell () } //printf("10GY %1.2f %1.2f %1.2f\n",_10GY30[44],_10GY30[84],_10GY30[125] ); - _10GY40 (maxInd); + _10GY40(maxInd); _10GY40.clear(); for (int i = 0; i < maxInd; i++) { @@ -6683,7 +6687,7 @@ void Color::initMunsell () } //printf("10GY %1.2f %1.2f %1.2f\n",_10GY40[44],_10GY40[84],_10GY40[125] ); - _10GY50 (maxInd); + _10GY50(maxInd); _10GY50.clear(); for (int i = 0; i < maxInd; i++) { @@ -6697,7 +6701,7 @@ void Color::initMunsell () } //printf("10GY %1.2f %1.2f %1.2f\n",_10GY50[44],_10GY50[84],_10GY50[125] ); - _10GY60 (maxInd); + _10GY60(maxInd); _10GY60.clear(); for (int i = 0; i < maxInd; i++) { @@ -6711,7 +6715,7 @@ void Color::initMunsell () } //printf("10GY %1.2f %1.2f %1.2f\n",_10GY60[44],_10GY60[84],_10GY60[125] ); - _10GY70 (maxInd); + _10GY70(maxInd); _10GY70.clear(); for (int i = 0; i < maxInd; i++) { @@ -6725,7 +6729,7 @@ void Color::initMunsell () } //printf("10GY %1.2f %1.2f %1.2f\n",_10GY70[44],_10GY70[84],_10GY70[125] ); - _10GY80 (maxInd); + _10GY80(maxInd); _10GY80.clear(); for (int i = 0; i < maxInd; i++) { @@ -6742,7 +6746,7 @@ void Color::initMunsell () //75GY - _75GY30 (maxInd2); + _75GY30(maxInd2); _75GY30.clear(); for (int i = 0; i < maxInd; i++) { @@ -6754,7 +6758,7 @@ void Color::initMunsell () } //printf("75GY %1.2f %1.2f\n",_75GY30[44],_75GY30[84] ); - _75GY40 (maxInd2); + _75GY40(maxInd2); _75GY40.clear(); for (int i = 0; i < maxInd; i++) { @@ -6766,7 +6770,7 @@ void Color::initMunsell () } //printf("75GY %1.2f %1.2f \n",_75GY40[44],_75GY40[84] ); - _75GY50 (maxInd); + _75GY50(maxInd); _75GY50.clear(); for (int i = 0; i < maxInd; i++) { @@ -6780,7 +6784,7 @@ void Color::initMunsell () } //printf("75GY %1.2f %1.2f %1.2f %1.2f\n",_75GY50[44],_75GY50[84],_75GY50[125],_75GY50[139] ); - _75GY60 (maxInd); + _75GY60(maxInd); _75GY60.clear(); for (int i = 0; i < maxInd; i++) { @@ -6794,7 +6798,7 @@ void Color::initMunsell () } //printf("75GY %1.2f %1.2f %1.2f\n",_75GY60[44],_75GY60[84],_75GY60[125] ); - _75GY70 (maxInd); + _75GY70(maxInd); _75GY70.clear(); for (int i = 0; i < maxInd; i++) { @@ -6808,7 +6812,7 @@ void Color::initMunsell () } //printf("75GY %1.2f %1.2f %1.2f\n",_75GY70[44],_75GY70[84],_75GY70[125] ); - _75GY80 (maxInd); + _75GY80(maxInd); _75GY80.clear(); for (int i = 0; i < maxInd; i++) { @@ -6825,7 +6829,7 @@ void Color::initMunsell () //55GY - _5GY30 (maxInd2); + _5GY30(maxInd2); _5GY30.clear(); for (int i = 0; i < maxInd; i++) { @@ -6840,7 +6844,7 @@ void Color::initMunsell () //5GY4: 2.14,2.04, 1.96, 1.91 //95 - _5GY40 (maxInd2); + _5GY40(maxInd2); _5GY40.clear(); for (int i = 0; i < maxInd; i++) { @@ -6852,7 +6856,7 @@ void Color::initMunsell () } //printf("5GY %1.2f %1.2f \n",_5GY40[44],_5GY40[84] ); - _5GY50 (maxInd); + _5GY50(maxInd); _5GY50.clear(); for (int i = 0; i < maxInd; i++) { @@ -6866,7 +6870,7 @@ void Color::initMunsell () } //printf("5GY %1.2f %1.2f %1.2f\n",_5GY50[44],_5GY50[84],_5GY50[125] ); - _5GY60 (maxInd); + _5GY60(maxInd); _5GY60.clear(); for (int i = 0; i < maxInd; i++) { @@ -6880,7 +6884,7 @@ void Color::initMunsell () } //printf("5GY %1.2f %1.2f %1.2f\n",_5GY60[44],_5GY60[84],_5GY60[125] ); - _5GY70 (maxInd); + _5GY70(maxInd); _5GY70.clear(); for (int i = 0; i < maxInd; i++) { @@ -6894,7 +6898,7 @@ void Color::initMunsell () } //printf("5GY %1.2f %1.2f %1.2f\n",_5GY70[44],_5GY70[84],_5GY70[125] ); - _5GY80 (maxInd); + _5GY80(maxInd); _5GY80.clear(); for (int i = 0; i < maxInd; i++) { @@ -6913,7 +6917,7 @@ void Color::initMunsell () t2e.set(); if (settings->verbose) { - printf ("Lutf Munsell %d usec\n", t2e.etime (t1e)); + printf("Lutf Munsell %d usec\n", t2e.etime(t1e)); } #endif diff --git a/rtengine/color.h b/rtengine/color.h index 76bfa4600..650d93250 100644 --- a/rtengine/color.h +++ b/rtengine/color.h @@ -91,11 +91,11 @@ private: static LUTf _5GY30, _5GY40, _5GY50, _5GY60, _5GY70, _5GY80; // Separated from init() to keep the code clear - static void initMunsell (); - static double hue2rgb (double p, double q, double t); - static float hue2rgbfloat (float p, float q, float t); + static void initMunsell(); + static double hue2rgb(double p, double q, double t); + static float hue2rgbfloat(float p, float q, float t); #ifdef __SSE2__ - static vfloat hue2rgb (vfloat p, vfloat q, vfloat t); + static vfloat hue2rgb(vfloat p, vfloat q, vfloat t); #endif public: @@ -155,8 +155,8 @@ public: static LUTuc gammatabThumb; // for thumbnails - static void init (); - static void cleanup (); + static void init(); + static void cleanup(); /** @@ -168,13 +168,13 @@ public: * @return luminance value */ // xyz_sRGBD65 : conversion matrix from XYZ to sRGB for D65 illuminant: we use diagonal values - static float rgbLuminance (float r, float g, float b) + static float rgbLuminance(float r, float g, float b) { // WArning: The sum of xyz_sRGBd65[1][] is > 1.0 (i.e. 1.0000001), so we use our own adapted values) // 0.2126729, 0.7151521, 0.0721750 return r * 0.2126729f + g * 0.7151521f + b * 0.0721750f; } - static double rgbLuminance (double r, double g, double b) + static double rgbLuminance(double r, double g, double b) { return r * 0.2126729 + g * 0.7151521 + b * 0.0721750; } @@ -193,7 +193,7 @@ public: * @param b Lab b channel [0; 1] (return value) * @param workingSpace true: compute the Lab value using the Working color space ; false: use the Output color space */ - static void rgb2lab (Glib::ustring profile, Glib::ustring profileW, int r, int g, int b, float &LAB_l, float &LAB_a, float &LAB_b, bool workingSpace); + static void rgb2lab(Glib::ustring profile, Glib::ustring profileW, int r, int g, int b, float &LAB_l, float &LAB_a, float &LAB_b, bool workingSpace); /** @@ -205,10 +205,10 @@ public: * @param s saturation channel [0 ; 1] (return value) * @param l luminance channel [0; 1] (return value) */ - static void rgb2hsl (float r, float g, float b, float &h, float &s, float &l); - static void rgb2hslfloat (float r, float g, float b, float &h, float &s, float &l); + static void rgb2hsl(float r, float g, float b, float &h, float &s, float &l); + static void rgb2hslfloat(float r, float g, float b, float &h, float &s, float &l); #ifdef __SSE2__ - static void rgb2hsl (vfloat r, vfloat g, vfloat b, vfloat &h, vfloat &s, vfloat &l); + static void rgb2hsl(vfloat r, vfloat g, vfloat b, vfloat &h, vfloat &s, vfloat &l); #endif /** @@ -220,10 +220,10 @@ public: * @param g green channel [0 ; 65535] (return value) * @param b blue channel [0 ; 65535] (return value) */ - static void hsl2rgb (float h, float s, float l, float &r, float &g, float &b); - static void hsl2rgbfloat (float h, float s, float l, float &r, float &g, float &b); + static void hsl2rgb(float h, float s, float l, float &r, float &g, float &b); + static void hsl2rgbfloat(float h, float s, float l, float &r, float &g, float &b); #ifdef __SSE2__ - static void hsl2rgb (vfloat h, vfloat s, vfloat l, vfloat &r, vfloat &g, vfloat &b); + static void hsl2rgb(vfloat h, vfloat s, vfloat l, vfloat &r, vfloat &g, vfloat &b); #endif /** @@ -235,7 +235,7 @@ public: * @param g green channel [0 ; 1] (return value) * @param b blue channel [0 ; 1] (return value) */ - static void hsl2rgb01 (float h, float s, float l, float &r, float &g, float &b); + static void hsl2rgb01(float h, float s, float l, float &r, float &g, float &b); /** @@ -247,12 +247,12 @@ public: * @param s saturation channel [0 ; 1] (return value) * @param v value channel [0 ; 1] (return value) */ - static void rgb2hsv (float r, float g, float b, float &h, float &s, float &v); + static void rgb2hsv(float r, float g, float b, float &h, float &s, float &v); - static inline float rgb2s (float r, float g, float b) // fast version if only saturation is needed + static inline float rgb2s(float r, float g, float b) // fast version if only saturation is needed { - float var_Min = min (r, g, b); - float var_Max = max (r, g, b); + float var_Min = min(r, g, b); + float var_Max = max(r, g, b); float del_Max = var_Max - var_Min; if (del_Max < 0.00001f) { @@ -262,35 +262,35 @@ public: } } - static inline bool rgb2hsvdcp (float r, float g, float b, float &h, float &s, float &v) + static inline bool rgb2hsvdcp(float r, float g, float b, float &h, float &s, float &v) { - float var_Min = min (r, g, b); + float var_Min = min(r, g, b); if (var_Min < 0.f) { return false; } else { - float var_Max = max (r, g, b); + float var_Max = max(r, g, b); float del_Max = var_Max - var_Min; v = var_Max / 65535.f; - if (fabsf (del_Max) < 0.00001f) { + if (fabsf(del_Max) < 0.00001f) { h = 0.f; s = 0.f; } else { s = del_Max / var_Max; - if ( r == var_Max ) { + if (r == var_Max) { h = (g - b) / del_Max; - } else if ( g == var_Max ) { + } else if (g == var_Max) { h = 2.f + (b - r) / del_Max; } else { /*if ( b == var_Max ) */ h = 4.f + (r - g) / del_Max; } - if ( h < 0.f ) { + if (h < 0.f) { h += 6.f; - } else if ( h > 6.f ) { + } else if (h > 6.f) { h -= 6.f; } } @@ -308,9 +308,9 @@ public: * @param g green channel [0 ; 65535] (return value) * @param b blue channel [0 ; 65535] (return value) */ - static void hsv2rgb (float h, float s, float v, float &r, float &g, float &b); + static void hsv2rgb(float h, float s, float v, float &r, float &g, float &b); - static inline void hsv2rgbdcp (float h, float s, float v, float &r, float &g, float &b) + static inline void hsv2rgbdcp(float h, float s, float v, float &r, float &g, float &b) { // special version for dcp which saves 1 division (in caller) and six multiplications (inside this function) int sector = h; // sector 0 to 5, floor() is very slow, and h is always >0 @@ -360,7 +360,7 @@ public: } } - static void hsv2rgb (float h, float s, float v, int &r, int &g, int &b); + static void hsv2rgb(float h, float s, float v, int &r, int &g, int &b); /** @@ -372,7 +372,7 @@ public: * @param g green channel [0 ; 1] (return value) * @param b blue channel [0 ; 1] (return value) */ - static void hsv2rgb01 (float h, float s, float v, float &r, float &g, float &b); + static void hsv2rgb01(float h, float s, float v, float &r, float &g, float &b); /** @@ -385,7 +385,7 @@ public: * @param g green channel [same range than xyz channel] (return value) * @param b blue channel [same range than xyz channel] (return value) */ - static void xyz2srgb (float x, float y, float z, float &r, float &g, float &b); + static void xyz2srgb(float x, float y, float z, float &r, float &g, float &b); /** @@ -398,7 +398,7 @@ public: * @param g green channel [same range than xyz channel] (return value) * @param b blue channel [same range than xyz channel] (return value) */ - static void xyz2Prophoto (float x, float y, float z, float &r, float &g, float &b); + static void xyz2Prophoto(float x, float y, float z, float &r, float &g, float &b); /** @@ -411,7 +411,7 @@ public: * @param y Y coordinate [same range than xyz channel] * @param z Z coordinate [same range than xyz channel] */ - static void Prophotoxyz (float r, float g, float b, float &x, float &y, float &z); + static void Prophotoxyz(float r, float g, float b, float &x, float &y, float &z); /** @@ -425,11 +425,11 @@ public: * @param b blue channel [same range than xyz channel] (return value) * @param rgb_xyz[3][3] transformation matrix to use for the conversion */ - static void xyz2rgb (float x, float y, float z, float &r, float &g, float &b, const double rgb_xyz[3][3]); - static void xyz2r (float x, float y, float z, float &r, const double rgb_xyz[3][3]); - static void xyz2rgb (float x, float y, float z, float &r, float &g, float &b, const float rgb_xyz[3][3]); + static void xyz2rgb(float x, float y, float z, float &r, float &g, float &b, const double rgb_xyz[3][3]); + static void xyz2r(float x, float y, float z, float &r, const double rgb_xyz[3][3]); + static void xyz2rgb(float x, float y, float z, float &r, float &g, float &b, const float rgb_xyz[3][3]); #ifdef __SSE2__ - static void xyz2rgb (vfloat x, vfloat y, vfloat z, vfloat &r, vfloat &g, vfloat &b, const vfloat rgb_xyz[3][3]); + static void xyz2rgb(vfloat x, vfloat y, vfloat z, vfloat &r, vfloat &g, vfloat &b, const vfloat rgb_xyz[3][3]); #endif @@ -444,10 +444,10 @@ public: * @param z Z coordinate [same range than rgb channel] (return value) * @param xyz_rgb[3][3] transformation matrix to use for the conversion */ - static void rgbxyz (float r, float g, float b, float &x, float &y, float &z, const double xyz_rgb[3][3]); - static void rgbxyz (float r, float g, float b, float &x, float &y, float &z, const float xyz_rgb[3][3]); + static void rgbxyz(float r, float g, float b, float &x, float &y, float &z, const double xyz_rgb[3][3]); + static void rgbxyz(float r, float g, float b, float &x, float &y, float &z, const float xyz_rgb[3][3]); #ifdef __SSE2__ - static void rgbxyz (vfloat r, vfloat g, vfloat b, vfloat &x, vfloat &y, vfloat &z, const vfloat xyz_rgb[3][3]); + static void rgbxyz(vfloat r, vfloat g, vfloat b, vfloat &x, vfloat &y, vfloat &z, const vfloat xyz_rgb[3][3]); #endif /** @@ -459,11 +459,11 @@ public: * @param y Y coordinate [0 ; 65535] ; can be negative! (return value) * @param z Z coordinate [0 ; 65535] ; can be negative! (return value) */ - static void Lab2XYZ (float L, float a, float b, float &x, float &y, float &z); - static void L2XYZ (float L, float &x, float &y, float &z); + static void Lab2XYZ(float L, float a, float b, float &x, float &y, float &z); + static void L2XYZ(float L, float &x, float &y, float &z); #ifdef __SSE2__ - static void Lab2XYZ (vfloat L, vfloat a, vfloat b, vfloat &x, vfloat &y, vfloat &z); + static void Lab2XYZ(vfloat L, vfloat a, vfloat b, vfloat &x, vfloat &y, vfloat &z); #endif // __SSE2__ /** @@ -487,7 +487,7 @@ public: * @param u red chrominance channel [0 ; 65535] (return value) * @param v blue chrominance channel [0 ; 65535] (return value) */ - static void Lab2Yuv (float L, float a, float b, float &Y, float &u, float &v); + static void Lab2Yuv(float L, float a, float b, float &Y, float &u, float &v); /** @@ -499,7 +499,7 @@ public: * @param a channel [-42000 ; +42000] ; can be more than 42000 (return value) * @param b channel [-42000 ; +42000] ; can be more than 42000 (return value) */ - static void Yuv2Lab (float Y, float u, float v, float &L, float &a, float &b, const double wp[3][3]); + static void Yuv2Lab(float Y, float u, float v, float &L, float &a, float &b, const double wp[3][3]); /** @@ -509,7 +509,7 @@ public: * @param c 'c' channel return value, in [0 ; 42000] ; can be more than 42000 (return value) * @param h 'h' channel return value, in [-PI ; +PI] (return value) */ - static void Lab2Lch (float a, float b, float &c, float &h); + static void Lab2Lch(float a, float b, float &c, float &h); /** @@ -519,7 +519,7 @@ public: * @param a 'a' channel [-42000 ; +42000] ; can be more than 42000 (return value) * @param b 'b' channel [-42000 ; +42000] ; can be more than 42000 (return value) */ - static void Lch2Lab (float c, float h, float &a, float &b); + static void Lch2Lab(float c, float h, float &a, float &b); /** @@ -529,7 +529,7 @@ public: * @param c 'c' channel [unknown range!] (return value) * @param h 'h' channel [-PI ; +PI] (return value) */ - static void Luv2Lch (float u, float v, float &c, float &h); + static void Luv2Lch(float u, float v, float &c, float &h); /** @@ -539,7 +539,7 @@ public: * @param u 'u' channel [unknown range!] (return value) * @param v 'v' channel [unknown range!] (return value) */ - static void Lch2Luv (float c, float h, float &u, float &v); + static void Lch2Luv(float c, float h, float &u, float &v); /** @@ -552,7 +552,7 @@ public: * @param u 'u' channel [-42000 ; 42000] ; can be more than 42000 (return value) * @param v 'v' channel [-42000 ; 42000] ; can be more than 42000 (return value) */ - static void XYZ2Luv (float X, float Y, float Z, float &L, float &u, float &v); + static void XYZ2Luv(float X, float Y, float Z, float &L, float &u, float &v); /** @@ -565,7 +565,7 @@ public: * @param y Y coordinate [0 ; 65535] ; can be negative or superior to 65535 (return value) * @param z Z coordinate [0 ; 65535] ; can be negative or superior to 65535 (return value) */ - static void Luv2XYZ (float L, float u, float v, float &X, float &Y, float &Z); + static void Luv2XYZ(float L, float u, float v, float &X, float &Y, float &Z); /** @@ -575,7 +575,7 @@ public: * fy=(L+16)/116 L=luminance [0 ; 100] * fz=fy-b/200 b=chroma blue yellow [-128 ; +128] */ - static inline double f2xyz (double f) + static inline double f2xyz(double f) { const double epsilonExpInv3 = 6.0 / 29.0; const double kappaInv = 27.0 / 24389.0; // inverse of kappa @@ -583,7 +583,7 @@ public: return (f > epsilonExpInv3) ? f * f * f : (116. * f - 16.) * kappaInv; } - static inline float f2xyz (float f) + static inline float f2xyz(float f) { const float epsilonExpInv3 = 0.20689655f; // 6.0f/29.0f; const float kappaInv = 0.0011070565f; // 27.0f/24389.0f; // inverse of kappa @@ -591,13 +591,13 @@ public: return (f > epsilonExpInv3) ? f * f * f : (116.f * f - 16.f) * kappaInv; } #ifdef __SSE2__ - static inline vfloat f2xyz (vfloat f) + static inline vfloat f2xyz(vfloat f) { - const vfloat epsilonExpInv3 = F2V (0.20689655f); // 6.0f/29.0f; - const vfloat kappaInv = F2V (0.0011070565f); // 27.0f/24389.0f; // inverse of kappa + const vfloat epsilonExpInv3 = F2V(0.20689655f); // 6.0f/29.0f; + const vfloat kappaInv = F2V(0.0011070565f); // 27.0f/24389.0f; // inverse of kappa vfloat res1 = f * f * f; - vfloat res2 = (F2V (116.f) * f - F2V (16.f)) * kappaInv; - return vself (vmaskf_gt (f, epsilonExpInv3), res1, res2); + vfloat res2 = (F2V(116.f) * f - F2V(16.f)) * kappaInv; + return vself(vmaskf_gt(f, epsilonExpInv3), res1, res2); } #endif @@ -608,7 +608,7 @@ public: * @param path Path to follow (shortest/longest) * @return The interpolation direction */ - static inline eInterpolationDirection getHueInterpolationDirection (double h1, double h2, eInterpolationPath path) + static inline eInterpolationDirection getHueInterpolationDirection(double h1, double h2, eInterpolationPath path) { if (path == IP_SHORTEST) { if (h2 > h1) { @@ -650,7 +650,7 @@ public: * @param dir Tells which direction the interpolation have to follow. You can get the value with getHueInterpolationDirection * @return The interpolated hue */ - static inline double interpolateHueHSV (double h1, double h2, double balance, eInterpolationDirection dir) + static inline double interpolateHueHSV(double h1, double h2, double balance, eInterpolationDirection dir) { if (h1 == h2) { return h1; @@ -704,7 +704,7 @@ public: * @param go green channel of output color [0 ; 65535] (return value) * @param bo blue channel of output color [0 ; 65535] (return value) */ - static void interpolateRGBColor (const float balance, const float r1, const float g1, const float b1, const float r2, const float g2, const float b2, int channels, const double xyz_rgb[3][3], const double rgb_xyz[3][3], float &ro, float &go, float &bo); + static void interpolateRGBColor(const float balance, const float r1, const float g1, const float b1, const float r2, const float g2, const float b2, int channels, const double xyz_rgb[3][3], const double rgb_xyz[3][3], float &ro, float &go, float &bo); /** * @brief Interpolate 2 colors from their respective red/green/blue channels, with a balance factor @@ -734,7 +734,7 @@ public: * @param go green channel of output color [0 ; 65535] (return value) * @param bo blue channel of output color [0 ; 65535] (return value) */ - static void interpolateRGBColor (float realL, float iplow, float iphigh, int algm, const float balance, int twoc, int metchrom, float chromat, float luma, const float r1, const float g1, const float b1, const float xl, const float yl, const float zl, const float x2, const float y2, const float z2, const double xyz_rgb[3][3], const double rgb_xyz[3][3], float &ro, float &go, float &bo); + static void interpolateRGBColor(float realL, float iplow, float iphigh, int algm, const float balance, int twoc, int metchrom, float chromat, float luma, const float r1, const float g1, const float b1, const float xl, const float yl, const float zl, const float x2, const float y2, const float z2, const double xyz_rgb[3][3], const double rgb_xyz[3][3], float &ro, float &go, float &bo); /** @@ -809,34 +809,34 @@ public: * @return the interpolated value [0;1] */ template - static inline T interpolatePolarHue_01 (T h1, T h2, U balance) + static inline T interpolatePolarHue_01(T h1, T h2, U balance) { float d = h2 - h1; float f; - f = T (balance); + f = T(balance); double h; if (h1 > h2) { - std::swap (h1, h2); + std::swap(h1, h2); d = -d; f = 1.f - f; } - if (d < T (-rtengine::RT_PI) || d < T (0) || d > T (rtengine::RT_PI)) { //there was an inversion here !! d > T(rtengine::RT_PI) - h1 += T (2 * rtengine::RT_PI); + if (d < T(-rtengine::RT_PI) || d < T(0) || d > T(rtengine::RT_PI)) { //there was an inversion here !! d > T(rtengine::RT_PI) + h1 += T(2 * rtengine::RT_PI); h = h1 + f * (h2 - h1); - h = std::fmod (h, 2 * rtengine::RT_PI); + h = std::fmod(h, 2 * rtengine::RT_PI); } else { h = h1 + f * d; } // not strictly necessary..but in case of - if (h < T (-rtengine::RT_PI)) { - h = T (2 * rtengine::RT_PI) - h; + if (h < T(-rtengine::RT_PI)) { + h = T(2 * rtengine::RT_PI) - h; } - if (h > T (rtengine::RT_PI)) { - h = h - T (2 * rtengine::RT_PI); + if (h > T(rtengine::RT_PI)) { + h = h - T(2 * rtengine::RT_PI); } return h; @@ -852,34 +852,34 @@ public: * @return the interpolated value [-PI ; +PI ] */ template - static inline T interpolatePolarHue_PI (T h1, T h2, U balance) + static inline T interpolatePolarHue_PI(T h1, T h2, U balance) { float d = h2 - h1; float f; - f = T (balance); + f = T(balance); double h; if (h1 > h2) { - std::swap (h1, h2); + std::swap(h1, h2); d = -d; f = 1.f - f; } - if (d < T (0) || d < T (0.5) || d > T (1.)) { //there was an inversion here !! d > T(rtengine::RT_PI) - h1 += T (1.); + if (d < T(0) || d < T(0.5) || d > T(1.)) { //there was an inversion here !! d > T(rtengine::RT_PI) + h1 += T(1.); h = h1 + f * (h2 - h1); - h = std::fmod (h, 1.); + h = std::fmod(h, 1.); } else { h = h1 + f * d; } // not strictly necessary..but in case of - if (h < T (0)) { - h = T (1.) - h; + if (h < T(0)) { + h = T(1.) - h; } - if (h > T (1)) { - h = h - T (1.); + if (h > T(1)) { + h = h - T(1.); } return h; @@ -899,7 +899,7 @@ public: * gamma4 used in ip2Lab2rgb [0 ; 1], usually near 0.03(return value) * gamma5 used in ip2Lab2rgb [0 ; 1], usually near 0.5 (return value) */ - static void calcGamma (double pwr, double ts, int mode, GammaValues &gamma); + static void calcGamma(double pwr, double ts, int mode, GammaValues &gamma); /** @@ -911,9 +911,9 @@ public: * @param gammabwg gamma value for red channel [>0] * @param gammabwb gamma value for red channel [>0] */ - static void trcGammaBW (float &r, float &g, float &b, float gammabwr, float gammabwg, float gammabwb); + static void trcGammaBW(float &r, float &g, float &b, float gammabwr, float gammabwg, float gammabwb); #ifdef __SSE2__ - static void trcGammaBWRow (float *r, float *g, float *b, int width, float gammabwr, float gammabwg, float gammabwb); + static void trcGammaBWRow(float *r, float *g, float *b, int width, float gammabwr, float gammabwg, float gammabwb); #endif @@ -936,9 +936,9 @@ public: * @param ggm green channel of the mixer (return value) * @param bbm blue channel of the mixer (return value) */ - static void computeBWMixerConstants (const Glib::ustring &setting, const Glib::ustring &filter, const Glib::ustring &algo, float &filcor, float &mixerRed, float &mixerGreen, - float &mixerBlue, float mixerOrange, float mixerYellow, float mixerCyan, float mixerPurple, float mixerMagenta, - bool autoc, bool complement, float &kcorec, double &rrm, double &ggm, double &bbm); + static void computeBWMixerConstants(const Glib::ustring &setting, const Glib::ustring &filter, const Glib::ustring &algo, float &filcor, float &mixerRed, float &mixerGreen, + float &mixerBlue, float mixerOrange, float mixerYellow, float mixerCyan, float mixerPurple, float mixerMagenta, + bool autoc, bool complement, float &kcorec, double &rrm, double &ggm, double &bbm); // standard srgb gamma and its inverse @@ -949,9 +949,9 @@ public: * @param x red, green or blue channel's value [0 ; 1] * @return the gamma modified's value [0 ; 1] */ - static inline double gamma2 (double x) // g3 1+g4 + static inline double gamma2(double x) // g3 1+g4 { - return x <= 0.003041 ? x * 12.92 : 1.055011 * exp (log (x) / sRGBGammaCurve) - 0.055011; + return x <= 0.003041 ? x * 12.92 : 1.055011 * exp(log(x) / sRGBGammaCurve) - 0.055011; } @@ -961,9 +961,9 @@ public: * @param x red, green or blue channel's value [0 ; 1] * @return the inverse gamma modified's value [0 ; 1] */ - static inline double igamma2 (double x) //g2 + static inline double igamma2(double x) //g2 { - return x <= 0.039293 ? x / 12.92 : exp (log ((x + 0.055011) / 1.055011) * sRGBGammaCurve); + return x <= 0.039293 ? x / 12.92 : exp(log((x + 0.055011) / 1.055011) * sRGBGammaCurve); } @@ -972,9 +972,9 @@ public: * @param x red, green or blue channel's value [0 ; 1] * @return the gamma modified's value [0 ; 1] */ - static inline double gamma55 (double x) // g3 1+g4 + static inline double gamma55(double x) // g3 1+g4 { - return x <= 0.013189 ? x * 10.0 : 1.593503 * exp (log (x) / 5.5) - 0.593503; // 5.5 10 + return x <= 0.013189 ? x * 10.0 : 1.593503 * exp(log(x) / 5.5) - 0.593503; // 5.5 10 } @@ -983,9 +983,9 @@ public: * @param x red, green or blue channel's value [0 ; 1] * @return the inverse gamma modified's value [0 ; 1] */ - static inline double igamma55 (double x) //g2 + static inline double igamma55(double x) //g2 { - return x <= 0.131889 ? x / 10.0 : exp (log ((x + 0.593503) / 1.593503) * 5.5); // 5.5 10 + return x <= 0.131889 ? x / 10.0 : exp(log((x + 0.593503) / 1.593503) * 5.5); // 5.5 10 } @@ -994,9 +994,9 @@ public: * @param x red, green or blue channel's value [0 ; 1] * @return the gamma modified's value [0 ; 1] */ - static inline double gamma4 (double x) // g3 1+g4 + static inline double gamma4(double x) // g3 1+g4 { - return x <= 0.03089 ? x * 5.0 : 1.478793 * exp (log (x) / 4.1) - 0.478793; // 4 5 + return x <= 0.03089 ? x * 5.0 : 1.478793 * exp(log(x) / 4.1) - 0.478793; // 4 5 } @@ -1005,9 +1005,9 @@ public: * @param x red, green or blue channel's value [0 ; 1] * @return the inverse gamma modified's value [0 ; 1] */ - static inline double igamma4 (double x) //g2 + static inline double igamma4(double x) //g2 { - return x <= 0.154449 ? x / 5.0 : exp (log ((x + 0.478793) / 1.478793) * 4.1); // 4 5 + return x <= 0.154449 ? x / 5.0 : exp(log((x + 0.478793) / 1.478793) * 4.1); // 4 5 } @@ -1036,9 +1036,9 @@ public: * @param x red, green or blue channel's value [0 ; 1] * @return the gamma modified's value [0 ; 1] */ - static inline double gamma24_17 (double x) + static inline double gamma24_17(double x) { - return x <= 0.001867 ? x * 17.0 : 1.044445 * exp (log (x) / 2.4) - 0.044445; + return x <= 0.001867 ? x * 17.0 : 1.044445 * exp(log(x) / 2.4) - 0.044445; } @@ -1047,9 +1047,9 @@ public: * @param x red, green or blue channel's value [0 ; 1] * @return the inverse gamma modified's value [0 ; 1] */ - static inline double igamma24_17 (double x) + static inline double igamma24_17(double x) { - return x <= 0.031746 ? x / 17.0 : exp (log ((x + 0.044445) / 1.044445) * 2.4); + return x <= 0.031746 ? x / 17.0 : exp(log((x + 0.044445) / 1.044445) * 2.4); } @@ -1058,9 +1058,9 @@ public: * @param x red, green or blue channel's value [0 ; 1] * @return the gamma modified's value [0 ; 1] */ - static inline double gamma26_11 (double x) + static inline double gamma26_11(double x) { - return x <= 0.004921 ? x * 11.0 : 1.086603 * exp (log (x) / 2.6) - 0.086603; + return x <= 0.004921 ? x * 11.0 : 1.086603 * exp(log(x) / 2.6) - 0.086603; } @@ -1069,53 +1069,53 @@ public: * @param x red, green or blue channel's value [0 ; 1] * @return the inverse gamma modified's value [0 ; 1] */ - static inline double igamma26_11 (double x) + static inline double igamma26_11(double x) { - return x <= 0.054127 ? x / 11.0 : exp (log ((x + 0.086603) / 1.086603) * 2.6); + return x <= 0.054127 ? x / 11.0 : exp(log((x + 0.086603) / 1.086603) * 2.6); } /** * @brief Get the gamma value for Gamma=1.3 Slope=2 * @param x red, green or blue channel's value [0 ; 1] * @return the gamma modified's value [0 ; 1] */ - static inline double gamma13_2 (double x) + static inline double gamma13_2(double x) { - return x <= 0.016613 ? x * 2.0 : 1.009968 * exp (log (x) / 1.3) - 0.009968; + return x <= 0.016613 ? x * 2.0 : 1.009968 * exp(log(x) / 1.3) - 0.009968; } - static inline double igamma13_2 (double x) + static inline double igamma13_2(double x) { - return x <= 0.033226 ? x / 2.0 : exp (log ((x + 0.009968) / 1.009968) * 1.3); + return x <= 0.033226 ? x / 2.0 : exp(log((x + 0.009968) / 1.009968) * 1.3); } - static inline double gamma115_2 (double x) + static inline double gamma115_2(double x) { - return x <= 0.001692 ? x * 2.0 : 1.000508 * exp (log (x) / 1.15) - 0.000508; + return x <= 0.001692 ? x * 2.0 : 1.000508 * exp(log(x) / 1.15) - 0.000508; } - static inline double igamma115_2 (double x) + static inline double igamma115_2(double x) { - return x <= 0.003384 ? x / 2.0 : exp (log ((x + 0.000508) / 1.000508) * 1.15); + return x <= 0.003384 ? x / 2.0 : exp(log((x + 0.000508) / 1.000508) * 1.15); } - static inline double gamma145_3 (double x) + static inline double gamma145_3(double x) { - return x <= 0.009115 ? x * 3.0 : 1.012305 * exp (log (x) / 1.45) - 0.012305; + return x <= 0.009115 ? x * 3.0 : 1.012305 * exp(log(x) / 1.45) - 0.012305; } - static inline double igamma145_3 (double x) + static inline double igamma145_3(double x) { - return x <= 0.027345 ? x / 3.0 : exp (log ((x + 0.012305) / 1.012305) * 1.45); + return x <= 0.027345 ? x / 3.0 : exp(log((x + 0.012305) / 1.012305) * 1.45); } //gamma for Retinex - static inline double gammareti (double x, double gamma, double start, double slope, double mul, double add) + static inline double gammareti(double x, double gamma, double start, double slope, double mul, double add) { - return (x <= start ? x*slope : exp (log (x) / gamma) * mul - add); + return (x <= start ? x*slope : exp(log(x) / gamma) * mul - add); } - static inline double igammareti (double x, double gamma, double start, double slope, double mul, double add) + static inline double igammareti(double x, double gamma, double start, double slope, double mul, double add) { - return (x <= start * slope ? x / slope : exp (log ((x + add) / mul) * gamma) ); + return (x <= start * slope ? x / slope : exp(log((x + add) / mul) * gamma)); } @@ -1123,22 +1123,22 @@ public: // gamma function with adjustable parameters //same as above with values calculate with Calcgamma above // X range 0..1 - static inline double gamma (double x, double gamma, double start, double slope, double mul, double add) + static inline double gamma(double x, double gamma, double start, double slope, double mul, double add) { - return (x <= start ? x*slope : exp (log (x) / gamma) * mul - add); + return (x <= start ? x*slope : exp(log(x) / gamma) * mul - add); } - static inline float gammaf (float x, float gamma, float start, float slope) + static inline float gammaf(float x, float gamma, float start, float slope) { - return x <= start ? x * slope : xexpf (xlogf (x) / gamma); + return x <= start ? x * slope : xexpf(xlogf(x) / gamma); } //fills a LUT of size 65536 using gamma with slope... - static void gammaf2lut (LUTf &gammacurve, float gamma, float start, float slope, float divisor, float factor); + static void gammaf2lut(LUTf &gammacurve, float gamma, float start, float slope, float divisor, float factor); - static inline double igamma (double x, double gamma, double start, double slope, double mul, double add) + static inline double igamma(double x, double gamma, double start, double slope, double mul, double add) { - return (x <= start * slope ? x / slope : exp (log ((x + add) / mul) * gamma) ); + return (x <= start * slope ? x / slope : exp(log((x + add) / mul) * gamma)); } @@ -1148,9 +1148,9 @@ public: * @param gamma gamma value [1 ; 5] * @return the gamma modified's value [0 ; 1] */ - static inline double gamman (double x, double gamma) //standard gamma without slope... + static inline double gamman(double x, double gamma) //standard gamma without slope... { - return exp (log (x) / gamma); + return exp(log(x) / gamma); } /** @@ -1159,12 +1159,12 @@ public: * @param gamma gamma value [1 ; 5] * @return the gamma modified's value [0 ; 1] */ - static inline float gammanf (float x, float gamma) //standard gamma without slope... + static inline float gammanf(float x, float gamma) //standard gamma without slope... { - return xexpf (xlogf (x) / gamma); + return xexpf(xlogf(x) / gamma); } //fills a LUT of size 65536 using gamma without slope... - static void gammanf2lut (LUTf &gammacurve, float gamma, float divisor, float factor); + static void gammanf2lut(LUTf &gammacurve, float gamma, float divisor, float factor); /** * @brief Very simply inverse gamma @@ -1172,9 +1172,9 @@ public: * @param gamma gamma value [1 ; 5] * @return the inverse gamma modified's value [0 ; 1] */ - static inline double igamman (double x, double gamma) //standard inverse gamma without slope... + static inline double igamman(double x, double gamma) //standard inverse gamma without slope... { - return exp (log (x) * gamma); + return exp(log(x) * gamma); } @@ -1186,48 +1186,48 @@ public: * @param x [0 ; 1] * @return the gamma modified's value [0 ; 65535] */ - static inline float gamma_srgb (char x) + static inline float gamma_srgb(char x) { return gammatab_srgb[x]; } - static inline float gamma_srgb327 (char x) + static inline float gamma_srgb327(char x) { return gammatab_srgb327[x]; } - static inline float gamma (char x) + static inline float gamma(char x) { return gammatab[x]; } - static inline float igamma_srgb (char x) + static inline float igamma_srgb(char x) { return igammatab_srgb[x]; } - static inline float gamma_srgb (int x) + static inline float gamma_srgb(int x) { return gammatab_srgb[x]; } - static inline float gamma (int x) + static inline float gamma(int x) { return gammatab[x]; } - static inline float igamma_srgb (int x) + static inline float igamma_srgb(int x) { return igammatab_srgb[x]; } - static inline float gamma_srgb (float x) + static inline float gamma_srgb(float x) { return gammatab_srgb[x]; } - static inline float gamma_srgbclipped (float x) + static inline float gamma_srgbclipped(float x) { return gamma2curve[x]; } - static inline float gamma (float x) + static inline float gamma(float x) { return gammatab[x]; } - static inline float igamma_srgb (float x) + static inline float igamma_srgb(float x) { return igammatab_srgb[x]; } @@ -1257,9 +1257,9 @@ public: */ #ifdef _DEBUG - static void AllMunsellLch (bool lumaMuns, float Lprov1, float Loldd, float HH, float Chprov1, float CC, float &correctionHueChroma, float &correctlum, MunsellDebugInfo* munsDbgInfo); + static void AllMunsellLch(bool lumaMuns, float Lprov1, float Loldd, float HH, float Chprov1, float CC, float &correctionHueChroma, float &correctlum, MunsellDebugInfo* munsDbgInfo); #else - static void AllMunsellLch (bool lumaMuns, float Lprov1, float Loldd, float HH, float Chprov1, float CC, float &correctionHueChroma, float &correctlum); + static void AllMunsellLch(bool lumaMuns, float Lprov1, float Loldd, float HH, float Chprov1, float CC, float &correctionHueChroma, float &correctlum); #endif @@ -1285,13 +1285,13 @@ public: * @param moreRGB (Debug target only) to calculate iterations for values >65535 */ #ifdef _DEBUG - static void gamutLchonly (float HH, float &Lprov1, float &Chprov1, float &R, float &G, float &B, const double wip[3][3], const bool isHLEnabled, const float lowerCoef, const float higherCoef, bool &neg, bool &more_rgb); - static void gamutLchonly (float HH, float2 sincosval, float &Lprov1, float &Chprov1, float &R, float &G, float &B, const double wip[3][3], const bool isHLEnabled, const float lowerCoef, const float higherCoef, bool &neg, bool &more_rgb); - static void gamutLchonly (float2 sincosval, float &Lprov1, float &Chprov1, const float wip[3][3], const bool isHLEnabled, const float lowerCoef, const float higherCoef, bool &neg, bool &more_rgb); + static void gamutLchonly(float HH, float &Lprov1, float &Chprov1, float &R, float &G, float &B, const double wip[3][3], const bool isHLEnabled, const float lowerCoef, const float higherCoef, bool &neg, bool &more_rgb); + static void gamutLchonly(float HH, float2 sincosval, float &Lprov1, float &Chprov1, float &R, float &G, float &B, const double wip[3][3], const bool isHLEnabled, const float lowerCoef, const float higherCoef, bool &neg, bool &more_rgb); + static void gamutLchonly(float2 sincosval, float &Lprov1, float &Chprov1, const float wip[3][3], const bool isHLEnabled, const float lowerCoef, const float higherCoef, bool &neg, bool &more_rgb); #else - static void gamutLchonly (float HH, float &Lprov1, float &Chprov1, float &R, float &G, float &B, const double wip[3][3], const bool isHLEnabled, const float lowerCoef, const float higherCoef); - static void gamutLchonly (float HH, float2 sincosval, float &Lprov1, float &Chprov1, float &R, float &G, float &B, const double wip[3][3], const bool isHLEnabled, const float lowerCoef, const float higherCoef); - static void gamutLchonly (float2 sincosval, float &Lprov1, float &Chprov1, const float wip[3][3], const bool isHLEnabled, const float lowerCoef, const float higherCoef); + static void gamutLchonly(float HH, float &Lprov1, float &Chprov1, float &R, float &G, float &B, const double wip[3][3], const bool isHLEnabled, const float lowerCoef, const float higherCoef); + static void gamutLchonly(float HH, float2 sincosval, float &Lprov1, float &Chprov1, float &R, float &G, float &B, const double wip[3][3], const bool isHLEnabled, const float lowerCoef, const float higherCoef); + static void gamutLchonly(float2 sincosval, float &Lprov1, float &Chprov1, const float wip[3][3], const bool isHLEnabled, const float lowerCoef, const float higherCoef); #endif @@ -1316,7 +1316,7 @@ public: * @param wip matrix for working profile * @param multiThread whether to parallelize the loop or not */ - static void LabGamutMunsell (float *labL, float *laba, float *labb, const int N, bool corMunsell, bool lumaMuns, bool isHLEnabled, bool gamut, const double wip[3][3]); + static void LabGamutMunsell(float *labL, float *laba, float *labb, const int N, bool corMunsell, bool lumaMuns, bool isHLEnabled, bool gamut, const double wip[3][3]); /* @@ -1331,7 +1331,7 @@ public: * @param satreduc [0.1 ; 1] (return value) * @param chromx [0 or 1], actually only 0 is used */ - static void SkinSat (float lum, float hue, float chrom, float &satreduc);//jacques Skin color + static void SkinSat(float lum, float hue, float chrom, float &satreduc); //jacques Skin color /** @@ -1346,22 +1346,22 @@ public: * @param zone [1 ; 4] 1=PB correction + sky 2=red yellow correction 3=Green yellow correction 4=Red purple correction * @param correctL true=enable the Luminance correction */ - static void MunsellLch (float lum, float hue, float chrom, float memChprov, float &correction, int zone, float &lbe, bool &correctL);//jacques: Munsell correction + static void MunsellLch(float lum, float hue, float chrom, float memChprov, float &correction, int zone, float &lbe, bool &correctL); //jacques: Munsell correction // -------------------------------- end Munsell - static void scalered ( const float rstprotection, const float param, const float limit, const float HH, const float deltaHH, float &scale, float &scaleext); - static void transitred (const float HH, const float Chprov1, const float dred, const float factorskin, const float protect_red, const float factorskinext, const float deltaHH, const float factorsat, float &factor); - static void skinred ( double J, double h, double sres, double Sp, float dred, float protect_red, int sk, float rstprotection, float ko, double &s); - static void skinredfloat ( float J, float h, float sres, float Sp, float dred, float protect_red, int sk, float rstprotection, float ko, float &s); + static void scalered(const float rstprotection, const float param, const float limit, const float HH, const float deltaHH, float &scale, float &scaleext); + static void transitred(const float HH, const float Chprov1, const float dred, const float factorskin, const float protect_red, const float factorskinext, const float deltaHH, const float factorsat, float &factor); + static void skinred(double J, double h, double sres, double Sp, float dred, float protect_red, int sk, float rstprotection, float ko, double &s); + static void skinredfloat(float J, float h, float sres, float Sp, float dred, float protect_red, int sk, float rstprotection, float ko, float &s); // static void scaleredcdbl ( float skinprot, float param, float limit, float HH, float deltaHH, float &scale,float &scaleext); - static inline void pregamutlab (float lum, float hue, float &chr)//big approximation to limit gamut (Prophoto) before good gamut procedure for locallab chroma, to avoid crash + static inline void pregamutlab(float lum, float hue, float &chr) //big approximation to limit gamut (Prophoto) before good gamut procedure for locallab chroma, to avoid crash { - if (lum >= 95.0f) { - if (hue > 1.5f && hue < 2.f ) { + if (lum >= 95.0f) { + if (hue > 1.5f && hue < 2.f) { chr = 120.f; } else if (hue > 0.7f && hue <= 1.5f) { chr = 60.f; @@ -1369,7 +1369,7 @@ public: chr = 40.f; } } else if (lum > 75.f) { - if (hue > 1.f && hue < 3.14f ) { + if (hue > 1.f && hue < 3.14f) { chr = 130.f; } else if (hue > -0.4f && hue <= 1.f) { chr = 80.f; @@ -1382,20 +1382,20 @@ public: } else if (lum > 35.f) { chr = 100.f; } else if (lum > 20.f) { - if (hue < -1.f && hue > -2.f ) { + if (hue < -1.f && hue > -2.f) { chr = 120.f; } else { chr = 80.f; } } else if (lum > 7.f) { - if (hue < -1.f && hue > -1.8f ) { + if (hue < -1.f && hue > -1.8f) { chr = 120.f; } else { chr = 60.f; } } else { - if (hue < -1.f && hue > -1.6f ) { + if (hue < -1.f && hue > -1.6f) { chr = 80.f; } else { chr = 40.f; @@ -1408,7 +1408,7 @@ public: // } } - static inline void SkinSatCbdl (float lum, float hue, float chrom, float skinprot, float &scale, bool neg, float b_l, float t_l, float t_r) + static inline void SkinSatCbdl(float lum, float hue, float chrom, float skinprot, float &scale, bool neg, float b_l, float t_l, float t_r) { static const float C9 = 8.f, C8 = 15.f, C7 = 12.f, C4 = 7.f, C3 = 5.f, C2 = 5.f, C1 = 5.f; @@ -1418,7 +1418,7 @@ public: // wide area skin color, useful if not accurate colorimetry or if the user has changed hue and saturation, uses explicit facor 0.6 // wide area for transition, uses explicit factor 0.4 - if (lum >= 85.0f) { + if (lum >= 85.0f) { if ((hue > (t_l + 0.53f - H9) && hue < (t_r + H9)) && (chrom > 8.0f && chrom < (14.0f + C9))) { scale = (100.f - skinprot) / 100.1f; } else if (lum >= 92.0f) { @@ -1435,48 +1435,48 @@ public: } else if (lum >= 70.0f) { if ((hue > t_l + 0.15f && hue < (t_r - 0.2f + H8)) && (chrom > 8.0f && chrom < (35.0f + C8))) { scale = (100.f - skinprot) / 100.1f; - } else if ((hue > (b_l + 0.07f + H11) && hue < t_r - 0.2f) && (chrom > 7.0f && chrom < (48.0f + C9) )) { + } else if ((hue > (b_l + 0.07f + H11) && hue < t_r - 0.2f) && (chrom > 7.0f && chrom < (48.0f + C9))) { scale = (100.f - skinprot * 0.6f) / 100.1f; - } else if ((hue > (b_l + 0.07f + H11) && hue < t_r) && (chrom > 7.0f && chrom < (55.0f + C9) )) { + } else if ((hue > (b_l + 0.07f + H11) && hue < t_r) && (chrom > 7.0f && chrom < (55.0f + C9))) { scale = (100.f - skinprot * 0.4f) / 100.1f; } } else if (lum >= 52.0f) { if ((hue > t_l && hue < (t_r + H7)) && (chrom > 11.0f && chrom < (35.0f + C7))) { scale = (100.f - skinprot) / 100.1f; - } else if ((hue > (b_l + 0.07f + H11) && hue < t_r - 0.2f) && (chrom > 7.0f && chrom < (48.0f + C9) )) { + } else if ((hue > (b_l + 0.07f + H11) && hue < t_r - 0.2f) && (chrom > 7.0f && chrom < (48.0f + C9))) { scale = (100.f - skinprot * 0.6f) / 100.1f; - } else if ((hue > (b_l + 0.07f + H11) && hue < t_r) && (chrom > 7.0f && chrom < (55.0f + C9) )) { + } else if ((hue > (b_l + 0.07f + H11) && hue < t_r) && (chrom > 7.0f && chrom < (55.0f + C9))) { scale = (100.f - skinprot * 0.4f) / 100.1f; } } else if (lum >= 35.0f) { - if ((hue > t_l && hue < (t_r + H4)) && (chrom > 13.0f && chrom < (37.0f + C4))) { + if ((hue > t_l && hue < (t_r + H4)) && (chrom > 13.0f && chrom < (37.0f + C4))) { scale = (100.f - skinprot) / 100.1f; - } else if ((hue > (b_l + 0.07f + H11) && hue < t_r - 0.2f) && (chrom > 7.0f && chrom < (48.0f + C9) )) { + } else if ((hue > (b_l + 0.07f + H11) && hue < t_r - 0.2f) && (chrom > 7.0f && chrom < (48.0f + C9))) { scale = (100.f - skinprot * 0.6f) / 100.1f; - } else if ((hue > (b_l + 0.07f + H11) && hue < t_r) && (chrom > 7.0f && chrom < (55.0f + C9) )) { + } else if ((hue > (b_l + 0.07f + H11) && hue < t_r) && (chrom > 7.0f && chrom < (55.0f + C9))) { scale = (100.f - skinprot * 0.4f) / 100.1f; } } else if (lum >= 20.0f) { - if ((hue > t_l && hue < (t_r + H3)) && (chrom > 7.0f && chrom < (35.0f + C3) )) { + if ((hue > t_l && hue < (t_r + H3)) && (chrom > 7.0f && chrom < (35.0f + C3))) { scale = (100.f - skinprot) / 100.1f; - } else if ((hue > (b_l + 0.07f + H11) && hue < t_r - 0.2f) && (chrom > 7.0f && chrom < (48.0f + C9) )) { + } else if ((hue > (b_l + 0.07f + H11) && hue < t_r - 0.2f) && (chrom > 7.0f && chrom < (48.0f + C9))) { scale = (100.f - skinprot * 0.6f) / 100.1f; - } else if ((hue > (b_l + 0.07f + H11) && hue < t_r) && (chrom > 7.0f && chrom < (55.0f + C9) )) { + } else if ((hue > (b_l + 0.07f + H11) && hue < t_r) && (chrom > 7.0f && chrom < (55.0f + C9))) { scale = (100.f - skinprot * 0.4f) / 100.1f; } } else if (lum >= 10.0f) { if ((hue > (t_l - 0.25f + H10) && hue < (t_r - 0.3f + H2)) && (chrom > 8.0f && chrom < (23.0f + C2))) { scale = (100.f - skinprot) / 100.1f; - } else if ((hue > (b_l + 0.07f + H11) && hue < t_r - 0.2f) && (chrom > 7.0f && chrom < (35.0f + C1) )) { + } else if ((hue > (b_l + 0.07f + H11) && hue < t_r - 0.2f) && (chrom > 7.0f && chrom < (35.0f + C1))) { scale = (100.f - skinprot * 0.6f) / 100.1f; - } else if ((hue > (b_l + 0.07f + H11) && hue < t_r - 0.1f) && (chrom > 7.0f && chrom < (45.0f + C1) )) { + } else if ((hue > (b_l + 0.07f + H11) && hue < t_r - 0.1f) && (chrom > 7.0f && chrom < (45.0f + C1))) { scale = (100.f - skinprot * 0.4f) / 100.1f; } } else if ((hue > (t_l - 0.2f + H10) && hue < (t_r - 0.3f + H1)) && (chrom > 8.0f && chrom < (23.0f + C1))) { scale = (100.f - skinprot) / 100.1f; - } else if ((hue > (b_l + 0.07f + H11) && hue < t_r - 0.2f) && (chrom > 7.0f && chrom < (35.0f + C1) )) { + } else if ((hue > (b_l + 0.07f + H11) && hue < t_r - 0.2f) && (chrom > 7.0f && chrom < (35.0f + C1))) { scale = (100.f - skinprot * 0.6f) / 100.1f; - } else if ((hue > (b_l + 0.07f + H11) && hue < t_r - 0.1f) && (chrom > 7.0f && chrom < (45.0f + C1) )) { + } else if ((hue > (b_l + 0.07f + H11) && hue < t_r - 0.1f) && (chrom > 7.0f && chrom < (45.0f + C1))) { scale = (100.f - skinprot * 0.4f) / 100.1f; } @@ -1487,7 +1487,7 @@ public: } } - static inline void SkinSatCbdl2 (float lum, float hue, float chrom, float skinprot, float &scale, bool neg, float b_l, float t_l, float t_r, float b_r, int basc) + static inline void SkinSatCbdl2(float lum, float hue, float chrom, float skinprot, float &scale, bool neg, float b_l, float t_l, float t_r, float b_r, int basc) { static const float C9 = 8.f, C8 = 15.f, C7 = 12.f, C4 = 7.f, C3 = 5.f, C2 = 5.f, C1 = 5.f; @@ -1497,7 +1497,7 @@ public: // wide area skin color, useful if not accurate colorimetry or if the user has changed hue and saturation, uses explicit facor 0.6 // wide area for transition, uses explicit factor 0.4 if ((b_l > -0.3f && b_r < 2.f) || basc == 0) { //range maxi skin - if (lum >= 85.0f) { + if (lum >= 85.0f) { if ((hue > (t_l + 0.53f - H9) && hue < (t_r + H9)) && (chrom > 8.0f && chrom < (14.0f + C9))) { scale = (100.f - skinprot) / 100.1f; } else if (lum >= 92.0f) { @@ -1514,48 +1514,48 @@ public: } else if (lum >= 70.0f) { if ((hue > t_l + 0.15f && hue < (t_r - 0.2f + H8)) && (chrom > 8.0f && chrom < (35.0f + C8))) { scale = (100.f - skinprot) / 100.1f; - } else if ((hue > (b_l + 0.07f + H11) && hue < t_r - 0.2f) && (chrom > 7.0f && chrom < (48.0f + C9) )) { + } else if ((hue > (b_l + 0.07f + H11) && hue < t_r - 0.2f) && (chrom > 7.0f && chrom < (48.0f + C9))) { scale = (100.f - skinprot * 0.6f) / 100.1f; - } else if ((hue > (b_l + 0.07f + H11) && hue < t_r) && (chrom > 7.0f && chrom < (55.0f + C9) )) { + } else if ((hue > (b_l + 0.07f + H11) && hue < t_r) && (chrom > 7.0f && chrom < (55.0f + C9))) { scale = (100.f - skinprot * 0.4f) / 100.1f; } } else if (lum >= 52.0f) { if ((hue > t_l && hue < (t_r + H7)) && (chrom > 11.0f && chrom < (35.0f + C7))) { scale = (100.f - skinprot) / 100.1f; - } else if ((hue > (b_l + 0.07f + H11) && hue < t_r - 0.2f) && (chrom > 7.0f && chrom < (48.0f + C9) )) { + } else if ((hue > (b_l + 0.07f + H11) && hue < t_r - 0.2f) && (chrom > 7.0f && chrom < (48.0f + C9))) { scale = (100.f - skinprot * 0.6f) / 100.1f; - } else if ((hue > (b_l + 0.07f + H11) && hue < t_r) && (chrom > 7.0f && chrom < (55.0f + C9) )) { + } else if ((hue > (b_l + 0.07f + H11) && hue < t_r) && (chrom > 7.0f && chrom < (55.0f + C9))) { scale = (100.f - skinprot * 0.4f) / 100.1f; } } else if (lum >= 35.0f) { - if ((hue > t_l && hue < (t_r + H4)) && (chrom > 13.0f && chrom < (37.0f + C4))) { + if ((hue > t_l && hue < (t_r + H4)) && (chrom > 13.0f && chrom < (37.0f + C4))) { scale = (100.f - skinprot) / 100.1f; - } else if ((hue > (b_l + 0.07f + H11) && hue < t_r - 0.2f) && (chrom > 7.0f && chrom < (48.0f + C9) )) { + } else if ((hue > (b_l + 0.07f + H11) && hue < t_r - 0.2f) && (chrom > 7.0f && chrom < (48.0f + C9))) { scale = (100.f - skinprot * 0.6f) / 100.1f; - } else if ((hue > (b_l + 0.07f + H11) && hue < t_r) && (chrom > 7.0f && chrom < (55.0f + C9) )) { + } else if ((hue > (b_l + 0.07f + H11) && hue < t_r) && (chrom > 7.0f && chrom < (55.0f + C9))) { scale = (100.f - skinprot * 0.4f) / 100.1f; } } else if (lum >= 20.0f) { - if ((hue > t_l && hue < (t_r + H3)) && (chrom > 7.0f && chrom < (35.0f + C3) )) { + if ((hue > t_l && hue < (t_r + H3)) && (chrom > 7.0f && chrom < (35.0f + C3))) { scale = (100.f - skinprot) / 100.1f; - } else if ((hue > (b_l + 0.07f + H11) && hue < t_r - 0.2f) && (chrom > 7.0f && chrom < (48.0f + C9) )) { + } else if ((hue > (b_l + 0.07f + H11) && hue < t_r - 0.2f) && (chrom > 7.0f && chrom < (48.0f + C9))) { scale = (100.f - skinprot * 0.6f) / 100.1f; - } else if ((hue > (b_l + 0.07f + H11) && hue < t_r) && (chrom > 7.0f && chrom < (55.0f + C9) )) { + } else if ((hue > (b_l + 0.07f + H11) && hue < t_r) && (chrom > 7.0f && chrom < (55.0f + C9))) { scale = (100.f - skinprot * 0.4f) / 100.1f; } } else if (lum >= 10.0f) { if ((hue > (t_l - 0.25f + H10) && hue < (t_r - 0.3f + H2)) && (chrom > 8.0f && chrom < (23.0f + C2))) { scale = (100.f - skinprot) / 100.1f; - } else if ((hue > (b_l + 0.07f + H11) && hue < t_r - 0.2f) && (chrom > 7.0f && chrom < (35.0f + C1) )) { + } else if ((hue > (b_l + 0.07f + H11) && hue < t_r - 0.2f) && (chrom > 7.0f && chrom < (35.0f + C1))) { scale = (100.f - skinprot * 0.6f) / 100.1f; - } else if ((hue > (b_l + 0.07f + H11) && hue < t_r - 0.1f) && (chrom > 7.0f && chrom < (45.0f + C1) )) { + } else if ((hue > (b_l + 0.07f + H11) && hue < t_r - 0.1f) && (chrom > 7.0f && chrom < (45.0f + C1))) { scale = (100.f - skinprot * 0.4f) / 100.1f; } } else if ((hue > (t_l - 0.2f + H10) && hue < (t_r - 0.3f + H1)) && (chrom > 8.0f && chrom < (23.0f + C1))) { scale = (100.f - skinprot) / 100.1f; - } else if ((hue > (b_l + 0.07f + H11) && hue < t_r - 0.2f) && (chrom > 7.0f && chrom < (35.0f + C1) )) { + } else if ((hue > (b_l + 0.07f + H11) && hue < t_r - 0.2f) && (chrom > 7.0f && chrom < (35.0f + C1))) { scale = (100.f - skinprot * 0.6f) / 100.1f; - } else if ((hue > (b_l + 0.07f + H11) && hue < t_r - 0.1f) && (chrom > 7.0f && chrom < (45.0f + C1) )) { + } else if ((hue > (b_l + 0.07f + H11) && hue < t_r - 0.1f) && (chrom > 7.0f && chrom < (45.0f + C1))) { scale = (100.f - skinprot * 0.4f) / 100.1f; } @@ -1585,7 +1585,7 @@ public: - static inline void SkinSatCbdlCam (float lum, float hue, float chrom, float skinprot, float &scale, bool neg, float b_l, float t_l, float t_r) + static inline void SkinSatCbdlCam(float lum, float hue, float chrom, float skinprot, float &scale, bool neg, float b_l, float t_l, float t_r) { static const float C9 = 8.f, C8 = 15.f, C7 = 12.f, C4 = 7.f, C3 = 5.f, C2 = 5.f, C1 = 5.f; @@ -1593,13 +1593,13 @@ public: float HH = 0.f; - if (hue > 8.6f && hue <= 74.f ) { + if (hue > 8.6f && hue <= 74.f) { HH = (1.15f / 65.4f) * hue - 0.0012f; //H > 0.15 H<1.3 - } else if (hue > 0.f && hue <= 8.6f ) { - HH = (0.19f / 8.6f ) * hue - 0.04f; //H>-0.04 H < 0.15 + } else if (hue > 0.f && hue <= 8.6f) { + HH = (0.19f / 8.6f) * hue - 0.04f; //H>-0.04 H < 0.15 } else if (hue > 355.f && hue <= 360.f) { - HH = (0.11f / 5.0f ) * hue - 7.96f; //H>-0.15 <-0.04 - } else if (hue > 74.f && hue < 95.f ) { + HH = (0.11f / 5.0f) * hue - 7.96f; //H>-0.15 <-0.04 + } else if (hue > 74.f && hue < 95.f) { HH = (0.30f / 21.0f) * hue + 0.24285f; //H>1.3 H<1.6 } else if (hue >= 95.f && hue < 137.5f) { HH = 0.01882f * hue - 0.18823f; // H>1.6 H<2.4 @@ -1613,7 +1613,7 @@ public: // wide area skin color, useful if not accurate colorimetry or if the user has changed hue and saturation, uses explicit facor 0.6 // wide area for transition, uses explicit factor 0.4 - if (lum >= 85.0f) { + if (lum >= 85.0f) { if ((hue > (t_l + 0.53f - H9) && hue < (t_r + H9)) && (chrom > 8.0f && chrom < (14.0f + C9))) { scale = (100.f - skinprot) / 100.1f; } else if (lum >= 92.0f) { @@ -1630,48 +1630,48 @@ public: } else if (lum >= 70.0f) { if ((hue > t_l + 0.15f && hue < (t_r - 0.2f + H8)) && (chrom > 8.0f && chrom < (35.0f + C8))) { scale = (100.f - skinprot) / 100.1f; - } else if ((hue > (b_l + 0.07f + H11) && hue < t_r - 0.2f) && (chrom > 7.0f && chrom < (48.0f + C9) )) { + } else if ((hue > (b_l + 0.07f + H11) && hue < t_r - 0.2f) && (chrom > 7.0f && chrom < (48.0f + C9))) { scale = (100.f - skinprot * 0.6f) / 100.1f; - } else if ((hue > (b_l + 0.07f + H11) && hue < t_r) && (chrom > 7.0f && chrom < (55.0f + C9) )) { + } else if ((hue > (b_l + 0.07f + H11) && hue < t_r) && (chrom > 7.0f && chrom < (55.0f + C9))) { scale = (100.f - skinprot * 0.4f) / 100.1f; } } else if (lum >= 52.0f) { if ((hue > t_l && hue < (t_r + H7)) && (chrom > 11.0f && chrom < (35.0f + C7))) { scale = (100.f - skinprot) / 100.1f; - } else if ((hue > (b_l + 0.07f + H11) && hue < t_r - 0.2f) && (chrom > 7.0f && chrom < (48.0f + C9) )) { + } else if ((hue > (b_l + 0.07f + H11) && hue < t_r - 0.2f) && (chrom > 7.0f && chrom < (48.0f + C9))) { scale = (100.f - skinprot * 0.6f) / 100.1f; - } else if ((hue > (b_l + 0.07f + H11) && hue < t_r) && (chrom > 7.0f && chrom < (55.0f + C9) )) { + } else if ((hue > (b_l + 0.07f + H11) && hue < t_r) && (chrom > 7.0f && chrom < (55.0f + C9))) { scale = (100.f - skinprot * 0.4f) / 100.1f; } } else if (lum >= 35.0f) { - if ((hue > t_l && hue < (t_r + H4)) && (chrom > 13.0f && chrom < (37.0f + C4))) { + if ((hue > t_l && hue < (t_r + H4)) && (chrom > 13.0f && chrom < (37.0f + C4))) { scale = (100.f - skinprot) / 100.1f; - } else if ((hue > (b_l + 0.07f + H11) && hue < t_r - 0.2f) && (chrom > 7.0f && chrom < (48.0f + C9) )) { + } else if ((hue > (b_l + 0.07f + H11) && hue < t_r - 0.2f) && (chrom > 7.0f && chrom < (48.0f + C9))) { scale = (100.f - skinprot * 0.6f) / 100.1f; - } else if ((hue > (b_l + 0.07f + H11) && hue < t_r) && (chrom > 7.0f && chrom < (55.0f + C9) )) { + } else if ((hue > (b_l + 0.07f + H11) && hue < t_r) && (chrom > 7.0f && chrom < (55.0f + C9))) { scale = (100.f - skinprot * 0.4f) / 100.1f; } } else if (lum >= 20.0f) { - if ((hue > t_l && hue < (t_r + H3)) && (chrom > 7.0f && chrom < (35.0f + C3) )) { + if ((hue > t_l && hue < (t_r + H3)) && (chrom > 7.0f && chrom < (35.0f + C3))) { scale = (100.f - skinprot) / 100.1f; - } else if ((hue > (b_l + 0.07f + H11) && hue < t_r - 0.2f) && (chrom > 7.0f && chrom < (48.0f + C9) )) { + } else if ((hue > (b_l + 0.07f + H11) && hue < t_r - 0.2f) && (chrom > 7.0f && chrom < (48.0f + C9))) { scale = (100.f - skinprot * 0.6f) / 100.1f; - } else if ((hue > (b_l + 0.07f + H11) && hue < t_r) && (chrom > 7.0f && chrom < (55.0f + C9) )) { + } else if ((hue > (b_l + 0.07f + H11) && hue < t_r) && (chrom > 7.0f && chrom < (55.0f + C9))) { scale = (100.f - skinprot * 0.4f) / 100.1f; } } else if (lum >= 10.0f) { if ((hue > (t_l - 0.25f + H10) && hue < (t_r - 0.3f + H2)) && (chrom > 8.0f && chrom < (23.0f + C2))) { scale = (100.f - skinprot) / 100.1f; - } else if ((hue > (b_l + 0.07f + H11) && hue < t_r - 0.2f) && (chrom > 7.0f && chrom < (35.0f + C1) )) { + } else if ((hue > (b_l + 0.07f + H11) && hue < t_r - 0.2f) && (chrom > 7.0f && chrom < (35.0f + C1))) { scale = (100.f - skinprot * 0.6f) / 100.1f; - } else if ((hue > (b_l + 0.07f + H11) && hue < t_r - 0.1f) && (chrom > 7.0f && chrom < (45.0f + C1) )) { + } else if ((hue > (b_l + 0.07f + H11) && hue < t_r - 0.1f) && (chrom > 7.0f && chrom < (45.0f + C1))) { scale = (100.f - skinprot * 0.4f) / 100.1f; } } else if ((hue > (t_l - 0.2f + H10) && hue < (t_r - 0.3f + H1)) && (chrom > 8.0f && chrom < (23.0f + C1))) { scale = (100.f - skinprot) / 100.1f; - } else if ((hue > (b_l + 0.07f + H11) && hue < t_r - 0.2f) && (chrom > 7.0f && chrom < (35.0f + C1) )) { + } else if ((hue > (b_l + 0.07f + H11) && hue < t_r - 0.2f) && (chrom > 7.0f && chrom < (35.0f + C1))) { scale = (100.f - skinprot * 0.6f) / 100.1f; - } else if ((hue > (b_l + 0.07f + H11) && hue < t_r - 0.1f) && (chrom > 7.0f && chrom < (45.0f + C1) )) { + } else if ((hue > (b_l + 0.07f + H11) && hue < t_r - 0.1f) && (chrom > 7.0f && chrom < (45.0f + C1))) { scale = (100.f - skinprot * 0.4f) / 100.1f; } @@ -1690,7 +1690,7 @@ public: * @param Z Z channel input value and corrected output value [0 ; 65535] * @param p working profile */ - static void gamutmap (float &X, float &Y, float &Z, const double p[3][3]); + static void gamutmap(float &X, float &Y, float &Z, const double p[3][3]); /** @@ -1698,35 +1698,35 @@ public: * @param HH Lab's hue value, in radians [-PI ; +PI] * @return HSV's hue value [0 ; 1] */ - static inline double huelab_to_huehsv2 (float HH) + static inline double huelab_to_huehsv2(float HH) { //hr=translate Hue Lab value (-Pi +Pi) in approximative hr (hsv values) (0 1) [red 1/6 yellow 1/6 green 1/6 cyan 1/6 blue 1/6 magenta 1/6 ] // with multi linear correspondances (I expect there is no error !!) double hr = 0.0; //allways put h between 0 and 1 - if (HH >= 0.f && HH < 0.6f ) { + if (HH >= 0.f && HH < 0.6f) { hr = 0.11666 * double (HH) + 0.93; //hr 0.93 1.00 full red - } else if (HH >= 0.6f && HH < 1.4f ) { + } else if (HH >= 0.6f && HH < 1.4f) { hr = 0.1125 * double (HH) - 0.0675; //hr 0.00 0.09 red yellow orange - } else if (HH >= 1.4f && HH < 2.f ) { + } else if (HH >= 1.4f && HH < 2.f) { hr = 0.2666 * double (HH) - 0.2833; //hr 0.09 0.25 orange yellow } else if (HH >= 2.f && HH < 3.14159f) { hr = 0.1489 * double (HH) - 0.04785; //hr 0.25 0.42 yellow green green - } else if (HH >= -3.14159f && HH < -2.8f ) { + } else if (HH >= -3.14159f && HH < -2.8f) { hr = 0.23419 * double (HH) + 1.1557; //hr 0.42 0.50 green - } else if (HH >= -2.8f && HH < -2.3f ) { + } else if (HH >= -2.8f && HH < -2.3f) { hr = 0.16 * double (HH) + 0.948; //hr 0.50 0.58 cyan - } else if (HH >= -2.3f && HH < -0.9f ) { + } else if (HH >= -2.3f && HH < -0.9f) { hr = 0.12143 * double (HH) + 0.85928; //hr 0.58 0.75 blue blue-sky - } else if (HH >= -0.9f && HH < -0.1f ) { + } else if (HH >= -0.9f && HH < -0.1f) { hr = 0.2125 * double (HH) + 0.94125; //hr 0.75 0.92 purple magenta - } else if (HH >= -0.1f && HH < 0.f ) { + } else if (HH >= -0.1f && HH < 0.f) { hr = 0.1 * double (HH) + 0.93; //hr 0.92 0.93 red } // in case of ! - if (hr < 0.0) { + if (hr < 0.0) { hr += 1.0; } else if (hr > 1.0) { hr -= 1.0; diff --git a/rtengine/curves.cc b/rtengine/curves.cc index 84f1ec46e..f798fb198 100644 --- a/rtengine/curves.cc +++ b/rtengine/curves.cc @@ -44,13 +44,13 @@ using namespace std; namespace rtengine { -Curve::Curve () : N (0), ppn (0), x (nullptr), y (nullptr), mc (0.0), mfc (0.0), msc (0.0), mhc (0.0), hashSize (1000 /* has to be initialized to the maximum value */), ypp (nullptr), x1 (0.0), y1 (0.0), x2 (0.0), y2 (0.0), x3 (0.0), y3 (0.0), firstPointIncluded (false), increment (0.0), nbr_points (0) {} +Curve::Curve() : N(0), ppn(0), x(nullptr), y(nullptr), mc(0.0), mfc(0.0), msc(0.0), mhc(0.0), hashSize(1000 /* has to be initialized to the maximum value */), ypp(nullptr), x1(0.0), y1(0.0), x2(0.0), y2(0.0), x3(0.0), y3(0.0), firstPointIncluded(false), increment(0.0), nbr_points(0) {} -void Curve::AddPolygons () +void Curve::AddPolygons() { if (firstPointIncluded) { - poly_x.push_back (x1); - poly_y.push_back (y1); + poly_x.push_back(x1); + poly_y.push_back(y1); } for (int k = 1; k < (nbr_points - 1); k++) { @@ -61,18 +61,18 @@ void Curve::AddPolygons () double tr2t = tr * 2 * t; // adding a point to the polyline - poly_x.push_back ( tr2 * x1 + tr2t * x2 + t2 * x3); - poly_y.push_back ( tr2 * y1 + tr2t * y2 + t2 * y3); + poly_x.push_back(tr2 * x1 + tr2t * x2 + t2 * x3); + poly_y.push_back(tr2 * y1 + tr2t * y2 + t2 * y3); } // adding the last point of the sub-curve - poly_x.push_back (x3); - poly_y.push_back (y3); + poly_x.push_back(x3); + poly_y.push_back(y3); } -void Curve::fillDyByDx () +void Curve::fillDyByDx() { - dyByDx.resize (poly_x.size() - 1); + dyByDx.resize(poly_x.size() - 1); for (unsigned int i = 0; i < poly_x.size() - 1; i++) { double dx = poly_x[i + 1] - poly_x[i]; @@ -84,7 +84,7 @@ void Curve::fillDyByDx () void Curve::fillHash() { - hash.resize (hashSize + 2); + hash.resize(hashSize + 2); unsigned int polyIter = 0; double const increment = 1. / hashSize; @@ -95,7 +95,7 @@ void Curve::fillHash() ++polyIter; } - hash.at (i).smallerValue = polyIter - 1; + hash.at(i).smallerValue = polyIter - 1; ++i; milestone = i * increment; } @@ -108,13 +108,13 @@ void Curve::fillHash() ++polyIter; } - hash.at (i).higherValue = polyIter; + hash.at(i).higherValue = polyIter; ++i; milestone = i * increment; } - hash.at (hashSize + 1).smallerValue = poly_x.size() - 1; - hash.at (hashSize + 1).higherValue = poly_x.size(); + hash.at(hashSize + 1).smallerValue = poly_x.size() - 1; + hash.at(hashSize + 1).higherValue = poly_x.size(); /* * Uncoment the code below to dump the polygon points and the hash table in files @@ -141,7 +141,7 @@ void Curve::fillHash() * This method return the number of control points of a curve. Not suitable for parametric curves. * @return number of control points of the curve. 0 will be sent back for Parametric curves */ -int Curve::getSize () const +int Curve::getSize() const { return N; } @@ -152,7 +152,7 @@ int Curve::getSize () const * @param x Y value of the control points, or -1 if invalid * @param y Y value of the control points, or -1 if invalid */ -void Curve::getControlPoint (int cpNum, double &x, double &y) const +void Curve::getControlPoint(int cpNum, double &x, double &y) const { if (this->x && cpNum < N) { x = this->x[cpNum]; @@ -168,15 +168,15 @@ void Curve::getControlPoint (int cpNum, double &x, double &y) const const double CurveFactory::sRGBGamma = 2.2; const double CurveFactory::sRGBGammaCurve = 2.4; -void fillCurveArray (DiagonalCurve* diagCurve, LUTf &outCurve, int skip, bool needed) +void fillCurveArray(DiagonalCurve* diagCurve, LUTf &outCurve, int skip, bool needed) { if (needed) { - for (int i = 0; i <= 0xffff; i += i < 0xffff - skip ? skip : 1 ) { + for (int i = 0; i <= 0xffff; i += i < 0xffff - skip ? skip : 1) { // change to [0,1] range float val = (float)i / 65535.f; // apply custom/parametric/NURBS curve, if any - val = diagCurve->getVal (val); + val = diagCurve->getVal(val); // store result in a temporary array outCurve[i] = val; } @@ -187,7 +187,7 @@ void fillCurveArray (DiagonalCurve* diagCurve, LUTf &outCurve, int skip, bool ne for (int i = 0; i <= 0x10000 - skip; i += skip) { for (int j = 1; j < skip; j++) { - outCurve[i + j] = ( outCurve[i] * (skip - j) + outCurve[i + skip] * j ) * skipmul; + outCurve[i + j] = (outCurve[i] * (skip - j) + outCurve[i + skip] * j) * skipmul; } } } @@ -198,7 +198,7 @@ void fillCurveArray (DiagonalCurve* diagCurve, LUTf &outCurve, int skip, bool ne } } -void CurveFactory::curveLightBrightColor (const std::vector& curvePoints1, const std::vector& curvePoints2, const std::vector& curvePoints3, +void CurveFactory::curveLightBrightColor(const std::vector& curvePoints1, const std::vector& curvePoints2, const std::vector& curvePoints3, const LUTu & histogram, LUTu & outBeforeCCurveHistogram,//for Luminance const LUTu & histogramC, LUTu & outBeforeCCurveHistogramC,//for chroma ColorAppearance & customColCurve1, ColorAppearance & customColCurve2, ColorAppearance & customColCurve3, int skip) @@ -210,14 +210,14 @@ void CurveFactory::curveLightBrightColor (const std::vector& curvePoints customColCurve3.Reset(); if (!curvePoints3.empty() && curvePoints3[0] > DCT_Linear && curvePoints3[0] < DCT_Unchanged) { - DiagonalCurve tcurve (curvePoints3, CURVES_MIN_POLY_POINTS / skip); + DiagonalCurve tcurve(curvePoints3, CURVES_MIN_POLY_POINTS / skip); if (outBeforeCCurveHistogramC) { - histogramC.compressTo (outBeforeCCurveHistogramC, 48000); + histogramC.compressTo(outBeforeCCurveHistogramC, 48000); } if (!tcurve.isIdentity()) { - customColCurve3.Set (tcurve); + customColCurve3.Set(tcurve); } } @@ -225,14 +225,14 @@ void CurveFactory::curveLightBrightColor (const std::vector& curvePoints customColCurve2.Reset(); if (!curvePoints2.empty() && curvePoints2[0] > DCT_Linear && curvePoints2[0] < DCT_Unchanged) { - DiagonalCurve tcurve (curvePoints2, CURVES_MIN_POLY_POINTS / skip); + DiagonalCurve tcurve(curvePoints2, CURVES_MIN_POLY_POINTS / skip); if (outBeforeCCurveHistogram) { histNeeded = true; } if (!tcurve.isIdentity()) { - customColCurve2.Set (tcurve); + customColCurve2.Set(tcurve); } } @@ -241,25 +241,25 @@ void CurveFactory::curveLightBrightColor (const std::vector& curvePoints customColCurve1.Reset(); if (!curvePoints1.empty() && curvePoints1[0] > DCT_Linear && curvePoints1[0] < DCT_Unchanged) { - DiagonalCurve tcurve (curvePoints1, CURVES_MIN_POLY_POINTS / skip); + DiagonalCurve tcurve(curvePoints1, CURVES_MIN_POLY_POINTS / skip); if (outBeforeCCurveHistogram) { histNeeded = true; } if (!tcurve.isIdentity()) { - customColCurve1.Set (tcurve); + customColCurve1.Set(tcurve); } } if (histNeeded) { - histogram.compressTo (outBeforeCCurveHistogram, 32768); + histogram.compressTo(outBeforeCCurveHistogram, 32768); } } -void CurveFactory::curveBW ( const std::vector& curvePointsbw, const std::vector& curvePointsbw2, - const LUTu & histogrambw, LUTu & outBeforeCCurveHistogrambw,//for Luminance - ToneCurve & customToneCurvebw1, ToneCurve & customToneCurvebw2, int skip) +void CurveFactory::curveBW(const std::vector& curvePointsbw, const std::vector& curvePointsbw2, + const LUTu & histogrambw, LUTu & outBeforeCCurveHistogrambw,//for Luminance + ToneCurve & customToneCurvebw1, ToneCurve & customToneCurvebw2, int skip) { const float gamma_ = Color::sRGBGammaCurve; @@ -270,14 +270,14 @@ void CurveFactory::curveBW ( const std::vector& curvePointsbw, const std customToneCurvebw2.Reset(); if (!curvePointsbw2.empty() && curvePointsbw2[0] > DCT_Linear && curvePointsbw2[0] < DCT_Unchanged) { - DiagonalCurve tcurve (curvePointsbw2, CURVES_MIN_POLY_POINTS / skip); + DiagonalCurve tcurve(curvePointsbw2, CURVES_MIN_POLY_POINTS / skip); if (outBeforeCCurveHistogrambw) { histNeeded = true; } if (!tcurve.isIdentity()) { - customToneCurvebw2.Set (tcurve, gamma_); + customToneCurvebw2.Set(tcurve, gamma_); } } @@ -285,42 +285,42 @@ void CurveFactory::curveBW ( const std::vector& curvePointsbw, const std customToneCurvebw1.Reset(); if (!curvePointsbw.empty() && curvePointsbw[0] > DCT_Linear && curvePointsbw[0] < DCT_Unchanged) { - DiagonalCurve tcurve (curvePointsbw, CURVES_MIN_POLY_POINTS / skip); + DiagonalCurve tcurve(curvePointsbw, CURVES_MIN_POLY_POINTS / skip); - if (outBeforeCCurveHistogrambw ) { + if (outBeforeCCurveHistogrambw) { histNeeded = true; } if (!tcurve.isIdentity()) { - customToneCurvebw1.Set (tcurve, gamma_); + customToneCurvebw1.Set(tcurve, gamma_); } } // create first curve if needed if (histNeeded) { - histogrambw.compressTo (outBeforeCCurveHistogrambw, 32768); + histogrambw.compressTo(outBeforeCCurveHistogrambw, 32768); } } // add curve Lab : C=f(L) -void CurveFactory::curveCL ( bool & clcutili, const std::vector& clcurvePoints, LUTf & clCurve, int skip) +void CurveFactory::curveCL(bool & clcutili, const std::vector& clcurvePoints, LUTf & clCurve, int skip) { clcutili = false; std::unique_ptr dCurve; if (!clcurvePoints.empty() && clcurvePoints[0] != 0) { - dCurve = std::unique_ptr (new DiagonalCurve (clcurvePoints, CURVES_MIN_POLY_POINTS / skip)); + dCurve = std::unique_ptr (new DiagonalCurve(clcurvePoints, CURVES_MIN_POLY_POINTS / skip)); if (dCurve && !dCurve->isIdentity()) { clcutili = true; } } - fillCurveArray (dCurve.get(), clCurve, skip, clcutili); + fillCurveArray(dCurve.get(), clCurve, skip, clcutili); } -void CurveFactory::mapcurve ( bool & mapcontlutili, const std::vector& mapcurvePoints, LUTf & mapcurve, int skip, const LUTu & histogram, LUTu & outBeforeCurveHistogram) +void CurveFactory::mapcurve(bool & mapcontlutili, const std::vector& mapcurvePoints, LUTf & mapcurve, int skip, const LUTu & histogram, LUTu & outBeforeCurveHistogram) { bool needed = false; std::unique_ptr dCurve; @@ -328,7 +328,7 @@ void CurveFactory::mapcurve ( bool & mapcontlutili, const std::vector& m bool histNeeded = false; if (!mapcurvePoints.empty() && mapcurvePoints[0] != 0) { - dCurve = std::unique_ptr (new DiagonalCurve (mapcurvePoints, CURVES_MIN_POLY_POINTS / skip)); + dCurve = std::unique_ptr (new DiagonalCurve(mapcurvePoints, CURVES_MIN_POLY_POINTS / skip)); if (outBeforeCurveHistogram) { histNeeded = true; @@ -341,13 +341,13 @@ void CurveFactory::mapcurve ( bool & mapcontlutili, const std::vector& m } if (histNeeded) { - histogram.compressTo (outBeforeCurveHistogram, 32768); + histogram.compressTo(outBeforeCurveHistogram, 32768); } - fillCurveArray (dCurve.get(), mapcurve, skip, needed); + fillCurveArray(dCurve.get(), mapcurve, skip, needed); } -void CurveFactory::curveDehaContL ( bool & dehacontlutili, const std::vector& dehaclcurvePoints, LUTf & dehaclCurve, int skip, const LUTu & histogram, LUTu & outBeforeCurveHistogram) +void CurveFactory::curveDehaContL(bool & dehacontlutili, const std::vector& dehaclcurvePoints, LUTf & dehaclCurve, int skip, const LUTu & histogram, LUTu & outBeforeCurveHistogram) { bool needed = false; std::unique_ptr dCurve; @@ -355,7 +355,7 @@ void CurveFactory::curveDehaContL ( bool & dehacontlutili, const std::vector (new DiagonalCurve (dehaclcurvePoints, CURVES_MIN_POLY_POINTS / skip)); + dCurve = std::unique_ptr (new DiagonalCurve(dehaclcurvePoints, CURVES_MIN_POLY_POINTS / skip)); if (outBeforeCurveHistogram) { histNeeded = true; @@ -368,20 +368,20 @@ void CurveFactory::curveDehaContL ( bool & dehacontlutili, const std::vector& wavclcurvePoints, LUTf & wavclCurve, /*LUTu & histogramwavcl, LUTu & outBeforeWavCLurveHistogram,*/int skip) +void CurveFactory::curveWavContL(bool & wavcontlutili, const std::vector& wavclcurvePoints, LUTf & wavclCurve, /*LUTu & histogramwavcl, LUTu & outBeforeWavCLurveHistogram,*/int skip) { bool needed = false; std::unique_ptr dCurve; if (!wavclcurvePoints.empty() && wavclcurvePoints[0] != 0) { - dCurve = std::unique_ptr (new DiagonalCurve (wavclcurvePoints, CURVES_MIN_POLY_POINTS / skip)); + dCurve = std::unique_ptr (new DiagonalCurve(wavclcurvePoints, CURVES_MIN_POLY_POINTS / skip)); if (dCurve && !dCurve->isIdentity()) { needed = true; @@ -389,33 +389,33 @@ void CurveFactory::curveWavContL ( bool & wavcontlutili, const std::vector& curvePoints, LUTf & ToningCurve, int skip) +void CurveFactory::curveToning(const std::vector& curvePoints, LUTf & ToningCurve, int skip) { bool needed = false; std::unique_ptr dCurve; if (!curvePoints.empty() && curvePoints[0] != 0) { - dCurve = std::unique_ptr (new DiagonalCurve (curvePoints, CURVES_MIN_POLY_POINTS / skip)); + dCurve = std::unique_ptr (new DiagonalCurve(curvePoints, CURVES_MIN_POLY_POINTS / skip)); if (dCurve && !dCurve->isIdentity()) { needed = true; } } - fillCurveArray (dCurve.get(), ToningCurve, skip, needed); + fillCurveArray(dCurve.get(), ToningCurve, skip, needed); } -void CurveFactory::curveLocal (bool & locallutili, const std::vector& curvePoints, LUTf & LocalLCurve, int skip) +void CurveFactory::curveLocal(bool & locallutili, const std::vector& curvePoints, LUTf & LocalLCurve, int skip) { bool needed = false; std::unique_ptr dCurve; if (!curvePoints.empty() && curvePoints[0] != 0) { - dCurve = std::unique_ptr (new DiagonalCurve (curvePoints, CURVES_MIN_POLY_POINTS / skip)); + dCurve = std::unique_ptr (new DiagonalCurve(curvePoints, CURVES_MIN_POLY_POINTS / skip)); if (dCurve && !dCurve->isIdentity()) { needed = true; @@ -423,18 +423,18 @@ void CurveFactory::curveLocal (bool & locallutili, const std::vector& cu } } - fillCurveArray (dCurve.get(), LocalLCurve, skip, needed); + fillCurveArray(dCurve.get(), LocalLCurve, skip, needed); //LocalLCurve.dump("wav"); } -void CurveFactory::curveCCLocal (bool & localcutili, const std::vector& curvePoints, LUTf & LocalCCurve, int skip) +void CurveFactory::curveCCLocal(bool & localcutili, const std::vector& curvePoints, LUTf & LocalCCurve, int skip) { bool needed = false; std::unique_ptr dCurve; if (!curvePoints.empty() && curvePoints[0] != 0) { - dCurve = std::unique_ptr (new DiagonalCurve (curvePoints, CURVES_MIN_POLY_POINTS / skip)); + dCurve = std::unique_ptr (new DiagonalCurve(curvePoints, CURVES_MIN_POLY_POINTS / skip)); if (dCurve && !dCurve->isIdentity()) { needed = true; @@ -442,18 +442,18 @@ void CurveFactory::curveCCLocal (bool & localcutili, const std::vector& } } - fillCurveArray (dCurve.get(), LocalCCurve, skip, needed); + fillCurveArray(dCurve.get(), LocalCCurve, skip, needed); //LocalLCurve.dump("wav"); } -void CurveFactory::curveskLocal (bool & localskutili, const std::vector& curvePoints, LUTf & LocalskCurve, int skip) +void CurveFactory::curveskLocal(bool & localskutili, const std::vector& curvePoints, LUTf & LocalskCurve, int skip) { bool needed = false; std::unique_ptr dCurve; if (localskutili && !curvePoints.empty() && curvePoints[0] != 0) { - dCurve = std::unique_ptr (new DiagonalCurve (curvePoints, CURVES_MIN_POLY_POINTS / skip)); + dCurve = std::unique_ptr (new DiagonalCurve(curvePoints, CURVES_MIN_POLY_POINTS / skip)); if (dCurve && !dCurve->isIdentity()) { needed = true; @@ -461,35 +461,35 @@ void CurveFactory::curveskLocal (bool & localskutili, const std::vector& } } - fillCurveArray (dCurve.get(), LocalskCurve, skip, needed); + fillCurveArray(dCurve.get(), LocalskCurve, skip, needed); } -void CurveFactory::curveexLocal (bool & localexutili, const std::vector& curvePoints, LUTf & LocalexCurve, int skip) +void CurveFactory::curveexLocal(bool & localexutili, const std::vector& curvePoints, LUTf & LocalexCurve, int skip) { bool needed = false; std::unique_ptr dCurve; if (localexutili && !curvePoints.empty() && curvePoints[0] != 0) { - dCurve = std::unique_ptr (new DiagonalCurve (curvePoints, CURVES_MIN_POLY_POINTS / skip)); + dCurve = std::unique_ptr (new DiagonalCurve(curvePoints, CURVES_MIN_POLY_POINTS / skip)); if (dCurve && !dCurve->isIdentity()) { needed = true; } } - fillCurveArray (dCurve.get(), LocalexCurve, skip, needed); + fillCurveArray(dCurve.get(), LocalexCurve, skip, needed); } -void CurveFactory::localLCurve (double br, double contr, /*const std::vector& curvePoints,*/ - LUTu & histogram, LUTf & outCurve, - int skip, bool & utili) +void CurveFactory::localLCurve(double br, double contr, /*const std::vector& curvePoints,*/ + LUTu & histogram, LUTf & outCurve, + int skip, bool & utili) { // curve without contrast - LUTf dcurve (65536, 0); + LUTf dcurve(65536, 0); // clear array that stores histogram valid before applying the custom curve @@ -502,30 +502,30 @@ void CurveFactory::localLCurve (double br, double contr, /*const std::vector brightcurvePoints; - brightcurvePoints.resize (9); - brightcurvePoints.at (0) = double (DCT_NURBS); + brightcurvePoints.resize(9); + brightcurvePoints.at(0) = double (DCT_NURBS); - brightcurvePoints.at (1) = 0.; // black point. Value in [0 ; 1] range - brightcurvePoints.at (2) = 0.; // black point. Value in [0 ; 1] range + brightcurvePoints.at(1) = 0.; // black point. Value in [0 ; 1] range + brightcurvePoints.at(2) = 0.; // black point. Value in [0 ; 1] range if (br > 0) { - brightcurvePoints.at (3) = 0.1; // toe point - brightcurvePoints.at (4) = 0.1 + br / 150.0; //value at toe point + brightcurvePoints.at(3) = 0.1; // toe point + brightcurvePoints.at(4) = 0.1 + br / 150.0; //value at toe point - brightcurvePoints.at (5) = 0.7; // shoulder point - brightcurvePoints.at (6) = min (1.0, 0.7 + br / 300.0); //value at shoulder point + brightcurvePoints.at(5) = 0.7; // shoulder point + brightcurvePoints.at(6) = min(1.0, 0.7 + br / 300.0); //value at shoulder point } else { - brightcurvePoints.at (3) = 0.1 - br / 150.0; // toe point - brightcurvePoints.at (4) = 0.1; // value at toe point + brightcurvePoints.at(3) = 0.1 - br / 150.0; // toe point + brightcurvePoints.at(4) = 0.1; // value at toe point - brightcurvePoints.at (5) = min (1.0, 0.7 - br / 300.0); // shoulder point - brightcurvePoints.at (6) = 0.7; // value at shoulder point + brightcurvePoints.at(5) = min(1.0, 0.7 - br / 300.0); // shoulder point + brightcurvePoints.at(6) = 0.7; // value at shoulder point } - brightcurvePoints.at (7) = 1.; // white point - brightcurvePoints.at (8) = 1.; // value at white point + brightcurvePoints.at(7) = 1.; // white point + brightcurvePoints.at(8) = 1.; // value at white point - DiagonalCurve* brightcurve = new DiagonalCurve (brightcurvePoints, CURVES_MIN_POLY_POINTS / skip); + DiagonalCurve* brightcurve = new DiagonalCurve(brightcurvePoints, CURVES_MIN_POLY_POINTS / skip); //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // Applying brightness curve @@ -535,10 +535,10 @@ void CurveFactory::localLCurve (double br, double contr, /*const std::vectorgetVal (val); + val = brightcurve->getVal(val); // store result in a temporary array - dcurve[i] = CLIPD (val); + dcurve[i] = CLIPD(val); } delete brightcurve; @@ -578,43 +578,43 @@ void CurveFactory::localLCurve (double br, double contr, /*const std::vector contrastcurvePoints; - contrastcurvePoints.resize (9); - contrastcurvePoints.at (0) = double (DCT_NURBS); + contrastcurvePoints.resize(9); + contrastcurvePoints.at(0) = double (DCT_NURBS); - contrastcurvePoints.at (1) = 0.; // black point. Value in [0 ; 1] range - contrastcurvePoints.at (2) = 0.; // black point. Value in [0 ; 1] range + contrastcurvePoints.at(1) = 0.; // black point. Value in [0 ; 1] range + contrastcurvePoints.at(2) = 0.; // black point. Value in [0 ; 1] range - contrastcurvePoints.at (3) = avg - avg * (0.6 - contr / 250.0); // toe point - contrastcurvePoints.at (4) = avg - avg * (0.6 + contr / 250.0); // value at toe point + contrastcurvePoints.at(3) = avg - avg * (0.6 - contr / 250.0); // toe point + contrastcurvePoints.at(4) = avg - avg * (0.6 + contr / 250.0); // value at toe point - contrastcurvePoints.at (5) = avg + (1 - avg) * (0.6 - contr / 250.0); // shoulder point - contrastcurvePoints.at (6) = avg + (1 - avg) * (0.6 + contr / 250.0); // value at shoulder point + contrastcurvePoints.at(5) = avg + (1 - avg) * (0.6 - contr / 250.0); // shoulder point + contrastcurvePoints.at(6) = avg + (1 - avg) * (0.6 + contr / 250.0); // value at shoulder point - contrastcurvePoints.at (7) = 1.; // white point - contrastcurvePoints.at (8) = 1.; // value at white point + contrastcurvePoints.at(7) = 1.; // white point + contrastcurvePoints.at(8) = 1.; // value at white point - contrastcurve = new DiagonalCurve (contrastcurvePoints, CURVES_MIN_POLY_POINTS / skip); + contrastcurve = new DiagonalCurve(contrastcurvePoints, CURVES_MIN_POLY_POINTS / skip); //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% } else { //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // sum has an invalid value (next to 0, producing a division by zero, so we create a fake contrast curve, producing a white image std::vector contrastcurvePoints; - contrastcurvePoints.resize (5); - contrastcurvePoints.at (0) = double (DCT_NURBS); + contrastcurvePoints.resize(5); + contrastcurvePoints.at(0) = double (DCT_NURBS); - contrastcurvePoints.at (1) = 0.; // black point. Value in [0 ; 1] range - contrastcurvePoints.at (2) = 1.; // black point. Value in [0 ; 1] range + contrastcurvePoints.at(1) = 0.; // black point. Value in [0 ; 1] range + contrastcurvePoints.at(2) = 1.; // black point. Value in [0 ; 1] range - contrastcurvePoints.at (3) = 1.; // white point - contrastcurvePoints.at (4) = 1.; // value at white point + contrastcurvePoints.at(3) = 1.; // white point + contrastcurvePoints.at(4) = 1.; // value at white point - contrastcurve = new DiagonalCurve (contrastcurvePoints, CURVES_MIN_POLY_POINTS / skip); + contrastcurve = new DiagonalCurve(contrastcurvePoints, CURVES_MIN_POLY_POINTS / skip); //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% } // apply contrast enhancement for (int i = 0; i < 32768; i++) { - dcurve[i] = contrastcurve->getVal (dcurve[i]); + dcurve[i] = contrastcurve->getVal(dcurve[i]); } delete contrastcurve; @@ -670,10 +670,10 @@ void CurveFactory::localLCurve (double br, double contr, /*const std::vector& acurvePoints, const std::vector& bcurvePoints, const std::vector& cccurvePoints, - const std::vector& lccurvePoints, LUTf & aoutCurve, LUTf & boutCurve, LUTf & satCurve, LUTf & lhskCurve, - int skip) +void CurveFactory::complexsgnCurve(bool & autili, bool & butili, bool & ccutili, bool & cclutili, + const std::vector& acurvePoints, const std::vector& bcurvePoints, const std::vector& cccurvePoints, + const std::vector& lccurvePoints, LUTf & aoutCurve, LUTf & boutCurve, LUTf & satCurve, LUTf & lhskCurve, + int skip) { autili = butili = ccutili = cclutili = false; @@ -681,60 +681,60 @@ void CurveFactory::complexsgnCurve (bool & autili, bool & butili, bool & ccutil // create a curve if needed if (!acurvePoints.empty() && acurvePoints[0] != 0) { - dCurve = std::unique_ptr (new DiagonalCurve (acurvePoints, CURVES_MIN_POLY_POINTS / skip)); + dCurve = std::unique_ptr (new DiagonalCurve(acurvePoints, CURVES_MIN_POLY_POINTS / skip)); if (dCurve && !dCurve->isIdentity()) { autili = true; } } - fillCurveArray (dCurve.get(), aoutCurve, skip, autili); + fillCurveArray(dCurve.get(), aoutCurve, skip, autili); dCurve = nullptr; //----------------------------------------------------- if (!bcurvePoints.empty() && bcurvePoints[0] != 0) { - dCurve = std::unique_ptr (new DiagonalCurve (bcurvePoints, CURVES_MIN_POLY_POINTS / skip)); + dCurve = std::unique_ptr (new DiagonalCurve(bcurvePoints, CURVES_MIN_POLY_POINTS / skip)); if (dCurve && !dCurve->isIdentity()) { butili = true; } } - fillCurveArray (dCurve.get(), boutCurve, skip, butili); + fillCurveArray(dCurve.get(), boutCurve, skip, butili); dCurve = nullptr; //----------------------------------------------- if (!cccurvePoints.empty() && cccurvePoints[0] != 0) { - dCurve = std::unique_ptr (new DiagonalCurve (cccurvePoints, CURVES_MIN_POLY_POINTS / skip)); + dCurve = std::unique_ptr (new DiagonalCurve(cccurvePoints, CURVES_MIN_POLY_POINTS / skip)); if (dCurve && !dCurve->isIdentity()) { ccutili = true; } } - fillCurveArray (dCurve.get(), satCurve, skip, ccutili); + fillCurveArray(dCurve.get(), satCurve, skip, ccutili); dCurve = nullptr; //---------------------------- if (!lccurvePoints.empty() && lccurvePoints[0] != 0) { - dCurve = std::unique_ptr (new DiagonalCurve (lccurvePoints, CURVES_MIN_POLY_POINTS / skip)); + dCurve = std::unique_ptr (new DiagonalCurve(lccurvePoints, CURVES_MIN_POLY_POINTS / skip)); if (dCurve && !dCurve->isIdentity()) { cclutili = true; } } - fillCurveArray (dCurve.get(), lhskCurve, skip, cclutili); + fillCurveArray(dCurve.get(), lhskCurve, skip, cclutili); } -SSEFUNCTION void CurveFactory::complexCurve (double ecomp, double black, double hlcompr, double hlcomprthresh, +SSEFUNCTION void CurveFactory::complexCurve(double ecomp, double black, double hlcompr, double hlcomprthresh, double shcompr, double br, double contr, const std::vector& curvePoints, const std::vector& curvePoints2, @@ -749,13 +749,13 @@ SSEFUNCTION void CurveFactory::complexCurve (double ecomp, double black, double // the curve shapes are defined in sRGB gamma, but the output curves will operate on linear floating point data, // hence we do both forward and inverse gamma conversions here. const float gamma_ = Color::sRGBGammaCurve; - const float start = expf (gamma_ * logf ( -0.055 / ((1.0 / gamma_ - 1.0) * 1.055 ))); - const float slope = 1.055 * powf (start, 1.0 / gamma_ - 1) - 0.055 / start; + const float start = expf(gamma_ * logf(-0.055 / ((1.0 / gamma_ - 1.0) * 1.055))); + const float slope = 1.055 * powf(start, 1.0 / gamma_ - 1) - 0.055 / start; const float mul = 1.055; const float add = 0.055; // a: slope of the curve, black: starting point at the x axis - const float a = powf (2.0, ecomp); + const float a = powf(2.0, ecomp); // clear array that stores histogram valid before applying the custom curve outBeforeCCurveHistogram.clear(); @@ -769,7 +769,7 @@ SSEFUNCTION void CurveFactory::complexCurve (double ecomp, double black, double // check if brightness curve is needed if (br > 0.00001 || br < -0.00001) { - std::vector brightcurvePoints (9); + std::vector brightcurvePoints(9); brightcurvePoints[0] = DCT_NURBS; brightcurvePoints[1] = 0.; //black point. Value in [0 ; 1] range @@ -780,9 +780,9 @@ SSEFUNCTION void CurveFactory::complexCurve (double ecomp, double black, double brightcurvePoints[4] = 0.1 + br / 150.0; //value at toe point brightcurvePoints[5] = 0.7; //shoulder point - brightcurvePoints[6] = min (1.0, 0.7 + br / 300.0); //value at shoulder point + brightcurvePoints[6] = min(1.0, 0.7 + br / 300.0); //value at shoulder point } else { - brightcurvePoints[3] = max (0.0, 0.1 - br / 150.0); //toe point + brightcurvePoints[3] = max(0.0, 0.1 - br / 150.0); //toe point brightcurvePoints[4] = 0.1; //value at toe point brightcurvePoints[5] = 0.7 - br / 300.0; //shoulder point @@ -792,21 +792,21 @@ SSEFUNCTION void CurveFactory::complexCurve (double ecomp, double black, double brightcurvePoints[7] = 1.; // white point brightcurvePoints[8] = 1.; // value at white point - brightcurve = std::unique_ptr (new DiagonalCurve (brightcurvePoints, CURVES_MIN_POLY_POINTS / skip)); + brightcurve = std::unique_ptr (new DiagonalCurve(brightcurvePoints, CURVES_MIN_POLY_POINTS / skip)); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - hlCurve.setClip (LUT_CLIP_BELOW); // used LUT_CLIP_BELOW, because we want to have a baseline of 2^expcomp in this curve. If we don't clip the lut we get wrong values, see Issue 2621 #14 for details + hlCurve.setClip(LUT_CLIP_BELOW); // used LUT_CLIP_BELOW, because we want to have a baseline of 2^expcomp in this curve. If we don't clip the lut we get wrong values, see Issue 2621 #14 for details float exp_scale = a; float scale = 65536.0; - float comp = (max (0.0, ecomp) + 1.0) * hlcompr / 100.0; - float shoulder = ((scale / max (1.0f, exp_scale)) * (hlcomprthresh / 200.0)) + 0.1; + float comp = (max(0.0, ecomp) + 1.0) * hlcompr / 100.0; + float shoulder = ((scale / max(1.0f, exp_scale)) * (hlcomprthresh / 200.0)) + 0.1; if (comp <= 0.0f) { - hlCurve.makeConstant (exp_scale); + hlCurve.makeConstant(exp_scale); } else { - hlCurve.makeConstant (exp_scale, shoulder + 1); + hlCurve.makeConstant(exp_scale, shoulder + 1); float scalemshoulder = scale - shoulder; @@ -817,22 +817,22 @@ SSEFUNCTION void CurveFactory::complexCurve (double ecomp, double black, double // change to [0,1] range float val = (float)i - shoulder; float R = val * comp / (scalemshoulder); - hlCurve[i] = xlog (1.0 + R * exp_scale) / R; // don't use xlogf or 1.f here. Leads to errors caused by too low precision + hlCurve[i] = xlog(1.0 + R * exp_scale) / R; // don't use xlogf or 1.f here. Leads to errors caused by too low precision i++; } - vdouble onev = _mm_set1_pd (1.0); - vdouble Rv = _mm_set_pd ((i + 1 - shoulder) * (double)comp / scalemshoulder, (i - shoulder) * (double)comp / scalemshoulder); - vdouble incrementv = _mm_set1_pd (2.0 * comp / scalemshoulder); - vdouble exp_scalev = _mm_set1_pd (exp_scale); + vdouble onev = _mm_set1_pd(1.0); + vdouble Rv = _mm_set_pd((i + 1 - shoulder) * (double)comp / scalemshoulder, (i - shoulder) * (double)comp / scalemshoulder); + vdouble incrementv = _mm_set1_pd(2.0 * comp / scalemshoulder); + vdouble exp_scalev = _mm_set1_pd(exp_scale); for (; i < 0x10000; i += 2) { // change to [0,1] range - vdouble resultv = xlog (onev + Rv * exp_scalev) / Rv; - vfloat resultfv = _mm_cvtpd_ps (resultv); - _mm_store_ss (&hlCurve[i], resultfv); - resultfv = PERMUTEPS (resultfv, _MM_SHUFFLE (1, 1, 1, 1)); - _mm_store_ss (&hlCurve[i + 1], resultfv); + vdouble resultv = xlog(onev + Rv * exp_scalev) / Rv; + vfloat resultfv = _mm_cvtpd_ps(resultv); + _mm_store_ss(&hlCurve[i], resultfv); + resultfv = PERMUTEPS(resultfv, _MM_SHUFFLE(1, 1, 1, 1)); + _mm_store_ss(&hlCurve[i + 1], resultfv); Rv += incrementv; } @@ -842,7 +842,7 @@ SSEFUNCTION void CurveFactory::complexCurve (double ecomp, double black, double for (int i = shoulder + 1; i < 0x10000; i++) { // change to [0,1] range - hlCurve[i] = xlog (1.0 + R * exp_scale) / R; // don't use xlogf or 1.f here. Leads to errors caused by too low precision + hlCurve[i] = xlog(1.0 + R * exp_scale) / R; // don't use xlogf or 1.f here. Leads to errors caused by too low precision R += increment; } @@ -852,30 +852,30 @@ SSEFUNCTION void CurveFactory::complexCurve (double ecomp, double black, double // curve without contrast - LUTf dcurve (0x10000); + LUTf dcurve(0x10000); //%%%%%%%%%%%%%%%%%%%%%%%%%% // change to [0,1] range - shCurve.setClip (LUT_CLIP_ABOVE); // used LUT_CLIP_ABOVE, because the curve converges to 1.0 at the upper end and we don't want to exceed this value. + shCurve.setClip(LUT_CLIP_ABOVE); // used LUT_CLIP_ABOVE, because the curve converges to 1.0 at the upper end and we don't want to exceed this value. float val = 1.f / 65535.f; - float val2 = simplebasecurve (val, black, 0.015 * shcompr); - shCurve[0] = CLIPD (val2) / val; + float val2 = simplebasecurve(val, black, 0.015 * shcompr); + shCurve[0] = CLIPD(val2) / val; // gamma correction val = Color::gammatab_srgb[0] / 65535.f; // apply brightness curve if (brightcurve) { - val = brightcurve->getVal (val); // TODO: getVal(double) is very slow! Optimize with a LUTf + val = brightcurve->getVal(val); // TODO: getVal(double) is very slow! Optimize with a LUTf } // store result in a temporary array - dcurve[0] = CLIPD (val); + dcurve[0] = CLIPD(val); for (int i = 1; i < 0x10000; i++) { float val = i / 65535.f; - float val2 = simplebasecurve (val, black, 0.015 * shcompr); + float val2 = simplebasecurve(val, black, 0.015 * shcompr); shCurve[i] = val2 / val; // gamma correction @@ -883,7 +883,7 @@ SSEFUNCTION void CurveFactory::complexCurve (double ecomp, double black, double // apply brightness curve if (brightcurve) { - val = CLIPD (brightcurve->getVal (val)); // TODO: getVal(double) is very slow! Optimize with a LUTf + val = CLIPD(brightcurve->getVal(val)); // TODO: getVal(double) is very slow! Optimize with a LUTf } // store result in a temporary array @@ -905,14 +905,14 @@ SSEFUNCTION void CurveFactory::complexCurve (double ecomp, double black, double for (int i = 0; i <= 0xffff; i++) { float fi = i * hlCurve[i]; - avg += dcurve[ (int) (shCurve[fi] * fi)] * histogram[i]; + avg += dcurve[(int)(shCurve[fi] * fi)] * histogram[i]; sum += histogram[i]; } avg /= sum; //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - std::vector contrastcurvePoints (9); + std::vector contrastcurvePoints(9); contrastcurvePoints[0] = DCT_NURBS; contrastcurvePoints[1] = 0; //black point. Value in [0 ; 1] range @@ -927,12 +927,12 @@ SSEFUNCTION void CurveFactory::complexCurve (double ecomp, double black, double contrastcurvePoints[7] = 1.; // white point contrastcurvePoints[8] = 1.; // value at white point - const DiagonalCurve contrastcurve (contrastcurvePoints, CURVES_MIN_POLY_POINTS / skip); + const DiagonalCurve contrastcurve(contrastcurvePoints, CURVES_MIN_POLY_POINTS / skip); //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // apply contrast enhancement for (int i = 0; i <= 0xffff; i++) { - dcurve[i] = contrastcurve.getVal (dcurve[i]); + dcurve[i] = contrastcurve.getVal(dcurve[i]); } } @@ -943,13 +943,13 @@ SSEFUNCTION void CurveFactory::complexCurve (double ecomp, double black, double customToneCurve2.Reset(); if (!curvePoints2.empty() && curvePoints2[0] > DCT_Linear && curvePoints2[0] < DCT_Unchanged) { - const DiagonalCurve tcurve (curvePoints2, CURVES_MIN_POLY_POINTS / skip); + const DiagonalCurve tcurve(curvePoints2, CURVES_MIN_POLY_POINTS / skip); if (!tcurve.isIdentity()) { - customToneCurve2.Set (tcurve, gamma_); + customToneCurve2.Set(tcurve, gamma_); } - if (outBeforeCCurveHistogram ) { + if (outBeforeCCurveHistogram) { histNeeded = true; } } @@ -962,10 +962,10 @@ SSEFUNCTION void CurveFactory::complexCurve (double ecomp, double black, double customToneCurve1.Reset(); if (!curvePoints.empty() && curvePoints[0] > DCT_Linear && curvePoints[0] < DCT_Unchanged) { - const DiagonalCurve tcurve (curvePoints, CURVES_MIN_POLY_POINTS / skip); + const DiagonalCurve tcurve(curvePoints, CURVES_MIN_POLY_POINTS / skip); if (!tcurve.isIdentity()) { - customToneCurve1.Set (tcurve, gamma_); + customToneCurve1.Set(tcurve, gamma_); } if (outBeforeCCurveHistogram) { @@ -976,24 +976,24 @@ SSEFUNCTION void CurveFactory::complexCurve (double ecomp, double black, double //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% #ifdef __SSE2__ - vfloat gamma_v = F2V (gamma_); - vfloat startv = F2V (start); - vfloat slopev = F2V (slope); - vfloat mulv = F2V (mul); - vfloat addv = F2V (add); - vfloat c65535v = F2V (65535.f); + vfloat gamma_v = F2V(gamma_); + vfloat startv = F2V(start); + vfloat slopev = F2V(slope); + vfloat mulv = F2V(mul); + vfloat addv = F2V(add); + vfloat c65535v = F2V(65535.f); for (int i = 0; i <= 0xffff; i += 4) { - vfloat valv = LVFU (dcurve[i]); - valv = igamma (valv, gamma_v, startv, slopev, mulv, addv); - STVFU (outCurve[i], c65535v * valv); + vfloat valv = LVFU(dcurve[i]); + valv = igamma(valv, gamma_v, startv, slopev, mulv, addv); + STVFU(outCurve[i], c65535v * valv); } #else for (int i = 0; i <= 0xffff; i++) { float val = dcurve[i]; - val = igamma (val, gamma_, start, slope, mul, add); + val = igamma(val, gamma_, start, slope, mul, add); outCurve[i] = (65535.f * val); } @@ -1004,7 +1004,7 @@ SSEFUNCTION void CurveFactory::complexCurve (double ecomp, double black, double float fi = i; float hval = hlCurve[i] * fi; hval = dcurve[shCurve[hval] * hval]; - int hi = (int) (255.f * (hval)); + int hi = (int)(255.f * (hval)); outBeforeCCurveHistogram[hi] += histogram[i] ; } } @@ -1016,7 +1016,7 @@ SSEFUNCTION void CurveFactory::complexCurve (double ecomp, double black, double -SSEFUNCTION void CurveFactory::complexCurvelocal (double ecomp, double black, double hlcompr, double hlcomprthresh, +SSEFUNCTION void CurveFactory::complexCurvelocal(double ecomp, double black, double hlcompr, double hlcomprthresh, double shcompr, double br, double contr, LUTu & histogram, LUTf & hlCurve, LUTf & shCurve, LUTf & outCurve, @@ -1026,16 +1026,16 @@ SSEFUNCTION void CurveFactory::complexCurvelocal (double ecomp, double black, do // the curve shapes are defined in sRGB gamma, but the output curves will operate on linear floating point data, // hence we do both forward and inverse gamma conversions here. const float gamma_ = Color::sRGBGammaCurve; - const float start = expf (gamma_ * logf ( -0.055 / ((1.0 / gamma_ - 1.0) * 1.055 ))); - const float slope = 1.055 * powf (start, 1.0 / gamma_ - 1) - 0.055 / start; + const float start = expf(gamma_ * logf(-0.055 / ((1.0 / gamma_ - 1.0) * 1.055))); + const float slope = 1.055 * powf(start, 1.0 / gamma_ - 1) - 0.055 / start; const float mul = 1.055; const float add = 0.055; - float maxran = 32768.f; //65536 + float maxran = 32768.f; //65536 ecomp /= 100.;//for mip files in integer * 100 // a: slope of the curve, black: starting point at the x axis - const float a = powf (2.0, ecomp); + const float a = powf(2.0, ecomp); // clear array that stores histogram valid before applying the custom curve // outBeforeCCurveHistogram.clear(); @@ -1049,7 +1049,7 @@ SSEFUNCTION void CurveFactory::complexCurvelocal (double ecomp, double black, do // check if brightness curve is needed if (br > 0.00001 || br < -0.00001) { - std::vector brightcurvePoints (9); + std::vector brightcurvePoints(9); brightcurvePoints[0] = DCT_NURBS; brightcurvePoints[1] = 0.; //black point. Value in [0 ; 1] range @@ -1060,9 +1060,9 @@ SSEFUNCTION void CurveFactory::complexCurvelocal (double ecomp, double black, do brightcurvePoints[4] = 0.1 + br / 150.0; //value at toe point brightcurvePoints[5] = 0.7; //shoulder point - brightcurvePoints[6] = min (1.0, 0.7 + br / 300.0); //value at shoulder point + brightcurvePoints[6] = min(1.0, 0.7 + br / 300.0); //value at shoulder point } else { - brightcurvePoints[3] = max (0.0, 0.1 - br / 150.0); //toe point + brightcurvePoints[3] = max(0.0, 0.1 - br / 150.0); //toe point brightcurvePoints[4] = 0.1; //value at toe point brightcurvePoints[5] = 0.7 - br / 300.0; //shoulder point @@ -1072,22 +1072,22 @@ SSEFUNCTION void CurveFactory::complexCurvelocal (double ecomp, double black, do brightcurvePoints[7] = 1.; // white point brightcurvePoints[8] = 1.; // value at white point - brightcurve = std::unique_ptr (new DiagonalCurve (brightcurvePoints, CURVES_MIN_POLY_POINTS / skip)); + brightcurve = std::unique_ptr (new DiagonalCurve(brightcurvePoints, CURVES_MIN_POLY_POINTS / skip)); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - hlCurve.setClip (LUT_CLIP_BELOW); // used LUT_CLIP_BELOW, because we want to have a baseline of 2^expcomp in this curve. If we don't clip the lut we get wrong values, see Issue 2621 #14 for details + hlCurve.setClip(LUT_CLIP_BELOW); // used LUT_CLIP_BELOW, because we want to have a baseline of 2^expcomp in this curve. If we don't clip the lut we get wrong values, see Issue 2621 #14 for details float exp_scale = a; // float scale = 65536.0; float scale = maxran; - float comp = (max (0.0, ecomp) + 1.0) * hlcompr / 100.0; - float shoulder = ((scale / max (1.0f, exp_scale)) * (hlcomprthresh / 200.0)) + 0.1; + float comp = (max(0.0, ecomp) + 1.0) * hlcompr / 100.0; + float shoulder = ((scale / max(1.0f, exp_scale)) * (hlcomprthresh / 200.0)) + 0.1; if (comp <= 0.0f) { - hlCurve.makeConstant (exp_scale); + hlCurve.makeConstant(exp_scale); } else { - hlCurve.makeConstant (exp_scale, shoulder + 1); + hlCurve.makeConstant(exp_scale, shoulder + 1); float scalemshoulder = scale - shoulder; @@ -1098,23 +1098,23 @@ SSEFUNCTION void CurveFactory::complexCurvelocal (double ecomp, double black, do // change to [0,1] range float val = (float)i - shoulder; float R = val * comp / (scalemshoulder); - hlCurve[i] = xlog (1.0 + R * exp_scale) / R; // don't use xlogf or 1.f here. Leads to errors caused by too low precision + hlCurve[i] = xlog(1.0 + R * exp_scale) / R; // don't use xlogf or 1.f here. Leads to errors caused by too low precision i++; } - vdouble onev = _mm_set1_pd (1.0); - vdouble Rv = _mm_set_pd ((i + 1 - shoulder) * (double)comp / scalemshoulder, (i - shoulder) * (double)comp / scalemshoulder); - vdouble incrementv = _mm_set1_pd (2.0 * comp / scalemshoulder); - vdouble exp_scalev = _mm_set1_pd (exp_scale); + vdouble onev = _mm_set1_pd(1.0); + vdouble Rv = _mm_set_pd((i + 1 - shoulder) * (double)comp / scalemshoulder, (i - shoulder) * (double)comp / scalemshoulder); + vdouble incrementv = _mm_set1_pd(2.0 * comp / scalemshoulder); + vdouble exp_scalev = _mm_set1_pd(exp_scale); // for (; i < 0x10000; i += 2) { for (; i < maxran; i += 2) { // change to [0,1] range - vdouble resultv = xlog (onev + Rv * exp_scalev) / Rv; - vfloat resultfv = _mm_cvtpd_ps (resultv); - _mm_store_ss (&hlCurve[i], resultfv); - resultfv = PERMUTEPS (resultfv, _MM_SHUFFLE (1, 1, 1, 1)); - _mm_store_ss (&hlCurve[i + 1], resultfv); + vdouble resultv = xlog(onev + Rv * exp_scalev) / Rv; + vfloat resultfv = _mm_cvtpd_ps(resultv); + _mm_store_ss(&hlCurve[i], resultfv); + resultfv = PERMUTEPS(resultfv, _MM_SHUFFLE(1, 1, 1, 1)); + _mm_store_ss(&hlCurve[i + 1], resultfv); Rv += incrementv; } @@ -1125,7 +1125,7 @@ SSEFUNCTION void CurveFactory::complexCurvelocal (double ecomp, double black, do // for (int i = shoulder + 1; i < 0x10000; i++) { for (int i = shoulder + 1; i < maxran; i++) { // change to [0,1] range - hlCurve[i] = xlog (1.0 + R * exp_scale) / R; // don't use xlogf or 1.f here. Leads to errors caused by too low precision + hlCurve[i] = xlog(1.0 + R * exp_scale) / R; // don't use xlogf or 1.f here. Leads to errors caused by too low precision R += increment; } @@ -1136,42 +1136,42 @@ SSEFUNCTION void CurveFactory::complexCurvelocal (double ecomp, double black, do // curve without contrast // LUTf dcurve (0x10000); - LUTf dcurve (maxran); + LUTf dcurve(maxran); //%%%%%%%%%%%%%%%%%%%%%%%%%% // change to [0,1] range - shCurve.setClip (LUT_CLIP_ABOVE); // used LUT_CLIP_ABOVE, because the curve converges to 1.0 at the upper end and we don't want to exceed this value. - float val = 1.f / (maxran -1.f); - float val2 = simplebasecurve (val, black, 0.015 * shcompr); - shCurve[0] = CLIPD (val2) / val; + shCurve.setClip(LUT_CLIP_ABOVE); // used LUT_CLIP_ABOVE, because the curve converges to 1.0 at the upper end and we don't want to exceed this value. + float val = 1.f / (maxran - 1.f); + float val2 = simplebasecurve(val, black, 0.015 * shcompr); + shCurve[0] = CLIPD(val2) / val; // gamma correction - // val = Color::gammatab_srgb[0] / maxran; + // val = Color::gammatab_srgb[0] / maxran; val = Color::gammatab_srgb327[0] / 32767.f; // apply brightness curve if (brightcurve) { - val = brightcurve->getVal (val); // TODO: getVal(double) is very slow! Optimize with a LUTf + val = brightcurve->getVal(val); // TODO: getVal(double) is very slow! Optimize with a LUTf } // store result in a temporary array - dcurve[0] = CLIPD (val); + dcurve[0] = CLIPD(val); // for (int i = 1; i < 0x10000; i++) { // float val = i / 65535.f; for (int i = 1; i < maxran; i++) { - float val = i / (maxran -1.f); + float val = i / (maxran - 1.f); - float val2 = simplebasecurve (val, black, 0.015 * shcompr); + float val2 = simplebasecurve(val, black, 0.015 * shcompr); shCurve[i] = val2 / val; // gamma correction // val = Color::gammatab_srgb[i] / maxran; - val = Color::gammatab_srgb327[i] / 32767.f; + val = Color::gammatab_srgb327[i] / 32767.f; // apply brightness curve if (brightcurve) { - val = CLIPD (brightcurve->getVal (val)); // TODO: getVal(double) is very slow! Optimize with a LUTf + val = CLIPD(brightcurve->getVal(val)); // TODO: getVal(double) is very slow! Optimize with a LUTf } // store result in a temporary array @@ -1192,16 +1192,16 @@ SSEFUNCTION void CurveFactory::complexCurvelocal (double ecomp, double black, do float avg = 0; // for (int i = 0; i <= 0xffff; i++) { - for (int i = 0; i <= (maxran-1.f); i++) { + for (int i = 0; i <= (maxran - 1.f); i++) { float fi = i * hlCurve[i]; - avg += dcurve[ (int) (shCurve[fi] * fi)] * histogram[i]; + avg += dcurve[(int)(shCurve[fi] * fi)] * histogram[i]; sum += histogram[i]; } avg /= sum; //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - std::vector contrastcurvePoints (9); + std::vector contrastcurvePoints(9); contrastcurvePoints[0] = DCT_NURBS; contrastcurvePoints[1] = 0; //black point. Value in [0 ; 1] range @@ -1216,42 +1216,42 @@ SSEFUNCTION void CurveFactory::complexCurvelocal (double ecomp, double black, do contrastcurvePoints[7] = 1.; // white point contrastcurvePoints[8] = 1.; // value at white point - const DiagonalCurve contrastcurve (contrastcurvePoints, CURVES_MIN_POLY_POINTS / skip); + const DiagonalCurve contrastcurve(contrastcurvePoints, CURVES_MIN_POLY_POINTS / skip); //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // apply contrast enhancement // for (int i = 0; i <= 0xffff; i++) { - for (int i = 0; i <= (maxran -1.f); i++) { - dcurve[i] = contrastcurve.getVal (dcurve[i]); + for (int i = 0; i <= (maxran - 1.f); i++) { + dcurve[i] = contrastcurve.getVal(dcurve[i]); } } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% #ifdef __SSE2__ - vfloat gamma_v = F2V (gamma_); - vfloat startv = F2V (start); - vfloat slopev = F2V (slope); - vfloat mulv = F2V (mul); - vfloat addv = F2V (add); + vfloat gamma_v = F2V(gamma_); + vfloat startv = F2V(start); + vfloat slopev = F2V(slope); + vfloat mulv = F2V(mul); + vfloat addv = F2V(add); // vfloat c65535v = F2V (65535.f); - vfloat c65535v = F2V (maxran -1.f); + vfloat c65535v = F2V(maxran - 1.f); // for (int i = 0; i <= 0xffff; i += 4) { - for (int i = 0; i <= (maxran -1.f); i += 4) { - vfloat valv = LVFU (dcurve[i]); - valv = igamma (valv, gamma_v, startv, slopev, mulv, addv); - STVFU (outCurve[i], c65535v * valv); + for (int i = 0; i <= (maxran - 1.f); i += 4) { + vfloat valv = LVFU(dcurve[i]); + valv = igamma(valv, gamma_v, startv, slopev, mulv, addv); + STVFU(outCurve[i], c65535v * valv); } #else // for (int i = 0; i <= 0xffff; i++) { - for (int i = 0; i <= (maxran -1.f); i++) { + for (int i = 0; i <= (maxran - 1.f); i++) { float val = dcurve[i]; - val = igamma (val, gamma_, start, slope, mul, add); + val = igamma(val, gamma_, start, slope, mul, add); // outCurve[i] = (65535.f * val); - outCurve[i] = ((maxran -1.) * val); + outCurve[i] = ((maxran - 1.) * val); } #endif @@ -1260,9 +1260,9 @@ SSEFUNCTION void CurveFactory::complexCurvelocal (double ecomp, double black, do //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -void CurveFactory::complexLCurve (double br, double contr, const std::vector& curvePoints, - const LUTu & histogram, LUTf & outCurve, - LUTu & outBeforeCCurveHistogram, int skip, bool & utili) +void CurveFactory::complexLCurve(double br, double contr, const std::vector& curvePoints, + const LUTu & histogram, LUTf & outCurve, + LUTu & outBeforeCCurveHistogram, int skip, bool & utili) { utili = false; @@ -1281,30 +1281,30 @@ void CurveFactory::complexLCurve (double br, double contr, const std::vector brightcurvePoints; - brightcurvePoints.resize (9); - brightcurvePoints.at (0) = double (DCT_NURBS); + brightcurvePoints.resize(9); + brightcurvePoints.at(0) = double (DCT_NURBS); - brightcurvePoints.at (1) = 0.; // black point. Value in [0 ; 1] range - brightcurvePoints.at (2) = 0.; // black point. Value in [0 ; 1] range + brightcurvePoints.at(1) = 0.; // black point. Value in [0 ; 1] range + brightcurvePoints.at(2) = 0.; // black point. Value in [0 ; 1] range if (br > 0) { - brightcurvePoints.at (3) = 0.1; // toe point - brightcurvePoints.at (4) = 0.1 + br / 150.0; //value at toe point + brightcurvePoints.at(3) = 0.1; // toe point + brightcurvePoints.at(4) = 0.1 + br / 150.0; //value at toe point - brightcurvePoints.at (5) = 0.7; // shoulder point - brightcurvePoints.at (6) = min (1.0, 0.7 + br / 300.0); //value at shoulder point + brightcurvePoints.at(5) = 0.7; // shoulder point + brightcurvePoints.at(6) = min(1.0, 0.7 + br / 300.0); //value at shoulder point } else { - brightcurvePoints.at (3) = 0.1 - br / 150.0; // toe point - brightcurvePoints.at (4) = 0.1; // value at toe point + brightcurvePoints.at(3) = 0.1 - br / 150.0; // toe point + brightcurvePoints.at(4) = 0.1; // value at toe point - brightcurvePoints.at (5) = min (1.0, 0.7 - br / 300.0); // shoulder point - brightcurvePoints.at (6) = 0.7; // value at shoulder point + brightcurvePoints.at(5) = min(1.0, 0.7 - br / 300.0); // shoulder point + brightcurvePoints.at(6) = 0.7; // value at shoulder point } - brightcurvePoints.at (7) = 1.; // white point - brightcurvePoints.at (8) = 1.; // value at white point + brightcurvePoints.at(7) = 1.; // white point + brightcurvePoints.at(8) = 1.; // value at white point - DiagonalCurve brightcurve (brightcurvePoints, CURVES_MIN_POLY_POINTS / skip); + DiagonalCurve brightcurve(brightcurvePoints, CURVES_MIN_POLY_POINTS / skip); //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // Applying brightness curve @@ -1314,14 +1314,14 @@ void CurveFactory::complexLCurve (double br, double contr, const std::vector (new DiagonalCurve (curvePoints, CURVES_MIN_POLY_POINTS / skip)); + tcurve = std::unique_ptr (new DiagonalCurve(curvePoints, CURVES_MIN_POLY_POINTS / skip)); if (outBeforeCCurveHistogram) { histNeeded = true; @@ -1414,12 +1414,12 @@ void CurveFactory::complexLCurve (double br, double contr, const std::vectorgetVal (outCurve[i]); + val = tcurve->getVal(outCurve[i]); outCurve[i] = (32767.f * val); } @@ -1428,7 +1428,7 @@ void CurveFactory::complexLCurve (double br, double contr, const std::vector& curvePoints, LUTf & outCurve, int skip) +void CurveFactory::RGBCurve(const std::vector& curvePoints, LUTf & outCurve, int skip) { // create a curve if needed std::unique_ptr tcurve; if (!curvePoints.empty() && curvePoints[0] != 0) { - tcurve = std::unique_ptr (new DiagonalCurve (curvePoints, CURVES_MIN_POLY_POINTS / skip)); + tcurve = std::unique_ptr (new DiagonalCurve(curvePoints, CURVES_MIN_POLY_POINTS / skip)); } if (tcurve && tcurve->isIdentity()) { @@ -1461,14 +1461,14 @@ void CurveFactory::RGBCurve (const std::vector& curvePoints, LUTf & outC if (tcurve) { if (!outCurve) { - outCurve (65536, 0); + outCurve(65536, 0); } for (int i = 0; i < 65536; i++) { // apply custom/parametric/NURBS curve, if any // RGB curves are defined with sRGB gamma, but operate on linear data float val = Color::gamma2curve[i] / 65535.f; - val = tcurve->getVal (val); + val = tcurve->getVal(val); outCurve[i] = Color::igammatab_srgb[val * 65535.f]; } } else { // let the LUTf empty for identity curves @@ -1477,7 +1477,7 @@ void CurveFactory::RGBCurve (const std::vector& curvePoints, LUTf & outC } -LocretigainCurverab::LocretigainCurverab() : sum (0.f) {}; +LocretigainCurverab::LocretigainCurverab() : sum(0.f) {}; void LocretigainCurverab::Reset() { @@ -1485,18 +1485,18 @@ void LocretigainCurverab::Reset() sum = 0.f; } -void LocretigainCurverab::Set (const Curve &pCurve) +void LocretigainCurverab::Set(const Curve &pCurve) { if (pCurve.isIdentity()) { Reset(); // raise this value if the quality suffers from this number of samples return; } - lutLocretigainCurverab (501); // raise this value if the quality suffers from this number of samples + lutLocretigainCurverab(501); // raise this value if the quality suffers from this number of samples sum = 0.f; for (int i = 0; i < 501; i++) { - lutLocretigainCurverab[i] = pCurve.getVal (double (i) / 500.); + lutLocretigainCurverab[i] = pCurve.getVal(double (i) / 500.); if (lutLocretigainCurverab[i] < 0.02f) { lutLocretigainCurverab[i] = 0.02f; //avoid 0.f for wavelet : under 0.01f quasi no action for each value @@ -1508,38 +1508,38 @@ void LocretigainCurverab::Set (const Curve &pCurve) //lutLocCurve.dump("wav"); } -void LocretigainCurverab::Set (const std::vector &curvePoints) +void LocretigainCurverab::Set(const std::vector &curvePoints) { if (!curvePoints.empty() && curvePoints[0] > FCT_Linear && curvePoints[0] < FCT_Unchanged) { - FlatCurve tcurve (curvePoints, false, CURVES_MIN_POLY_POINTS / 2); - tcurve.setIdentityValue (0.); - Set (tcurve); + FlatCurve tcurve(curvePoints, false, CURVES_MIN_POLY_POINTS / 2); + tcurve.setIdentityValue(0.); + Set(tcurve); } else { Reset(); } } -LocHHCurve::LocHHCurve() : sum (0.f) {}; +LocHHCurve::LocHHCurve() : sum(0.f) {}; void LocHHCurve::Reset() { lutLocHHCurve.reset(); sum = 0.f; } -void LocHHCurve::Set (const Curve &pCurve) +void LocHHCurve::Set(const Curve &pCurve) { if (pCurve.isIdentity()) { Reset(); // raise this value if the quality suffers from this number of samples return; } - lutLocHHCurve (501); // raise this value if the quality suffers from this number of samples + lutLocHHCurve(501); // raise this value if the quality suffers from this number of samples sum = 0.f; for (int i = 0; i < 501; i++) { - lutLocHHCurve[i] = pCurve.getVal (double (i) / 500.); + lutLocHHCurve[i] = pCurve.getVal(double (i) / 500.); if (lutLocHHCurve[i] < 0.02f) { lutLocHHCurve[i] = 0.02f; //avoid 0.f for wavelet : under 0.01f quasi no action for each value @@ -1553,19 +1553,19 @@ void LocHHCurve::Set (const Curve &pCurve) -void LocHHCurve::Set (const std::vector &curvePoints, bool &HHutili) +void LocHHCurve::Set(const std::vector &curvePoints, bool &HHutili) { if (HHutili && !curvePoints.empty() && curvePoints[0] > FCT_Linear && curvePoints[0] < FCT_Unchanged) { - FlatCurve ttcurve (curvePoints, false, CURVES_MIN_POLY_POINTS / 2); - ttcurve.setIdentityValue (0.); - Set (ttcurve); + FlatCurve ttcurve(curvePoints, false, CURVES_MIN_POLY_POINTS / 2); + ttcurve.setIdentityValue(0.); + Set(ttcurve); } else { Reset(); } } -LocLHCurve::LocLHCurve() : sum (0.f) {}; +LocLHCurve::LocLHCurve() : sum(0.f) {}; void LocLHCurve::Reset() { @@ -1573,18 +1573,18 @@ void LocLHCurve::Reset() sum = 0.f; } -void LocLHCurve::Set (const Curve &pCurve) +void LocLHCurve::Set(const Curve &pCurve) { if (pCurve.isIdentity()) { Reset(); // raise this value if the quality suffers from this number of samples return; } - lutLocLHCurve (501); // raise this value if the quality suffers from this number of samples + lutLocLHCurve(501); // raise this value if the quality suffers from this number of samples sum = 0.f; for (int i = 0; i < 501; i++) { - lutLocLHCurve[i] = pCurve.getVal (double (i) / 500.); + lutLocLHCurve[i] = pCurve.getVal(double (i) / 500.); if (lutLocLHCurve[i] < 0.02f) { lutLocLHCurve[i] = 0.02f; //avoid 0.f for wavelet : under 0.01f quasi no action for each value @@ -1599,20 +1599,20 @@ void LocLHCurve::Set (const Curve &pCurve) -void LocLHCurve::Set (const std::vector &curvePoints, bool &LHutili) +void LocLHCurve::Set(const std::vector &curvePoints, bool &LHutili) { if (LHutili && !curvePoints.empty() && curvePoints[0] > FCT_Linear && curvePoints[0] < FCT_Unchanged) { - FlatCurve tcurve (curvePoints, false, CURVES_MIN_POLY_POINTS / 2); - tcurve.setIdentityValue (0.); - Set (tcurve); + FlatCurve tcurve(curvePoints, false, CURVES_MIN_POLY_POINTS / 2); + tcurve.setIdentityValue(0.); + Set(tcurve); } else { Reset(); } } -LocretigainCurve::LocretigainCurve() : sum (0.f) {}; +LocretigainCurve::LocretigainCurve() : sum(0.f) {}; void LocretigainCurve::Reset() { @@ -1620,18 +1620,18 @@ void LocretigainCurve::Reset() sum = 0.f; } -void LocretigainCurve::Set (const Curve &pCurve) +void LocretigainCurve::Set(const Curve &pCurve) { if (pCurve.isIdentity()) { Reset(); // raise this value if the quality suffers from this number of samples return; } - lutLocretigainCurve (501); // raise this value if the quality suffers from this number of samples + lutLocretigainCurve(501); // raise this value if the quality suffers from this number of samples sum = 0.f; for (int i = 0; i < 501; i++) { - lutLocretigainCurve[i] = pCurve.getVal (double (i) / 500.); + lutLocretigainCurve[i] = pCurve.getVal(double (i) / 500.); if (lutLocretigainCurve[i] < 0.02f) { lutLocretigainCurve[i] = 0.02f; //avoid 0.f for wavelet : under 0.01f quasi no action for each value @@ -1642,13 +1642,13 @@ void LocretigainCurve::Set (const Curve &pCurve) //lutLocCurve.dump("wav"); } -void LocretigainCurve::Set (const std::vector &curvePoints) +void LocretigainCurve::Set(const std::vector &curvePoints) { if (!curvePoints.empty() && curvePoints[0] > FCT_Linear && curvePoints[0] < FCT_Unchanged) { - FlatCurve tcurve (curvePoints, false, CURVES_MIN_POLY_POINTS / 2); - tcurve.setIdentityValue (0.); - Set (tcurve); + FlatCurve tcurve(curvePoints, false, CURVES_MIN_POLY_POINTS / 2); + tcurve.setIdentityValue(0.); + Set(tcurve); } else { Reset(); } @@ -1662,12 +1662,12 @@ void ColorAppearance::Reset() } // Fill a LUT with X/Y, ranged 0xffff -void ColorAppearance::Set (const Curve &pCurve) +void ColorAppearance::Set(const Curve &pCurve) { - lutColCurve (65536); + lutColCurve(65536); for (int i = 0; i < 65536; i++) { - lutColCurve[i] = pCurve.getVal (double (i) / 65535.) * 65535.; + lutColCurve[i] = pCurve.getVal(double (i) / 65535.) * 65535.; } } @@ -1679,26 +1679,26 @@ void RetinextransmissionCurve::Reset() luttransmission.reset(); } -void RetinextransmissionCurve::Set (const Curve &pCurve) +void RetinextransmissionCurve::Set(const Curve &pCurve) { if (pCurve.isIdentity()) { luttransmission.reset(); // raise this value if the quality suffers from this number of samples return; } - luttransmission (501); // raise this value if the quality suffers from this number of samples + luttransmission(501); // raise this value if the quality suffers from this number of samples for (int i = 0; i < 501; i++) { - luttransmission[i] = pCurve.getVal (double (i) / 500.); + luttransmission[i] = pCurve.getVal(double (i) / 500.); } } -void RetinextransmissionCurve::Set (const std::vector &curvePoints) +void RetinextransmissionCurve::Set(const std::vector &curvePoints) { if (!curvePoints.empty() && curvePoints[0] > FCT_Linear && curvePoints[0] < FCT_Unchanged) { - FlatCurve tcurve (curvePoints, false, CURVES_MIN_POLY_POINTS / 2); - tcurve.setIdentityValue (0.); - Set (tcurve); + FlatCurve tcurve(curvePoints, false, CURVES_MIN_POLY_POINTS / 2); + tcurve.setIdentityValue(0.); + Set(tcurve); } else { Reset(); } @@ -1712,26 +1712,26 @@ void RetinexgaintransmissionCurve::Reset() lutgaintransmission.reset(); } -void RetinexgaintransmissionCurve::Set (const Curve &pCurve) +void RetinexgaintransmissionCurve::Set(const Curve &pCurve) { if (pCurve.isIdentity()) { lutgaintransmission.reset(); // raise this value if the quality suffers from this number of samples return; } - lutgaintransmission (501); // raise this value if the quality suffers from this number of samples + lutgaintransmission(501); // raise this value if the quality suffers from this number of samples for (int i = 0; i < 501; i++) { - lutgaintransmission[i] = pCurve.getVal (double (i) / 500.); + lutgaintransmission[i] = pCurve.getVal(double (i) / 500.); } } -void RetinexgaintransmissionCurve::Set (const std::vector &curvePoints) +void RetinexgaintransmissionCurve::Set(const std::vector &curvePoints) { if (!curvePoints.empty() && curvePoints[0] > FCT_Linear && curvePoints[0] < FCT_Unchanged) { - FlatCurve tcurve (curvePoints, false, CURVES_MIN_POLY_POINTS / 2); - tcurve.setIdentityValue (0.); - Set (tcurve); + FlatCurve tcurve(curvePoints, false, CURVES_MIN_POLY_POINTS / 2); + tcurve.setIdentityValue(0.); + Set(tcurve); } else { Reset(); } @@ -1743,35 +1743,35 @@ void ToneCurve::Reset() } // Fill a LUT with X/Y, ranged 0xffff -void ToneCurve::Set (const Curve &pCurve, float gamma) +void ToneCurve::Set(const Curve &pCurve, float gamma) { - lutToneCurve (65536); + lutToneCurve(65536); if (gamma <= 0.0 || gamma == 1.) { for (int i = 0; i < 65536; i++) { - lutToneCurve[i] = (float)pCurve.getVal (float (i) / 65535.f) * 65535.f; + lutToneCurve[i] = (float)pCurve.getVal(float (i) / 65535.f) * 65535.f; } } else if (gamma == (float)Color::sRGBGammaCurve) { // for sRGB gamma we can use luts, which is much faster for (int i = 0; i < 65536; i++) { float val = Color::gammatab_srgb[i] / 65535.f; - val = pCurve.getVal (val); + val = pCurve.getVal(val); val = Color::igammatab_srgb[val * 65535.f]; lutToneCurve[i] = val; } } else { - const float start = expf (gamma * logf ( -0.055 / ((1.0 / gamma - 1.0) * 1.055 ))); - const float slope = 1.055 * powf (start, 1.0 / gamma - 1) - 0.055 / start; + const float start = expf(gamma * logf(-0.055 / ((1.0 / gamma - 1.0) * 1.055))); + const float slope = 1.055 * powf(start, 1.0 / gamma - 1) - 0.055 / start; const float mul = 1.055; const float add = 0.055; // apply gamma, that is 'pCurve' is defined with the given gamma and here we convert it to a curve in linear space for (int i = 0; i < 65536; i++) { float val = float (i) / 65535.f; - val = CurveFactory::gamma (val, gamma, start, slope, mul, add); - val = pCurve.getVal (val); - val = CurveFactory::igamma (val, gamma, start, slope, mul, add); + val = CurveFactory::gamma(val, gamma, start, slope, mul, add); + val = pCurve.getVal(val); + val = CurveFactory::igamma(val, gamma, start, slope, mul, add); lutToneCurve[i] = val * 65535.f; } } @@ -1782,40 +1782,40 @@ void OpacityCurve::Reset() lutOpacityCurve.reset(); } -void OpacityCurve::Set (const Curve *pCurve) +void OpacityCurve::Set(const Curve *pCurve) { if (pCurve->isIdentity()) { lutOpacityCurve.reset(); // raise this value if the quality suffers from this number of samples return; } - lutOpacityCurve (501); // raise this value if the quality suffers from this number of samples + lutOpacityCurve(501); // raise this value if the quality suffers from this number of samples for (int i = 0; i < 501; i++) { - lutOpacityCurve[i] = pCurve->getVal (double (i) / 500.); + lutOpacityCurve[i] = pCurve->getVal(double (i) / 500.); } //lutOpacityCurve.dump("opacity"); } -void OpacityCurve::Set (const std::vector &curvePoints, bool &opautili) +void OpacityCurve::Set(const std::vector &curvePoints, bool &opautili) { std::unique_ptr tcurve; if (!curvePoints.empty() && curvePoints[0] > FCT_Linear && curvePoints[0] < FCT_Unchanged) { - tcurve = std::unique_ptr (new FlatCurve (curvePoints, false, CURVES_MIN_POLY_POINTS / 2)); - tcurve->setIdentityValue (0.); + tcurve = std::unique_ptr (new FlatCurve(curvePoints, false, CURVES_MIN_POLY_POINTS / 2)); + tcurve->setIdentityValue(0.); } if (tcurve) { - Set (tcurve.get()); + Set(tcurve.get()); opautili = true; tcurve = nullptr; } } -WavCurve::WavCurve() : sum (0.f) {}; +WavCurve::WavCurve() : sum(0.f) {}; void WavCurve::Reset() { @@ -1823,18 +1823,18 @@ void WavCurve::Reset() sum = 0.f; } -void WavCurve::Set (const Curve &pCurve) +void WavCurve::Set(const Curve &pCurve) { if (pCurve.isIdentity()) { Reset(); // raise this value if the quality suffers from this number of samples return; } - lutWavCurve (501); // raise this value if the quality suffers from this number of samples + lutWavCurve(501); // raise this value if the quality suffers from this number of samples sum = 0.f; for (int i = 0; i < 501; i++) { - lutWavCurve[i] = pCurve.getVal (double (i) / 500.); + lutWavCurve[i] = pCurve.getVal(double (i) / 500.); if (lutWavCurve[i] < 0.02f) { lutWavCurve[i] = 0.02f; //avoid 0.f for wavelet : under 0.01f quasi no action for each value @@ -1845,13 +1845,13 @@ void WavCurve::Set (const Curve &pCurve) //lutWavCurve.dump("wav"); } -void WavCurve::Set (const std::vector &curvePoints) +void WavCurve::Set(const std::vector &curvePoints) { if (!curvePoints.empty() && curvePoints[0] > FCT_Linear && curvePoints[0] < FCT_Unchanged) { - FlatCurve tcurve (curvePoints, false, CURVES_MIN_POLY_POINTS / 2); - tcurve.setIdentityValue (0.); - Set (tcurve); + FlatCurve tcurve(curvePoints, false, CURVES_MIN_POLY_POINTS / 2); + tcurve.setIdentityValue(0.); + Set(tcurve); } else { Reset(); } @@ -1865,26 +1865,26 @@ void WavOpacityCurveRG::Reset() lutOpacityCurveRG.reset(); } -void WavOpacityCurveRG::Set (const Curve &pCurve) +void WavOpacityCurveRG::Set(const Curve &pCurve) { if (pCurve.isIdentity()) { Reset(); // raise this value if the quality suffers from this number of samples return; } - lutOpacityCurveRG (501); // raise this value if the quality suffers from this number of samples + lutOpacityCurveRG(501); // raise this value if the quality suffers from this number of samples for (int i = 0; i < 501; i++) { - lutOpacityCurveRG[i] = pCurve.getVal (double (i) / 500.); + lutOpacityCurveRG[i] = pCurve.getVal(double (i) / 500.); } } -void WavOpacityCurveRG::Set (const std::vector &curvePoints) +void WavOpacityCurveRG::Set(const std::vector &curvePoints) { if (!curvePoints.empty() && curvePoints[0] > FCT_Linear && curvePoints[0] < FCT_Unchanged) { - FlatCurve tcurve (curvePoints, false, CURVES_MIN_POLY_POINTS / 2); - tcurve.setIdentityValue (0.); - Set (tcurve); + FlatCurve tcurve(curvePoints, false, CURVES_MIN_POLY_POINTS / 2); + tcurve.setIdentityValue(0.); + Set(tcurve); } else { Reset(); } @@ -1898,26 +1898,26 @@ void WavOpacityCurveBY::Reset() lutOpacityCurveBY.reset(); } -void WavOpacityCurveBY::Set (const Curve &pCurve) +void WavOpacityCurveBY::Set(const Curve &pCurve) { if (pCurve.isIdentity()) { lutOpacityCurveBY.reset(); // raise this value if the quality suffers from this number of samples return; } - lutOpacityCurveBY (501); // raise this value if the quality suffers from this number of samples + lutOpacityCurveBY(501); // raise this value if the quality suffers from this number of samples for (int i = 0; i < 501; i++) { - lutOpacityCurveBY[i] = pCurve.getVal (double (i) / 500.); + lutOpacityCurveBY[i] = pCurve.getVal(double (i) / 500.); } } -void WavOpacityCurveBY::Set (const std::vector &curvePoints) +void WavOpacityCurveBY::Set(const std::vector &curvePoints) { if (!curvePoints.empty() && curvePoints[0] > FCT_Linear && curvePoints[0] < FCT_Unchanged) { - FlatCurve tcurve (curvePoints, false, CURVES_MIN_POLY_POINTS / 2); - tcurve.setIdentityValue (0.); - Set (tcurve); + FlatCurve tcurve(curvePoints, false, CURVES_MIN_POLY_POINTS / 2); + tcurve.setIdentityValue(0.); + Set(tcurve); } else { Reset(); } @@ -1930,26 +1930,26 @@ void WavOpacityCurveW::Reset() lutOpacityCurveW.reset(); } -void WavOpacityCurveW::Set (const Curve &pCurve) +void WavOpacityCurveW::Set(const Curve &pCurve) { if (pCurve.isIdentity()) { lutOpacityCurveW.reset(); // raise this value if the quality suffers from this number of samples return; } - lutOpacityCurveW (501); // raise this value if the quality suffers from this number of samples + lutOpacityCurveW(501); // raise this value if the quality suffers from this number of samples for (int i = 0; i < 501; i++) { - lutOpacityCurveW[i] = pCurve.getVal (double (i) / 500.); + lutOpacityCurveW[i] = pCurve.getVal(double (i) / 500.); } } -void WavOpacityCurveW::Set (const std::vector &curvePoints) +void WavOpacityCurveW::Set(const std::vector &curvePoints) { if (!curvePoints.empty() && curvePoints[0] > FCT_Linear && curvePoints[0] < FCT_Unchanged) { - FlatCurve tcurve (curvePoints, false, CURVES_MIN_POLY_POINTS / 2); - tcurve.setIdentityValue (0.); - Set (tcurve); + FlatCurve tcurve(curvePoints, false, CURVES_MIN_POLY_POINTS / 2); + tcurve.setIdentityValue(0.); + Set(tcurve); } else { Reset(); } @@ -1962,33 +1962,33 @@ void WavOpacityCurveWL::Reset() lutOpacityCurveWL.reset(); } -void WavOpacityCurveWL::Set (const Curve &pCurve) +void WavOpacityCurveWL::Set(const Curve &pCurve) { if (pCurve.isIdentity()) { lutOpacityCurveWL.reset(); // raise this value if the quality suffers from this number of samples return; } - lutOpacityCurveWL (501); // raise this value if the quality suffers from this number of samples + lutOpacityCurveWL(501); // raise this value if the quality suffers from this number of samples for (int i = 0; i < 501; i++) { - lutOpacityCurveWL[i] = pCurve.getVal (double (i) / 500.); + lutOpacityCurveWL[i] = pCurve.getVal(double (i) / 500.); } } -void WavOpacityCurveWL::Set (const std::vector &curvePoints) +void WavOpacityCurveWL::Set(const std::vector &curvePoints) { if (!curvePoints.empty() && curvePoints[0] > FCT_Linear && curvePoints[0] < FCT_Unchanged) { - FlatCurve tcurve (curvePoints, false, CURVES_MIN_POLY_POINTS / 2); - tcurve.setIdentityValue (0.); - Set (tcurve); + FlatCurve tcurve(curvePoints, false, CURVES_MIN_POLY_POINTS / 2); + tcurve.setIdentityValue(0.); + Set(tcurve); } else { Reset(); } } -NoiseCurve::NoiseCurve() : sum (0.f) {}; +NoiseCurve::NoiseCurve() : sum(0.f) {}; void NoiseCurve::Reset() { @@ -1996,18 +1996,18 @@ void NoiseCurve::Reset() sum = 0.f; } -void NoiseCurve::Set (const Curve &pCurve) +void NoiseCurve::Set(const Curve &pCurve) { if (pCurve.isIdentity()) { Reset(); // raise this value if the quality suffers from this number of samples return; } - lutNoiseCurve (501); // raise this value if the quality suffers from this number of samples + lutNoiseCurve(501); // raise this value if the quality suffers from this number of samples sum = 0.f; for (int i = 0; i < 501; i++) { - lutNoiseCurve[i] = pCurve.getVal (double (i) / 500.); + lutNoiseCurve[i] = pCurve.getVal(double (i) / 500.); if (lutNoiseCurve[i] < 0.01f) { lutNoiseCurve[i] = 0.01f; //avoid 0.f for wavelet : under 0.01f quasi no action for each value @@ -2019,13 +2019,13 @@ void NoiseCurve::Set (const Curve &pCurve) //lutNoisCurve.dump("Nois"); } -void NoiseCurve::Set (const std::vector &curvePoints) +void NoiseCurve::Set(const std::vector &curvePoints) { if (!curvePoints.empty() && curvePoints[0] > FCT_Linear && curvePoints[0] < FCT_Unchanged) { - FlatCurve tcurve (curvePoints, false, CURVES_MIN_POLY_POINTS / 2); - tcurve.setIdentityValue (0.); - Set (tcurve); + FlatCurve tcurve(curvePoints, false, CURVES_MIN_POLY_POINTS / 2); + tcurve.setIdentityValue(0.); + Set(tcurve); } else { Reset(); } @@ -2049,9 +2049,9 @@ void ColorGradientCurve::SetXYZ(const Curve *pCurve, const double xyz_rgb[3][3], } if (!lut1) { - lut1 (501); - lut2 (501); - lut3 (501); + lut1(501); + lut2(501); + lut3(501); } float r, g, b, xx, yy, zz; @@ -2059,8 +2059,8 @@ void ColorGradientCurve::SetXYZ(const Curve *pCurve, const double xyz_rgb[3][3], int upperBound = lut1.getUpperBound(); if (pCurve->isIdentity()) { - Color::hsv2rgb (0.5f, satur, lumin, r, g, b); - Color::rgbxyz (r, g, b, xx, yy, zz, xyz_rgb); + Color::hsv2rgb(0.5f, satur, lumin, r, g, b); + Color::rgbxyz(r, g, b, xx, yy, zz, xyz_rgb); for (int i = 0; i <= 500; ++i) { // WARNING: set the identity value according to what is set in the GUI @@ -2075,7 +2075,7 @@ void ColorGradientCurve::SetXYZ(const Curve *pCurve, const double xyz_rgb[3][3], int nPoints = pCurve->getSize(); int ptNum = 0; double nextX, nextY; - pCurve->getControlPoint (ptNum, nextX, nextY); + pCurve->getControlPoint(ptNum, nextX, nextY); double prevY = nextY; double dY = 0.; low = nextX; @@ -2090,7 +2090,7 @@ void ColorGradientCurve::SetXYZ(const Curve *pCurve, const double xyz_rgb[3][3], if (ptNum < nPoints) { prevY = nextY; - pCurve->getControlPoint (ptNum, nextX, nextY); + pCurve->getControlPoint(ptNum, nextX, nextY); dY = nextY - prevY; high = nextX; lr2 = (0.5f + high) / 2.f; //optimize use of gamut in high light..one can optimize more using directly high ? @@ -2099,28 +2099,28 @@ void ColorGradientCurve::SetXYZ(const Curve *pCurve, const double xyz_rgb[3][3], } if (!ptNum) { - Color::hsv2rgb (float (prevY), satur, lr1, r, g, b); - Color::rgbxyz (r, g, b, xx, yy, zz, xyz_rgb); + Color::hsv2rgb(float (prevY), satur, lr1, r, g, b); + Color::rgbxyz(r, g, b, xx, yy, zz, xyz_rgb); lut1[i] = xx; lut2[i] = yy; lut3[i] = zz; } else if (ptNum >= nPoints) { - Color::hsv2rgb (float (nextY), satur, lr2, r, g, b); - Color::rgbxyz (r, g, b, xx, yy, zz, xyz_rgb); + Color::hsv2rgb(float (nextY), satur, lr2, r, g, b); + Color::rgbxyz(r, g, b, xx, yy, zz, xyz_rgb); lut1[i] = xx; lut2[i] = yy; lut3[i] = zz; } else { - double currY = pCurve->getVal (x) - prevY; + double currY = pCurve->getVal(x) - prevY; if (dY > 0.000001 || dY < -0.000001) { float r1, g1, b1, r2, g2, b2; - Color::hsv2rgb (float (prevY), satur, lr1, r1, g1, b1); - Color::hsv2rgb (float (nextY), satur, lr2, r2, g2, b2); + Color::hsv2rgb(float (prevY), satur, lr1, r1, g1, b1); + Color::hsv2rgb(float (nextY), satur, lr2, r2, g2, b2); LUTf dum; float X1, X2, Y1, Y2, Z1, Z2, L1, a_1, b_1, c1, h1; - Color::rgbxyz (r2, g2, b2, X2, Y2, Z2, xyz_rgb); - Color::rgbxyz (r1, g1, b1, X1, Y1, Z1, xyz_rgb); + Color::rgbxyz(r2, g2, b2, X2, Y2, Z2, xyz_rgb); + Color::rgbxyz(r1, g1, b1, X1, Y1, Z1, xyz_rgb); //I use XYZ to mix color 1 and 2 rather than rgb (gamut) and rather than Lab artifacts X1 = X1 + (X2 - X1) * currY / dY; @@ -2140,29 +2140,29 @@ void ColorGradientCurve::SetXYZ(const Curve *pCurve, const double xyz_rgb[3][3], Z1 = 0.f; } - Color::XYZ2Lab (X1, Y1, Z1, L1, a_1, b_1); //prepare to gamut control - Color::Lab2Lch (a_1, b_1, c1, h1); + Color::XYZ2Lab(X1, Y1, Z1, L1, a_1, b_1); //prepare to gamut control + Color::Lab2Lch(a_1, b_1, c1, h1); float Lr = L1 / 327.68f; float RR, GG, BB; #ifndef NDEBUG bool neg = false; bool more_rgb = false; //gamut control : Lab values are in gamut - Color::gamutLchonly (h1, Lr, c1, RR, GG, BB, xyz_rgb, false, 0.15f, 0.96f, neg, more_rgb); + Color::gamutLchonly(h1, Lr, c1, RR, GG, BB, xyz_rgb, false, 0.15f, 0.96f, neg, more_rgb); #else - Color::gamutLchonly (h1, Lr, c1, RR, GG, BB, xyz_rgb, false, 0.15f, 0.96f); + Color::gamutLchonly(h1, Lr, c1, RR, GG, BB, xyz_rgb, false, 0.15f, 0.96f); #endif L1 = Lr * 327.68f; float a, b, X, Y, Z; // converting back to rgb - Color::Lch2Lab (c1, h1, a, b); - Color::Lab2XYZ (L1, a, b, X, Y, Z); + Color::Lch2Lab(c1, h1, a, b); + Color::Lab2XYZ(L1, a, b, X, Y, Z); lut1[i] = X; lut2[i] = Y; lut3[i] = Z; } else { - Color::hsv2rgb (float (nextY), satur, lumin, r, g, b); - Color::rgbxyz (r, g, b, xx, yy, zz, xyz_rgb); + Color::hsv2rgb(float (nextY), satur, lumin, r, g, b); + Color::rgbxyz(r, g, b, xx, yy, zz, xyz_rgb); lut1[i] = xx; lut2[i] = yy; lut3[i] = zz; @@ -2184,7 +2184,7 @@ void ColorGradientCurve::SetXYZ(const std::vector &curvePoints, const do std::unique_ptr tcurve; if (!curvePoints.empty() && curvePoints[0] > FCT_Linear && curvePoints[0] < FCT_Unchanged) { - tcurve = std::unique_ptr (new FlatCurve (curvePoints, false, CURVES_MIN_POLY_POINTS / 2)); + tcurve = std::unique_ptr (new FlatCurve(curvePoints, false, CURVES_MIN_POLY_POINTS / 2)); } if (tcurve) { @@ -2202,9 +2202,9 @@ void ColorGradientCurve::SetRGB(const Curve *pCurve) } if (!lut1) { - lut1 (501); - lut2 (501); - lut3 (501); + lut1(501); + lut2(501); + lut3(501); } float r, g, b; @@ -2214,7 +2214,7 @@ void ColorGradientCurve::SetRGB(const Curve *pCurve) int nPoints = pCurve->getSize(); int ptNum = 0; double nextX, nextY; - pCurve->getControlPoint (ptNum, nextX, nextY); + pCurve->getControlPoint(ptNum, nextX, nextY); double prevY = nextY; double dY = 0.; Color::eInterpolationDirection dir = Color::ID_DOWN; @@ -2227,41 +2227,41 @@ void ColorGradientCurve::SetRGB(const Curve *pCurve) if (ptNum < nPoints) { prevY = nextY; - pCurve->getControlPoint (ptNum, nextX, nextY); + pCurve->getControlPoint(ptNum, nextX, nextY); dY = nextY - prevY; - dir = Color::getHueInterpolationDirection (prevY, nextY, Color::IP_SHORTEST); + dir = Color::getHueInterpolationDirection(prevY, nextY, Color::IP_SHORTEST); } } if (!ptNum) { - Color::hsv2rgb (float (prevY), 1.f, 1.f, r, g, b); + Color::hsv2rgb(float (prevY), 1.f, 1.f, r, g, b); lut1[i] = r; lut2[i] = g; lut3[i] = b; } else if (ptNum >= nPoints) { - Color::hsv2rgb (float (nextY), 1.f, 1.f, r, g, b); + Color::hsv2rgb(float (nextY), 1.f, 1.f, r, g, b); lut1[i] = r; lut2[i] = g; lut3[i] = b; } else { - double currY = pCurve->getVal (x) - prevY; + double currY = pCurve->getVal(x) - prevY; if (dY > 0.0000001 || dY < -0.0000001) { #if 1 float ro, go, bo; - double h2 = Color::interpolateHueHSV (prevY, nextY, currY / dY, dir); - Color::hsv2rgb (h2, 1.f, 1.f, ro, go, bo); + double h2 = Color::interpolateHueHSV(prevY, nextY, currY / dY, dir); + Color::hsv2rgb(h2, 1.f, 1.f, ro, go, bo); #else float r1, g1, b1, r2, g2, b2, ro, go, bo; - Color::hsv2rgb (float (prevY), 1., 1., r1, g1, b1); - Color::hsv2rgb (float (nextY), 1., 1., r2, g2, b2); - Color::interpolateRGBColor (currY / dY, r1, g1, b1, r2, g2, b2, Color::CHANNEL_LIGHTNESS | Color::CHANNEL_CHROMATICITY | Color::CHANNEL_HUE, xyz_rgb, rgb_xyz, ro, go, bo); + Color::hsv2rgb(float (prevY), 1., 1., r1, g1, b1); + Color::hsv2rgb(float (nextY), 1., 1., r2, g2, b2); + Color::interpolateRGBColor(currY / dY, r1, g1, b1, r2, g2, b2, Color::CHANNEL_LIGHTNESS | Color::CHANNEL_CHROMATICITY | Color::CHANNEL_HUE, xyz_rgb, rgb_xyz, ro, go, bo); #endif lut1[i] = ro; lut2[i] = go; lut3[i] = bo; } else { - Color::hsv2rgb (float (nextY), 1.f, 1.f, r, g, b); + Color::hsv2rgb(float (nextY), 1.f, 1.f, r, g, b); lut1[i] = r; lut2[i] = g; lut3[i] = b; @@ -2283,7 +2283,7 @@ void ColorGradientCurve::SetRGB(const std::vector &curvePoints) std::unique_ptr tcurve; if (!curvePoints.empty() && curvePoints[0] > FCT_Linear && curvePoints[0] < FCT_Unchanged) { - tcurve = std::unique_ptr (new FlatCurve (curvePoints, false, CURVES_MIN_POLY_POINTS / 2)); + tcurve = std::unique_ptr (new FlatCurve(curvePoints, false, CURVES_MIN_POLY_POINTS / 2)); } if (tcurve) { @@ -2291,7 +2291,7 @@ void ColorGradientCurve::SetRGB(const std::vector &curvePoints) } } -void ColorGradientCurve::getVal (float index, float &r, float &g, float &b) const +void ColorGradientCurve::getVal(float index, float &r, float &g, float &b) const { r = lut1[index * 500.f]; g = lut2[index * 500.f]; @@ -2299,15 +2299,15 @@ void ColorGradientCurve::getVal (float index, float &r, float &g, float &b) cons } // this is a generic cubic spline implementation, to clean up we could probably use something already existing elsewhere -void PerceptualToneCurve::cubic_spline (const float x[], const float y[], const int len, const float out_x[], float out_y[], const int out_len) +void PerceptualToneCurve::cubic_spline(const float x[], const float y[], const int len, const float out_x[], float out_y[], const int out_len) { int i, j; - float **A = (float **)malloc (2 * len * sizeof (*A)); - float *As = (float *)calloc (1, 2 * len * 2 * len * sizeof (*As)); - float *b = (float *)calloc (1, 2 * len * sizeof (*b)); - float *c = (float *)calloc (1, 2 * len * sizeof (*c)); - float *d = (float *)calloc (1, 2 * len * sizeof (*d)); + float **A = (float **)malloc(2 * len * sizeof(*A)); + float *As = (float *)calloc(1, 2 * len * 2 * len * sizeof(*As)); + float *b = (float *)calloc(1, 2 * len * sizeof(*b)); + float *c = (float *)calloc(1, 2 * len * sizeof(*c)); + float *d = (float *)calloc(1, 2 * len * sizeof(*d)); for (i = 0; i < 2 * len; i++) { A[i] = &As[2 * len * i]; @@ -2364,35 +2364,35 @@ void PerceptualToneCurve::cubic_spline (const float x[], const float y[], const out_y[i] = y_out; } - free (A); - free (As); - free (b); - free (c); - free (d); + free(A); + free(As); + free(b); + free(c); + free(d); } // generic function for finding minimum of f(x) in the a-b range using the interval halving method -float PerceptualToneCurve::find_minimum_interval_halving (float (*func) (float x, void *arg), void *arg, float a, float b, float tol, int nmax) +float PerceptualToneCurve::find_minimum_interval_halving(float (*func)(float x, void *arg), void *arg, float a, float b, float tol, int nmax) { float L = b - a; float x = (a + b) * 0.5; for (int i = 0; i < nmax; i++) { - float f_x = func (x, arg); + float f_x = func(x, arg); if ((b - a) * 0.5 < tol) { return x; } float x1 = a + L / 4; - float f_x1 = func (x1, arg); + float f_x1 = func(x1, arg); if (f_x1 < f_x) { b = x; x = x1; } else { float x2 = b - L / 4; - float f_x2 = func (x2, arg); + float f_x2 = func(x2, arg); if (f_x2 < f_x) { a = x; @@ -2413,7 +2413,7 @@ struct find_tc_slope_fun_arg { const ToneCurve * tc; }; -float PerceptualToneCurve::find_tc_slope_fun (float k, void *arg) +float PerceptualToneCurve::find_tc_slope_fun(float k, void *arg) { struct find_tc_slope_fun_arg *a = (struct find_tc_slope_fun_arg *)arg; float areasum = 0; @@ -2421,7 +2421,7 @@ float PerceptualToneCurve::find_tc_slope_fun (float k, void *arg) for (int i = 0; i < steps; i++) { float x = 0.1 + ((float)i / (steps - 1)) * 0.5; // testing (sRGB) range [0.1 - 0.6], ie ignore highligths and dark shadows - float y = CurveFactory::gamma2 (a->tc->lutToneCurve[CurveFactory::igamma2 (x) * 65535] / 65535.0); + float y = CurveFactory::gamma2(a->tc->lutToneCurve[CurveFactory::igamma2(x) * 65535] / 65535.0); float y1 = k * x; if (y1 > 1) { @@ -2434,7 +2434,7 @@ float PerceptualToneCurve::find_tc_slope_fun (float k, void *arg) return areasum; } -float PerceptualToneCurve::get_curve_val (float x, float range[2], float lut[], size_t lut_size) +float PerceptualToneCurve::get_curve_val(float x, float range[2], float lut[], size_t lut_size) { float xm = (x - range[0]) / (range[1] - range[0]) * (lut_size - 1); @@ -2444,7 +2444,7 @@ float PerceptualToneCurve::get_curve_val (float x, float range[2], float lut[], int idx = (int)xm; - if (idx >= static_cast (lut_size) - 1) { + if (idx >= static_cast(lut_size) - 1) { return lut[lut_size - 1]; } @@ -2460,7 +2460,7 @@ float PerceptualToneCurve::calculateToneCurveContrastValue() const // Note: the analysis is made on the gamma encoded curve, as the LUT is linear we make backwards gamma to struct find_tc_slope_fun_arg arg = { this }; - float k = find_minimum_interval_halving (find_tc_slope_fun, &arg, 0.1, 5.0, 0.01, 20); // normally found in 8 iterations + float k = find_minimum_interval_halving(find_tc_slope_fun, &arg, 0.1, 5.0, 0.01, 20); // normally found in 8 iterations //fprintf(stderr, "average slope: %f\n", k); float maxslope = 0; @@ -2469,11 +2469,11 @@ float PerceptualToneCurve::calculateToneCurveContrastValue() const const float xd = 0.07; const float tx[] = { 0.30, 0.35, 0.40, 0.45 }; // we only look in the midtone range - for (size_t i = 0; i < sizeof (tx) / sizeof (tx[0]); i++) { + for (size_t i = 0; i < sizeof(tx) / sizeof(tx[0]); i++) { float x0 = tx[i] - xd; - float y0 = CurveFactory::gamma2 (lutToneCurve[CurveFactory::igamma2 (x0) * 65535.f] / 65535.f) - k * x0; + float y0 = CurveFactory::gamma2(lutToneCurve[CurveFactory::igamma2(x0) * 65535.f] / 65535.f) - k * x0; float x1 = tx[i] + xd; - float y1 = CurveFactory::gamma2 (lutToneCurve[CurveFactory::igamma2 (x1) * 65535.f] / 65535.f) - k * x1; + float y1 = CurveFactory::gamma2(lutToneCurve[CurveFactory::igamma2(x1) * 65535.f] / 65535.f) - k * x1; float slope = 1.0 + (y1 - y0) / (x1 - x0); if (slope > maxslope) { @@ -2486,11 +2486,11 @@ float PerceptualToneCurve::calculateToneCurveContrastValue() const { const float tx[] = { 0.20, 0.25, 0.50, 0.55 }; // we only look in the midtone range - for (size_t i = 0; i < sizeof (tx) / sizeof (tx[0]); i++) { + for (size_t i = 0; i < sizeof(tx) / sizeof(tx[0]); i++) { float x0 = tx[i] - xd; - float y0 = CurveFactory::gamma2 (lutToneCurve[CurveFactory::igamma2 (x0) * 65535.f] / 65535.f) - k * x0; + float y0 = CurveFactory::gamma2(lutToneCurve[CurveFactory::igamma2(x0) * 65535.f] / 65535.f) - k * x0; float x1 = tx[i] + xd; - float y1 = CurveFactory::gamma2 (lutToneCurve[CurveFactory::igamma2 (x1) * 65535.f] / 65535.f) - k * x1; + float y1 = CurveFactory::gamma2(lutToneCurve[CurveFactory::igamma2(x1) * 65535.f] / 65535.f) - k * x1; float slope = 1.0 + (y1 - y0) / (x1 - x0); if (slope > e_maxslope) { @@ -2505,7 +2505,7 @@ float PerceptualToneCurve::calculateToneCurveContrastValue() const return maxslope; } -void PerceptualToneCurve::Apply (float &r, float &g, float &b, PerceptualToneCurveState & state) const +void PerceptualToneCurve::Apply(float &r, float &g, float &b, PerceptualToneCurveState & state) const { float x, y, z; @@ -2519,11 +2519,11 @@ void PerceptualToneCurve::Apply (float &r, float &g, float &b, PerceptualToneCur b = newb; } - const AdobeToneCurve& adobeTC = static_cast ((const ToneCurve&) * this); + const AdobeToneCurve& adobeTC = static_cast((const ToneCurve&) * this); float ar = r; float ag = g; float ab = b; - adobeTC.Apply (ar, ag, ab); + adobeTC.Apply(ar, ag, ab); if (ar >= 65535.f && ag >= 65535.f && ab >= 65535.f) { // clip fast path, will also avoid strange colors of clipped highlights @@ -2551,17 +2551,17 @@ void PerceptualToneCurve::Apply (float &r, float &g, float &b, PerceptualToneCur b = LIM (b * Lcoef, 0.f, 65535.f); // move to JCh so we can modulate chroma based on the global contrast-related chroma scaling factor - Color::Prophotoxyz (r, g, b, x, y, z); + Color::Prophotoxyz(r, g, b, x, y, z); float J, C, h; - Ciecam02::xyz2jch_ciecam02float ( J, C, h, - aw, fl, - x * 0.0015259022f, y * 0.0015259022f, z * 0.0015259022f, - xw, yw, zw, - c, nc, pow1, nbb, ncb, cz, d); + Ciecam02::xyz2jch_ciecam02float(J, C, h, + aw, fl, + x * 0.0015259022f, y * 0.0015259022f, z * 0.0015259022f, + xw, yw, zw, + c, nc, pow1, nbb, ncb, cz, d); - if (!isfinite (J) || !isfinite (C) || !isfinite (h)) { + if (!isfinite(J) || !isfinite(C) || !isfinite(h)) { // this can happen for dark noise colors or colors outside human gamut. Then we just return the curve's result. if (!state.isProphoto) { float newr = state.Prophoto2Working[0][0] * r + state.Prophoto2Working[0][1] * g + state.Prophoto2Working[0][2] * b; @@ -2593,9 +2593,9 @@ void PerceptualToneCurve::Apply (float &r, float &g, float &b, PerceptualToneCur float x = (C - lolim) / (hilim - lolim); // x = [0..1], 0 at lolim, 1 at hilim if (x < 0.5f) { - x = 2.f * SQR (x); + x = 2.f * SQR(x); } else { - x = 1.f - 2.f * SQR (1 - x); + x = 1.f - 2.f * SQR(1 - x); } saturated_scale_factor = (1.f - x) + saturated_scale_factor * x; @@ -2621,9 +2621,9 @@ void PerceptualToneCurve::Apply (float &r, float &g, float &b, PerceptualToneCur float x = (nL - lolim) / (hilim - lolim); // x = [0..1], 0 at lolim, 1 at hilim if (x < 0.5f) { - x = 2.f * SQR (x); + x = 2.f * SQR(x); } else { - x = 1.f - 2.f * SQR (1 - x); + x = 1.f - 2.f * SQR(1 - x); } dark_scale_factor = dark_scale_factor * (1.0f - x) + x; @@ -2647,9 +2647,9 @@ void PerceptualToneCurve::Apply (float &r, float &g, float &b, PerceptualToneCur float x = (J - lolim) / (hilim - lolim); if (x < 0.5f) { - x = 2.f * SQR (x); + x = 2.f * SQR(x); } else { - x = 1.f - 2.f * SQR (1 - x); + x = 1.f - 2.f * SQR(1 - x); } dark_scale_factor = dark_scale_factor * (1.f - x) + x; @@ -2662,12 +2662,12 @@ void PerceptualToneCurve::Apply (float &r, float &g, float &b, PerceptualToneCur C *= cmul; - Ciecam02::jch2xyz_ciecam02float( x, y, z, - J, C, h, - xw, yw, zw, - c, nc, 1, pow1, nbb, ncb, fl, cz, d, aw ); + Ciecam02::jch2xyz_ciecam02float(x, y, z, + J, C, h, + xw, yw, zw, + c, nc, 1, pow1, nbb, ncb, fl, cz, d, aw); - if (!isfinite (x) || !isfinite (y) || !isfinite (z)) { + if (!isfinite(x) || !isfinite(y) || !isfinite(z)) { // can happen for colors on the rim of being outside gamut, that worked without chroma scaling but not with. Then we return only the curve's result. if (!state.isProphoto) { float newr = state.Prophoto2Working[0][0] * r + state.Prophoto2Working[0][1] * g + state.Prophoto2Working[0][2] * b; @@ -2681,7 +2681,7 @@ void PerceptualToneCurve::Apply (float &r, float &g, float &b, PerceptualToneCur return; } - Color::xyz2Prophoto (x, y, z, r, g, b); + Color::xyz2Prophoto(x, y, z, r, g, b); r *= 655.35f; g *= 655.35f; b *= 655.35f; @@ -2696,8 +2696,8 @@ void PerceptualToneCurve::Apply (float &r, float &g, float &b, PerceptualToneCur // saturation greatly, but desaturates extreme highlights and thus provide a smooth transition to // the white point. However the desaturation effect is quite strong so we make a weighting float ah, as, av, h, s, v; - Color::rgb2hsv (ar, ag, ab, ah, as, av); - Color::rgb2hsv (r, g, b, h, s, v); + Color::rgb2hsv(ar, ag, ab, ah, as, av); + Color::rgb2hsv(r, g, b, h, s, v); float sat_scale = as <= 0.f ? 1.f : s / as; // saturation scale compared to Adobe curve float keep = 0.2f; @@ -2712,9 +2712,9 @@ void PerceptualToneCurve::Apply (float &r, float &g, float &b, PerceptualToneCur float x = (sat_scale - lolim) / (hilim - lolim); // x = [0..1], 0 at lolim, 1 at hilim if (x < 0.5f) { - x = 2.f * SQR (x); + x = 2.f * SQR(x); } else { - x = 1.f - 2.f * SQR (1 - x); + x = 1.f - 2.f * SQR(1 - x); } keep = (1.f - x) + keep * x; @@ -2758,9 +2758,9 @@ void PerceptualToneCurve::init() c = 0.69f; nc = 1.00f; - Ciecam02::initcam1float (gamut, yb, 1.f, f, la, xw, yw, zw, n, d, nbb, ncb, - cz, aw, wh, pfl, fl, c); - pow1 = pow_F ( 1.64f - pow_F ( 0.29f, n ), 0.73f ); + Ciecam02::initcam1float(gamut, yb, 1.f, f, la, xw, yw, zw, n, d, nbb, ncb, + cz, aw, wh, pfl, fl, c); + pow1 = pow_F(1.64f - pow_F(0.29f, n), 0.73f); { // init contrast-value-to-chroma-scaling conversion curve @@ -2784,7 +2784,7 @@ void PerceptualToneCurve::init() 2.00, 1.22 // highest contrast }; - const size_t in_len = sizeof (p) / sizeof (p[0]) / 2; + const size_t in_len = sizeof(p) / sizeof(p[0]) / 2; float in_x[in_len]; float in_y[in_len]; @@ -2793,25 +2793,25 @@ void PerceptualToneCurve::init() in_y[i] = p[2 * i + 1]; } - const size_t out_len = sizeof (cf) / sizeof (cf[0]); + const size_t out_len = sizeof(cf) / sizeof(cf[0]); float out_x[out_len]; for (size_t i = 0; i < out_len; i++) { out_x[i] = in_x[0] + (in_x[in_len - 1] - in_x[0]) * (float)i / (out_len - 1); } - cubic_spline (in_x, in_y, in_len, out_x, cf, out_len); + cubic_spline(in_x, in_y, in_len, out_x, cf, out_len); cf_range[0] = in_x[0]; cf_range[1] = in_x[in_len - 1]; } } -void PerceptualToneCurve::initApplyState (PerceptualToneCurveState & state, Glib::ustring workingSpace) const +void PerceptualToneCurve::initApplyState(PerceptualToneCurveState & state, Glib::ustring workingSpace) const { // Get the curve's contrast value, and convert to a chroma scaling const float contrast_value = calculateToneCurveContrastValue(); - state.cmul_contrast = get_curve_val (contrast_value, cf_range, cf, sizeof (cf) / sizeof (cf[0])); + state.cmul_contrast = get_curve_val(contrast_value, cf_range, cf, sizeof(cf) / sizeof(cf[0])); //fprintf(stderr, "contrast value: %f => chroma scaling %f\n", contrast_value, state.cmul_contrast); // Create state for converting to/from prophoto (if necessary) @@ -2819,8 +2819,8 @@ void PerceptualToneCurve::initApplyState (PerceptualToneCurveState & state, Glib state.isProphoto = true; } else { state.isProphoto = false; - TMatrix Work = ICCStore::getInstance()->workingSpaceMatrix (workingSpace); - memset (state.Working2Prophoto, 0, sizeof (state.Working2Prophoto)); + TMatrix Work = ICCStore::getInstance()->workingSpaceMatrix(workingSpace); + memset(state.Working2Prophoto, 0, sizeof(state.Working2Prophoto)); for (int i = 0; i < 3; i++) for (int j = 0; j < 3; j++) @@ -2828,8 +2828,8 @@ void PerceptualToneCurve::initApplyState (PerceptualToneCurveState & state, Glib state.Working2Prophoto[i][j] += prophoto_xyz[i][k] * Work[k][j]; } - Work = ICCStore::getInstance()->workingSpaceInverseMatrix (workingSpace); - memset (state.Prophoto2Working, 0, sizeof (state.Prophoto2Working)); + Work = ICCStore::getInstance()->workingSpaceInverseMatrix(workingSpace); + memset(state.Prophoto2Working, 0, sizeof(state.Prophoto2Working)); for (int i = 0; i < 3; i++) for (int j = 0; j < 3; j++) diff --git a/rtengine/curves.h b/rtengine/curves.h index 34f672b13..f75cfabc6 100644 --- a/rtengine/curves.h +++ b/rtengine/curves.h @@ -53,33 +53,33 @@ class CurveFactory protected: // functions calculating the parameters of the contrast curve based on the desired slope at the center - static double solve_upper (double m, double c, double deriv); - static double solve_lower (double m, double c, double deriv); - static double dupper (const double b, const double m, const double c); - static double dlower (const double b, const double m, const double c); + static double solve_upper(double m, double c, double deriv); + static double solve_lower(double m, double c, double deriv); + static double dupper(const double b, const double m, const double c); + static double dlower(const double b, const double m, const double c); // basic convex function between (0,0) and (1,1). m1 and m2 controls the slope at the start and end point - static inline double basel (double x, double m1, double m2) + static inline double basel(double x, double m1, double m2) { if (x == 0.0) { return 0.0; } - double k = sqrt ((m1 - 1.0) * (m1 - m2) * 0.5) / (1.0 - m2); + double k = sqrt((m1 - 1.0) * (m1 - m2) * 0.5) / (1.0 - m2); double l = (m1 - m2) / (1.0 - m2) + k; - double lx = xlog (x); - return m2 * x + (1.0 - m2) * (2.0 - xexp (k * lx)) * xexp (l * lx); + double lx = xlog(x); + return m2 * x + (1.0 - m2) * (2.0 - xexp(k * lx)) * xexp(l * lx); } // basic concave function between (0,0) and (1,1). m1 and m2 controls the slope at the start and end point - static inline double baseu (double x, double m1, double m2) + static inline double baseu(double x, double m1, double m2) { - return 1.0 - basel (1.0 - x, m1, m2); + return 1.0 - basel(1.0 - x, m1, m2); } // convex curve between (0,0) and (1,1) with slope m at (0,0). hr controls the highlight recovery - static inline double cupper (double x, double m, double hr) + static inline double cupper(double x, double m, double hr) { if (hr > 1.0) { - return baseu (x, m, 2.0 * (hr - 1.0) / m); + return baseu(x, m, 2.0 * (hr - 1.0) / m); } double x1 = (1.0 - hr) / m; @@ -93,15 +93,15 @@ protected: return x * m; } - return 1.0 - hr + hr * baseu ((x - x1) / hr, m, 0); + return 1.0 - hr + hr * baseu((x - x1) / hr, m, 0); } // concave curve between (0,0) and (1,1) with slope m at (1,1). sr controls the shadow recovery - static inline double clower (double x, double m, double sr) + static inline double clower(double x, double m, double sr) { - return 1.0 - cupper (1.0 - x, m, sr); + return 1.0 - cupper(1.0 - x, m, sr); } // convex curve between (0,0) and (1,1) with slope m at (0,0). hr controls the highlight recovery - static inline double cupper2 (double x, double m, double hr) + static inline double cupper2(double x, double m, double hr) { double x1 = (1.0 - hr) / m; double x2 = x1 + hr; @@ -114,9 +114,9 @@ protected: return x * m; } - return 1.0 - hr + hr * baseu ((x - x1) / hr, m, 0.3 * hr); + return 1.0 - hr + hr * baseu((x - x1) / hr, m, 0.3 * hr); } - static inline double clower2 (double x, double m, double sr) + static inline double clower2(double x, double m, double sr) { //curve for b<0; starts with positive slope and then rolls over toward straight line to x=y=1 double x1 = sr / 1.5 + 0.00001; @@ -125,12 +125,12 @@ protected: return 1 - (1 - x) * m; } else { double y1 = 1 - (1 - x1) * m; - return y1 + m * (x - x1) - (1 - m) * SQR (SQR (1 - x / x1)); + return y1 + m * (x - x1) - (1 - m) * SQR(SQR(1 - x / x1)); } } // tone curve base. a: slope (from exp.comp.), b: black point normalized by 65535, // D: max. x value (can be>1), hr,sr: highlight,shadow recovery - static inline double basecurve (double x, double a, double b, double D, double hr, double sr) + static inline double basecurve(double x, double a, double b, double D, double hr, double sr) { if (b < 0) { double m = 0.5;//midpoint @@ -140,7 +140,7 @@ protected: if (x > m) { return y + (x - m) * slope; //value on straight line between (m,y) and (1,1) } else { - return y * clower2 (x / m, slope * m / y, 2.0 - sr); + return y * clower2(x / m, slope * m / y, 2.0 - sr); } } else { double slope = a / (1.0 - b); @@ -148,15 +148,15 @@ protected: double y = a * D > 1.0 ? 0.25 : (m - b / a) * slope; if (x <= m) { - return b == 0 ? x * slope : clower (x / m, slope * m / y, sr) * y; + return b == 0 ? x * slope : clower(x / m, slope * m / y, sr) * y; } else if (a * D > 1.0) { - return y + (1.0 - y) * cupper2 ((x - m) / (D - m), slope * (D - m) / (1.0 - y), hr); + return y + (1.0 - y) * cupper2((x - m) / (D - m), slope * (D - m) / (1.0 - y), hr); } else { return y + (x - m) * slope; } } } - static inline double simplebasecurve (double x, double b, double sr) + static inline double simplebasecurve(double x, double b, double sr) { // a = 1, D = 1, hr = 0 (unused for a = D = 1) if (b == 0.0) { @@ -169,7 +169,7 @@ protected: if (x > m) { return y + (x - m) * slope; //value on straight line between (m,y) and (1,1) } else { - return y * clower2 (x / m, slope * m / y, 2.0 - sr); + return y * clower2(x / m, slope * m / y, 2.0 - sr); } } else { double slope = 1.0 / (1.0 - b); @@ -177,7 +177,7 @@ protected: double y = (m - b) * slope; if (x <= m) { - return clower (x / m, slope * m / y, sr) * y; + return clower(x / m, slope * m / y, sr) * y; } else { return y + (x - m) * slope; } @@ -193,70 +193,70 @@ public: //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // accurately determine value from integer array with float as index //linearly interpolate from ends of range if arg is out of bounds - static inline float interp (int *array, float f) + static inline float interp(int *array, float f) { - int index = CLIPI (floor (f)); - float part = (float) ((f) - index) * (float) (array[index + 1] - array[index]); + int index = CLIPI(floor(f)); + float part = (float)((f) - index) * (float)(array[index + 1] - array[index]); return (float)array[index] + part; } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // accurately determine value from float array with float as index //linearly interpolate from ends of range if arg is out of bounds - static inline float flinterp (float *array, float f) + static inline float flinterp(float *array, float f) { - int index = CLIPI (floor (f)); + int index = CLIPI(floor(f)); float part = ((f) - (float)index) * (array[index + 1] - array[index]); return array[index] + part; } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - static inline double centercontrast (double x, double b, double m); + static inline double centercontrast(double x, double b, double m); // standard srgb gamma and its inverse - static inline double gamma2 (double x) + static inline double gamma2(double x) { - return x <= 0.00304 ? x * 12.92 : 1.055 * exp (log (x) / sRGBGammaCurve) - 0.055; + return x <= 0.00304 ? x * 12.92 : 1.055 * exp(log(x) / sRGBGammaCurve) - 0.055; } - static inline double igamma2 (double x) + static inline double igamma2(double x) { - return x <= 0.03928 ? x / 12.92 : exp (log ((x + 0.055) / 1.055) * sRGBGammaCurve); + return x <= 0.03928 ? x / 12.92 : exp(log((x + 0.055) / 1.055) * sRGBGammaCurve); } - static inline float gamma2 (float x) + static inline float gamma2(float x) { - return x <= 0.00304 ? x * 12.92 : 1.055 * expf (logf (x) / sRGBGammaCurve) - 0.055; + return x <= 0.00304 ? x * 12.92 : 1.055 * expf(logf(x) / sRGBGammaCurve) - 0.055; } - static inline float igamma2 (float x) + static inline float igamma2(float x) { - return x <= 0.03928 ? x / 12.92 : expf (logf ((x + 0.055) / 1.055) * sRGBGammaCurve); + return x <= 0.03928 ? x / 12.92 : expf(logf((x + 0.055) / 1.055) * sRGBGammaCurve); } // gamma function with adjustable parameters - static inline double gamma (double x, double gamma, double start, double slope, double mul, double add) + static inline double gamma(double x, double gamma, double start, double slope, double mul, double add) { - return (x <= start ? x*slope : exp (log (x) / gamma) * mul - add); + return (x <= start ? x*slope : exp(log(x) / gamma) * mul - add); } - static inline double igamma (double x, double gamma, double start, double slope, double mul, double add) + static inline double igamma(double x, double gamma, double start, double slope, double mul, double add) { - return (x <= start * slope ? x / slope : exp (log ((x + add) / mul) * gamma) ); + return (x <= start * slope ? x / slope : exp(log((x + add) / mul) * gamma)); } - static inline float gamma (float x, float gamma, float start, float slope, float mul, float add) + static inline float gamma(float x, float gamma, float start, float slope, float mul, float add) { - return (x <= start ? x*slope : xexpf (xlogf (x) / gamma) * mul - add); + return (x <= start ? x*slope : xexpf(xlogf(x) / gamma) * mul - add); } - static inline float igamma (float x, float gamma, float start, float slope, float mul, float add) + static inline float igamma(float x, float gamma, float start, float slope, float mul, float add) { - return (x <= start * slope ? x / slope : xexpf (xlogf ((x + add) / mul) * gamma) ); + return (x <= start * slope ? x / slope : xexpf(xlogf((x + add) / mul) * gamma)); } #ifdef __SSE2__ - static inline vfloat igamma (vfloat x, vfloat gamma, vfloat start, vfloat slope, vfloat mul, vfloat add) + static inline vfloat igamma(vfloat x, vfloat gamma, vfloat start, vfloat slope, vfloat mul, vfloat add) { #if !defined(__clang__) - return (x <= start * slope ? x / slope : xexpf (xlogf ((x + add) / mul) * gamma) ); + return (x <= start * slope ? x / slope : xexpf(xlogf((x + add) / mul) * gamma)); #else - return vself (vmaskf_le (x, start * slope), x / slope, xexpf (xlogf ((x + add) / mul) * gamma)); + return vself(vmaskf_le(x, start * slope), x / slope, xexpf(xlogf((x + add) / mul) * gamma)); #endif } #endif - static inline float hlcurve (const float exp_scale, const float comp, const float hlrange, float level) + static inline float hlcurve(const float exp_scale, const float comp, const float hlrange, float level) { if (comp > 0.0) { float val = level + (hlrange - 65536.0); @@ -273,13 +273,13 @@ public: } float R = hlrange / (val * comp); - return log1p (Y) * R; + return log1p(Y) * R; } else { return exp_scale; } } - static inline float hlcurveloc (const float exp_scale, const float comp, const float hlrange, float level, float niv) + static inline float hlcurveloc(const float exp_scale, const float comp, const float hlrange, float level, float niv) { if (comp > 0.0) { float val = level + (hlrange - niv);//655536 32768 @@ -296,52 +296,52 @@ public: } float R = hlrange / (val * comp); - return log1p (Y) * R; + return log1p(Y) * R; } else { return exp_scale; } } - + public: - static void complexCurve (double ecomp, double black, double hlcompr, double hlcomprthresh, double shcompr, double br, double contr, - const std::vector& curvePoints, const std::vector& curvePoints2, - LUTu & histogram, LUTf & hlCurve, LUTf & shCurve, LUTf & outCurve, LUTu & outBeforeCCurveHistogram, ToneCurve & outToneCurve, ToneCurve & outToneCurve2, + static void complexCurve(double ecomp, double black, double hlcompr, double hlcomprthresh, double shcompr, double br, double contr, + const std::vector& curvePoints, const std::vector& curvePoints2, + LUTu & histogram, LUTf & hlCurve, LUTf & shCurve, LUTf & outCurve, LUTu & outBeforeCCurveHistogram, ToneCurve & outToneCurve, ToneCurve & outToneCurve2, - int skip = 1); + int skip = 1); - static void complexCurvelocal (double ecomp, double black, double hlcompr, double hlcomprthresh, double shcompr, double br, double contr, - LUTu & histogram, LUTf & hlCurve, LUTf & shCurve, LUTf & outCurve, - int skip = 1); - - static void curveBW (const std::vector& curvePointsbw, const std::vector& curvePointsbw2, const LUTu & histogrambw, LUTu & outBeforeCCurveHistogrambw, - ToneCurve & customToneCurvebw1, ToneCurve & customToneCurvebw2, int skip); - - static void curveCL ( bool & clcutili, const std::vector& clcurvePoints, LUTf & clCurve, int skip); - - static void curveWavContL ( bool & wavcontlutili, const std::vector& wavclcurvePoints, LUTf & wavclCurve,/* LUTu & histogramwavcl, LUTu & outBeforeWavCLurveHistogram,*/int skip); - static void curveDehaContL ( bool & dehacontlutili, const std::vector& dehaclcurvePoints, LUTf & dehaclCurve, int skip, const LUTu & histogram, LUTu & outBeforeCurveHistogram); - static void mapcurve ( bool & mapcontlutili, const std::vector& mapcurvePoints, LUTf & mapcurve, int skip, const LUTu & histogram, LUTu & outBeforeCurveHistogram); - - static void curveToning ( const std::vector& curvePoints, LUTf & ToningCurve, int skip); - - static void curveLocal ( bool & locallutili, const std::vector& curvePoints, LUTf & LocalLCurve, int skip); - static void curveCCLocal ( bool & localcutili, const std::vector& curvePoints, LUTf & LocalCCurve, int skip); - static void curveskLocal ( bool & localskutili, const std::vector& curvePoints, LUTf & LocalskCurve, int skip); - static void curveexLocal ( bool & localexutili, const std::vector& curvePoints, LUTf & LocalexCurve, int skip); - - static void complexsgnCurve ( bool & autili, bool & butili, bool & ccutili, bool & clcutili, const std::vector& acurvePoints, - const std::vector& bcurvePoints, const std::vector& cccurvePoints, const std::vector& lccurvePoints, LUTf & aoutCurve, LUTf & boutCurve, LUTf & satCurve, LUTf & lhskCurve, + static void complexCurvelocal(double ecomp, double black, double hlcompr, double hlcomprthresh, double shcompr, double br, double contr, + LUTu & histogram, LUTf & hlCurve, LUTf & shCurve, LUTf & outCurve, int skip = 1); - static void localLCurve (double br, double contr,/* const std::vector& curvePoints,*/ LUTu & histogram, LUTf & outCurve, int skip, bool & utili); + static void curveBW(const std::vector& curvePointsbw, const std::vector& curvePointsbw2, const LUTu & histogrambw, LUTu & outBeforeCCurveHistogrambw, + ToneCurve & customToneCurvebw1, ToneCurve & customToneCurvebw2, int skip); - static void updatechroma ( + static void curveCL(bool & clcutili, const std::vector& clcurvePoints, LUTf & clCurve, int skip); + + static void curveWavContL(bool & wavcontlutili, const std::vector& wavclcurvePoints, LUTf & wavclCurve,/* LUTu & histogramwavcl, LUTu & outBeforeWavCLurveHistogram,*/int skip); + static void curveDehaContL(bool & dehacontlutili, const std::vector& dehaclcurvePoints, LUTf & dehaclCurve, int skip, const LUTu & histogram, LUTu & outBeforeCurveHistogram); + static void mapcurve(bool & mapcontlutili, const std::vector& mapcurvePoints, LUTf & mapcurve, int skip, const LUTu & histogram, LUTu & outBeforeCurveHistogram); + + static void curveToning(const std::vector& curvePoints, LUTf & ToningCurve, int skip); + + static void curveLocal(bool & locallutili, const std::vector& curvePoints, LUTf & LocalLCurve, int skip); + static void curveCCLocal(bool & localcutili, const std::vector& curvePoints, LUTf & LocalCCurve, int skip); + static void curveskLocal(bool & localskutili, const std::vector& curvePoints, LUTf & LocalskCurve, int skip); + static void curveexLocal(bool & localexutili, const std::vector& curvePoints, LUTf & LocalexCurve, int skip); + + static void complexsgnCurve(bool & autili, bool & butili, bool & ccutili, bool & clcutili, const std::vector& acurvePoints, + const std::vector& bcurvePoints, const std::vector& cccurvePoints, const std::vector& lccurvePoints, LUTf & aoutCurve, LUTf & boutCurve, LUTf & satCurve, LUTf & lhskCurve, + int skip = 1); + + static void localLCurve(double br, double contr,/* const std::vector& curvePoints,*/ LUTu & histogram, LUTf & outCurve, int skip, bool & utili); + + static void updatechroma( const std::vector& cccurvePoints, LUTu & histogramC, LUTu & outBeforeCCurveHistogramC,//for chroma int skip = 1); - static void complexLCurve (double br, double contr, const std::vector& curvePoints, const LUTu & histogram, LUTf & outCurve, LUTu & outBeforeCCurveHistogram, int skip, bool & utili); + static void complexLCurve(double br, double contr, const std::vector& curvePoints, const LUTu & histogram, LUTf & outCurve, LUTu & outBeforeCCurveHistogram, int skip, bool & utili); - static void curveLightBrightColor ( + static void curveLightBrightColor( const std::vector& curvePoints, const std::vector& curvePoints2, const std::vector& curvePoints3, @@ -351,7 +351,7 @@ public: ColorAppearance & outColCurve2, ColorAppearance & outColCurve3, int skip = 1); - static void RGBCurve (const std::vector& curvePoints, LUTf & outCurve, int skip); + static void RGBCurve(const std::vector& curvePoints, LUTf & outCurve, int skip); }; @@ -389,40 +389,40 @@ protected: double increment; int nbr_points; - static inline double p00 (double x, double prot) + static inline double p00(double x, double prot) { - return CurveFactory::clower (x, 2.0, prot); + return CurveFactory::clower(x, 2.0, prot); } - static inline double p11 (double x, double prot) + static inline double p11(double x, double prot) { - return CurveFactory::cupper (x, 2.0, prot); + return CurveFactory::cupper(x, 2.0, prot); } - static inline double p01 (double x, double prot) + static inline double p01(double x, double prot) { - return x <= 0.5 ? CurveFactory::clower (x * 2, 2.0, prot) * 0.5 : 0.5 + CurveFactory::cupper ((x - 0.5) * 2, 2.0, prot) * 0.5; + return x <= 0.5 ? CurveFactory::clower(x * 2, 2.0, prot) * 0.5 : 0.5 + CurveFactory::cupper((x - 0.5) * 2, 2.0, prot) * 0.5; } - static inline double p10 (double x, double prot) + static inline double p10(double x, double prot) { - return x <= 0.5 ? CurveFactory::cupper (x * 2, 2.0, prot) * 0.5 : 0.5 + CurveFactory::clower ((x - 0.5) * 2, 2.0, prot) * 0.5; + return x <= 0.5 ? CurveFactory::cupper(x * 2, 2.0, prot) * 0.5 : 0.5 + CurveFactory::clower((x - 0.5) * 2, 2.0, prot) * 0.5; } - static inline double pfull (double x, double prot, double sh, double hl) + static inline double pfull(double x, double prot, double sh, double hl) { - return (1 - sh) * (1 - hl) * p00 (x, prot) + sh * hl * p11 (x, prot) + (1 - sh) * hl * p01 (x, prot) + sh * (1 - hl) * p10 (x, prot); + return (1 - sh) * (1 - hl) * p00(x, prot) + sh * hl * p11(x, prot) + (1 - sh) * hl * p01(x, prot) + sh * (1 - hl) * p10(x, prot); } void fillHash(); void fillDyByDx(); public: - Curve (); - virtual ~Curve () {}; - void AddPolygons (); - int getSize () const; // return the number of control points - void getControlPoint (int cpNum, double &x, double &y) const; - virtual double getVal (double t) const = 0; - virtual void getVal (const std::vector& t, std::vector& res) const = 0; + Curve(); + virtual ~Curve() {}; + void AddPolygons(); + int getSize() const; // return the number of control points + void getControlPoint(int cpNum, double &x, double &y) const; + virtual double getVal(double t) const = 0; + virtual void getVal(const std::vector& t, std::vector& res) const = 0; - virtual bool isIdentity () const = 0; + virtual bool isIdentity() const = 0; }; class DiagonalCurve : public Curve @@ -431,16 +431,16 @@ class DiagonalCurve : public Curve protected: DiagonalCurveType kind; - void spline_cubic_set (); - void NURBS_set (); + void spline_cubic_set(); + void NURBS_set(); public: - DiagonalCurve (const std::vector& points, int ppn = CURVES_MIN_POLY_POINTS); - virtual ~DiagonalCurve (); + DiagonalCurve(const std::vector& points, int ppn = CURVES_MIN_POLY_POINTS); + virtual ~DiagonalCurve(); - double getVal (double t) const; - void getVal (const std::vector& t, std::vector& res) const; - bool isIdentity () const + double getVal(double t) const; + void getVal(const std::vector& t, std::vector& res) const; + bool isIdentity() const { return kind == DCT_Empty; }; @@ -456,17 +456,17 @@ private: double identityValue; bool periodic; - void CtrlPoints_set (); + void CtrlPoints_set(); public: - FlatCurve (const std::vector& points, bool isPeriodic = true, int ppn = CURVES_MIN_POLY_POINTS); - virtual ~FlatCurve (); + FlatCurve(const std::vector& points, bool isPeriodic = true, int ppn = CURVES_MIN_POLY_POINTS); + virtual ~FlatCurve(); - double getVal (double t) const; - void getVal (const std::vector& t, std::vector& res) const; - bool setIdentityValue (double iVal); - bool isIdentity () const + double getVal(double t) const; + void getVal(const std::vector& t, std::vector& res) const; + bool setIdentityValue(double iVal); + bool isIdentity() const { return kind == FCT_Empty; }; @@ -476,16 +476,16 @@ class RetinextransmissionCurve { private: LUTf luttransmission; // 0xffff range - void Set (const Curve &pCurve); + void Set(const Curve &pCurve); public: virtual ~RetinextransmissionCurve() {}; RetinextransmissionCurve(); void Reset(); - void Set (const Curve *pCurve); - void Set (const std::vector &curvePoints); - float operator[] (float index) const + void Set(const Curve *pCurve); + void Set(const std::vector &curvePoints); + float operator[](float index) const { return luttransmission[index]; } @@ -500,16 +500,16 @@ class RetinexgaintransmissionCurve { private: LUTf lutgaintransmission; // 0xffff range - void Set (const Curve &pCurve); + void Set(const Curve &pCurve); public: virtual ~RetinexgaintransmissionCurve() {}; RetinexgaintransmissionCurve(); void Reset(); - void Set (const Curve *pCurve); - void Set (const std::vector &curvePoints); - float operator[] (float index) const + void Set(const Curve *pCurve); + void Set(const std::vector &curvePoints); + float operator[](float index) const { return lutgaintransmission[index]; } @@ -530,7 +530,7 @@ public: virtual ~ToneCurve() {}; void Reset(); - void Set (const Curve &pCurve, float gamma = 0); + void Set(const Curve &pCurve, float gamma = 0); operator bool (void) const { return lutToneCurve; @@ -545,15 +545,15 @@ public: virtual ~OpacityCurve() {}; void Reset(); - void Set (const Curve *pCurve); - void Set (const std::vector &curvePoints, bool &opautili); + void Set(const Curve *pCurve); + void Set(const std::vector &curvePoints, bool &opautili); // TODO: transfer this method to the Color class... - float blend (float x, float lower, float upper) const + float blend(float x, float lower, float upper) const { return (upper - lower) * lutOpacityCurve[x * 500.f] + lower; } - void blend3f (float x, float lower1, float upper1, float &result1, float lower2, float upper2, float &result2, float lower3, float upper3, float &result3) const + void blend3f(float x, float lower1, float upper1, float &result1, float lower2, float upper2, float &result2, float lower3, float upper3, float &result3) const { float opacity = lutOpacityCurve[x * 500.f]; result1 = (upper1 - lower1) * opacity + lower1; @@ -571,7 +571,7 @@ class LocLHCurve { private: LUTf lutLocLHCurve; // 0xffff range - void Set (const Curve &pCurve); + void Set(const Curve &pCurve); public: float sum; @@ -579,13 +579,13 @@ public: virtual ~LocLHCurve() {}; LocLHCurve(); void Reset(); - void Set (const std::vector &curvePoints, bool &LHutili); + void Set(const std::vector &curvePoints, bool &LHutili); float getSum() const { return sum; } - float operator[] (float index) const + float operator[](float index) const { return lutLocLHCurve[index]; } @@ -599,7 +599,7 @@ class LocHHCurve { private: LUTf lutLocHHCurve; // 0xffff range - void Set (const Curve &pCurve); + void Set(const Curve &pCurve); public: float sum; @@ -607,13 +607,13 @@ public: virtual ~LocHHCurve() {}; LocHHCurve(); void Reset(); - void Set (const std::vector &curvePoints, bool &HHutili); + void Set(const std::vector &curvePoints, bool &HHutili); float getSum() const { return sum; } - float operator[] (float index) const + float operator[](float index) const { return lutLocHHCurve[index]; } @@ -627,7 +627,7 @@ class LocretigainCurve { private: LUTf lutLocretigainCurve; // 0xffff range - void Set (const Curve &pCurve); + void Set(const Curve &pCurve); public: float sum; @@ -635,13 +635,13 @@ public: virtual ~LocretigainCurve() {}; LocretigainCurve(); void Reset(); - void Set (const std::vector &curvePoints); + void Set(const std::vector &curvePoints); float getSum() const { return sum; } - float operator[] (float index) const + float operator[](float index) const { return lutLocretigainCurve[index]; } @@ -655,7 +655,7 @@ class LocretigainCurverab { private: LUTf lutLocretigainCurverab; // 0xffff range - void Set (const Curve &pCurve); + void Set(const Curve &pCurve); public: float sum; @@ -663,13 +663,13 @@ public: virtual ~LocretigainCurverab() {}; LocretigainCurverab(); void Reset(); - void Set (const std::vector &curvePoints); + void Set(const std::vector &curvePoints); float getSum() const { return sum; } - float operator[] (float index) const + float operator[](float index) const { return lutLocretigainCurverab[index]; } @@ -684,7 +684,7 @@ class WavCurve { private: LUTf lutWavCurve; // 0xffff range - void Set (const Curve &pCurve); + void Set(const Curve &pCurve); public: float sum; @@ -692,13 +692,13 @@ public: virtual ~WavCurve() {}; WavCurve(); void Reset(); - void Set (const std::vector &curvePoints); + void Set(const std::vector &curvePoints); float getSum() const { return sum; } - float operator[] (float index) const + float operator[](float index) const { return lutWavCurve[index]; } @@ -712,15 +712,15 @@ class WavOpacityCurveRG { private: LUTf lutOpacityCurveRG; // 0xffff range - void Set (const Curve &pCurve); + void Set(const Curve &pCurve); public: virtual ~WavOpacityCurveRG() {}; WavOpacityCurveRG(); void Reset(); // void Set(const std::vector &curvePoints, bool &opautili); - void Set (const std::vector &curvePoints); - float operator[] (float index) const + void Set(const std::vector &curvePoints); + float operator[](float index) const { return lutOpacityCurveRG[index]; } @@ -734,16 +734,16 @@ class WavOpacityCurveBY { private: LUTf lutOpacityCurveBY; // 0xffff range - void Set (const Curve &pCurve); + void Set(const Curve &pCurve); public: virtual ~WavOpacityCurveBY() {}; WavOpacityCurveBY(); void Reset(); - void Set (const Curve *pCurve); - void Set (const std::vector &curvePoints); - float operator[] (float index) const + void Set(const Curve *pCurve); + void Set(const std::vector &curvePoints); + float operator[](float index) const { return lutOpacityCurveBY[index]; } @@ -757,16 +757,16 @@ class WavOpacityCurveW { private: LUTf lutOpacityCurveW; // 0xffff range - void Set (const Curve &pCurve); + void Set(const Curve &pCurve); public: virtual ~WavOpacityCurveW() {}; WavOpacityCurveW(); void Reset(); - void Set (const Curve *pCurve); - void Set (const std::vector &curvePoints); - float operator[] (float index) const + void Set(const Curve *pCurve); + void Set(const std::vector &curvePoints); + float operator[](float index) const { return lutOpacityCurveW[index]; } @@ -781,16 +781,16 @@ class WavOpacityCurveWL { private: LUTf lutOpacityCurveWL; // 0xffff range - void Set (const Curve &pCurve); + void Set(const Curve &pCurve); public: virtual ~WavOpacityCurveWL() {}; WavOpacityCurveWL(); void Reset(); - void Set (const Curve *pCurve); - void Set (const std::vector &curvePoints); - float operator[] (float index) const + void Set(const Curve *pCurve); + void Set(const std::vector &curvePoints); + float operator[](float index) const { return lutOpacityCurveWL[index]; } @@ -806,19 +806,19 @@ class NoiseCurve private: LUTf lutNoiseCurve; // 0xffff range float sum; - void Set (const Curve &pCurve); + void Set(const Curve &pCurve); public: virtual ~NoiseCurve() {}; NoiseCurve(); void Reset(); - void Set (const std::vector &curvePoints); + void Set(const std::vector &curvePoints); float getSum() const { return sum; } - float operator[] (float index) const + float operator[](float index) const { return lutNoiseCurve[index]; } @@ -852,7 +852,7 @@ public: * @param g corresponding green value [0 ; 65535] (return value) * @param b corresponding blue value [0 ; 65535] (return value) */ - void getVal (float index, float &r, float &g, float &b) const; + void getVal(float index, float &r, float &g, float &b) const; operator bool (void) const { return lut1 && lut2 && lut3; @@ -867,7 +867,7 @@ public: virtual ~ColorAppearance() {}; void Reset(); - void Set (const Curve &pCurve); + void Set(const Curve &pCurve); operator bool (void) const { return lutColCurve; @@ -877,14 +877,14 @@ public: class Lightcurve : public ColorAppearance { public: - void Apply (float& Li) const; + void Apply(float& Li) const; }; //lightness curve -inline void Lightcurve::Apply (float& Li) const +inline void Lightcurve::Apply(float& Li) const { - assert (lutColCurve); + assert(lutColCurve); Li = lutColCurve[Li]; } @@ -892,14 +892,14 @@ inline void Lightcurve::Apply (float& Li) const class Brightcurve : public ColorAppearance { public: - void Apply (float& Br) const; + void Apply(float& Br) const; }; //brightness curve -inline void Brightcurve::Apply (float& Br) const +inline void Brightcurve::Apply(float& Br) const { - assert (lutColCurve); + assert(lutColCurve); Br = lutColCurve[Br]; } @@ -907,28 +907,28 @@ inline void Brightcurve::Apply (float& Br) const class Chromacurve : public ColorAppearance { public: - void Apply (float& Cr) const; + void Apply(float& Cr) const; }; //Chroma curve -inline void Chromacurve::Apply (float& Cr) const +inline void Chromacurve::Apply(float& Cr) const { - assert (lutColCurve); + assert(lutColCurve); Cr = lutColCurve[Cr]; } class Saturcurve : public ColorAppearance { public: - void Apply (float& Sa) const; + void Apply(float& Sa) const; }; //Saturation curve -inline void Saturcurve::Apply (float& Sa) const +inline void Saturcurve::Apply(float& Sa) const { - assert (lutColCurve); + assert(lutColCurve); Sa = lutColCurve[Sa]; } @@ -936,14 +936,14 @@ inline void Saturcurve::Apply (float& Sa) const class Colorfcurve : public ColorAppearance { public: - void Apply (float& Cf) const; + void Apply(float& Cf) const; }; //Colorfullness curve -inline void Colorfcurve::Apply (float& Cf) const +inline void Colorfcurve::Apply(float& Cf) const { - assert (lutColCurve); + assert(lutColCurve); Cf = lutColCurve[Cf]; } @@ -958,37 +958,37 @@ public: // and ending at `r[end]` (and respectively for `b` and `g`). Uses SSE // and requires that `r`, `g`, and `b` pointers have the same alignment. void BatchApply( - const size_t start, const size_t end, - float *r, float *g, float *b) const; + const size_t start, const size_t end, + float *r, float *g, float *b) const; }; class AdobeToneCurve : public ToneCurve { private: - void RGBTone (float& r, float& g, float& b) const; // helper for tone curve + void RGBTone(float& r, float& g, float& b) const; // helper for tone curve public: - void Apply (float& r, float& g, float& b) const; + void Apply(float& r, float& g, float& b) const; }; class SatAndValueBlendingToneCurve : public ToneCurve { public: - void Apply (float& r, float& g, float& b) const; + void Apply(float& r, float& g, float& b) const; }; class WeightedStdToneCurve : public ToneCurve { private: - float Triangle (float refX, float refY, float X2) const; + float Triangle(float refX, float refY, float X2) const; public: - void Apply (float& r, float& g, float& b) const; + void Apply(float& r, float& g, float& b) const; }; class LuminanceToneCurve : public ToneCurve { public: - void Apply (float& r, float& g, float& b) const; + void Apply(float& r, float& g, float& b) const; }; class PerceptualToneCurveState @@ -1013,22 +1013,22 @@ private: static float f, c, nc, yb, la, xw, yw, zw, gamut; static float n, d, nbb, ncb, cz, aw, wh, pfl, fl, pow1; - static void cubic_spline (const float x[], const float y[], const int len, const float out_x[], float out_y[], const int out_len); - static float find_minimum_interval_halving (float (*func) (float x, void *arg), void *arg, float a, float b, float tol, int nmax); - static float find_tc_slope_fun (float k, void *arg); - static float get_curve_val (float x, float range[2], float lut[], size_t lut_size); + static void cubic_spline(const float x[], const float y[], const int len, const float out_x[], float out_y[], const int out_len); + static float find_minimum_interval_halving(float (*func)(float x, void *arg), void *arg, float a, float b, float tol, int nmax); + static float find_tc_slope_fun(float k, void *arg); + static float get_curve_val(float x, float range[2], float lut[], size_t lut_size); float calculateToneCurveContrastValue() const; public: static void init(); - void initApplyState (PerceptualToneCurveState & state, Glib::ustring workingSpace) const; - void Apply (float& r, float& g, float& b, PerceptualToneCurveState & state) const; + void initApplyState(PerceptualToneCurveState & state, Glib::ustring workingSpace) const; + void Apply(float& r, float& g, float& b, PerceptualToneCurveState & state) const; }; // Standard tone curve -inline void StandardToneCurve::Apply (float& r, float& g, float& b) const +inline void StandardToneCurve::Apply(float& r, float& g, float& b) const { - assert (lutToneCurve); + assert(lutToneCurve); r = lutToneCurve[r]; g = lutToneCurve[g]; @@ -1036,18 +1036,20 @@ inline void StandardToneCurve::Apply (float& r, float& g, float& b) const } inline void StandardToneCurve::BatchApply( - const size_t start, const size_t end, - float *r, float *g, float *b) const { - assert (lutToneCurve); - assert (lutToneCurve.getClip() & LUT_CLIP_BELOW); - assert (lutToneCurve.getClip() & LUT_CLIP_ABOVE); + const size_t start, const size_t end, + float *r, float *g, float *b) const +{ + assert(lutToneCurve); + assert(lutToneCurve.getClip() & LUT_CLIP_BELOW); + assert(lutToneCurve.getClip() & LUT_CLIP_ABOVE); // All pointers must have the same alignment for SSE usage. In the loop body below, // we will only check `r`, assuming that the same result would hold for `g` and `b`. - assert (reinterpret_cast(r) % 16 == reinterpret_cast(g) % 16); - assert (reinterpret_cast(g) % 16 == reinterpret_cast(b) % 16); + assert(reinterpret_cast(r) % 16 == reinterpret_cast(g) % 16); + assert(reinterpret_cast(g) % 16 == reinterpret_cast(b) % 16); size_t i = start; + while (true) { if (i >= end) { // If we get to the end before getting to an aligned address, just return. @@ -1059,6 +1061,7 @@ inline void StandardToneCurve::BatchApply( break; #endif } + r[i] = lutToneCurve[r[i]]; g[i] = lutToneCurve[g[i]]; b[i] = lutToneCurve[b[i]]; @@ -1066,6 +1069,7 @@ inline void StandardToneCurve::BatchApply( } #if defined( __SSE2__ ) && defined( __x86_64__ ) + for (; i + 3 < end; i += 4) { __m128 r_val = LVF(r[i]); __m128 g_val = LVF(g[i]); @@ -1081,41 +1085,42 @@ inline void StandardToneCurve::BatchApply( g[i] = lutToneCurve[g[i]]; b[i] = lutToneCurve[b[i]]; } + #endif } // Tone curve according to Adobe's reference implementation // values in 0xffff space // inlined to make sure there will be no cache flush when used -inline void AdobeToneCurve::Apply (float& r, float& g, float& b) const +inline void AdobeToneCurve::Apply(float& r, float& g, float& b) const { - assert (lutToneCurve); + assert(lutToneCurve); if (r >= g) { - if (g > b) { - RGBTone (r, g, b); // Case 1: r >= g > b + if (g > b) { + RGBTone(r, g, b); // Case 1: r >= g > b } else if (b > r) { - RGBTone (b, r, g); // Case 2: b > r >= g + RGBTone(b, r, g); // Case 2: b > r >= g } else if (b > g) { - RGBTone (r, b, g); // Case 3: r >= b > g + RGBTone(r, b, g); // Case 3: r >= b > g } else { // Case 4: r >= g == b r = lutToneCurve[r]; g = lutToneCurve[g]; b = g; } } else { - if (r >= b) { - RGBTone (g, r, b); // Case 5: g > r >= b + if (r >= b) { + RGBTone(g, r, b); // Case 5: g > r >= b } else if (b > g) { - RGBTone (b, g, r); // Case 6: b > g > r + RGBTone(b, g, r); // Case 6: b > g > r } else { - RGBTone (g, b, r); // Case 7: g >= b > r + RGBTone(g, b, r); // Case 7: g >= b > r } } } -inline void AdobeToneCurve::RGBTone (float& r, float& g, float& b) const +inline void AdobeToneCurve::RGBTone(float& r, float& g, float& b) const { float rold = r, gold = g, bold = b; @@ -1125,9 +1130,9 @@ inline void AdobeToneCurve::RGBTone (float& r, float& g, float& b) const } // Modifying the Luminance channel only -inline void LuminanceToneCurve::Apply (float &r, float &g, float &b) const +inline void LuminanceToneCurve::Apply(float &r, float &g, float &b) const { - assert (lutToneCurve); + assert(lutToneCurve); float currLuminance = r * 0.2126729f + g * 0.7151521f + b * 0.0721750f; @@ -1139,7 +1144,7 @@ inline void LuminanceToneCurve::Apply (float &r, float &g, float &b) const b = LIM (b * coef, 0.f, 65535.f); } -inline float WeightedStdToneCurve::Triangle (float a, float a1, float b) const +inline float WeightedStdToneCurve::Triangle(float a, float a1, float b) const { if (a != b) { float b1; @@ -1159,34 +1164,34 @@ inline float WeightedStdToneCurve::Triangle (float a, float a1, float b) const // Tone curve modifying the value channel only, preserving hue and saturation // values in 0xffff space -inline void WeightedStdToneCurve::Apply (float& r, float& g, float& b) const +inline void WeightedStdToneCurve::Apply(float& r, float& g, float& b) const { - assert (lutToneCurve); + assert(lutToneCurve); float r1 = lutToneCurve[r]; - float g1 = Triangle (r, r1, g); - float b1 = Triangle (r, r1, b); + float g1 = Triangle(r, r1, g); + float b1 = Triangle(r, r1, b); float g2 = lutToneCurve[g]; - float r2 = Triangle (g, g2, r); - float b2 = Triangle (g, g2, b); + float r2 = Triangle(g, g2, r); + float b2 = Triangle(g, g2, b); float b3 = lutToneCurve[b]; - float r3 = Triangle (b, b3, r); - float g3 = Triangle (b, b3, g); + float r3 = Triangle(b, b3, r); + float g3 = Triangle(b, b3, g); - r = CLIP ( r1 * 0.50f + r2 * 0.25f + r3 * 0.25f); + r = CLIP (r1 * 0.50f + r2 * 0.25f + r3 * 0.25f); g = CLIP (g1 * 0.25f + g2 * 0.50f + g3 * 0.25f); b = CLIP (b1 * 0.25f + b2 * 0.25f + b3 * 0.50f); } // Tone curve modifying the value channel only, preserving hue and saturation // values in 0xffff space -inline void SatAndValueBlendingToneCurve::Apply (float& r, float& g, float& b) const +inline void SatAndValueBlendingToneCurve::Apply(float& r, float& g, float& b) const { - assert (lutToneCurve); + assert(lutToneCurve); float h, s, v; float lum = (r + g + b) / 3.f; @@ -1200,6 +1205,7 @@ inline void SatAndValueBlendingToneCurve::Apply (float& r, float& g, float& b) c Color::rgb2hsv(r, g, b, h, s, v); float dV; + if (newLum > lum) { // Linearly targeting Value = 1 and Saturation = 0 float coef = (newLum - lum) / (65535.f - lum); @@ -1210,6 +1216,7 @@ inline void SatAndValueBlendingToneCurve::Apply (float& r, float& g, float& b) c float coef = (newLum - lum) / lum ; dV = v * coef; } + Color::hsv2rgb(h, s, v + dV, r, g, b); } diff --git a/rtengine/dirpyr_equalizer.cc b/rtengine/dirpyr_equalizer.cc index 5f8e9ab33..370744f2c 100644 --- a/rtengine/dirpyr_equalizer.cc +++ b/rtengine/dirpyr_equalizer.cc @@ -47,7 +47,7 @@ SSEFUNCTION void ImProcFunctions :: dirpyr_equalizer(float ** src, float ** dst, int lastlevel = maxlevel; if (settings->verbose) { - printf ("Dirpyr scaleprev=%i\n", scaleprev); + printf("Dirpyr scaleprev=%i\n", scaleprev); } float atten123 = (float) settings->level123_cbdl; @@ -75,7 +75,7 @@ SSEFUNCTION void ImProcFunctions :: dirpyr_equalizer(float ** src, float ** dst, } - while (lastlevel > 0 && fabs (mult[lastlevel - 1] - 1) < 0.001) { + while (lastlevel > 0 && fabs(mult[lastlevel - 1] - 1) < 0.001) { lastlevel--; //printf("last level to process %d \n",lastlevel); } @@ -88,7 +88,7 @@ SSEFUNCTION void ImProcFunctions :: dirpyr_equalizer(float ** src, float ** dst, float multi[maxlevel] = {1.f, 1.f, 1.f, 1.f, 1.f, 1.f}; float scalefl[maxlevel]; - for(int lv = 0; lv < maxlevel; lv++) { + for (int lv = 0; lv < maxlevel; lv++) { scalefl[lv] = ((float) scales[lv]) / (float) scaleprev; if (lv >= 1) { @@ -108,34 +108,34 @@ SSEFUNCTION void ImProcFunctions :: dirpyr_equalizer(float ** src, float ** dst, } if (settings->verbose) { - printf ("CbDL mult0=%f 1=%f 2=%f 3=%f 4=%f 5=%f\n", multi[0], multi[1], multi[2], multi[3], multi[4], multi[5]); + printf("CbDL mult0=%f 1=%f 2=%f 3=%f 4=%f 5=%f\n", multi[0], multi[1], multi[2], multi[3], multi[4], multi[5]); } - multi_array2D dirpyrlo (srcwidth, srcheight); + multi_array2D dirpyrlo(srcwidth, srcheight); level = 0; //int thresh = 100 * mult[5]; - int scale = (int) (scales[level]) / scaleprev; + int scale = (int)(scales[level]) / scaleprev; if (scale < 1) { scale = 1; } - dirpyr_channel (src, dirpyrlo[0], srcwidth, srcheight, 0, scale); + dirpyr_channel(src, dirpyrlo[0], srcwidth, srcheight, 0, scale); level = 1; while (level < lastlevel) { - scale = (int) (scales[level]) / scaleprev; + scale = (int)(scales[level]) / scaleprev; if (scale < 1) { scale = 1; } - dirpyr_channel (dirpyrlo[level - 1], dirpyrlo[level], srcwidth, srcheight, level, scale); + dirpyr_channel(dirpyrlo[level - 1], dirpyrlo[level], srcwidth, srcheight, level, scale); level ++; } @@ -159,11 +159,11 @@ SSEFUNCTION void ImProcFunctions :: dirpyr_equalizer(float ** src, float ** dst, int j; for (j = 0; j < srcwidth - 3; j += 4) { - _mm_storeu_ps (&tmpHue[i][j], xatan2f (LVFU (l_b[i][j]), LVFU (l_a[i][j]))); + _mm_storeu_ps(&tmpHue[i][j], xatan2f(LVFU(l_b[i][j]), LVFU(l_a[i][j]))); } for (; j < srcwidth; j++) { - tmpHue[i][j] = xatan2f (l_b[i][j], l_a[i][j]); + tmpHue[i][j] = xatan2f(l_b[i][j], l_a[i][j]); } } @@ -172,7 +172,7 @@ SSEFUNCTION void ImProcFunctions :: dirpyr_equalizer(float ** src, float ** dst, for (int i = 0; i < srcheight; i++) { for (int j = 0; j < srcwidth; j++) { - tmpHue[i][j] = xatan2f (l_b[i][j], l_a[i][j]); + tmpHue[i][j] = xatan2f(l_b[i][j], l_a[i][j]); } } @@ -186,18 +186,18 @@ SSEFUNCTION void ImProcFunctions :: dirpyr_equalizer(float ** src, float ** dst, #ifdef __SSE2__ #pragma omp parallel { - __m128 div = _mm_set1_ps (327.68f); + __m128 div = _mm_set1_ps(327.68f); #pragma omp for for (int i = 0; i < srcheight; i++) { int j; for (j = 0; j < srcwidth - 3; j += 4) { - _mm_storeu_ps (&tmpChr[i][j], _mm_sqrt_ps (SQRV (LVFU (l_b[i][j])) + SQRV (LVFU (l_a[i][j]))) / div); + _mm_storeu_ps(&tmpChr[i][j], _mm_sqrt_ps(SQRV(LVFU(l_b[i][j])) + SQRV(LVFU(l_a[i][j]))) / div); } for (; j < srcwidth; j++) { - tmpChr[i][j] = sqrtf (SQR ((l_b[i][j])) + SQR ((l_a[i][j]))) / 327.68f; + tmpChr[i][j] = sqrtf(SQR((l_b[i][j])) + SQR((l_a[i][j]))) / 327.68f; } } } @@ -206,7 +206,7 @@ SSEFUNCTION void ImProcFunctions :: dirpyr_equalizer(float ** src, float ** dst, for (int i = 0; i < srcheight; i++) { for (int j = 0; j < srcwidth; j++) { - tmpChr[i][j] = sqrtf (SQR ((l_b[i][j])) + SQR ((l_a[i][j]))) / 327.68f; + tmpChr[i][j] = sqrtf(SQR((l_b[i][j])) + SQR((l_a[i][j]))) / 327.68f; } } @@ -216,7 +216,7 @@ SSEFUNCTION void ImProcFunctions :: dirpyr_equalizer(float ** src, float ** dst, // with the current implementation of idirpyr_eq_channel we can safely use the buffer from last level as buffer, saves some memory float ** buffer = dirpyrlo[lastlevel - 1]; - for(int level = lastlevel - 1; level > 0; level--) { + for (int level = lastlevel - 1; level > 0; level--) { idirpyr_eq_channel(dirpyrlo[level], dirpyrlo[level - 1], buffer, srcwidth, srcheight, level, multi, dirpyrThreshold, tmpHue, tmpChr, skinprot, b_l, t_l, t_r); } @@ -242,17 +242,17 @@ SSEFUNCTION void ImProcFunctions :: dirpyr_equalizer(float ** src, float ** dst, for (int i = 0; i < srcheight; i++) for (int j = 0; j < srcwidth; j++) { - dst[i][j] = CLIP (buffer[i][j]); // TODO: Really a clip necessary? + dst[i][j] = CLIP(buffer[i][j]); // TODO: Really a clip necessary? } } -SSEFUNCTION void ImProcFunctions :: cbdl_local_temp (float ** src, float ** dst, float ** loctemp, int srcwidth, int srcheight, const float * mult, float kchro, const double dirpyrThreshold, const double skinprot, const bool gamutlab, float b_l, float t_l, float t_r, float b_r, int choice, int scaleprev) +SSEFUNCTION void ImProcFunctions :: cbdl_local_temp(float ** src, float ** dst, float ** loctemp, int srcwidth, int srcheight, const float * mult, float kchro, const double dirpyrThreshold, const double skinprot, const bool gamutlab, float b_l, float t_l, float t_r, float b_r, int choice, int scaleprev) { int lastlevel = maxlevelloc; if (settings->verbose) { - printf ("Dirpyr scaleprev=%i\n", scaleprev); + printf("Dirpyr scaleprev=%i\n", scaleprev); } float atten123 = (float) settings->level123_cbdl; @@ -279,7 +279,7 @@ SSEFUNCTION void ImProcFunctions :: cbdl_local_temp (float ** src, float ** dst, t_l = t_r + 0.55f; //avoid too small range } - while (lastlevel > 0 && fabs (mult[lastlevel - 1] - 1) < 0.001) { + while (lastlevel > 0 && fabs(mult[lastlevel - 1] - 1) < 0.001) { lastlevel--; //printf("last level to process %d \n",lastlevel); @@ -316,34 +316,34 @@ SSEFUNCTION void ImProcFunctions :: cbdl_local_temp (float ** src, float ** dst, } if (settings->verbose) { - printf ("CbDL local mult0=%f 1=%f 2=%f 3=%f 4=%f\n", multi[0], multi[1], multi[2], multi[3], multi[4]); + printf("CbDL local mult0=%f 1=%f 2=%f 3=%f 4=%f\n", multi[0], multi[1], multi[2], multi[3], multi[4]); } - multi_array2D dirpyrlo (srcwidth, srcheight); + multi_array2D dirpyrlo(srcwidth, srcheight); level = 0; //int thresh = 100 * mult[5]; - int scale = (int) (scalesloc[level]) / scaleprev; + int scale = (int)(scalesloc[level]) / scaleprev; if (scale < 1) { scale = 1; } - dirpyr_channel (src, dirpyrlo[0], srcwidth, srcheight, 0, scale); + dirpyr_channel(src, dirpyrlo[0], srcwidth, srcheight, 0, scale); level = 1; while (level < lastlevel) { - scale = (int) (scalesloc[level]) / scaleprev; + scale = (int)(scalesloc[level]) / scaleprev; if (scale < 1) { scale = 1; } - dirpyr_channel (dirpyrlo[level - 1], dirpyrlo[level], srcwidth, srcheight, level, scale); + dirpyr_channel(dirpyrlo[level - 1], dirpyrlo[level], srcwidth, srcheight, level, scale); level ++; } @@ -354,31 +354,31 @@ SSEFUNCTION void ImProcFunctions :: cbdl_local_temp (float ** src, float ** dst, float ** buffer = dirpyrlo[lastlevel - 1]; for (int level = lastlevel - 1; level > 0; level--) { - idirpyr_eq_channel_loc (dirpyrlo[level], dirpyrlo[level - 1], loctemp, buffer, srcwidth, srcheight, level, multi, dirpyrThreshold, tmpHue, tmpChr, skinprot, gamutlab, b_l, t_l, t_r, b_r, choice ); + idirpyr_eq_channel_loc(dirpyrlo[level], dirpyrlo[level - 1], loctemp, buffer, srcwidth, srcheight, level, multi, dirpyrThreshold, tmpHue, tmpChr, skinprot, gamutlab, b_l, t_l, t_r, b_r, choice); } scale = scalesloc[0]; - idirpyr_eq_channel_loc (dirpyrlo[0], dst, loctemp, buffer, srcwidth, srcheight, 0, multi, dirpyrThreshold, tmpHue, tmpChr, skinprot, gamutlab, b_l, t_l, t_r, b_r, choice ); + idirpyr_eq_channel_loc(dirpyrlo[0], dst, loctemp, buffer, srcwidth, srcheight, 0, multi, dirpyrThreshold, tmpHue, tmpChr, skinprot, gamutlab, b_l, t_l, t_r, b_r, choice); //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% #pragma omp parallel for for (int i = 0; i < srcheight; i++) for (int j = 0; j < srcwidth; j++) { dst[i][j] = src[i][j]; - loctemp[i][j] = CLIP (buffer[i][j]); // TODO: Really a clip necessary? + loctemp[i][j] = CLIP(buffer[i][j]); // TODO: Really a clip necessary? // dst[i][j] = CLIP (buffer[i][j]); // TODO: Really a clip necessary? } } -void ImProcFunctions :: dirpyr_equalizercam (CieImage *ncie, float ** src, float ** dst, int srcwidth, int srcheight, float ** h_p, float ** C_p, const double * mult, const double dirpyrThreshold, const double skinprot, bool execdir, float b_l, float t_l, float t_r, int scaleprev) +void ImProcFunctions :: dirpyr_equalizercam(CieImage *ncie, float ** src, float ** dst, int srcwidth, int srcheight, float ** h_p, float ** C_p, const double * mult, const double dirpyrThreshold, const double skinprot, bool execdir, float b_l, float t_l, float t_r, int scaleprev) { int lastlevel = maxlevel; if (settings->verbose) { - printf ("CAM dirpyr scaleprev=%i\n", scaleprev); + printf("CAM dirpyr scaleprev=%i\n", scaleprev); } float atten123 = (float) settings->level123_cbdl; @@ -406,7 +406,7 @@ void ImProcFunctions :: dirpyr_equalizercam (CieImage *ncie, float ** src, float t_l = t_r + 0.55f; //avoid too small range } - while (fabs (mult[lastlevel - 1] - 1) < 0.001 && lastlevel > 0) { + while (fabs(mult[lastlevel - 1] - 1) < 0.001 && lastlevel > 0) { lastlevel--; //printf("last level to process %d \n",lastlevel); } @@ -420,7 +420,7 @@ void ImProcFunctions :: dirpyr_equalizercam (CieImage *ncie, float ** src, float float multi[maxlevel] = {1.f, 1.f, 1.f, 1.f, 1.f, 1.f}; float scalefl[maxlevel]; - for(int lv = 0; lv < maxlevel; lv++) { + for (int lv = 0; lv < maxlevel; lv++) { scalefl[lv] = ((float) scales[lv]) / (float) scaleprev; // if(scalefl[lv] < 1.f) multi[lv] = 1.f; else multi[lv]=(float) mult[lv]; @@ -442,34 +442,34 @@ void ImProcFunctions :: dirpyr_equalizercam (CieImage *ncie, float ** src, float } if (settings->verbose) { - printf ("CAM CbDL mult0=%f 1=%f 2=%f 3=%f 4=%f 5=%f\n", multi[0], multi[1], multi[2], multi[3], multi[4], multi[5]); + printf("CAM CbDL mult0=%f 1=%f 2=%f 3=%f 4=%f 5=%f\n", multi[0], multi[1], multi[2], multi[3], multi[4], multi[5]); } - multi_array2D dirpyrlo (srcwidth, srcheight); + multi_array2D dirpyrlo(srcwidth, srcheight); level = 0; - int scale = (int) (scales[level]) / scaleprev; + int scale = (int)(scales[level]) / scaleprev; if (scale < 1) { scale = 1; } - dirpyr_channel (src, dirpyrlo[0], srcwidth, srcheight, 0, scale); + dirpyr_channel(src, dirpyrlo[0], srcwidth, srcheight, 0, scale); level = 1; while (level < lastlevel) { - scale = (int) (scales[level]) / scaleprev; + scale = (int)(scales[level]) / scaleprev; if (scale < 1) { scale = 1; } - dirpyr_channel (dirpyrlo[level - 1], dirpyrlo[level], srcwidth, srcheight, level, scale); + dirpyr_channel(dirpyrlo[level - 1], dirpyrlo[level], srcwidth, srcheight, level, scale); level ++; } @@ -479,13 +479,13 @@ void ImProcFunctions :: dirpyr_equalizercam (CieImage *ncie, float ** src, float float ** buffer = dirpyrlo[lastlevel - 1]; for (int level = lastlevel - 1; level > 0; level--) { - idirpyr_eq_channelcam (dirpyrlo[level], dirpyrlo[level - 1], buffer, srcwidth, srcheight, level, multi, dirpyrThreshold, h_p, C_p, skinprot, b_l, t_l, t_r); + idirpyr_eq_channelcam(dirpyrlo[level], dirpyrlo[level - 1], buffer, srcwidth, srcheight, level, multi, dirpyrThreshold, h_p, C_p, skinprot, b_l, t_l, t_r); } - idirpyr_eq_channelcam (dirpyrlo[0], dst, buffer, srcwidth, srcheight, 0, multi, dirpyrThreshold, h_p, C_p, skinprot, b_l, t_l, t_r); + idirpyr_eq_channelcam(dirpyrlo[0], dst, buffer, srcwidth, srcheight, 0, multi, dirpyrThreshold, h_p, C_p, skinprot, b_l, t_l, t_r); - if(execdir) { + if (execdir) { #ifdef _OPENMP #pragma omp parallel for schedule(dynamic,16) #endif @@ -493,7 +493,7 @@ void ImProcFunctions :: dirpyr_equalizercam (CieImage *ncie, float ** src, float for (int i = 0; i < srcheight; i++) for (int j = 0; j < srcwidth; j++) { if (ncie->J_p[i][j] > 8.f && ncie->J_p[i][j] < 92.f) { - dst[i][j] = CLIP ( buffer[i][j] ); // TODO: Really a clip necessary? + dst[i][j] = CLIP(buffer[i][j]); // TODO: Really a clip necessary? } else { dst[i][j] = src[i][j]; } @@ -501,7 +501,7 @@ void ImProcFunctions :: dirpyr_equalizercam (CieImage *ncie, float ** src, float } else { for (int i = 0; i < srcheight; i++) for (int j = 0; j < srcwidth; j++) { - dst[i][j] = CLIP ( buffer[i][j] ); // TODO: Really a clip necessary? + dst[i][j] = CLIP(buffer[i][j]); // TODO: Really a clip necessary? } } } @@ -522,7 +522,7 @@ SSEFUNCTION void ImProcFunctions::dirpyr_channel(float ** data_fine, float ** da #endif { #ifdef __SSE2__ - __m128 thousandv = _mm_set1_ps ( 1000.0f ); + __m128 thousandv = _mm_set1_ps(1000.0f); __m128 dirwtv, valv, normv, dftemp1v, dftemp2v; // multiplied each value of domkerv by 1000 to avoid multiplication by 1000 inside the loop float domkerv[5][5][4] ALIGNED16 = {{{1000, 1000, 1000, 1000}, {1000, 1000, 1000, 1000}, {1000, 1000, 1000, 1000}, {1000, 1000, 1000, 1000}, {1000, 1000, 1000, 1000}}, {{1000, 1000, 1000, 1000}, {2000, 2000, 2000, 2000}, {2000, 2000, 2000, 2000}, {2000, 2000, 2000, 2000}, {1000, 1000, 1000, 1000}}, {{1000, 1000, 1000, 1000}, {2000, 2000, 2000, 2000}, {2000, 2000, 2000, 2000}, {2000, 2000, 2000, 2000}, {1000, 1000, 1000, 1000}}, {{1000, 1000, 1000, 1000}, {2000, 2000, 2000, 2000}, {2000, 2000, 2000, 2000}, {2000, 2000, 2000, 2000}, {1000, 1000, 1000, 1000}}, {{1000, 1000, 1000, 1000}, {1000, 1000, 1000, 1000}, {1000, 1000, 1000, 1000}, {1000, 1000, 1000, 1000}, {1000, 1000, 1000, 1000}}}; @@ -541,10 +541,10 @@ SSEFUNCTION void ImProcFunctions::dirpyr_channel(float ** data_fine, float ** da float norm = 0.f; - for (int inbr = max (0, i - scalewin); inbr <= min (height - 1, i + scalewin); inbr += scale) { - for (int jnbr = max (0, j - scalewin); jnbr <= j + scalewin; jnbr += scale) { + for (int inbr = max(0, i - scalewin); inbr <= min(height - 1, i + scalewin); inbr += scale) { + for (int jnbr = max(0, j - scalewin); jnbr <= j + scalewin; jnbr += scale) { //printf("i=%d ",(inbr-i)/scale+halfwin); - dirwt = DIRWT (inbr, jnbr, i, j); + dirwt = DIRWT(inbr, jnbr, i, j); val += dirwt * data_fine[inbr][jnbr]; norm += dirwt; } @@ -558,29 +558,29 @@ SSEFUNCTION void ImProcFunctions::dirpyr_channel(float ** data_fine, float ** da for (; j < width - scalewin - 3; j += 4) { valv = _mm_setzero_ps(); normv = _mm_setzero_ps(); - dftemp1v = LVFU (data_fine[i][j]); + dftemp1v = LVFU(data_fine[i][j]); - for (int inbr = MAX (0, i - scalewin); inbr <= MIN (height - 1, i + scalewin); inbr += scale) { + for (int inbr = MAX(0, i - scalewin); inbr <= MIN(height - 1, i + scalewin); inbr += scale) { int indexihlp = (inbr - i) / scale + halfwin; for (int jnbr = j - scalewin, indexjhlp = 0; jnbr <= j + scalewin; jnbr += scale, indexjhlp++) { - dftemp2v = LVFU (data_fine[inbr][jnbr]); - dirwtv = LVF (domkerv[indexihlp][indexjhlp]) / (vabsf (dftemp1v - dftemp2v) + thousandv); + dftemp2v = LVFU(data_fine[inbr][jnbr]); + dirwtv = LVF(domkerv[indexihlp][indexjhlp]) / (vabsf(dftemp1v - dftemp2v) + thousandv); valv += dirwtv * dftemp2v; normv += dirwtv; } } - _mm_storeu_ps ( &data_coarse[i][j], valv / normv); //low pass filter + _mm_storeu_ps(&data_coarse[i][j], valv / normv); //low pass filter } for (; j < width - scalewin; j++) { float val = 0.f; float norm = 0.f; - for (int inbr = max (0, i - scalewin); inbr <= min (height - 1, i + scalewin); inbr += scale) { + for (int inbr = max(0, i - scalewin); inbr <= min(height - 1, i + scalewin); inbr += scale) { for (int jnbr = j - scalewin; jnbr <= j + scalewin; jnbr += scale) { - dirwt = DIRWT (inbr, jnbr, i, j); + dirwt = DIRWT(inbr, jnbr, i, j); val += dirwt * data_fine[inbr][jnbr]; norm += dirwt; } @@ -595,9 +595,9 @@ SSEFUNCTION void ImProcFunctions::dirpyr_channel(float ** data_fine, float ** da float val = 0.f; float norm = 0.f; - for (int inbr = max (0, i - scalewin); inbr <= min (height - 1, i + scalewin); inbr += scale) { + for (int inbr = max(0, i - scalewin); inbr <= min(height - 1, i + scalewin); inbr += scale) { for (int jnbr = j - scalewin; jnbr <= j + scalewin; jnbr += scale) { - dirwt = DIRWT (inbr, jnbr, i, j); + dirwt = DIRWT(inbr, jnbr, i, j); val += dirwt * data_fine[inbr][jnbr]; norm += dirwt; } @@ -612,9 +612,9 @@ SSEFUNCTION void ImProcFunctions::dirpyr_channel(float ** data_fine, float ** da float val = 0.f; float norm = 0.f; - for (int inbr = max (0, i - scalewin); inbr <= min (height - 1, i + scalewin); inbr += scale) { - for (int jnbr = j - scalewin; jnbr <= min (width - 1, j + scalewin); jnbr += scale) { - dirwt = DIRWT (inbr, jnbr, i, j); + for (int inbr = max(0, i - scalewin); inbr <= min(height - 1, i + scalewin); inbr += scale) { + for (int jnbr = j - scalewin; jnbr <= min(width - 1, j + scalewin); jnbr += scale) { + dirwt = DIRWT(inbr, jnbr, i, j); val += dirwt * data_fine[inbr][jnbr]; norm += dirwt; } @@ -631,7 +631,7 @@ SSEFUNCTION void ImProcFunctions::dirpyr_channel(float ** data_fine, float ** da #endif { #ifdef __SSE2__ - __m128 thousandv = _mm_set1_ps ( 1000.0f ); + __m128 thousandv = _mm_set1_ps(1000.0f); __m128 dirwtv, valv, normv, dftemp1v, dftemp2v; #endif // __SSE2__ int j; @@ -647,9 +647,9 @@ SSEFUNCTION void ImProcFunctions::dirpyr_channel(float ** data_fine, float ** da float val = 0.f; float norm = 0.f; - for (int inbr = max (0, i - scale); inbr <= min (height - 1, i + scale); inbr += scale) { - for (int jnbr = max (0, j - scale); jnbr <= j + scale; jnbr += scale) { - dirwt = RANGEFN (fabsf (data_fine[inbr][jnbr] - data_fine[i][j])); + for (int inbr = max(0, i - scale); inbr <= min(height - 1, i + scale); inbr += scale) { + for (int jnbr = max(0, j - scale); jnbr <= j + scale; jnbr += scale) { + dirwt = RANGEFN(fabsf(data_fine[inbr][jnbr] - data_fine[i][j])); val += dirwt * data_fine[inbr][jnbr]; norm += dirwt; } @@ -663,27 +663,27 @@ SSEFUNCTION void ImProcFunctions::dirpyr_channel(float ** data_fine, float ** da for (; j < width - scale - 3; j += 4) { valv = _mm_setzero_ps(); normv = _mm_setzero_ps(); - dftemp1v = LVFU (data_fine[i][j]); + dftemp1v = LVFU(data_fine[i][j]); - for (int inbr = MAX (0, i - scale); inbr <= MIN (height - 1, i + scale); inbr += scale) { + for (int inbr = MAX(0, i - scale); inbr <= MIN(height - 1, i + scale); inbr += scale) { for (int jnbr = j - scale; jnbr <= j + scale; jnbr += scale) { - dftemp2v = LVFU (data_fine[inbr][jnbr]); - dirwtv = thousandv / (vabsf (dftemp2v - dftemp1v) + thousandv); + dftemp2v = LVFU(data_fine[inbr][jnbr]); + dirwtv = thousandv / (vabsf(dftemp2v - dftemp1v) + thousandv); valv += dirwtv * dftemp2v; normv += dirwtv; } } - _mm_storeu_ps ( &data_coarse[i][j], valv / normv); //low pass filter + _mm_storeu_ps(&data_coarse[i][j], valv / normv); //low pass filter } for (; j < width - scale; j++) { float val = 0.f; float norm = 0.f; - for (int inbr = max (0, i - scale); inbr <= min (height - 1, i + scale); inbr += scale) { + for (int inbr = max(0, i - scale); inbr <= min(height - 1, i + scale); inbr += scale) { for (int jnbr = j - scale; jnbr <= j + scale; jnbr += scale) { - dirwt = RANGEFN (fabsf (data_fine[inbr][jnbr] - data_fine[i][j])); + dirwt = RANGEFN(fabsf(data_fine[inbr][jnbr] - data_fine[i][j])); val += dirwt * data_fine[inbr][jnbr]; norm += dirwt; } @@ -698,9 +698,9 @@ SSEFUNCTION void ImProcFunctions::dirpyr_channel(float ** data_fine, float ** da float val = 0.f; float norm = 0.f; - for (int inbr = max (0, i - scale); inbr <= min (height - 1, i + scale); inbr += scale) { + for (int inbr = max(0, i - scale); inbr <= min(height - 1, i + scale); inbr += scale) { for (int jnbr = j - scale; jnbr <= j + scale; jnbr += scale) { - dirwt = RANGEFN (fabsf (data_fine[inbr][jnbr] - data_fine[i][j])); + dirwt = RANGEFN(fabsf(data_fine[inbr][jnbr] - data_fine[i][j])); val += dirwt * data_fine[inbr][jnbr]; norm += dirwt; } @@ -715,9 +715,9 @@ SSEFUNCTION void ImProcFunctions::dirpyr_channel(float ** data_fine, float ** da float val = 0.f; float norm = 0.f; - for (int inbr = max (0, i - scale); inbr <= min (height - 1, i + scale); inbr += scale) { - for (int jnbr = j - scale; jnbr <= min (width - 1, j + scale); jnbr += scale) { - dirwt = RANGEFN (fabsf (data_fine[inbr][jnbr] - data_fine[i][j])); + for (int inbr = max(0, i - scale); inbr <= min(height - 1, i + scale); inbr += scale) { + for (int jnbr = j - scale; jnbr <= min(width - 1, j + scale); jnbr += scale) { + dirwt = RANGEFN(fabsf(data_fine[inbr][jnbr] - data_fine[i][j])); val += dirwt * data_fine[inbr][jnbr]; norm += dirwt; } @@ -731,7 +731,7 @@ SSEFUNCTION void ImProcFunctions::dirpyr_channel(float ** data_fine, float ** da } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -void ImProcFunctions::idirpyr_eq_channel_loc (float ** data_coarse, float ** data_fine, float ** loctemp, float ** buffer, int width, int height, int level, float mult[5], const double dirpyrThreshold, float ** hue, float ** chrom, const double skinprot, const bool gamutlab, float b_l, float t_l, float t_r, float b_r, int choice) +void ImProcFunctions::idirpyr_eq_channel_loc(float ** data_coarse, float ** data_fine, float ** loctemp, float ** buffer, int width, int height, int level, float mult[5], const double dirpyrThreshold, float ** hue, float ** chrom, const double skinprot, const bool gamutlab, float b_l, float t_l, float t_r, float b_r, int choice) { // const float skinprotneg = -skinprot; // const float factorHard = (1.f - skinprotneg / 100.f); @@ -756,19 +756,19 @@ void ImProcFunctions::idirpyr_eq_channel_loc (float ** data_coarse, float ** dat // multbis[level] = 1.f + 0.45f * (mult[level] - 1.f); // } - LUTf irangefn (0x20000); + LUTf irangefn(0x20000); { - const float noisehi = 1.33f * noise * dirpyrThreshold / expf (level * log (3.0)), noiselo = 0.66f * noise * dirpyrThreshold / expf (level * log (3.0)); + const float noisehi = 1.33f * noise * dirpyrThreshold / expf(level * log(3.0)), noiselo = 0.66f * noise * dirpyrThreshold / expf(level * log(3.0)); //printf("level=%i multlev=%f noisehi=%f noiselo=%f skinprot=%f\n",level,mult[level], noisehi, noiselo, skinprot); for (int i = 0; i < 0x20000; i++) { - if (abs (i - 0x10000) > noisehi || multbis[level] < 1.0) { + if (abs(i - 0x10000) > noisehi || multbis[level] < 1.0) { irangefn[i] = multbis[level] + offs; } else { - if (abs (i - 0x10000) < noiselo) { + if (abs(i - 0x10000) < noiselo) { irangefn[i] = 1.f + offs ; } else { - irangefn[i] = 1.f + offs + (multbis[level] - 1.f) * (noisehi - abs (i - 0x10000)) / (noisehi - noiselo + 0.01f) ; + irangefn[i] = 1.f + offs + (multbis[level] - 1.f) * (noisehi - abs(i - 0x10000)) / (noisehi - noiselo + 0.01f) ; } } } @@ -850,19 +850,19 @@ void ImProcFunctions::idirpyr_eq_channel(float ** data_coarse, float ** data_fin multbis[level] = 1.f + 0.45f * (mult[level] - 1.f); } - LUTf irangefn (0x20000); + LUTf irangefn(0x20000); { - const float noisehi = 1.33f * noise * dirpyrThreshold / expf (level * log (3.0)), noiselo = 0.66f * noise * dirpyrThreshold / expf (level * log (3.0)); + const float noisehi = 1.33f * noise * dirpyrThreshold / expf(level * log(3.0)), noiselo = 0.66f * noise * dirpyrThreshold / expf(level * log(3.0)); //printf("level=%i multlev=%f noisehi=%f noiselo=%f skinprot=%f\n",level,mult[level], noisehi, noiselo, skinprot); for (int i = 0; i < 0x20000; i++) { - if (abs (i - 0x10000) > noisehi || multbis[level] < 1.0) { + if (abs(i - 0x10000) > noisehi || multbis[level] < 1.0) { irangefn[i] = multbis[level] + offs; } else { - if (abs (i - 0x10000) < noiselo) { + if (abs(i - 0x10000) < noiselo) { irangefn[i] = 1.f + offs ; } else { - irangefn[i] = 1.f + offs + (multbis[level] - 1.f) * (noisehi - abs (i - 0x10000)) / (noisehi - noiselo + 0.01f) ; + irangefn[i] = 1.f + offs + (multbis[level] - 1.f) * (noisehi - abs(i - 0x10000)) / (noisehi - noiselo + 0.01f) ; } } } @@ -888,7 +888,7 @@ void ImProcFunctions::idirpyr_eq_channel(float ** data_coarse, float ** data_fin // These values are precalculated now float modhue = hue[i][j]; float modchro = chrom[i][j]; - Color::SkinSatCbdl ((data_fine[i][j]) / 327.68f, modhue, modchro, skinprot, scale, true, b_l, t_l, t_r); + Color::SkinSatCbdl((data_fine[i][j]) / 327.68f, modhue, modchro, skinprot, scale, true, b_l, t_l, t_r); buffer[i][j] += (1.f + (irangefn[hipass + 0x10000]) * scale) * hipass ; } } else @@ -902,7 +902,7 @@ void ImProcFunctions::idirpyr_eq_channel(float ** data_coarse, float ** data_fin // These values are precalculated now float modhue = hue[i][j]; float modchro = chrom[i][j]; - Color::SkinSatCbdl ((data_fine[i][j]) / 327.68f, modhue, modchro, skinprotneg, scale, false, b_l, t_l, t_r); + Color::SkinSatCbdl((data_fine[i][j]) / 327.68f, modhue, modchro, skinprotneg, scale, false, b_l, t_l, t_r); float correct = irangefn[hipass + 0x10000]; if (scale == 1.f) {//image hard @@ -941,19 +941,19 @@ void ImProcFunctions::idirpyr_eq_channelcam(float ** data_coarse, float ** data_ multbis[level] = 1.f + 0.45f * (mult[level] - 1.f); } - LUTf irangefn (0x20000); + LUTf irangefn(0x20000); { - const float noisehi = 1.33f * noise * dirpyrThreshold / expf (level * log (3.0)), noiselo = 0.66f * noise * dirpyrThreshold / expf (level * log (3.0)); + const float noisehi = 1.33f * noise * dirpyrThreshold / expf(level * log(3.0)), noiselo = 0.66f * noise * dirpyrThreshold / expf(level * log(3.0)); //printf("level=%i multlev=%f noisehi=%f noiselo=%f skinprot=%f\n",level,mult[level], noisehi, noiselo, skinprot); for (int i = 0; i < 0x20000; i++) { - if (abs (i - 0x10000) > noisehi || multbis[level] < 1.0) { + if (abs(i - 0x10000) > noisehi || multbis[level] < 1.0) { irangefn[i] = multbis[level] + offs; } else { - if (abs (i - 0x10000) < noiselo) { + if (abs(i - 0x10000) < noiselo) { irangefn[i] = 1.f + offs ; } else { - irangefn[i] = 1.f + offs + (multbis[level] - 1.f) * (noisehi - abs (i - 0x10000)) / (noisehi - noiselo + 0.01f) ; + irangefn[i] = 1.f + offs + (multbis[level] - 1.f) * (noisehi - abs(i - 0x10000)) / (noisehi - noiselo + 0.01f) ; } } } @@ -976,7 +976,7 @@ void ImProcFunctions::idirpyr_eq_channelcam(float ** data_coarse, float ** data_ for (int j = 0; j < width; j++) { float hipass = (data_fine[i][j] - data_coarse[i][j]); float scale = 1.f; - Color::SkinSatCbdlCam ((data_fine[i][j]) / 327.68f, l_a_h[i][j], l_b_c[i][j], skinprot, scale, true, b_l, t_l, t_r); + Color::SkinSatCbdlCam((data_fine[i][j]) / 327.68f, l_a_h[i][j], l_b_c[i][j], skinprot, scale, true, b_l, t_l, t_r); buffer[i][j] += (1.f + (irangefn[hipass + 0x10000]) * scale) * hipass ; } } else @@ -989,7 +989,7 @@ void ImProcFunctions::idirpyr_eq_channelcam(float ** data_coarse, float ** data_ float scale = 1.f; float correct; correct = irangefn[hipass + 0x10000]; - Color::SkinSatCbdlCam ((data_fine[i][j]) / 327.68f, l_a_h[i][j], l_b_c[i][j], skinprotneg, scale, false, b_l, t_l, t_r); + Color::SkinSatCbdlCam((data_fine[i][j]) / 327.68f, l_a_h[i][j], l_b_c[i][j], skinprotneg, scale, false, b_l, t_l, t_r); if (scale == 1.f) {//image hard buffer[i][j] += (1.f + (correct) * factorHard) * hipass ; diff --git a/rtengine/imagedata.cc b/rtengine/imagedata.cc index 5fb1e98f6..1b720b0dc 100644 --- a/rtengine/imagedata.cc +++ b/rtengine/imagedata.cc @@ -29,33 +29,33 @@ using namespace rtengine; -extern "C" IptcData *iptc_data_new_from_jpeg_file (FILE* infile); +extern "C" IptcData *iptc_data_new_from_jpeg_file(FILE* infile); namespace { -Glib::ustring to_utf8 (const std::string& str) +Glib::ustring to_utf8(const std::string& str) { try { - return Glib::locale_to_utf8 (str); + return Glib::locale_to_utf8(str); } catch (Glib::Error&) { - return Glib::convert_with_fallback (str, "UTF-8", "ISO-8859-1", "?"); + return Glib::convert_with_fallback(str, "UTF-8", "ISO-8859-1", "?"); } } } -FramesMetaData* FramesMetaData::fromFile (const Glib::ustring& fname, std::unique_ptr rml, bool firstFrameOnly) +FramesMetaData* FramesMetaData::fromFile(const Glib::ustring& fname, std::unique_ptr rml, bool firstFrameOnly) { - return new FramesData (fname, std::move(rml), firstFrameOnly); + return new FramesData(fname, std::move(rml), firstFrameOnly); } -FrameData::FrameData (rtexif::TagDirectory* frameRootDir_, rtexif::TagDirectory* rootDir, rtexif::TagDirectory* firstRootDir) +FrameData::FrameData(rtexif::TagDirectory* frameRootDir_, rtexif::TagDirectory* rootDir, rtexif::TagDirectory* firstRootDir) : frameRootDir(frameRootDir_), iptc(nullptr), time(), timeStamp(), iso_speed(0), aperture(0.), focal_len(0.), focal_len35mm(0.), focus_dist(0.f), shutter(0.), expcomp(0.), make("Unknown"), model("Unknown"), orientation("Unknown"), lens("Unknown"), sampleFormat(IIOSF_UNKNOWN), isPixelShift(false), isHDR(false) { - memset (&time, 0, sizeof(time)); + memset(&time, 0, sizeof(time)); if (!frameRootDir) { return; @@ -80,39 +80,43 @@ FrameData::FrameData (rtexif::TagDirectory* frameRootDir_, rtexif::TagDirectory* lens.clear(); tag = newFrameRootDir->findTag("Make"); + if (!tag) { newFrameRootDir = rootDir; tag = newFrameRootDir->findTag("Make"); + if (!tag) { // For some raw files (like Canon's CR2 files), the metadata are contained in the first root directory newFrameRootDir = firstRootDir; tag = newFrameRootDir->findTag("Make"); } } + if (tag) { make = tag->valueToString(); + // Same dcraw treatment for (const auto& corp : { - "Canon", - "NIKON", - "EPSON", - "KODAK", - "Kodak", - "OLYMPUS", - "PENTAX", - "RICOH", - "MINOLTA", - "Minolta", - "Konica", - "CASIO", - "Sinar", - "Phase One", - "SAMSUNG", - "Mamiya", - "MOTOROLA", - "Leaf", - "Panasonic" - }) { + "Canon", + "NIKON", + "EPSON", + "KODAK", + "Kodak", + "OLYMPUS", + "PENTAX", + "RICOH", + "MINOLTA", + "Minolta", + "Konica", + "CASIO", + "Sinar", + "Phase One", + "SAMSUNG", + "Mamiya", + "MOTOROLA", + "Leaf", + "Panasonic" + }) { if (make.find(corp) != std::string::npos) { // Simplify company names make = corp; break; @@ -123,6 +127,7 @@ FrameData::FrameData (rtexif::TagDirectory* frameRootDir_, rtexif::TagDirectory* } tag = newFrameRootDir->findTagUpward("Model"); + if (tag) { model = tag->valueToString(); } @@ -149,7 +154,7 @@ FrameData::FrameData (rtexif::TagDirectory* frameRootDir_, rtexif::TagDirectory* } } - if (model.find( "Digital Camera ") != std::string::npos) { + if (model.find("Digital Camera ") != std::string::npos) { model.erase(0, 15); } } else { @@ -157,51 +162,54 @@ FrameData::FrameData (rtexif::TagDirectory* frameRootDir_, rtexif::TagDirectory* } tag = newFrameRootDir->findTagUpward("Orientation"); + if (tag) { - orientation = tag->valueToString (); + orientation = tag->valueToString(); } tag = newFrameRootDir->findTagUpward("MakerNote"); rtexif::TagDirectory* mnote = nullptr; + if (tag) { mnote = tag->getDirectory(); } rtexif::TagDirectory* exif = nullptr; tag = newFrameRootDir->findTagUpward("Exif"); + if (tag) { - exif = tag->getDirectory (); + exif = tag->getDirectory(); } if (exif) { // standard exif tags - if ((tag = exif->getTag ("ShutterSpeedValue"))) { - shutter = tag->toDouble (); + if ((tag = exif->getTag("ShutterSpeedValue"))) { + shutter = tag->toDouble(); } - if ((tag = exif->getTag ("ExposureTime"))) { - shutter = tag->toDouble (); + if ((tag = exif->getTag("ExposureTime"))) { + shutter = tag->toDouble(); } - if ((tag = exif->getTag ("ApertureValue"))) { - aperture = tag->toDouble (); + if ((tag = exif->getTag("ApertureValue"))) { + aperture = tag->toDouble(); } - if ((tag = exif->getTag ("FNumber"))) { - aperture = tag->toDouble (); + if ((tag = exif->getTag("FNumber"))) { + aperture = tag->toDouble(); } - if ((tag = exif->getTag ("ExposureBiasValue"))) { - expcomp = tag->toDouble (); + if ((tag = exif->getTag("ExposureBiasValue"))) { + expcomp = tag->toDouble(); } - if ((tag = exif->getTag ("FocalLength"))) { - focal_len = tag->toDouble (); + if ((tag = exif->getTag("FocalLength"))) { + focal_len = tag->toDouble(); } - if ((tag = exif->getTag ("FocalLengthIn35mmFilm"))) { - focal_len35mm = tag->toDouble (); + if ((tag = exif->getTag("FocalLengthIn35mmFilm"))) { + focal_len35mm = tag->toDouble(); } // Focus distance from EXIF or XMP. MakerNote ones are scattered and partly encrypted @@ -230,12 +238,12 @@ FrameData::FrameData (rtexif::TagDirectory* frameRootDir_, rtexif::TagDirectory* } } - if ((tag = exif->getTag ("ISOSpeedRatings"))) { - iso_speed = tag->toDouble (); + if ((tag = exif->getTag("ISOSpeedRatings"))) { + iso_speed = tag->toDouble(); } - if ((tag = exif->getTag ("DateTimeOriginal"))) { - if (sscanf ((const char*)tag->getValue(), "%d:%d:%d %d:%d:%d", &time.tm_year, &time.tm_mon, &time.tm_mday, &time.tm_hour, &time.tm_min, &time.tm_sec) == 6) { + if ((tag = exif->getTag("DateTimeOriginal"))) { + if (sscanf((const char*)tag->getValue(), "%d:%d:%d %d:%d:%d", &time.tm_year, &time.tm_mon, &time.tm_mday, &time.tm_hour, &time.tm_min, &time.tm_sec) == 6) { time.tm_year -= 1900; time.tm_mon -= 1; time.tm_isdst = -1; @@ -243,10 +251,10 @@ FrameData::FrameData (rtexif::TagDirectory* frameRootDir_, rtexif::TagDirectory* } } - tag = exif->findTag ("SerialNumber"); + tag = exif->findTag("SerialNumber"); - if(!tag) { - tag = exif->findTag ("InternalSerialNumber"); + if (!tag) { + tag = exif->findTag("InternalSerialNumber"); } if (tag) { @@ -258,15 +266,15 @@ FrameData::FrameData (rtexif::TagDirectory* frameRootDir_, rtexif::TagDirectory* // Sometimes (e.g. DNG) EXIF already contains lens data - if(!make.compare (0, 8, "FUJIFILM")) { - if(exif->getTag ("LensModel")) { - lens = exif->getTag ("LensModel")->valueToString (); + if (!make.compare(0, 8, "FUJIFILM")) { + if (exif->getTag("LensModel")) { + lens = exif->getTag("LensModel")->valueToString(); } - } else if(!make.compare (0, 4, "SONY")) { + } else if (!make.compare(0, 4, "SONY")) { if (iso_speed == 65535 || iso_speed == 0) { - rtexif::Tag* isoTag = exif->getTag ("RecommendedExposureIndex"); + rtexif::Tag* isoTag = exif->getTag("RecommendedExposureIndex"); - if(isoTag) { + if (isoTag) { iso_speed = isoTag->toDouble(); } } @@ -277,7 +285,7 @@ FrameData::FrameData (rtexif::TagDirectory* frameRootDir_, rtexif::TagDirectory* if (mnote) { - if (!make.compare (0, 5, "NIKON")) { + if (!make.compare(0, 5, "NIKON")) { // ISO at max value supported, check manufacturer specific if (iso_speed == 65535 || iso_speed == 0) { rtexif::Tag* isoTag = mnote->getTagP("ISOInfo/ISO"); @@ -289,25 +297,25 @@ FrameData::FrameData (rtexif::TagDirectory* frameRootDir_, rtexif::TagDirectory* bool lensOk = false; - if (mnote->getTag ("LensData")) { - std::string ldata = mnote->getTag ("LensData")->valueToString (); + if (mnote->getTag("LensData")) { + std::string ldata = mnote->getTag("LensData")->valueToString(); size_t pos; - if (ldata.size() > 10 && (pos = ldata.find ("Lens = ")) != Glib::ustring::npos) { - lens = ldata.substr (pos + 7); + if (ldata.size() > 10 && (pos = ldata.find("Lens = ")) != Glib::ustring::npos) { + lens = ldata.substr(pos + 7); - if (lens.compare (0, 7, "Unknown")) { + if (lens.compare(0, 7, "Unknown")) { lensOk = true; } else { size_t pos = lens.find("$FL$"); // is there a placeholder for focallength? - if(pos != Glib::ustring::npos) { // then fill in focallength - lens = lens.replace(pos, 4, exif->getTag ("FocalLength")->valueToString ()); + if (pos != Glib::ustring::npos) { // then fill in focallength + lens = lens.replace(pos, 4, exif->getTag("FocalLength")->valueToString()); - if(mnote->getTag ("LensType")) { - std::string ltype = mnote->getTag ("LensType")->valueToString (); + if (mnote->getTag("LensType")) { + std::string ltype = mnote->getTag("LensType")->valueToString(); - if(ltype.find("MF = Yes") != Glib::ustring::npos) { // check, whether it's a MF lens, should be always + if (ltype.find("MF = Yes") != Glib::ustring::npos) { // check, whether it's a MF lens, should be always lens = lens.replace(0, 7, "MF"); } @@ -318,8 +326,8 @@ FrameData::FrameData (rtexif::TagDirectory* frameRootDir_, rtexif::TagDirectory* } } - if (!lensOk && mnote->getTag ("Lens")) { - std::string ldata = mnote->getTag ("Lens")->valueToString (); + if (!lensOk && mnote->getTag("Lens")) { + std::string ldata = mnote->getTag("Lens")->valueToString(); size_t i = 0, j = 0; double n[4] = {0.0}; @@ -339,7 +347,7 @@ FrameData::FrameData (rtexif::TagDirectory* frameRootDir_, rtexif::TagDirectory* int den = atoi(ldata.substr(j, i).c_str()); j = i + 2; i += 2; - n[m] = (double) nom / std::max(den,1); + n[m] = (double) nom / std::max(den, 1); } std::ostringstream str; @@ -355,17 +363,17 @@ FrameData::FrameData (rtexif::TagDirectory* frameRootDir_, rtexif::TagDirectory* lens = str.str(); // Look whether it's MF or AF - if(mnote->getTag ("LensType")) { - std::string ltype = mnote->getTag ("LensType")->valueToString (); + if (mnote->getTag("LensType")) { + std::string ltype = mnote->getTag("LensType")->valueToString(); - if(ltype.find("MF = Yes") != Glib::ustring::npos) { // check, whether it's a MF lens + if (ltype.find("MF = Yes") != Glib::ustring::npos) { // check, whether it's a MF lens lens = lens.replace(0, 7, "MF"); // replace 'Unknwon' with 'MF' } else { lens = lens.replace(0, 7, "AF"); // replace 'Unknwon' with 'AF' } } } - } else if (!make.compare (0, 5, "Canon")) { + } else if (!make.compare(0, 5, "Canon")) { // ISO at max value supported, check manufacturer specific if (iso_speed == 65535 || iso_speed == 0) { rtexif::Tag* baseIsoTag = mnote->getTagP("CanonShotInfo/BaseISO"); @@ -379,8 +387,8 @@ FrameData::FrameData (rtexif::TagDirectory* frameRootDir_, rtexif::TagDirectory* // canon EXIF have a string for lens model rtexif::Tag *lt = mnote->getTag("LensType"); - if ( lt ) { - std::string ldata = lt->valueToString (); + if (lt) { + std::string ldata = lt->valueToString(); if (ldata.size() > 1) { found = true; @@ -388,85 +396,88 @@ FrameData::FrameData (rtexif::TagDirectory* frameRootDir_, rtexif::TagDirectory* } } - if( !found || lens.substr(lens.find(' ')).length() < 7 ) { + if (!found || lens.substr(lens.find(' ')).length() < 7) { lt = mnote->findTag("LensID"); - if ( lt ) { - std::string ldata = lt->valueToString (); + if (lt) { + std::string ldata = lt->valueToString(); if (ldata.size() > 1) { lens = ldata; } } } - } else if (!make.compare (0, 6, "PENTAX") || (!make.compare (0, 5, "RICOH") && !model.compare (0, 6, "PENTAX"))) { + } else if (!make.compare(0, 6, "PENTAX") || (!make.compare(0, 5, "RICOH") && !model.compare(0, 6, "PENTAX"))) { // ISO at max value supported, check manufacturer specific if (iso_speed == 65535 || iso_speed == 0) { rtexif::Tag* baseIsoTag = mnote->getTag("ISO"); + if (baseIsoTag) { std::string isoData = baseIsoTag->valueToString(); + if (isoData.size() > 1) { iso_speed = stoi(isoData); } } } - if (mnote->getTag ("LensType")) { - lens = mnote->getTag ("LensType")->valueToString (); + + if (mnote->getTag("LensType")) { + lens = mnote->getTag("LensType")->valueToString(); } // Try to get the FocalLength from the LensInfo structure, where length below 10mm will be correctly set - rtexif::Tag* flt = mnote->getTagP ("LensInfo/FocalLength"); + rtexif::Tag* flt = mnote->getTagP("LensInfo/FocalLength"); if (flt) { // Don't replace Exif focal_len if Makernotes focal_len is 0 if (flt->toDouble() > 0) { - focal_len = flt->toDouble (); + focal_len = flt->toDouble(); } - } else if ((flt = mnote->getTagP ("FocalLength"))) { - rtexif::Tag* flt = mnote->getTag ("FocalLength"); - focal_len = flt->toDouble (); + } else if ((flt = mnote->getTagP("FocalLength"))) { + rtexif::Tag* flt = mnote->getTag("FocalLength"); + focal_len = flt->toDouble(); } - if (mnote->getTag ("FocalLengthIn35mmFilm")) { - focal_len35mm = mnote->getTag ("FocalLengthIn35mmFilm")->toDouble (); + if (mnote->getTag("FocalLengthIn35mmFilm")) { + focal_len35mm = mnote->getTag("FocalLengthIn35mmFilm")->toDouble(); } - } else if (mnote && (!make.compare (0, 4, "SONY") || !make.compare (0, 6, "KONICA"))) { - if (mnote->getTag ("LensID")) { - lens = mnote->getTag ("LensID")->valueToString (); + } else if (mnote && (!make.compare(0, 4, "SONY") || !make.compare(0, 6, "KONICA"))) { + if (mnote->getTag("LensID")) { + lens = mnote->getTag("LensID")->valueToString(); } - } else if (!make.compare (0, 7, "OLYMPUS")) { - if (mnote->getTag ("Equipment")) { - rtexif::TagDirectory* eq = mnote->getTag ("Equipment")->getDirectory (); + } else if (!make.compare(0, 7, "OLYMPUS")) { + if (mnote->getTag("Equipment")) { + rtexif::TagDirectory* eq = mnote->getTag("Equipment")->getDirectory(); - if (eq->getTag ("LensType")) { - lens = eq->getTag ("LensType")->valueToString (); + if (eq->getTag("LensType")) { + lens = eq->getTag("LensType")->valueToString(); } } - } else if (mnote && !make.compare (0, 9, "Panasonic")) { - if (mnote->getTag ("LensType")) { + } else if (mnote && !make.compare(0, 9, "Panasonic")) { + if (mnote->getTag("LensType")) { std::string panalens = mnote->getTag("LensType")->valueToString(); if (panalens.find("LUMIX") != Glib::ustring::npos) { lens = "Panasonic " + panalens; - } - else { + } else { lens = panalens; } } } - } else if (exif->getTag ("DNGLensInfo")) { - lens = exif->getTag ("DNGLensInfo")->valueToString (); - } else if (exif->getTag ("LensModel")) { - lens = exif->getTag ("LensModel")->valueToString (); - } else if (exif->getTag ("LensInfo")) { - lens = exif->getTag ("LensInfo")->valueToString (); + } else if (exif->getTag("DNGLensInfo")) { + lens = exif->getTag("DNGLensInfo")->valueToString(); + } else if (exif->getTag("LensModel")) { + lens = exif->getTag("LensModel")->valueToString(); + } else if (exif->getTag("LensInfo")) { + lens = exif->getTag("LensInfo")->valueToString(); } } } rtexif::Tag* t = newFrameRootDir->getTag(0x83BB); + if (t) { - iptc = iptc_data_new_from_data ((unsigned char*)t->getValue (), (unsigned)t->getValueSize ()); + iptc = iptc_data_new_from_data((unsigned char*)t->getValue(), (unsigned)t->getValueSize()); } @@ -480,8 +491,9 @@ FrameData::FrameData (rtexif::TagDirectory* frameRootDir_, rtexif::TagDirectory* const rtexif::Tag* const pi = frameRootDir->findTag("PhotometricInterpretation"); const rtexif::Tag* const c = frameRootDir->findTag("Compression"); - if (mnote && (!make.compare (0, 6, "PENTAX") || (!make.compare (0, 5, "RICOH") && !model.compare (0, 6, "PENTAX")))) { + if (mnote && (!make.compare(0, 6, "PENTAX") || (!make.compare(0, 5, "RICOH") && !model.compare(0, 6, "PENTAX")))) { const rtexif::Tag* const hdr = mnote->findTag("HDR"); + if (hdr) { if (hdr->toInt() > 0 && hdr->toInt(2) > 0) { isHDR = true; @@ -491,10 +503,12 @@ FrameData::FrameData (rtexif::TagDirectory* frameRootDir_, rtexif::TagDirectory* } } else { const rtexif::Tag* const dm = mnote->findTag("DriveMode"); + if (dm) { char buffer[60]; dm->toString(buffer, 3); buffer[3] = 0; + if (!strcmp(buffer, "HDR")) { isHDR = true; #if PRINT_HDR_PS_DETECTION @@ -506,6 +520,7 @@ FrameData::FrameData (rtexif::TagDirectory* frameRootDir_, rtexif::TagDirectory* if (!isHDR) { const rtexif::Tag* const q = mnote->findTag("Quality"); + if (q && q->toInt() == 7) { isPixelShift = true; #if PRINT_HDR_PS_DETECTION @@ -542,6 +557,7 @@ FrameData::FrameData (rtexif::TagDirectory* frameRootDir_, rtexif::TagDirectory* samplesperpixel = spp->toInt(); photometric = pi->toInt(); + if (photometric == PHOTOMETRIC_LOGLUV) { if (!c) { compression = COMPRESSION_NONE; @@ -599,7 +615,8 @@ FrameData::FrameData (rtexif::TagDirectory* frameRootDir_, rtexif::TagDirectory* sampleFormat = IIOSF_UNSIGNED_CHAR; } else if (bitspersample <= 16) { sampleFormat = IIOSF_UNSIGNED_SHORT; - if (mnote && (!make.compare (0, 4, "SONY")) && bitspersample >= 12 && samplesperpixel == 4) { + + if (mnote && (!make.compare(0, 4, "SONY")) && bitspersample >= 12 && samplesperpixel == 4) { isPixelShift = true; #if PRINT_HDR_PS_DETECTION printf("PixelShift detected ! -> \"Make\" = SONY, bitsPerPixel > 8, samplesPerPixel == 4\n"); @@ -624,20 +641,20 @@ FrameData::FrameData (rtexif::TagDirectory* frameRootDir_, rtexif::TagDirectory* } } -FrameData::~FrameData () +FrameData::~FrameData() { if (iptc) { - iptc_data_free (iptc); + iptc_data_free(iptc); } } -procparams::IPTCPairs FrameData::getIPTCData () const +procparams::IPTCPairs FrameData::getIPTCData() const { return getIPTCData(iptc); } -procparams::IPTCPairs FrameData::getIPTCData (IptcData* iptc_) +procparams::IPTCPairs FrameData::getIPTCData(IptcData* iptc_) { procparams::IPTCPairs iptcc; @@ -649,34 +666,34 @@ procparams::IPTCPairs FrameData::getIPTCData (IptcData* iptc_) unsigned char buffer[2100]; for (int i = 0; i < 16; i++) { - IptcDataSet* ds = iptc_data_get_next_dataset (iptc_, nullptr, IPTC_RECORD_APP_2, strTags[i].tag); + IptcDataSet* ds = iptc_data_get_next_dataset(iptc_, nullptr, IPTC_RECORD_APP_2, strTags[i].tag); if (ds) { - iptc_dataset_get_data (ds, buffer, 2100); + iptc_dataset_get_data(ds, buffer, 2100); std::vector icValues; - icValues.push_back (to_utf8((char*)buffer)); + icValues.push_back(to_utf8((char*)buffer)); iptcc[strTags[i].field] = icValues; - iptc_dataset_unref (ds); + iptc_dataset_unref(ds); } } IptcDataSet* ds = nullptr; std::vector keywords; - while ((ds = iptc_data_get_next_dataset (iptc_, ds, IPTC_RECORD_APP_2, IPTC_TAG_KEYWORDS))) { - iptc_dataset_get_data (ds, buffer, 2100); - keywords.push_back (to_utf8((char*)buffer)); + while ((ds = iptc_data_get_next_dataset(iptc_, ds, IPTC_RECORD_APP_2, IPTC_TAG_KEYWORDS))) { + iptc_dataset_get_data(ds, buffer, 2100); + keywords.push_back(to_utf8((char*)buffer)); } iptcc["Keywords"] = keywords; ds = nullptr; std::vector suppCategories; - while ((ds = iptc_data_get_next_dataset (iptc_, ds, IPTC_RECORD_APP_2, IPTC_TAG_SUPPL_CATEGORY))) { - iptc_dataset_get_data (ds, buffer, 2100); - suppCategories.push_back (to_utf8((char*)buffer)); - iptc_dataset_unref (ds); + while ((ds = iptc_data_get_next_dataset(iptc_, ds, IPTC_RECORD_APP_2, IPTC_TAG_SUPPL_CATEGORY))) { + iptc_dataset_get_data(ds, buffer, 2100); + suppCategories.push_back(to_utf8((char*)buffer)); + iptc_dataset_unref(ds); } iptcc["SupplementalCategories"] = suppCategories; @@ -684,110 +701,110 @@ procparams::IPTCPairs FrameData::getIPTCData (IptcData* iptc_) } -bool FrameData::getPixelShift () const +bool FrameData::getPixelShift() const { return isPixelShift; } -bool FrameData::getHDR () const +bool FrameData::getHDR() const { return isHDR; } -IIOSampleFormat FrameData::getSampleFormat () const +IIOSampleFormat FrameData::getSampleFormat() const { return sampleFormat; } -rtexif::TagDirectory* FrameData::getExifData () const +rtexif::TagDirectory* FrameData::getExifData() const { return frameRootDir; } -bool FrameData::hasExif () const +bool FrameData::hasExif() const { return frameRootDir && frameRootDir->getCount(); } -bool FrameData::hasIPTC () const +bool FrameData::hasIPTC() const { return iptc; } -tm FrameData::getDateTime () const +tm FrameData::getDateTime() const { return time; } -time_t FrameData::getDateTimeAsTS () const +time_t FrameData::getDateTimeAsTS() const { return timeStamp; } -int FrameData::getISOSpeed () const +int FrameData::getISOSpeed() const { return iso_speed; } -double FrameData::getFNumber () const +double FrameData::getFNumber() const { return aperture; } -double FrameData::getFocalLen () const +double FrameData::getFocalLen() const { return focal_len; } -double FrameData::getFocalLen35mm () const +double FrameData::getFocalLen35mm() const { return focal_len35mm; } -float FrameData::getFocusDist () const +float FrameData::getFocusDist() const { return focus_dist; } -double FrameData::getShutterSpeed () const +double FrameData::getShutterSpeed() const { return shutter; } -double FrameData::getExpComp () const +double FrameData::getExpComp() const { return expcomp; } -std::string FrameData::getMake () const +std::string FrameData::getMake() const { return make; } -std::string FrameData::getModel () const +std::string FrameData::getModel() const { return model; } -std::string FrameData::getLens () const +std::string FrameData::getLens() const { return lens; } -std::string FrameData::getSerialNumber () const +std::string FrameData::getSerialNumber() const { return serial; } -std::string FrameData::getOrientation () const +std::string FrameData::getOrientation() const { return orientation; } -void FramesData::setDCRawFrameCount (unsigned int frameCount) +void FramesData::setDCRawFrameCount(unsigned int frameCount) { dcrawFrameCount = frameCount; } -unsigned int FramesData::getRootCount () const +unsigned int FramesData::getRootCount() const { return roots.size(); } -unsigned int FramesData::getFrameCount () const +unsigned int FramesData::getFrameCount() const { return dcrawFrameCount ? dcrawFrameCount : frames.size(); } -FrameData *FramesData::getFrameData (unsigned int frame) const +FrameData *FramesData::getFrameData(unsigned int frame) const { return frames.empty() || frame >= frames.size() ? nullptr : frames.at(frame); } -bool FramesData::getPixelShift (unsigned int frame) const +bool FramesData::getPixelShift(unsigned int frame) const { // So far only Pentax and Sony provide multi-frame HDR file. // Only the first frame contains the HDR tag @@ -795,9 +812,9 @@ bool FramesData::getPixelShift (unsigned int frame) const // to evolve //return frames.at(frame)->getPixelShift (); - return frames.empty() || frame >= frames.size() ? false : frames.at(0)->getPixelShift (); + return frames.empty() || frame >= frames.size() ? false : frames.at(0)->getPixelShift(); } -bool FramesData::getHDR (unsigned int frame) const +bool FramesData::getHDR(unsigned int frame) const { // So far only Pentax provide multi-frame HDR file. // Only the first frame contains the HDR tag @@ -805,56 +822,61 @@ bool FramesData::getHDR (unsigned int frame) const // to evolve //return frames.at(frame)->getHDR (); - return frames.empty() || frame >= frames.size() ? false : frames.at(0)->getHDR (); + return frames.empty() || frame >= frames.size() ? false : frames.at(0)->getHDR(); } -IIOSampleFormat FramesData::getSampleFormat (unsigned int frame) const +IIOSampleFormat FramesData::getSampleFormat(unsigned int frame) const { - return frames.empty() || frame >= frames.size() ? IIOSF_UNKNOWN : frames.at(frame)->getSampleFormat (); + return frames.empty() || frame >= frames.size() ? IIOSF_UNKNOWN : frames.at(frame)->getSampleFormat(); } -rtexif::TagDirectory* FramesData::getFrameExifData (unsigned int frame) const +rtexif::TagDirectory* FramesData::getFrameExifData(unsigned int frame) const { - return frames.empty() || frame >= frames.size() ? nullptr : frames.at(frame)->getExifData (); + return frames.empty() || frame >= frames.size() ? nullptr : frames.at(frame)->getExifData(); } -rtexif::TagDirectory* FramesData::getBestExifData (ImageSource *imgSource, procparams::RAWParams *rawParams) const +rtexif::TagDirectory* FramesData::getBestExifData(ImageSource *imgSource, procparams::RAWParams *rawParams) const { rtexif::TagDirectory *td = nullptr; + if (frames.empty()) { return nullptr; } + if (imgSource && rawParams) { eSensorType sensorType = imgSource->getSensorType(); unsigned int imgNum = 0; + if (sensorType == ST_BAYER) { imgNum = rtengine::LIM(rawParams->bayersensor.imageNum, 0, frames.size() - 1); - /* - // might exist someday ? - } else if (sensorType == ST_FUJI_XTRANS) { - imgNum = rtengine::LIM(rawParams->xtranssensor.imageNum, 0, frames.size() - 1); - } else if (sensorType == ST_NONE && !imgSource->isRAW()) { - // standard image multiframe support should come here (when implemented in GUI) - */ + /* + // might exist someday ? + } else if (sensorType == ST_FUJI_XTRANS) { + imgNum = rtengine::LIM(rawParams->xtranssensor.imageNum, 0, frames.size() - 1); + } else if (sensorType == ST_NONE && !imgSource->isRAW()) { + // standard image multiframe support should come here (when implemented in GUI) + */ } - td = getFrameExifData (imgNum); + td = getFrameExifData(imgNum); rtexif::Tag* makeTag; + if (td && (makeTag = td->findTag("Make", true))) { td = makeTag->getParent(); } else { td = getRootExifData(0); } } + return td; } -rtexif::TagDirectory* FramesData::getRootExifData (unsigned int root) const +rtexif::TagDirectory* FramesData::getRootExifData(unsigned int root) const { return roots.empty() || root >= roots.size() ? nullptr : roots.at(root); } -procparams::IPTCPairs FramesData::getIPTCData (unsigned int frame) const +procparams::IPTCPairs FramesData::getIPTCData(unsigned int frame) const { if (frame < frames.size() && frames.at(frame)->hasIPTC()) { return frames.at(frame)->getIPTCData(); @@ -868,136 +890,136 @@ procparams::IPTCPairs FramesData::getIPTCData (unsigned int frame) const } } -bool FramesData::hasExif (unsigned int frame) const +bool FramesData::hasExif(unsigned int frame) const { - return frames.empty() || frame >= frames.size() ? false : frames.at(frame)->hasExif (); + return frames.empty() || frame >= frames.size() ? false : frames.at(frame)->hasExif(); } -bool FramesData::hasIPTC (unsigned int frame) const +bool FramesData::hasIPTC(unsigned int frame) const { - return frames.empty() || frame >= frames.size() ? false : frames.at(frame)->hasIPTC (); + return frames.empty() || frame >= frames.size() ? false : frames.at(frame)->hasIPTC(); } -tm FramesData::getDateTime (unsigned int frame) const +tm FramesData::getDateTime(unsigned int frame) const { - if (frames.empty() || frame >= frames.size() ) { + if (frames.empty() || frame >= frames.size()) { return {}; } else { - return frames.at(frame)->getDateTime (); + return frames.at(frame)->getDateTime(); } } time_t FramesData::getDateTimeAsTS(unsigned int frame) const { - return frames.empty() || frame >= frames.size() ? 0 : frames.at(frame)->getDateTimeAsTS (); + return frames.empty() || frame >= frames.size() ? 0 : frames.at(frame)->getDateTimeAsTS(); } -int FramesData::getISOSpeed (unsigned int frame) const +int FramesData::getISOSpeed(unsigned int frame) const { - return frames.empty() || frame >= frames.size() ? 0 : frames.at(frame)->getISOSpeed (); + return frames.empty() || frame >= frames.size() ? 0 : frames.at(frame)->getISOSpeed(); } -double FramesData::getFNumber (unsigned int frame) const +double FramesData::getFNumber(unsigned int frame) const { - return frames.empty() || frame >= frames.size() ? 0. : frames.at(frame)->getFNumber (); + return frames.empty() || frame >= frames.size() ? 0. : frames.at(frame)->getFNumber(); } -double FramesData::getFocalLen (unsigned int frame) const +double FramesData::getFocalLen(unsigned int frame) const { - return frames.empty() || frame >= frames.size() ? 0. : frames.at(frame)->getFocalLen (); + return frames.empty() || frame >= frames.size() ? 0. : frames.at(frame)->getFocalLen(); } -double FramesData::getFocalLen35mm (unsigned int frame) const +double FramesData::getFocalLen35mm(unsigned int frame) const { - return frames.empty() || frame >= frames.size() ? 0. : frames.at(frame)->getFocalLen35mm (); + return frames.empty() || frame >= frames.size() ? 0. : frames.at(frame)->getFocalLen35mm(); } -float FramesData::getFocusDist (unsigned int frame) const +float FramesData::getFocusDist(unsigned int frame) const { - return frames.empty() || frame >= frames.size() ? 0.f : frames.at(frame)->getFocusDist (); + return frames.empty() || frame >= frames.size() ? 0.f : frames.at(frame)->getFocusDist(); } -double FramesData::getShutterSpeed (unsigned int frame) const +double FramesData::getShutterSpeed(unsigned int frame) const { - return frames.empty() || frame >= frames.size() ? 0. : frames.at(frame)->getShutterSpeed (); + return frames.empty() || frame >= frames.size() ? 0. : frames.at(frame)->getShutterSpeed(); } -double FramesData::getExpComp (unsigned int frame) const +double FramesData::getExpComp(unsigned int frame) const { - return frames.empty() || frame >= frames.size() ? 0. : frames.at(frame)->getExpComp (); + return frames.empty() || frame >= frames.size() ? 0. : frames.at(frame)->getExpComp(); } -std::string FramesData::getMake (unsigned int frame) const +std::string FramesData::getMake(unsigned int frame) const { - return frames.empty() || frame >= frames.size() ? std::string() : frames.at(frame)->getMake (); + return frames.empty() || frame >= frames.size() ? std::string() : frames.at(frame)->getMake(); } -std::string FramesData::getModel (unsigned int frame) const +std::string FramesData::getModel(unsigned int frame) const { - return frames.empty() || frame >= frames.size() ? std::string() : frames.at(frame)->getModel (); + return frames.empty() || frame >= frames.size() ? std::string() : frames.at(frame)->getModel(); } -std::string FramesData::getLens (unsigned int frame) const +std::string FramesData::getLens(unsigned int frame) const { - return frames.empty() || frame >= frames.size() ? std::string() : frames.at(frame)->getLens (); + return frames.empty() || frame >= frames.size() ? std::string() : frames.at(frame)->getLens(); } -std::string FramesData::getSerialNumber (unsigned int frame) const +std::string FramesData::getSerialNumber(unsigned int frame) const { - return frames.empty() || frame >= frames.size() ? std::string() : frames.at(frame)->getSerialNumber (); + return frames.empty() || frame >= frames.size() ? std::string() : frames.at(frame)->getSerialNumber(); } -std::string FramesData::getOrientation (unsigned int frame) const +std::string FramesData::getOrientation(unsigned int frame) const { - return frames.empty() || frame >= frames.size() ? std::string() : frames.at(frame)->getOrientation (); + return frames.empty() || frame >= frames.size() ? std::string() : frames.at(frame)->getOrientation(); } //------inherited functions--------------// -std::string FramesMetaData::apertureToString (double aperture) +std::string FramesMetaData::apertureToString(double aperture) { char buffer[256]; - sprintf (buffer, "%0.1f", aperture); + sprintf(buffer, "%0.1f", aperture); return buffer; } -std::string FramesMetaData::shutterToString (double shutter) +std::string FramesMetaData::shutterToString(double shutter) { char buffer[256]; if (shutter > 0.0 && shutter <= 0.5) { - sprintf (buffer, "1/%0.0f", 1.0 / shutter); + sprintf(buffer, "1/%0.0f", 1.0 / shutter); } else { - sprintf (buffer, "%0.1f", shutter); + sprintf(buffer, "%0.1f", shutter); } return buffer; } -std::string FramesMetaData::expcompToString (double expcomp, bool maskZeroexpcomp) +std::string FramesMetaData::expcompToString(double expcomp, bool maskZeroexpcomp) { char buffer[256]; if (maskZeroexpcomp) { if (expcomp != 0.0) { - sprintf (buffer, "%0.2f", expcomp); + sprintf(buffer, "%0.2f", expcomp); return buffer; } else { return ""; } } else { - sprintf (buffer, "%0.2f", expcomp); + sprintf(buffer, "%0.2f", expcomp); return buffer; } } -double FramesMetaData::shutterFromString (std::string s) +double FramesMetaData::shutterFromString(std::string s) { - size_t i = s.find_first_of ('/'); + size_t i = s.find_first_of('/'); if (i == std::string::npos) { - return atof (s.c_str()); + return atof(s.c_str()); } else { - return atof (s.substr(0, i).c_str()) / atof (s.substr(i + 1).c_str()); + return atof(s.substr(0, i).c_str()) / atof(s.substr(i + 1).c_str()); } } -double FramesMetaData::apertureFromString (std::string s) +double FramesMetaData::apertureFromString(std::string s) { - return atof (s.c_str()); + return atof(s.c_str()); } extern "C" { @@ -1013,7 +1035,7 @@ extern "C" { }; IptcData * - iptc_data_new_from_jpeg_file (FILE *infile) + iptc_data_new_from_jpeg_file(FILE *infile) { IptcData *d; unsigned char * buf; @@ -1025,61 +1047,61 @@ extern "C" { return nullptr; } - d = iptc_data_new (); + d = iptc_data_new(); if (!d) { return nullptr; } - buf = (unsigned char*)iptc_mem_alloc (d->priv->mem, buf_len); + buf = (unsigned char*)iptc_mem_alloc(d->priv->mem, buf_len); if (!buf) { - iptc_data_unref (d); + iptc_data_unref(d); return nullptr; } - len = iptc_jpeg_read_ps3 (infile, buf, buf_len); + len = iptc_jpeg_read_ps3(infile, buf, buf_len); if (len <= 0) { goto failure; } - offset = iptc_jpeg_ps3_find_iptc (buf, len, &iptc_len); + offset = iptc_jpeg_ps3_find_iptc(buf, len, &iptc_len); if (offset <= 0) { goto failure; } - iptc_data_load (d, buf + offset, iptc_len); + iptc_data_load(d, buf + offset, iptc_len); - iptc_mem_free (d->priv->mem, buf); + iptc_mem_free(d->priv->mem, buf); return d; failure: - iptc_mem_free (d->priv->mem, buf); - iptc_data_unref (d); + iptc_mem_free(d->priv->mem, buf); + iptc_data_unref(d); return nullptr; } } -FramesData::FramesData (const Glib::ustring& fname, std::unique_ptr rml, bool firstFrameOnly) : - iptc(nullptr), dcrawFrameCount (0) +FramesData::FramesData(const Glib::ustring& fname, std::unique_ptr rml, bool firstFrameOnly) : + iptc(nullptr), dcrawFrameCount(0) { if (rml && (rml->exifBase >= 0 || rml->ciffBase >= 0)) { - FILE* f = g_fopen (fname.c_str (), "rb"); + FILE* f = g_fopen(fname.c_str(), "rb"); if (f) { const bool has_rml_exif_base = rml->exifBase >= 0; - rtexif::ExifManager exifManager (f, std::move(rml), firstFrameOnly); + rtexif::ExifManager exifManager(f, std::move(rml), firstFrameOnly); if (has_rml_exif_base) { if (exifManager.f && exifManager.rml) { if (exifManager.rml->exifBase >= 0) { - exifManager.parseRaw (); + exifManager.parseRaw(); } else if (exifManager.rml->ciffBase >= 0) { - exifManager.parseCIFF (); + exifManager.parseCIFF(); } } @@ -1092,39 +1114,45 @@ FramesData::FramesData (const Glib::ustring& fname, std::unique_ptrgetTag(0x83BB); if (t && !iptc) { - iptc = iptc_data_new_from_data ((unsigned char*)t->getValue (), (unsigned)t->getValueSize ()); + iptc = iptc_data_new_from_data((unsigned char*)t->getValue(), (unsigned)t->getValueSize()); break; } } } - fclose (f); + + fclose(f); } } else if (hasJpegExtension(fname)) { - FILE* f = g_fopen (fname.c_str (), "rb"); + FILE* f = g_fopen(fname.c_str(), "rb"); if (f) { - rtexif::ExifManager exifManager (f, std::move(rml), true); + rtexif::ExifManager exifManager(f, std::move(rml), true); + if (exifManager.f) { - exifManager.parseJPEG (); + exifManager.parseJPEG(); roots = exifManager.roots; + for (auto currFrame : exifManager.frames) { FrameData* fd = new FrameData(currFrame, currFrame->getRoot(), roots.at(0)); frames.push_back(fd); } - rewind (exifManager.f); // Not sure this is necessary - iptc = iptc_data_new_from_jpeg_file (exifManager.f); + + rewind(exifManager.f); // Not sure this is necessary + iptc = iptc_data_new_from_jpeg_file(exifManager.f); } - fclose (f); + + fclose(f); } } else if (hasTiffExtension(fname)) { - FILE* f = g_fopen (fname.c_str (), "rb"); + FILE* f = g_fopen(fname.c_str(), "rb"); if (f) { - rtexif::ExifManager exifManager (f, std::move(rml), firstFrameOnly); + rtexif::ExifManager exifManager(f, std::move(rml), firstFrameOnly); exifManager.parseTIFF(); roots = exifManager.roots; @@ -1135,26 +1163,28 @@ FramesData::FramesData (const Glib::ustring& fname, std::unique_ptrgetTag(0x83BB); if (t && !iptc) { - iptc = iptc_data_new_from_data ((unsigned char*)t->getValue (), (unsigned)t->getValueSize ()); + iptc = iptc_data_new_from_data((unsigned char*)t->getValue(), (unsigned)t->getValueSize()); break; } } - fclose (f); + + fclose(f); } } } -FramesData::~FramesData () +FramesData::~FramesData() { for (auto currRoot : roots) { delete currRoot; } if (iptc) { - iptc_data_free (iptc); + iptc_data_free(iptc); } } diff --git a/rtengine/improcfun.cc b/rtengine/improcfun.cc index 18b1b7a5c..3cb29cae7 100644 --- a/rtengine/improcfun.cc +++ b/rtengine/improcfun.cc @@ -48,11 +48,13 @@ #undef CLIPD #define CLIPD(a) ((a)>0.0f?((a)<1.0f?(a):1.0f):0.0f) -namespace { +namespace +{ using namespace rtengine; // begin of helper function for rgbProc() -void shadowToneCurve(const LUTf &shtonecurve, float *rtemp, float *gtemp, float *btemp, int istart, int tH, int jstart, int tW, int tileSize) { +void shadowToneCurve(const LUTf &shtonecurve, float *rtemp, float *gtemp, float *btemp, int istart, int tH, int jstart, int tW, int tileSize) +{ #ifdef __SSE2__ vfloat cr = F2V(0.299f); @@ -63,7 +65,8 @@ void shadowToneCurve(const LUTf &shtonecurve, float *rtemp, float *gtemp, float for (int i = istart, ti = 0; i < tH; i++, ti++) { int j = jstart, tj = 0; #ifdef __SSE2__ - for (; j < tW - 3; j+=4, tj+=4) { + + for (; j < tW - 3; j += 4, tj += 4) { vfloat rv = LVF(rtemp[ti * tileSize + tj]); vfloat gv = LVF(gtemp[ti * tileSize + tj]); @@ -76,7 +79,9 @@ void shadowToneCurve(const LUTf &shtonecurve, float *rtemp, float *gtemp, float STVF(gtemp[ti * tileSize + tj], gv * tonefactorv); STVF(btemp[ti * tileSize + tj], bv * tonefactorv); } + #endif + for (; j < tW; j++, tj++) { float r = rtemp[ti * tileSize + tj]; @@ -93,7 +98,8 @@ void shadowToneCurve(const LUTf &shtonecurve, float *rtemp, float *gtemp, float } } -void highlightToneCurve(const LUTf &hltonecurve, float *rtemp, float *gtemp, float *btemp, int istart, int tH, int jstart, int tW, int tileSize, float exp_scale, float comp, float hlrange) { +void highlightToneCurve(const LUTf &hltonecurve, float *rtemp, float *gtemp, float *btemp, int istart, int tH, int jstart, int tW, int tileSize, float exp_scale, float comp, float hlrange) +{ #ifdef __SSE2__ vfloat threev = F2V(3.f); @@ -103,7 +109,8 @@ void highlightToneCurve(const LUTf &hltonecurve, float *rtemp, float *gtemp, flo for (int i = istart, ti = 0; i < tH; i++, ti++) { int j = jstart, tj = 0; #ifdef __SSE2__ - for (; j < tW - 3; j+=4, tj+=4) { + + for (; j < tW - 3; j += 4, tj += 4) { vfloat rv = LVF(rtemp[ti * tileSize + tj]); vfloat gv = LVF(gtemp[ti * tileSize + tj]); @@ -112,14 +119,15 @@ void highlightToneCurve(const LUTf &hltonecurve, float *rtemp, float *gtemp, flo //TODO: proper treatment of out-of-gamut colors //float tonefactor = hltonecurve[(0.299f*r+0.587f*g+0.114f*b)]; vmask maxMask = vmaskf_ge(vmaxf(rv, vmaxf(gv, bv)), maxvalfv); - if(_mm_movemask_ps((vfloat)maxMask)) { + + if (_mm_movemask_ps((vfloat)maxMask)) { for (int k = 0; k < 4; ++k) { float r = rtemp[ti * tileSize + tj + k]; float g = gtemp[ti * tileSize + tj + k]; float b = btemp[ti * tileSize + tj + k]; - float tonefactor = ((r < MAXVALF ? hltonecurve[r] : CurveFactory::hlcurve (exp_scale, comp, hlrange, r) ) + - (g < MAXVALF ? hltonecurve[g] : CurveFactory::hlcurve (exp_scale, comp, hlrange, g) ) + - (b < MAXVALF ? hltonecurve[b] : CurveFactory::hlcurve (exp_scale, comp, hlrange, b) ) ) / 3.0; + float tonefactor = ((r < MAXVALF ? hltonecurve[r] : CurveFactory::hlcurve(exp_scale, comp, hlrange, r)) + + (g < MAXVALF ? hltonecurve[g] : CurveFactory::hlcurve(exp_scale, comp, hlrange, g)) + + (b < MAXVALF ? hltonecurve[b] : CurveFactory::hlcurve(exp_scale, comp, hlrange, b))) / 3.0; // note: tonefactor includes exposure scaling, that is here exposure slider and highlight compression takes place rtemp[ti * tileSize + tj + k] = r * tonefactor; @@ -134,7 +142,9 @@ void highlightToneCurve(const LUTf &hltonecurve, float *rtemp, float *gtemp, flo STVF(btemp[ti * tileSize + tj], bv * tonefactorv); } } + #endif + for (; j < tW; j++, tj++) { float r = rtemp[ti * tileSize + tj]; @@ -143,9 +153,9 @@ void highlightToneCurve(const LUTf &hltonecurve, float *rtemp, float *gtemp, flo //TODO: proper treatment of out-of-gamut colors //float tonefactor = hltonecurve[(0.299f*r+0.587f*g+0.114f*b)]; - float tonefactor = ((r < MAXVALF ? hltonecurve[r] : CurveFactory::hlcurve (exp_scale, comp, hlrange, r) ) + - (g < MAXVALF ? hltonecurve[g] : CurveFactory::hlcurve (exp_scale, comp, hlrange, g) ) + - (b < MAXVALF ? hltonecurve[b] : CurveFactory::hlcurve (exp_scale, comp, hlrange, b) ) ) / 3.0; + float tonefactor = ((r < MAXVALF ? hltonecurve[r] : CurveFactory::hlcurve(exp_scale, comp, hlrange, r)) + + (g < MAXVALF ? hltonecurve[g] : CurveFactory::hlcurve(exp_scale, comp, hlrange, g)) + + (b < MAXVALF ? hltonecurve[b] : CurveFactory::hlcurve(exp_scale, comp, hlrange, b))) / 3.0; // note: tonefactor includes exposure scaling, that is here exposure slider and highlight compression takes place rtemp[ti * tileSize + tj] = r * tonefactor; @@ -155,30 +165,36 @@ void highlightToneCurve(const LUTf &hltonecurve, float *rtemp, float *gtemp, flo } } -void proPhotoBlue(float *rtemp, float *gtemp, float *btemp, int istart, int tH, int jstart, int tW, int tileSize) { +void proPhotoBlue(float *rtemp, float *gtemp, float *btemp, int istart, int tH, int jstart, int tW, int tileSize) +{ // this is a hack to avoid the blue=>black bug (Issue 2141) for (int i = istart, ti = 0; i < tH; i++, ti++) { int j = jstart, tj = 0; #ifdef __SSE2__ - for (; j < tW - 3; j+=4, tj+=4) { + + for (; j < tW - 3; j += 4, tj += 4) { vfloat rv = LVF(rtemp[ti * tileSize + tj]); vfloat gv = LVF(gtemp[ti * tileSize + tj]); vmask zeromask = vorm(vmaskf_eq(rv, ZEROV), vmaskf_eq(gv, ZEROV)); - if(_mm_movemask_ps((vfloat)zeromask)) { + + if (_mm_movemask_ps((vfloat)zeromask)) { for (int k = 0; k < 4; ++k) { float r = rtemp[ti * tileSize + tj + k]; float g = gtemp[ti * tileSize + tj + k]; + if (r == 0.0f || g == 0.0f) { float b = btemp[ti * tileSize + tj + k]; 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 * tileSize + tj + k], gtemp[ti * tileSize + tj + k], btemp[ti * tileSize + tj + k]); + Color::hsv2rgb(h, s, v, rtemp[ti * tileSize + tj + k], gtemp[ti * tileSize + tj + k], btemp[ti * tileSize + tj + k]); } } } } + #endif + for (; j < tW; j++, tj++) { float r = rtemp[ti * tileSize + tj]; float g = gtemp[ti * tileSize + tj]; @@ -186,77 +202,79 @@ void proPhotoBlue(float *rtemp, float *gtemp, float *btemp, int istart, int tH, if (r == 0.0f || g == 0.0f) { float b = btemp[ti * tileSize + 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 * tileSize + tj], gtemp[ti * tileSize + tj], btemp[ti * tileSize + tj]); + Color::hsv2rgb(h, s, v, rtemp[ti * tileSize + tj], gtemp[ti * tileSize + tj], btemp[ti * tileSize + tj]); } } } } -void customToneCurve(const ToneCurve &customToneCurve, ToneCurveParams::TcMode curveMode, float *rtemp, float *gtemp, float *btemp, int istart, int tH, int jstart, int tW, int tileSize, PerceptualToneCurveState ptcApplyState) { +void customToneCurve(const ToneCurve &customToneCurve, ToneCurveParams::TcMode curveMode, float *rtemp, float *gtemp, float *btemp, int istart, int tH, int jstart, int tW, int tileSize, PerceptualToneCurveState ptcApplyState) +{ if (curveMode == ToneCurveParams::TcMode::STD) { // Standard for (int i = istart, ti = 0; i < tH; i++, ti++) { - const StandardToneCurve& userToneCurve = static_cast (customToneCurve); - userToneCurve.BatchApply ( - 0, tW - jstart, - &rtemp[ti * tileSize], >emp[ti * tileSize], &btemp[ti * tileSize]); + const StandardToneCurve& userToneCurve = static_cast(customToneCurve); + userToneCurve.BatchApply( + 0, tW - jstart, + &rtemp[ti * tileSize], >emp[ti * tileSize], &btemp[ti * tileSize]); } } else if (curveMode == ToneCurveParams::TcMode::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 (customToneCurve); - userToneCurve.Apply (rtemp[ti * tileSize + tj], gtemp[ti * tileSize + tj], btemp[ti * tileSize + tj]); + const AdobeToneCurve& userToneCurve = static_cast(customToneCurve); + userToneCurve.Apply(rtemp[ti * tileSize + tj], gtemp[ti * tileSize + tj], btemp[ti * tileSize + tj]); } } } else if (curveMode == ToneCurveParams::TcMode::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 (customToneCurve); + const SatAndValueBlendingToneCurve& userToneCurve = static_cast(customToneCurve); rtemp[ti * tileSize + tj] = CLIP (rtemp[ti * tileSize + tj]); gtemp[ti * tileSize + tj] = CLIP (gtemp[ti * tileSize + tj]); btemp[ti * tileSize + tj] = CLIP (btemp[ti * tileSize + tj]); - userToneCurve.Apply (rtemp[ti * tileSize + tj], gtemp[ti * tileSize + tj], btemp[ti * tileSize + tj]); + userToneCurve.Apply(rtemp[ti * tileSize + tj], gtemp[ti * tileSize + tj], btemp[ti * tileSize + tj]); } } } else if (curveMode == ToneCurveParams::TcMode::WEIGHTEDSTD) { // apply the curve to the rgb channels, weighted - const WeightedStdToneCurve& userToneCurve = static_cast (customToneCurve); + const WeightedStdToneCurve& userToneCurve = static_cast(customToneCurve); for (int i = istart, ti = 0; i < tH; i++, ti++) { for (int j = jstart, tj = 0; j < tW; j++, tj++) { rtemp[ti * tileSize + tj] = CLIP (rtemp[ti * tileSize + tj]); gtemp[ti * tileSize + tj] = CLIP (gtemp[ti * tileSize + tj]); btemp[ti * tileSize + tj] = CLIP (btemp[ti * tileSize + tj]); - userToneCurve.Apply (rtemp[ti * tileSize + tj], gtemp[ti * tileSize + tj], btemp[ti * tileSize + tj]); + userToneCurve.Apply(rtemp[ti * tileSize + tj], gtemp[ti * tileSize + tj], btemp[ti * tileSize + tj]); } } } else if (curveMode == ToneCurveParams::TcMode::LUMINANCE) { // apply the curve to the luminance channel - const LuminanceToneCurve& userToneCurve = static_cast (customToneCurve); + const LuminanceToneCurve& userToneCurve = static_cast(customToneCurve); for (int i = istart, ti = 0; i < tH; i++, ti++) { for (int j = jstart, tj = 0; j < tW; j++, tj++) { rtemp[ti * tileSize + tj] = CLIP (rtemp[ti * tileSize + tj]); gtemp[ti * tileSize + tj] = CLIP (gtemp[ti * tileSize + tj]); btemp[ti * tileSize + tj] = CLIP (btemp[ti * tileSize + tj]); - userToneCurve.Apply (rtemp[ti * tileSize + tj], gtemp[ti * tileSize + tj], btemp[ti * tileSize + tj]); + userToneCurve.Apply(rtemp[ti * tileSize + tj], gtemp[ti * tileSize + tj], btemp[ti * tileSize + tj]); } } } else if (curveMode == ToneCurveParams::TcMode::PERCEPTUAL) { // apply curve while keeping color appearance constant - const PerceptualToneCurve& userToneCurve = static_cast (customToneCurve); + const PerceptualToneCurve& userToneCurve = static_cast(customToneCurve); for (int i = istart, ti = 0; i < tH; i++, ti++) { for (int j = jstart, tj = 0; j < tW; j++, tj++) { rtemp[ti * tileSize + tj] = CLIP (rtemp[ti * tileSize + tj]); gtemp[ti * tileSize + tj] = CLIP (gtemp[ti * tileSize + tj]); btemp[ti * tileSize + tj] = CLIP (btemp[ti * tileSize + tj]); - userToneCurve.Apply (rtemp[ti * tileSize + tj], gtemp[ti * tileSize + tj], btemp[ti * tileSize + tj], ptcApplyState); + userToneCurve.Apply(rtemp[ti * tileSize + tj], gtemp[ti * tileSize + tj], btemp[ti * tileSize + tj], ptcApplyState); } } } } -void fillEditFloat(float *editIFloatTmpR, float *editIFloatTmpG, float *editIFloatTmpB, float *rtemp, float *gtemp, float *btemp, int istart, int tH, int jstart, int tW, int tileSize) { +void fillEditFloat(float *editIFloatTmpR, float *editIFloatTmpG, float *editIFloatTmpB, float *rtemp, float *gtemp, float *btemp, int istart, int tH, int jstart, int tW, int tileSize) +{ for (int i = istart, ti = 0; i < tH; i++, ti++) { for (int j = jstart, tj = 0; j < tW; j++, tj++) { editIFloatTmpR[ti * tileSize + tj] = Color::gamma2curve[rtemp[ti * tileSize + tj]] / 65535.f; @@ -1919,7 +1937,7 @@ void ImProcFunctions::ciecam_02float(CieImage* ncie, float adap, int pW, int pwb // level of adaptation const float deg = (params->colorappearance.degree) / 100.0f; const float pilot = params->colorappearance.autodegree ? 2.0f : deg; - + const float degout = (params->colorappearance.degreeout) / 100.0f; const float pilotout = params->colorappearance.autodegreeout ? 2.0f : degout; @@ -3378,7 +3396,7 @@ void ImProcFunctions::rgbProc(Imagefloat* working, LabImage* lab, PipetteBuffer }; bool mixchannels = params->chmixer.enabled && - (params->chmixer.red[0] != 100 || params->chmixer.red[1] != 0 || params->chmixer.red[2] != 0 || + (params->chmixer.red[0] != 100 || params->chmixer.red[1] != 0 || params->chmixer.red[2] != 0 || params->chmixer.green[0] != 0 || params->chmixer.green[1] != 100 || params->chmixer.green[2] != 0 || params->chmixer.blue[0] != 0 || params->chmixer.blue[1] != 0 || params->chmixer.blue[2] != 100); @@ -3387,10 +3405,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 = params->hsvequalizer.enabled && hCurveType > FCT_Linear; bool sCurveEnabled = params->hsvequalizer.enabled && sCurveType > FCT_Linear; bool vCurveEnabled = params->hsvequalizer.enabled && vCurveType > FCT_Linear; @@ -3642,7 +3660,7 @@ void ImProcFunctions::rgbProc(Imagefloat* working, LabImage* lab, PipetteBuffer #pragma omp parallel if (multiThread) #endif { - size_t perChannelSizeBytes = padToAlignment(sizeof (float) * TS * TS + 4 * 64); + size_t perChannelSizeBytes = padToAlignment(sizeof(float) * TS * TS + 4 * 64); AlignedBuffer buffer(3 * perChannelSizeBytes); char *editIFloatBuffer = nullptr; char *editWhateverBuffer = nullptr; @@ -3661,8 +3679,8 @@ 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); - char *data = (char*) ( ( uintptr_t (editIFloatBuffer) + uintptr_t (63)) / 64 * 64); + editIFloatBuffer = (char *) malloc(3 * sizeof(float) * TS * TS + 20 * 64 + 63); + char *data = (char*)((uintptr_t (editIFloatBuffer) + uintptr_t (63)) / 64 * 64); editIFloatTmpR = (float (*))data; editIFloatTmpG = (float (*))((char*)editIFloatTmpR + sizeof(float) * TS * TS + 4 * 64); @@ -3670,8 +3688,8 @@ void ImProcFunctions::rgbProc(Imagefloat* working, LabImage* lab, PipetteBuffer } if (editWhatever) { - editWhateverBuffer = (char *) malloc (sizeof (float) * TS * TS + 20 * 64 + 63); - char *data = (char*) ( ( uintptr_t (editWhateverBuffer) + uintptr_t (63)) / 64 * 64); + editWhateverBuffer = (char *) malloc(sizeof(float) * TS * TS + 20 * 64 + 63); + char *data = (char*)((uintptr_t (editWhateverBuffer) + uintptr_t (63)) / 64 * 64); editWhateverTmp = (float (*))data; } @@ -3790,13 +3808,16 @@ void ImProcFunctions::rgbProc(Imagefloat* working, LabImage* lab, PipetteBuffer for (int i = istart, ti = 0; i < tH; i++, ti++) { int j = jstart, tj = 0; #ifdef __SSE2__ - for (; j < tW - 3; j+=4, tj+=4) { + + for (; j < tW - 3; j += 4, tj += 4) { //brightness/contrast STVF(rtemp[ti * TS + tj], tonecurve(LVF(rtemp[ti * TS + tj]))); STVF(gtemp[ti * TS + tj], tonecurve(LVF(gtemp[ti * TS + tj]))); STVF(btemp[ti * TS + tj], tonecurve(LVF(btemp[ti * TS + tj]))); } + #endif + for (; j < tW; j++, tj++) { //brightness/contrast rtemp[ti * TS + tj] = tonecurve[rtemp[ti * TS + tj]]; @@ -4534,15 +4555,16 @@ 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]; } } } } + // ready, fill lab for (int i = istart, ti = 0; i < tH; i++, ti++) { Color::RGB2Lab(&rtemp[ti * TS], >emp[ti * TS], &btemp[ti * TS], &(lab->L[i][jstart]), &(lab->a[i][jstart]), &(lab->b[i][jstart]), toxyz, tW - jstart); @@ -5607,7 +5629,7 @@ SSEFUNCTION void ImProcFunctions::chromiLuminanceCurve(PipetteBuffer *pipetteBuf if (!params->labCurve.enabled) { return; } - + int W = lold->W; int H = lold->H; // lhskcurve.dump("lh_curve"); diff --git a/rtengine/iplocallab.cc b/rtengine/iplocallab.cc index bea843b7e..5354b572e 100644 --- a/rtengine/iplocallab.cc +++ b/rtengine/iplocallab.cc @@ -3987,7 +3987,7 @@ void ImProcFunctions::InverseReti_Local(const struct local_params & lp, LabImage if (lp.shapmet == 0) { calcTransition(lox, loy, ach, lp, zone, localFactor); } else if (lp.shapmet == 1) { - calcTransition(lox, loy, ach, lp, zone, localFactor); + calcTransitionrect(lox, loy, ach, lp, zone, localFactor); } // calcTransition(lox, loy, ach, lp, zone, localFactor); @@ -4493,7 +4493,7 @@ void ImProcFunctions::InverseBlurNoise_Local(const struct local_params & lp, Lab if (lp.shapmet == 0) { calcTransition(lox, loy, ach, lp, zone, localFactor); } else if (lp.shapmet == 1) { - calcTransition(lox, loy, ach, lp, zone, localFactor); + calcTransitionrect(lox, loy, ach, lp, zone, localFactor); } // calcTransition(lox, loy, ach, lp, zone, localFactor); @@ -5057,7 +5057,7 @@ void ImProcFunctions::InverseContrast_Local(float ave, struct local_contra & lco if (lp.shapmet == 0) { calcTransition(lox, loy, ach, lp, zone, localFactor); } else if (lp.shapmet == 1) { - calcTransition(lox, loy, ach, lp, zone, localFactor); + calcTransitionrect(lox, loy, ach, lp, zone, localFactor); } // calcTransition(lox, loy, ach, lp, zone, localFactor); @@ -5365,7 +5365,7 @@ void ImProcFunctions::InverseSharp_Local(float **loctemp, const float hueplus, c if (lp.shapmet == 0) { calcTransition(lox, loy, ach, lp, zone, localFactor); } else if (lp.shapmet == 1) { - calcTransition(lox, loy, ach, lp, zone, localFactor); + calcTransitionrect(lox, loy, ach, lp, zone, localFactor); } // calcTransition(lox, loy, ach, lp, zone, localFactor); @@ -7607,7 +7607,7 @@ void ImProcFunctions::InverseColorLight_Local(const struct local_params & lp, La if (lp.shapmet == 0) { calcTransition(lox, loy, ach, lp, zone, localFactor); } else if (lp.shapmet == 1) { - calcTransition(lox, loy, ach, lp, zone, localFactor);//rect not good + calcTransitionrect(lox, loy, ach, lp, zone, localFactor);//rect not good } // calcTransition(lox, loy, ach, lp, zone, localFactor); @@ -12023,7 +12023,7 @@ void ImProcFunctions::Lab_Local(int call, float** shbuffer, LabImage * original, tmpl = new LabImage(Wd, Hd); - } /* else { + } else { #ifdef _OPENMP #pragma omp parallel for schedule(dynamic,16) @@ -12035,11 +12035,11 @@ void ImProcFunctions::Lab_Local(int call, float** shbuffer, LabImage * original, orig1[ir][jr] = transformed->L[ir][jr]; } - tmpl = new LabImage (transformed->W, transformed->H); + tmpl = new LabImage(transformed->W, transformed->H); } -*/ + float minCD, maxCD, mini, maxi, Tmean, Tsigma, Tmin, Tmax; ImProcFunctions::MSRLocal(orig, tmpl->L, orig1, Wd, Hd, params->locallab, sk, locRETgainCcurve, 0, 4, 0.8f, minCD, maxCD, mini, maxi, Tmean, Tsigma, Tmin, Tmax); #ifdef _OPENMP @@ -12093,7 +12093,7 @@ void ImProcFunctions::Lab_Local(int call, float** shbuffer, LabImage * original, orig1[ir][jr] = sqrt(SQR(bufreti->a[ir][jr]) + SQR(bufreti->b[ir][jr])); } - } /* else { + } else { #ifdef _OPENMP #pragma omp parallel for schedule(dynamic,16) @@ -12101,11 +12101,11 @@ void ImProcFunctions::Lab_Local(int call, float** shbuffer, LabImage * original, for (int ir = 0; ir < GH; ir += 1) for (int jr = 0; jr < GW; jr += 1) { - orig[ir][jr] = sqrt (SQR (original->a[ir][jr]) + SQR (original->b[ir][jr])); - orig1[ir][jr] = sqrt (SQR (transformed->a[ir][jr]) + SQR (transformed->b[ir][jr])); + orig[ir][jr] = sqrt(SQR(original->a[ir][jr]) + SQR(original->b[ir][jr])); + orig1[ir][jr] = sqrt(SQR(transformed->a[ir][jr]) + SQR(transformed->b[ir][jr])); } } -*/ + ImProcFunctions::MSRLocal(orig, tmpl->L, orig1, Wd, Hd, params->locallab, sk, locRETgainCcurve, 1, 4, 0.8f, minCD, maxCD, mini, maxi, Tmean, Tsigma, Tmin, Tmax); if (!lp.invret && call <= 3) { @@ -12146,7 +12146,7 @@ void ImProcFunctions::Lab_Local(int call, float** shbuffer, LabImage * original, // printf ("minch=%2.2f maxch=%2.2f", minch, maxch); - } /* else { + } else { #ifdef _OPENMP #pragma omp parallel for schedule(dynamic,16) @@ -12163,7 +12163,7 @@ void ImProcFunctions::Lab_Local(int call, float** shbuffer, LabImage * original, } } -*/ + if (!lp.invret) { diff --git a/rtengine/ipretinex.cc b/rtengine/ipretinex.cc index fcc370a54..8ff1357f3 100644 --- a/rtengine/ipretinex.cc +++ b/rtengine/ipretinex.cc @@ -52,10 +52,10 @@ namespace { -void retinex_scales ( float* scales, int nscales, int mode, int s, float high) +void retinex_scales(float* scales, int nscales, int mode, int s, float high) { - if ( nscales == 1 ) { - scales[0] = (float)s / 2.f; + if (nscales == 1) { + scales[0] = (float)s / 2.f; } else if (nscales == 2) { scales[1] = (float) s / 2.f; scales[0] = (float) s; @@ -63,32 +63,32 @@ void retinex_scales ( float* scales, int nscales, int mode, int s, float high) float size_step = (float) s / (float) nscales; if (mode == 0) { - for (int i = 0; i < nscales; ++i ) { + for (int i = 0; i < nscales; ++i) { scales[nscales - i - 1] = 2.0f + (float)i * size_step; } } else if (mode == 1) { - size_step = (float)log (s - 2.0f) / (float) nscales; + size_step = (float)log(s - 2.0f) / (float) nscales; - for (int i = 0; i < nscales; ++i ) { - scales[nscales - i - 1] = 2.0f + (float)pow (10.f, (i * size_step) / log (10.f)); + for (int i = 0; i < nscales; ++i) { + scales[nscales - i - 1] = 2.0f + (float)pow(10.f, (i * size_step) / log(10.f)); } } else if (mode == 2) { - size_step = (float) log (s - 2.0f) / (float) nscales; + size_step = (float) log(s - 2.0f) / (float) nscales; - for ( int i = 0; i < nscales; ++i ) { - scales[i] = s - (float)pow (10.f, (i * size_step) / log (10.f)); + for (int i = 0; i < nscales; ++i) { + scales[i] = s - (float)pow(10.f, (i * size_step) / log(10.f)); } } else if (mode == 3) { - size_step = (float) log (s - 2.0f) / (float) nscales; + size_step = (float) log(s - 2.0f) / (float) nscales; - for ( int i = 0; i < nscales; ++i ) { - scales[i] = high * s - (float)pow (10.f, (i * size_step) / log (10.f)); + for (int i = 0; i < nscales; ++i) { + scales[i] = high * s - (float)pow(10.f, (i * size_step) / log(10.f)); } } } } -void mean_stddv2 ( float **dst, float &mean, float &stddv, int W_L, int H_L, float &maxtr, float &mintr) +void mean_stddv2(float **dst, float &mean, float &stddv, int W_L, int H_L, float &maxtr, float &mintr) { // summation using double precision to avoid too large summation error for large pictures double vsquared = 0.f; @@ -104,7 +104,7 @@ void mean_stddv2 ( float **dst, float &mean, float &stddv, int W_L, int H_L, flo #pragma omp for reduction(+:sum,vsquared) nowait // this leads to differences, but parallel summation is more accurate #endif - for (int i = 0; i < H_L; i++ ) + for (int i = 0; i < H_L; i++) for (int j = 0; j < W_L; j++) { sum += dst[i][j]; vsquared += (dst[i][j] * dst[i][j]); @@ -122,10 +122,10 @@ void mean_stddv2 ( float **dst, float &mean, float &stddv, int W_L, int H_L, flo } } - mean = sum / (double) (W_L * H_L); + mean = sum / (double)(W_L * H_L); vsquared /= (double) W_L * H_L; - stddv = ( vsquared - (mean * mean) ); - stddv = (float)sqrt (stddv); + stddv = (vsquared - (mean * mean)); + stddv = (float)sqrt(stddv); } } @@ -148,13 +148,13 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e int iter = deh.iter; int gradient = deh.scal; int scal = 3;//disabled scal - int nei = (int) (2.8f * deh.neigh); //def = 220 + int nei = (int)(2.8f * deh.neigh); //def = 220 float vart = (float)deh.vart / 100.f;//variance float gradvart = (float)deh.grad; float gradstr = (float)deh.grads; float strength = (float) deh.str / 100.f; // Blend with original L channel data float limD = (float) deh.limd; - limD = pow (limD, 1.7f); //about 2500 enough + limD = pow(limD, 1.7f); //about 2500 enough limD *= useHslLin ? 10.f : 1.f; float ilimD = 1.f / limD; float hig = ((float) deh.highl) / 100.f; @@ -169,7 +169,7 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e constexpr float elogt = 2.71828f; bool lhutili = false; - FlatCurve* shcurve = new FlatCurve (deh.lhcurve); //curve L=f(H) + FlatCurve* shcurve = new FlatCurve(deh.lhcurve); //curve L=f(H) if (!shcurve || shcurve->isIdentity()) { if (shcurve) { @@ -287,7 +287,7 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e } } - scal = round (sc); + scal = round(sc); float ks = 1.f; if (gradstr != 0) { @@ -323,7 +323,7 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e constexpr auto maxRetinexScales = 8; float RetinexScales[maxRetinexScales]; - retinex_scales ( RetinexScales, scal, moderetinex, nei / grad, high ); + retinex_scales(RetinexScales, scal, moderetinex, nei / grad, high); float *src[H_L] ALIGNED16; float *srcBuffer = new float[H_L * W_L]; @@ -386,29 +386,29 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e } } - const float logBetaGain = xlogf (16384.f); + const float logBetaGain = xlogf(16384.f); float pond = logBetaGain / (float) scal; if (!useHslLin) { - pond /= log (elogt); + pond /= log(elogt); } - auto shmap = ((mapmet == 2 || mapmet == 3 || mapmet == 4) && it == 1) ? new SHMap (W_L, H_L, true) : nullptr; + auto shmap = ((mapmet == 2 || mapmet == 3 || mapmet == 4) && it == 1) ? new SHMap(W_L, H_L, true) : nullptr; float *buffer = new float[W_L * H_L];; - for ( int scale = scal - 1; scale >= 0; scale-- ) { + for (int scale = scal - 1; scale >= 0; scale--) { #ifdef _OPENMP #pragma omp parallel #endif { if (scale == scal - 1) { - gaussianBlur (src, out, W_L, H_L, RetinexScales[scale], buffer); - } else { // reuse result of last iteration + gaussianBlur(src, out, W_L, H_L, RetinexScales[scale], buffer); + } else // reuse result of last iteration + { // out was modified in last iteration => restore it - if ((((mapmet == 2 && scale > 1) || mapmet == 3 || mapmet == 4) || (mapmet > 0 && mapcontlutili)) && it == 1) - { + if ((((mapmet == 2 && scale > 1) || mapmet == 3 || mapmet == 4) || (mapmet > 0 && mapcontlutili)) && it == 1) { #ifdef _OPENMP #pragma omp for #endif @@ -420,8 +420,9 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e } } - gaussianBlur (out, out, W_L, H_L, sqrtf (SQR (RetinexScales[scale]) - SQR (RetinexScales[scale + 1])), buffer); + gaussianBlur(out, out, W_L, H_L, sqrtf(SQR(RetinexScales[scale]) - SQR(RetinexScales[scale + 1])), buffer); } + if ((((mapmet == 2 && scale > 2) || mapmet == 3 || mapmet == 4) || (mapmet > 0 && mapcontlutili)) && it == 1 && scale > 0) { // out will be modified => store it for use in next iteration. We even don't need a new buffer because 'buffer' is free after gaussianBlur :) @@ -438,15 +439,15 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e } if (((mapmet == 2 && scale > 2) || mapmet == 3 || mapmet == 4) && it == 1) { - shmap->updateL (out, shradius, true, 1); + shmap->updateL(out, shradius, true, 1); h_th = shmap->max_f - deh.htonalwidth * (shmap->max_f - shmap->avg) / 100; s_th = deh.stonalwidth * (shmap->avg - shmap->min_f) / 100; } #ifdef __SSE2__ - vfloat pondv = F2V (pond); - vfloat limMinv = F2V (ilimdx); - vfloat limMaxv = F2V (limdx); + vfloat pondv = F2V(pond); + vfloat limMinv = F2V(ilimdx); + vfloat limMaxv = F2V(limdx); #endif @@ -504,11 +505,11 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e if (useHslLin) { for (; j < W_L - 3; j += 4) { - _mm_storeu_ps (&luminance[i][j], LVFU (luminance[i][j]) + pondv * (LIMV (LVFU (src[i][j]) / LVFU (out[i][j]), limMinv, limMaxv) )); + _mm_storeu_ps(&luminance[i][j], LVFU(luminance[i][j]) + pondv * (LIMV(LVFU(src[i][j]) / LVFU(out[i][j]), limMinv, limMaxv))); } } else { for (; j < W_L - 3; j += 4) { - _mm_storeu_ps (&luminance[i][j], LVFU (luminance[i][j]) + pondv * xlogf (LIMV (LVFU (src[i][j]) / LVFU (out[i][j]), limMinv, limMaxv) )); + _mm_storeu_ps(&luminance[i][j], LVFU(luminance[i][j]) + pondv * xlogf(LIMV(LVFU(src[i][j]) / LVFU(out[i][j]), limMinv, limMaxv))); } } @@ -516,11 +517,11 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e if (useHslLin) { for (; j < W_L; j++) { - luminance[i][j] += pond * (LIM (src[i][j] / out[i][j], ilimdx, limdx)); + luminance[i][j] += pond * (LIM(src[i][j] / out[i][j], ilimdx, limdx)); } } else { for (; j < W_L; j++) { - luminance[i][j] += pond * xlogf (LIM (src[i][j] / out[i][j], ilimdx, limdx)); // /logt ? + luminance[i][j] += pond * xlogf(LIM(src[i][j] / out[i][j], ilimdx, limdx)); // /logt ? } } } @@ -541,7 +542,7 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e float stddv = 0.f; // I call mean_stddv2 instead of mean_stddv ==> logBetaGain - mean_stddv2 ( luminance, mean, stddv, W_L, H_L, maxtr, mintr); + mean_stddv2(luminance, mean, stddv, W_L, H_L, maxtr, mintr); //printf("mean=%f std=%f delta=%f maxtr=%f mintr=%f\n", mean, stddv, delta, maxtr, mintr); //mean_stddv( luminance, mean, stddv, W_L, H_L, logBetaGain, maxtr, mintr); @@ -569,9 +570,9 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e #pragma omp for schedule(dynamic,16) #endif - for (int i = 0; i < H_L; i++ ) + for (int i = 0; i < H_L; i++) for (int j = 0; j < W_L; j++) { //for mintr to maxtr evalate absciss in function of original transmission - if (LIKELY (fabsf (luminance[i][j] - mean) < stddv)) { + if (LIKELY(fabsf(luminance[i][j] - mean) < stddv)) { absciss = asig * luminance[i][j] + bsig; } else if (luminance[i][j] >= mean) { absciss = amax * luminance[i][j] + bmax; @@ -606,7 +607,7 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e for (int i = borderL; i < hei - borderL; i++) { for (int j = borderL; j < wid - borderL; j++) { - tmL[i][j] = median (luminance[i][j], luminance[i - 1][j], luminance[i + 1][j], luminance[i][j + 1], luminance[i][j - 1], luminance[i - 1][j - 1], luminance[i - 1][j + 1], luminance[i + 1][j - 1], luminance[i + 1][j + 1]); //3x3 + tmL[i][j] = median(luminance[i][j], luminance[i - 1][j], luminance[i + 1][j], luminance[i][j + 1], luminance[i][j - 1], luminance[i - 1][j - 1], luminance[i - 1][j + 1], luminance[i + 1][j - 1], luminance[i + 1][j + 1]); //3x3 } } @@ -614,7 +615,7 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e #pragma omp parallel for #endif - for (int i = borderL; i < hei - borderL; i++ ) { + for (int i = borderL; i < hei - borderL; i++) { for (int j = borderL; j < wid - borderL; j++) { luminance[i][j] = tmL[i][j]; } @@ -626,7 +627,7 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e // I call mean_stddv2 instead of mean_stddv ==> logBetaGain //mean_stddv( luminance, mean, stddv, W_L, H_L, 1.f, maxtr, mintr); - mean_stddv2 ( luminance, mean, stddv, W_L, H_L, maxtr, mintr); + mean_stddv2(luminance, mean, stddv, W_L, H_L, maxtr, mintr); } @@ -647,7 +648,7 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e float delta = maxi - mini; //printf("maxi=%f mini=%f mean=%f std=%f delta=%f maxtr=%f mintr=%f\n", maxi, mini, mean, stddv, delta, maxtr, mintr); - if ( !delta ) { + if (!delta) { delta = 1.0f; } @@ -675,7 +676,7 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e stddv = 0.f; // I call mean_stddv2 instead of mean_stddv ==> logBetaGain - mean_stddv2 ( luminance, mean, stddv, W_L, H_L, maxtr, mintr); + mean_stddv2(luminance, mean, stddv, W_L, H_L, maxtr, mintr); float asig = 0.f, bsig = 0.f, amax = 0.f, bmax = 0.f, amin = 0.f, bmin = 0.f; if (dehagaintransmissionCurve && mean != 0.f && stddv != 0.f) { //if curve @@ -703,14 +704,14 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e #pragma omp for schedule(dynamic,16) nowait #endif - for ( int i = 0; i < H_L; i ++ ) + for (int i = 0; i < H_L; i ++) for (int j = 0; j < W_L; j++) { float gan; if (dehagaintransmissionCurve && mean != 0.f && stddv != 0.f) { float absciss; - if (LIKELY (fabsf (luminance[i][j] - mean) < stddv)) { + if (LIKELY(fabsf(luminance[i][j] - mean) < stddv)) { absciss = asig * luminance[i][j] + bsig; } else if (luminance[i][j] >= mean) { absciss = amax * luminance[i][j] + bmax; @@ -726,7 +727,7 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e gan = 0.5f; } - float cd = gan * cdfactor * ( luminance[i][j] ) + offse; + float cd = gan * cdfactor * (luminance[i][j]) + offse; cdmax = cd > cdmax ? cd : cdmax; cdmin = cd < cdmin ? cd : cdmin; @@ -739,9 +740,9 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e float valparam; if (useHsl || useHslLin) { - valparam = float ((shcurve->getVal (HH) - 0.5f)); + valparam = float ((shcurve->getVal(HH) - 0.5f)); } else { - valparam = float ((shcurve->getVal (Color::huelab_to_huehsv2 (HH)) - 0.5f)); + valparam = float ((shcurve->getVal(Color::huelab_to_huehsv2(HH)) - 0.5f)); } str *= (1.f + 2.f * valparam); @@ -753,7 +754,7 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e } if (viewmet == 0) { - luminance[i][j] = intp (str, clipretinex ( cd, 0.f, 32768.f ), originalLuminance[i][j]); + luminance[i][j] = intp(str, clipretinex(cd, 0.f, 32768.f), originalLuminance[i][j]); } else if (viewmet == 1) { luminance[i][j] = out[i][j]; } else if (viewmet == 4) { @@ -801,7 +802,7 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e } } -void ImProcFunctions::MSRLocal (float** luminance, float** templ, const float* const *originalLuminance, const int width, const int height, const LocallabParams &loc, const int skip, const LocretigainCurve &locRETgainCcurve, const int chrome, const int scall, const float krad, float &minCD, float &maxCD, float &mini, float &maxi, float &Tmean, float &Tsigma, float &Tmin, float &Tmax) +void ImProcFunctions::MSRLocal(float** luminance, float** templ, const float* const *originalLuminance, const int width, const int height, const LocallabParams &loc, const int skip, const LocretigainCurve &locRETgainCcurve, const int chrome, const int scall, const float krad, float &minCD, float &maxCD, float &mini, float &maxi, float &Tmean, float &Tsigma, float &Tmin, float &Tmax) { BENCHFUN bool py = true; @@ -813,24 +814,24 @@ void ImProcFunctions::MSRLocal (float** luminance, float** templ, const float* c // constexpr bool useHsl = false; //never used constexpr bool useHslLin = false;//never used const float offse = 0.f; //loc.offs; - const float chrT = (float) (loc.chrrt) / 100.f; + const float chrT = (float)(loc.chrrt) / 100.f; const int scal = scall;//3;//loc.scale;; const float vart = loc.vart / 100.f;//variance const float strength = loc.str / 100.f; // Blend with original L channel data float limD = 10.f;//(float) loc.limd; - limD = pow (limD, 1.7f); //about 2500 enough + limD = pow(limD, 1.7f); //about 2500 enough //limD *= useHslLin ? 10.f : 1.f; float ilimD = 1.f / limD; const float elogt = 2.71828f; //empirical skip evaluation : very difficult because quasi all parameters interfere //to test on several images - int nei = (int) (krad * loc.neigh); + int nei = (int)(krad * loc.neigh); if (skip >= 4) { - nei = (int) (0.1f * nei + 2.f); //not too bad + nei = (int)(0.1f * nei + 2.f); //not too bad } else if (skip > 1 && skip < 4) { - nei = (int) (0.3f * nei + 2.f); + nei = (int)(0.3f * nei + 2.f); } int moderetinex = 0; @@ -850,7 +851,7 @@ void ImProcFunctions::MSRLocal (float** luminance, float** templ, const float* c constexpr auto maxRetinexScales = 8; float RetinexScales[maxRetinexScales]; - retinex_scales ( RetinexScales, scal, moderetinex, nei, high ); + retinex_scales(RetinexScales, scal, moderetinex, nei, high); const int H_L = height; @@ -888,18 +889,18 @@ void ImProcFunctions::MSRLocal (float** luminance, float** templ, const float* c out[i] = &outBuffer[i * W_L]; } - const float logBetaGain = xlogf (16384.f); + const float logBetaGain = xlogf(16384.f); float pond = logBetaGain / (float) scal; if (!useHslLin) { - pond /= log (elogt); + pond /= log(elogt); } - auto shmap = mapmet == 4 ? new SHMap (W_L, H_L, true) : nullptr; + auto shmap = mapmet == 4 ? new SHMap(W_L, H_L, true) : nullptr; float *buffer = new float[W_L * H_L]; - for ( int scale = scal - 1; scale >= 0; scale-- ) { + for (int scale = scal - 1; scale >= 0; scale--) { #ifdef _OPENMP #pragma omp parallel #endif @@ -907,11 +908,11 @@ void ImProcFunctions::MSRLocal (float** luminance, float** templ, const float* c if (scale == scal - 1) { - gaussianBlur (src, out, W_L, H_L, RetinexScales[scale], buffer); - } else { // reuse result of last iteration + gaussianBlur(src, out, W_L, H_L, RetinexScales[scale], buffer); + } else // reuse result of last iteration + { // out was modified in last iteration => restore it - if (((mapmet == 4)) && it == 1) - { + if (((mapmet == 4)) && it == 1) { #ifdef _OPENMP #pragma omp for @@ -924,8 +925,9 @@ void ImProcFunctions::MSRLocal (float** luminance, float** templ, const float* c } } - gaussianBlur (out, out, W_L, H_L, sqrtf (SQR (RetinexScales[scale]) - SQR (RetinexScales[scale + 1])), buffer); + gaussianBlur(out, out, W_L, H_L, sqrtf(SQR(RetinexScales[scale]) - SQR(RetinexScales[scale + 1])), buffer); } + if ((mapmet == 4) && it == 1 && scale > 0) { // out will be modified => store it for use in next iteration. We even don't need a new buffer because 'buffer' is free after gaussianBlur :) @@ -945,7 +947,7 @@ void ImProcFunctions::MSRLocal (float** luminance, float** templ, const float* c float h_thcomp, s_thcomp; if ((mapmet == 4) && it == 1) { - shmap->updateL (out, shradius, true, 1); + shmap->updateL(out, shradius, true, 1); h_thcomp = 0.f;//shmap->max_f - loc.htonalwidth * (shmap->max_f - shmap->avg) / 100.f; h_th = h_thcomp - (shHighlights * h_thcomp); s_thcomp = 0.f;//loc.stonalwidth * (shmap->avg - shmap->min_f) / 100.f; @@ -973,9 +975,9 @@ void ImProcFunctions::MSRLocal (float** luminance, float** templ, const float* c } #ifdef __SSE2__ - vfloat pondv = F2V (pond); - vfloat limMinv = F2V (ilimD); - vfloat limMaxv = F2V (limD); + vfloat pondv = F2V(pond); + vfloat limMinv = F2V(ilimD); + vfloat limMaxv = F2V(limD); #endif #ifdef _OPENMP @@ -989,11 +991,11 @@ void ImProcFunctions::MSRLocal (float** luminance, float** templ, const float* c if (useHslLin) { //keep in case of ?? for (; j < W_L - 3; j += 4) { - _mm_storeu_ps (&luminance[i][j], LVFU (luminance[i][j]) + pondv * (LIMV (LVFU (src[i][j]) / LVFU (out[i][j]), limMinv, limMaxv) )); + _mm_storeu_ps(&luminance[i][j], LVFU(luminance[i][j]) + pondv * (LIMV(LVFU(src[i][j]) / LVFU(out[i][j]), limMinv, limMaxv))); } } else {//always Lab mode due to Wavelet for (; j < W_L - 3; j += 4) { - _mm_storeu_ps (&luminance[i][j], LVFU (luminance[i][j]) + pondv * xlogf (LIMV (LVFU (src[i][j]) / LVFU (out[i][j]), limMinv, limMaxv) )); + _mm_storeu_ps(&luminance[i][j], LVFU(luminance[i][j]) + pondv * xlogf(LIMV(LVFU(src[i][j]) / LVFU(out[i][j]), limMinv, limMaxv))); } } @@ -1001,11 +1003,11 @@ void ImProcFunctions::MSRLocal (float** luminance, float** templ, const float* c if (useHslLin) { for (; j < W_L; j++) { - luminance[i][j] += pond * (LIM (src[i][j] / out[i][j], ilimD, limD)); + luminance[i][j] += pond * (LIM(src[i][j] / out[i][j], ilimD, limD)); } } else { for (; j < W_L; j++) { - luminance[i][j] += pond * xlogf (LIM (src[i][j] / out[i][j], ilimD, limD)); // /logt ? + luminance[i][j] += pond * xlogf(LIM(src[i][j] / out[i][j], ilimD, limD)); // /logt ? } } } @@ -1025,7 +1027,7 @@ void ImProcFunctions::MSRLocal (float** luminance, float** templ, const float* c mean = 0.f; stddv = 0.f; - mean_stddv2 ( luminance, mean, stddv, W_L, H_L, maxtr, mintr); + mean_stddv2(luminance, mean, stddv, W_L, H_L, maxtr, mintr); //printf("mean=%f std=%f delta=%f maxtr=%f mintr=%f\n", mean, stddv, delta, maxtr, mintr); // mean_stddv( luminance, mean, stddv, W_L, H_L, logBetaGain, maxtr, mintr); @@ -1088,7 +1090,7 @@ void ImProcFunctions::MSRLocal (float** luminance, float** templ, const float* c // float pp[9], temp; for (int j = borderL; j < wid - borderL; j++) { - tmL[i][j] = median (luminance[i][j], luminance[i - 1][j], luminance[i + 1][j], luminance[i][j + 1], luminance[i][j - 1], luminance[i - 1][j - 1], luminance[i - 1][j + 1], luminance[i + 1][j - 1], luminance[i + 1][j + 1]); //3x3 + tmL[i][j] = median(luminance[i][j], luminance[i - 1][j], luminance[i + 1][j], luminance[i][j + 1], luminance[i][j - 1], luminance[i - 1][j - 1], luminance[i - 1][j + 1], luminance[i + 1][j - 1], luminance[i + 1][j + 1]); //3x3 } } @@ -1096,7 +1098,7 @@ void ImProcFunctions::MSRLocal (float** luminance, float** templ, const float* c #pragma omp parallel for #endif - for (int i = borderL; i < hei - borderL; i++ ) { + for (int i = borderL; i < hei - borderL; i++) { for (int j = borderL; j < wid - borderL; j++) { luminance[i][j] = tmL[i][j]; } @@ -1108,7 +1110,7 @@ void ImProcFunctions::MSRLocal (float** luminance, float** templ, const float* c // I call mean_stddv2 instead of mean_stddv ==> logBetaGain // mean_stddv( luminance, mean, stddv, W_L, H_L, 1.f, maxtr, mintr); - mean_stddv2 ( luminance, mean, stddv, W_L, H_L, maxtr, mintr); + mean_stddv2(luminance, mean, stddv, W_L, H_L, maxtr, mintr); } @@ -1129,7 +1131,7 @@ void ImProcFunctions::MSRLocal (float** luminance, float** templ, const float* c delta = maxi - mini; //printf("maxi=%f mini=%f mean=%f std=%f delta=%f maxtr=%f mintr=%f\n", maxi, mini, mean, stddv, delta, maxtr, mintr); - if ( !delta ) { + if (!delta) { delta = 1.0f; } @@ -1152,7 +1154,7 @@ void ImProcFunctions::MSRLocal (float** luminance, float** templ, const float* c stddv = 0.f; // I call mean_stddv2 instead of mean_stddv ==> logBetaGain - mean_stddv2 ( luminance, mean, stddv, W_L, H_L, maxtr, mintr); + mean_stddv2(luminance, mean, stddv, W_L, H_L, maxtr, mintr); float asig = 0.f, bsig = 0.f, amax = 0.f, bmax = 0.f, amin = 0.f, bmin = 0.f; // bool gaincurve = false; //wavRETgainCcurve const bool hasWavRetGainCurve = locRETgainCcurve && mean != 0.f && stddv != 0.f; @@ -1188,12 +1190,12 @@ void ImProcFunctions::MSRLocal (float** luminance, float** templ, const float* c #pragma omp for schedule(dynamic,16) #endif - for ( int i = 0; i < H_L; i ++ ) + for (int i = 0; i < H_L; i ++) for (int j = 0; j < W_L; j++) { if (hasWavRetGainCurve) { float absciss; - if (LIKELY (fabsf (luminance[i][j] - mean) < stddv)) { + if (LIKELY(fabsf(luminance[i][j] - mean) < stddv)) { absciss = asig * luminance[i][j] + bsig; } else if (luminance[i][j] >= mean) { absciss = amax * luminance[i][j] + bmax; @@ -1208,7 +1210,7 @@ void ImProcFunctions::MSRLocal (float** luminance, float** templ, const float* c cdmax = cd > cdmax ? cd : cdmax; cdmin = cd < cdmin ? cd : cdmin; - luminance[i][j] = LIM ( cd, 0.f, maxclip ) * str + (1.f - str) * originalLuminance[i][j]; + luminance[i][j] = LIM(cd, 0.f, maxclip) * str + (1.f - str) * originalLuminance[i][j]; // templ[i][j] = LIM( cd, 0.f, maxclip ) * str + (1.f - str) * originalLuminance[i][j]; // luminance[i][j] = LIM( cd, 0.f, maxclip ); } diff --git a/rtengine/procparams.cc b/rtengine/procparams.cc index f3f118f03..735a222e9 100644 --- a/rtengine/procparams.cc +++ b/rtengine/procparams.cc @@ -2995,7 +2995,7 @@ bool MetaDataParams::operator!=(const MetaDataParams &other) const } -ProcParams::ProcParams () +ProcParams::ProcParams() { setDefaults(); } @@ -3086,8 +3086,8 @@ void ProcParams::setDefaults() raw = RAWParams(); metadata = MetaDataParams(); - exif.clear (); - iptc.clear (); + exif.clear(); + iptc.clear(); rank = 0; colorlabel = 0; @@ -5389,13 +5389,14 @@ int ProcParams::load(const Glib::ustring& fname, ParamsEdited* pedited) if (keyFile.has_group("MetaData")) { int mode = int(MetaDataParams::TUNNEL); assignFromKeyfile(keyFile, "MetaData", "Mode", pedited, mode, pedited->metadata.mode); + if (mode >= int(MetaDataParams::TUNNEL) && mode <= int(MetaDataParams::STRIP)) { metadata.mode = static_cast(mode); } } - if (keyFile.has_group ("Exif")) { - std::vector keys = keyFile.get_keys ("Exif"); + if (keyFile.has_group("Exif")) { + std::vector keys = keyFile.get_keys("Exif"); for (const auto& key : keyFile.get_keys("Exif")) { exif[key] = keyFile.get_string("Exif", key); diff --git a/rtengine/rawimage.cc b/rtengine/rawimage.cc index 8d7292113..5857279b9 100644 --- a/rtengine/rawimage.cc +++ b/rtengine/rawimage.cc @@ -21,7 +21,7 @@ namespace rtengine extern const Settings* settings; -RawImage::RawImage( const Glib::ustring &name ) +RawImage::RawImage(const Glib::ustring &name) : data(nullptr) , prefilters(0) , filename(name) @@ -37,31 +37,31 @@ RawImage::RawImage( const Glib::ustring &name ) RawImage::~RawImage() { - if(ifp) { + if (ifp) { fclose(ifp); ifp = nullptr; } - if( image ) { + if (image) { free(image); } - if(allocation) { + if (allocation) { delete [] allocation; allocation = nullptr; } - if(float_raw_image) { + if (float_raw_image) { delete [] float_raw_image; float_raw_image = nullptr; } - if(data) { + if (data) { delete [] data; data = nullptr; } - if(profile_data) { + if (profile_data) { delete [] profile_data; profile_data = nullptr; } @@ -83,7 +83,7 @@ eSensorType RawImage::getSensorType() /* Similar to dcraw scale_colors for coeff. calculation, but without actual pixels scaling. * need pixels in data[][] available */ -void RawImage::get_colorsCoeff( float *pre_mul_, float *scale_mul_, float *cblack_, bool forceAutoWB) +void RawImage::get_colorsCoeff(float *pre_mul_, float *scale_mul_, float *cblack_, bool forceAutoWB) { unsigned sum[8], c; unsigned W = this->get_width(); @@ -91,7 +91,7 @@ void RawImage::get_colorsCoeff( float *pre_mul_, float *scale_mul_, float *cblac float val; double dsum[8], dmin, dmax; - if(isXtrans()) { + if (isXtrans()) { // for xtrans files dcraw stores black levels in cblack[6] .. cblack[41], but all are equal, so we just use cblack[6] for (int c = 0; c < 4; c++) { cblack_[c] = (float) this->get_cblack(6); @@ -101,6 +101,7 @@ void RawImage::get_colorsCoeff( float *pre_mul_, float *scale_mul_, float *cblac for (int c = 0; c < 4; c++) { cblack_[c] = this->get_cblack(c); } + for (int c = 0; c < 4; c++) { cblack_[FC(c / 2, c % 2)] = this->get_cblack(6 + c / 2 % this->get_cblack(4) * this->get_cblack(5) + c % 2 % this->get_cblack(5)); pre_mul_[c] = this->get_pre_mul(c); @@ -113,9 +114,10 @@ void RawImage::get_colorsCoeff( float *pre_mul_, float *scale_mul_, float *cblac } if (this->get_cam_mul(0) == -1 || forceAutoWB) { - if(!data) { // this happens only for thumbnail creation when get_cam_mul(0) == -1 + if (!data) { // this happens only for thumbnail creation when get_cam_mul(0) == -1 compress_image(0, false); } + memset(dsum, 0, sizeof dsum); if (this->isBayer()) { @@ -191,11 +193,11 @@ skip_block2: } } - for(int c = 0; c < 4; c++) { + for (int c = 0; c < 4; c++) { dsum[c] -= cblack_[c] * dsum[c + 4]; } - } else if(isXtrans()) { + } else if (isXtrans()) { #pragma omp parallel { double dsumthr[8]; @@ -280,7 +282,7 @@ skip_block3: sum[c] += val; sum[c + 4]++; - if ( this->isBayer()) { + if (this->isBayer()) { break; } } @@ -315,8 +317,7 @@ skip_block: if (sum[0] && sum[1] && sum[2] && sum[3]) for (int c = 0; c < 4; c++) { pre_mul_[c] = (float) sum[c + 4] / sum[c]; - } - else if (this->get_cam_mul(0) && this->get_cam_mul(2)) { + } else if (this->get_cam_mul(0) && this->get_cam_mul(2)) { pre_mul_[0] = this->get_cam_mul(0); pre_mul_[1] = this->get_cam_mul(1); pre_mul_[2] = this->get_cam_mul(2); @@ -407,17 +408,17 @@ skip_block: } } -int RawImage::loadRaw (bool loadData, unsigned int imageNum, bool closeFile, ProgressListener *plistener, double progressRange) +int RawImage::loadRaw(bool loadData, unsigned int imageNum, bool closeFile, ProgressListener *plistener, double progressRange) { ifname = filename.c_str(); image = nullptr; verbose = settings->verbose; oprof = nullptr; - if(!ifp) { - ifp = gfopen (ifname); // Maps to either file map or direct fopen + if (!ifp) { + ifp = gfopen(ifname); // Maps to either file map or direct fopen } else { - fseek (ifp, 0, SEEK_SET); + fseek(ifp, 0, SEEK_SET); } if (!ifp) { @@ -453,9 +454,9 @@ int RawImage::loadRaw (bool loadData, unsigned int imageNum, bool closeFile, Pro return 2; } - if(!strcmp(make,"Fujifilm") && raw_height * raw_width * 2u != raw_size) { + if (!strcmp(make, "Fujifilm") && raw_height * raw_width * 2u != raw_size) { parse_fuji_compressed_header(); - } + } if (flip == 5) { this->rotate_deg = 270; @@ -469,28 +470,28 @@ int RawImage::loadRaw (bool loadData, unsigned int imageNum, bool closeFile, Pro this->rotate_deg = 0; } - if( loadData ) { + if (loadData) { use_camera_wb = 1; shrink = 0; if (settings->verbose) { - printf ("Loading %s %s image from %s...\n", make, model, filename.c_str()); + printf("Loading %s %s image from %s...\n", make, model, filename.c_str()); } iheight = height; iwidth = width; if (filters || colors == 1) { - raw_image = (ushort *) calloc ((raw_height + 7) * raw_width, 2); - merror (raw_image, "main()"); + raw_image = (ushort *) calloc((raw_height + 7) * raw_width, 2); + merror(raw_image, "main()"); } // dcraw needs this global variable to hold pixel data - image = (dcrawImage_t)calloc (height * width * sizeof * image + meta_length, 1); - meta_data = (char *) (image + height * width); + image = (dcrawImage_t)calloc(height * width * sizeof * image + meta_length, 1); + meta_data = (char *)(image + height * width); - if(!image) { + if (!image) { return 200; } @@ -503,7 +504,7 @@ int RawImage::loadRaw (bool loadData, unsigned int imageNum, bool closeFile, Pro } */ // Load raw pixels data - fseek (ifp, data_offset, SEEK_SET); + fseek(ifp, data_offset, SEEK_SET); (this->*load_raw)(); if (plistener) { @@ -517,13 +518,15 @@ int RawImage::loadRaw (bool loadData, unsigned int imageNum, bool closeFile, Pro if (cc && cc->has_rawCrop()) { int lm, tm, w, h; cc->get_rawCrop(lm, tm, w, h); - if(isXtrans()) { - shiftXtransMatrix(6 - ((top_margin - tm)%6), 6 - ((left_margin - lm)%6)); + + if (isXtrans()) { + shiftXtransMatrix(6 - ((top_margin - tm) % 6), 6 - ((left_margin - lm) % 6)); } else { - if(((int)top_margin - tm) & 1) { // we have an odd border difference + if (((int)top_margin - tm) & 1) { // we have an odd border difference filters = (filters << 4) | (filters >> 28); // left rotate filters by 4 bits } } + left_margin = lm; top_margin = tm; @@ -553,7 +556,7 @@ int RawImage::loadRaw (bool loadData, unsigned int imageNum, bool closeFile, Pro } crop_masked_pixels(); - free (raw_image); + free(raw_image); raw_image = nullptr; } else { if (get_maker() == "Sigma" && cc && cc->has_rawCrop()) { // foveon images @@ -581,8 +584,8 @@ int RawImage::loadRaw (bool loadData, unsigned int imageNum, bool closeFile, Pro // Load embedded profile if (profile_length) { profile_data = new char[profile_length]; - fseek ( ifp, profile_offset, SEEK_SET); - fread ( profile_data, 1, profile_length, ifp); + fseek(ifp, profile_offset, SEEK_SET); + fread(profile_data, 1, profile_length, ifp); } /* @@ -612,10 +615,10 @@ int RawImage::loadRaw (bool loadData, unsigned int imageNum, bool closeFile, Pro if (RT_whitelevel_from_constant) { maximum_c4[i] = cc->get_WhiteLevel(i, iso_speed, aperture); - if(tiff_bps > 0 && maximum_c4[i] > 0 && !isFoveon()) { + if (tiff_bps > 0 && maximum_c4[i] > 0 && !isFoveon()) { unsigned compare = ((uint64_t)1 << tiff_bps) - 1; // use uint64_t to avoid overflow if tiff_bps == 32 - while(static_cast(maximum_c4[i]) > compare) { + while (static_cast(maximum_c4[i]) > compare) { maximum_c4[i] >>= 1; } } @@ -624,11 +627,10 @@ int RawImage::loadRaw (bool loadData, unsigned int imageNum, bool closeFile, Pro } if (black_c4[0] == -1) { - if(isXtrans()) + if (isXtrans()) for (int c = 0; c < 4; c++) { black_c4[c] = cblack[6]; - } - else + } else // RT constants not set, bring in the DCRAW single channel black constant for (int c = 0; c < 4; c++) { @@ -664,7 +666,7 @@ int RawImage::loadRaw (bool loadData, unsigned int imageNum, bool closeFile, Pro } } - if ( closeFile ) { + if (closeFile) { fclose(ifp); ifp = nullptr; } @@ -678,7 +680,7 @@ int RawImage::loadRaw (bool loadData, unsigned int imageNum, bool closeFile, Pro float** RawImage::compress_image(int frameNum, bool freeImage) { - if( !image ) { + if (!image) { return nullptr; } @@ -714,7 +716,7 @@ float** RawImage::compress_image(int frameNum, bool freeImage) } // copy pixel raw data: the compressed format earns space - if( float_raw_image ) { + if (float_raw_image) { #pragma omp parallel for for (int row = 0; row < height; row++) @@ -746,10 +748,11 @@ float** RawImage::compress_image(int frameNum, bool freeImage) this->data[row][col] = image[row * width + col][0]; } } else { - if(get_maker() == "Sigma" && dng_version) { // Hack to prevent sigma dng files from crashing + if (get_maker() == "Sigma" && dng_version) { // Hack to prevent sigma dng files from crashing height -= top_margin; width -= left_margin; } + #pragma omp parallel for for (int row = 0; row < height; row++) @@ -760,50 +763,51 @@ float** RawImage::compress_image(int frameNum, bool freeImage) } } - if(freeImage) { + if (freeImage) { free(image); // we don't need this anymore image = nullptr; } + return data; } bool RawImage::is_supportedThumb() const { - return ( (thumb_width * thumb_height) > 0 && - ( write_thumb == &rtengine::RawImage::jpeg_thumb || - write_thumb == &rtengine::RawImage::ppm_thumb) && - !thumb_load_raw ); + return ((thumb_width * thumb_height) > 0 && + (write_thumb == &rtengine::RawImage::jpeg_thumb || + write_thumb == &rtengine::RawImage::ppm_thumb) && + !thumb_load_raw); } bool RawImage::is_jpegThumb() const { - return ( (thumb_width * thumb_height) > 0 && - write_thumb == &rtengine::RawImage::jpeg_thumb && - !thumb_load_raw ); + return ((thumb_width * thumb_height) > 0 && + write_thumb == &rtengine::RawImage::jpeg_thumb && + !thumb_load_raw); } bool RawImage::is_ppmThumb() const { - return ( (thumb_width * thumb_height) > 0 && - write_thumb == &rtengine::RawImage::ppm_thumb && - !thumb_load_raw ); + return ((thumb_width * thumb_height) > 0 && + write_thumb == &rtengine::RawImage::ppm_thumb && + !thumb_load_raw); } -void RawImage::getXtransMatrix( int XtransMatrix[6][6]) +void RawImage::getXtransMatrix(int XtransMatrix[6][6]) { - for(int row = 0; row < 6; row++) - for(int col = 0; col < 6; col++) { + for (int row = 0; row < 6; row++) + for (int col = 0; col < 6; col++) { XtransMatrix[row][col] = xtrans[row][col]; } } -void RawImage::getRgbCam (float rgbcam[3][4]) +void RawImage::getRgbCam(float rgbcam[3][4]) { - for(int row = 0; row < 3; row++) - for(int col = 0; col < 4; col++) { + for (int row = 0; row < 3; row++) + for (int col = 0; col < 4; col++) { rgbcam[row][col] = rgb_cam[row][col]; } diff --git a/rtengine/rawimage.h b/rtengine/rawimage.h index 95e7aea8d..63745d71c 100644 --- a/rtengine/rawimage.h +++ b/rtengine/rawimage.h @@ -33,7 +33,7 @@ namespace rtengine struct badPix { uint16_t x; uint16_t y; - badPix( uint16_t xc, uint16_t yc ): x(xc), y(yc) {} + badPix(uint16_t xc, uint16_t yc): x(xc), y(yc) {} }; class PixelsMap : @@ -46,12 +46,12 @@ class PixelsMap : base_t *pm; public: - PixelsMap(int width, int height ) + PixelsMap(int width, int height) : h(height) { w = (width / (base_t_size * 8)) + 1; pm = new base_t [h * w ]; - memset(pm, 0, h * w * base_t_size ); + memset(pm, 0, h * w * base_t_size); } ~PixelsMap() @@ -70,7 +70,7 @@ public: // if a pixel is set returns true bool get(int x, int y) { - return (pm[y * w + x / (base_t_size * 8) ] & (base_t)1 << (x % (base_t_size * 8)) ) != 0; + return (pm[y * w + x / (base_t_size * 8) ] & (base_t)1 << (x % (base_t_size * 8))) != 0; } // set a pixel @@ -80,10 +80,10 @@ public: } // set pixels from a list - int set( std::vector &bp) + int set(std::vector &bp) { - for(std::vector::iterator iter = bp.begin(); iter != bp.end(); ++iter) { - set( iter->x, iter->y); + for (std::vector::iterator iter = bp.begin(); iter != bp.end(); ++iter) { + set(iter->x, iter->y); } return bp.size(); @@ -91,7 +91,7 @@ public: void clear() { - memset(pm, 0, h * w * base_t_size ); + memset(pm, 0, h * w * base_t_size); } // return 0 if at least one pixel in the word(base_t) is set, otherwise return the number of pixels to skip to the next word base_t int skipIfZero(int x, int y) @@ -105,11 +105,11 @@ class RawImage: public DCraw { public: - explicit RawImage( const Glib::ustring &name ); + explicit RawImage(const Glib::ustring &name); ~RawImage(); - int loadRaw (bool loadData, unsigned int imageNum = 0, bool closeFile = true, ProgressListener *plistener = nullptr, double progressRange = 1.0); - void get_colorsCoeff( float* pre_mul_, float* scale_mul_, float* cblack_, bool forceAutoWB ); + int loadRaw(bool loadData, unsigned int imageNum = 0, bool closeFile = true, ProgressListener *plistener = nullptr, double progressRange = 1.0); + void get_colorsCoeff(float* pre_mul_, float* scale_mul_, float* cblack_, bool forceAutoWB); void set_prefilters() { if (isBayer() && get_colors() == 3) { @@ -124,7 +124,10 @@ public: float** compress_image(int frameNum, bool freeImage = true); // revert to compressed pixels format and release image data float** data; // holds pixel values, data[i][j] corresponds to the ith row and jth column unsigned prefilters; // original filters saved ( used for 4 color processing ) - unsigned int getFrameCount() const { return is_raw; } + unsigned int getFrameCount() const + { + return is_raw; + } protected: Glib::ustring filename; // complete filename int rotate_deg; // 0,90,180,270 degree of rotation: info taken by dcraw from exif @@ -173,8 +176,8 @@ public: } eSensorType getSensorType(); - void getRgbCam (float rgbcam[3][4]); - void getXtransMatrix ( int xtransMatrix[6][6]); + void getRgbCam(float rgbcam[3][4]); + void getXtransMatrix(int xtransMatrix[6][6]); unsigned get_filters() const { return filters; @@ -195,7 +198,7 @@ public: return maximum; } } - unsigned short get_whiteSample( int r, int c ) const + unsigned short get_whiteSample(int r, int c) const { return white[r][c]; } @@ -229,13 +232,13 @@ public: return std::string(model); } - float get_cam_mul(int c )const + float get_cam_mul(int c)const { return cam_mul[c]; } - float get_pre_mul(int c )const + float get_pre_mul(int c)const { - if(std::isfinite(pre_mul[c])) { + if (std::isfinite(pre_mul[c])) { return pre_mul[c]; } else { std::cout << "Failure decoding '" << filename << "', please file a bug report including the raw file and the line below:" << std::endl; @@ -243,7 +246,7 @@ public: return 1.f; } } - float get_rgb_cam( int r, int c) const + float get_rgb_cam(int r, int c) const { return rgb_cam[r][c]; } @@ -320,7 +323,7 @@ public: } public: - bool ISRED (unsigned row, unsigned col) const + bool ISRED(unsigned row, unsigned col) const { return ((filters >> ((((row) << 1 & 14) + ((col) & 1)) << 1) & 3) == 0); } @@ -328,15 +331,15 @@ public: { return ((filters >> ((((row) << 1 & 14) + ((col) & 1)) << 1) & 3) == 1); } - bool ISBLUE (unsigned row, unsigned col) const + bool ISBLUE(unsigned row, unsigned col) const { return ((filters >> ((((row) << 1 & 14) + ((col) & 1)) << 1) & 3) == 2); } - unsigned FC (unsigned row, unsigned col) const + unsigned FC(unsigned row, unsigned col) const { return (filters >> ((((row) << 1 & 14) + ((col) & 1)) << 1) & 3); } - bool ISXTRANSRED (unsigned row, unsigned col) const + bool ISXTRANSRED(unsigned row, unsigned col) const { return ((xtrans[(row) % 6][(col) % 6]) == 0); } @@ -344,16 +347,16 @@ public: { return ((xtrans[(row) % 6][(col) % 6]) == 1); } - bool ISXTRANSBLUE (unsigned row, unsigned col) const + bool ISXTRANSBLUE(unsigned row, unsigned col) const { return ((xtrans[(row) % 6][(col) % 6]) == 2); } - unsigned XTRANSFC (unsigned row, unsigned col) const + unsigned XTRANSFC(unsigned row, unsigned col) const { return (xtrans[(row) % 6][(col) % 6]); } - unsigned DNGVERSION ( ) const + unsigned DNGVERSION() const { return dng_version; } diff --git a/rtengine/rawimagesource.cc b/rtengine/rawimagesource.cc index 60b625e5a..46b51f035 100644 --- a/rtengine/rawimagesource.cc +++ b/rtengine/rawimagesource.cc @@ -47,26 +47,26 @@ namespace { -void rotateLine (const float* const line, rtengine::PlanarPtr &channel, const int tran, const int i, const int w, const int h) +void rotateLine(const float* const line, rtengine::PlanarPtr &channel, const int tran, const int i, const int w, const int h) { switch (tran & TR_ROT) { case TR_R180: for (int j = 0; j < w; j++) { - channel (h - 1 - i, w - 1 - j) = line[j]; + channel(h - 1 - i, w - 1 - j) = line[j]; } break; case TR_R90: for (int j = 0; j < w; j++) { - channel (j, h - 1 - i) = line[j]; + channel(j, h - 1 - i) = line[j]; } break; case TR_R270: for (int j = 0; j < w; j++) { - channel (w - 1 - j, i) = line[j]; + channel(w - 1 - j, i) = line[j]; } break; @@ -74,27 +74,27 @@ void rotateLine (const float* const line, rtengine::PlanarPtr &channel, c case TR_NONE: default: for (int j = 0; j < w; j++) { - channel (i, j) = line[j]; + channel(i, j) = line[j]; } } } -void transLineStandard (const float* const red, const float* const green, const float* const blue, const int i, rtengine::Imagefloat* const image, const int tran, const int imwidth, const int imheight) +void transLineStandard(const float* const red, const float* const green, const float* const blue, const int i, rtengine::Imagefloat* const image, const int tran, const int imwidth, const int imheight) { // conventional CCD coarse rotation - rotateLine (red, image->r, tran, i, imwidth, imheight); - rotateLine (green, image->g, tran, i, imwidth, imheight); - rotateLine (blue, image->b, tran, i, imwidth, imheight); + rotateLine(red, image->r, tran, i, imwidth, imheight); + rotateLine(green, image->g, tran, i, imwidth, imheight); + rotateLine(blue, image->b, tran, i, imwidth, imheight); } -void transLineFuji (const float* const red, const float* const green, const float* const blue, const int i, rtengine::Imagefloat* const image, const int tran, const int imheight, const int fw) +void transLineFuji(const float* const red, const float* const green, const float* const blue, const int i, rtengine::Imagefloat* const image, const int tran, const int imheight, const int fw) { // Fuji SuperCCD rotation + coarse rotation - int start = ABS (fw - i); + int start = ABS(fw - i); int w = fw * 2 + 1; int h = (imheight - fw) * 2 + 1; - int end = min (h + fw - i, w - fw + i); + int end = min(h + fw - i, w - fw + i); switch (tran & TR_ROT) { case TR_R180: @@ -103,9 +103,9 @@ void transLineFuji (const float* const red, const float* const green, const floa int x = fw - i + j; if (x >= 0 && y < image->getHeight() && y >= 0 && x < image->getWidth()) { - image->r (image->getHeight() - 1 - y, image->getWidth() - 1 - x) = red[j]; - image->g (image->getHeight() - 1 - y, image->getWidth() - 1 - x) = green[j]; - image->b (image->getHeight() - 1 - y, image->getWidth() - 1 - x) = blue[j]; + image->r(image->getHeight() - 1 - y, image->getWidth() - 1 - x) = red[j]; + image->g(image->getHeight() - 1 - y, image->getWidth() - 1 - x) = green[j]; + image->b(image->getHeight() - 1 - y, image->getWidth() - 1 - x) = blue[j]; } } @@ -117,9 +117,9 @@ void transLineFuji (const float* const red, const float* const green, const floa int x = fw - i + j; if (x >= 0 && x < image->getHeight() && y >= 0 && y < image->getWidth()) { - image->r (image->getHeight() - 1 - x, y) = red[j]; - image->g (image->getHeight() - 1 - x, y) = green[j]; - image->b (image->getHeight() - 1 - x, y) = blue[j]; + image->r(image->getHeight() - 1 - x, y) = red[j]; + image->g(image->getHeight() - 1 - x, y) = green[j]; + image->b(image->getHeight() - 1 - x, y) = blue[j]; } } @@ -131,9 +131,9 @@ void transLineFuji (const float* const red, const float* const green, const floa int x = fw - i + j; if (x >= 0 && y < image->getWidth() && y >= 0 && x < image->getHeight()) { - image->r (x, image->getWidth() - 1 - y) = red[j]; - image->g (x, image->getWidth() - 1 - y) = green[j]; - image->b (x, image->getWidth() - 1 - y) = blue[j]; + image->r(x, image->getWidth() - 1 - y) = red[j]; + image->g(x, image->getWidth() - 1 - y) = green[j]; + image->b(x, image->getWidth() - 1 - y) = blue[j]; } } @@ -146,15 +146,15 @@ void transLineFuji (const float* const red, const float* const green, const floa int x = fw - i + j; if (x >= 0 && y < image->getHeight() && y >= 0 && x < image->getWidth()) { - image->r (y, x) = red[j]; - image->g (y, x) = green[j]; - image->b (y, x) = blue[j]; + image->r(y, x) = red[j]; + image->g(y, x) = green[j]; + image->b(y, x) = blue[j]; } } } } -void transLineD1x (const float* const red, const float* const green, const float* const blue, const int i, rtengine::Imagefloat* const image, const int tran, const int imwidth, const int imheight, const bool oddHeight, const bool clip) +void transLineD1x(const float* const red, const float* const green, const float* const blue, const int i, rtengine::Imagefloat* const image, const int tran, const int imwidth, const int imheight, const bool oddHeight, const bool clip) { // Nikon D1X has an uncommon sensor with 4028 x 1324 sensels. // Vertical sensel size is 2x horizontal sensel size @@ -164,16 +164,16 @@ void transLineD1x (const float* const red, const float* const green, const float switch (tran & TR_ROT) { case TR_R180: // rotate 180 degree for (int j = 0; j < imwidth; j++) { - image->r (2 * (imheight - 1 - i), imwidth - 1 - j) = red[j]; - image->g (2 * (imheight - 1 - i), imwidth - 1 - j) = green[j]; - image->b (2 * (imheight - 1 - i), imwidth - 1 - j) = blue[j]; + image->r(2 * (imheight - 1 - i), imwidth - 1 - j) = red[j]; + image->g(2 * (imheight - 1 - i), imwidth - 1 - j) = green[j]; + image->b(2 * (imheight - 1 - i), imwidth - 1 - j) = blue[j]; } if (i == 0) { for (int j = 0; j < imwidth; j++) { - image->r (2 * imheight - 1, imwidth - 1 - j) = red[j]; - image->g (2 * imheight - 1, imwidth - 1 - j) = green[j]; - image->b (2 * imheight - 1, imwidth - 1 - j) = blue[j]; + image->r(2 * imheight - 1, imwidth - 1 - j) = red[j]; + image->g(2 * imheight - 1, imwidth - 1 - j) = green[j]; + image->b(2 * imheight - 1, imwidth - 1 - j) = blue[j]; } } @@ -182,9 +182,9 @@ void transLineD1x (const float* const red, const float* const green, const float for (int j = 0; j < imwidth; j++) { int col = imwidth - 1 - j; - image->r (row, col) = (red[j] + image->r (row + 1, col)) / 2; - image->g (row, col) = (green[j] + image->g (row + 1, col)) / 2; - image->b (row, col) = (blue[j] + image->b (row + 1, col)) / 2; + image->r(row, col) = (red[j] + image->r(row + 1, col)) / 2; + image->g(row, col) = (green[j] + image->g(row + 1, col)) / 2; + image->b(row, col) = (blue[j] + image->b(row + 1, col)) / 2; } if (i == 2 && oddHeight) { @@ -192,9 +192,9 @@ void transLineD1x (const float* const red, const float* const green, const float for (int j = 0; j < imwidth; j++) { int col = imwidth - 1 - j; - image->r (row, col) = (red[j] + image->r (row - 2, col)) / 2; - image->g (row, col) = (green[j] + image->g (row - 2, col)) / 2; - image->b (row, col) = (blue[j] + image->b (row - 2, col)) / 2; + image->r(row, col) = (red[j] + image->r(row - 2, col)) / 2; + image->g(row, col) = (green[j] + image->g(row - 2, col)) / 2; + image->b(row, col) = (blue[j] + image->b(row - 2, col)) / 2; } } } else if (i == imheight - 1 || i == imheight - 2) { @@ -202,32 +202,32 @@ void transLineD1x (const float* const red, const float* const green, const float for (int j = 0; j < imwidth; j++) { int col = imwidth - 1 - j; - image->r (row, col) = (red[j] + image->r (row + 1, col)) / 2; - image->g (row, col) = (green[j] + image->g (row + 1, col)) / 2; - image->b (row, col) = (blue[j] + image->b (row + 1, col)) / 2; + image->r(row, col) = (red[j] + image->r(row + 1, col)) / 2; + image->g(row, col) = (green[j] + image->g(row + 1, col)) / 2; + image->b(row, col) = (blue[j] + image->b(row + 1, col)) / 2; } row = 2 * imheight - 1 - 2 * i + 2; for (int j = 0; j < imwidth; j++) { int col = imwidth - 1 - j; - image->r (row, col) = (red[j] + image->r (row + 1, col)) / 2; - image->g (row, col) = (green[j] + image->g (row + 1, col)) / 2; - image->b (row, col) = (blue[j] + image->b (row + 1, col)) / 2; + image->r(row, col) = (red[j] + image->r(row + 1, col)) / 2; + image->g(row, col) = (green[j] + image->g(row + 1, col)) / 2; + image->b(row, col) = (blue[j] + image->b(row + 1, col)) / 2; } } else if (i > 2 && i < imheight - 1) { // vertical bicubic interpolation int row = 2 * imheight - 1 - 2 * i + 2; for (int j = 0; j < imwidth; j++) { int col = imwidth - 1 - j; - image->r (row, col) = MAX (0.f, -0.0625f * (red[j] + image->r (row + 3, col)) + 0.5625f * (image->r (row - 1, col) + image->r (row + 1, col))); - image->g (row, col) = MAX (0.f, -0.0625f * (green[j] + image->g (row + 3, col)) + 0.5625f * (image->g (row - 1, col) + image->g (row + 1, col))); - image->b (row, col) = MAX (0.f, -0.0625f * (blue[j] + image->b (row + 3, col)) + 0.5625f * (image->b (row - 1, col) + image->b (row + 1, col))); + image->r(row, col) = MAX(0.f, -0.0625f * (red[j] + image->r(row + 3, col)) + 0.5625f * (image->r(row - 1, col) + image->r(row + 1, col))); + image->g(row, col) = MAX(0.f, -0.0625f * (green[j] + image->g(row + 3, col)) + 0.5625f * (image->g(row - 1, col) + image->g(row + 1, col))); + image->b(row, col) = MAX(0.f, -0.0625f * (blue[j] + image->b(row + 3, col)) + 0.5625f * (image->b(row - 1, col) + image->b(row + 1, col))); if (clip) { - image->r (row, col) = MIN (image->r (row, col), rtengine::MAXVALF); - image->g (row, col) = MIN (image->g (row, col), rtengine::MAXVALF); - image->b (row, col) = MIN (image->b (row, col), rtengine::MAXVALF); + image->r(row, col) = MIN(image->r(row, col), rtengine::MAXVALF); + image->g(row, col) = MIN(image->g(row, col), rtengine::MAXVALF); + image->b(row, col) = MIN(image->b(row, col), rtengine::MAXVALF); } } } @@ -235,62 +235,62 @@ void transLineD1x (const float* const red, const float* const green, const float break; case TR_R90: // rotate right - if ( i == 0) { + if (i == 0) { for (int j = 0; j < imwidth; j++) { - image->r (j, 2 * imheight - 1) = red[j]; - image->g (j, 2 * imheight - 1) = green[j]; - image->b (j, 2 * imheight - 1) = blue[j]; + image->r(j, 2 * imheight - 1) = red[j]; + image->g(j, 2 * imheight - 1) = green[j]; + image->b(j, 2 * imheight - 1) = blue[j]; } } for (int j = 0; j < imwidth; j++) { - image->r (j, 2 * (imheight - 1 - i)) = red[j]; - image->g (j, 2 * (imheight - 1 - i)) = green[j]; - image->b (j, 2 * (imheight - 1 - i)) = blue[j]; + image->r(j, 2 * (imheight - 1 - i)) = red[j]; + image->g(j, 2 * (imheight - 1 - i)) = green[j]; + image->b(j, 2 * (imheight - 1 - i)) = blue[j]; } if (i == 1 || i == 2) { // linear interpolation int col = 2 * imheight - 1 - 2 * i; for (int j = 0; j < imwidth; j++) { - image->r (j, col) = (red[j] + image->r (j, col + 1)) / 2; - image->g (j, col) = (green[j] + image->g (j, col + 1)) / 2; - image->b (j, col) = (blue[j] + image->b (j, col + 1)) / 2; + image->r(j, col) = (red[j] + image->r(j, col + 1)) / 2; + image->g(j, col) = (green[j] + image->g(j, col + 1)) / 2; + image->b(j, col) = (blue[j] + image->b(j, col + 1)) / 2; if (oddHeight && i == 2) { - image->r (j, 2 * imheight) = (red[j] + image->r (j, 2 * imheight - 2)) / 2; - image->g (j, 2 * imheight) = (green[j] + image->g (j, 2 * imheight - 2)) / 2; - image->b (j, 2 * imheight) = (blue[j] + image->b (j, 2 * imheight - 2)) / 2; + image->r(j, 2 * imheight) = (red[j] + image->r(j, 2 * imheight - 2)) / 2; + image->g(j, 2 * imheight) = (green[j] + image->g(j, 2 * imheight - 2)) / 2; + image->b(j, 2 * imheight) = (blue[j] + image->b(j, 2 * imheight - 2)) / 2; } } } else if (i == imheight - 1) { int col = 2 * imheight - 1 - 2 * i; for (int j = 0; j < imwidth; j++) { - image->r (j, col) = (red[j] + image->r (j, col + 1)) / 2; - image->g (j, col) = (green[j] + image->g (j, col + 1)) / 2; - image->b (j, col) = (blue[j] + image->b (j, col + 1)) / 2; + image->r(j, col) = (red[j] + image->r(j, col + 1)) / 2; + image->g(j, col) = (green[j] + image->g(j, col + 1)) / 2; + image->b(j, col) = (blue[j] + image->b(j, col + 1)) / 2; } col = 2 * imheight - 1 - 2 * i + 2; for (int j = 0; j < imwidth; j++) { - image->r (j, col) = (red[j] + image->r (j, col + 1)) / 2; - image->g (j, col) = (green[j] + image->g (j, col + 1)) / 2; - image->b (j, col) = (blue[j] + image->b (j, col + 1)) / 2; + image->r(j, col) = (red[j] + image->r(j, col + 1)) / 2; + image->g(j, col) = (green[j] + image->g(j, col + 1)) / 2; + image->b(j, col) = (blue[j] + image->b(j, col + 1)) / 2; } } else if (i > 2 && i < imheight - 1) { // vertical bicubic interpolation int col = 2 * imheight - 1 - 2 * i + 2; for (int j = 0; j < imwidth; j++) { - image->r (j, col) = MAX (0.f, -0.0625f * (red[j] + image->r (j, col + 3)) + 0.5625f * (image->r (j, col - 1) + image->r (j, col + 1))); - image->g (j, col) = MAX (0.f, -0.0625f * (green[j] + image->g (j, col + 3)) + 0.5625f * (image->g (j, col - 1) + image->g (j, col + 1))); - image->b (j, col) = MAX (0.f, -0.0625f * (blue[j] + image->b (j, col + 3)) + 0.5625f * (image->b (j, col - 1) + image->b (j, col + 1))); + image->r(j, col) = MAX(0.f, -0.0625f * (red[j] + image->r(j, col + 3)) + 0.5625f * (image->r(j, col - 1) + image->r(j, col + 1))); + image->g(j, col) = MAX(0.f, -0.0625f * (green[j] + image->g(j, col + 3)) + 0.5625f * (image->g(j, col - 1) + image->g(j, col + 1))); + image->b(j, col) = MAX(0.f, -0.0625f * (blue[j] + image->b(j, col + 3)) + 0.5625f * (image->b(j, col - 1) + image->b(j, col + 1))); if (clip) { - image->r (j, col) = MIN (image->r (j, col), rtengine::MAXVALF); - image->g (j, col) = MIN (image->g (j, col), rtengine::MAXVALF); - image->b (j, col) = MIN (image->b (j, col), rtengine::MAXVALF); + image->r(j, col) = MIN(image->r(j, col), rtengine::MAXVALF); + image->g(j, col) = MIN(image->g(j, col), rtengine::MAXVALF); + image->b(j, col) = MIN(image->b(j, col), rtengine::MAXVALF); } } } @@ -300,57 +300,57 @@ void transLineD1x (const float* const red, const float* const green, const float case TR_R270: // rotate left if (i == 0) { for (int j = imwidth - 1, row = 0; j >= 0; j--, row++) { - image->r (row, 2 * i) = red[j]; - image->g (row, 2 * i) = green[j]; - image->b (row, 2 * i) = blue[j]; + image->r(row, 2 * i) = red[j]; + image->g(row, 2 * i) = green[j]; + image->b(row, 2 * i) = blue[j]; } } else if (i == 1 || i == 2) { // linear interpolation for (int j = imwidth - 1, row = 0; j >= 0; j--, row++) { - image->r (row, 2 * i) = red[j]; - image->g (row, 2 * i) = green[j]; - image->b (row, 2 * i) = blue[j]; - image->r (row, 2 * i - 1) = (red[j] + image->r (row, 2 * i - 2)) * 0.5f; - image->g (row, 2 * i - 1) = (green[j] + image->g (row, 2 * i - 2)) * 0.5f; - image->b (row, 2 * i - 1) = (blue[j] + image->b (row, 2 * i - 2)) * 0.5f; + image->r(row, 2 * i) = red[j]; + image->g(row, 2 * i) = green[j]; + image->b(row, 2 * i) = blue[j]; + image->r(row, 2 * i - 1) = (red[j] + image->r(row, 2 * i - 2)) * 0.5f; + image->g(row, 2 * i - 1) = (green[j] + image->g(row, 2 * i - 2)) * 0.5f; + image->b(row, 2 * i - 1) = (blue[j] + image->b(row, 2 * i - 2)) * 0.5f; } } else if (i > 0 && i < imheight) { // vertical bicubic interpolation for (int j = imwidth - 1, row = 0; j >= 0; j--, row++) { - image->r (row, 2 * i - 3) = MAX (0.f, -0.0625f * (red[j] + image->r (row, 2 * i - 6)) + 0.5625f * (image->r (row, 2 * i - 2) + image->r (row, 2 * i - 4))); - image->g (row, 2 * i - 3) = MAX (0.f, -0.0625f * (green[j] + image->g (row, 2 * i - 6)) + 0.5625f * (image->g (row, 2 * i - 2) + image->g (row, 2 * i - 4))); - image->b (row, 2 * i - 3) = MAX (0.f, -0.0625f * (blue[j] + image->b (row, 2 * i - 6)) + 0.5625f * (image->b (row, 2 * i - 2) + image->b (row, 2 * i - 4))); + image->r(row, 2 * i - 3) = MAX(0.f, -0.0625f * (red[j] + image->r(row, 2 * i - 6)) + 0.5625f * (image->r(row, 2 * i - 2) + image->r(row, 2 * i - 4))); + image->g(row, 2 * i - 3) = MAX(0.f, -0.0625f * (green[j] + image->g(row, 2 * i - 6)) + 0.5625f * (image->g(row, 2 * i - 2) + image->g(row, 2 * i - 4))); + image->b(row, 2 * i - 3) = MAX(0.f, -0.0625f * (blue[j] + image->b(row, 2 * i - 6)) + 0.5625f * (image->b(row, 2 * i - 2) + image->b(row, 2 * i - 4))); if (clip) { - image->r (row, 2 * i - 3) = MIN (image->r (row, 2 * i - 3), rtengine::MAXVALF); - image->g (row, 2 * i - 3) = MIN (image->g (row, 2 * i - 3), rtengine::MAXVALF); - image->b (row, 2 * i - 3) = MIN (image->b (row, 2 * i - 3), rtengine::MAXVALF); + image->r(row, 2 * i - 3) = MIN(image->r(row, 2 * i - 3), rtengine::MAXVALF); + image->g(row, 2 * i - 3) = MIN(image->g(row, 2 * i - 3), rtengine::MAXVALF); + image->b(row, 2 * i - 3) = MIN(image->b(row, 2 * i - 3), rtengine::MAXVALF); } - image->r (row, 2 * i) = red[j]; - image->g (row, 2 * i) = green[j]; - image->b (row, 2 * i) = blue[j]; + image->r(row, 2 * i) = red[j]; + image->g(row, 2 * i) = green[j]; + image->b(row, 2 * i) = blue[j]; } } if (i == imheight - 1) { for (int j = imwidth - 1, row = 0; j >= 0; j--, row++) { - image->r (row, 2 * i - 1) = MAX (0.f, -0.0625f * (red[j] + image->r (row, 2 * i - 4)) + 0.5625f * (image->r (row, 2 * i) + image->r (row, 2 * i - 2))); - image->g (row, 2 * i - 1) = MAX (0.f, -0.0625f * (green[j] + image->g (row, 2 * i - 4)) + 0.5625f * (image->g (row, 2 * i) + image->g (row, 2 * i - 2))); - image->b (row, 2 * i - 1) = MAX (0.f, -0.0625f * (blue[j] + image->b (row, 2 * i - 4)) + 0.5625f * (image->b (row, 2 * i) + image->b (row, 2 * i - 2))); + image->r(row, 2 * i - 1) = MAX(0.f, -0.0625f * (red[j] + image->r(row, 2 * i - 4)) + 0.5625f * (image->r(row, 2 * i) + image->r(row, 2 * i - 2))); + image->g(row, 2 * i - 1) = MAX(0.f, -0.0625f * (green[j] + image->g(row, 2 * i - 4)) + 0.5625f * (image->g(row, 2 * i) + image->g(row, 2 * i - 2))); + image->b(row, 2 * i - 1) = MAX(0.f, -0.0625f * (blue[j] + image->b(row, 2 * i - 4)) + 0.5625f * (image->b(row, 2 * i) + image->b(row, 2 * i - 2))); if (clip) { - image->r (j, 2 * i - 1) = MIN (image->r (j, 2 * i - 1), rtengine::MAXVALF); - image->g (j, 2 * i - 1) = MIN (image->g (j, 2 * i - 1), rtengine::MAXVALF); - image->b (j, 2 * i - 1) = MIN (image->b (j, 2 * i - 1), rtengine::MAXVALF); + image->r(j, 2 * i - 1) = MIN(image->r(j, 2 * i - 1), rtengine::MAXVALF); + image->g(j, 2 * i - 1) = MIN(image->g(j, 2 * i - 1), rtengine::MAXVALF); + image->b(j, 2 * i - 1) = MIN(image->b(j, 2 * i - 1), rtengine::MAXVALF); } - image->r (row, 2 * i + 1) = (red[j] + image->r (row, 2 * i - 1)) / 2; - image->g (row, 2 * i + 1) = (green[j] + image->g (row, 2 * i - 1)) / 2; - image->b (row, 2 * i + 1) = (blue[j] + image->b (row, 2 * i - 1)) / 2; + image->r(row, 2 * i + 1) = (red[j] + image->r(row, 2 * i - 1)) / 2; + image->g(row, 2 * i + 1) = (green[j] + image->g(row, 2 * i - 1)) / 2; + image->b(row, 2 * i + 1) = (blue[j] + image->b(row, 2 * i - 1)) / 2; if (oddHeight) { - image->r (row, 2 * i + 2) = (red[j] + image->r (row, 2 * i - 2)) / 2; - image->g (row, 2 * i + 2) = (green[j] + image->g (row, 2 * i - 2)) / 2; - image->b (row, 2 * i + 2) = (blue[j] + image->b (row, 2 * i - 2)) / 2; + image->r(row, 2 * i + 2) = (red[j] + image->r(row, 2 * i - 2)) / 2; + image->g(row, 2 * i + 2) = (green[j] + image->g(row, 2 * i - 2)) / 2; + image->b(row, 2 * i + 2) = (blue[j] + image->b(row, 2 * i - 2)) / 2; } } } @@ -359,50 +359,50 @@ void transLineD1x (const float* const red, const float* const green, const float case TR_NONE: // no coarse rotation default: - rotateLine (red, image->r, tran, 2 * i, imwidth, imheight); - rotateLine (green, image->g, tran, 2 * i, imwidth, imheight); - rotateLine (blue, image->b, tran, 2 * i, imwidth, imheight); + rotateLine(red, image->r, tran, 2 * i, imwidth, imheight); + rotateLine(green, image->g, tran, 2 * i, imwidth, imheight); + rotateLine(blue, image->b, tran, 2 * i, imwidth, imheight); if (i == 1 || i == 2) { // linear interpolation for (int j = 0; j < imwidth; j++) { - image->r (2 * i - 1, j) = (red[j] + image->r (2 * i - 2, j)) / 2; - image->g (2 * i - 1, j) = (green[j] + image->g (2 * i - 2, j)) / 2; - image->b (2 * i - 1, j) = (blue[j] + image->b (2 * i - 2, j)) / 2; + image->r(2 * i - 1, j) = (red[j] + image->r(2 * i - 2, j)) / 2; + image->g(2 * i - 1, j) = (green[j] + image->g(2 * i - 2, j)) / 2; + image->b(2 * i - 1, j) = (blue[j] + image->b(2 * i - 2, j)) / 2; } } else if (i > 2 && i < imheight) { // vertical bicubic interpolation for (int j = 0; j < imwidth; j++) { - image->r (2 * i - 3, j) = MAX (0.f, -0.0625f * (red[j] + image->r (2 * i - 6, j)) + 0.5625f * (image->r (2 * i - 2, j) + image->r (2 * i - 4, j))); - image->g (2 * i - 3, j) = MAX (0.f, -0.0625f * (green[j] + image->g (2 * i - 6, j)) + 0.5625f * (image->g (2 * i - 2, j) + image->g (2 * i - 4, j))); - image->b (2 * i - 3, j) = MAX (0.f, -0.0625f * (blue[j] + image->b (2 * i - 6, j)) + 0.5625f * (image->b (2 * i - 2, j) + image->b (2 * i - 4, j))); + image->r(2 * i - 3, j) = MAX(0.f, -0.0625f * (red[j] + image->r(2 * i - 6, j)) + 0.5625f * (image->r(2 * i - 2, j) + image->r(2 * i - 4, j))); + image->g(2 * i - 3, j) = MAX(0.f, -0.0625f * (green[j] + image->g(2 * i - 6, j)) + 0.5625f * (image->g(2 * i - 2, j) + image->g(2 * i - 4, j))); + image->b(2 * i - 3, j) = MAX(0.f, -0.0625f * (blue[j] + image->b(2 * i - 6, j)) + 0.5625f * (image->b(2 * i - 2, j) + image->b(2 * i - 4, j))); if (clip) { - image->r (2 * i - 3, j) = MIN (image->r (2 * i - 3, j), rtengine::MAXVALF); - image->g (2 * i - 3, j) = MIN (image->g (2 * i - 3, j), rtengine::MAXVALF); - image->b (2 * i - 3, j) = MIN (image->b (2 * i - 3, j), rtengine::MAXVALF); + image->r(2 * i - 3, j) = MIN(image->r(2 * i - 3, j), rtengine::MAXVALF); + image->g(2 * i - 3, j) = MIN(image->g(2 * i - 3, j), rtengine::MAXVALF); + image->b(2 * i - 3, j) = MIN(image->b(2 * i - 3, j), rtengine::MAXVALF); } } } if (i == imheight - 1) { for (int j = 0; j < imwidth; j++) { - image->r (2 * i - 1, j) = MAX (0.f, -0.0625f * (red[j] + image->r (2 * i - 4, j)) + 0.5625f * (image->r (2 * i, j) + image->r (2 * i - 2, j))); - image->g (2 * i - 1, j) = MAX (0.f, -0.0625f * (green[j] + image->g (2 * i - 4, j)) + 0.5625f * (image->g (2 * i, j) + image->g (2 * i - 2, j))); - image->b (2 * i - 1, j) = MAX (0.f, -0.0625f * (blue[j] + image->b (2 * i - 4, j)) + 0.5625f * (image->b (2 * i, j) + image->b (2 * i - 2, j))); + image->r(2 * i - 1, j) = MAX(0.f, -0.0625f * (red[j] + image->r(2 * i - 4, j)) + 0.5625f * (image->r(2 * i, j) + image->r(2 * i - 2, j))); + image->g(2 * i - 1, j) = MAX(0.f, -0.0625f * (green[j] + image->g(2 * i - 4, j)) + 0.5625f * (image->g(2 * i, j) + image->g(2 * i - 2, j))); + image->b(2 * i - 1, j) = MAX(0.f, -0.0625f * (blue[j] + image->b(2 * i - 4, j)) + 0.5625f * (image->b(2 * i, j) + image->b(2 * i - 2, j))); if (clip) { - image->r (2 * i - 1, j) = MIN (image->r (2 * i - 1, j), rtengine::MAXVALF); - image->g (2 * i - 1, j) = MIN (image->g (2 * i - 1, j), rtengine::MAXVALF); - image->b (2 * i - 1, j) = MIN (image->b (2 * i - 1, j), rtengine::MAXVALF); + image->r(2 * i - 1, j) = MIN(image->r(2 * i - 1, j), rtengine::MAXVALF); + image->g(2 * i - 1, j) = MIN(image->g(2 * i - 1, j), rtengine::MAXVALF); + image->b(2 * i - 1, j) = MIN(image->b(2 * i - 1, j), rtengine::MAXVALF); } - image->r (2 * i + 1, j) = (red[j] + image->r (2 * i - 1, j)) / 2; - image->g (2 * i + 1, j) = (green[j] + image->g (2 * i - 1, j)) / 2; - image->b (2 * i + 1, j) = (blue[j] + image->b (2 * i - 1, j)) / 2; + image->r(2 * i + 1, j) = (red[j] + image->r(2 * i - 1, j)) / 2; + image->g(2 * i + 1, j) = (green[j] + image->g(2 * i - 1, j)) / 2; + image->b(2 * i + 1, j) = (blue[j] + image->b(2 * i - 1, j)) / 2; if (oddHeight) { - image->r (2 * i + 2, j) = (red[j] + image->r (2 * i - 2, j)) / 2; - image->g (2 * i + 2, j) = (green[j] + image->g (2 * i - 2, j)) / 2; - image->b (2 * i + 2, j) = (blue[j] + image->b (2 * i - 2, j)) / 2; + image->r(2 * i + 2, j) = (red[j] + image->r(2 * i - 2, j)) / 2; + image->g(2 * i + 2, j) = (green[j] + image->g(2 * i - 2, j)) / 2; + image->b(2 * i + 2, j) = (blue[j] + image->b(2 * i - 2, j)) / 2; } } } @@ -422,25 +422,25 @@ extern const Settings* settings; #define ABS(a) ((a)<0?-(a):(a)) #define DIST(a,b) (ABS(a-b)) -RawImageSource::RawImageSource () +RawImageSource::RawImageSource() : ImageSource() - , W (0), H (0) - , plistener (nullptr) + , W(0), H(0) + , plistener(nullptr) , scale_mul{} , c_black{} , c_white{} , cblacksom{} , ref_pre_mul{} - , refwb_red (0.0) - , refwb_green (0.0) - , refwb_blue (0.0) + , refwb_red(0.0) + , refwb_green(0.0) + , refwb_blue(0.0) , rgb_cam{} , cam_rgb{} , xyz_cam{} , cam_xyz{} - , fuji (false) - , d1x (false) - , border (4) + , fuji(false) + , d1x(false) + , border(4) , chmax{} , hlmax{} , clmax{} @@ -468,14 +468,15 @@ RawImageSource::RawImageSource () camProfile = nullptr; embProfile = nullptr; rgbSourceModified = false; - for(int i = 0; i < 4; ++i) { + + for (int i = 0; i < 4; ++i) { psRedBrightness[i] = psGreenBrightness[i] = psBlueBrightness[i] = 1.f; } } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -RawImageSource::~RawImageSource () +RawImageSource::~RawImageSource() { delete idata; @@ -491,22 +492,22 @@ RawImageSource::~RawImageSource () flushRGB(); flushRawData(); - if ( cache ) { + if (cache) { delete [] cache; } if (camProfile) { - cmsCloseProfile (camProfile); + cmsCloseProfile(camProfile); } if (embProfile) { - cmsCloseProfile (embProfile); + cmsCloseProfile(embProfile); } } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -void RawImageSource::transformRect (const PreviewProps &pp, int tran, int &ssx1, int &ssy1, int &width, int &height, int &fw) +void RawImageSource::transformRect(const PreviewProps &pp, int tran, int &ssx1, int &ssy1, int &width, int &height, int &fw) { int pp_x = pp.getX() + border; int pp_y = pp.getY() + border; @@ -537,51 +538,51 @@ void RawImageSource::transformRect (const PreviewProps &pp, int tran, int &ssx1, sh = w; } - if ( pp_width > sw - 2 * border) { + if (pp_width > sw - 2 * border) { pp_width = sw - 2 * border; } - if ( pp_height > sh - 2 * border) { + if (pp_height > sh - 2 * border) { pp_height = sh - 2 * border; } int ppx = pp_x, ppy = pp_y; if (tran & TR_HFLIP) { - ppx = max (sw - pp_x - pp_width, 0); + ppx = max(sw - pp_x - pp_width, 0); } if (tran & TR_VFLIP) { - ppy = max (sh - pp_y - pp_height, 0); + ppy = max(sh - pp_y - pp_height, 0); } int sx1 = ppx; // assuming it's >=0 int sy1 = ppy; // assuming it's >=0 - int sx2 = min (ppx + pp_width, w - 1); - int sy2 = min (ppy + pp_height, h - 1); + int sx2 = min(ppx + pp_width, w - 1); + int sy2 = min(ppy + pp_height, h - 1); if ((tran & TR_ROT) == TR_R180) { - sx1 = max (w - ppx - pp_width, 0); - sy1 = max (h - ppy - pp_height, 0); - sx2 = min (sx1 + pp_width, w - 1); - sy2 = min (sy1 + pp_height, h - 1); + sx1 = max(w - ppx - pp_width, 0); + sy1 = max(h - ppy - pp_height, 0); + sx2 = min(sx1 + pp_width, w - 1); + sy2 = min(sy1 + pp_height, h - 1); } else if ((tran & TR_ROT) == TR_R90) { sx1 = ppy; - sy1 = max (h - ppx - pp_width, 0); - sx2 = min (sx1 + pp_height, w - 1); - sy2 = min (sy1 + pp_width, h - 1); + sy1 = max(h - ppx - pp_width, 0); + sx2 = min(sx1 + pp_height, w - 1); + sy2 = min(sy1 + pp_width, h - 1); } else if ((tran & TR_ROT) == TR_R270) { - sx1 = max (w - ppy - pp_height, 0); + sx1 = max(w - ppy - pp_height, 0); sy1 = ppx; - sx2 = min (sx1 + pp_height, w - 1); - sy2 = min (sy1 + pp_width, h - 1); + sx2 = min(sx1 + pp_height, w - 1); + sy2 = min(sy1 + pp_width, h - 1); } if (fuji) { // atszamoljuk a koordinatakat fuji-ra: // recalculate the coordinates fuji-ra: ssx1 = (sx1 + sy1) / 2; - ssy1 = (sy1 - sx2 ) / 2 + ri->get_FujiWidth(); + ssy1 = (sy1 - sx2) / 2 + ri->get_FujiWidth(); int ssx2 = (sx2 + sy2) / 2 + 1; int ssy2 = (sy2 - sx1) / 2 + ri->get_FujiWidth(); fw = (sx2 - sx1) / 2 / pp.getSkip(); @@ -595,7 +596,7 @@ void RawImageSource::transformRect (const PreviewProps &pp, int tran, int &ssx1, } } -float calculate_scale_mul (float scale_mul[4], const float pre_mul_[4], const float c_white[4], const float c_black[4], bool isMono, int colors) +float calculate_scale_mul(float scale_mul[4], const float pre_mul_[4], const float c_white[4], const float c_black[4], bool isMono, int colors) { if (isMono || colors == 1) { for (int c = 0; c < 4; c++) { @@ -612,22 +613,22 @@ float calculate_scale_mul (float scale_mul[4], const float pre_mul_[4], const fl pre_mul[3] = pre_mul[1]; // G2 == G1 } - float maxpremul = max (pre_mul[0], pre_mul[1], pre_mul[2], pre_mul[3]); + float maxpremul = max(pre_mul[0], pre_mul[1], pre_mul[2], pre_mul[3]); for (int c = 0; c < 4; c++) { scale_mul[c] = (pre_mul[c] / maxpremul) * 65535.0 / (c_white[c] - c_black[c]); } } - float gain = max (scale_mul[0], scale_mul[1], scale_mul[2], scale_mul[3]) / min (scale_mul[0], scale_mul[1], scale_mul[2], scale_mul[3]); + float gain = max(scale_mul[0], scale_mul[1], scale_mul[2], scale_mul[3]) / min(scale_mul[0], scale_mul[1], scale_mul[2], scale_mul[3]); return gain; } -void RawImageSource::getImage (const ColorTemp &ctemp, int tran, Imagefloat* image, const PreviewProps &pp, const ToneCurveParams &hrp, const RAWParams &raw ) +void RawImageSource::getImage(const ColorTemp &ctemp, int tran, Imagefloat* image, const PreviewProps &pp, const ToneCurveParams &hrp, const RAWParams &raw) { - MyMutex::MyLock lock (getImageMutex); + MyMutex::MyLock lock(getImageMutex); - tran = defTransform (tran); + tran = defTransform(tran); // compute channel multipliers double r, g, b; @@ -635,11 +636,11 @@ void RawImageSource::getImage (const ColorTemp &ctemp, int tran, Imagefloat* ima if (ctemp.getTemp() < 0) { // no white balance, ie revert the pre-process white balance to restore original unbalanced raw camera color - rm = ri->get_pre_mul (0); - gm = ri->get_pre_mul (1); - bm = ri->get_pre_mul (2); + rm = ri->get_pre_mul(0); + gm = ri->get_pre_mul(1); + bm = ri->get_pre_mul(2); } else { - ctemp.getMultipliers (r, g, b); + ctemp.getMultipliers(r, g, b); rm = imatrices.cam_rgb[0][0] * r + imatrices.cam_rgb[0][1] * g + imatrices.cam_rgb[0][2] * b; gm = imatrices.cam_rgb[1][0] * r + imatrices.cam_rgb[1][1] * g + imatrices.cam_rgb[1][2] * b; bm = imatrices.cam_rgb[2][0] * r + imatrices.cam_rgb[2][1] * g + imatrices.cam_rgb[2][2] * b; @@ -647,7 +648,7 @@ void RawImageSource::getImage (const ColorTemp &ctemp, int tran, Imagefloat* ima if (true) { // adjust gain so the maximum raw value of the least scaled channel just hits max - const float new_pre_mul[4] = { ri->get_pre_mul (0) / rm, ri->get_pre_mul (1) / gm, ri->get_pre_mul (2) / bm, ri->get_pre_mul (3) / gm }; + const float new_pre_mul[4] = { ri->get_pre_mul(0) / rm, ri->get_pre_mul(1) / gm, ri->get_pre_mul(2) / bm, ri->get_pre_mul(3) / gm }; float new_scale_mul[4]; bool isMono = (ri->getSensorType() == ST_FUJI_XTRANS && raw.xtranssensor.method == RAWParams::XTransSensor::getMethodString(RAWParams::XTransSensor::Method::MONO)) @@ -665,7 +666,7 @@ void RawImageSource::getImage (const ColorTemp &ctemp, int tran, Imagefloat* ima gm = refwb_green / gm; bm = refwb_blue / bm; // normalize so larger multiplier becomes 1.0 - float minval = min (rm, gm, bm); + float minval = min(rm, gm, bm); rm /= minval; gm /= minval; bm /= minval; @@ -678,7 +679,7 @@ void RawImageSource::getImage (const ColorTemp &ctemp, int tran, Imagefloat* ima defGain = 0.0; // compute image area to render in order to provide the requested part of the image int sx1, sy1, imwidth, imheight, fw, d1xHeightOdd = 0; - transformRect (pp, tran, sx1, sy1, imwidth, imheight, fw); + transformRect(pp, tran, sx1, sy1, imwidth, imheight, fw); // check possible overflows int maximwidth, maximheight; @@ -712,7 +713,7 @@ void RawImageSource::getImage (const ColorTemp &ctemp, int tran, Imagefloat* ima if (fuji) { // zero image to avoid access to uninitialized values in further processing because fuji super-ccd processing is not clean... for (int i = 0; i < image->getHeight(); ++i) { for (int j = 0; j < image->getWidth(); ++j) { - image->r (i, j) = image->g (i, j) = image->b (i, j) = 0; + image->r(i, j) = image->g(i, j) = image->b(i, j) = 0; } } } @@ -753,7 +754,7 @@ void RawImageSource::getImage (const ColorTemp &ctemp, int tran, Imagefloat* ima if (ri->getSensorType() == ST_BAYER || ri->getSensorType() == ST_FUJI_XTRANS || ri->get_colors() == 1) { for (int j = 0, jx = sx1; j < imwidth; j++, jx += skip) { - jx = std::min (jx, maxx - skip - 1); // avoid trouble + jx = std::min(jx, maxx - skip - 1); // avoid trouble float rtot = 0.f, gtot = 0.f, btot = 0.f; @@ -774,9 +775,9 @@ void RawImageSource::getImage (const ColorTemp &ctemp, int tran, Imagefloat* ima // are not clipped. We have to do that though as we only check pixel by pixel // and don't know if this will transition into a clipped area, if so we need // to clip also surrounding to make a good colour transition - rtot = CLIP (rtot); - gtot = CLIP (gtot); - btot = CLIP (btot); + rtot = CLIP(rtot); + gtot = CLIP(gtot); + btot = CLIP(btot); } line_red[j] = rtot; @@ -794,9 +795,9 @@ void RawImageSource::getImage (const ColorTemp &ctemp, int tran, Imagefloat* ima for (int m = 0; m < skip; m++) for (int n = 0; n < skip; n++) { - rtot += rawData[i + m][ (jx + n) * 3 + 0]; - gtot += rawData[i + m][ (jx + n) * 3 + 1]; - btot += rawData[i + m][ (jx + n) * 3 + 2]; + rtot += rawData[i + m][(jx + n) * 3 + 0]; + gtot += rawData[i + m][(jx + n) * 3 + 1]; + btot += rawData[i + m][(jx + n) * 3 + 2]; } rtot *= rm; @@ -804,9 +805,9 @@ void RawImageSource::getImage (const ColorTemp &ctemp, int tran, Imagefloat* ima btot *= bm; if (doClip) { - rtot = CLIP (rtot); - gtot = CLIP (gtot); - btot = CLIP (btot); + rtot = CLIP(rtot); + gtot = CLIP(gtot); + btot = CLIP(btot); } line_red[j] = rtot; @@ -818,15 +819,15 @@ void RawImageSource::getImage (const ColorTemp &ctemp, int tran, Imagefloat* ima //process all highlight recovery other than "Color" if (doHr) { - hlRecovery (hrp.method, line_red, line_grn, line_blue, imwidth, hlmax); + hlRecovery(hrp.method, line_red, line_grn, line_blue, imwidth, hlmax); } if (d1x) { - transLineD1x (line_red, line_grn, line_blue, ix, image, tran, imwidth, imheight, d1xHeightOdd, doClip); - } else if(fuji) { - transLineFuji (line_red, line_grn, line_blue, ix, image, tran, imheight, fw); + transLineD1x(line_red, line_grn, line_blue, ix, image, tran, imwidth, imheight, d1xHeightOdd, doClip); + } else if (fuji) { + transLineFuji(line_red, line_grn, line_blue, ix, image, tran, imheight, fw); } else { - transLineStandard (line_red, line_grn, line_blue, ix, image, tran, imwidth, imheight); + transLineStandard(line_red, line_grn, line_blue, ix, image, tran, imwidth, imheight); } } @@ -840,36 +841,36 @@ void RawImageSource::getImage (const ColorTemp &ctemp, int tran, Imagefloat* ima // first row for (int j = 1 + a; j < image->getWidth() - 1; j += 2) { - image->r (0, j) = (image->r (1, j) + image->r (0, j + 1) + image->r (0, j - 1)) / 3; - image->g (0, j) = (image->g (1, j) + image->g (0, j + 1) + image->g (0, j - 1)) / 3; - image->b (0, j) = (image->b (1, j) + image->b (0, j + 1) + image->b (0, j - 1)) / 3; + image->r(0, j) = (image->r(1, j) + image->r(0, j + 1) + image->r(0, j - 1)) / 3; + image->g(0, j) = (image->g(1, j) + image->g(0, j + 1) + image->g(0, j - 1)) / 3; + image->b(0, j) = (image->b(1, j) + image->b(0, j + 1) + image->b(0, j - 1)) / 3; } // other rows for (int i = 1; i < image->getHeight() - 1; i++) { for (int j = 2 - (a + i + 1) % 2; j < image->getWidth() - 1; j += 2) { // edge-adaptive interpolation - double dh = (ABS (image->r (i, j + 1) - image->r (i, j - 1)) + ABS (image->g (i, j + 1) - image->g (i, j - 1)) + ABS (image->b (i, j + 1) - image->b (i, j - 1))) / 1.0; - double dv = (ABS (image->r (i + 1, j) - image->r (i - 1, j)) + ABS (image->g (i + 1, j) - image->g (i - 1, j)) + ABS (image->b (i + 1, j) - image->b (i - 1, j))) / 1.0; + double dh = (ABS(image->r(i, j + 1) - image->r(i, j - 1)) + ABS(image->g(i, j + 1) - image->g(i, j - 1)) + ABS(image->b(i, j + 1) - image->b(i, j - 1))) / 1.0; + double dv = (ABS(image->r(i + 1, j) - image->r(i - 1, j)) + ABS(image->g(i + 1, j) - image->g(i - 1, j)) + ABS(image->b(i + 1, j) - image->b(i - 1, j))) / 1.0; double eh = 1.0 / (1.0 + dh); double ev = 1.0 / (1.0 + dv); - image->r (i, j) = (eh * (image->r (i, j + 1) + image->r (i, j - 1)) + ev * (image->r (i + 1, j) + image->r (i - 1, j))) / (2.0 * (eh + ev)); - image->g (i, j) = (eh * (image->g (i, j + 1) + image->g (i, j - 1)) + ev * (image->g (i + 1, j) + image->g (i - 1, j))) / (2.0 * (eh + ev)); - image->b (i, j) = (eh * (image->b (i, j + 1) + image->b (i, j - 1)) + ev * (image->b (i + 1, j) + image->b (i - 1, j))) / (2.0 * (eh + ev)); + image->r(i, j) = (eh * (image->r(i, j + 1) + image->r(i, j - 1)) + ev * (image->r(i + 1, j) + image->r(i - 1, j))) / (2.0 * (eh + ev)); + image->g(i, j) = (eh * (image->g(i, j + 1) + image->g(i, j - 1)) + ev * (image->g(i + 1, j) + image->g(i - 1, j))) / (2.0 * (eh + ev)); + image->b(i, j) = (eh * (image->b(i, j + 1) + image->b(i, j - 1)) + ev * (image->b(i + 1, j) + image->b(i - 1, j))) / (2.0 * (eh + ev)); } // first pixel if (2 - (a + i + 1) % 2 == 2) { - image->r (i, 0) = (image->r (i + 1, 0) + image->r (i - 1, 0) + image->r (i, 1)) / 3; - image->g (i, 0) = (image->g (i + 1, 0) + image->g (i - 1, 0) + image->g (i, 1)) / 3; - image->b (i, 0) = (image->b (i + 1, 0) + image->b (i - 1, 0) + image->b (i, 1)) / 3; + image->r(i, 0) = (image->r(i + 1, 0) + image->r(i - 1, 0) + image->r(i, 1)) / 3; + image->g(i, 0) = (image->g(i + 1, 0) + image->g(i - 1, 0) + image->g(i, 1)) / 3; + image->b(i, 0) = (image->b(i + 1, 0) + image->b(i - 1, 0) + image->b(i, 1)) / 3; } // last pixel if (2 - (a + i + image->getWidth()) % 2 == 2) { - image->r (i, image->getWidth() - 1) = (image->r (i + 1, image->getWidth() - 1) + image->r (i - 1, image->getWidth() - 1) + image->r (i, image->getWidth() - 2)) / 3; - image->g (i, image->getWidth() - 1) = (image->g (i + 1, image->getWidth() - 1) + image->g (i - 1, image->getWidth() - 1) + image->g (i, image->getWidth() - 2)) / 3; - image->b (i, image->getWidth() - 1) = (image->b (i + 1, image->getWidth() - 1) + image->b (i - 1, image->getWidth() - 1) + image->b (i, image->getWidth() - 2)) / 3; + image->r(i, image->getWidth() - 1) = (image->r(i + 1, image->getWidth() - 1) + image->r(i - 1, image->getWidth() - 1) + image->r(i, image->getWidth() - 2)) / 3; + image->g(i, image->getWidth() - 1) = (image->g(i + 1, image->getWidth() - 1) + image->g(i - 1, image->getWidth() - 1) + image->g(i, image->getWidth() - 2)) / 3; + image->b(i, image->getWidth() - 1) = (image->b(i + 1, image->getWidth() - 1) + image->b(i - 1, image->getWidth() - 1) + image->b(i, image->getWidth() - 2)) / 3; } } @@ -877,30 +878,30 @@ void RawImageSource::getImage (const ColorTemp &ctemp, int tran, Imagefloat* ima int b = (a == 1 && image->getHeight() % 2) || (a == 0 && image->getHeight() % 2 == 0); for (int j = 1 + b; j < image->getWidth() - 1; j += 2) { - image->r (image->getHeight() - 1, j) = (image->r (image->getHeight() - 2, j) + image->r (image->getHeight() - 1, j + 1) + image->r (image->getHeight() - 1, j - 1)) / 3; - image->g (image->getHeight() - 1, j) = (image->g (image->getHeight() - 2, j) + image->g (image->getHeight() - 1, j + 1) + image->g (image->getHeight() - 1, j - 1)) / 3; - image->b (image->getHeight() - 1, j) = (image->b (image->getHeight() - 2, j) + image->b (image->getHeight() - 1, j + 1) + image->b (image->getHeight() - 1, j - 1)) / 3; + image->r(image->getHeight() - 1, j) = (image->r(image->getHeight() - 2, j) + image->r(image->getHeight() - 1, j + 1) + image->r(image->getHeight() - 1, j - 1)) / 3; + image->g(image->getHeight() - 1, j) = (image->g(image->getHeight() - 2, j) + image->g(image->getHeight() - 1, j + 1) + image->g(image->getHeight() - 1, j - 1)) / 3; + image->b(image->getHeight() - 1, j) = (image->b(image->getHeight() - 2, j) + image->b(image->getHeight() - 1, j + 1) + image->b(image->getHeight() - 1, j - 1)) / 3; } } // Flip if needed if (tran & TR_HFLIP) { - hflip (image); + hflip(image); } if (tran & TR_VFLIP) { - vflip (image); + vflip(image); } // Colour correction (only when running on full resolution) if (pp.getSkip() == 1) { switch (ri->getSensorType()) { case ST_BAYER: - processFalseColorCorrection (image, raw.bayersensor.ccSteps); + processFalseColorCorrection(image, raw.bayersensor.ccSteps); break; case ST_FUJI_XTRANS: - processFalseColorCorrection (image, raw.xtranssensor.ccSteps); + processFalseColorCorrection(image, raw.xtranssensor.ccSteps); break; case ST_FOVEON: @@ -918,20 +919,20 @@ DCPProfile *RawImageSource::getDCP(const ColorManagementParams &cmp, DCPProfile: if (dcpProf == nullptr) { if (settings->verbose) { - printf ("Can't load DCP profile '%s'!\n", cmp.input.c_str()); + printf("Can't load DCP profile '%s'!\n", cmp.input.c_str()); } return nullptr; } - dcpProf->setStep2ApplyState (cmp.working, cmp.toneCurve, cmp.applyLookTable, cmp.applyBaselineExposureOffset, as); + dcpProf->setStep2ApplyState(cmp.working, cmp.toneCurve, cmp.applyLookTable, cmp.applyBaselineExposureOffset, as); return dcpProf; } -void RawImageSource::convertColorSpace (Imagefloat* image, const ColorManagementParams &cmp, const ColorTemp &wb) +void RawImageSource::convertColorSpace(Imagefloat* image, const ColorManagementParams &cmp, const ColorTemp &wb) { double pre_mul[3] = { ri->get_pre_mul(0), ri->get_pre_mul(1), ri->get_pre_mul(2) }; - colorSpaceConversion (image, cmp, wb, pre_mul, embProfile, camProfile, imatrices.xyz_cam, (static_cast(getMetaData()))->getCamera()); + colorSpaceConversion(image, cmp, wb, pre_mul, embProfile, camProfile, imatrices.xyz_cam, (static_cast(getMetaData()))->getCamera()); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -939,7 +940,7 @@ void RawImageSource::convertColorSpace (Imagefloat* image, const ColorManagement /* interpolateBadPixelsBayer: correct raw pixels looking at the bitmap * takes into consideration if there are multiple bad pixels in the neighbourhood */ -int RawImageSource::interpolateBadPixelsBayer ( PixelsMap &bitmapBads, array2D &rawData ) +int RawImageSource::interpolateBadPixelsBayer(PixelsMap &bitmapBads, array2D &rawData) { static const float eps = 1.f; int counter = 0; @@ -947,23 +948,23 @@ int RawImageSource::interpolateBadPixelsBayer ( PixelsMap &bitmapBads, array2D weighting is 0.70710678 // For green channel following pixels will be used for interpolation. Pixel to be interpolated is in centre. // 1 means that pixel is used in this step, if itself and his counterpart are not marked bad @@ -972,12 +973,12 @@ int RawImageSource::interpolateBadPixelsBayer ( PixelsMap &bitmapBads, array2D 0.f)) { // This means, we found at least one pair of valid pixels in the steps above, likelihood of this case is about 99.999% + if (LIKELY(norm > 0.f)) { // This means, we found at least one pair of valid pixels in the steps above, likelihood of this case is about 99.999% rawData[row][col] = wtdsum / (2.f * norm); //gradient weighted average, Factor of 2.f is an optimization to avoid multiplications in former steps counter++; } else { //backup plan -- simple average. Same method for all channels. We could improve this, but it's really unlikely that this case happens int tot = 0; float sum = 0; - for ( int dy = -2; dy <= 2; dy += 2) { - for ( int dx = -2; dx <= 2; dx += 2) { - if (bitmapBads.get (col + dx, row + dy)) { + for (int dy = -2; dy <= 2; dy += 2) { + for (int dx = -2; dx <= 2; dx += 2) { + if (bitmapBads.get(col + dx, row + dy)) { continue; } @@ -1056,7 +1057,7 @@ int RawImageSource::interpolateBadPixelsBayer ( PixelsMap &bitmapBads, array2D 0.f)) { // This means, we found at least one pair of valid pixels in the steps above, likelihood of this case is about 99.999% + if (LIKELY(norm[0] > 0.f)) { // This means, we found at least one pair of valid pixels in the steps above, likelihood of this case is about 99.999% for (int c = 0; c < colours; c++) { rawData[row][col * colours + c] = wtdsum[c] / (2.f * norm[c]); //gradient weighted average, Factor of 2.f is an optimization to avoid multiplications in former steps } @@ -1128,14 +1129,14 @@ int RawImageSource::interpolateBadPixelsNColours ( PixelsMap &bitmapBads, const sum[i] = 0.f; } - for ( int dy = -2; dy <= 2; dy += 2) { - for ( int dx = -2; dx <= 2; dx += 2) { - if (bitmapBads.get (col + dx, row + dy)) { + for (int dy = -2; dy <= 2; dy += 2) { + for (int dx = -2; dx <= 2; dx += 2) { + if (bitmapBads.get(col + dx, row + dy)) { continue; } for (int c = 0; c < colours; c++) { - sum[c] += rawData[row + dy][ (col + dx) * colours + c]; + sum[c] += rawData[row + dy][(col + dx) * colours + c]; } tot++; @@ -1158,7 +1159,7 @@ int RawImageSource::interpolateBadPixelsNColours ( PixelsMap &bitmapBads, const /* interpolateBadPixelsXtrans: correct raw pixels looking at the bitmap * takes into consideration if there are multiple bad pixels in the neighbourhood */ -int RawImageSource::interpolateBadPixelsXtrans ( PixelsMap &bitmapBads ) +int RawImageSource::interpolateBadPixelsXtrans(PixelsMap &bitmapBads) { static const float eps = 1.f; int counter = 0; @@ -1166,25 +1167,25 @@ int RawImageSource::interpolateBadPixelsXtrans ( PixelsMap &bitmapBads ) #pragma omp parallel for reduction(+:counter) schedule(dynamic,16) #endif - for ( int row = 2; row < H - 2; row++ ) { - for (int col = 2; col < W - 2; col++ ) { - int skip = bitmapBads.skipIfZero (col, row); //optimization for a stripe all zero + for (int row = 2; row < H - 2; row++) { + for (int col = 2; col < W - 2; col++) { + int skip = bitmapBads.skipIfZero(col, row); //optimization for a stripe all zero - if ( skip ) { + if (skip) { col += skip - 1; //-1 is because of col++ in cycle continue; } - if (!bitmapBads.get (col, row)) { + if (!bitmapBads.get(col, row)) { continue; } float wtdsum = 0.f, norm = 0.f; - unsigned int pixelColor = ri->XTRANSFC (row, col); + unsigned int pixelColor = ri->XTRANSFC(row, col); if (pixelColor == 1) { // green channel. A green pixel can either be a solitary green pixel or a member of a 2x2 square of green pixels - if (ri->XTRANSFC (row, col - 1) == ri->XTRANSFC (row, col + 1)) { + if (ri->XTRANSFC(row, col - 1) == ri->XTRANSFC(row, col + 1)) { // If left and right neighbour have same colour, then this is a solitary green pixel // For these the following pixels will be used for interpolation. Pixel to be interpolated is in centre and marked with a P. // Pairs of pixels used in this step are numbered. A pair will be used if none of the pixels of the pair is marked bad @@ -1194,32 +1195,32 @@ int RawImageSource::interpolateBadPixelsXtrans ( PixelsMap &bitmapBads ) // 0 0 P 0 0 // 4 6 0 5 3 // 0 2 0 1 0 - for ( int dx = -1; dx <= 1; dx += 2) { // pixels marked 5 or 6 in above example. Distance to P is sqrt(2) => weighting is 0.70710678f - if ( bitmapBads.get (col + dx, row - 1) || bitmapBads.get (col - dx, row + 1)) { + for (int dx = -1; dx <= 1; dx += 2) { // pixels marked 5 or 6 in above example. Distance to P is sqrt(2) => weighting is 0.70710678f + if (bitmapBads.get(col + dx, row - 1) || bitmapBads.get(col - dx, row + 1)) { continue; } - float dirwt = 0.70710678f / ( fabsf ( rawData[row - 1][col + dx] - rawData[row + 1][col - dx]) + eps); + float dirwt = 0.70710678f / (fabsf(rawData[row - 1][col + dx] - rawData[row + 1][col - dx]) + eps); wtdsum += dirwt * (rawData[row - 1][col + dx] + rawData[row + 1][col - dx]); norm += dirwt; } - for ( int dx = -1; dx <= 1; dx += 2) { // pixels marked 1 or 2 on above example. Distance to P is sqrt(5) => weighting is 0.44721359f - if ( bitmapBads.get (col + dx, row - 2) || bitmapBads.get (col - dx, row + 2)) { + for (int dx = -1; dx <= 1; dx += 2) { // pixels marked 1 or 2 on above example. Distance to P is sqrt(5) => weighting is 0.44721359f + if (bitmapBads.get(col + dx, row - 2) || bitmapBads.get(col - dx, row + 2)) { continue; } - float dirwt = 0.44721359f / ( fabsf ( rawData[row - 2][col + dx] - rawData[row + 2][col - dx]) + eps); + float dirwt = 0.44721359f / (fabsf(rawData[row - 2][col + dx] - rawData[row + 2][col - dx]) + eps); wtdsum += dirwt * (rawData[row - 2][col + dx] + rawData[row + 2][col - dx]); norm += dirwt; } - for ( int dx = -2; dx <= 2; dx += 4) { // pixels marked 3 or 4 on above example. Distance to P is sqrt(5) => weighting is 0.44721359f - if ( bitmapBads.get (col + dx, row - 1) || bitmapBads.get (col - dx, row + 1)) { + for (int dx = -2; dx <= 2; dx += 4) { // pixels marked 3 or 4 on above example. Distance to P is sqrt(5) => weighting is 0.44721359f + if (bitmapBads.get(col + dx, row - 1) || bitmapBads.get(col - dx, row + 1)) { continue; } - float dirwt = 0.44721359f / ( fabsf ( rawData[row - 1][col + dx] - rawData[row + 1][col - dx]) + eps); + float dirwt = 0.44721359f / (fabsf(rawData[row - 1][col + dx] - rawData[row + 1][col - dx]) + eps); wtdsum += dirwt * (rawData[row - 1][col + dx] + rawData[row + 1][col - dx]); norm += dirwt; } @@ -1234,20 +1235,20 @@ int RawImageSource::interpolateBadPixelsXtrans ( PixelsMap &bitmapBads ) // 3 0 0 0 // pixels marked 1 in above example. Distance to P is sqrt(2) => weighting is 0.70710678f - int offset1 = ri->XTRANSFC (row - 1, col - 1) == ri->XTRANSFC (row + 1, col + 1) ? 1 : -1; + int offset1 = ri->XTRANSFC(row - 1, col - 1) == ri->XTRANSFC(row + 1, col + 1) ? 1 : -1; - if ( ! (bitmapBads.get (col - offset1, row - 1) || bitmapBads.get (col + offset1, row + 1))) { - float dirwt = 0.70710678f / ( fabsf ( rawData[row - 1][col - offset1] - rawData[row + 1][col + offset1]) + eps); + if (!(bitmapBads.get(col - offset1, row - 1) || bitmapBads.get(col + offset1, row + 1))) { + float dirwt = 0.70710678f / (fabsf(rawData[row - 1][col - offset1] - rawData[row + 1][col + offset1]) + eps); wtdsum += dirwt * (rawData[row - 1][col - offset1] + rawData[row + 1][col + offset1]); norm += dirwt; } // pixels marked 2 in above example. Distance to P is 1 => weighting is 1.f - int offsety = (ri->XTRANSFC (row - 1, col) != 1 ? 1 : -1); + int offsety = (ri->XTRANSFC(row - 1, col) != 1 ? 1 : -1); int offsetx = offset1 * offsety; - if ( ! (bitmapBads.get (col + offsetx, row) || bitmapBads.get (col, row + offsety))) { - float dirwt = 1.f / ( fabsf ( rawData[row][col + offsetx] - rawData[row + offsety][col]) + eps); + if (!(bitmapBads.get(col + offsetx, row) || bitmapBads.get(col, row + offsety))) { + float dirwt = 1.f / (fabsf(rawData[row][col + offsetx] - rawData[row + offsety][col]) + eps); wtdsum += dirwt * (rawData[row][col + offsetx] + rawData[row + offsety][col]); norm += dirwt; } @@ -1258,8 +1259,8 @@ int RawImageSource::interpolateBadPixelsXtrans ( PixelsMap &bitmapBads ) offsety *= 2; // pixels marked 3 in above example. Distance to P is sqrt(5) => weighting is 0.44721359f - if ( ! (bitmapBads.get (col + offsetx, row + offsety2) || bitmapBads.get (col + offsetx2, row + offsety))) { - float dirwt = 0.44721359f / ( fabsf ( rawData[row + offsety2][col + offsetx] - rawData[row + offsety][col + offsetx2]) + eps); + if (!(bitmapBads.get(col + offsetx, row + offsety2) || bitmapBads.get(col + offsetx2, row + offsety))) { + float dirwt = 0.44721359f / (fabsf(rawData[row + offsety2][col + offsetx] - rawData[row + offsety][col + offsetx2]) + eps); wtdsum += dirwt * (rawData[row + offsety2][col + offsetx] + rawData[row + offsety][col + offsetx2]); norm += dirwt; } @@ -1284,9 +1285,9 @@ int RawImageSource::interpolateBadPixelsXtrans ( PixelsMap &bitmapBads ) // The following loop simply scans the four possible places. To keep things simple, it does not stop after finding two knight pixels, because it will not find more than two for (int d1 = -2, offsety = 3; d1 <= 2; d1 += 4, offsety -= 6) { for (int d2 = -1, offsetx = 3; d2 < 1; d2 += 2, offsetx -= 6) { - if (ri->XTRANSFC (row + d1, col + d2) == pixelColor) { - if ( ! (bitmapBads.get (col + d2, row + d1) || bitmapBads.get (col + d2 + offsetx, row + d1 + offsety))) { - float dirwt = 0.44721359f / ( fabsf ( rawData[row + d1][col + d2] - rawData[row + d1 + offsety][col + d2 + offsetx]) + eps); + if (ri->XTRANSFC(row + d1, col + d2) == pixelColor) { + if (!(bitmapBads.get(col + d2, row + d1) || bitmapBads.get(col + d2 + offsetx, row + d1 + offsety))) { + float dirwt = 0.44721359f / (fabsf(rawData[row + d1][col + d2] - rawData[row + d1 + offsety][col + d2 + offsetx]) + eps); wtdsum += dirwt * (rawData[row + d1][col + d2] + rawData[row + d1 + offsety][col + d2 + offsetx]); norm += dirwt; } @@ -1300,7 +1301,7 @@ int RawImageSource::interpolateBadPixelsXtrans ( PixelsMap &bitmapBads ) // check horizontal for (dx = -2, dy = 0; dx <= 2 && !distance2PixelFound; dx += 4) - if (ri->XTRANSFC (row, col + dx) == pixelColor) { + if (ri->XTRANSFC(row, col + dx) == pixelColor) { distance2PixelFound = true; } @@ -1308,7 +1309,7 @@ int RawImageSource::interpolateBadPixelsXtrans ( PixelsMap &bitmapBads ) // no distance 2 pixel on horizontal, check vertical for (dx = 0, dy = -2; dy <= 2 && !distance2PixelFound; dy += 4) - if (ri->XTRANSFC (row + dy, col) == pixelColor) { + if (ri->XTRANSFC(row + dy, col) == pixelColor) { distance2PixelFound = true; } @@ -1322,12 +1323,12 @@ int RawImageSource::interpolateBadPixelsXtrans ( PixelsMap &bitmapBads ) } // and weight as usual. Distance to P is 2 => weighting is 0.5f - float dirwt = 0.5f / ( fabsf ( virtualPixel - rawData[row + dy][col + dx]) + eps); + float dirwt = 0.5f / (fabsf(virtualPixel - rawData[row + dy][col + dx]) + eps); wtdsum += dirwt * (virtualPixel + rawData[row + dy][col + dx]); norm += dirwt; } - if (LIKELY (norm > 0.f)) { // This means, we found at least one pair of valid pixels in the steps above, likelihood of this case is about 99.999% + if (LIKELY(norm > 0.f)) { // This means, we found at least one pair of valid pixels in the steps above, likelihood of this case is about 99.999% rawData[row][col] = wtdsum / (2.f * norm); //gradient weighted average, Factor of 2.f is an optimization to avoid multiplications in former steps counter++; } @@ -1343,13 +1344,13 @@ int RawImageSource::interpolateBadPixelsXtrans ( PixelsMap &bitmapBads ) * (Taken from Emil Martinec idea) * (Optimized by Ingo Weyrich 2013 and 2015) */ -SSEFUNCTION int RawImageSource::findHotDeadPixels ( PixelsMap &bpMap, float thresh, bool findHotPixels, bool findDeadPixels ) +SSEFUNCTION int RawImageSource::findHotDeadPixels(PixelsMap &bpMap, float thresh, bool findHotPixels, bool findDeadPixels) { - float varthresh = (20.0 * (thresh / 100.0) + 1.0 ) / 24.f; + float varthresh = (20.0 * (thresh / 100.0) + 1.0) / 24.f; // allocate temporary buffer float (*cfablur); - cfablur = (float (*)) malloc (H * W * sizeof * cfablur); + cfablur = (float (*)) malloc(H * W * sizeof * cfablur); // counter for dead or hot pixels int counter = 0; @@ -1364,9 +1365,9 @@ SSEFUNCTION int RawImageSource::findHotDeadPixels ( PixelsMap &bpMap, float thre for (int i = 2; i < H - 2; i++) { for (int j = 2; j < W - 2; j++) { - const float& temp = median (rawData[i - 2][j - 2], rawData[i - 2][j], rawData[i - 2][j + 2], - rawData[i][j - 2], rawData[i][j], rawData[i][j + 2], - rawData[i + 2][j - 2], rawData[i + 2][j], rawData[i + 2][j + 2]); + const float& temp = median(rawData[i - 2][j - 2], rawData[i - 2][j], rawData[i - 2][j + 2], + rawData[i][j - 2], rawData[i][j], rawData[i][j + 2], + rawData[i + 2][j - 2], rawData[i + 2][j], rawData[i + 2][j + 2]); cfablur[i * W + j] = rawData[i][j] - temp; } } @@ -1425,22 +1426,22 @@ SSEFUNCTION int RawImageSource::findHotDeadPixels ( PixelsMap &bpMap, float thre continue; } - pixdev = fabsf (pixdev); + pixdev = fabsf(pixdev); float hfnbrave = -pixdev; #ifdef __SSE2__ // sum up 5*4 = 20 values using SSE // 10 fabs function calls and float 10 additions with SSE - vfloat sum = vabsf (LVFU (cfablur[ (rr - 2) * W + cc - 2])) + vabsf (LVFU (cfablur[ (rr - 1) * W + cc - 2])); - sum += vabsf (LVFU (cfablur[ (rr) * W + cc - 2])); - sum += vabsf (LVFU (cfablur[ (rr + 1) * W + cc - 2])); - sum += vabsf (LVFU (cfablur[ (rr + 2) * W + cc - 2])); + vfloat sum = vabsf(LVFU(cfablur[(rr - 2) * W + cc - 2])) + vabsf(LVFU(cfablur[(rr - 1) * W + cc - 2])); + sum += vabsf(LVFU(cfablur[(rr) * W + cc - 2])); + sum += vabsf(LVFU(cfablur[(rr + 1) * W + cc - 2])); + sum += vabsf(LVFU(cfablur[(rr + 2) * W + cc - 2])); // horizontally add the values and add the result to hfnbrave - hfnbrave += vhadd (sum); + hfnbrave += vhadd(sum); // add remaining 5 values of last column for (int mm = rr - 2; mm <= rr + 2; mm++) { - hfnbrave += fabsf (cfablur[mm * W + cc + 2]); + hfnbrave += fabsf(cfablur[mm * W + cc + 2]); } #else @@ -1448,7 +1449,7 @@ SSEFUNCTION int RawImageSource::findHotDeadPixels ( PixelsMap &bpMap, float thre // 25 fabs function calls and 25 float additions without SSE for (int mm = rr - 2; mm <= rr + 2; mm++) { for (int nn = cc - 2; nn <= cc + 2; nn++) { - hfnbrave += fabsf (cfablur[mm * W + nn]); + hfnbrave += fabsf(cfablur[mm * W + nn]); } } @@ -1456,22 +1457,22 @@ SSEFUNCTION int RawImageSource::findHotDeadPixels ( PixelsMap &bpMap, float thre if (pixdev > varthresh * hfnbrave) { // mark the pixel as "bad" - bpMap.set (cc, rr); + bpMap.set(cc, rr); counter++; } }//end of pixel evaluation } }//end of parallel processing - free (cfablur); + free(cfablur); return counter; } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -void RawImageSource::getFullSize (int& w, int& h, int tr) +void RawImageSource::getFullSize(int& w, int& h, int tr) { - tr = defTransform (tr); + tr = defTransform(tr); if (fuji) { w = ri->get_FujiWidth() * 2 + 1; @@ -1496,7 +1497,7 @@ void RawImageSource::getFullSize (int& w, int& h, int tr) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -void RawImageSource::getSize (const PreviewProps &pp, int& w, int& h) +void RawImageSource::getSize(const PreviewProps &pp, int& w, int& h) { w = pp.getWidth() / pp.getSkip() + (pp.getWidth() % pp.getSkip() > 0); h = pp.getHeight() / pp.getSkip() + (pp.getHeight() % pp.getSkip() > 0); @@ -1504,14 +1505,14 @@ void RawImageSource::getSize (const PreviewProps &pp, int& w, int& h) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -void RawImageSource::hflip (Imagefloat* image) +void RawImageSource::hflip(Imagefloat* image) { image->hflip(); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -void RawImageSource::vflip (Imagefloat* image) +void RawImageSource::vflip(Imagefloat* image) { image->vflip(); } @@ -1519,7 +1520,7 @@ void RawImageSource::vflip (Imagefloat* image) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -int RawImageSource::load (const Glib::ustring &fname) +int RawImageSource::load(const Glib::ustring &fname) { MyTime t1, t2; @@ -1527,12 +1528,12 @@ int RawImageSource::load (const Glib::ustring &fname) fileName = fname; if (plistener) { - plistener->setProgressStr ("Decoding..."); - plistener->setProgress (0.0); + plistener->setProgressStr("Decoding..."); + plistener->setProgress(0.0); } - ri = new RawImage (fname); - int errCode = ri->loadRaw (false, 0, false); + ri = new RawImage(fname); + int errCode = ri->loadRaw(false, 0, false); if (errCode) { return errCode; @@ -1556,10 +1557,10 @@ int RawImageSource::load (const Glib::ustring &fname) { if (i == 0) { riFrames[i] = ri; - errCodeThr = riFrames[i]->loadRaw (true, i, true, plistener, 0.8); + errCodeThr = riFrames[i]->loadRaw(true, i, true, plistener, 0.8); } else { - riFrames[i] = new RawImage (fname); - errCodeThr = riFrames[i]->loadRaw (true, i); + riFrames[i] = new RawImage(fname); + errCodeThr = riFrames[i]->loadRaw(true, i); } } @@ -1572,25 +1573,25 @@ int RawImageSource::load (const Glib::ustring &fname) } } else { riFrames[0] = ri; - errCode = riFrames[0]->loadRaw (true, 0, true, plistener, 0.8); + errCode = riFrames[0]->loadRaw(true, 0, true, plistener, 0.8); } if (!errCode) { for (unsigned int i = 0; i < numFrames; ++i) { - riFrames[i]->compress_image (i); + riFrames[i]->compress_image(i); } } else { return errCode; } - if (numFrames > 1 ) { // this disables multi frame support for Fuji S5 until I found a solution to handle different dimensions + if (numFrames > 1) { // this disables multi frame support for Fuji S5 until I found a solution to handle different dimensions if (riFrames[0]->get_width() != riFrames[1]->get_width() || riFrames[0]->get_height() != riFrames[1]->get_height()) { numFrames = 1; } } if (plistener) { - plistener->setProgress (0.9); + plistener->setProgress(0.9); } /***** Copy once constant data extracted from raw *******/ @@ -1600,14 +1601,14 @@ int RawImageSource::load (const Glib::ustring &fname) for (int i = 0; i < 3; i++) for (int j = 0; j < 3; j++) { - imatrices.rgb_cam[i][j] = ri->get_rgb_cam (i, j); + imatrices.rgb_cam[i][j] = ri->get_rgb_cam(i, j); } // compute inverse of the color transformation matrix // first arg is matrix, second arg is inverse - inverse33 (imatrices.rgb_cam, imatrices.cam_rgb); + inverse33(imatrices.rgb_cam, imatrices.cam_rgb); - d1x = ! ri->get_model().compare ("D1X"); + d1x = ! ri->get_model().compare("D1X"); if (ri->getSensorType() == ST_FUJI_XTRANS) { border = 7; @@ -1615,12 +1616,12 @@ int RawImageSource::load (const Glib::ustring &fname) border = 0; } - if ( ri->get_profile() ) { - embProfile = cmsOpenProfileFromMem (ri->get_profile(), ri->get_profileLen()); + if (ri->get_profile()) { + embProfile = cmsOpenProfileFromMem(ri->get_profile(), ri->get_profileLen()); } // create profile - memset (imatrices.xyz_cam, 0, sizeof (imatrices.xyz_cam)); + memset(imatrices.xyz_cam, 0, sizeof(imatrices.xyz_cam)); for (int i = 0; i < 3; i++) for (int j = 0; j < 3; j++) @@ -1628,46 +1629,46 @@ int RawImageSource::load (const Glib::ustring &fname) imatrices.xyz_cam[i][j] += xyz_sRGB[i][k] * imatrices.rgb_cam[k][j]; } - camProfile = ICCStore::getInstance()->createFromMatrix (imatrices.xyz_cam, false, "Camera"); - inverse33 (imatrices.xyz_cam, imatrices.cam_xyz); + camProfile = ICCStore::getInstance()->createFromMatrix(imatrices.xyz_cam, false, "Camera"); + inverse33(imatrices.xyz_cam, imatrices.cam_xyz); for (int c = 0; c < 4; c++) { - c_white[c] = ri->get_white (c); + c_white[c] = ri->get_white(c); } // First we get the "as shot" ("Camera") white balance and store it float pre_mul[4]; // FIXME: get_colorsCoeff not so much used nowadays, when we have calculate_scale_mul() function here - ri->get_colorsCoeff ( pre_mul, scale_mul, c_black, false); //modify for black level - camInitialGain = max (scale_mul[0], scale_mul[1], scale_mul[2], scale_mul[3]) / min (scale_mul[0], scale_mul[1], scale_mul[2], scale_mul[3]); + ri->get_colorsCoeff(pre_mul, scale_mul, c_black, false); //modify for black level + camInitialGain = max(scale_mul[0], scale_mul[1], scale_mul[2], scale_mul[3]) / min(scale_mul[0], scale_mul[1], scale_mul[2], scale_mul[3]); - double camwb_red = ri->get_pre_mul (0) / pre_mul[0]; - double camwb_green = ri->get_pre_mul (1) / pre_mul[1]; - double camwb_blue = ri->get_pre_mul (2) / pre_mul[2]; + double camwb_red = ri->get_pre_mul(0) / pre_mul[0]; + double camwb_green = ri->get_pre_mul(1) / pre_mul[1]; + double camwb_blue = ri->get_pre_mul(2) / pre_mul[2]; double cam_r = imatrices.rgb_cam[0][0] * camwb_red + imatrices.rgb_cam[0][1] * camwb_green + imatrices.rgb_cam[0][2] * camwb_blue; double cam_g = imatrices.rgb_cam[1][0] * camwb_red + imatrices.rgb_cam[1][1] * camwb_green + imatrices.rgb_cam[1][2] * camwb_blue; double cam_b = imatrices.rgb_cam[2][0] * camwb_red + imatrices.rgb_cam[2][1] * camwb_green + imatrices.rgb_cam[2][2] * camwb_blue; - camera_wb = ColorTemp (cam_r, cam_g, cam_b, 1.); // as shot WB + camera_wb = ColorTemp(cam_r, cam_g, cam_b, 1.); // as shot WB ColorTemp ReferenceWB; double ref_r, ref_g, ref_b; { // ...then we re-get the constants but now with auto which gives us better demosaicing and CA auto-correct // performance for strange white balance settings (such as UniWB) - ri->get_colorsCoeff ( ref_pre_mul, scale_mul, c_black, true); - refwb_red = ri->get_pre_mul (0) / ref_pre_mul[0]; - refwb_green = ri->get_pre_mul (1) / ref_pre_mul[1]; - refwb_blue = ri->get_pre_mul (2) / ref_pre_mul[2]; - initialGain = max (scale_mul[0], scale_mul[1], scale_mul[2], scale_mul[3]) / min (scale_mul[0], scale_mul[1], scale_mul[2], scale_mul[3]); + ri->get_colorsCoeff(ref_pre_mul, scale_mul, c_black, true); + refwb_red = ri->get_pre_mul(0) / ref_pre_mul[0]; + refwb_green = ri->get_pre_mul(1) / ref_pre_mul[1]; + refwb_blue = ri->get_pre_mul(2) / ref_pre_mul[2]; + initialGain = max(scale_mul[0], scale_mul[1], scale_mul[2], scale_mul[3]) / min(scale_mul[0], scale_mul[1], scale_mul[2], scale_mul[3]); ref_r = imatrices.rgb_cam[0][0] * refwb_red + imatrices.rgb_cam[0][1] * refwb_green + imatrices.rgb_cam[0][2] * refwb_blue; ref_g = imatrices.rgb_cam[1][0] * refwb_red + imatrices.rgb_cam[1][1] * refwb_green + imatrices.rgb_cam[1][2] * refwb_blue; ref_b = imatrices.rgb_cam[2][0] * refwb_red + imatrices.rgb_cam[2][1] * refwb_green + imatrices.rgb_cam[2][2] * refwb_blue; - ReferenceWB = ColorTemp (ref_r, ref_g, ref_b, 1.); + ReferenceWB = ColorTemp(ref_r, ref_g, ref_b, 1.); } if (settings->verbose) { - printf ("Raw As Shot White balance: temp %f, tint %f\n", camera_wb.getTemp(), camera_wb.getGreen()); - printf ("Raw Reference (auto) white balance: temp %f, tint %f, multipliers [%f %f %f | %f %f %f]\n", ReferenceWB.getTemp(), ReferenceWB.getGreen(), ref_r, ref_g, ref_b, refwb_red, refwb_blue, refwb_green); + printf("Raw As Shot White balance: temp %f, tint %f\n", camera_wb.getTemp(), camera_wb.getGreen()); + printf("Raw Reference (auto) white balance: temp %f, tint %f, multipliers [%f %f %f | %f %f %f]\n", ReferenceWB.getTemp(), ReferenceWB.getGreen(), ref_r, ref_g, ref_b, refwb_red, refwb_blue, refwb_green); } /*{ @@ -1706,9 +1707,9 @@ int RawImageSource::load (const Glib::ustring &fname) // Load complete Exif informations - std::unique_ptr rml(new RawMetaDataLocation (ri->get_exifBase(), ri->get_ciffBase(), ri->get_ciffLen())); - idata = new FramesData (fname, std::move(rml)); - idata->setDCRawFrameCount (numFrames); + std::unique_ptr rml(new RawMetaDataLocation(ri->get_exifBase(), ri->get_ciffBase(), ri->get_ciffLen())); + idata = new FramesData(fname, std::move(rml)); + idata->setDCRawFrameCount(numFrames); green(W, H); red(W, H); @@ -1716,14 +1717,14 @@ int RawImageSource::load (const Glib::ustring &fname) //hpmap = allocArray(W, H); if (plistener) { - plistener->setProgress (1.0); + plistener->setProgress(1.0); } plistener = nullptr; // This must be reset, because only load() is called through progressConnector t2.set(); - if ( settings->verbose ) { - printf ("Load %s: %d usec\n", fname.c_str(), t2.etime (t1)); + if (settings->verbose) { + printf("Load %s: %d usec\n", fname.c_str(), t2.etime(t1)); } return 0; // OK! @@ -1731,7 +1732,7 @@ int RawImageSource::load (const Glib::ustring &fname) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -void RawImageSource::preprocess (const RAWParams &raw, const LensProfParams &lensProf, const CoarseTransformParams& coarse, bool prepareDenoise) +void RawImageSource::preprocess(const RAWParams &raw, const LensProfParams &lensProf, const CoarseTransformParams& coarse, bool prepareDenoise) { // BENCHFUN MyTime t1, t2; @@ -1741,15 +1742,15 @@ void RawImageSource::preprocess (const RAWParams &raw, const LensProfParams &le RawImage *rid = nullptr; if (!raw.df_autoselect) { - if ( !raw.dark_frame.empty()) { - rid = dfm.searchDarkFrame ( raw.dark_frame ); + if (!raw.dark_frame.empty()) { + rid = dfm.searchDarkFrame(raw.dark_frame); } } else { - rid = dfm.searchDarkFrame (idata->getMake(), idata->getModel(), idata->getISOSpeed(), idata->getShutterSpeed(), idata->getDateTimeAsTS()); + rid = dfm.searchDarkFrame(idata->getMake(), idata->getModel(), idata->getISOSpeed(), idata->getShutterSpeed(), idata->getDateTimeAsTS()); } - if ( rid && settings->verbose) { - printf ( "Subtracting Darkframe:%s\n", rid->get_filename().c_str()); + if (rid && settings->verbose) { + printf("Subtracting Darkframe:%s\n", rid->get_filename().c_str()); } PixelsMap *bitmapBads = nullptr; @@ -1757,7 +1758,7 @@ void RawImageSource::preprocess (const RAWParams &raw, const LensProfParams &le int totBP = 0; // Hold count of bad pixels to correct if (ri->zeroIsBad()) { // mark all pixels with value zero as bad, has to be called before FF and DF. dcraw sets this flag only for some cameras (mainly Panasonic and Leica) - bitmapBads = new PixelsMap (W, H); + bitmapBads = new PixelsMap(W, H); #ifdef _OPENMP #pragma omp parallel for reduction(+:totBP) schedule(dynamic,16) #endif @@ -1765,13 +1766,13 @@ void RawImageSource::preprocess (const RAWParams &raw, const LensProfParams &le for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) { if (ri->data[i][j] == 0.f) { - bitmapBads->set (j, i); + bitmapBads->set(j, i); totBP++; } } - if ( settings->verbose) { - printf ( "%d pixels with value zero marked as bad pixels\n", totBP); + if (settings->verbose) { + printf("%d pixels with value zero marked as bad pixels\n", totBP); } } @@ -1779,18 +1780,18 @@ void RawImageSource::preprocess (const RAWParams &raw, const LensProfParams &le RawImage *rif = nullptr; if (!raw.ff_AutoSelect) { - if ( !raw.ff_file.empty()) { - rif = ffm.searchFlatField ( raw.ff_file ); + if (!raw.ff_file.empty()) { + rif = ffm.searchFlatField(raw.ff_file); } } else { - rif = ffm.searchFlatField ( idata->getMake(), idata->getModel(), idata->getLens(), idata->getFocalLen(), idata->getFNumber(), idata->getDateTimeAsTS()); + rif = ffm.searchFlatField(idata->getMake(), idata->getModel(), idata->getLens(), idata->getFocalLen(), idata->getFNumber(), idata->getDateTimeAsTS()); } bool hasFlatField = (rif != nullptr); - if ( hasFlatField && settings->verbose) { - printf ( "Flat Field Correction:%s\n", rif->get_filename().c_str()); + if (hasFlatField && settings->verbose) { + printf("Flat Field Correction:%s\n", rif->get_filename().c_str()); } if (numFrames == 4) { @@ -1798,7 +1799,7 @@ void RawImageSource::preprocess (const RAWParams &raw, const LensProfParams &le for (unsigned int i = 0; i < 4; ++i) { if (i == currFrame) { - copyOriginalPixels (raw, ri, rid, rif, rawData); + copyOriginalPixels(raw, ri, rid, rif, rawData); rawDataFrames[i] = &rawData; } else { if (!rawDataBuffer[bufferNumber]) { @@ -1807,27 +1808,27 @@ void RawImageSource::preprocess (const RAWParams &raw, const LensProfParams &le rawDataFrames[i] = rawDataBuffer[bufferNumber]; ++bufferNumber; - copyOriginalPixels (raw, riFrames[i], rid, rif, *rawDataFrames[i]); + copyOriginalPixels(raw, riFrames[i], rid, rif, *rawDataFrames[i]); } } } else { - copyOriginalPixels (raw, ri, rid, rif, rawData); + copyOriginalPixels(raw, ri, rid, rif, rawData); } //FLATFIELD end // Always correct camera badpixels from .badpixels file - std::vector *bp = dfm.getBadPixels ( ri->get_maker(), ri->get_model(), idata->getSerialNumber() ); + std::vector *bp = dfm.getBadPixels(ri->get_maker(), ri->get_model(), idata->getSerialNumber()); - if ( bp ) { + if (bp) { if (!bitmapBads) { - bitmapBads = new PixelsMap (W, H); + bitmapBads = new PixelsMap(W, H); } - totBP += bitmapBads->set ( *bp ); + totBP += bitmapBads->set(*bp); - if ( settings->verbose ) { + if (settings->verbose) { std::cout << "Correcting " << bp->size() << " pixels from .badpixels" << std::endl; } } @@ -1835,35 +1836,36 @@ void RawImageSource::preprocess (const RAWParams &raw, const LensProfParams &le // If darkframe selected, correct hotpixels found on darkframe bp = nullptr; - if ( raw.df_autoselect ) { - bp = dfm.getHotPixels (idata->getMake(), idata->getModel(), idata->getISOSpeed(), idata->getShutterSpeed(), idata->getDateTimeAsTS()); - } else if ( !raw.dark_frame.empty() ) { - bp = dfm.getHotPixels ( raw.dark_frame ); + if (raw.df_autoselect) { + bp = dfm.getHotPixels(idata->getMake(), idata->getModel(), idata->getISOSpeed(), idata->getShutterSpeed(), idata->getDateTimeAsTS()); + } else if (!raw.dark_frame.empty()) { + bp = dfm.getHotPixels(raw.dark_frame); } if (bp) { if (!bitmapBads) { - bitmapBads = new PixelsMap (W, H); + bitmapBads = new PixelsMap(W, H); } - totBP += bitmapBads->set ( *bp ); + totBP += bitmapBads->set(*bp); - if ( settings->verbose && !bp->empty()) { + if (settings->verbose && !bp->empty()) { std::cout << "Correcting " << bp->size() << " hotpixels from darkframe" << std::endl; } } if (numFrames == 4) { for (int i = 0; i < 4; ++i) { - scaleColors ( 0, 0, W, H, raw, *rawDataFrames[i]); + scaleColors(0, 0, W, H, raw, *rawDataFrames[i]); } } else { - scaleColors ( 0, 0, W, H, raw, rawData); //+ + raw parameters for black level(raw.blackxx) + scaleColors(0, 0, W, H, raw, rawData); //+ + raw parameters for black level(raw.blackxx) } // Correct vignetting of lens profile if (!hasFlatField && lensProf.useVign) { std::unique_ptr pmap; + if (lensProf.useLensfun()) { pmap = LFDatabase::findModifier(lensProf, idata, W, H, coarse, -1); } else { @@ -1876,6 +1878,7 @@ void RawImageSource::preprocess (const RAWParams &raw, const LensProfParams &le if (pmap) { LensCorrection &map = *pmap; + if (ri->getSensorType() == ST_BAYER || ri->getSensorType() == ST_FUJI_XTRANS || ri->get_colors() == 1) { if (numFrames == 4) { for (int i = 0; i < 4; ++i) { @@ -1884,7 +1887,7 @@ void RawImageSource::preprocess (const RAWParams &raw, const LensProfParams &le #endif for (int y = 0; y < H; y++) { - map.processVignetteLine (W, y, (*rawDataFrames[i])[y]); + map.processVignetteLine(W, y, (*rawDataFrames[i])[y]); } } } else { @@ -1894,7 +1897,7 @@ void RawImageSource::preprocess (const RAWParams &raw, const LensProfParams &le #endif for (int y = 0; y < H; y++) { - map.processVignetteLine (W, y, rawData[y]); + map.processVignetteLine(W, y, rawData[y]); } } } else if (ri->get_colors() == 3) { @@ -1903,7 +1906,7 @@ void RawImageSource::preprocess (const RAWParams &raw, const LensProfParams &le #endif for (int y = 0; y < H; y++) { - map.processVignetteLine3Channels (W, y, rawData[y]); + map.processVignetteLine3Channels(W, y, rawData[y]); } } } @@ -1911,29 +1914,29 @@ void RawImageSource::preprocess (const RAWParams &raw, const LensProfParams &le defGain = 0.0;//log(initialGain) / log(2.0); - if ( ri->getSensorType() == ST_BAYER && (raw.hotPixelFilter > 0 || raw.deadPixelFilter > 0)) { + if (ri->getSensorType() == ST_BAYER && (raw.hotPixelFilter > 0 || raw.deadPixelFilter > 0)) { if (plistener) { - plistener->setProgressStr ("Hot/Dead Pixel Filter..."); - plistener->setProgress (0.0); + plistener->setProgressStr("Hot/Dead Pixel Filter..."); + plistener->setProgress(0.0); } if (!bitmapBads) { - bitmapBads = new PixelsMap (W, H); + bitmapBads = new PixelsMap(W, H); } - int nFound = findHotDeadPixels ( *bitmapBads, raw.hotdeadpix_thresh, raw.hotPixelFilter, raw.deadPixelFilter ); + int nFound = findHotDeadPixels(*bitmapBads, raw.hotdeadpix_thresh, raw.hotPixelFilter, raw.deadPixelFilter); totBP += nFound; - if ( settings->verbose && nFound > 0) { - printf ( "Correcting %d hot/dead pixels found inside image\n", nFound ); + if (settings->verbose && nFound > 0) { + printf("Correcting %d hot/dead pixels found inside image\n", nFound); } } // check if it is an olympus E camera or green equilibration is enabled. If yes, compute G channel pre-compensation factors - if ( ri->getSensorType() == ST_BAYER && (raw.bayersensor.greenthresh || (((idata->getMake().size() >= 7 && idata->getMake().substr(0, 7) == "OLYMPUS" && idata->getModel()[0] == 'E') || (idata->getMake().size() >= 9 && idata->getMake().substr(0, 9) == "Panasonic")) && raw.bayersensor.method != RAWParams::BayerSensor::getMethodString( RAWParams::BayerSensor::Method::VNG4))) ) { + if (ri->getSensorType() == ST_BAYER && (raw.bayersensor.greenthresh || (((idata->getMake().size() >= 7 && idata->getMake().substr(0, 7) == "OLYMPUS" && idata->getModel()[0] == 'E') || (idata->getMake().size() >= 9 && idata->getMake().substr(0, 9) == "Panasonic")) && raw.bayersensor.method != RAWParams::BayerSensor::getMethodString(RAWParams::BayerSensor::Method::VNG4)))) { // global correction - if(numFrames == 4) { - for(int i = 0; i < 4; ++i) { + if (numFrames == 4) { + for (int i = 0; i < 4; ++i) { green_equilibrate_global(*rawDataFrames[i]); } } else { @@ -1941,14 +1944,14 @@ void RawImageSource::preprocess (const RAWParams &raw, const LensProfParams &le } } - if ( ri->getSensorType() == ST_BAYER && raw.bayersensor.greenthresh > 0) { + if (ri->getSensorType() == ST_BAYER && raw.bayersensor.greenthresh > 0) { if (plistener) { - plistener->setProgressStr ("Green equilibrate..."); - plistener->setProgress (0.0); + plistener->setProgressStr("Green equilibrate..."); + plistener->setProgress(0.0); } - if(numFrames == 4) { - for(int i = 0; i < 4; ++i) { + if (numFrames == 4) { + for (int i = 0; i < 4; ++i) { green_equilibrate(0.01 * raw.bayersensor.greenthresh, *rawDataFrames[i]); } } else { @@ -1957,38 +1960,39 @@ void RawImageSource::preprocess (const RAWParams &raw, const LensProfParams &le } - if ( totBP ) { - if ( ri->getSensorType() == ST_BAYER ) { + if (totBP) { + if (ri->getSensorType() == ST_BAYER) { if (numFrames == 4) { for (int i = 0; i < 4; ++i) { - interpolateBadPixelsBayer ( *bitmapBads, *rawDataFrames[i] ); + interpolateBadPixelsBayer(*bitmapBads, *rawDataFrames[i]); } } else { - interpolateBadPixelsBayer ( *bitmapBads, rawData ); + interpolateBadPixelsBayer(*bitmapBads, rawData); } - } else if ( ri->getSensorType() == ST_FUJI_XTRANS ) { - interpolateBadPixelsXtrans ( *bitmapBads ); + } else if (ri->getSensorType() == ST_FUJI_XTRANS) { + interpolateBadPixelsXtrans(*bitmapBads); } else { - interpolateBadPixelsNColours ( *bitmapBads, ri->get_colors() ); + interpolateBadPixelsNColours(*bitmapBads, ri->get_colors()); } } - if ( ri->getSensorType() == ST_BAYER && raw.bayersensor.linenoise > 0 ) { + if (ri->getSensorType() == ST_BAYER && raw.bayersensor.linenoise > 0) { if (plistener) { - plistener->setProgressStr ("Line Denoise..."); - plistener->setProgress (0.0); + plistener->setProgressStr("Line Denoise..."); + plistener->setProgress(0.0); } - cfa_linedn (0.00002 * (raw.bayersensor.linenoise)); + cfa_linedn(0.00002 * (raw.bayersensor.linenoise)); } - if ( (raw.ca_autocorrect || fabs (raw.cared) > 0.001 || fabs (raw.cablue) > 0.001) && ri->getSensorType() == ST_BAYER ) { // Auto CA correction disabled for X-Trans, for now... + if ((raw.ca_autocorrect || fabs(raw.cared) > 0.001 || fabs(raw.cablue) > 0.001) && ri->getSensorType() == ST_BAYER) { // Auto CA correction disabled for X-Trans, for now... if (plistener) { - plistener->setProgressStr ("CA Auto Correction..."); - plistener->setProgress (0.0); + plistener->setProgressStr("CA Auto Correction..."); + plistener->setProgress(0.0); } - if(numFrames == 4) { - for(int i=0; i<4; ++i) { + + if (numFrames == 4) { + for (int i = 0; i < 4; ++i) { CA_correct_RT(raw.ca_autocorrect, raw.cared, raw.cablue, 8.0, *rawDataFrames[i]); } } else { @@ -1996,13 +2000,13 @@ void RawImageSource::preprocess (const RAWParams &raw, const LensProfParams &le } } - if ( raw.expos != 1 ) { + if (raw.expos != 1) { if (numFrames == 4) { for (int i = 0; i < 4; ++i) { - processRawWhitepoint (raw.expos, raw.preser, *rawDataFrames[i]); + processRawWhitepoint(raw.expos, raw.preser, *rawDataFrames[i]); } } else { - processRawWhitepoint (raw.expos, raw.preser, rawData); + processRawWhitepoint(raw.expos, raw.preser, rawData); } } @@ -2011,14 +2015,14 @@ void RawImageSource::preprocess (const RAWParams &raw, const LensProfParams &le int aehistcompr; double clip = 0; int brightness, contrast, black, hlcompr, hlcomprthresh; - getAutoExpHistogram (aehist, aehistcompr); - ImProcFunctions::getAutoExp (aehist, aehistcompr, clip, dirpyrdenoiseExpComp, brightness, contrast, black, hlcompr, hlcomprthresh); + getAutoExpHistogram(aehist, aehistcompr); + ImProcFunctions::getAutoExp(aehist, aehistcompr, clip, dirpyrdenoiseExpComp, brightness, contrast, black, hlcompr, hlcomprthresh); } t2.set(); - if ( settings->verbose ) { - printf ("Preprocessing: %d usec\n", t2.etime (t1)); + if (settings->verbose) { + printf("Preprocessing: %d usec\n", t2.etime(t1)); } if (bitmapBads) { @@ -2030,57 +2034,57 @@ void RawImageSource::preprocess (const RAWParams &raw, const LensProfParams &le } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -void RawImageSource::demosaic (const RAWParams &raw) +void RawImageSource::demosaic(const RAWParams &raw) { MyTime t1, t2; t1.set(); if (ri->getSensorType() == ST_BAYER) { - if ( raw.bayersensor.method == RAWParams::BayerSensor::getMethodString(RAWParams::BayerSensor::Method::HPHD) ) { - hphd_demosaic (); - } else if (raw.bayersensor.method == RAWParams::BayerSensor::getMethodString(RAWParams::BayerSensor::Method::VNG4) ) { - vng4_demosaic (); - } else if (raw.bayersensor.method == RAWParams::BayerSensor::getMethodString(RAWParams::BayerSensor::Method::AHD) ) { - ahd_demosaic (); - } else if (raw.bayersensor.method == RAWParams::BayerSensor::getMethodString(RAWParams::BayerSensor::Method::AMAZE) ) { - amaze_demosaic_RT (0, 0, W, H, rawData, red, green, blue); - } else if (raw.bayersensor.method == RAWParams::BayerSensor::getMethodString(RAWParams::BayerSensor::Method::PIXELSHIFT) ) { + if (raw.bayersensor.method == RAWParams::BayerSensor::getMethodString(RAWParams::BayerSensor::Method::HPHD)) { + hphd_demosaic(); + } else if (raw.bayersensor.method == RAWParams::BayerSensor::getMethodString(RAWParams::BayerSensor::Method::VNG4)) { + vng4_demosaic(); + } else if (raw.bayersensor.method == RAWParams::BayerSensor::getMethodString(RAWParams::BayerSensor::Method::AHD)) { + ahd_demosaic(); + } else if (raw.bayersensor.method == RAWParams::BayerSensor::getMethodString(RAWParams::BayerSensor::Method::AMAZE)) { + amaze_demosaic_RT(0, 0, W, H, rawData, red, green, blue); + } else if (raw.bayersensor.method == RAWParams::BayerSensor::getMethodString(RAWParams::BayerSensor::Method::PIXELSHIFT)) { pixelshift(0, 0, W, H, raw.bayersensor, currFrame, ri->get_maker(), ri->get_model(), raw.expos); - } else if (raw.bayersensor.method == RAWParams::BayerSensor::getMethodString(RAWParams::BayerSensor::Method::DCB) ) { + } else if (raw.bayersensor.method == RAWParams::BayerSensor::getMethodString(RAWParams::BayerSensor::Method::DCB)) { dcb_demosaic(raw.bayersensor.dcb_iterations, raw.bayersensor.dcb_enhance); } else if (raw.bayersensor.method == RAWParams::BayerSensor::getMethodString(RAWParams::BayerSensor::Method::EAHD)) { - eahd_demosaic (); + eahd_demosaic(); } else if (raw.bayersensor.method == RAWParams::BayerSensor::getMethodString(RAWParams::BayerSensor::Method::IGV)) { igv_interpolate(W, H); } else if (raw.bayersensor.method == RAWParams::BayerSensor::getMethodString(RAWParams::BayerSensor::Method::LMMSE)) { lmmse_interpolate_omp(W, H, rawData, red, green, blue, raw.bayersensor.lmmse_iterations); - } else if (raw.bayersensor.method == RAWParams::BayerSensor::getMethodString(RAWParams::BayerSensor::Method::FAST) ) { + } else if (raw.bayersensor.method == RAWParams::BayerSensor::getMethodString(RAWParams::BayerSensor::Method::FAST)) { fast_demosaic(); - } else if (raw.bayersensor.method == RAWParams::BayerSensor::getMethodString(RAWParams::BayerSensor::Method::MONO) ) { + } else if (raw.bayersensor.method == RAWParams::BayerSensor::getMethodString(RAWParams::BayerSensor::Method::MONO)) { nodemosaic(true); - } else if (raw.bayersensor.method == RAWParams::BayerSensor::getMethodString(RAWParams::BayerSensor::Method::RCD) ) { - rcd_demosaic (); + } else if (raw.bayersensor.method == RAWParams::BayerSensor::getMethodString(RAWParams::BayerSensor::Method::RCD)) { + rcd_demosaic(); } else { - nodemosaic (false); + nodemosaic(false); } //if (raw.all_enhance) refinement_lassus(); } else if (ri->getSensorType() == ST_FUJI_XTRANS) { - if (raw.xtranssensor.method == RAWParams::XTransSensor::getMethodString(RAWParams::XTransSensor::Method::FAST) ) { + if (raw.xtranssensor.method == RAWParams::XTransSensor::getMethodString(RAWParams::XTransSensor::Method::FAST)) { fast_xtrans_interpolate(); } else if (raw.xtranssensor.method == RAWParams::XTransSensor::getMethodString(RAWParams::XTransSensor::Method::ONE_PASS)) { xtrans_interpolate(1, false); - } else if (raw.xtranssensor.method == RAWParams::XTransSensor::getMethodString(RAWParams::XTransSensor::Method::THREE_PASS) ) { + } else if (raw.xtranssensor.method == RAWParams::XTransSensor::getMethodString(RAWParams::XTransSensor::Method::THREE_PASS)) { xtrans_interpolate(3, true); - } else if(raw.xtranssensor.method == RAWParams::XTransSensor::getMethodString(RAWParams::XTransSensor::Method::MONO) ) { + } else if (raw.xtranssensor.method == RAWParams::XTransSensor::getMethodString(RAWParams::XTransSensor::Method::MONO)) { nodemosaic(true); } else { - nodemosaic (false); + nodemosaic(false); } } else if (ri->get_colors() == 1) { // Monochrome - nodemosaic (true); + nodemosaic(true); } t2.set(); @@ -2089,11 +2093,11 @@ void RawImageSource::demosaic (const RAWParams &raw) rgbSourceModified = false; - if ( settings->verbose ) { + if (settings->verbose) { if (getSensorType() == ST_BAYER) { - printf ("Demosaicing Bayer data: %s - %d usec\n", raw.bayersensor.method.c_str(), t2.etime (t1)); + printf("Demosaicing Bayer data: %s - %d usec\n", raw.bayersensor.method.c_str(), t2.etime(t1)); } else if (getSensorType() == ST_FUJI_XTRANS) { - printf ("Demosaicing X-Trans data: %s - %d usec\n", raw.xtranssensor.method.c_str(), t2.etime (t1)); + printf("Demosaicing X-Trans data: %s - %d usec\n", raw.xtranssensor.method.c_str(), t2.etime(t1)); } } } @@ -2103,10 +2107,10 @@ void RawImageSource::demosaic (const RAWParams &raw) void RawImageSource::retinexPrepareBuffers(const ColorManagementParams& cmp, const RetinexParams &retinexParams, multi_array2D &conversionBuffer, LUTu &lhist16RETI) { bool useHsl = (retinexParams.retinexcolorspace == "HSLLOG" || retinexParams.retinexcolorspace == "HSLLIN"); - conversionBuffer[0] (W - 2 * border, H - 2 * border); - conversionBuffer[1] (W - 2 * border, H - 2 * border); - conversionBuffer[2] (W - 2 * border, H - 2 * border); - conversionBuffer[3] (W - 2 * border, H - 2 * border); + conversionBuffer[0](W - 2 * border, H - 2 * border); + conversionBuffer[1](W - 2 * border, H - 2 * border); + conversionBuffer[2](W - 2 * border, H - 2 * border); + conversionBuffer[3](W - 2 * border, H - 2 * border); LUTf *retinexgamtab = nullptr;//gamma before and after Retinex to restore tones LUTf lutTonereti; @@ -2125,7 +2129,7 @@ void RawImageSource::retinexPrepareBuffers(const ColorManagementParams& cmp, con double gamm2 = retinexParams.gam; if (gamm2 < 1.) { - std::swap (pwr, gamm); + std::swap(pwr, gamm); } int mode = 0; @@ -2145,19 +2149,19 @@ void RawImageSource::retinexPrepareBuffers(const ColorManagementParams& cmp, con double mul = 1. + g_a[4]; - lutTonereti (65536); + lutTonereti(65536); for (int i = 0; i < 65536; i++) { double val = (i) / 65535.; double x; if (gamm2 < 1.) { - x = Color::igammareti (val, gamm, start, ts, mul , add); + x = Color::igammareti(val, gamm, start, ts, mul, add); } else { - x = Color::gammareti (val, gamm, start, ts, mul , add); + x = Color::gammareti(val, gamm, start, ts, mul, add); } - lutTonereti[i] = CLIP (x * 65535.); // CLIP avoid in some case extra values + lutTonereti[i] = CLIP(x * 65535.); // CLIP avoid in some case extra values } retinexgamtab = &lutTonereti; @@ -2202,14 +2206,14 @@ void RawImageSource::retinexPrepareBuffers(const ColorManagementParams& cmp, con } } */ - if(retinexParams.gammaretinex != "none" && retinexParams.str != 0 && retinexgamtab) {//gamma + if (retinexParams.gammaretinex != "none" && retinexParams.str != 0 && retinexgamtab) { //gamma #ifdef _OPENMP #pragma omp parallel for #endif - for (int i = border; i < H - border; i++ ) { - for (int j = border; j < W - border; j++ ) { + for (int i = border; i < H - border; i++) { + for (int j = border; j < W - border; j++) { float R_, G_, B_; R_ = red[i][j]; G_ = green[i][j]; @@ -2232,34 +2236,34 @@ void RawImageSource::retinexPrepareBuffers(const ColorManagementParams& cmp, con if (lhist16RETI) { - lhist16RETIThr (lhist16RETI.getSize()); + lhist16RETIThr(lhist16RETI.getSize()); lhist16RETIThr.clear(); } #ifdef __SSE2__ - vfloat c32768 = F2V (32768.f); + vfloat c32768 = F2V(32768.f); #endif #ifdef _OPENMP #pragma omp for #endif - for (int i = border; i < H - border; i++ ) + for (int i = border; i < H - border; i++) { int j = border; #ifdef __SSE2__ for (; j < W - border - 3; j += 4) { vfloat H, S, L; - Color::rgb2hsl (LVFU (red[i][j]), LVFU (green[i][j]), LVFU (blue[i][j]), H, S, L); - STVFU (conversionBuffer[0][i - border][j - border], H); - STVFU (conversionBuffer[1][i - border][j - border], S); + Color::rgb2hsl(LVFU(red[i][j]), LVFU(green[i][j]), LVFU(blue[i][j]), H, S, L); + STVFU(conversionBuffer[0][i - border][j - border], H); + STVFU(conversionBuffer[1][i - border][j - border], S); L *= c32768; - STVFU (conversionBuffer[2][i - border][j - border], L); - STVFU (conversionBuffer[3][i - border][j - border], H); + STVFU(conversionBuffer[2][i - border][j - border], L); + STVFU(conversionBuffer[3][i - border][j - border], H); if (lhist16RETI) { for (int p = 0; p < 4; p++) { - int pos = ( conversionBuffer[2][i - border][j - border + p]);//histogram in curve HSL + int pos = (conversionBuffer[2][i - border][j - border + p]); //histogram in curve HSL lhist16RETIThr[pos]++; } } @@ -2270,7 +2274,7 @@ void RawImageSource::retinexPrepareBuffers(const ColorManagementParams& cmp, con for (; j < W - border; j++) { float L; //rgb=>lab - Color::rgb2hslfloat (red[i][j], green[i][j], blue[i][j], conversionBuffer[0][i - border][j - border], conversionBuffer[1][i - border][j - border], L); + Color::rgb2hslfloat(red[i][j], green[i][j], blue[i][j], conversionBuffer[0][i - border][j - border], conversionBuffer[1][i - border][j - border], L); L *= 32768.f; conversionBuffer[2][i - border][j - border] = L; @@ -2293,11 +2297,11 @@ void RawImageSource::retinexPrepareBuffers(const ColorManagementParams& cmp, con } } else { - TMatrix wprof = ICCStore::getInstance()->workingSpaceMatrix (cmp.working); + TMatrix wprof = ICCStore::getInstance()->workingSpaceMatrix(cmp.working); 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])} }; // Conversion rgb -> lab is hard to vectorize because it uses a lut (that's not the main problem) @@ -2310,7 +2314,7 @@ void RawImageSource::retinexPrepareBuffers(const ColorManagementParams& cmp, con LUTu lhist16RETIThr; if (lhist16RETI) { - lhist16RETIThr (lhist16RETI.getSize()); + lhist16RETIThr(lhist16RETI.getSize()); lhist16RETIThr.clear(); } @@ -2318,17 +2322,17 @@ void RawImageSource::retinexPrepareBuffers(const ColorManagementParams& cmp, con #pragma omp for schedule(dynamic,16) #endif - for (int i = border; i < H - border; i++ ) + for (int i = border; i < H - border; i++) for (int j = border; j < W - border; j++) { float X, Y, Z, L, aa, bb; //rgb=>lab - Color::rgbxyz (red[i][j], green[i][j], blue[i][j], X, Y, Z, wp); + Color::rgbxyz(red[i][j], green[i][j], blue[i][j], X, Y, Z, wp); //convert Lab - Color::XYZ2Lab (X, Y, Z, L, aa, bb); + Color::XYZ2Lab(X, Y, Z, L, aa, bb); conversionBuffer[0][i - border][j - border] = aa; conversionBuffer[1][i - border][j - border] = bb; conversionBuffer[2][i - border][j - border] = L; - conversionBuffer[3][i - border][j - border] = xatan2f (bb, aa); + conversionBuffer[3][i - border][j - border] = xatan2f(bb, aa); // if(R_>40000.f && G_ > 30000.f && B_ > 30000.f) conversionBuffer[3][i - border][j - border] = R_; // else conversionBuffer[3][i - border][j - border] = 0.f; @@ -2359,14 +2363,14 @@ void RawImageSource::retinexPrepareCurves(const RetinexParams &retinexParams, LU useHsl = (retinexParams.retinexcolorspace == "HSLLOG" || retinexParams.retinexcolorspace == "HSLLIN"); if (useHsl) { - CurveFactory::curveDehaContL (retinexcontlutili, retinexParams.cdHcurve, cdcurve, 1, lhist16RETI, histLRETI); + CurveFactory::curveDehaContL(retinexcontlutili, retinexParams.cdHcurve, cdcurve, 1, lhist16RETI, histLRETI); } else { - CurveFactory::curveDehaContL (retinexcontlutili, retinexParams.cdcurve, cdcurve, 1, lhist16RETI, histLRETI); + CurveFactory::curveDehaContL(retinexcontlutili, retinexParams.cdcurve, cdcurve, 1, lhist16RETI, histLRETI); } - CurveFactory::mapcurve (mapcontlutili, retinexParams.mapcurve, mapcurve, 1, lhist16RETI, histLRETI); + CurveFactory::mapcurve(mapcontlutili, retinexParams.mapcurve, mapcurve, 1, lhist16RETI, histLRETI); - retinexParams.getCurves (retinextransmissionCurve, retinexgaintransmissionCurve); + retinexParams.getCurves(retinextransmissionCurve, retinexgaintransmissionCurve); } void RawImageSource::retinex(const ColorManagementParams& cmp, const RetinexParams &deh, ToneCurveParams Tc, LUTf & cdcurve, LUTf & mapcurve, const RetinextransmissionCurve & dehatransmissionCurve, const RetinexgaintransmissionCurve & dehagaintransmissionCurve, multi_array2D &conversionBuffer, bool dehacontlutili, bool mapcontlutili, bool useHsl, float &minCD, float &maxCD, float &mini, float &maxi, float &Tmean, float &Tsigma, float &Tmin, float &Tmax, LUTu &histLRETI) @@ -2375,11 +2379,11 @@ void RawImageSource::retinex(const ColorManagementParams& cmp, const RetinexPara t4.set(); if (settings->verbose) { - printf ("Applying Retinex\n"); + printf("Applying Retinex\n"); } LUTf lutToneireti; - lutToneireti (65536); + lutToneireti(65536); LUTf *retinexigamtab = nullptr;//gamma before and after Retinex to restore tones @@ -2398,7 +2402,7 @@ void RawImageSource::retinex(const ColorManagementParams& cmp, const RetinexPara int mode = 0; if (gamm2 < 1.) { - std::swap (pwr, gamm); + std::swap(pwr, gamm); } Color::calcGamma(pwr, ts, mode, g_a); // call to calcGamma with selected gamma and slope @@ -2421,12 +2425,12 @@ void RawImageSource::retinex(const ColorManagementParams& cmp, const RetinexPara double x; if (gamm2 < 1.) { - x = Color::gammareti (val, gamm, start, ts, mul , add); + x = Color::gammareti(val, gamm, start, ts, mul, add); } else { - x = Color::igammareti (val, gamm, start, ts, mul , add); + x = Color::igammareti(val, gamm, start, ts, mul, add); } - lutToneireti[i] = CLIP (x * 65535.); + lutToneireti[i] = CLIP(x * 65535.); } retinexigamtab = &lutToneireti; @@ -2437,23 +2441,23 @@ void RawImageSource::retinex(const ColorManagementParams& cmp, const RetinexPara const int HNew = H - 2 * border; const int WNew = W - 2 * border; - array2D LBuffer (WNew, HNew); + array2D LBuffer(WNew, HNew); float **temp = conversionBuffer[2]; // one less dereference LUTf dLcurve; LUTu hist16RET; if (dehacontlutili && histLRETI) { - hist16RET (32768); + hist16RET(32768); hist16RET.clear(); histLRETI.clear(); - dLcurve (32768); + dLcurve(32768); } FlatCurve* chcurve = nullptr;//curve c=f(H) bool chutili = false; if (deh.enabled && deh.retinexMethod == "highli") { - chcurve = new FlatCurve (deh.lhcurve); + chcurve = new FlatCurve(deh.lhcurve); if (!chcurve || chcurve->isIdentity()) { if (chcurve) { @@ -2475,7 +2479,7 @@ void RawImageSource::retinex(const ColorManagementParams& cmp, const RetinexPara LUTu hist16RETThr; if (hist16RET) { - hist16RETThr (hist16RET.getSize()); + hist16RETThr(hist16RET.getSize()); hist16RETThr.clear(); } @@ -2483,7 +2487,7 @@ void RawImageSource::retinex(const ColorManagementParams& cmp, const RetinexPara #pragma omp for #endif - for (int i = 0; i < H - 2 * border; i++ ) + for (int i = 0; i < H - 2 * border; i++) if (dehacontlutili) for (int j = 0; j < W - 2 * border; j++) { LBuffer[i][j] = cdcurve[2.f * temp[i][j]] / 2.f; @@ -2492,8 +2496,7 @@ void RawImageSource::retinex(const ColorManagementParams& cmp, const RetinexPara int pos = LBuffer[i][j]; hist16RETThr[pos]++; //histogram in Curve } - } - else + } else for (int j = 0; j < W - 2 * border; j++) { LBuffer[i][j] = temp[i][j]; } @@ -2519,12 +2522,12 @@ void RawImageSource::retinex(const ColorManagementParams& cmp, const RetinexPara for (int i = 0; i < 32768; i++) { float hval = dLcurve[i]; - int hi = (int) (255.0f * hval); + int hi = (int)(255.0f * hval); histLRETI[hi] += hist16RET[i]; } } - MSR (LBuffer, conversionBuffer[2], conversionBuffer[3], mapcurve, mapcontlutili, WNew, HNew, deh, dehatransmissionCurve, dehagaintransmissionCurve, minCD, maxCD, mini, maxi, Tmean, Tsigma, Tmin, Tmax); + MSR(LBuffer, conversionBuffer[2], conversionBuffer[3], mapcurve, mapcontlutili, WNew, HNew, deh, dehatransmissionCurve, dehagaintransmissionCurve, minCD, maxCD, mini, maxi, Tmean, Tsigma, Tmin, Tmax); if (useHsl) { if (chutili) { @@ -2532,12 +2535,12 @@ void RawImageSource::retinex(const ColorManagementParams& cmp, const RetinexPara #pragma omp parallel for #endif - for (int i = border; i < H - border; i++ ) { + for (int i = border; i < H - border; i++) { int j = border; for (; j < W - border; j++) { - float valp = (chcurve->getVal (conversionBuffer[3][i - border][j - border]) - 0.5f); + float valp = (chcurve->getVal(conversionBuffer[3][i - border][j - border]) - 0.5f); conversionBuffer[1][i - border][j - border] *= (1.f + 2.f * valp); } @@ -2548,29 +2551,29 @@ void RawImageSource::retinex(const ColorManagementParams& cmp, const RetinexPara #pragma omp parallel for #endif - for (int i = border; i < H - border; i++ ) { + for (int i = border; i < H - border; i++) { int j = border; #ifdef __SSE2__ - vfloat c32768 = F2V (32768.f); + vfloat c32768 = F2V(32768.f); for (; j < W - border - 3; j += 4) { vfloat R, G, B; - Color::hsl2rgb (LVFU (conversionBuffer[0][i - border][j - border]), LVFU (conversionBuffer[1][i - border][j - border]), LVFU (LBuffer[i - border][j - border]) / c32768, R, G, B); + Color::hsl2rgb(LVFU(conversionBuffer[0][i - border][j - border]), LVFU(conversionBuffer[1][i - border][j - border]), LVFU(LBuffer[i - border][j - border]) / c32768, R, G, B); - STVFU (red[i][j], R); - STVFU (green[i][j], G); - STVFU (blue[i][j], B); + STVFU(red[i][j], R); + STVFU(green[i][j], G); + STVFU(blue[i][j], B); } #endif for (; j < W - border; j++) { - Color::hsl2rgbfloat (conversionBuffer[0][i - border][j - border], conversionBuffer[1][i - border][j - border], LBuffer[i - border][j - border] / 32768.f, red[i][j], green[i][j], blue[i][j]); + Color::hsl2rgbfloat(conversionBuffer[0][i - border][j - border], conversionBuffer[1][i - border][j - border], LBuffer[i - border][j - border] / 32768.f, red[i][j], green[i][j], blue[i][j]); } } } else { - TMatrix wiprof = ICCStore::getInstance()->workingSpaceInverseMatrix (cmp.working); + TMatrix wiprof = ICCStore::getInstance()->workingSpaceInverseMatrix(cmp.working); double wip[3][3] = { {wiprof[0][0], wiprof[0][1], wiprof[0][2]}, @@ -2589,14 +2592,14 @@ void RawImageSource::retinex(const ColorManagementParams& cmp, const RetinexPara float sqrtBuffer[W] ALIGNED16; float sincosxBuffer[W] ALIGNED16; float sincosyBuffer[W] ALIGNED16; - const vfloat c327d68v = F2V (327.68); - const vfloat onev = F2V (1.f); + const vfloat c327d68v = F2V(327.68); + const vfloat onev = F2V(1.f); #endif // __SSE2__ #ifdef _OPENMP #pragma omp for #endif - for (int i = border; i < H - border; i++ ) { + for (int i = border; i < H - border; i++) { #ifdef __SSE2__ // vectorized precalculation { @@ -2604,26 +2607,26 @@ void RawImageSource::retinex(const ColorManagementParams& cmp, const RetinexPara for (; j < W - border - 3; j += 4) { - vfloat av = LVFU (conversionBuffer[0][i - border][j - border]); - vfloat bv = LVFU (conversionBuffer[1][i - border][j - border]); - vfloat chprovv = vsqrtf (SQRV (av) + SQRV (bv)); - STVF (sqrtBuffer[j - border], chprovv / c327d68v); - vfloat HHv = xatan2f (bv, av); - STVF (atan2Buffer[j - border], HHv); + vfloat av = LVFU(conversionBuffer[0][i - border][j - border]); + vfloat bv = LVFU(conversionBuffer[1][i - border][j - border]); + vfloat chprovv = vsqrtf(SQRV(av) + SQRV(bv)); + STVF(sqrtBuffer[j - border], chprovv / c327d68v); + vfloat HHv = xatan2f(bv, av); + STVF(atan2Buffer[j - border], HHv); av /= chprovv; bv /= chprovv; - vmask selMask = vmaskf_eq (chprovv, ZEROV); - STVF (sincosyBuffer[j - border], vself (selMask, onev, av)); - STVF (sincosxBuffer[j - border], vselfnotzero (selMask, bv)); + vmask selMask = vmaskf_eq(chprovv, ZEROV); + STVF(sincosyBuffer[j - border], vself(selMask, onev, av)); + STVF(sincosxBuffer[j - border], vselfnotzero(selMask, bv)); } for (; j < W - border; j++) { float aa = conversionBuffer[0][i - border][j - border]; float bb = conversionBuffer[1][i - border][j - border]; - float Chprov1 = sqrt (SQR (aa) + SQR (bb)) / 327.68f; + float Chprov1 = sqrt(SQR(aa) + SQR(bb)) / 327.68f; sqrtBuffer[j - border] = Chprov1; - float HH = xatan2f (bb, aa); + float HH = xatan2f(bb, aa); atan2Buffer[j - border] = HH; if (Chprov1 == 0.0f) { @@ -2649,8 +2652,8 @@ void RawImageSource::retinex(const ColorManagementParams& cmp, const RetinexPara #else float aa = conversionBuffer[0][i - border][j - border]; float bb = conversionBuffer[1][i - border][j - border]; - float Chprov1 = sqrt (SQR (aa) + SQR (bb)) / 327.68f; - float HH = xatan2f (bb, aa); + float Chprov1 = sqrt(SQR(aa) + SQR(bb)) / 327.68f; + float HH = xatan2f(bb, aa); float2 sincosval;// = xsincosf(HH); if (Chprov1 == 0.0f) { @@ -2664,7 +2667,7 @@ void RawImageSource::retinex(const ColorManagementParams& cmp, const RetinexPara #endif if (chutili) { // c=f(H) - float valp = float ((chcurve->getVal (Color::huelab_to_huehsv2 (HH)) - 0.5f)); + float valp = float ((chcurve->getVal(Color::huelab_to_huehsv2(HH)) - 0.5f)); Chprov1 *= (1.f + 2.f * valp); } @@ -2673,10 +2676,10 @@ void RawImageSource::retinex(const ColorManagementParams& cmp, const RetinexPara 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 @@ -2693,7 +2696,7 @@ void RawImageSource::retinex(const ColorManagementParams& cmp, const RetinexPara for (int i = 0; i < 3; i++) for (int j = 0; j < 3; j++) { - wipv[i][j] = F2V (wiprof[i][j]); + wipv[i][j] = F2V(wiprof[i][j]); } #endif // __SSE2__ @@ -2701,19 +2704,19 @@ void RawImageSource::retinex(const ColorManagementParams& cmp, const RetinexPara #pragma omp parallel for #endif - for (int i = border; i < H - border; i++ ) { + for (int i = border; i < H - border; i++) { int j = border; #ifdef __SSE2__ for (; j < W - border - 3; j += 4) { vfloat x_, y_, z_; vfloat R, G, B; - Color::Lab2XYZ (LVFU (LBuffer[i - border][j - border]), LVFU (conversionBuffer[0][i - border][j - border]), LVFU (conversionBuffer[1][i - border][j - border]), x_, y_, z_) ; - Color::xyz2rgb (x_, y_, z_, R, G, B, wipv); + Color::Lab2XYZ(LVFU(LBuffer[i - border][j - border]), LVFU(conversionBuffer[0][i - border][j - border]), LVFU(conversionBuffer[1][i - border][j - border]), x_, y_, z_) ; + Color::xyz2rgb(x_, y_, z_, R, G, B, wipv); - STVFU (red[i][j], R); - STVFU (green[i][j], G); - STVFU (blue[i][j], B); + STVFU(red[i][j], R); + STVFU(green[i][j], G); + STVFU(blue[i][j], B); } @@ -2722,8 +2725,8 @@ void RawImageSource::retinex(const ColorManagementParams& cmp, const RetinexPara for (; j < W - border; j++) { float x_, y_, z_; float R, G, B; - Color::Lab2XYZ (LBuffer[i - border][j - border], conversionBuffer[0][i - border][j - border], conversionBuffer[1][i - border][j - border], x_, y_, z_) ; - Color::xyz2rgb (x_, y_, z_, R, G, B, wip); + Color::Lab2XYZ(LBuffer[i - border][j - border], conversionBuffer[0][i - border][j - border], conversionBuffer[1][i - border][j - border], x_, y_, z_) ; + Color::xyz2rgb(x_, y_, z_, R, G, B, wip); red[i][j] = R; green[i][j] = G; blue[i][j] = B; @@ -2740,8 +2743,8 @@ void RawImageSource::retinex(const ColorManagementParams& cmp, const RetinexPara #pragma omp parallel for #endif - for (int i = border; i < H - border; i++ ) { - for (int j = border; j < W - border; j++ ) { + for (int i = border; i < H - border; i++) { + for (int j = border; j < W - border; j++) { float R_, G_, B_; R_ = red[i][j]; G_ = green[i][j]; @@ -2757,8 +2760,8 @@ void RawImageSource::retinex(const ColorManagementParams& cmp, const RetinexPara t5.set(); - if ( settings->verbose ) { - printf ("Retinex=%d usec\n", t5.etime (t4)); + if (settings->verbose) { + printf("Retinex=%d usec\n", t5.etime(t4)); } } @@ -2771,34 +2774,34 @@ void RawImageSource::flushRawData() } if (rawData) { - rawData (0, 0); + rawData(0, 0); } } void RawImageSource::flushRGB() { if (green) { - green (0, 0); + green(0, 0); } if (red) { - red (0, 0); + red(0, 0); } if (blue) { - blue (0, 0); + blue(0, 0); } } -void RawImageSource::HLRecovery_Global (ToneCurveParams hrp) +void RawImageSource::HLRecovery_Global(ToneCurveParams hrp) { if (hrp.hrenabled && hrp.method == "Color") { if (!rgbSourceModified) { if (settings->verbose) { - printf ("Applying Highlight Recovery: Color propagation...\n"); + printf("Applying Highlight Recovery: Color propagation...\n"); } - HLRecovery_inpaint (red, green, blue); + HLRecovery_inpaint(red, green, blue); rgbSourceModified = true; } } @@ -2806,10 +2809,10 @@ void RawImageSource::HLRecovery_Global (ToneCurveParams hrp) } -void RawImageSource::processFlatField (const RAWParams &raw, RawImage *riFlatFile, unsigned short black[4]) +void RawImageSource::processFlatField(const RAWParams &raw, RawImage *riFlatFile, unsigned short black[4]) { // BENCHFUN - float *cfablur = (float (*)) malloc (H * W * sizeof * cfablur); + float *cfablur = (float (*)) malloc(H * W * sizeof * cfablur); int BS = raw.ff_BlurRadius; BS += BS & 1; @@ -2833,9 +2836,9 @@ void RawImageSource::processFlatField (const RAWParams &raw, RawImage *riFlatFil for (int n = 0; n < 2; n++) { int row = 2 * (H >> 2) + m; int col = 2 * (W >> 2) + n; - int c = FC (row, col); - int c4 = ( c == 1 && ! (row & 1) ) ? 3 : c; - refcolor[m][n] = max (0.0f, cfablur[row * W + col] - black[c4]); + int c = FC(row, col); + int c4 = (c == 1 && !(row & 1)) ? 3 : c; + refcolor[m][n] = max(0.0f, cfablur[row * W + col] - black[c4]); } float limitFactor = 1.f; @@ -2846,8 +2849,8 @@ void RawImageSource::processFlatField (const RAWParams &raw, RawImage *riFlatFil for (int m = 0; m < 2; m++) for (int n = 0; n < 2; n++) { float maxval = 0.f; - int c = FC (m, n); - int c4 = ( c == 1 && ! (m & 1) ) ? 3 : c; + int c = FC(m, n); + int c4 = (c == 1 && !(m & 1)) ? 3 : c; #ifdef _OPENMP #pragma omp parallel #endif @@ -2859,7 +2862,7 @@ void RawImageSource::processFlatField (const RAWParams &raw, RawImage *riFlatFil for (int row = 0; row < H - m; row += 2) { for (int col = 0; col < W - n; col += 2) { - float tempval = (rawData[row + m][col + n] - black[c4]) * ( refcolor[m][n] / max (1e-5f, cfablur[ (row + m) * W + col + n] - black[c4]) ); + float tempval = (rawData[row + m][col + n] - black[c4]) * (refcolor[m][n] / max(1e-5f, cfablur[(row + m) * W + col + n] - black[c4])); if (tempval > maxvalthr) { maxvalthr = tempval; @@ -2881,14 +2884,14 @@ void RawImageSource::processFlatField (const RAWParams &raw, RawImage *riFlatFil // now we have the max value for the channel // if it clips, calculate factor to avoid clipping - if (maxval + black[c4] >= ri->get_white (c4)) { - limitFactor = min (limitFactor, ri->get_white (c4) / (maxval + black[c4])); + if (maxval + black[c4] >= ri->get_white(c4)) { + limitFactor = min(limitFactor, ri->get_white(c4) / (maxval + black[c4])); } } // clipControlGui = (1.f - limitFactor) * 100.f; // this value can be used to set the clip control slider in gui } else { - limitFactor = max ((float) (100 - raw.ff_clipControl) / 100.f, 0.01f); + limitFactor = max((float)(100 - raw.ff_clipControl) / 100.f, 0.01f); } for (int m = 0; m < 2; m++) @@ -2897,22 +2900,22 @@ void RawImageSource::processFlatField (const RAWParams &raw, RawImage *riFlatFil } - unsigned int c[2][2] = {{FC (0, 0), FC (0, 1)}, {FC (1, 0), FC (1, 1)}}; + unsigned int c[2][2] = {{FC(0, 0), FC(0, 1)}, {FC(1, 0), FC(1, 1)}}; unsigned int c4[2][2]; - c4[0][0] = ( c[0][0] == 1) ? 3 : c[0][0]; - c4[0][1] = ( c[0][1] == 1) ? 3 : c[0][1]; + c4[0][0] = (c[0][0] == 1) ? 3 : c[0][0]; + c4[0][1] = (c[0][1] == 1) ? 3 : c[0][1]; c4[1][0] = c[1][0]; c4[1][1] = c[1][1]; #ifdef __SSE2__ - vfloat refcolorv[2] = {_mm_set_ps (refcolor[0][1], refcolor[0][0], refcolor[0][1], refcolor[0][0]), - _mm_set_ps (refcolor[1][1], refcolor[1][0], refcolor[1][1], refcolor[1][0]) + vfloat refcolorv[2] = {_mm_set_ps(refcolor[0][1], refcolor[0][0], refcolor[0][1], refcolor[0][0]), + _mm_set_ps(refcolor[1][1], refcolor[1][0], refcolor[1][1], refcolor[1][0]) }; - vfloat blackv[2] = {_mm_set_ps (black[c4[0][1]], black[c4[0][0]], black[c4[0][1]], black[c4[0][0]]), - _mm_set_ps (black[c4[1][1]], black[c4[1][0]], black[c4[1][1]], black[c4[1][0]]) + vfloat blackv[2] = {_mm_set_ps(black[c4[0][1]], black[c4[0][0]], black[c4[0][1]], black[c4[0][0]]), + _mm_set_ps(black[c4[1][1]], black[c4[1][0]], black[c4[1][1]], black[c4[1][0]]) }; - vfloat epsv = F2V (1e-5f); + vfloat epsv = F2V(1e-5f); #endif #ifdef _OPENMP #pragma omp parallel for schedule(dynamic,16) @@ -2925,16 +2928,16 @@ void RawImageSource::processFlatField (const RAWParams &raw, RawImage *riFlatFil vfloat rowRefcolorv = refcolorv[row & 1]; for (; col < W - 3; col += 4) { - vfloat vignettecorrv = rowRefcolorv / vmaxf (epsv, LVFU (cfablur[ (row) * W + col]) - rowBlackv); - vfloat valv = LVFU (rawData[row][col]); + vfloat vignettecorrv = rowRefcolorv / vmaxf(epsv, LVFU(cfablur[(row) * W + col]) - rowBlackv); + vfloat valv = LVFU(rawData[row][col]); valv -= rowBlackv; - STVFU (rawData[row][col], valv * vignettecorrv + rowBlackv); + STVFU(rawData[row][col], valv * vignettecorrv + rowBlackv); } #endif for (; col < W; col ++) { - float vignettecorr = refcolor[row & 1][col & 1] / max (1e-5f, cfablur[ (row) * W + col] - black[c4[row & 1][col & 1]]); + float vignettecorr = refcolor[row & 1][col & 1] / max(1e-5f, cfablur[(row) * W + col] - black[c4[row & 1][col & 1]]); rawData[row][col] = (rawData[row][col] - black[c4[row & 1][col & 1]]) * vignettecorr + black[c4[row & 1][col & 1]]; } } @@ -2947,8 +2950,8 @@ void RawImageSource::processFlatField (const RAWParams &raw, RawImage *riFlatFil for (int n = -3; n < 3; n++) { int row = 2 * (H >> 2) + m; int col = 2 * (W >> 2) + n; - int c = riFlatFile->XTRANSFC (row, col); - refcolor[c] += max (0.0f, cfablur[row * W + col] - black[c]); + int c = riFlatFile->XTRANSFC(row, col); + refcolor[c] += max(0.0f, cfablur[row * W + col] - black[c]); cCount[c] ++; } @@ -2974,7 +2977,7 @@ void RawImageSource::processFlatField (const RAWParams &raw, RawImage *riFlatFil for (int row = 0; row < H; row++) { for (int col = 0; col < W; col++) { - float tempval = (rawData[row][col] - black[0]) * ( refcolor[ri->XTRANSFC (row, col)] / max (1e-5f, cfablur[ (row) * W + col] - black[0]) ); + float tempval = (rawData[row][col] - black[0]) * (refcolor[ri->XTRANSFC(row, col)] / max(1e-5f, cfablur[(row) * W + col] - black[0])); if (tempval > maxvalthr) { maxvalthr = tempval; @@ -2993,12 +2996,12 @@ void RawImageSource::processFlatField (const RAWParams &raw, RawImage *riFlatFil } // there's only one white level for xtrans - if (maxval + black[0] > ri->get_white (0)) { - limitFactor = ri->get_white (0) / (maxval + black[0]); + if (maxval + black[0] > ri->get_white(0)) { + limitFactor = ri->get_white(0) / (maxval + black[0]); // clipControlGui = (1.f - limitFactor) * 100.f; // this value can be used to set the clip control slider in gui } } else { - limitFactor = max ((float) (100 - raw.ff_clipControl) / 100.f, 0.01f); + limitFactor = max((float)(100 - raw.ff_clipControl) / 100.f, 0.01f); } @@ -3012,34 +3015,34 @@ void RawImageSource::processFlatField (const RAWParams &raw, RawImage *riFlatFil for (int row = 0; row < H; row++) { for (int col = 0; col < W; col++) { - int c = ri->XTRANSFC (row, col); - float vignettecorr = ( refcolor[c] / max (1e-5f, cfablur[ (row) * W + col] - black[c]) ); + int c = ri->XTRANSFC(row, col); + float vignettecorr = (refcolor[c] / max(1e-5f, cfablur[(row) * W + col] - black[c])); rawData[row][col] = (rawData[row][col] - black[c]) * vignettecorr + black[c]; } } } if (raw.ff_BlurType == RAWParams::getFlatFieldBlurTypeString(RAWParams::FlatFieldBlurType::VH)) { - float *cfablur1 = (float (*)) malloc (H * W * sizeof * cfablur1); - float *cfablur2 = (float (*)) malloc (H * W * sizeof * cfablur2); + float *cfablur1 = (float (*)) malloc(H * W * sizeof * cfablur1); + float *cfablur2 = (float (*)) malloc(H * W * sizeof * cfablur2); //slightly more complicated blur if trying to correct both vertical and horizontal anomalies - cfaboxblur (riFlatFile, cfablur1, 0, 2 * BS); //now do horizontal blur - cfaboxblur (riFlatFile, cfablur2, 2 * BS, 0); //now do vertical blur + cfaboxblur(riFlatFile, cfablur1, 0, 2 * BS); //now do horizontal blur + cfaboxblur(riFlatFile, cfablur2, 2 * BS, 0); //now do vertical blur if (ri->getSensorType() == ST_BAYER) { - unsigned int c[2][2] = {{FC (0, 0), FC (0, 1)}, {FC (1, 0), FC (1, 1)}}; + unsigned int c[2][2] = {{FC(0, 0), FC(0, 1)}, {FC(1, 0), FC(1, 1)}}; unsigned int c4[2][2]; - c4[0][0] = ( c[0][0] == 1) ? 3 : c[0][0]; - c4[0][1] = ( c[0][1] == 1) ? 3 : c[0][1]; + c4[0][0] = (c[0][0] == 1) ? 3 : c[0][0]; + c4[0][1] = (c[0][1] == 1) ? 3 : c[0][1]; c4[1][0] = c[1][0]; c4[1][1] = c[1][1]; #ifdef __SSE2__ - vfloat blackv[2] = {_mm_set_ps (black[c4[0][1]], black[c4[0][0]], black[c4[0][1]], black[c4[0][0]]), - _mm_set_ps (black[c4[1][1]], black[c4[1][0]], black[c4[1][1]], black[c4[1][0]]) + vfloat blackv[2] = {_mm_set_ps(black[c4[0][1]], black[c4[0][0]], black[c4[0][1]], black[c4[0][0]]), + _mm_set_ps(black[c4[1][1]], black[c4[1][0]], black[c4[1][1]], black[c4[1][0]]) }; - vfloat epsv = F2V (1e-5f); + vfloat epsv = F2V(1e-5f); #endif #ifdef _OPENMP #pragma omp parallel for schedule(dynamic,16) @@ -3051,18 +3054,18 @@ void RawImageSource::processFlatField (const RAWParams &raw, RawImage *riFlatFil vfloat rowBlackv = blackv[row & 1]; for (; col < W - 3; col += 4) { - vfloat linecorrv = SQRV (vmaxf (epsv, LVFU (cfablur[row * W + col]) - rowBlackv)) / - (vmaxf (epsv, LVFU (cfablur1[row * W + col]) - rowBlackv) * vmaxf (epsv, LVFU (cfablur2[row * W + col]) - rowBlackv)); - vfloat valv = LVFU (rawData[row][col]); + vfloat linecorrv = SQRV(vmaxf(epsv, LVFU(cfablur[row * W + col]) - rowBlackv)) / + (vmaxf(epsv, LVFU(cfablur1[row * W + col]) - rowBlackv) * vmaxf(epsv, LVFU(cfablur2[row * W + col]) - rowBlackv)); + vfloat valv = LVFU(rawData[row][col]); valv -= rowBlackv; - STVFU (rawData[row][col], valv * linecorrv + rowBlackv); + STVFU(rawData[row][col], valv * linecorrv + rowBlackv); } #endif for (; col < W; col ++) { - float linecorr = SQR (max (1e-5f, cfablur[row * W + col] - black[c4[row & 1][col & 1]])) / - (max (1e-5f, cfablur1[row * W + col] - black[c4[row & 1][col & 1]]) * max (1e-5f, cfablur2[row * W + col] - black[c4[row & 1][col & 1]])) ; + float linecorr = SQR(max(1e-5f, cfablur[row * W + col] - black[c4[row & 1][col & 1]])) / + (max(1e-5f, cfablur1[row * W + col] - black[c4[row & 1][col & 1]]) * max(1e-5f, cfablur2[row * W + col] - black[c4[row & 1][col & 1]])) ; rawData[row][col] = (rawData[row][col] - black[c4[row & 1][col & 1]]) * linecorr + black[c4[row & 1][col & 1]]; } } @@ -3073,20 +3076,20 @@ void RawImageSource::processFlatField (const RAWParams &raw, RawImage *riFlatFil for (int row = 0; row < H; row++) { for (int col = 0; col < W; col++) { - int c = ri->XTRANSFC (row, col); - float hlinecorr = (max (1e-5f, cfablur[ (row) * W + col] - black[c]) / max (1e-5f, cfablur1[ (row) * W + col] - black[c]) ); - float vlinecorr = (max (1e-5f, cfablur[ (row) * W + col] - black[c]) / max (1e-5f, cfablur2[ (row) * W + col] - black[c]) ); + int c = ri->XTRANSFC(row, col); + float hlinecorr = (max(1e-5f, cfablur[(row) * W + col] - black[c]) / max(1e-5f, cfablur1[(row) * W + col] - black[c])); + float vlinecorr = (max(1e-5f, cfablur[(row) * W + col] - black[c]) / max(1e-5f, cfablur2[(row) * W + col] - black[c])); rawData[row][col] = ((rawData[row][col] - black[c]) * hlinecorr * vlinecorr + black[c]); } } } - free (cfablur1); - free (cfablur2); + free(cfablur1); + free(cfablur2); } - free (cfablur); + free(cfablur); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -3094,25 +3097,25 @@ void RawImageSource::processFlatField (const RAWParams &raw, RawImage *riFlatFil /* Copy original pixel data and * subtract dark frame (if present) from current image and apply flat field correction (if present) */ -void RawImageSource::copyOriginalPixels (const RAWParams &raw, RawImage *src, RawImage *riDark, RawImage *riFlatFile, array2D &rawData ) +void RawImageSource::copyOriginalPixels(const RAWParams &raw, RawImage *src, RawImage *riDark, RawImage *riFlatFile, array2D &rawData) { // TODO: Change type of black[] to float to avoid conversions unsigned short black[4] = { - (unsigned short)ri->get_cblack (0), (unsigned short)ri->get_cblack (1), - (unsigned short)ri->get_cblack (2), (unsigned short)ri->get_cblack (3) + (unsigned short)ri->get_cblack(0), (unsigned short)ri->get_cblack(1), + (unsigned short)ri->get_cblack(2), (unsigned short)ri->get_cblack(3) }; if (ri->getSensorType() == ST_BAYER || ri->getSensorType() == ST_FUJI_XTRANS) { if (!rawData) { - rawData (W, H); + rawData(W, H); } if (riDark && W == riDark->get_width() && H == riDark->get_height()) { // This works also for xtrans-sensors, because black[0] to black[4] are equal for these for (int row = 0; row < H; row++) { for (int col = 0; col < W; col++) { - int c = FC (row, col); - int c4 = ( c == 1 && ! (row & 1) ) ? 3 : c; - rawData[row][col] = max (src->data[row][col] + black[c4] - riDark->data[row][col], 0.0f); + int c = FC(row, col); + int c4 = (c == 1 && !(row & 1)) ? 3 : c; + rawData[row][col] = max(src->data[row][col] + black[c4] - riDark->data[row][col], 0.0f); } } } else { @@ -3129,18 +3132,18 @@ void RawImageSource::copyOriginalPixels (const RAWParams &raw, RawImage *src, Ra if (riFlatFile && W == riFlatFile->get_width() && H == riFlatFile->get_height()) { - processFlatField (raw, riFlatFile, black); + processFlatField(raw, riFlatFile, black); } // flatfield } else if (ri->get_colors() == 1) { // Monochrome if (!rawData) { - rawData (W, H); + rawData(W, H); } if (riDark && W == riDark->get_width() && H == riDark->get_height()) { for (int row = 0; row < H; row++) { for (int col = 0; col < W; col++) { - rawData[row][col] = max (src->data[row][col] + black[0] - riDark->data[row][col], 0.0f); + rawData[row][col] = max(src->data[row][col] + black[0] - riDark->data[row][col], 0.0f); } } } else { @@ -3154,17 +3157,17 @@ void RawImageSource::copyOriginalPixels (const RAWParams &raw, RawImage *src, Ra // No bayer pattern // TODO: Is there a flat field correction possible? if (!rawData) { - rawData (3 * W, H); + rawData(3 * W, H); } if (riDark && W == riDark->get_width() && H == riDark->get_height()) { for (int row = 0; row < H; row++) { for (int col = 0; col < W; col++) { - int c = FC (row, col); - int c4 = ( c == 1 && ! (row & 1) ) ? 3 : c; - rawData[row][3 * col + 0] = max (src->data[row][3 * col + 0] + black[c4] - riDark->data[row][3 * col + 0], 0.0f); - rawData[row][3 * col + 1] = max (src->data[row][3 * col + 1] + black[c4] - riDark->data[row][3 * col + 1], 0.0f); - rawData[row][3 * col + 2] = max (src->data[row][3 * col + 2] + black[c4] - riDark->data[row][3 * col + 2], 0.0f); + int c = FC(row, col); + int c4 = (c == 1 && !(row & 1)) ? 3 : c; + rawData[row][3 * col + 0] = max(src->data[row][3 * col + 0] + black[c4] - riDark->data[row][3 * col + 0], 0.0f); + rawData[row][3 * col + 1] = max(src->data[row][3 * col + 1] + black[c4] - riDark->data[row][3 * col + 1], 0.0f); + rawData[row][3 * col + 2] = max(src->data[row][3 * col + 2] + black[c4] - riDark->data[row][3 * col + 2], 0.0f); } } } else { @@ -3179,11 +3182,11 @@ void RawImageSource::copyOriginalPixels (const RAWParams &raw, RawImage *src, Ra } } -SSEFUNCTION void RawImageSource::cfaboxblur (RawImage *riFlatFile, float* cfablur, const int boxH, const int boxW) +SSEFUNCTION void RawImageSource::cfaboxblur(RawImage *riFlatFile, float* cfablur, const int boxH, const int boxW) { if (boxW == 0 && boxH == 0) { // nothing to blur - memcpy (cfablur, riFlatFile->data[0], W * H * sizeof (float)); + memcpy(cfablur, riFlatFile->data[0], W * H * sizeof(float)); return; } @@ -3194,7 +3197,7 @@ SSEFUNCTION void RawImageSource::cfaboxblur (RawImage *riFlatFile, float* cfablu if (boxH > 0 && boxW > 0) { // we need a temporary buffer if we have to blur both directions - tmpBuffer = (float (*)) calloc (H * W, sizeof * tmpBuffer); + tmpBuffer = (float (*)) calloc(H * W, sizeof * tmpBuffer); } if (boxH == 0) { @@ -3258,8 +3261,8 @@ SSEFUNCTION void RawImageSource::cfaboxblur (RawImage *riFlatFile, float* cfablu if (boxH > 0) { //vertical blur #ifdef __SSE2__ - vfloat leninitv = F2V (boxH / 2 + 1); - vfloat onev = F2V ( 1.0f ); + vfloat leninitv = F2V(boxH / 2 + 1); + vfloat onev = F2V(1.0f); vfloat temp1v, temp2v, temp3v, temp4v, lenv, lenp1v, lenm1v; int row; #ifdef _OPENMP @@ -3268,52 +3271,52 @@ SSEFUNCTION void RawImageSource::cfaboxblur (RawImage *riFlatFile, float* cfablu for (int col = 0; col < W - 7; col += 8) { lenv = leninitv; - temp1v = LVFU (srcVertical[0 * W + col]) / lenv; - temp2v = LVFU (srcVertical[1 * W + col]) / lenv; - temp3v = LVFU (srcVertical[0 * W + col + 4]) / lenv; - temp4v = LVFU (srcVertical[1 * W + col + 4]) / lenv; + temp1v = LVFU(srcVertical[0 * W + col]) / lenv; + temp2v = LVFU(srcVertical[1 * W + col]) / lenv; + temp3v = LVFU(srcVertical[0 * W + col + 4]) / lenv; + temp4v = LVFU(srcVertical[1 * W + col + 4]) / lenv; for (int i = 2; i < boxH + 2; i += 2) { - temp1v += LVFU (srcVertical[i * W + col]) / lenv; - temp2v += LVFU (srcVertical[ (i + 1) * W + col]) / lenv; - temp3v += LVFU (srcVertical[i * W + col + 4]) / lenv; - temp4v += LVFU (srcVertical[ (i + 1) * W + col + 4]) / lenv; + temp1v += LVFU(srcVertical[i * W + col]) / lenv; + temp2v += LVFU(srcVertical[(i + 1) * W + col]) / lenv; + temp3v += LVFU(srcVertical[i * W + col + 4]) / lenv; + temp4v += LVFU(srcVertical[(i + 1) * W + col + 4]) / lenv; } - STVFU (cfablur[0 * W + col], temp1v); - STVFU (cfablur[1 * W + col], temp2v); - STVFU (cfablur[0 * W + col + 4], temp3v); - STVFU (cfablur[1 * W + col + 4], temp4v); + STVFU(cfablur[0 * W + col], temp1v); + STVFU(cfablur[1 * W + col], temp2v); + STVFU(cfablur[0 * W + col + 4], temp3v); + STVFU(cfablur[1 * W + col + 4], temp4v); for (row = 2; row < boxH + 2; row += 2) { lenp1v = lenv + onev; - temp1v = (temp1v * lenv + LVFU (srcVertical[ (row + boxH) * W + col])) / lenp1v; - temp2v = (temp2v * lenv + LVFU (srcVertical[ (row + boxH + 1) * W + col])) / lenp1v; - temp3v = (temp3v * lenv + LVFU (srcVertical[ (row + boxH) * W + col + 4])) / lenp1v; - temp4v = (temp4v * lenv + LVFU (srcVertical[ (row + boxH + 1) * W + col + 4])) / lenp1v; - STVFU (cfablur[row * W + col], temp1v); - STVFU (cfablur[ (row + 1)*W + col], temp2v); - STVFU (cfablur[row * W + col + 4], temp3v); - STVFU (cfablur[ (row + 1)*W + col + 4], temp4v); + temp1v = (temp1v * lenv + LVFU(srcVertical[(row + boxH) * W + col])) / lenp1v; + temp2v = (temp2v * lenv + LVFU(srcVertical[(row + boxH + 1) * W + col])) / lenp1v; + temp3v = (temp3v * lenv + LVFU(srcVertical[(row + boxH) * W + col + 4])) / lenp1v; + temp4v = (temp4v * lenv + LVFU(srcVertical[(row + boxH + 1) * W + col + 4])) / lenp1v; + STVFU(cfablur[row * W + col], temp1v); + STVFU(cfablur[(row + 1)*W + col], temp2v); + STVFU(cfablur[row * W + col + 4], temp3v); + STVFU(cfablur[(row + 1)*W + col + 4], temp4v); lenv = lenp1v; } for (; row < H - boxH - 1; row += 2) { - temp1v = temp1v + (LVFU (srcVertical[ (row + boxH) * W + col]) - LVFU (srcVertical[ (row - boxH - 2) * W + col])) / lenv; - temp2v = temp2v + (LVFU (srcVertical[ (row + 1 + boxH) * W + col]) - LVFU (srcVertical[ (row + 1 - boxH - 2) * W + col])) / lenv; - temp3v = temp3v + (LVFU (srcVertical[ (row + boxH) * W + col + 4]) - LVFU (srcVertical[ (row - boxH - 2) * W + col + 4])) / lenv; - temp4v = temp4v + (LVFU (srcVertical[ (row + 1 + boxH) * W + col + 4]) - LVFU (srcVertical[ (row + 1 - boxH - 2) * W + col + 4])) / lenv; - STVFU (cfablur[row * W + col], temp1v); - STVFU (cfablur[ (row + 1)*W + col], temp2v); - STVFU (cfablur[row * W + col + 4], temp3v); - STVFU (cfablur[ (row + 1)*W + col + 4], temp4v); + temp1v = temp1v + (LVFU(srcVertical[(row + boxH) * W + col]) - LVFU(srcVertical[(row - boxH - 2) * W + col])) / lenv; + temp2v = temp2v + (LVFU(srcVertical[(row + 1 + boxH) * W + col]) - LVFU(srcVertical[(row + 1 - boxH - 2) * W + col])) / lenv; + temp3v = temp3v + (LVFU(srcVertical[(row + boxH) * W + col + 4]) - LVFU(srcVertical[(row - boxH - 2) * W + col + 4])) / lenv; + temp4v = temp4v + (LVFU(srcVertical[(row + 1 + boxH) * W + col + 4]) - LVFU(srcVertical[(row + 1 - boxH - 2) * W + col + 4])) / lenv; + STVFU(cfablur[row * W + col], temp1v); + STVFU(cfablur[(row + 1)*W + col], temp2v); + STVFU(cfablur[row * W + col + 4], temp3v); + STVFU(cfablur[(row + 1)*W + col + 4], temp4v); } for (; row < H - boxH; row++) { - temp1v = temp1v + (LVFU (srcVertical[ (row + boxH) * W + col]) - LVFU (srcVertical[ (row - boxH - 2) * W + col])) / lenv; - temp3v = temp3v + (LVFU (srcVertical[ (row + boxH) * W + col + 4]) - LVFU (srcVertical[ (row - boxH - 2) * W + col + 4])) / lenv; - STVFU (cfablur[row * W + col], temp1v); - STVFU (cfablur[row * W + col + 4], temp3v); + temp1v = temp1v + (LVFU(srcVertical[(row + boxH) * W + col]) - LVFU(srcVertical[(row - boxH - 2) * W + col])) / lenv; + temp3v = temp3v + (LVFU(srcVertical[(row + boxH) * W + col + 4]) - LVFU(srcVertical[(row - boxH - 2) * W + col + 4])) / lenv; + STVFU(cfablur[row * W + col], temp1v); + STVFU(cfablur[row * W + col + 4], temp3v); vfloat swapv = temp1v; temp1v = temp2v; temp2v = swapv; @@ -3324,23 +3327,23 @@ SSEFUNCTION void RawImageSource::cfaboxblur (RawImage *riFlatFile, float* cfablu for (; row < H - 1; row += 2) { lenm1v = lenv - onev; - temp1v = (temp1v * lenv - LVFU (srcVertical[ (row - boxH - 2) * W + col])) / lenm1v; - temp2v = (temp2v * lenv - LVFU (srcVertical[ (row - boxH - 1) * W + col])) / lenm1v; - temp3v = (temp3v * lenv - LVFU (srcVertical[ (row - boxH - 2) * W + col + 4])) / lenm1v; - temp4v = (temp4v * lenv - LVFU (srcVertical[ (row - boxH - 1) * W + col + 4])) / lenm1v; - STVFU (cfablur[row * W + col], temp1v); - STVFU (cfablur[ (row + 1)*W + col], temp2v); - STVFU (cfablur[row * W + col + 4], temp3v); - STVFU (cfablur[ (row + 1)*W + col + 4], temp4v); + temp1v = (temp1v * lenv - LVFU(srcVertical[(row - boxH - 2) * W + col])) / lenm1v; + temp2v = (temp2v * lenv - LVFU(srcVertical[(row - boxH - 1) * W + col])) / lenm1v; + temp3v = (temp3v * lenv - LVFU(srcVertical[(row - boxH - 2) * W + col + 4])) / lenm1v; + temp4v = (temp4v * lenv - LVFU(srcVertical[(row - boxH - 1) * W + col + 4])) / lenm1v; + STVFU(cfablur[row * W + col], temp1v); + STVFU(cfablur[(row + 1)*W + col], temp2v); + STVFU(cfablur[row * W + col + 4], temp3v); + STVFU(cfablur[(row + 1)*W + col + 4], temp4v); lenv = lenm1v; } for (; row < H; row++) { lenm1v = lenv - onev; - temp1v = (temp1v * lenv - LVFU (srcVertical[ (row - boxH - 2) * W + col])) / lenm1v; - temp3v = (temp3v * lenv - LVFU (srcVertical[ (row - boxH - 2) * W + col + 4])) / lenm1v; - STVFU (cfablur[ (row)*W + col], temp1v); - STVFU (cfablur[ (row)*W + col + 4], temp3v); + temp1v = (temp1v * lenv - LVFU(srcVertical[(row - boxH - 2) * W + col])) / lenm1v; + temp3v = (temp3v * lenv - LVFU(srcVertical[(row - boxH - 2) * W + col + 4])) / lenm1v; + STVFU(cfablur[(row)*W + col], temp1v); + STVFU(cfablur[(row)*W + col + 4], temp3v); } } @@ -3354,24 +3357,24 @@ SSEFUNCTION void RawImageSource::cfaboxblur (RawImage *riFlatFile, float* cfablu for (int i = 2; i < boxH + 2; i += 2) { cfablur[0 * W + col] += srcVertical[i * W + col] / len; - cfablur[1 * W + col] += srcVertical[ (i + 1) * W + col] / len; + cfablur[1 * W + col] += srcVertical[(i + 1) * W + col] / len; } for (int row = 2; row < boxH + 2; row += 2) { - cfablur[row * W + col] = (cfablur[ (row - 2) * W + col] * len + srcVertical[ (row + boxH) * W + col]) / (len + 1); - cfablur[ (row + 1)*W + col] = (cfablur[ (row - 1) * W + col] * len + srcVertical[ (row + boxH + 1) * W + col]) / (len + 1); + cfablur[row * W + col] = (cfablur[(row - 2) * W + col] * len + srcVertical[(row + boxH) * W + col]) / (len + 1); + cfablur[(row + 1)*W + col] = (cfablur[(row - 1) * W + col] * len + srcVertical[(row + boxH + 1) * W + col]) / (len + 1); len ++; } for (int row = boxH + 2; row < H - boxH; row++) { - cfablur[row * W + col] = cfablur[ (row - 2) * W + col] + (srcVertical[ (row + boxH) * W + col] - srcVertical[ (row - boxH - 2) * W + col]) / len; + cfablur[row * W + col] = cfablur[(row - 2) * W + col] + (srcVertical[(row + boxH) * W + col] - srcVertical[(row - boxH - 2) * W + col]) / len; } for (int row = H - boxH; row < H; row += 2) { - cfablur[row * W + col] = (cfablur[ (row - 2) * W + col] * len - srcVertical[ (row - boxH - 2) * W + col]) / (len - 1); + cfablur[row * W + col] = (cfablur[(row - 2) * W + col] * len - srcVertical[(row - boxH - 2) * W + col]) / (len - 1); if (row + 1 < H) { - cfablur[ (row + 1)*W + col] = (cfablur[ (row - 1) * W + col] * len - srcVertical[ (row - boxH - 1) * W + col]) / (len - 1); + cfablur[(row + 1)*W + col] = (cfablur[(row - 1) * W + col] * len - srcVertical[(row - boxH - 1) * W + col]) / (len - 1); } len --; @@ -3390,24 +3393,24 @@ SSEFUNCTION void RawImageSource::cfaboxblur (RawImage *riFlatFile, float* cfablu for (int i = 2; i < boxH + 2; i += 2) { cfablur[0 * W + col] += srcVertical[i * W + col] / len; - cfablur[1 * W + col] += srcVertical[ (i + 1) * W + col] / len; + cfablur[1 * W + col] += srcVertical[(i + 1) * W + col] / len; } for (int row = 2; row < boxH + 2; row += 2) { - cfablur[row * W + col] = (cfablur[ (row - 2) * W + col] * len + srcVertical[ (row + boxH) * W + col]) / (len + 1); - cfablur[ (row + 1)*W + col] = (cfablur[ (row - 1) * W + col] * len + srcVertical[ (row + boxH + 1) * W + col]) / (len + 1); + cfablur[row * W + col] = (cfablur[(row - 2) * W + col] * len + srcVertical[(row + boxH) * W + col]) / (len + 1); + cfablur[(row + 1)*W + col] = (cfablur[(row - 1) * W + col] * len + srcVertical[(row + boxH + 1) * W + col]) / (len + 1); len ++; } for (int row = boxH + 2; row < H - boxH; row++) { - cfablur[row * W + col] = cfablur[ (row - 2) * W + col] + (srcVertical[ (row + boxH) * W + col] - srcVertical[ (row - boxH - 2) * W + col]) / len; + cfablur[row * W + col] = cfablur[(row - 2) * W + col] + (srcVertical[(row + boxH) * W + col] - srcVertical[(row - boxH - 2) * W + col]) / len; } for (int row = H - boxH; row < H; row += 2) { - cfablur[row * W + col] = (cfablur[ (row - 2) * W + col] * len - srcVertical[ (row - boxH - 2) * W + col]) / (len - 1); + cfablur[row * W + col] = (cfablur[(row - 2) * W + col] * len - srcVertical[(row - boxH - 2) * W + col]) / (len - 1); if (row + 1 < H) { - cfablur[ (row + 1)*W + col] = (cfablur[ (row - 1) * W + col] * len - srcVertical[ (row - boxH - 1) * W + col]) / (len - 1); + cfablur[(row + 1)*W + col] = (cfablur[(row - 1) * W + col] * len - srcVertical[(row - boxH - 1) * W + col]) / (len - 1); } len --; @@ -3419,13 +3422,13 @@ SSEFUNCTION void RawImageSource::cfaboxblur (RawImage *riFlatFile, float* cfablu } if (tmpBuffer) { - free (tmpBuffer); + free(tmpBuffer); } } // Scale original pixels into the range 0 65535 using black offsets and multipliers -void RawImageSource::scaleColors (int winx, int winy, int winw, int winh, const RAWParams &raw, array2D &rawData) +void RawImageSource::scaleColors(int winx, int winy, int winw, int winh, const RAWParams &raw, array2D &rawData) { chmax[0] = chmax[1] = chmax[2] = chmax[3] = 0; //channel maxima float black_lev[4] = {0.f};//black level @@ -3433,7 +3436,7 @@ void RawImageSource::scaleColors (int winx, int winy, int winw, int winh, const //adjust black level (eg Canon) bool isMono = false; - if (getSensorType() == ST_BAYER || getSensorType() == ST_FOVEON ) { + if (getSensorType() == ST_BAYER || getSensorType() == ST_FOVEON) { black_lev[0] = raw.bayersensor.black1; //R black_lev[1] = raw.bayersensor.black0; //G1 @@ -3452,10 +3455,10 @@ void RawImageSource::scaleColors (int winx, int winy, int winw, int winh, const } for (int i = 0; i < 4 ; i++) { - cblacksom[i] = max ( c_black[i] + black_lev[i], 0.0f ); // adjust black level + cblacksom[i] = max(c_black[i] + black_lev[i], 0.0f); // adjust black level } - initialGain = calculate_scale_mul (scale_mul, ref_pre_mul, c_white, cblacksom, isMono, ri->get_colors()); // recalculate scale colors with adjusted levels + initialGain = calculate_scale_mul(scale_mul, ref_pre_mul, c_white, cblacksom, isMono, ri->get_colors()); // recalculate scale colors with adjusted levels //fprintf(stderr, "recalc: %f [%f %f %f %f]\n", initialGain, scale_mul[0], scale_mul[1], scale_mul[2], scale_mul[3]); for (int i = 0; i < 4 ; i++) { @@ -3466,7 +3469,7 @@ void RawImageSource::scaleColors (int winx, int winy, int winw, int winh, const // scale image colors - if ( ri->getSensorType() == ST_BAYER) { + if (ri->getSensorType() == ST_BAYER) { #ifdef _OPENMP #pragma omp parallel #endif @@ -3481,12 +3484,12 @@ void RawImageSource::scaleColors (int winx, int winy, int winw, int winh, const { for (int col = winx; col < winx + winw; col++) { float val = rawData[row][col]; - int c = FC (row, col); // three colors, 0=R, 1=G, 2=B - int c4 = ( c == 1 && ! (row & 1) ) ? 3 : c; // four colors, 0=R, 1=G1, 2=B, 3=G2 + int c = FC(row, col); // three colors, 0=R, 1=G, 2=B + int c4 = (c == 1 && !(row & 1)) ? 3 : c; // four colors, 0=R, 1=G1, 2=B, 3=G2 val -= cblacksom[c4]; val *= scale_mul[c4]; rawData[row][col] = (val); - tmpchmax[c] = max (tmpchmax[c], val); + tmpchmax[c] = max(tmpchmax[c], val); } } @@ -3494,12 +3497,12 @@ void RawImageSource::scaleColors (int winx, int winy, int winw, int winh, const #pragma omp critical #endif { - chmax[0] = max (tmpchmax[0], chmax[0]); - chmax[1] = max (tmpchmax[1], chmax[1]); - chmax[2] = max (tmpchmax[2], chmax[2]); + chmax[0] = max(tmpchmax[0], chmax[0]); + chmax[1] = max(tmpchmax[1], chmax[1]); + chmax[2] = max(tmpchmax[2], chmax[2]); } } - } else if ( ri->get_colors() == 1 ) { + } else if (ri->get_colors() == 1) { #ifdef _OPENMP #pragma omp parallel #endif @@ -3516,7 +3519,7 @@ void RawImageSource::scaleColors (int winx, int winy, int winw, int winh, const val -= cblacksom[0]; val *= scale_mul[0]; rawData[row][col] = (val); - tmpchmax = max (tmpchmax, val); + tmpchmax = max(tmpchmax, val); } } @@ -3524,7 +3527,7 @@ void RawImageSource::scaleColors (int winx, int winy, int winw, int winh, const #pragma omp critical #endif { - chmax[0] = chmax[1] = chmax[2] = chmax[3] = max (tmpchmax, chmax[0]); + chmax[0] = chmax[1] = chmax[2] = chmax[3] = max(tmpchmax, chmax[0]); } } } else if (ri->getSensorType() == ST_FUJI_XTRANS) { @@ -3542,12 +3545,12 @@ void RawImageSource::scaleColors (int winx, int winy, int winw, int winh, const { for (int col = winx; col < winx + winw; col++) { float val = rawData[row][col]; - int c = ri->XTRANSFC (row, col); + int c = ri->XTRANSFC(row, col); val -= cblacksom[c]; val *= scale_mul[c]; rawData[row][col] = (val); - tmpchmax[c] = max (tmpchmax[c], val); + tmpchmax[c] = max(tmpchmax[c], val); } } @@ -3555,9 +3558,9 @@ void RawImageSource::scaleColors (int winx, int winy, int winw, int winh, const #pragma omp critical #endif { - chmax[0] = max (tmpchmax[0], chmax[0]); - chmax[1] = max (tmpchmax[1], chmax[1]); - chmax[2] = max (tmpchmax[2], chmax[2]); + chmax[0] = max(tmpchmax[0], chmax[0]); + chmax[1] = max(tmpchmax[1], chmax[1]); + chmax[2] = max(tmpchmax[2], chmax[2]); } } } else { @@ -3579,7 +3582,7 @@ void RawImageSource::scaleColors (int winx, int winy, int winw, int winh, const val -= cblacksom[c]; val *= scale_mul[c]; rawData[row][3 * col + c] = (val); - tmpchmax[c] = max (tmpchmax[c], val); + tmpchmax[c] = max(tmpchmax[c], val); } } } @@ -3588,9 +3591,9 @@ void RawImageSource::scaleColors (int winx, int winy, int winw, int winh, const #pragma omp critical #endif { - chmax[0] = max (tmpchmax[0], chmax[0]); - chmax[1] = max (tmpchmax[1], chmax[1]); - chmax[2] = max (tmpchmax[2], chmax[2]); + chmax[0] = max(tmpchmax[0], chmax[0]); + chmax[1] = max(tmpchmax[1], chmax[1]); + chmax[2] = max(tmpchmax[2], chmax[2]); } } chmax[3] = chmax[1]; @@ -3600,7 +3603,7 @@ void RawImageSource::scaleColors (int winx, int winy, int winw, int winh, const //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -int RawImageSource::defTransform (int tran) +int RawImageSource::defTransform(int tran) { int deg = ri->get_rotateDegree(); @@ -3639,7 +3642,7 @@ int RawImageSource::defTransform (int tran) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // Thread called part -void RawImageSource::processFalseColorCorrectionThread (Imagefloat* im, array2D &rbconv_Y, array2D &rbconv_I, array2D &rbconv_Q, array2D &rbout_I, array2D &rbout_Q, const int row_from, const int row_to) +void RawImageSource::processFalseColorCorrectionThread(Imagefloat* im, array2D &rbconv_Y, array2D &rbconv_I, array2D &rbconv_Q, array2D &rbout_I, array2D &rbout_Q, const int row_from, const int row_to) { const int W = im->getWidth(); @@ -3661,8 +3664,8 @@ void RawImageSource::processFalseColorCorrectionThread (Imagefloat* im, array2D int px = (row_from - 1) % 3, cx = row_from % 3, nx = 0; - convert_row_to_YIQ (im->r (row_from - 1), im->g (row_from - 1), im->b (row_from - 1), rbconv_Y[px], rbconv_I[px], rbconv_Q[px], W); - convert_row_to_YIQ (im->r (row_from), im->g (row_from), im->b (row_from), rbconv_Y[cx], rbconv_I[cx], rbconv_Q[cx], W); + convert_row_to_YIQ(im->r(row_from - 1), im->g(row_from - 1), im->b(row_from - 1), rbconv_Y[px], rbconv_I[px], rbconv_Q[px], W); + convert_row_to_YIQ(im->r(row_from), im->g(row_from), im->b(row_from), rbconv_Y[cx], rbconv_I[cx], rbconv_Q[cx], W); for (int j = 0; j < W; j++) { rbout_I[px][j] = rbconv_I[px][j]; @@ -3675,11 +3678,11 @@ void RawImageSource::processFalseColorCorrectionThread (Imagefloat* im, array2D cx = i % 3; nx = (i + 1) % 3; - convert_row_to_YIQ (im->r (i + 1), im->g (i + 1), im->b (i + 1), rbconv_Y[nx], rbconv_I[nx], rbconv_Q[nx], W); + convert_row_to_YIQ(im->r(i + 1), im->g(i + 1), im->b(i + 1), rbconv_Y[nx], rbconv_I[nx], rbconv_Q[nx], W); #ifdef __SSE2__ - pre1[0] = _mm_setr_ps (rbconv_I[px][0], rbconv_Q[px][0], 0, 0) , pre1[1] = _mm_setr_ps (rbconv_I[cx][0], rbconv_Q[cx][0], 0, 0), pre1[2] = _mm_setr_ps (rbconv_I[nx][0], rbconv_Q[nx][0], 0, 0); - pre2[0] = _mm_setr_ps (rbconv_I[px][1], rbconv_Q[px][1], 0, 0) , pre2[1] = _mm_setr_ps (rbconv_I[cx][1], rbconv_Q[cx][1], 0, 0), pre2[2] = _mm_setr_ps (rbconv_I[nx][1], rbconv_Q[nx][1], 0, 0); + pre1[0] = _mm_setr_ps(rbconv_I[px][0], rbconv_Q[px][0], 0, 0), pre1[1] = _mm_setr_ps(rbconv_I[cx][0], rbconv_Q[cx][0], 0, 0), pre1[2] = _mm_setr_ps(rbconv_I[nx][0], rbconv_Q[nx][0], 0, 0); + pre2[0] = _mm_setr_ps(rbconv_I[px][1], rbconv_Q[px][1], 0, 0), pre2[1] = _mm_setr_ps(rbconv_I[cx][1], rbconv_Q[cx][1], 0, 0), pre2[2] = _mm_setr_ps(rbconv_I[nx][1], rbconv_Q[nx][1], 0, 0); // fill first element in rbout_I and rbout_Q rbout_I[cx][0] = rbconv_I[cx][0]; @@ -3687,17 +3690,17 @@ void RawImageSource::processFalseColorCorrectionThread (Imagefloat* im, array2D // median I channel for (int j = 1; j < W - 2; j += 2) { - post1[0] = _mm_setr_ps (rbconv_I[px][j + 1], rbconv_Q[px][j + 1], 0, 0), post1[1] = _mm_setr_ps (rbconv_I[cx][j + 1], rbconv_Q[cx][j + 1], 0, 0), post1[2] = _mm_setr_ps (rbconv_I[nx][j + 1], rbconv_Q[nx][j + 1], 0, 0); - const auto middle = middle4of6 (pre2[0], pre2[1], pre2[2], post1[0], post1[1], post1[2]); - vfloat medianval = median (pre1[0], pre1[1], pre1[2], middle[0], middle[1], middle[2], middle[3]); + post1[0] = _mm_setr_ps(rbconv_I[px][j + 1], rbconv_Q[px][j + 1], 0, 0), post1[1] = _mm_setr_ps(rbconv_I[cx][j + 1], rbconv_Q[cx][j + 1], 0, 0), post1[2] = _mm_setr_ps(rbconv_I[nx][j + 1], rbconv_Q[nx][j + 1], 0, 0); + const auto middle = middle4of6(pre2[0], pre2[1], pre2[2], post1[0], post1[1], post1[2]); + vfloat medianval = median(pre1[0], pre1[1], pre1[2], middle[0], middle[1], middle[2], middle[3]); rbout_I[cx][j] = medianval[0]; rbout_Q[cx][j] = medianval[1]; - post2[0] = _mm_setr_ps (rbconv_I[px][j + 2], rbconv_Q[px][j + 2], 0, 0), post2[1] = _mm_setr_ps (rbconv_I[cx][j + 2], rbconv_Q[cx][j + 2], 0, 0), post2[2] = _mm_setr_ps (rbconv_I[nx][j + 2], rbconv_Q[nx][j + 2], 0, 0); - medianval = median (post2[0], post2[1], post2[2], middle[0], middle[1], middle[2], middle[3]); + post2[0] = _mm_setr_ps(rbconv_I[px][j + 2], rbconv_Q[px][j + 2], 0, 0), post2[1] = _mm_setr_ps(rbconv_I[cx][j + 2], rbconv_Q[cx][j + 2], 0, 0), post2[2] = _mm_setr_ps(rbconv_I[nx][j + 2], rbconv_Q[nx][j + 2], 0, 0); + medianval = median(post2[0], post2[1], post2[2], middle[0], middle[1], middle[2], middle[3]); rbout_I[cx][j + 1] = medianval[0]; rbout_Q[cx][j + 1] = medianval[1]; - std::swap (pre1, post1); - std::swap (pre2, post2); + std::swap(pre1, post1); + std::swap(pre2, post2); } // fill last elements in rbout_I and rbout_Q @@ -3716,12 +3719,12 @@ void RawImageSource::processFalseColorCorrectionThread (Imagefloat* im, array2D // median I channel for (int j = 1; j < W - 2; j += 2) { post1[0] = rbconv_I[px][j + 1], post1[1] = rbconv_I[cx][j + 1], post1[2] = rbconv_I[nx][j + 1]; - const auto middle = middle4of6 (pre2[0], pre2[1], pre2[2], post1[0], post1[1], post1[2]); - rbout_I[cx][j] = median (pre1[0], pre1[1], pre1[2], middle[0], middle[1], middle[2], middle[3]); + const auto middle = middle4of6(pre2[0], pre2[1], pre2[2], post1[0], post1[1], post1[2]); + rbout_I[cx][j] = median(pre1[0], pre1[1], pre1[2], middle[0], middle[1], middle[2], middle[3]); post2[0] = rbconv_I[px][j + 2], post2[1] = rbconv_I[cx][j + 2], post2[2] = rbconv_I[nx][j + 2]; - rbout_I[cx][j + 1] = median (post2[0], post2[1], post2[2], middle[0], middle[1], middle[2], middle[3]); - std::swap (pre1, post1); - std::swap (pre2, post2); + rbout_I[cx][j + 1] = median(post2[0], post2[1], post2[2], middle[0], middle[1], middle[2], middle[3]); + std::swap(pre1, post1); + std::swap(pre2, post2); } // fill last elements in rbout_I @@ -3737,12 +3740,12 @@ void RawImageSource::processFalseColorCorrectionThread (Imagefloat* im, array2D // median Q channel for (int j = 1; j < W - 2; j += 2) { post1[0] = rbconv_Q[px][j + 1], post1[1] = rbconv_Q[cx][j + 1], post1[2] = rbconv_Q[nx][j + 1]; - const auto middle = middle4of6 (pre2[0], pre2[1], pre2[2], post1[0], post1[1], post1[2]); - rbout_Q[cx][j] = median (pre1[0], pre1[1], pre1[2], middle[0], middle[1], middle[2], middle[3]); + const auto middle = middle4of6(pre2[0], pre2[1], pre2[2], post1[0], post1[1], post1[2]); + rbout_Q[cx][j] = median(pre1[0], pre1[1], pre1[2], middle[0], middle[1], middle[2], middle[3]); post2[0] = rbconv_Q[px][j + 2], post2[1] = rbconv_Q[cx][j + 2], post2[2] = rbconv_Q[nx][j + 2]; - rbout_Q[cx][j + 1] = median (post2[0], post2[1], post2[2], middle[0], middle[1], middle[2], middle[3]); - std::swap (pre1, post1); - std::swap (pre2, post2); + rbout_Q[cx][j + 1] = median(post2[0], post2[1], post2[2], middle[0], middle[1], middle[2], middle[3]); + std::swap(pre1, post1); + std::swap(pre2, post2); } // fill last elements in rbout_Q @@ -3752,7 +3755,7 @@ void RawImageSource::processFalseColorCorrectionThread (Imagefloat* im, array2D // blur i-1th row if (i > row_from) { - convert_to_RGB (im->r (i - 1, 0), im->g (i - 1, 0), im->b (i - 1, 0), rbconv_Y[px][0], rbout_I[px][0], rbout_Q[px][0]); + convert_to_RGB(im->r(i - 1, 0), im->g(i - 1, 0), im->b(i - 1, 0), rbconv_Y[px][0], rbout_I[px][0], rbout_Q[px][0]); #ifdef _OPENMP #pragma omp simd @@ -3761,15 +3764,15 @@ void RawImageSource::processFalseColorCorrectionThread (Imagefloat* im, array2D for (int j = 1; j < W - 1; j++) { float I = (rbout_I[px][j - 1] + rbout_I[px][j] + rbout_I[px][j + 1] + rbout_I[cx][j - 1] + rbout_I[cx][j] + rbout_I[cx][j + 1] + rbout_I[nx][j - 1] + rbout_I[nx][j] + rbout_I[nx][j + 1]) * onebynine; float Q = (rbout_Q[px][j - 1] + rbout_Q[px][j] + rbout_Q[px][j + 1] + rbout_Q[cx][j - 1] + rbout_Q[cx][j] + rbout_Q[cx][j + 1] + rbout_Q[nx][j - 1] + rbout_Q[nx][j] + rbout_Q[nx][j + 1]) * onebynine; - convert_to_RGB (im->r (i - 1, j), im->g (i - 1, j), im->b (i - 1, j), rbconv_Y[px][j], I, Q); + convert_to_RGB(im->r(i - 1, j), im->g(i - 1, j), im->b(i - 1, j), rbconv_Y[px][j], I, Q); } - convert_to_RGB (im->r (i - 1, W - 1), im->g (i - 1, W - 1), im->b (i - 1, W - 1), rbconv_Y[px][W - 1], rbout_I[px][W - 1], rbout_Q[px][W - 1]); + convert_to_RGB(im->r(i - 1, W - 1), im->g(i - 1, W - 1), im->b(i - 1, W - 1), rbconv_Y[px][W - 1], rbout_I[px][W - 1], rbout_Q[px][W - 1]); } } // blur last 3 row and finalize H-1th row - convert_to_RGB (im->r (row_to - 1, 0), im->g (row_to - 1, 0), im->b (row_to - 1, 0), rbconv_Y[cx][0], rbout_I[cx][0], rbout_Q[cx][0]); + convert_to_RGB(im->r(row_to - 1, 0), im->g(row_to - 1, 0), im->b(row_to - 1, 0), rbconv_Y[cx][0], rbout_I[cx][0], rbout_Q[cx][0]); #ifdef _OPENMP #pragma omp simd #endif @@ -3777,16 +3780,16 @@ void RawImageSource::processFalseColorCorrectionThread (Imagefloat* im, array2D for (int j = 1; j < W - 1; j++) { float I = (rbout_I[px][j - 1] + rbout_I[px][j] + rbout_I[px][j + 1] + rbout_I[cx][j - 1] + rbout_I[cx][j] + rbout_I[cx][j + 1] + rbconv_I[nx][j - 1] + rbconv_I[nx][j] + rbconv_I[nx][j + 1]) * onebynine; float Q = (rbout_Q[px][j - 1] + rbout_Q[px][j] + rbout_Q[px][j + 1] + rbout_Q[cx][j - 1] + rbout_Q[cx][j] + rbout_Q[cx][j + 1] + rbconv_Q[nx][j - 1] + rbconv_Q[nx][j] + rbconv_Q[nx][j + 1]) * onebynine; - convert_to_RGB (im->r (row_to - 1, j), im->g (row_to - 1, j), im->b (row_to - 1, j), rbconv_Y[cx][j], I, Q); + convert_to_RGB(im->r(row_to - 1, j), im->g(row_to - 1, j), im->b(row_to - 1, j), rbconv_Y[cx][j], I, Q); } - convert_to_RGB (im->r (row_to - 1, W - 1), im->g (row_to - 1, W - 1), im->b (row_to - 1, W - 1), rbconv_Y[cx][W - 1], rbout_I[cx][W - 1], rbout_Q[cx][W - 1]); + convert_to_RGB(im->r(row_to - 1, W - 1), im->g(row_to - 1, W - 1), im->b(row_to - 1, W - 1), rbconv_Y[cx][W - 1], rbout_I[cx][W - 1], rbout_Q[cx][W - 1]); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // correction_YIQ_LQ -void RawImageSource::processFalseColorCorrection (Imagefloat* im, const int steps) +void RawImageSource::processFalseColorCorrection(Imagefloat* im, const int steps) { if (im->getHeight() < 4 || steps < 1) { @@ -3796,7 +3799,7 @@ void RawImageSource::processFalseColorCorrection (Imagefloat* im, const int ste #ifdef _OPENMP #pragma omp parallel { - multi_array2D buffer (W, 3); + multi_array2D buffer(W, 3); int tid = omp_get_thread_num(); int nthreads = omp_get_num_threads(); int blk = (im->getHeight() - 2) / nthreads; @@ -3804,19 +3807,19 @@ void RawImageSource::processFalseColorCorrection (Imagefloat* im, const int ste for (int t = 0; t < steps; t++) { if (tid < nthreads - 1) { - processFalseColorCorrectionThread (im, buffer[0], buffer[1], buffer[2], buffer[3], buffer[4], 1 + tid * blk, 1 + (tid + 1)*blk); + processFalseColorCorrectionThread(im, buffer[0], buffer[1], buffer[2], buffer[3], buffer[4], 1 + tid * blk, 1 + (tid + 1)*blk); } else { - processFalseColorCorrectionThread (im, buffer[0], buffer[1], buffer[2], buffer[3], buffer[4], 1 + tid * blk, im->getHeight() - 1); + processFalseColorCorrectionThread(im, buffer[0], buffer[1], buffer[2], buffer[3], buffer[4], 1 + tid * blk, im->getHeight() - 1); } #pragma omp barrier } } #else - multi_array2D buffer (W, 3); + multi_array2D buffer(W, 3); for (int t = 0; t < steps; t++) { - processFalseColorCorrectionThread (im, buffer[0], buffer[1], buffer[2], buffer[3], buffer[4], 1 , im->getHeight() - 1); + processFalseColorCorrectionThread(im, buffer[0], buffer[1], buffer[2], buffer[3], buffer[4], 1, im->getHeight() - 1); } #endif @@ -3824,7 +3827,7 @@ void RawImageSource::processFalseColorCorrection (Imagefloat* im, const int ste // Some camera input profiles need gamma preprocessing // gamma is applied before the CMS, correct line fac=lineFac*rawPixel+LineSum after the CMS -void RawImageSource::getProfilePreprocParams (cmsHPROFILE in, float& gammaFac, float& lineFac, float& lineSum) +void RawImageSource::getProfilePreprocParams(cmsHPROFILE in, float& gammaFac, float& lineFac, float& lineSum) { gammaFac = 0; lineFac = 1; @@ -3833,10 +3836,10 @@ void RawImageSource::getProfilePreprocParams (cmsHPROFILE in, float& gammaFac, f char copyright[256]; copyright[0] = 0; - if (cmsGetProfileInfoASCII (in, cmsInfoCopyright, cmsNoLanguage, cmsNoCountry, copyright, 256) > 0) { - if (strstr (copyright, "Phase One") != nullptr) { + if (cmsGetProfileInfoASCII(in, cmsInfoCopyright, cmsNoLanguage, cmsNoCountry, copyright, 256) > 0) { + if (strstr(copyright, "Phase One") != nullptr) { gammaFac = 0.55556; // 1.8 - } else if (strstr (copyright, "Nikon Corporation") != nullptr) { + } else if (strstr(copyright, "Nikon Corporation") != nullptr) { gammaFac = 0.5; lineFac = -0.4; lineSum = 1.35; // determined in reverse by measuring NX an RT developed colorchecker PNGs @@ -3847,7 +3850,7 @@ void RawImageSource::getProfilePreprocParams (cmsHPROFILE in, float& gammaFac, f //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% static void -lab2ProphotoRgbD50 (float L, float A, float B, float& r, float& g, float& b) +lab2ProphotoRgbD50(float L, float A, float B, float& r, float& g, float& b) { float X; float Y; @@ -3887,13 +3890,13 @@ lab2ProphotoRgbD50 (float L, float A, float B, float& r, float& g, float& b) r = prophoto_xyz[0][0] * X + prophoto_xyz[0][1] * Y + prophoto_xyz[0][2] * Z; g = prophoto_xyz[1][0] * X + prophoto_xyz[1][1] * Y + prophoto_xyz[1][2] * Z; b = prophoto_xyz[2][0] * X + prophoto_xyz[2][1] * Y + prophoto_xyz[2][2] * Z; - r = CLIP01 (r); - g = CLIP01 (g); - b = CLIP01 (b); + r = CLIP01(r); + g = CLIP01(g); + b = CLIP01(b); } // Converts raw image including ICC input profile to working space - floating point version -void RawImageSource::colorSpaceConversion_ (Imagefloat* im, const ColorManagementParams& cmp, const ColorTemp &wb, double pre_mul[3], cmsHPROFILE embedded, cmsHPROFILE camprofile, double camMatrix[3][3], const std::string &camName) +void RawImageSource::colorSpaceConversion_(Imagefloat* im, const ColorManagementParams& cmp, const ColorTemp &wb, double pre_mul[3], cmsHPROFILE embedded, cmsHPROFILE camprofile, double camMatrix[3][3], const std::string &camName) { // MyTime t1, t2, t3; @@ -3901,7 +3904,7 @@ void RawImageSource::colorSpaceConversion_ (Imagefloat* im, const ColorManagemen cmsHPROFILE in; DCPProfile *dcpProf; - if (!findInputProfile (cmp.input, embedded, camName, &dcpProf, in)) { + if (!findInputProfile(cmp.input, embedded, camName, &dcpProf, in)) { return; } @@ -3918,7 +3921,7 @@ void RawImageSource::colorSpaceConversion_ (Imagefloat* im, const ColorManagemen {camMatrix[2][0], camMatrix[2][1], camMatrix[2][2]} } }; - dcpProf->apply (im, cmp.dcpIlluminant, cmp.working, wb, pre_mul_row, cam_matrix, cmp.applyHueSatMap); + dcpProf->apply(im, cmp.dcpIlluminant, cmp.working, wb, pre_mul_row, cam_matrix, cmp.applyHueSatMap); return; } @@ -3927,7 +3930,7 @@ void RawImageSource::colorSpaceConversion_ (Imagefloat* im, const ColorManagemen // in this case we avoid using the slllllooooooowwww lcms // Calculate matrix for direct conversion raw>working space - TMatrix work = ICCStore::getInstance()->workingSpaceInverseMatrix (cmp.working); + TMatrix work = ICCStore::getInstance()->workingSpaceInverseMatrix(cmp.working); double mat[3][3] = {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}}; for (int i = 0; i < 3; i++) @@ -3943,13 +3946,13 @@ void RawImageSource::colorSpaceConversion_ (Imagefloat* im, const ColorManagemen for (int i = 0; i < im->getHeight(); i++) for (int j = 0; j < im->getWidth(); j++) { - float newr = mat[0][0] * im->r (i, j) + mat[0][1] * im->g (i, j) + mat[0][2] * im->b (i, j); - float newg = mat[1][0] * im->r (i, j) + mat[1][1] * im->g (i, j) + mat[1][2] * im->b (i, j); - float newb = mat[2][0] * im->r (i, j) + mat[2][1] * im->g (i, j) + mat[2][2] * im->b (i, j); + float newr = mat[0][0] * im->r(i, j) + mat[0][1] * im->g(i, j) + mat[0][2] * im->b(i, j); + float newg = mat[1][0] * im->r(i, j) + mat[1][1] * im->g(i, j) + mat[1][2] * im->b(i, j); + float newb = mat[2][0] * im->r(i, j) + mat[2][1] * im->g(i, j) + mat[2][2] * im->b(i, j); - im->r (i, j) = newr; - im->g (i, j) = newg; - im->b (i, j) = newb; + im->r(i, j) = newr; + im->g(i, j) = newg; + im->b(i, j) = newb; } } else { @@ -3993,36 +3996,36 @@ void RawImageSource::colorSpaceConversion_ (Imagefloat* im, const ColorManagemen char copyright[256] = ""; char description[256] = ""; - cmsGetProfileInfoASCII (in, cmsInfoCopyright, cmsNoLanguage, cmsNoCountry, copyright, 256); - cmsGetProfileInfoASCII (in, cmsInfoDescription, cmsNoLanguage, cmsNoCountry, description, 256); + cmsGetProfileInfoASCII(in, cmsInfoCopyright, cmsNoLanguage, cmsNoCountry, copyright, 256); + cmsGetProfileInfoASCII(in, cmsInfoDescription, cmsNoLanguage, cmsNoCountry, description, 256); camera_icc_type = CAMERA_ICC_TYPE_GENERIC; // Note: order the identification with the most detailed matching first since the more general ones may also match the more detailed - if ((strstr (copyright, "Leaf") != nullptr || - strstr (copyright, "Phase One A/S") != nullptr || - strstr (copyright, "Kodak") != nullptr || - strstr (copyright, "Creo") != nullptr) && - (strstr (description, "LF2 ") == description || - strstr (description, "LF3 ") == description || - strstr (description, "LeafLF2") == description || - strstr (description, "LeafLF3") == description || - strstr (description, "LeafLF4") == description || - strstr (description, "MamiyaLF2") == description || - strstr (description, "MamiyaLF3") == description)) { + if ((strstr(copyright, "Leaf") != nullptr || + strstr(copyright, "Phase One A/S") != nullptr || + strstr(copyright, "Kodak") != nullptr || + strstr(copyright, "Creo") != nullptr) && + (strstr(description, "LF2 ") == description || + strstr(description, "LF3 ") == description || + strstr(description, "LeafLF2") == description || + strstr(description, "LeafLF3") == description || + strstr(description, "LeafLF4") == description || + strstr(description, "MamiyaLF2") == description || + strstr(description, "MamiyaLF3") == description)) { camera_icc_type = CAMERA_ICC_TYPE_LEAF; - } else if (strstr (copyright, "Phase One A/S") != nullptr) { + } else if (strstr(copyright, "Phase One A/S") != nullptr) { camera_icc_type = CAMERA_ICC_TYPE_PHASE_ONE; - } else if (strstr (copyright, "Nikon Corporation") != nullptr) { + } else if (strstr(copyright, "Nikon Corporation") != nullptr) { camera_icc_type = CAMERA_ICC_TYPE_NIKON; } } // Initialize transform cmsHTRANSFORM hTransform; - cmsHPROFILE prophoto = ICCStore::getInstance()->workingSpace ("ProPhoto"); // We always use Prophoto to apply the ICC profile to minimize problems with clipping in LUT conversion. + cmsHPROFILE prophoto = ICCStore::getInstance()->workingSpace("ProPhoto"); // We always use Prophoto to apply the ICC profile to minimize problems with clipping in LUT conversion. bool transform_via_pcs_lab = false; bool separate_pcs_lab_highlights = false; - lcmsMutex->lock (); + lcmsMutex->lock(); switch (camera_icc_type) { case CAMERA_ICC_TYPE_PHASE_ONE: @@ -4031,7 +4034,7 @@ void RawImageSource::colorSpaceConversion_ (Imagefloat* im, const ColorManagemen transform_via_pcs_lab = true; separate_pcs_lab_highlights = true; // We transform to Lab because we can and that we avoid getting an unnecessary unmatched gamma conversion which we would need to revert. - hTransform = cmsCreateTransform (in, TYPE_RGB_FLT, nullptr, TYPE_Lab_FLT, INTENT_RELATIVE_COLORIMETRIC, cmsFLAGS_NOOPTIMIZE | cmsFLAGS_NOCACHE ); + hTransform = cmsCreateTransform(in, TYPE_RGB_FLT, nullptr, TYPE_Lab_FLT, INTENT_RELATIVE_COLORIMETRIC, cmsFLAGS_NOOPTIMIZE | cmsFLAGS_NOCACHE); for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { @@ -4049,42 +4052,42 @@ void RawImageSource::colorSpaceConversion_ (Imagefloat* im, const ColorManagemen case CAMERA_ICC_TYPE_NIKON: case CAMERA_ICC_TYPE_GENERIC: default: - hTransform = cmsCreateTransform (in, TYPE_RGB_FLT, prophoto, TYPE_RGB_FLT, INTENT_RELATIVE_COLORIMETRIC, cmsFLAGS_NOOPTIMIZE | cmsFLAGS_NOCACHE ); // NOCACHE is important for thread safety + hTransform = cmsCreateTransform(in, TYPE_RGB_FLT, prophoto, TYPE_RGB_FLT, INTENT_RELATIVE_COLORIMETRIC, cmsFLAGS_NOOPTIMIZE | cmsFLAGS_NOCACHE); // NOCACHE is important for thread safety break; } - lcmsMutex->unlock (); + lcmsMutex->unlock(); if (hTransform == nullptr) { // Fallback: create transform from camera profile. Should not happen normally. - lcmsMutex->lock (); - hTransform = cmsCreateTransform (camprofile, TYPE_RGB_FLT, prophoto, TYPE_RGB_FLT, INTENT_RELATIVE_COLORIMETRIC, cmsFLAGS_NOOPTIMIZE | cmsFLAGS_NOCACHE ); - lcmsMutex->unlock (); + lcmsMutex->lock(); + hTransform = cmsCreateTransform(camprofile, TYPE_RGB_FLT, prophoto, TYPE_RGB_FLT, INTENT_RELATIVE_COLORIMETRIC, cmsFLAGS_NOOPTIMIZE | cmsFLAGS_NOCACHE); + lcmsMutex->unlock(); } TMatrix toxyz = {}, torgb = {}; if (!working_space_is_prophoto) { - toxyz = ICCStore::getInstance()->workingSpaceMatrix ("ProPhoto"); - torgb = ICCStore::getInstance()->workingSpaceInverseMatrix (cmp.working); //sRGB .. Adobe...Wide... + toxyz = ICCStore::getInstance()->workingSpaceMatrix("ProPhoto"); + torgb = ICCStore::getInstance()->workingSpaceInverseMatrix(cmp.working); //sRGB .. Adobe...Wide... } #ifdef _OPENMP #pragma omp parallel #endif { - AlignedBuffer buffer (im->getWidth() * 3); - AlignedBuffer hl_buffer (im->getWidth() * 3); - AlignedBuffer hl_scale (im->getWidth()); + AlignedBuffer buffer(im->getWidth() * 3); + AlignedBuffer hl_buffer(im->getWidth() * 3); + AlignedBuffer hl_scale(im->getWidth()); #ifdef _OPENMP #pragma omp for schedule(static) #endif - for ( int h = 0; h < im->getHeight(); ++h ) { - float *p = buffer.data, *pR = im->r (h), *pG = im->g (h), *pB = im->b (h); + for (int h = 0; h < im->getHeight(); ++h) { + float *p = buffer.data, *pR = im->r(h), *pG = im->g(h), *pB = im->b(h); // Apply pre-processing - for ( int w = 0; w < im->getWidth(); ++w ) { + for (int w = 0; w < im->getWidth(); ++w) { float r = * (pR++); float g = * (pG++); float b = * (pB++); @@ -4094,7 +4097,7 @@ void RawImageSource::colorSpaceConversion_ (Imagefloat* im, const ColorManagemen g /= 65535.0f; b /= 65535.0f; - float maxc = max (r, g, b); + float maxc = max(r, g, b); if (maxc <= 1.0) { hl_scale.data[w] = 1.0; @@ -4114,12 +4117,12 @@ void RawImageSource::colorSpaceConversion_ (Imagefloat* im, const ColorManagemen // We will revert this curve after we've made the color transform. However when we revert the curve, we'll notice that // highlight rendering suffers due to that the LUT transform don't expand well, therefore we do a less compressed // conversion too and mix them, this gives us the highest quality and most flexible result. - hl_buffer.data[3 * w + 0] = pow_F (r, 1.0 / 1.8); - hl_buffer.data[3 * w + 1] = pow_F (g, 1.0 / 1.8); - hl_buffer.data[3 * w + 2] = pow_F (b, 1.0 / 1.8); - r = phaseOneIccCurveInv->getVal (r); - g = phaseOneIccCurveInv->getVal (g); - b = phaseOneIccCurveInv->getVal (b); + hl_buffer.data[3 * w + 0] = pow_F(r, 1.0 / 1.8); + hl_buffer.data[3 * w + 1] = pow_F(g, 1.0 / 1.8); + hl_buffer.data[3 * w + 2] = pow_F(b, 1.0 / 1.8); + r = phaseOneIccCurveInv->getVal(r); + g = phaseOneIccCurveInv->getVal(g); + b = phaseOneIccCurveInv->getVal(b); break; case CAMERA_ICC_TYPE_LEAF: { @@ -4127,20 +4130,20 @@ void RawImageSource::colorSpaceConversion_ (Imagefloat* im, const ColorManagemen float newr = leaf_prophoto_mat[0][0] * r + leaf_prophoto_mat[0][1] * g + leaf_prophoto_mat[0][2] * b; float newg = leaf_prophoto_mat[1][0] * r + leaf_prophoto_mat[1][1] * g + leaf_prophoto_mat[1][2] * b; float newb = leaf_prophoto_mat[2][0] * r + leaf_prophoto_mat[2][1] * g + leaf_prophoto_mat[2][2] * b; - hl_buffer.data[3 * w + 0] = pow_F (newr, 1.0 / 1.8); - hl_buffer.data[3 * w + 1] = pow_F (newg, 1.0 / 1.8); - hl_buffer.data[3 * w + 2] = pow_F (newb, 1.0 / 1.8); - r = phaseOneIccCurveInv->getVal (newr); - g = phaseOneIccCurveInv->getVal (newg); - b = phaseOneIccCurveInv->getVal (newb); + hl_buffer.data[3 * w + 0] = pow_F(newr, 1.0 / 1.8); + hl_buffer.data[3 * w + 1] = pow_F(newg, 1.0 / 1.8); + hl_buffer.data[3 * w + 2] = pow_F(newb, 1.0 / 1.8); + r = phaseOneIccCurveInv->getVal(newr); + g = phaseOneIccCurveInv->getVal(newg); + b = phaseOneIccCurveInv->getVal(newb); break; } case CAMERA_ICC_TYPE_NIKON: // gamma 0.5 - r = sqrtf (r); - g = sqrtf (g); - b = sqrtf (b); + r = sqrtf(r); + g = sqrtf(g); + b = sqrtf(b); break; case CAMERA_ICC_TYPE_GENERIC: @@ -4155,19 +4158,19 @@ void RawImageSource::colorSpaceConversion_ (Imagefloat* im, const ColorManagemen } // Run icc transform - cmsDoTransform (hTransform, buffer.data, buffer.data, im->getWidth()); + cmsDoTransform(hTransform, buffer.data, buffer.data, im->getWidth()); if (separate_pcs_lab_highlights) { - cmsDoTransform (hTransform, hl_buffer.data, hl_buffer.data, im->getWidth()); + cmsDoTransform(hTransform, hl_buffer.data, hl_buffer.data, im->getWidth()); } // Apply post-processing p = buffer.data; - pR = im->r (h); - pG = im->g (h); - pB = im->b (h); + pR = im->r(h); + pG = im->g(h); + pB = im->b(h); - for ( int w = 0; w < im->getWidth(); ++w ) { + for (int w = 0; w < im->getWidth(); ++w) { float r, g, b, hr, hg, hb; @@ -4176,10 +4179,10 @@ void RawImageSource::colorSpaceConversion_ (Imagefloat* im, const ColorManagemen float A = * (p++); float B = * (p++); // profile connection space CIELAB should have D50 illuminant - lab2ProphotoRgbD50 (L, A, B, r, g, b); + lab2ProphotoRgbD50(L, A, B, r, g, b); if (separate_pcs_lab_highlights) { - lab2ProphotoRgbD50 (hl_buffer.data[3 * w + 0], hl_buffer.data[3 * w + 1], hl_buffer.data[3 * w + 2], hr, hg, hb); + lab2ProphotoRgbD50(hl_buffer.data[3 * w + 0], hl_buffer.data[3 * w + 1], hl_buffer.data[3 * w + 2], hr, hg, hb); } } else { r = * (p++); @@ -4195,15 +4198,15 @@ void RawImageSource::colorSpaceConversion_ (Imagefloat* im, const ColorManagemen case CAMERA_ICC_TYPE_PHASE_ONE: case CAMERA_ICC_TYPE_LEAF: { // note the 1/1.8 gamma, it's the gamma that the profile has applied, which we must revert before we can revert the curve - r = phaseOneIccCurve->getVal (pow_F (r, 1.0 / 1.8)); - g = phaseOneIccCurve->getVal (pow_F (g, 1.0 / 1.8)); - b = phaseOneIccCurve->getVal (pow_F (b, 1.0 / 1.8)); + r = phaseOneIccCurve->getVal(pow_F(r, 1.0 / 1.8)); + g = phaseOneIccCurve->getVal(pow_F(g, 1.0 / 1.8)); + b = phaseOneIccCurve->getVal(pow_F(b, 1.0 / 1.8)); const float mix = 0.25; // may seem a low number, but remember this is linear space, mixing starts 2 stops from clipping - const float maxc = max (r, g, b); + const float maxc = max(r, g, b); if (maxc > mix) { float fac = (maxc - mix) / (1.0 - mix); - fac = sqrtf (sqrtf (fac)); // gamma 0.25 to mix in highlight render relatively quick + fac = sqrtf(sqrtf(fac)); // gamma 0.25 to mix in highlight render relatively quick r = (1.0 - fac) * r + fac * hr; g = (1.0 - fac) * g + fac * hg; b = (1.0 - fac) * b + fac * hb; @@ -4234,9 +4237,9 @@ void RawImageSource::colorSpaceConversion_ (Imagefloat* im, const ColorManagemen // to a small space such as sRGB we may end up with negative values and values larger than max. if (!working_space_is_prophoto) { //convert from Prophoto to XYZ - 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 ) ; - float z = (toxyz[2][0] * r + toxyz[2][1] * g + toxyz[2][2] * b ) ; + 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) ; + float z = (toxyz[2][0] * r + toxyz[2][1] * g + toxyz[2][2] * b) ; //convert from XYZ to cmp.working (sRGB...Adobe...Wide..) r = ((torgb[0][0] * x + torgb[0][1] * y + torgb[0][2] * z)) ; g = ((torgb[1][0] * x + torgb[1][1] * y + torgb[1][2] * z)) ; @@ -4254,7 +4257,7 @@ void RawImageSource::colorSpaceConversion_ (Imagefloat* im, const ColorManagemen } } } // End of parallelization - cmsDeleteTransform (hTransform); + cmsDeleteTransform(hTransform); } //t3.set (); @@ -4263,7 +4266,7 @@ void RawImageSource::colorSpaceConversion_ (Imagefloat* im, const ColorManagemen // Determine RAW input and output profiles. Returns TRUE on success -bool RawImageSource::findInputProfile (Glib::ustring inProfile, cmsHPROFILE embedded, std::string camName, DCPProfile **dcpProf, cmsHPROFILE& in) +bool RawImageSource::findInputProfile(Glib::ustring inProfile, cmsHPROFILE embedded, std::string camName, DCPProfile **dcpProf, cmsHPROFILE& in) { in = nullptr; // cam will be taken on NULL *dcpProf = nullptr; @@ -4276,24 +4279,24 @@ bool RawImageSource::findInputProfile (Glib::ustring inProfile, cmsHPROFILE embe in = embedded; } else if (inProfile == "(cameraICC)") { // DCPs have higher quality, so use them first - *dcpProf = DCPStore::getInstance()->getStdProfile (camName); + *dcpProf = DCPStore::getInstance()->getStdProfile(camName); if (*dcpProf == nullptr) { - in = ICCStore::getInstance()->getStdProfile (camName); + in = ICCStore::getInstance()->getStdProfile(camName); } } else if (inProfile != "(camera)" && inProfile != "") { Glib::ustring normalName = inProfile; - if (!inProfile.compare (0, 5, "file:")) { - normalName = inProfile.substr (5); + if (!inProfile.compare(0, 5, "file:")) { + normalName = inProfile.substr(5); } - if (DCPStore::getInstance()->isValidDCPFileName (normalName)) { - *dcpProf = DCPStore::getInstance()->getProfile (normalName); + if (DCPStore::getInstance()->isValidDCPFileName(normalName)) { + *dcpProf = DCPStore::getInstance()->getProfile(normalName); } if (*dcpProf == nullptr) { - in = ICCStore::getInstance()->getProfile (inProfile); + in = ICCStore::getInstance()->getProfile(inProfile); } } @@ -4305,7 +4308,7 @@ bool RawImageSource::findInputProfile (Glib::ustring inProfile, cmsHPROFILE embe //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // derived from Dcraw "blend_highlights()" // very effective to reduce (or remove) the magenta, but with levels of grey ! -void RawImageSource::HLRecovery_blend (float* rin, float* gin, float* bin, int width, float maxval, float* hlmax) +void RawImageSource::HLRecovery_blend(float* rin, float* gin, float* bin, int width, float maxval, float* hlmax) { const int ColorCount = 3; @@ -4321,7 +4324,7 @@ void RawImageSource::HLRecovery_blend (float* rin, float* gin, float* bin, int w #define FOREACHCOLOR for (int c=0; c < ColorCount; c++) - float minpt = min (hlmax[0], hlmax[1], hlmax[2]); //min of the raw clip points + float minpt = min(hlmax[0], hlmax[1], hlmax[2]); //min of the raw clip points //float maxpt=max(hlmax[0],hlmax[1],hlmax[2]);//max of the raw clip points //float medpt=hlmax[0]+hlmax[1]+hlmax[2]-minpt-maxpt;//median of the raw clip points float maxave = (hlmax[0] + hlmax[1] + hlmax[2]) / 3; //ave of the raw clip points @@ -4331,7 +4334,7 @@ void RawImageSource::HLRecovery_blend (float* rin, float* gin, float* bin, int w const float satthresh = 0.5; float clip[3]; - FOREACHCOLOR clip[c] = min (maxave, hlmax[c]); + FOREACHCOLOR clip[c] = min(maxave, hlmax[c]); // Determine the maximum level (clip) of all channels const float clippt = clipthresh * maxval; @@ -4362,9 +4365,9 @@ void RawImageSource::HLRecovery_blend (float* rin, float* gin, float* bin, int w // Initialize cam with raw input [0] and potentially clipped input [1] FOREACHCOLOR { - lratio += min (rgb[c], clip[c]); + lratio += min(rgb[c], clip[c]); cam[0][c] = rgb[c]; - cam[1][c] = min (cam[0][c], maxval); + cam[1][c] = min(cam[0][c], maxval); } // Calculate the lightness correction ratio (chratio) @@ -4381,11 +4384,11 @@ void RawImageSource::HLRecovery_blend (float* rin, float* gin, float* bin, int w sum[i] = 0; for (int c = 1; c < ColorCount; c++) { - sum[i] += SQR (lab[i][c]); + sum[i] += SQR(lab[i][c]); } } - chratio = (sqrt (sum[1] / sum[0])); + chratio = (sqrt(sum[1] / sum[0])); // Apply ratio to lightness in LCH space for (int c = 1; c < ColorCount; c++) { @@ -4405,18 +4408,18 @@ void RawImageSource::HLRecovery_blend (float* rin, float* gin, float* bin, int w // Copy converted pixel back if (rin[col] > fixpt) { - float rfrac = SQR ((min (clip[0], rin[col]) - fixpt) / (clip[0] - fixpt)); - rin[col] = min (maxave, rfrac * rgb[0] + (1 - rfrac) * rin[col]); + float rfrac = SQR((min(clip[0], rin[col]) - fixpt) / (clip[0] - fixpt)); + rin[col] = min(maxave, rfrac * rgb[0] + (1 - rfrac) * rin[col]); } if (gin[col] > fixpt) { - float gfrac = SQR ((min (clip[1], gin[col]) - fixpt) / (clip[1] - fixpt)); - gin[col] = min (maxave, gfrac * rgb[1] + (1 - gfrac) * gin[col]); + float gfrac = SQR((min(clip[1], gin[col]) - fixpt) / (clip[1] - fixpt)); + gin[col] = min(maxave, gfrac * rgb[1] + (1 - gfrac) * gin[col]); } if (bin[col] > fixpt) { - float bfrac = SQR ((min (clip[2], bin[col]) - fixpt) / (clip[2] - fixpt)); - bin[col] = min (maxave, bfrac * rgb[2] + (1 - bfrac) * bin[col]); + float bfrac = SQR((min(clip[2], bin[col]) - fixpt) / (clip[2] - fixpt)); + bin[col] = min(maxave, bfrac * rgb[2] + (1 - bfrac) * bin[col]); } lratio /= (rin[col] + gin[col] + bin[col]); @@ -4428,7 +4431,7 @@ void RawImageSource::HLRecovery_blend (float* rin, float* gin, float* bin, int w bin[col] = L + H / 3.0; if ((L = (rin[col] + gin[col] + bin[col]) / 3) > desatpt) { - float Lfrac = max (0.0f, (maxave - L) / (maxave - desatpt)); + float Lfrac = max(0.0f, (maxave - L) / (maxave - desatpt)); C = Lfrac * 1.732050808 * (rin[col] - gin[col]); H = Lfrac * (2 * bin[col] - rin[col] - gin[col]); rin[col] = L - H / 6.0 + C / 3.464101615; @@ -4438,16 +4441,16 @@ void RawImageSource::HLRecovery_blend (float* rin, float* gin, float* bin, int w } } -void RawImageSource::HLRecovery_Luminance (float* rin, float* gin, float* bin, float* rout, float* gout, float* bout, int width, float maxval) +void RawImageSource::HLRecovery_Luminance(float* rin, float* gin, float* bin, float* rout, float* gout, float* bout, int width, float maxval) { for (int i = 0; i < width; i++) { float r = rin[i], g = gin[i], b = bin[i]; if (r > maxval || g > maxval || b > maxval) { - float ro = min (r, maxval); - float go = min (g, maxval); - float bo = min (b, maxval); + float ro = min(r, maxval); + float go = min(g, maxval); + float bo = min(b, maxval); double L = r + g + b; double C = 1.732050808 * (r - g); double H = 2 * b - r - g; @@ -4455,7 +4458,7 @@ void RawImageSource::HLRecovery_Luminance (float* rin, float* gin, float* bin, f double Ho = 2 * bo - ro - go; if (r != g && g != b) { - double ratio = sqrt ((Co * Co + Ho * Ho) / (C * C + H * H)); + double ratio = sqrt((Co * Co + Ho * Ho) / (C * C + H * H)); C *= ratio; H *= ratio; } @@ -4476,8 +4479,8 @@ void RawImageSource::HLRecovery_Luminance (float* rin, float* gin, float* bin, f //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -void RawImageSource::HLRecovery_CIELab (float* rin, float* gin, float* bin, float* rout, float* gout, float* bout, - int width, float maxval, double xyz_cam[3][3], double cam_xyz[3][3]) +void RawImageSource::HLRecovery_CIELab(float* rin, float* gin, float* bin, float* rout, float* gout, float* bout, + int width, float maxval, double xyz_cam[3][3], double cam_xyz[3][3]) { //static bool crTableReady = false; @@ -4495,24 +4498,24 @@ void RawImageSource::HLRecovery_CIELab (float* rin, float* gin, float* bin, floa float r = rin[i], g = gin[i], b = bin[i]; if (r > maxval || g > maxval || b > maxval) { - float ro = min (r, maxval); - float go = min (g, maxval); - float bo = min (b, maxval); + float ro = min(r, maxval); + float go = min(g, maxval); + float bo = min(b, maxval); float yy = xyz_cam[1][0] * r + xyz_cam[1][1] * g + xyz_cam[1][2] * b; - float fy = (yy < 65535.0 ? Color::cachef[yy] / 327.68 : std::cbrt (yy / MAXVALD)); + float fy = (yy < 65535.0 ? Color::cachef[yy] / 327.68 : std::cbrt(yy / MAXVALD)); // compute LCH decompostion of the clipped pixel (only color information, thus C and H will be used) float x = xyz_cam[0][0] * ro + xyz_cam[0][1] * go + xyz_cam[0][2] * bo; float y = xyz_cam[1][0] * ro + xyz_cam[1][1] * go + xyz_cam[1][2] * bo; float z = xyz_cam[2][0] * ro + xyz_cam[2][1] * go + xyz_cam[2][2] * bo; - x = (x < 65535.0 ? Color::cachef[x] / 327.68 : std::cbrt (x / MAXVALD)); - y = (y < 65535.0 ? Color::cachef[y] / 327.68 : std::cbrt (y / MAXVALD)); - z = (z < 65535.0 ? Color::cachef[z] / 327.68 : std::cbrt (z / MAXVALD)); + x = (x < 65535.0 ? Color::cachef[x] / 327.68 : std::cbrt(x / MAXVALD)); + y = (y < 65535.0 ? Color::cachef[y] / 327.68 : std::cbrt(y / MAXVALD)); + z = (z < 65535.0 ? Color::cachef[z] / 327.68 : std::cbrt(z / MAXVALD)); // convert back to rgb double fz = fy - y + z; double fx = fy + x - y; - double zr = Color::f2xyz (fz); - double xr = Color::f2xyz (fx); + double zr = Color::f2xyz(fz); + double xr = Color::f2xyz(fx); x = xr * 65535.0 ; y = yy; @@ -4533,35 +4536,35 @@ void RawImageSource::HLRecovery_CIELab (float* rin, float* gin, float* bin, floa //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -void RawImageSource::hlRecovery (const std::string &method, float* red, float* green, float* blue, int width, float* hlmax ) +void RawImageSource::hlRecovery(const std::string &method, float* red, float* green, float* blue, int width, float* hlmax) { if (method == "Luminance") { - HLRecovery_Luminance (red, green, blue, red, green, blue, width, 65535.0); + HLRecovery_Luminance(red, green, blue, red, green, blue, width, 65535.0); } else if (method == "CIELab blending") { - HLRecovery_CIELab (red, green, blue, red, green, blue, width, 65535.0, imatrices.xyz_cam, imatrices.cam_xyz); + HLRecovery_CIELab(red, green, blue, red, green, blue, width, 65535.0, imatrices.xyz_cam, imatrices.cam_xyz); } else if (method == "Blend") { // derived from Dcraw - HLRecovery_blend (red, green, blue, width, 65535.0, hlmax); + HLRecovery_blend(red, green, blue, width, 65535.0, hlmax); } } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -void RawImageSource::getAutoExpHistogram (LUTu & histogram, int& histcompr) +void RawImageSource::getAutoExpHistogram(LUTu & histogram, int& histcompr) { // BENCHFUN histcompr = 3; - histogram (65536 >> histcompr); + histogram(65536 >> histcompr); histogram.clear(); - const float refwb[3] = {static_cast (refwb_red / (1 << histcompr)), static_cast (refwb_green / (1 << histcompr)), static_cast (refwb_blue / (1 << histcompr))}; + const float refwb[3] = {static_cast(refwb_red / (1 << histcompr)), static_cast(refwb_green / (1 << histcompr)), static_cast(refwb_blue / (1 << histcompr))}; #ifdef _OPENMP #pragma omp parallel #endif { - LUTu tmphistogram (histogram.getSize()); + LUTu tmphistogram(histogram.getSize()); tmphistogram.clear(); #ifdef _OPENMP #pragma omp for schedule(dynamic,16) nowait @@ -4569,43 +4572,43 @@ void RawImageSource::getAutoExpHistogram (LUTu & histogram, int& histcompr) for (int i = border; i < H - border; i++) { int start, end; - getRowStartEnd (i, start, end); + getRowStartEnd(i, start, end); if (ri->getSensorType() == ST_BAYER) { // precalculate factors to avoid expensive per pixel calculations - float refwb0 = refwb[ri->FC (i, start)]; - float refwb1 = refwb[ri->FC (i, start + 1)]; + float refwb0 = refwb[ri->FC(i, start)]; + float refwb1 = refwb[ri->FC(i, start + 1)]; int j; for (j = start; j < end - 1; j += 2) { - tmphistogram[ (int) (refwb0 * rawData[i][j])] += 4; - tmphistogram[ (int) (refwb1 * rawData[i][j + 1])] += 4; + tmphistogram[(int)(refwb0 * rawData[i][j])] += 4; + tmphistogram[(int)(refwb1 * rawData[i][j + 1])] += 4; } if (j < end) { - tmphistogram[ (int) (refwb0 * rawData[i][j])] += 4; + tmphistogram[(int)(refwb0 * rawData[i][j])] += 4; } } else if (ri->getSensorType() == ST_FUJI_XTRANS) { // precalculate factors to avoid expensive per pixel calculations - float refwb0 = refwb[ri->XTRANSFC (i, start)]; - float refwb1 = refwb[ri->XTRANSFC (i, start + 1)]; - float refwb2 = refwb[ri->XTRANSFC (i, start + 2)]; - float refwb3 = refwb[ri->XTRANSFC (i, start + 3)]; - float refwb4 = refwb[ri->XTRANSFC (i, start + 4)]; - float refwb5 = refwb[ri->XTRANSFC (i, start + 5)]; + float refwb0 = refwb[ri->XTRANSFC(i, start)]; + float refwb1 = refwb[ri->XTRANSFC(i, start + 1)]; + float refwb2 = refwb[ri->XTRANSFC(i, start + 2)]; + float refwb3 = refwb[ri->XTRANSFC(i, start + 3)]; + float refwb4 = refwb[ri->XTRANSFC(i, start + 4)]; + float refwb5 = refwb[ri->XTRANSFC(i, start + 5)]; int j; for (j = start; j < end - 5; j += 6) { - tmphistogram[ (int) (refwb0 * rawData[i][j])] += 4; - tmphistogram[ (int) (refwb1 * rawData[i][j + 1])] += 4; - tmphistogram[ (int) (refwb2 * rawData[i][j + 2])] += 4; - tmphistogram[ (int) (refwb3 * rawData[i][j + 3])] += 4; - tmphistogram[ (int) (refwb4 * rawData[i][j + 4])] += 4; - tmphistogram[ (int) (refwb5 * rawData[i][j + 5])] += 4; + tmphistogram[(int)(refwb0 * rawData[i][j])] += 4; + tmphistogram[(int)(refwb1 * rawData[i][j + 1])] += 4; + tmphistogram[(int)(refwb2 * rawData[i][j + 2])] += 4; + tmphistogram[(int)(refwb3 * rawData[i][j + 3])] += 4; + tmphistogram[(int)(refwb4 * rawData[i][j + 4])] += 4; + tmphistogram[(int)(refwb5 * rawData[i][j + 5])] += 4; } for (; j < end; j++) { - tmphistogram[ (int) (refwb[ri->XTRANSFC (i, j)] * rawData[i][j])] += 4; + tmphistogram[(int)(refwb[ri->XTRANSFC(i, j)] * rawData[i][j])] += 4; } } else if (ri->get_colors() == 1) { for (int j = start; j < end; j++) { @@ -4630,59 +4633,59 @@ void RawImageSource::getAutoExpHistogram (LUTu & histogram, int& histcompr) } // Histogram MUST be 256 in size; gamma is applied, blackpoint and gain also -void RawImageSource::getRAWHistogram (LUTu & histRedRaw, LUTu & histGreenRaw, LUTu & histBlueRaw) +void RawImageSource::getRAWHistogram(LUTu & histRedRaw, LUTu & histGreenRaw, LUTu & histBlueRaw) { // BENCHFUN histRedRaw.clear(); histGreenRaw.clear(); histBlueRaw.clear(); - const float mult[4] = { 65535.0f / ri->get_white (0), - 65535.0f / ri->get_white (1), - 65535.0f / ri->get_white (2), - 65535.0f / ri->get_white (3) + const float mult[4] = { 65535.0f / ri->get_white(0), + 65535.0f / ri->get_white(1), + 65535.0f / ri->get_white(2), + 65535.0f / ri->get_white(3) }; - const bool fourColours = ri->getSensorType() == ST_BAYER && ((mult[1] != mult[3] || cblacksom[1] != cblacksom[3]) || FC (0, 0) == 3 || FC (0, 1) == 3 || FC (1, 0) == 3 || FC (1, 1) == 3); + const bool fourColours = ri->getSensorType() == ST_BAYER && ((mult[1] != mult[3] || cblacksom[1] != cblacksom[3]) || FC(0, 0) == 3 || FC(0, 1) == 3 || FC(1, 0) == 3 || FC(1, 1) == 3); constexpr int histoSize = 65536; LUTu hist[4]; - hist[0] (histoSize); + hist[0](histoSize); hist[0].clear(); if (ri->get_colors() > 1) { - hist[1] (histoSize); + hist[1](histoSize); hist[1].clear(); - hist[2] (histoSize); + hist[2](histoSize); hist[2].clear(); } if (fourColours) { - hist[3] (histoSize); + hist[3](histoSize); hist[3].clear(); } #ifdef _OPENMP int numThreads; // reduce the number of threads under certain conditions to avoid overhead of too many critical regions - numThreads = sqrt ((((H - 2 * border) * (W - 2 * border)) / 262144.f)); - numThreads = std::min (std::max (numThreads, 1), omp_get_max_threads()); + numThreads = sqrt((((H - 2 * border) * (W - 2 * border)) / 262144.f)); + numThreads = std::min(std::max(numThreads, 1), omp_get_max_threads()); #pragma omp parallel num_threads(numThreads) #endif { // we need one LUT per color and thread, which corresponds to 1 MB per thread LUTu tmphist[4]; - tmphist[0] (histoSize); + tmphist[0](histoSize); tmphist[0].clear(); if (ri->get_colors() > 1) { - tmphist[1] (histoSize); + tmphist[1](histoSize); tmphist[1].clear(); - tmphist[2] (histoSize); + tmphist[2](histoSize); tmphist[2].clear(); if (fourColours) { - tmphist[3] (histoSize); + tmphist[3](histoSize); tmphist[3].clear(); } } @@ -4693,36 +4696,36 @@ void RawImageSource::getRAWHistogram (LUTu & histRedRaw, LUTu & histGreenRaw, LU for (int i = border; i < H - border; i++) { int start, end; - getRowStartEnd (i, start, end); + getRowStartEnd(i, start, end); if (ri->getSensorType() == ST_BAYER) { int j; - int c1 = FC (i, start); - c1 = ( fourColours && c1 == 1 && ! (i & 1) ) ? 3 : c1; - int c2 = FC (i, start + 1); - c2 = ( fourColours && c2 == 1 && ! (i & 1) ) ? 3 : c2; + int c1 = FC(i, start); + c1 = (fourColours && c1 == 1 && !(i & 1)) ? 3 : c1; + int c2 = FC(i, start + 1); + c2 = (fourColours && c2 == 1 && !(i & 1)) ? 3 : c2; for (j = start; j < end - 1; j += 2) { - tmphist[c1][ (int)ri->data[i][j]]++; - tmphist[c2][ (int)ri->data[i][j + 1]]++; + tmphist[c1][(int)ri->data[i][j]]++; + tmphist[c2][(int)ri->data[i][j + 1]]++; } if (j < end) { // last pixel of row if width is odd - tmphist[c1][ (int)ri->data[i][j]]++; + tmphist[c1][(int)ri->data[i][j]]++; } } else if (ri->get_colors() == 1) { for (int j = start; j < end; j++) { - tmphist[0][ (int)ri->data[i][j]]++; + tmphist[0][(int)ri->data[i][j]]++; } } else if (ri->getSensorType() == ST_FUJI_XTRANS) { for (int j = start; j < end - 1; j += 2) { - int c = ri->XTRANSFC (i, j); - tmphist[c][ (int)ri->data[i][j]]++; + int c = ri->XTRANSFC(i, j); + tmphist[c][(int)ri->data[i][j]]++; } } else { for (int j = start; j < end; j++) { for (int c = 0; c < 3; c++) { - tmphist[c][ (int)ri->data[i][3 * j + c]]++; + tmphist[c][(int)ri->data[i][3 * j + c]]++; } } } @@ -4747,19 +4750,19 @@ void RawImageSource::getRAWHistogram (LUTu & histRedRaw, LUTu & histGreenRaw, LU for (int i = 0; i < 65536; i++) { int idx; - idx = CLIP ((int)Color::gamma (mult[0] * (i - (cblacksom[0]/*+black_lev[0]*/)))); + idx = CLIP((int)Color::gamma(mult[0] * (i - (cblacksom[0]/*+black_lev[0]*/)))); histRedRaw[idx >> 8] += hist[0][i]; if (ri->get_colors() > 1) { - idx = CLIP ((int)Color::gamma (mult[1] * (i - (cblacksom[1]/*+black_lev[1]*/)))); + idx = CLIP((int)Color::gamma(mult[1] * (i - (cblacksom[1]/*+black_lev[1]*/)))); histGreenRaw[idx >> 8] += hist[1][i]; if (fourColours) { - idx = CLIP ((int)Color::gamma (mult[3] * (i - (cblacksom[3]/*+black_lev[3]*/)))); + idx = CLIP((int)Color::gamma(mult[3] * (i - (cblacksom[3]/*+black_lev[3]*/)))); histGreenRaw[idx >> 8] += hist[3][i]; } - idx = CLIP ((int)Color::gamma (mult[2] * (i - (cblacksom[2]/*+black_lev[2]*/)))); + idx = CLIP((int)Color::gamma(mult[2] * (i - (cblacksom[2]/*+black_lev[2]*/)))); histBlueRaw[idx >> 8] += hist[2][i]; } } @@ -4767,12 +4770,10 @@ void RawImageSource::getRAWHistogram (LUTu & histRedRaw, LUTu & histGreenRaw, LU if (ri->getSensorType() == ST_BAYER) // since there are twice as many greens, correct for it for (int i = 0; i < 256; i++) { histGreenRaw[i] >>= 1; - } - else if (ri->getSensorType() == ST_FUJI_XTRANS) // since Xtrans has 2.5 as many greens, correct for it + } else if (ri->getSensorType() == ST_FUJI_XTRANS) // since Xtrans has 2.5 as many greens, correct for it for (int i = 0; i < 256; i++) { histGreenRaw[i] = (histGreenRaw[i] * 2) / 5; - } - else if (ri->get_colors() == 1) { // monochrome sensor => set all histograms equal + } else if (ri->get_colors() == 1) { // monochrome sensor => set all histograms equal histGreenRaw += histRedRaw; histBlueRaw += histRedRaw; } @@ -4781,12 +4782,12 @@ void RawImageSource::getRAWHistogram (LUTu & histRedRaw, LUTu & histGreenRaw, LU //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -void RawImageSource::getRowStartEnd (int x, int &start, int &end) +void RawImageSource::getRowStartEnd(int x, int &start, int &end) { if (fuji) { int fw = ri->get_FujiWidth(); - start = ABS (fw - x) + border; - end = min (H + W - fw - x, fw + x) - border; + start = ABS(fw - x) + border; + end = min(H + W - fw - x, fw + x) - border; } else { start = border; end = W - border; @@ -4794,7 +4795,7 @@ void RawImageSource::getRowStartEnd (int x, int &start, int &end) } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -void RawImageSource::getAutoWBMultipliers (double &rm, double &gm, double &bm) +void RawImageSource::getAutoWBMultipliers(double &rm, double &gm, double &bm) { // BENCHFUN constexpr double clipHigh = 64000.0; @@ -4826,14 +4827,14 @@ void RawImageSource::getAutoWBMultipliers (double &rm, double &gm, double &bm) if (fuji) { for (int i = 32; i < H - 32; i++) { int fw = ri->get_FujiWidth(); - int start = ABS (fw - i) + 32; - int end = min (H + W - fw - i, fw + i) - 32; + int start = ABS(fw - i) + 32; + int end = min(H + W - fw - i, fw + i) - 32; for (int j = start; j < end; j++) { if (ri->getSensorType() != ST_BAYER) { - double dr = CLIP (initialGain * (rawData[i][3 * j] )); - double dg = CLIP (initialGain * (rawData[i][3 * j + 1])); - double db = CLIP (initialGain * (rawData[i][3 * j + 2])); + double dr = CLIP(initialGain * (rawData[i][3 * j])); + double dg = CLIP(initialGain * (rawData[i][3 * j + 1])); + double db = CLIP(initialGain * (rawData[i][3 * j + 2])); if (dr > clipHigh || dg > clipHigh || db > clipHigh) { continue; @@ -4844,8 +4845,8 @@ void RawImageSource::getAutoWBMultipliers (double &rm, double &gm, double &bm) avg_b += db; rn = gn = ++bn; } else { - int c = FC ( i, j); - double d = CLIP (initialGain * (rawData[i][j])); + int c = FC(i, j); + double d = CLIP(initialGain * (rawData[i][j])); if (d > clipHigh) { continue; @@ -4888,7 +4889,7 @@ void RawImageSource::getAutoWBMultipliers (double &rm, double &gm, double &bm) continue; } - int c = ri->XTRANSFC (i, j); + int c = ri->XTRANSFC(i, j); avg_c[c] += d; cn[c]++; } @@ -4914,9 +4915,9 @@ void RawImageSource::getAutoWBMultipliers (double &rm, double &gm, double &bm) for (int j = 32; j < W - 32; j++) { // each loop read 1 rgb triplet value - double dr = CLIP (initialGain * (rawData[i][3 * j] )); - double dg = CLIP (initialGain * (rawData[i][3 * j + 1])); - double db = CLIP (initialGain * (rawData[i][3 * j + 2])); + double dr = CLIP(initialGain * (rawData[i][3 * j])); + double dg = CLIP(initialGain * (rawData[i][3 * j + 1])); + double db = CLIP(initialGain * (rawData[i][3 * j + 2])); if (dr > clipHigh || dg > clipHigh || db > clipHigh) { continue; @@ -4935,8 +4936,8 @@ void RawImageSource::getAutoWBMultipliers (double &rm, double &gm, double &bm) //determine GRBG coset; (ey,ex) is the offset of the R subarray int ey, ex; - if (ri->ISGREEN (0, 0)) { //first pixel is G - if (ri->ISRED (0, 1)) { + if (ri->ISGREEN(0, 0)) { //first pixel is G + if (ri->ISRED(0, 1)) { ey = 0; ex = 1; } else { @@ -4944,7 +4945,7 @@ void RawImageSource::getAutoWBMultipliers (double &rm, double &gm, double &bm) ex = 0; } } else {//first pixel is R or B - if (ri->ISRED (0, 0)) { + if (ri->ISRED(0, 0)) { ey = 0; ex = 0; } else { @@ -4995,8 +4996,8 @@ void RawImageSource::getAutoWBMultipliers (double &rm, double &gm, double &bm) } } - if( settings->verbose ) { - printf ("AVG: %g %g %g\n", avg_r / std::max(1, rn), avg_g / std::max(1, gn), avg_b / std::max(1, bn)); + if (settings->verbose) { + printf("AVG: %g %g %g\n", avg_r / std::max(1, rn), avg_g / std::max(1, gn), avg_b / std::max(1, bn)); } // return ColorTemp (pow(avg_r/rn, 1.0/6.0)*img_r, pow(avg_g/gn, 1.0/6.0)*img_g, pow(avg_b/bn, 1.0/6.0)*img_b); @@ -5013,7 +5014,7 @@ void RawImageSource::getAutoWBMultipliers (double &rm, double &gm, double &bm) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -ColorTemp RawImageSource::getSpotWB (std::vector &red, std::vector &green, std::vector &blue, int tran, double equal) +ColorTemp RawImageSource::getSpotWB(std::vector &red, std::vector &green, std::vector &blue, int tran, double equal) { int x; @@ -5026,7 +5027,7 @@ ColorTemp RawImageSource::getSpotWB (std::vector &red, std::vector &red, std::vector= 0 && yv >= 0 && xv < W && yv < H) { - if (ri->ISXTRANSRED (yv, xv)) { //RED + if (ri->ISXTRANSRED(yv, xv)) { //RED rloc += (rawData[yv][xv]); rnbrs++; continue; - } else if (ri->ISXTRANSBLUE (yv, xv)) { //BLUE + } else if (ri->ISXTRANSBLUE(yv, xv)) { //BLUE bloc += (rawData[yv][xv]); bnbrs++; continue; @@ -5069,23 +5070,23 @@ ColorTemp RawImageSource::getSpotWB (std::vector &red, std::vector 52500 || + if (initialGain * (rawData[yr][3 * xr]) > 52500 || initialGain * (rawData[yg][3 * xg + 1]) > 52500 || initialGain * (rawData[yb][3 * xb + 2]) > 52500) { continue; } - xmin = min (xr, xg, xb); - xmax = max (xr, xg, xb); - ymin = min (yr, yg, yb); - ymax = max (yr, yg, yb); + xmin = min(xr, xg, xb); + xmax = max(xr, xg, xb); + ymin = min(yr, yg, yb); + ymax = max(yr, yg, yb); if (xmin >= 0 && ymin >= 0 && xmax < W && ymax < H) { - reds += (rawData[yr][3 * xr] ); + reds += (rawData[yr][3 * xr]); greens += (rawData[yg][3 * xg + 1]); blues += (rawData[yb][3 * xb + 2]); rn++; @@ -5098,7 +5099,7 @@ ColorTemp RawImageSource::getSpotWB (std::vector &red, std::vector &red, std::vector= 0 && yv >= 0 && xv < W && yv < H) { if (c == 0) { //RED @@ -5136,13 +5137,13 @@ ColorTemp RawImageSource::getSpotWB (std::vector &red, std::vector= 0 && yv >= 0 && xv < W && yv < H) { if (c == 0) { //RED @@ -5172,13 +5173,13 @@ ColorTemp RawImageSource::getSpotWB (std::vector &red, std::vector= 0 && yv >= 0 && xv < W && yv < H) { if (c == 0) { //RED @@ -5211,7 +5212,7 @@ ColorTemp RawImageSource::getSpotWB (std::vector &red, std::vector &red, std::vector cForwardPoints; - cForwardPoints.push_back (double (DCT_Spline)); // The first value is the curve type + cForwardPoints.push_back(double (DCT_Spline)); // The first value is the curve type std::vector cInversePoints; - cInversePoints.push_back (double (DCT_Spline)); // The first value is the curve type + cInversePoints.push_back(double (DCT_Spline)); // The first value is the curve type - for (unsigned int i = 0; i < sizeof (phase_one_forward) / sizeof (phase_one_forward[0]); i += 2) { - cForwardPoints.push_back (phase_one_forward[i + 0]); - cForwardPoints.push_back (phase_one_forward[i + 1]); - cInversePoints.push_back (phase_one_forward[i + 1]); - cInversePoints.push_back (phase_one_forward[i + 0]); + for (unsigned int i = 0; i < sizeof(phase_one_forward) / sizeof(phase_one_forward[0]); i += 2) { + cForwardPoints.push_back(phase_one_forward[i + 0]); + cForwardPoints.push_back(phase_one_forward[i + 1]); + cInversePoints.push_back(phase_one_forward[i + 1]); + cInversePoints.push_back(phase_one_forward[i + 0]); } - phaseOneIccCurve = new DiagonalCurve (cForwardPoints, CURVES_MIN_POLY_POINTS); - phaseOneIccCurveInv = new DiagonalCurve (cInversePoints, CURVES_MIN_POLY_POINTS); + phaseOneIccCurve = new DiagonalCurve(cForwardPoints, CURVES_MIN_POLY_POINTS); + phaseOneIccCurveInv = new DiagonalCurve(cInversePoints, CURVES_MIN_POLY_POINTS); } } -void RawImageSource::getRawValues (int x, int y, int rotate, int &R, int &G, int &B) +void RawImageSource::getRawValues(int x, int y, int rotate, int &R, int &G, int &B) { int xnew = x + border; int ynew = y + border; @@ -5363,20 +5364,20 @@ void RawImageSource::getRawValues (int x, int y, int rotate, int &R, int &G, int rotate %= 360; if (rotate == 90) { - std::swap (xnew, ynew); + std::swap(xnew, ynew); ynew = H - 1 - ynew; } else if (rotate == 180) { xnew = W - 1 - xnew; ynew = H - 1 - ynew; } else if (rotate == 270) { - std::swap (xnew, ynew); + std::swap(xnew, ynew); ynew = H - 1 - ynew; xnew = W - 1 - xnew; ynew = H - 1 - ynew; } - int c = ri->getSensorType() == ST_FUJI_XTRANS ? ri->XTRANSFC (ynew, xnew) : ri->FC (ynew, xnew); - int val = round (rawData[ynew][xnew] / scale_mul[c]); + int c = ri->getSensorType() == ST_FUJI_XTRANS ? ri->XTRANSFC(ynew, xnew) : ri->FC(ynew, xnew); + int val = round(rawData[ynew][xnew] / scale_mul[c]); if (c == 0) { R = val; @@ -5393,7 +5394,7 @@ void RawImageSource::getRawValues (int x, int y, int rotate, int &R, int &G, int } } -void RawImageSource::cleanup () +void RawImageSource::cleanup() { delete phaseOneIccCurve; delete phaseOneIccCurveInv; diff --git a/rtengine/rawimagesource.h b/rtengine/rawimagesource.h index cdd7ca675..a9dd1add8 100644 --- a/rtengine/rawimagesource.h +++ b/rtengine/rawimagesource.h @@ -38,9 +38,9 @@ private: static DiagonalCurve *phaseOneIccCurve; static DiagonalCurve *phaseOneIccCurveInv; static LUTf invGrad; // for fast_demosaic - static LUTf initInvGrad (); - static void colorSpaceConversion_ (Imagefloat* im, const ColorManagementParams& cmp, const ColorTemp &wb, double pre_mul[3], cmsHPROFILE embedded, cmsHPROFILE camprofile, double cam[3][3], const std::string &camName); - int defTransform (int tran); + static LUTf initInvGrad(); + static void colorSpaceConversion_(Imagefloat* im, const ColorManagementParams& cmp, const ColorTemp &wb, double pre_mul[3], cmsHPROFILE embedded, cmsHPROFILE camprofile, double cam[3][3], const std::string &camName); + int defTransform(int tran); protected: MyMutex getImageMutex; // locks getImage @@ -96,36 +96,36 @@ protected: float psBlueBrightness[4]; - void hphd_vertical (float** hpmap, int col_from, int col_to); - void hphd_horizontal (float** hpmap, int row_from, int row_to); - void hphd_green (float** hpmap); - void processFalseColorCorrectionThread (Imagefloat* im, array2D &rbconv_Y, array2D &rbconv_I, array2D &rbconv_Q, array2D &rbout_I, array2D &rbout_Q, const int row_from, const int row_to); - void hlRecovery (const std::string &method, float* red, float* green, float* blue, int width, float* hlmax); - void transformRect (const PreviewProps &pp, int tran, int &sx1, int &sy1, int &width, int &height, int &fw); - void transformPosition (int x, int y, int tran, int& tx, int& ty); + void hphd_vertical(float** hpmap, int col_from, int col_to); + void hphd_horizontal(float** hpmap, int row_from, int row_to); + void hphd_green(float** hpmap); + void processFalseColorCorrectionThread(Imagefloat* im, array2D &rbconv_Y, array2D &rbconv_I, array2D &rbconv_Q, array2D &rbout_I, array2D &rbout_Q, const int row_from, const int row_to); + void hlRecovery(const std::string &method, float* red, float* green, float* blue, int width, float* hlmax); + void transformRect(const PreviewProps &pp, int tran, int &sx1, int &sy1, int &width, int &height, int &fw); + void transformPosition(int x, int y, int tran, int& tx, int& ty); unsigned FC(int row, int col) { return ri->FC(row, col); } - inline void getRowStartEnd (int x, int &start, int &end); + inline void getRowStartEnd(int x, int &start, int &end); static void getProfilePreprocParams(cmsHPROFILE in, float& gammafac, float& lineFac, float& lineSum); public: - RawImageSource (); - ~RawImageSource (); + RawImageSource(); + ~RawImageSource(); - int load (const Glib::ustring &fname); - void preprocess (const RAWParams &raw, const LensProfParams &lensProf, const CoarseTransformParams& coarse, bool prepareDenoise = true); - void demosaic (const RAWParams &raw); - void retinex (const ColorManagementParams& cmp, const RetinexParams &deh, ToneCurveParams Tc, LUTf & cdcurve, LUTf & mapcurve, const RetinextransmissionCurve & dehatransmissionCurve, const RetinexgaintransmissionCurve & dehagaintransmissionCurve, multi_array2D &conversionBuffer, bool dehacontlutili, bool mapcontlutili, bool useHsl, float &minCD, float &maxCD, float &mini, float &maxi, float &Tmean, float &Tsigma, float &Tmin, float &Tmax, LUTu &histLRETI); - void retinexPrepareCurves (const RetinexParams &retinexParams, LUTf &cdcurve, LUTf &mapcurve, RetinextransmissionCurve &retinextransmissionCurve, RetinexgaintransmissionCurve &retinexgaintransmissionCurve, bool &retinexcontlutili, bool &mapcontlutili, bool &useHsl, LUTu & lhist16RETI, LUTu & histLRETI); - void retinexPrepareBuffers (const ColorManagementParams& cmp, const RetinexParams &retinexParams, multi_array2D &conversionBuffer, LUTu &lhist16RETI); - void flushRawData (); - void flushRGB (); - void HLRecovery_Global (ToneCurveParams hrp); - void refinement_lassus (int PassCount); + int load(const Glib::ustring &fname); + void preprocess(const RAWParams &raw, const LensProfParams &lensProf, const CoarseTransformParams& coarse, bool prepareDenoise = true); + void demosaic(const RAWParams &raw); + void retinex(const ColorManagementParams& cmp, const RetinexParams &deh, ToneCurveParams Tc, LUTf & cdcurve, LUTf & mapcurve, const RetinextransmissionCurve & dehatransmissionCurve, const RetinexgaintransmissionCurve & dehagaintransmissionCurve, multi_array2D &conversionBuffer, bool dehacontlutili, bool mapcontlutili, bool useHsl, float &minCD, float &maxCD, float &mini, float &maxi, float &Tmean, float &Tsigma, float &Tmin, float &Tmax, LUTu &histLRETI); + void retinexPrepareCurves(const RetinexParams &retinexParams, LUTf &cdcurve, LUTf &mapcurve, RetinextransmissionCurve &retinextransmissionCurve, RetinexgaintransmissionCurve &retinexgaintransmissionCurve, bool &retinexcontlutili, bool &mapcontlutili, bool &useHsl, LUTu & lhist16RETI, LUTu & histLRETI); + void retinexPrepareBuffers(const ColorManagementParams& cmp, const RetinexParams &retinexParams, multi_array2D &conversionBuffer, LUTu &lhist16RETI); + void flushRawData(); + void flushRGB(); + void HLRecovery_Global(ToneCurveParams hrp); + void refinement_lassus(int PassCount); void refinement(int PassCount); bool isRGBSourceModified() const @@ -134,43 +134,43 @@ public: } void processFlatField(const RAWParams &raw, RawImage *riFlatFile, unsigned short black[4]); - void copyOriginalPixels(const RAWParams &raw, RawImage *ri, RawImage *riDark, RawImage *riFlatFile, array2D &rawData ); - void cfaboxblur (RawImage *riFlatFile, float* cfablur, int boxH, int boxW); - void scaleColors (int winx, int winy, int winw, int winh, const RAWParams &raw, array2D &rawData); // raw for cblack + void copyOriginalPixels(const RAWParams &raw, RawImage *ri, RawImage *riDark, RawImage *riFlatFile, array2D &rawData); + void cfaboxblur(RawImage *riFlatFile, float* cfablur, int boxH, int boxW); + void scaleColors(int winx, int winy, int winw, int winh, const RAWParams &raw, array2D &rawData); // raw for cblack - void getImage (const ColorTemp &ctemp, int tran, Imagefloat* image, const PreviewProps &pp, const ToneCurveParams &hrp, const RAWParams &raw); - eSensorType getSensorType () const + void getImage(const ColorTemp &ctemp, int tran, Imagefloat* image, const PreviewProps &pp, const ToneCurveParams &hrp, const RAWParams &raw); + eSensorType getSensorType() const { return ri != nullptr ? ri->getSensorType() : ST_NONE; } - ColorTemp getWB () const + ColorTemp getWB() const { return camera_wb; } - void getAutoWBMultipliers (double &rm, double &gm, double &bm); - ColorTemp getSpotWB (std::vector &red, std::vector &green, std::vector &blue, int tran, double equal); - bool isWBProviderReady () + void getAutoWBMultipliers(double &rm, double &gm, double &bm); + ColorTemp getSpotWB(std::vector &red, std::vector &green, std::vector &blue, int tran, double equal); + bool isWBProviderReady() { return rawData; } - double getDefGain () const + double getDefGain() const { return defGain; } - void getFullSize (int& w, int& h, int tr = TR_NONE); - void getSize (const PreviewProps &pp, int& w, int& h); + void getFullSize(int& w, int& h, int tr = TR_NONE); + void getSize(const PreviewProps &pp, int& w, int& h); int getRotateDegree() const { return ri->get_rotateDegree(); } - FrameData* getImageData (unsigned int frameNum) + FrameData* getImageData(unsigned int frameNum) { - return idata->getFrameData (frameNum); + return idata->getFrameData(frameNum); } - ImageMatrices* getImageMatrices () + ImageMatrices* getImageMatrices() { return &imatrices; } @@ -179,62 +179,66 @@ public: return true; } - void setProgressListener (ProgressListener* pl) + void setProgressListener(ProgressListener* pl) { plistener = pl; } - void getAutoExpHistogram (LUTu & histogram, int& histcompr); - void getRAWHistogram (LUTu & histRedRaw, LUTu & histGreenRaw, LUTu & histBlueRaw); + void getAutoExpHistogram(LUTu & histogram, int& histcompr); + void getRAWHistogram(LUTu & histRedRaw, LUTu & histGreenRaw, LUTu & histBlueRaw); DCPProfile *getDCP(const ColorManagementParams &cmp, DCPProfile::ApplyState &as); void convertColorSpace(Imagefloat* image, const ColorManagementParams &cmp, const ColorTemp &wb); static bool findInputProfile(Glib::ustring inProfile, cmsHPROFILE embedded, std::string camName, DCPProfile **dcpProf, cmsHPROFILE& in); - static void colorSpaceConversion (Imagefloat* im, const ColorManagementParams& cmp, const ColorTemp &wb, double pre_mul[3], cmsHPROFILE embedded, cmsHPROFILE camprofile, double cam[3][3], const std::string &camName) + static void colorSpaceConversion(Imagefloat* im, const ColorManagementParams& cmp, const ColorTemp &wb, double pre_mul[3], cmsHPROFILE embedded, cmsHPROFILE camprofile, double cam[3][3], const std::string &camName) { - colorSpaceConversion_ (im, cmp, wb, pre_mul, embedded, camprofile, cam, camName); + colorSpaceConversion_(im, cmp, wb, pre_mul, embedded, camprofile, cam, camName); } - static void inverse33 (const double (*coeff)[3], double (*icoeff)[3]); + static void inverse33(const double (*coeff)[3], double (*icoeff)[3]); - void boxblur2(float** src, float** dst, float** temp, int H, int W, int box ); - void boxblur_resamp(float **src, float **dst, float** temp, int H, int W, int box, int samp ); + void boxblur2(float** src, float** dst, float** temp, int H, int W, int box); + void boxblur_resamp(float **src, float **dst, float** temp, int H, int W, int box, int samp); void MSR(float** luminance, float **originalLuminance, float **exLuminance, LUTf & mapcurve, bool &mapcontlutili, int width, int height, const RetinexParams &deh, const RetinextransmissionCurve & dehatransmissionCurve, const RetinexgaintransmissionCurve & dehagaintransmissionCurve, float &minCD, float &maxCD, float &mini, float &maxi, float &Tmean, float &Tsigma, float &Tmin, float &Tmax); - void HLRecovery_inpaint (float** red, float** green, float** blue); - static void HLRecovery_Luminance (float* rin, float* gin, float* bin, float* rout, float* gout, float* bout, int width, float maxval); - static void HLRecovery_CIELab (float* rin, float* gin, float* bin, float* rout, float* gout, float* bout, int width, float maxval, double cam[3][3], double icam[3][3]); - static void HLRecovery_blend (float* rin, float* gin, float* bin, int width, float maxval, float* hlmax); - static void init (); - static void cleanup (); - void setCurrentFrame(unsigned int frameNum) { + void HLRecovery_inpaint(float** red, float** green, float** blue); + static void HLRecovery_Luminance(float* rin, float* gin, float* bin, float* rout, float* gout, float* bout, int width, float maxval); + static void HLRecovery_CIELab(float* rin, float* gin, float* bin, float* rout, float* gout, float* bout, int width, float maxval, double cam[3][3], double icam[3][3]); + static void HLRecovery_blend(float* rin, float* gin, float* bin, int width, float maxval, float* hlmax); + static void init(); + static void cleanup(); + void setCurrentFrame(unsigned int frameNum) + { currFrame = std::min(numFrames - 1, frameNum); ri = riFrames[currFrame]; } - int getFrameCount() {return numFrames;} + int getFrameCount() + { + return numFrames; + } protected: typedef unsigned short ushort; - void processFalseColorCorrection (Imagefloat* i, const int steps); - inline void convert_row_to_YIQ (const float* const r, const float* const g, const float* const b, float* Y, float* I, float* Q, const int W); - inline void convert_row_to_RGB (float* r, float* g, float* b, const float* const Y, const float* const I, const float* const Q, const int W); - inline void convert_to_RGB (float &r, float &g, float &b, const float Y, const float I, const float Q); + void processFalseColorCorrection(Imagefloat* i, const int steps); + inline void convert_row_to_YIQ(const float* const r, const float* const g, const float* const b, float* Y, float* I, float* Q, const int W); + inline void convert_row_to_RGB(float* r, float* g, float* b, const float* const Y, const float* const I, const float* const Q, const int W); + inline void convert_to_RGB(float &r, float &g, float &b, const float Y, const float I, const float Q); - inline void convert_to_cielab_row (float* ar, float* ag, float* ab, float* oL, float* oa, float* ob); - inline void interpolate_row_g (float* agh, float* agv, int i); - inline void interpolate_row_rb (float* ar, float* ab, float* pg, float* cg, float* ng, int i); - inline void interpolate_row_rb_mul_pp (float* ar, float* ab, float* pg, float* cg, float* ng, int i, float r_mul, float g_mul, float b_mul, int x1, int width, int skip); + inline void convert_to_cielab_row(float* ar, float* ag, float* ab, float* oL, float* oa, float* ob); + inline void interpolate_row_g(float* agh, float* agv, int i); + inline void interpolate_row_rb(float* ar, float* ab, float* pg, float* cg, float* ng, int i); + inline void interpolate_row_rb_mul_pp(float* ar, float* ab, float* pg, float* cg, float* ng, int i, float r_mul, float g_mul, float b_mul, int x1, int width, int skip); - void CA_correct_RT (const bool autoCA, const double cared, const double cablue, const double caautostrength, array2D &rawData); + void CA_correct_RT(const bool autoCA, const double cared, const double cablue, const double caautostrength, array2D &rawData); void ddct8x8s(int isgn, float a[8][8]); - void processRawWhitepoint (float expos, float preser, array2D &rawData); // exposure before interpolation + void processRawWhitepoint(float expos, float preser, array2D &rawData); // exposure before interpolation - int interpolateBadPixelsBayer( PixelsMap &bitmapBads, array2D &rawData ); - int interpolateBadPixelsNColours( PixelsMap &bitmapBads, const int colours ); - int interpolateBadPixelsXtrans( PixelsMap &bitmapBads ); - int findHotDeadPixels( PixelsMap &bpMap, float thresh, bool findHotPixels, bool findDeadPixels ); + int interpolateBadPixelsBayer(PixelsMap &bitmapBads, array2D &rawData); + int interpolateBadPixelsNColours(PixelsMap &bitmapBads, const int colours); + int interpolateBadPixelsXtrans(PixelsMap &bitmapBads); + int findHotDeadPixels(PixelsMap &bpMap, float thresh, bool findHotPixels, bool findDeadPixels); - void cfa_linedn (float linenoiselevel);//Emil's line denoise + void cfa_linedn(float linenoiselevel); //Emil's line denoise - void green_equilibrate_global (array2D &rawData); - void green_equilibrate (float greenthresh, array2D &rawData);//Emil's green equilibration + void green_equilibrate_global(array2D &rawData); + void green_equilibrate(float greenthresh, array2D &rawData); //Emil's green equilibration void nodemosaic(bool bw); void eahd_demosaic(); @@ -252,8 +256,8 @@ protected: void border_interpolate(unsigned int border, float (*image)[4], unsigned int start = 0, unsigned int end = 0); void border_interpolate2(int winw, int winh, int lborders); void dcb_initTileLimits(int &colMin, int &rowMin, int &colMax, int &rowMax, int x0, int y0, int border); - void fill_raw( float (*cache )[3], int x0, int y0, float** rawData); - void fill_border( float (*cache )[3], int border, int x0, int y0); + void fill_raw(float (*cache)[3], int x0, int y0, float** rawData); + void fill_border(float (*cache)[3], int border, int x0, int y0); void copy_to_buffer(float (*image2)[2], float (*image)[3]); void dcb_hid(float (*image)[3], int x0, int y0); void dcb_color(float (*image)[3], int x0, int y0); @@ -265,13 +269,13 @@ protected: void restore_from_buffer(float (*image)[3], float (*image2)[2]); void dcb_refinement(float (*image)[3], uint8_t *map, int x0, int y0); void dcb_color_full(float (*image)[3], int x0, int y0, float (*chroma)[2]); - void cielab (const float (*rgb)[3], float* l, float* a, float *b, const int width, const int height, const int labWidth, const float xyz_cam[3][3]); - void xtransborder_interpolate (int border); - void xtrans_interpolate (const int passes, const bool useCieLab); - void fast_xtrans_interpolate (); + void cielab(const float (*rgb)[3], float* l, float* a, float *b, const int width, const int height, const int labWidth, const float xyz_cam[3][3]); + void xtransborder_interpolate(int border); + void xtrans_interpolate(const int passes, const bool useCieLab); + void fast_xtrans_interpolate(); void pixelshift(int winx, int winy, int winw, int winh, const RAWParams::BayerSensor &bayerParams, unsigned int frame, const std::string &make, const std::string &model, float rawWpCorrection); - void hflip (Imagefloat* im); - void vflip (Imagefloat* im); + void hflip(Imagefloat* im); + void vflip(Imagefloat* im); void getRawValues(int x, int y, int rotate, int &R, int &G, int &B); }; diff --git a/rtengine/simpleprocess.cc b/rtengine/simpleprocess.cc index 69335e967..65e1d8ced 100644 --- a/rtengine/simpleprocess.cc +++ b/rtengine/simpleprocess.cc @@ -56,12 +56,12 @@ void adjust_radius(const T &default_param, double scale_factor, T ¶m) class ImageProcessor { public: - ImageProcessor (ProcessingJob* pjob, int& errorCode, - ProgressListener* pl, bool flush): - job (static_cast (pjob)), - errorCode (errorCode), - pl (pl), - flush (flush), + ImageProcessor(ProcessingJob* pjob, int& errorCode, + ProgressListener* pl, bool flush): + job(static_cast(pjob)), + errorCode(errorCode), + pl(pl), + flush(flush), // internal state ipf_p(nullptr), ii(nullptr), @@ -2467,18 +2467,20 @@ private: } switch (params.metadata.mode) { - case MetaDataParams::TUNNEL: - // Sending back the whole first root, which won't necessarily be the selected frame number - // and may contain subframe depending on initial raw's hierarchy - readyImg->setMetadata (ii->getMetaData()->getRootExifData ()); - break; - case MetaDataParams::EDIT: - // ask for the correct frame number, but may contain subframe depending on initial raw's hierarchy - readyImg->setMetadata (ii->getMetaData()->getBestExifData(imgsrc, ¶ms.raw), params.exif, params.iptc); - break; - default: // case MetaDataParams::STRIP - // nothing to do - break; + case MetaDataParams::TUNNEL: + // Sending back the whole first root, which won't necessarily be the selected frame number + // and may contain subframe depending on initial raw's hierarchy + readyImg->setMetadata(ii->getMetaData()->getRootExifData()); + break; + + case MetaDataParams::EDIT: + // ask for the correct frame number, but may contain subframe depending on initial raw's hierarchy + readyImg->setMetadata(ii->getMetaData()->getBestExifData(imgsrc, ¶ms.raw), params.exif, params.iptc); + break; + + default: // case MetaDataParams::STRIP + // nothing to do + break; } @@ -2747,20 +2749,20 @@ private: } // namespace -IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* pl, bool flush) +IImage16* processImage(ProcessingJob* pjob, int& errorCode, ProgressListener* pl, bool flush) { - ImageProcessor proc (pjob, errorCode, pl, flush); + ImageProcessor proc(pjob, errorCode, pl, flush); return proc(); } -void batchProcessingThread (ProcessingJob* job, BatchProcessingListener* bpl) +void batchProcessingThread(ProcessingJob* job, BatchProcessingListener* bpl) { ProcessingJob* currentJob = job; while (currentJob) { int errorCode; - IImage16* img = processImage (currentJob, errorCode, bpl, true); + IImage16* img = processImage(currentJob, errorCode, bpl, true); if (errorCode) { bpl->error(M("MAIN_MSG_CANNOTLOAD")); @@ -2776,11 +2778,11 @@ void batchProcessingThread (ProcessingJob* job, BatchProcessingListener* bpl) } } -void startBatchProcessing (ProcessingJob* job, BatchProcessingListener* bpl) +void startBatchProcessing(ProcessingJob* job, BatchProcessingListener* bpl) { if (bpl) { - Glib::Thread::create (sigc::bind (sigc::ptr_fun (batchProcessingThread), job, bpl), 0, true, true, Glib::THREAD_PRIORITY_LOW); + Glib::Thread::create(sigc::bind(sigc::ptr_fun(batchProcessingThread), job, bpl), 0, true, true, Glib::THREAD_PRIORITY_LOW); } } diff --git a/rtgui/locallab.cc b/rtgui/locallab.cc index c002cacab..37f869a91 100644 --- a/rtgui/locallab.cc +++ b/rtgui/locallab.cc @@ -400,7 +400,7 @@ Locallab::Locallab(): ctboxshape->pack_start(*labmshape, Gtk::PACK_SHRINK, 4); - ctboxshape->set_tooltip_markup(M("TP_LOCALLAB_SHAPE_TOOLTIP")); + //ctboxshape->set_tooltip_markup(M("TP_LOCALLAB_SHAPE_TOOLTIP")); ctboxEx->pack_start(*labmEx, Gtk::PACK_SHRINK, 4); ctboxEx->set_tooltip_markup(M("TP_LOCALLAB_EXCLUTYPE_TOOLTIP")); diff --git a/rtgui/preferences.cc b/rtgui/preferences.cc index 7827548c5..bd9510584 100644 --- a/rtgui/preferences.cc +++ b/rtgui/preferences.cc @@ -193,64 +193,64 @@ Gtk::Widget* Preferences::getBatchProcPanel() appendBehavList(mi, M("TP_LOCALCONTRAST_AMOUNT"), ADDSET_LOCALCONTRAST_AMOUNT, false); appendBehavList(mi, M("TP_LOCALCONTRAST_DARKNESS"), ADDSET_LOCALCONTRAST_DARKNESS, false); appendBehavList(mi, M("TP_LOCALCONTRAST_LIGHTNESS"), ADDSET_LOCALCONTRAST_LIGHTNESS, false); - - mi = behModel->append (); - mi->set_value (behavColumns.label, M ("TP_EPD_LABEL")); - appendBehavList (mi, M ("TP_EPD_STRENGTH"), ADDSET_EPD_STRENGTH, false); - appendBehavList (mi, M ("TP_EPD_GAMMA"), ADDSET_EPD_GAMMA, false); - appendBehavList (mi, M ("TP_EPD_EDGESTOPPING"), ADDSET_EPD_EDGESTOPPING, false); - appendBehavList (mi, M ("TP_EPD_SCALE"), ADDSET_EPD_SCALE, false); - appendBehavList (mi, M ("TP_EPD_REWEIGHTINGITERATES"), ADDSET_EPD_REWEIGHTINGITERATES, false); - mi = behModel->append (); - mi->set_value (behavColumns.label, M ("TP_TM_FATTAL_LABEL")); - appendBehavList (mi, M ("TP_TM_FATTAL_THRESHOLD"), ADDSET_FATTAL_ALPHA, false); - appendBehavList (mi, M ("TP_TM_FATTAL_AMOUNT"), ADDSET_FATTAL_BETA, false); + mi = behModel->append(); + mi->set_value(behavColumns.label, M("TP_EPD_LABEL")); + appendBehavList(mi, M("TP_EPD_STRENGTH"), ADDSET_EPD_STRENGTH, false); + appendBehavList(mi, M("TP_EPD_GAMMA"), ADDSET_EPD_GAMMA, false); + appendBehavList(mi, M("TP_EPD_EDGESTOPPING"), ADDSET_EPD_EDGESTOPPING, false); + appendBehavList(mi, M("TP_EPD_SCALE"), ADDSET_EPD_SCALE, false); + appendBehavList(mi, M("TP_EPD_REWEIGHTINGITERATES"), ADDSET_EPD_REWEIGHTINGITERATES, false); - mi = behModel->append (); - mi->set_value (behavColumns.label, M ("TP_RETINEX_LABEL")); - appendBehavList (mi, M ("TP_RETINEX_STRENGTH"), ADDSET_RETI_STR, false); - appendBehavList (mi, M ("TP_RETINEX_NEIGHBOR"), ADDSET_RETI_NEIGH, false); - appendBehavList (mi, M ("TP_RETINEX_VARIANCE"), ADDSET_RETI_VART, false); - appendBehavList (mi, M ("TP_RETINEX_GAMMA"), ADDSET_RETI_GAM, false); - appendBehavList (mi, M ("TP_RETINEX_SLOPE"), ADDSET_RETI_SLO, false); - appendBehavList (mi, M ("TP_RETINEX_GAIN"), ADDSET_RETI_GAIN, false); - appendBehavList (mi, M ("TP_RETINEX_OFFSET"), ADDSET_RETI_OFFS, false); - appendBehavList (mi, M ("TP_RETINEX_THRESHOLD"), ADDSET_RETI_LIMD, false); + mi = behModel->append(); + mi->set_value(behavColumns.label, M("TP_TM_FATTAL_LABEL")); + appendBehavList(mi, M("TP_TM_FATTAL_THRESHOLD"), ADDSET_FATTAL_ALPHA, false); + appendBehavList(mi, M("TP_TM_FATTAL_AMOUNT"), ADDSET_FATTAL_BETA, false); - mi = behModel->append (); - mi->set_value (behavColumns.label, M ("TP_SHADOWSHLIGHTS_LABEL")); - appendBehavList (mi, M ("TP_SHADOWSHLIGHTS_HIGHLIGHTS"), ADDSET_SH_HIGHLIGHTS, false); - appendBehavList (mi, M ("TP_SHADOWSHLIGHTS_SHADOWS"), ADDSET_SH_SHADOWS, false); + mi = behModel->append(); + mi->set_value(behavColumns.label, M("TP_RETINEX_LABEL")); + appendBehavList(mi, M("TP_RETINEX_STRENGTH"), ADDSET_RETI_STR, false); + appendBehavList(mi, M("TP_RETINEX_NEIGHBOR"), ADDSET_RETI_NEIGH, false); + appendBehavList(mi, M("TP_RETINEX_VARIANCE"), ADDSET_RETI_VART, false); + appendBehavList(mi, M("TP_RETINEX_GAMMA"), ADDSET_RETI_GAM, false); + appendBehavList(mi, M("TP_RETINEX_SLOPE"), ADDSET_RETI_SLO, false); + appendBehavList(mi, M("TP_RETINEX_GAIN"), ADDSET_RETI_GAIN, false); + appendBehavList(mi, M("TP_RETINEX_OFFSET"), ADDSET_RETI_OFFS, false); + appendBehavList(mi, M("TP_RETINEX_THRESHOLD"), ADDSET_RETI_LIMD, false); - mi = behModel->append (); - mi->set_value (behavColumns.label, M ("TP_LABCURVE_LABEL")); - appendBehavList (mi, M ("TP_LABCURVE_BRIGHTNESS"), ADDSET_LC_BRIGHTNESS, false); - appendBehavList (mi, M ("TP_LABCURVE_CONTRAST"), ADDSET_LC_CONTRAST, false); - appendBehavList (mi, M ("TP_LABCURVE_CHROMATICITY"), ADDSET_LC_CHROMATICITY, false); + mi = behModel->append(); + mi->set_value(behavColumns.label, M("TP_SHADOWSHLIGHTS_LABEL")); + appendBehavList(mi, M("TP_SHADOWSHLIGHTS_HIGHLIGHTS"), ADDSET_SH_HIGHLIGHTS, false); + appendBehavList(mi, M("TP_SHADOWSHLIGHTS_SHADOWS"), ADDSET_SH_SHADOWS, false); - mi = behModel->append (); // Used for both Resize and Post-Resize sharpening - mi->set_value (behavColumns.label, M ("TP_SHARPENING_LABEL")); - appendBehavList (mi, M ("TP_SHARPENING_RADIUS"), ADDSET_SHARP_RADIUS, false); - appendBehavList (mi, M ("TP_SHARPENING_AMOUNT"), ADDSET_SHARP_AMOUNT, false); - appendBehavList (mi, M ("TP_SHARPENING_RLD_DAMPING"), ADDSET_SHARP_DAMPING, false); - appendBehavList (mi, M ("TP_SHARPENING_RLD_ITERATIONS"), ADDSET_SHARP_ITER, false); - appendBehavList (mi, M ("TP_SHARPENING_EDTOLERANCE"), ADDSET_SHARP_EDGETOL, false); - appendBehavList (mi, M ("TP_SHARPENING_HALOCONTROL"), ADDSET_SHARP_HALOCTRL, false); + mi = behModel->append(); + mi->set_value(behavColumns.label, M("TP_LABCURVE_LABEL")); + appendBehavList(mi, M("TP_LABCURVE_BRIGHTNESS"), ADDSET_LC_BRIGHTNESS, false); + appendBehavList(mi, M("TP_LABCURVE_CONTRAST"), ADDSET_LC_CONTRAST, false); + appendBehavList(mi, M("TP_LABCURVE_CHROMATICITY"), ADDSET_LC_CHROMATICITY, false); - mi = behModel->append (); - mi->set_value (behavColumns.label, M ("TP_SHARPENEDGE_LABEL")); - appendBehavList (mi, M ("TP_SHARPENEDGE_PASSES"), ADDSET_SHARPENEDGE_PASS, false); - appendBehavList (mi, M ("TP_SHARPENEDGE_AMOUNT"), ADDSET_SHARPENEDGE_AMOUNT, false); + mi = behModel->append(); // Used for both Resize and Post-Resize sharpening + mi->set_value(behavColumns.label, M("TP_SHARPENING_LABEL")); + appendBehavList(mi, M("TP_SHARPENING_RADIUS"), ADDSET_SHARP_RADIUS, false); + appendBehavList(mi, M("TP_SHARPENING_AMOUNT"), ADDSET_SHARP_AMOUNT, false); + appendBehavList(mi, M("TP_SHARPENING_RLD_DAMPING"), ADDSET_SHARP_DAMPING, false); + appendBehavList(mi, M("TP_SHARPENING_RLD_ITERATIONS"), ADDSET_SHARP_ITER, false); + appendBehavList(mi, M("TP_SHARPENING_EDTOLERANCE"), ADDSET_SHARP_EDGETOL, false); + appendBehavList(mi, M("TP_SHARPENING_HALOCONTROL"), ADDSET_SHARP_HALOCTRL, false); - mi = behModel->append (); - mi->set_value (behavColumns.label, M ("TP_SHARPENMICRO_LABEL")); - appendBehavList (mi, M ("TP_SHARPENMICRO_AMOUNT"), ADDSET_SHARPENMICRO_AMOUNT, false); - appendBehavList (mi, M ("TP_SHARPENMICRO_UNIFORMITY"), ADDSET_SHARPENMICRO_UNIFORMITY, false); + mi = behModel->append(); + mi->set_value(behavColumns.label, M("TP_SHARPENEDGE_LABEL")); + appendBehavList(mi, M("TP_SHARPENEDGE_PASSES"), ADDSET_SHARPENEDGE_PASS, false); + appendBehavList(mi, M("TP_SHARPENEDGE_AMOUNT"), ADDSET_SHARPENEDGE_AMOUNT, false); - mi = behModel->append (); - mi->set_value (behavColumns.label, M ("TP_DIRPYRDENOISE_LABEL")); + mi = behModel->append(); + mi->set_value(behavColumns.label, M("TP_SHARPENMICRO_LABEL")); + appendBehavList(mi, M("TP_SHARPENMICRO_AMOUNT"), ADDSET_SHARPENMICRO_AMOUNT, false); + appendBehavList(mi, M("TP_SHARPENMICRO_UNIFORMITY"), ADDSET_SHARPENMICRO_UNIFORMITY, false); + + mi = behModel->append(); + mi->set_value(behavColumns.label, M("TP_DIRPYRDENOISE_LABEL")); //appendBehavList (mi, M("TP_DIRPYRDENOISE_LUMA")+", "+M("TP_DIRPYRDENOISE_CHROMA"), ADDSET_DIRPYRDN_CHLUM, true); appendBehavList(mi, M("TP_DIRPYRDENOISE_LUMA"), ADDSET_DIRPYRDN_LUMA, true); appendBehavList(mi, M("TP_DIRPYRDENOISE_LDETAIL"), ADDSET_DIRPYRDN_LUMDET, true);