diff --git a/rtengine/FTblockDN.cc b/rtengine/FTblockDN.cc index 121c8189d..4e5dae42b 100644 --- a/rtengine/FTblockDN.cc +++ b/rtengine/FTblockDN.cc @@ -548,7 +548,7 @@ BENCHFUN const bool denoiseMethodRgb = (dnparams.dmethod == "RGB"); // init luma noisevarL const float noiseluma = static_cast(dnparams.luma); - const float noisevarL = (useNoiseLCurve && (denoiseMethodRgb || !isRAW)) ? static_cast(SQR(((noiseluma + 1.0) / 125.0) * (10. + (noiseluma + 1.0) / 25.0))) : static_cast(SQR((noiseluma / 125.0) * (1.0 + noiseluma / 25.0))); + const float noisevarL = (useNoiseLCurve && (denoiseMethodRgb || !isRAW)) ? SQR(((noiseluma + 1.f) / 125.f) * (10.f + (noiseluma + 1.f) / 25.f)) : SQR((noiseluma / 125.f) * (1.f + noiseluma / 25.f)); const bool denoiseLuminance = (noisevarL > 0.00001f); //printf("NL=%f \n",noisevarL); @@ -635,20 +635,20 @@ BENCHFUN if (dnparams.luma != 0 || dnparams.chroma != 0 || dnparams.methodmed == "Lab" || dnparams.methodmed == "Lonly") { // gamma transform for input data - float gam = dnparams.gamma; - float gamthresh = 0.001f; + double gam = dnparams.gamma; + constexpr double gamthresh = 0.001; if (!isRAW) {//reduce gamma under 1 for Lab mode ==> TIF and JPG - if (gam < 1.9f) { - gam = 1.f - (1.9f - gam) / 3.f; //minimum gamma 0.7 - } else if (gam >= 1.9f && gam <= 3.f) { - gam = (1.4f / 1.1f) * gam - 1.41818f; + if (gam < 1.9) { + gam = 1.0 - (1.9 - gam) / 3.0; //minimum gamma 0.7 + } else if (gam >= 1.9 && gam <= 3.0) { + gam = (1.4 / 1.1) * gam - 1.41818; } } LUTf gamcurve(65536, LUT_CLIP_BELOW); - float gamslope = exp(log(static_cast(gamthresh)) / gam) / gamthresh; + const double gamslope = exp(log(gamthresh) / gam) / gamthresh; if (denoiseMethodRgb) { Color::gammaf2lut(gamcurve, gam, gamthresh, gamslope, 65535.f, 32768.f); @@ -657,9 +657,9 @@ BENCHFUN } // inverse gamma transform for output data - float igam = 1.f / gam; - float igamthresh = gamthresh * gamslope; - float igamslope = 1.f / gamslope; + const float igam = 1.0 / gam; + const float igamthresh = gamthresh * gamslope; + const float igamslope = 1.0 / gamslope; LUTf igamcurve(65536, LUT_CLIP_BELOW); @@ -669,9 +669,9 @@ BENCHFUN Color::gammanf2lut(igamcurve, igam, 32768.f, 65535.f); } - const float gain = pow(2.0f, float(expcomp)); - float params_Ldetail = min(float(dnparams.Ldetail), 99.9f); // max out to avoid div by zero when using noisevar_Ldetail as divisor - float noisevar_Ldetail = SQR(static_cast(SQR(100. - params_Ldetail) + 50.*(100. - params_Ldetail)) * TS * 0.5f); + const float gain = std::pow(2.0, expcomp); + const double params_Ldetail = std::min(dnparams.Ldetail, 99.9); // max out to avoid div by zero when using noisevar_Ldetail as divisor + const float noisevar_Ldetail = SQR(SQR(100. - params_Ldetail) + 50.0 * (100.0 - params_Ldetail) * TS * 0.5); array2D tilemask_in(TS, TS); array2D tilemask_out(TS, TS); @@ -681,13 +681,13 @@ BENCHFUN for (int i = 0; i < TS; ++i) { float i1 = abs((i > TS / 2 ? i - TS + 1 : i)); - float vmask = (i1 < border ? SQR(sin((rtengine::RT_PI * i1) / (2 * border))) : 1.0f); - float vmask2 = (i1 < 2 * border ? SQR(sin((rtengine::RT_PI * i1) / (2 * border))) : 1.0f); + float vmask = (i1 < border ? SQR(sin((rtengine::RT_PI_F * i1) / (2 * border))) : 1.f); + float vmask2 = (i1 < 2 * border ? SQR(sin((rtengine::RT_PI_F * i1) / (2 * border))) : 1.f); for (int j = 0; j < TS; ++j) { float j1 = abs((j > TS / 2 ? j - TS + 1 : j)); - tilemask_in[i][j] = (vmask * (j1 < border ? SQR(sin((rtengine::RT_PI * j1) / (2 * border))) : 1.0f)) + epsilon; - tilemask_out[i][j] = (vmask2 * (j1 < 2 * border ? SQR(sin((rtengine::RT_PI * j1) / (2 * border))) : 1.0f)) + epsilon; + tilemask_in[i][j] = (vmask * (j1 < border ? SQR(sin((rtengine::RT_PI_F * j1) / (2 * border))) : 1.0f)) + epsilon; + tilemask_out[i][j] = (vmask2 * (j1 < 2 * border ? SQR(sin((rtengine::RT_PI_F * j1) / (2 * border))) : 1.0f)) + epsilon; } } @@ -883,19 +883,19 @@ BENCHFUN int height = tilebottom - tiletop; int width2 = (width + 1) / 2; float realred, realblue; - float interm_med = static_cast(dnparams.chroma) / 10.0; + float interm_med = dnparams.chroma / 10.0; float intermred, intermblue; if (dnparams.redchro > 0.) { - intermred = (dnparams.redchro / 10.); + intermred = dnparams.redchro / 10.0; } else { - intermred = static_cast(dnparams.redchro) / 7.0; //increase slower than linear for more sensit + intermred = dnparams.redchro / 7.0; //increase slower than linear for more sensit } if (dnparams.bluechro > 0.) { - intermblue = (dnparams.bluechro / 10.); + intermblue = dnparams.bluechro / 10.0; } else { - intermblue = static_cast(dnparams.bluechro) / 7.0; //increase slower than linear for more sensit + intermblue = dnparams.bluechro / 7.0; //increase slower than linear for more sensit } if (ponder && kall == 2) { @@ -1096,7 +1096,7 @@ BENCHFUN //binary 1 or 0 for each level, eg subsampling = 0 means no subsampling, 1 means subsample //the first level only, 7 means subsample the first three levels, etc. //actual implementation only works with subsampling set to 1 - float interm_medT = static_cast(dnparams.chroma) / 10.0; + float interm_medT = dnparams.chroma / 10.0; bool execwavelet = true; if (!denoiseLuminance && interm_medT < 0.05f && dnparams.median && (dnparams.methodmed == "Lab" || dnparams.methodmed == "Lonly")) { @@ -2121,7 +2121,7 @@ float ImProcFunctions::Mad(const float * DataList, const int datalen) int count_ = count - histo[median - 1]; // interpolate - return (((median - 1) + (datalen / 2 - count_) / (static_cast(count - count_))) / 0.6745); + return (((median - 1) + (datalen / 2 - count_) / (static_cast(count - count_))) / 0.6745f); } float ImProcFunctions::MadRgb(const float * DataList, const int datalen) @@ -2155,7 +2155,7 @@ float ImProcFunctions::MadRgb(const float * DataList, const int datalen) // interpolate delete[] histo; - return (((median - 1) + (datalen / 2 - count_) / (static_cast(count - count_))) / 0.6745); + return (((median - 1) + (datalen / 2 - count_) / (static_cast(count - count_))) / 0.6745f); } @@ -2908,7 +2908,7 @@ void ImProcFunctions::RGB_denoise_infoGamCurve(const procparams::DirPyrDenoisePa bool denoiseMethodRgb = (dnparams.dmethod == "RGB"); if (denoiseMethodRgb) { - gamslope = exp(log(static_cast(gamthresh)) / gam) / gamthresh; + gamslope = exp(log(static_cast(gamthresh)) / static_cast(gam)) / static_cast(gamthresh); Color::gammaf2lut(gamcurve, gam, gamthresh, gamslope, 65535.f, 32768.f); } else { Color::gammanf2lut(gamcurve, gam, 65535.f, 32768.f); @@ -3189,19 +3189,19 @@ void ImProcFunctions::RGB_denoise_info(Imagefloat * src, Imagefloat * provicalc, } float realred, realblue; - float interm_med = static_cast(dnparams.chroma) / 10.0; + float interm_med = dnparams.chroma / 10.0; float intermred, intermblue; if (dnparams.redchro > 0.) { - intermred = (dnparams.redchro / 10.); + intermred = dnparams.redchro / 10.0; } else { - intermred = static_cast(dnparams.redchro) / 7.0; //increase slower than linear for more sensit + intermred = dnparams.redchro / 7.0; //increase slower than linear for more sensit } if (dnparams.bluechro > 0.) { - intermblue = (dnparams.bluechro / 10.); + intermblue = dnparams.bluechro / 10.0; } else { - intermblue = static_cast(dnparams.bluechro) / 7.0; //increase slower than linear for more sensit + intermblue = dnparams.bluechro / 7.0; //increase slower than linear for more sensit } realred = interm_med + intermred; diff --git a/rtengine/color.h b/rtengine/color.h index 845770bbe..998e47ee7 100644 --- a/rtengine/color.h +++ b/rtengine/color.h @@ -147,6 +147,7 @@ public: constexpr static double u0 = 4.0 * static_cast(D50x) / (static_cast(D50x) + 15 + 3 * static_cast(D50z)); constexpr static double v0 = 9.0 / (static_cast(D50x) + 15 + 3 * static_cast(D50z)); constexpr static double epskap = 8.0; + constexpr static float epskapf = epskap; constexpr static float c1By116 = 1.0 / 116.0; constexpr static float c16By116 = 16.0 / 116.0; diff --git a/rtengine/hilite_recon.cc b/rtengine/hilite_recon.cc index 697a5e3d3..a56ff1918 100644 --- a/rtengine/hilite_recon.cc +++ b/rtengine/hilite_recon.cc @@ -496,7 +496,7 @@ void RawImageSource::HLRecovery_inpaint(float** red, float** green, float** blue && blue[i + miny][j + minx] < max_f[2] ) { // if one or more channels is highlight but none are blown, add to highlight accumulator - hipass_sum += channelblur[0][i][j]; + hipass_sum += static_cast(channelblur[0][i][j]); ++hipass_norm; hilite_full[0][i][j] = red[i + miny][j + minx]; @@ -507,7 +507,7 @@ void RawImageSource::HLRecovery_inpaint(float** red, float** green, float** blue } } - const float hipass_ave = 2.f * hipass_sum / (hipass_norm + epsilon); + const float hipass_ave = 2.0 * hipass_sum / (hipass_norm + static_cast(epsilon)); if (plistener) { progress += 0.05; diff --git a/rtengine/improcfun.cc b/rtengine/improcfun.cc index d5c69773e..91c1e2c00 100644 --- a/rtengine/improcfun.cc +++ b/rtengine/improcfun.cc @@ -137,7 +137,7 @@ void highlightToneCurve(const LUTf &hltonecurve, float *rtemp, float *gtemp, flo 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; + (b < MAXVALF ? hltonecurve[b] : CurveFactory::hlcurve(exp_scale, comp, hlrange, b))) / 3.f; // note: tonefactor includes exposure scaling, that is here exposure slider and highlight compression takes place rtemp[ti * tileSize + tj + k] = r * tonefactor; @@ -165,7 +165,7 @@ void highlightToneCurve(const LUTf &hltonecurve, float *rtemp, float *gtemp, flo //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; + (b < MAXVALF ? hltonecurve[b] : CurveFactory::hlcurve(exp_scale, comp, hlrange, b))) / 3.f; // note: tonefactor includes exposure scaling, that is here exposure slider and highlight compression takes place rtemp[ti * tileSize + tj] = r * tonefactor; @@ -518,8 +518,7 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int pW, int pw int width = lab->W, height = lab->H; float minQ = 10000.f; float maxQ = -1000.f; - float Yw; - Yw = 1.0; + double Yw = 1.0; double Xw, Zw; float f = 0.f, nc = 0.f, la, c = 0.f, xw, yw, zw, f2 = 1.f, c2 = 1.f, nc2 = 1.f, yb2; float fl, n, nbb, ncb, aw; //d @@ -596,13 +595,13 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int pW, int pw algepd = true; } - xwd = 100.f * Xwout; - zwd = 100.f * Zwout; - ywd = 100.f / params->colorappearance.greenout;//approximation to simplify + xwd = 100.0 * Xwout; + zwd = 100.0 * Zwout; + ywd = 100.0 / params->colorappearance.greenout;//approximation to simplify - xws = 100.f * Xwsc; - zws = 100.f * Zwsc; - yws = 100.f / params->colorappearance.greensc;//approximation to simplify + xws = 100.0 * Xwsc; + zws = 100.0 * Zwsc; + yws = 100.0 / params->colorappearance.greensc;//approximation to simplify /* @@ -699,20 +698,20 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int pW, int pw if (alg == 3 || alg == 1) { schr = params->colorappearance.schroma; - if (schr > 0.0) { - schr = schr / 2.0f; //divide sensibility for saturation + if (schr > 0.f) { + schr = schr / 2.f; //divide sensibility for saturation } if (alg == 3) { - if (schr == -100.0f) { + if (schr == -100.f) { schr = -99.f; } - if (schr == 100.0f) { + if (schr == 100.f) { schr = 98.f; } } else { - if (schr == -100.0f) { + if (schr == -100.f) { schr = -99.8f; } } @@ -751,7 +750,7 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int pW, int pw LUTu hist16J; LUTu hist16Q; - if ((needJ && CAMBrightCurveJ.dirty) || (needQ && CAMBrightCurveQ.dirty) || (std::isnan (mean) && settings->viewinggreySc != 0)) { + if ((needJ && CAMBrightCurveJ.dirty) || (needQ && CAMBrightCurveQ.dirty) || (std::isnan(mean) && settings->viewinggreySc != 0)) { if (needJ) { hist16J (32768); @@ -788,7 +787,7 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int pW, int pw #endif - for (int i = 0; i < height; i++) + for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { //rough correspondence between L and J float currL = lab->L[i][j] / 327.68f; float koef; //rough correspondence between L and J @@ -849,10 +848,11 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int pW, int pw //hist16Qthr[ (int) (sqrtf ((koef * (lab->L[i][j])) * 32768.f))]++; //for brightness Q : approximation for Q=wh*sqrt(J/100) J not equal L } - sum += koef * lab->L[i][j]; //evaluate mean J to calculate Yb + sum += static_cast(koef) * static_cast(lab->L[i][j]); //evaluate mean J to calculate Yb //sumQ += whestim * sqrt ((koef * (lab->L[i][j])) / 32768.f); //can be used in case of... } + } #ifdef _OPENMP #pragma omp critical @@ -868,8 +868,8 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int pW, int pw } - if (std::isnan (mean)) { - mean = (sum / ((height) * width)) / 327.68f; //for Yb for all image...if one day "pipette" we can adapt Yb for each zone + if (std::isnan(mean)) { + mean = (sum / ((height) * width)) / 327.68; //for Yb for all image...if one day "pipette" we can adapt Yb for each zone } } #ifdef _OPENMP @@ -916,9 +916,9 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int pW, int pw const bool highlight = params->toneCurve.hrenabled; //Get the value if "highlight reconstruction" is activated const int gamu = (params->colorappearance.gamut) ? 1 : 0; - xw = 100.0f * Xw; - yw = 100.0f * Yw; - zw = 100.0f * Zw; + xw = 100.0 * Xw; + yw = 100.0 * Yw; + zw = 100.0 * Zw; float xw1 = 0.f, yw1 = 0.f, zw1 = 0.f, xw2 = 0.f, yw2 = 0.f, zw2 = 0.f; // settings of WB: scene and viewing @@ -2002,9 +2002,9 @@ void ImProcFunctions::moyeqt (Imagefloat* working, float &moyS, float &eqty) for (int i = 0; i < tHh; i++) { for (int j = 0; j < tWw; j++) { - float s = Color::rgb2s (CLIP (working->r (i, j)), CLIP (working->g (i, j)), CLIP (working->b (i, j))); + double s = Color::rgb2s (CLIP (working->r (i, j)), CLIP (working->g (i, j)), CLIP (working->b (i, j))); moy += s; - sqrs += SQR (s); + sqrs += SQR(s); } } @@ -2108,17 +2108,17 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer float toxyz[3][3] = { { - static_cast ( wprof[0][0] / Color::D50x), - static_cast ( wprof[0][1] / Color::D50x), - static_cast ( wprof[0][2] / Color::D50x) + static_cast(wprof[0][0] / static_cast(Color::D50x)), + static_cast(wprof[0][1] / static_cast(Color::D50x)), + static_cast(wprof[0][2] / static_cast(Color::D50x)) }, { - static_cast ( wprof[1][0]), - static_cast ( wprof[1][1]), - static_cast ( wprof[1][2]) + static_cast(wprof[1][0]), + static_cast(wprof[1][1]), + static_cast(wprof[1][2]) }, { - static_cast ( wprof[2][0] / Color::D50z), - static_cast ( wprof[2][1] / Color::D50z), - static_cast ( wprof[2][2] / Color::D50z) + static_cast(wprof[2][0] / static_cast(Color::D50z)), + static_cast(wprof[2][1] / static_cast(Color::D50z)), + static_cast(wprof[2][2] / static_cast(Color::D50z)) } }; float maxFactorToxyz = max (toxyz[1][0], toxyz[1][1], toxyz[1][2]); @@ -2238,10 +2238,10 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer const float film_simulation_strength = static_cast (params->filmSimulation.strength) / 100.0f; - const float exp_scale = pow (2.0, expcomp); - const float comp = (max (0.0, expcomp) + 1.0) * hlcompr / 100.0; - const float shoulder = ((65536.0 / max (1.0f, exp_scale)) * (hlcomprthresh / 200.0)) + 0.1; - const float hlrange = 65536.0 - shoulder; + const float exp_scale = pow(2.0, expcomp); + const float comp = (max(0.0, expcomp) + 1.0) * hlcompr / 100.0; + const float shoulder = ((65536.f / max(1.0f, exp_scale)) * (hlcomprthresh / 200.f)) + 0.1f; + const float hlrange = 65536.f - shoulder; const bool isProPhoto = (params->icm.workingProfile == "ProPhoto"); // extracting data from 'params' to avoid cache flush (to be confirmed) ToneCurveMode curveMode = params->toneCurve.curveMode; @@ -2303,43 +2303,43 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer } */ - float RedLow = params->colorToning.redlow / 100.f; - float GreenLow = params->colorToning.greenlow / 100.f; - float BlueLow = params->colorToning.bluelow / 100.f; - float RedMed = params->colorToning.redmed / 100.f; - float GreenMed = params->colorToning.greenmed / 100.f; - float BlueMed = params->colorToning.bluemed / 100.f; - float RedHigh = params->colorToning.redhigh / 100.f; - float GreenHigh = params->colorToning.greenhigh / 100.f; - float BlueHigh = params->colorToning.bluehigh / 100.f; - float SatLow = float (params->colorToning.shadowsColSat.getBottom()) / 100.f; - float SatHigh = float (params->colorToning.hlColSat.getBottom()) / 100.f; + float RedLow = params->colorToning.redlow / 100.0; + float GreenLow = params->colorToning.greenlow / 100.0; + float BlueLow = params->colorToning.bluelow / 100.0; + float RedMed = params->colorToning.redmed / 100.0; + float GreenMed = params->colorToning.greenmed / 100.0; + float BlueMed = params->colorToning.bluemed / 100.0; + float RedHigh = params->colorToning.redhigh / 100.0; + float GreenHigh = params->colorToning.greenhigh / 100.0; + float BlueHigh = params->colorToning.bluehigh / 100.0; + float SatLow = params->colorToning.shadowsColSat.getBottom() / 100.f; + float SatHigh = params->colorToning.hlColSat.getBottom() / 100.f; - float Balan = float (params->colorToning.balance); + float Balan = params->colorToning.balance; - float chMixRR = float (params->chmixer.red[0])/10.f; - float chMixRG = float (params->chmixer.red[1])/10.f; - float chMixRB = float (params->chmixer.red[2])/10.f; - float chMixGR = float (params->chmixer.green[0])/10.f; - float chMixGG = float (params->chmixer.green[1])/10.f; - float chMixGB = float (params->chmixer.green[2])/10.f; - float chMixBR = float (params->chmixer.blue[0])/10.f; - float chMixBG = float (params->chmixer.blue[1])/10.f; - float chMixBB = float (params->chmixer.blue[2])/10.f; + float chMixRR = params->chmixer.red[0] / 10.f; + float chMixRG = params->chmixer.red[1] / 10.f; + float chMixRB = params->chmixer.red[2] / 10.f; + float chMixGR = params->chmixer.green[0] / 10.f; + float chMixGG = params->chmixer.green[1] / 10.f; + float chMixGB = params->chmixer.green[2] / 10.f; + float chMixBR = params->chmixer.blue[0] / 10.f; + float chMixBG = params->chmixer.blue[1] / 10.f; + float chMixBB = params->chmixer.blue[2] / 10.f; bool blackwhite = params->blackwhite.enabled; bool complem = params->blackwhite.enabledcc; - float bwr = float (params->blackwhite.mixerRed); - float bwg = float (params->blackwhite.mixerGreen); - float bwb = float (params->blackwhite.mixerBlue); - float bwrgam = float (params->blackwhite.gammaRed); - float bwggam = float (params->blackwhite.gammaGreen); - float bwbgam = float (params->blackwhite.gammaBlue); - float mixerOrange = float (params->blackwhite.mixerOrange); - float mixerYellow = float (params->blackwhite.mixerYellow); - float mixerCyan = float (params->blackwhite.mixerCyan); - float mixerMagenta = float (params->blackwhite.mixerMagenta); - float mixerPurple = float (params->blackwhite.mixerPurple); + float bwr = params->blackwhite.mixerRed; + float bwg = params->blackwhite.mixerGreen; + float bwb = params->blackwhite.mixerBlue; + float bwrgam = params->blackwhite.gammaRed; + float bwggam = params->blackwhite.gammaGreen; + float bwbgam = params->blackwhite.gammaBlue; + float mixerOrange = params->blackwhite.mixerOrange; + float mixerYellow = params->blackwhite.mixerYellow; + float mixerCyan = params->blackwhite.mixerCyan; + float mixerMagenta = params->blackwhite.mixerMagenta; + float mixerPurple = params->blackwhite.mixerPurple; int algm = 0; if (params->blackwhite.method == "Desaturation") { @@ -2720,7 +2720,7 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer //HSV equalizer if (hCurveEnabled) { - h = (hCurve->getVal (double (h)) - 0.5) * 2.f + h; + h = (hCurve->getVal(h) - 0.5) * 2.0 + static_cast(h); if (h > 1.0f) { h -= 1.0f; @@ -2751,7 +2751,7 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer } //shift value - float valparam = vCurve->getVal ((double)h) - 0.5f; + float valparam = vCurve->getVal(h) - 0.5; valparam *= (1.f - SQR (SQR (1.f - min (s, 1.0f)))); if (valparam > 0.00001f) { @@ -3063,7 +3063,7 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer if (bwlCurveEnabled) { L /= 32768.f; double hr = Color::huelab_to_huehsv2 (HH); - float valparam = float ((bwlCurve->getVal (hr) - 0.5f) * 2.0f); //get l_r=f(H) + float valparam = (bwlCurve->getVal(hr) - 0.5) * 2.0; //get l_r=f(H) float kcc = (CC / 70.f); //take Chroma into account...70 "middle" of chromaticity (arbitrary and simple), one can imagine other algorithme //reduct action for low chroma and increase action for high chroma valparam *= kcc; @@ -3317,9 +3317,9 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer for (int i = 0; i < tH; i++) { for (int j = 0; j < tW; j++) { - nr += tmpImage->r (i, j); - ng += tmpImage->g (i, j); - nb += tmpImage->b (i, j); + nr += static_cast(tmpImage->r(i, j)); + ng += static_cast(tmpImage->g(i, j)); + nb += static_cast(tmpImage->b(i, j)); } } @@ -4385,8 +4385,7 @@ void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBuffer, int pW float factnoise = 1.f; if (params->dirpyrDenoise.enabled) { - factnoise = (1.f + params->dirpyrDenoise.chroma / 500.f); //levels=5 -// if(yyyy) factnoise=(1.f+params->dirpyrDenoise.chroma/100.f);//levels=7 + factnoise = 1.0 + params->dirpyrDenoise.chroma / 500.0; //levels=5 } const float scaleConst = 100.0f / 100.1f; @@ -4564,7 +4563,7 @@ void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBuffer, int pW float l_r;//Luminance Lab in 0..1 l_r = Lprov1 / 100.f; { - float valparam = float ((lhCurve->getVal (Color::huelab_to_huehsv2 (HH)) - 0.5f)); //get l_r=f(H) + float valparam = lhCurve->getVal(Color::huelab_to_huehsv2(HH)) - 0.5; //get l_r=f(H) float valparamneg; valparamneg = valparam; float kcc = (CC / amountchroma); //take Chroma into account...40 "middle low" of chromaticity (arbitrary and simple), one can imagine other algorithme @@ -4597,9 +4596,9 @@ void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBuffer, int pW float fx = (0.002f * aprov1) + fy; float fz = fy - (0.005f * bprov1); - float x_ = 65535.0f * Color::f2xyz (fx) * Color::D50x; - float z_ = 65535.0f * Color::f2xyz (fz) * Color::D50z; - float y_ = (Lprov1 > Color::epskap) ? 65535.0 * fy * fy * fy : 65535.0 * Lprov1 / Color::kappa; + float x_ = 65535.f * Color::f2xyz (fx) * Color::D50x; + float z_ = 65535.f * Color::f2xyz (fz) * Color::D50z; + float y_ = Lprov1 > Color::epskapf ? 65535.f * fy * fy * fy : 65535.f * Lprov1 / Color::kappaf; float R, G, B; Color::xyz2rgb (x_, y_, z_, R, G, B, wip); @@ -4627,7 +4626,7 @@ void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBuffer, int pW // calculate C=f(H) if (chutili) { double hr = Color::huelab_to_huehsv2 (HH); - float chparam = float ((chCurve->getVal (hr) - 0.5f) * 2.0f); //get C=f(H) + float chparam = (chCurve->getVal(hr) - 0.5) * 2.0; //get C=f(H) float chromaChfactor = 1.0f + chparam; atmp *= chromaChfactor;//apply C=f(H) btmp *= chromaChfactor; @@ -4635,9 +4634,9 @@ void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBuffer, int pW if (hhutili) { // H=f(H) //hue Lab in -PI +PI - float valparam = float ((hhCurve->getVal (Color::huelab_to_huehsv2 (HH)) - 0.5f) * 1.7f) + HH; //get H=f(H) 1.7 optimisation ! + float valparam = (hhCurve->getVal(Color::huelab_to_huehsv2(HH)) - 0.5) * 1.7 + static_cast(HH); //get H=f(H) 1.7 optimisation ! HH = valparam; - sincosval = xsincosf (HH); + sincosval = xsincosf(HH); } if (!bwToning) { @@ -4713,11 +4712,11 @@ void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBuffer, int pW deltaHH = protect_redhcur; //transition hue - if (chromaCfactor > 0.0) { + if (chromaCfactor > 0.f) { Color::scalered ( rstprotection, chromaCfactor, 0.0, HH, deltaHH, scale, scaleext); //1.0 } - if (chromaCfactor > 1.0) { + if (chromaCfactor > 1.f) { float interm = (chromaCfactor - 1.0f) * 100.0f; factorskin = 1.0f + (interm * scale) / 100.0f; factorskinext = 1.0f + (interm * scaleext) / 100.0f; @@ -4774,11 +4773,11 @@ void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBuffer, int pW deltaHH = protect_redhcur; //transition hue - if (chromaCfactor > 0.0) { + if (chromaCfactor > 0.f) { Color::scalered ( rstprotection, chromaCfactor, 0.0, HH, deltaHH, scale, scaleext); //1.0 } - if (chromaCfactor > 1.0) { + if (chromaCfactor > 1.f) { float interm = (chromaCfactor - 1.0f) * 100.0f; factorskin = 1.0f + (interm * scale) / 100.0f; factorskinext = 1.0f + (interm * scaleext) / 100.0f; @@ -5061,7 +5060,7 @@ void ImProcFunctions::impulsedenoise (LabImage* lab) if (params->impulseDenoise.enabled && lab->W >= 8 && lab->H >= 8) { - impulse_nr (lab, (float)params->impulseDenoise.thresh / 20.0 ); + impulse_nr(lab, params->impulseDenoise.thresh / 20.0); } } @@ -5071,7 +5070,7 @@ void ImProcFunctions::impulsedenoisecam (CieImage* ncie, float **buffers[3]) if (params->impulseDenoise.enabled && ncie->W >= 8 && ncie->H >= 8) { - impulse_nrcam (ncie, (float)params->impulseDenoise.thresh / 20.0, buffers ); + impulse_nrcam(ncie, params->impulseDenoise.thresh / 20.0, buffers); } } @@ -5141,7 +5140,7 @@ void ImProcFunctions::EPDToneMapCIE (CieImage *ncie, float a_w, float c_, int Wi float sca = params->epd.scale; float gamm = params->epd.gamma; float rew = params->epd.reweightingIterates; - float Qpro = ( 4.0 / c_) * ( a_w + 4.0 ) ; //estimate Q max if J=100.0 + float Qpro = (4.f / c_) * (a_w + 4.f) ; //estimate Q max if J=100.0 float *Qpr = ncie->Q_p[0]; if (settings->verbose) { @@ -5172,7 +5171,7 @@ void ImProcFunctions::EPDToneMapCIE (CieImage *ncie, float a_w, float c_, int Wi //Auto select number of iterates. Note that p->EdgeStopping = 0 makes a Gaussian blur. if (Iterates == 0) { - Iterates = (unsigned int) (edgest * 15.0); + Iterates = edgest * 15.f; } //Jacques Desmis : always Iterates=5 for compatibility images between preview and output @@ -5399,7 +5398,7 @@ void ImProcFunctions::getAutoExp (const LUTu &histogram, int histcompr, double octile[count] += histogram[j]; if (octile[count] > sum / 8.f || (count == 7 && octile[count] > sum / 16.f)) { - octile[count] = xlog (1. + j) / log (2.f); + octile[count] = xlog(1. + j) / log(2.0); count++;// = min(count+1,7); } } @@ -5412,7 +5411,7 @@ void ImProcFunctions::getAutoExp (const LUTu &histogram, int histcompr, double octile[count] += histogram[j]; if (octile[count] > sum / 8.f || (count == 7 && octile[count] > sum / 16.f)) { - octile[count] = xlog (1. + j) / log (2.f); + octile[count] = xlog(1. + j) / log(2.0); count++;// = min(count+1,7); } } @@ -5487,7 +5486,7 @@ void ImProcFunctions::getAutoExp (const LUTu &histogram, int histcompr, double } //compute clipped white point - unsigned int clippable = (int) (sum * clip / 100.f ); + unsigned int clippable = (int) (static_cast(sum) * clip / 100.0 ); clipped = 0; int whiteclip = (imax) - 1; @@ -5546,8 +5545,8 @@ void ImProcFunctions::getAutoExp (const LUTu &histogram, int histcompr, double hlcomprthresh = 0; //this is a series approximation of the actual formula for comp, //which is a transcendental equation - float comp = (gain * ((float)whiteclip) / scale - 1.f) * 2.3f; // 2.3 instead of 2 to increase slightly comp - hlcompr = (int) (100.*comp / (max (0.0, expcomp) + 1.0)); + double comp = (gain * whiteclip / scale - 1.f) * 2.3f; // 2.3 instead of 2 to increase slightly comp + hlcompr = 100.0 * comp / (max(0.0, expcomp) + 1.0); hlcompr = max (0, min (100, hlcompr)); //now find brightness if gain didn't bring ave to midgray using @@ -5555,9 +5554,9 @@ void ImProcFunctions::getAutoExp (const LUTu &histogram, int histcompr, double float midtmp = gain * sqrt (median * ave) / scale; if (midtmp < 0.1f) { - bright = (midgray - midtmp) * 15.0 / (midtmp); + bright = (midgray - midtmp) * 15.f / (midtmp); } else { - bright = (midgray - midtmp) * 15.0 / (0.10833 - 0.0833 * midtmp); + bright = (midgray - midtmp) * 15.f / (0.10833f - 0.0833f * midtmp); } bright = 0.25 */*(median/ave)*(hidev/lodev)*/max (0, bright);