From be765768ffe5a863d33a6ceaf989c3c0485d4114 Mon Sep 17 00:00:00 2001 From: Ingo Weyrich Date: Sat, 29 Feb 2020 14:19:06 +0100 Subject: [PATCH] further cleanups --- rtengine/colortemp.cc | 10 ++++------ rtengine/colortemp.h | 2 +- rtengine/rawimagesource.cc | 35 ++++------------------------------- rtengine/rt_math.h | 6 ++++++ 4 files changed, 15 insertions(+), 38 deletions(-) diff --git a/rtengine/colortemp.cc b/rtengine/colortemp.cc index 75efa7979..ec8641fc0 100644 --- a/rtengine/colortemp.cc +++ b/rtengine/colortemp.cc @@ -3211,7 +3211,7 @@ void ColorTemp::temp2mul (double temp, double green, double equal, double& rmul, double ColorTemp::blackbody_spect(double wavelength, double temperature) { const double wlm = wavelength * 1e-9; /* Wavelength in meters */ - return (3.7417715247e-16 / (wlm * rtengine::pow4(wlm))) / //3.7417..= c1 = 2*Pi*h*c2 where h=Planck constant, c=velocity of light + return (3.7417715247e-16 / rtengine::pow5(wlm)) / //3.7417..= c1 = 2*Pi*h*c2 where h=Planck constant, c=velocity of light (xexp(1.438786e-2 / (wlm * temperature)) - 1.0); //1.4387..= c2 = h*c/k where k=Boltzmann constant } @@ -3400,7 +3400,7 @@ double ColorTemp::daylight_spect(double wavelength, double m1, double m2) // we can change step for temperature and increase number for T > 7500K if necessary //these values Temp, x, y are references for all calculations and very precise. //copyright J.Desmis august 2017 and june 2018 -void ColorTemp::tempxy(bool separated, int &repref, float **Tx, float **Ty, float **Tz, float **Ta, float **Tb, float **TL, double *TX, double *TY, double *TZ, const procparams::WBParams & wbpar) +void ColorTemp::tempxy(bool separated, int repref, float **Tx, float **Ty, float **Tz, float **Ta, float **Tb, float **TL, double *TX, double *TY, double *TZ, const procparams::WBParams & wbpar) { const double* spec_colorforxcyc[] = {//color references JDC468_BluH10_spect, JDC468_BluD6_spect, ColorchechCyaF3_spect, JDC468_BluM5_spect, // 0 3 @@ -3595,10 +3595,8 @@ void ColorTemp::tempxy(bool separated, int &repref, float **Tx, float **Ty, floa Refxyz[i].Zref = 0.f; } - double tempw = 5000.; - if (separated) { - tempw = Txyz[repref].Tem; + const double tempw = Txyz[repref].Tem; if (tempw <= INITIALBLACKBODY) { for (int i = 0; i < N_c; i++) { @@ -3626,7 +3624,7 @@ void ColorTemp::tempxy(bool separated, int &repref, float **Tx, float **Ty, floa } } else { for (int tt = 0; tt < N_t; tt++) { - tempw = Txyz[tt].Tem; + const double tempw = Txyz[tt].Tem; if (tempw <= INITIALBLACKBODY) { for (int i = 0; i < N_c; i++) { diff --git a/rtengine/colortemp.h b/rtengine/colortemp.h index fd2796552..5feed9d26 100644 --- a/rtengine/colortemp.h +++ b/rtengine/colortemp.h @@ -54,7 +54,7 @@ public: explicit ColorTemp (double e) : temp(-1.), green(-1.), equal (e), method("Custom") {} ColorTemp (double t, double g, double e, const std::string &m); ColorTemp (double mulr, double mulg, double mulb, double e); - static void tempxy(bool separated, int &repref, float **Tx, float **Ty, float **Tz, float **Ta, float **Tb, float **TL, double *TX, double *TY, double *TZ, const procparams::WBParams & wbpar); + static void tempxy(bool separated, int repref, float **Tx, float **Ty, float **Tz, float **Ta, float **Tb, float **TL, double *TX, double *TY, double *TZ, const procparams::WBParams & wbpar); void update (const double rmul, const double gmul, const double bmul, const double equal, const double tempBias=0.0) { diff --git a/rtengine/rawimagesource.cc b/rtengine/rawimagesource.cc index 9f7b9a850..1cbdf1140 100644 --- a/rtengine/rawimagesource.cc +++ b/rtengine/rawimagesource.cc @@ -4553,12 +4553,11 @@ void RawImageSource::ItcWB(bool extra, double &tempref, double &greenref, double typedef struct RangeGreen { int begin; int end; - int ng; } RangeGreen; - constexpr RangeGreen Rangestandard = {8, 70, 62}; - constexpr RangeGreen Rangeextand = {4, 77, 73}; - const RangeGreen Rangemax = {0, N_g, N_g}; + constexpr RangeGreen Rangestandard = {8, 70}; + constexpr RangeGreen Rangeextand = {4, 77}; + const RangeGreen Rangemax = {0, N_g}; RangeGreen Rangegreenused; @@ -5064,8 +5063,6 @@ void RawImageSource::ItcWB(bool extra, double &tempref, double &greenref, double const int scantempbeg = rtengine::max(goodref - (dgoodref + 1), 1); const int scantempend = rtengine::min(goodref + dgoodref, N_t - 1); - const bool isMono = (ri->getSensorType() == ST_FUJI_XTRANS && raw.xtranssensor.method == RAWParams::XTransSensor::getMethodString(RAWParams::XTransSensor::Method::MONO)) - || (ri->getSensorType() == ST_BAYER && raw.bayersensor.method == RAWParams::BayerSensor::getMethodString(RAWParams::BayerSensor::Method::MONO)); for (int gr = Rangegreenused.begin; gr < Rangegreenused.end; ++gr) { float minstudgr = 100000.f; int goodrefgr = 1; @@ -5185,7 +5182,7 @@ void RawImageSource::ItcWB(bool extra, double &tempref, double &greenref, double } avg_rm = 10000.f * rmm[goodref]; - avg_gm = 10000.* gmm[goodref]; + avg_gm = 10000.f * gmm[goodref]; avg_bm = 10000.f * bmm[goodref]; if (!extra) { @@ -5206,7 +5203,6 @@ void RawImageSource::WBauto(double & tempref, double & greenref, array2D if (greenref > 0.77 && greenref < 1.3) { greenitc = greenref; - extra = false; if (settings->itcwb_forceextra) { extra = true; @@ -5222,7 +5218,6 @@ void RawImageSource::WBauto(double & tempref, double & greenref, array2D } } - void RawImageSource::getrgbloc(bool local, bool gamma, bool cat02, int begx, int begy, int yEn, int xEn, int cx, int cy, int bf_h, int bf_w) { //used by auto WB local to calculate red, green, blue in local region @@ -5304,28 +5299,6 @@ void RawImageSource::getrgbloc(bool local, bool gamma, bool cat02, int begx, in blueloc[i][j] = Color::gammatab_srgb[blueloc[i][j]]; } } - - if (cat02) {//CAT02 - /* - //not good threatment, I must wait merge branch cat02wb - for (int i = 0; i < bfh; i++) - for (int j = 0; j < bfw; j++) { - float X = 0.f, Y = 0.f, Z = 0.f; - Color::rgbxyz(redloc[i][j], greenloc[i][j], blueloc[i][j], X, Y, Z, wp); - double temp; - double Xr = X / 65535.; - double Yr = Y / 65535.; - double Zr = Z / 65535.; - - Ciecam02::xyz_to_cat02float (redloc[i][j], greenloc[i][j], blueloc[i][j], Xr, Yr, Zr, 1); - redloc[i][j] *= 65535.f; - greenloc[i][j] *= 65535.f; - blueloc[i][j] *= 65535.f; - //to do ciecam adaptation - } - */ - } - } void RawImageSource::getAutoWBMultipliersitc(double & tempref, double & greenref, double & tempitc, double & greenitc, float &studgood, int begx, int begy, int yEn, int xEn, int cx, int cy, int bf_h, int bf_w, double & rm, double & gm, double & bm, const WBParams & wbpar, const ColorManagementParams & cmp, const RAWParams & raw) diff --git a/rtengine/rt_math.h b/rtengine/rt_math.h index 9342f5430..6d4799254 100644 --- a/rtengine/rt_math.h +++ b/rtengine/rt_math.h @@ -44,6 +44,12 @@ constexpr T pow4(T x) return SQR(SQR(x)); } +template +constexpr T pow5(T x) +{ + return x * pow4(x); +} + template constexpr const T& min(const T& a) {