diff --git a/rtengine/colortemp.cc b/rtengine/colortemp.cc index 0edd7aeb2..75efa7979 100644 --- a/rtengine/colortemp.cc +++ b/rtengine/colortemp.cc @@ -3210,8 +3210,8 @@ void ColorTemp::temp2mul (double temp, double green, double equal, double& rmul, //calculate spectral data for blackbody at temp! double ColorTemp::blackbody_spect(double wavelength, double temperature) { - double wlm = wavelength * 1e-9; /* Wavelength in meters */ - return (3.7417715247e-16 / pow(wlm, 5)) / //3.7417..= c1 = 2*Pi*h*c2 where h=Planck constant, c=velocity of light + 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 (xexp(1.438786e-2 / (wlm * temperature)) - 1.0); //1.4387..= c2 = h*c/k where k=Boltzmann constant } @@ -3337,62 +3337,38 @@ void ColorTemp::spectrum_to_color_xyz_preset(const double* spec_color, const dou void ColorTemp::spectrum_to_color_xyz_daylight(const double* spec_color, double _m1, double _m2, double &xx, double &yy, double &zz) { int i; - double lambda, X = 0, Y = 0, Z = 0, Yo = 0; + double lambda, X = 0, Y = 0, Z = 0; for (i = 0, lambda = 350; lambda < 830.1; i++, lambda += 5) { - - double Me; - double Mc; - - Me = get_spectral_color(lambda, spec_color); - Mc = daylight_spect(lambda, _m1, _m2); + const double Me = spec_color[i]; + const double Mc = daylight_spect(lambda, _m1, _m2); X += Mc * cie_colour_match_jd[i][0] * Me; Y += Mc * cie_colour_match_jd[i][1] * Me; Z += Mc * cie_colour_match_jd[i][2] * Me; } - for (i = 0, lambda = 350; lambda < 830.1; i++, lambda += 5) { - - double Ms; - - Ms = daylight_spect(lambda, _m1, _m2); - Yo += cie_colour_match_jd[i][1] * Ms; - } - - xx = X / Yo; - yy = Y / Yo; - zz = Z / Yo; + xx = X / Y; + yy = 1.0; + zz = Z / Y; } //calculate XYZ from spectrum data (color) and illuminant : J.Desmis december 2011 void ColorTemp::spectrum_to_color_xyz_blackbody(const double* spec_color, double _temp, double &xx, double &yy, double &zz) { int i; - double lambda, X = 0, Y = 0, Z = 0, Yo = 0; + double lambda, X = 0, Y = 0, Z = 0; for (i = 0, lambda = 350; lambda < 830.1; i++, lambda += 5) { - - double Me; - double Mc; - - Me = get_spectral_color(lambda, spec_color); - Mc = blackbody_spect(lambda, _temp); + const double Me = spec_color[i]; + const double Mc = blackbody_spect(lambda, _temp); X += Mc * cie_colour_match_jd[i][0] * Me; Y += Mc * cie_colour_match_jd[i][1] * Me; Z += Mc * cie_colour_match_jd[i][2] * Me; } - for (i = 0, lambda = 350; lambda < 830.1; i++, lambda += 5) { - - double Ms; - - Ms = blackbody_spect(lambda, _temp); - Yo += cie_colour_match_jd[i][1] * Ms; - } - - xx = X / Yo; - yy = Y / Yo; - zz = Z / Yo; + xx = X / Y; + yy = 1.0; + zz = Z / Y; } double ColorTemp::daylight_spect(double wavelength, double m1, double m2) @@ -3483,7 +3459,7 @@ void ColorTemp::tempxy(bool separated, int &repref, float **Tx, float **Ty, floa double ZZ; } WbTxyz; //probbaly can be "passed" with rawimagesource.cc but I don't know how to do. - WbTxyz Txyz[118] = {//temperature Xwb Zwb 118 values x wb and y wb are calculated after + constexpr WbTxyz Txyz[118] = {//temperature Xwb Zwb 118 values x wb and y wb are calculated after {2001., 1.273842, 0.145295}, {2101., 1.244008, 0.167533}, {2201., 1.217338, 0.190697}, @@ -3612,68 +3588,22 @@ void ColorTemp::tempxy(bool separated, int &repref, float **Tx, float **Ty, floa double Zref; } XYZref; XYZref Refxyz[N_c + 1]; - typedef struct XYZrefcat02 { - double Xrefcat; - double Yrefcat; - double Zrefcat; - } XYZrefcat02; - XYZrefcat02 Refxyzcat02[N_c + 1]; for (int i = 0; i < N_c; i++) { Refxyz[i].Xref = 0.f; Refxyz[i].Yref = 0.f; Refxyz[i].Zref = 0.f; - Refxyzcat02[i].Xrefcat = 0.f; - Refxyzcat02[i].Yrefcat = 0.f; - Refxyzcat02[i].Zrefcat = 0.f; } - - struct chrom { - float chroab; - float chroa; - float chrob; - int nn; - float L; - bool operator()(const chrom& lchro, const chrom& rchro) - { - return lchro.chroab < rchro.chroab; - } - - } ; - - // chrom wbchro[N_c + 1]; - double tempw = 5000.; if (separated) { tempw = Txyz[repref].Tem; - // tempw = 5004.; if (tempw <= INITIALBLACKBODY) { - // float aa = 0.f; - // float bb = 0.f; - for (int i = 0; i < N_c; i++) { spectrum_to_color_xyz_blackbody(spec_colorforxcyc[i], tempw, TX[i], TY[i], TZ[i]); - /* float XX = TX[i] * 65535.f; - float YY = TY[i] * 65535.f; - float ZZ = TZ[i] * 65535.f; - float L, a, b; - Color::XYZ2Lab(XX, YY, ZZ, L, a, b);//only to see Lab values in console - printf("N=%i L=%f a=%f b=%f\n", i, L / 327.68f, a / 327.68f, b / 327.68f); - aa += (a / 327.68f); - bb += (b / 327.68f); - */ } - - /* - aa /= N_c; - bb /= N_c; - printf("aa=%f bb=%f\n", aa, bb); - */ - // } - } else { double m11, m22, x_DD, y_DD, interm2; @@ -3689,97 +3619,21 @@ void ColorTemp::tempxy(bool separated, int &repref, float **Tx, float **Ty, floa interm2 = (0.0241 + 0.2562 * x_DD - 0.734 * y_DD); m11 = (-1.3515 - 1.7703 * x_DD + 5.9114 * y_DD) / interm2; m22 = (0.03 - 31.4424 * x_DD + 30.0717 * y_DD) / interm2; - // float aa = 0.f; - // float bb = 0.f; for (int i = 0; i < N_c; i++) { spectrum_to_color_xyz_daylight(spec_colorforxcyc[i], m11, m22, TX[i], TY[i], TZ[i]); - -/* float XX = TX[i] * 65535.f; - float YY = TY[i] * 65535.f; - float ZZ = TZ[i] * 65535.f; - float L, a, b; - Color::XYZ2Lab(XX, YY, ZZ, L, a, b);//only to see Lab values in console - // printf("N=%i L=%f a=%f b=%f\n", i, L / 327.68f, a / 327.6 8f, b / 327.68f); - aa += (a / 327.68f); - bb += (b / 327.68f); - wbchro[i].chroab = (sqrt(SQR(a) + SQR(b))) / 327.68f; - wbchro[i].chroa = a / 327.68f; - wbchro[i].chrob = b / 327.68f; - wbchro[i].nn = i; -*/ - - } -/* - std::sort(wbchro, wbchro + N_c + 1, wbchro[0]); - float ab5 = 0.f; - int n5 = 0; - float ab15 = 0.f; - int n15 = 0; - float ab30 = 0.f; - int n30 = 0; - float ab50 = 0.f; - int n50 = 0; - float ab70 = 0.f; - int n70 = 0; - float ab120 = 0.f; - int n120 = 0; - - for (int i = 0; i < N_c; i++) { - if (wbchro[i].chroab < 5.f) { - ab5 += (wbchro[i].chroa + wbchro[i].chrob); - n5++; - } else if (wbchro[i].chroab < 15.f) { - ab15 += (wbchro[i].chroa + wbchro[i].chrob); - n15++; - } else if (wbchro[i].chroab < 30.f) { - ab30 += (wbchro[i].chroa + wbchro[i].chrob); - n30++; - } else if (wbchro[i].chroab < 50.f) { - ab50 += (wbchro[i].chroa + wbchro[i].chrob); - n50++; - } else if (wbchro[i].chroab < 70.f) { - ab70 += (wbchro[i].chroa + wbchro[i].chrob); - n70++; - } else if (wbchro[i].chroab < 120.f) { - ab120 += (wbchro[i].chroa + wbchro[i].chrob); - n120++; - } - - printf("N=%i nn=%i chr=%f cha=%f chb=%f\n", i, wbchro[i].nn, wbchro[i].chroab, wbchro[i].chroa, wbchro[i].chrob); - } - - printf("ab5=%f n5=%i\n", ab5 / n5, n5); - printf("ab15=%f n15=%i\n", ab15 / n15, n15); - printf("ab30=%f n30=%i\n", ab30 / n30, n30); - printf("ab50=%f n50=%i\n", ab50 / n50, n50); - printf("ab70=%f n70=%i\n", ab70 / n70, n70); - printf("ab120=%f n120=%i\n", ab120 / n120, n120); - aa /= N_c; - bb /= N_c; - printf("aa=%f bb=%f\n", aa, bb); - //very low 15 --, 16 -+, 17 + -, 18 +-, 20 ++, 22 -+, 73 ++, 98 ++, 99 -+, 101 -+, 129 ++, 130 -+, 131 --, - //low 8 +-, 9 --, 10 --, 12 --, 19 -+, 21 -+, 24 -+, 25 ++, 27 ++, 30 ++, 33++, 34 ++, 36 ++, 37++,38 +-, - */ } - } - - if (!separated) { - // std::string wbcat02Method = wbpar.wbcat02Method; - std::string wbcat02Method = "none"; - + } else { for (int tt = 0; tt < N_t; tt++) { tempw = Txyz[tt].Tem; if (tempw <= INITIALBLACKBODY) { - for (int i = 0; i < N_c; i++) { spectrum_to_color_xyz_blackbody(spec_colorforxcyc[i], tempw, Refxyz[i].Xref, Refxyz[i].Yref, Refxyz[i].Zref); } - } else { - double m11, m22, x_DD, y_DD, interm2; + double x_DD; if (tempw <= 7000) { x_DD = -4.6070e9 / (tempw * tempw * tempw) + 2.9678e6 / (tempw * tempw) + 0.09911e3 / tempw + 0.244063; @@ -3787,80 +3641,22 @@ void ColorTemp::tempxy(bool separated, int &repref, float **Tx, float **Ty, floa x_DD = -2.0064e9 / (tempw * tempw * tempw) + 1.9018e6 / (tempw * tempw) + 0.24748e3 / tempw + 0.237040; } - y_DD = -3.0 * x_DD * x_DD + 2.87 * x_DD - 0.275; + const double y_DD = -3.0 * x_DD * x_DD + 2.87 * x_DD - 0.275; //calculate D -daylight in function of s0, s1, s2 and temp ==> x_D y_D //S(lamda)=So(lambda)+m1*s1(lambda)+m2*s2(lambda) - interm2 = (0.0241 + 0.2562 * x_DD - 0.734 * y_DD); - m11 = (-1.3515 - 1.7703 * x_DD + 5.9114 * y_DD) / interm2; - m22 = (0.03 - 31.4424 * x_DD + 30.0717 * y_DD) / interm2; + const double interm2 = (0.0241 + 0.2562 * x_DD - 0.734 * y_DD); + const double m11 = (-1.3515 - 1.7703 * x_DD + 5.9114 * y_DD) / interm2; + const double m22 = (0.03 - 31.4424 * x_DD + 30.0717 * y_DD) / interm2; for (int i = 0; i < N_c; i++) { spectrum_to_color_xyz_daylight(spec_colorforxcyc[i], m11, m22, Refxyz[i].Xref, Refxyz[i].Yref, Refxyz[i].Zref); } } -//CAT02 - - float CAM02BB00 = 1.0, CAM02BB01 = 1.0, CAM02BB02 = 1.0, CAM02BB10 = 1.0, CAM02BB11 = 1.0, CAM02BB12 = 1.0, CAM02BB20 = 1.0, CAM02BB21 = 1.0, CAM02BB22 = 1.0; //for CIECAT02 - float Xwb = Txyz[tt].XX; - float Ywb = 1.; - float Zwb = Txyz[tt].ZZ; - - if (wbcat02Method == "icam") {//not used - icieCAT02float(Xwb, Ywb, Zwb, CAM02BB00, CAM02BB01, CAM02BB02, CAM02BB10, CAM02BB11, CAM02BB12, CAM02BB20, CAM02BB21, CAM02BB22, 1.0); - } - - if (wbcat02Method == "cam") { - - cieCAT02float(Xwb, Ywb, Zwb, CAM02BB00, CAM02BB01, CAM02BB02, CAM02BB10, CAM02BB11, CAM02BB12, CAM02BB20, CAM02BB21, CAM02BB22, 1.0); - } - - if (wbcat02Method == "none") { - - for (int i = 0; i < N_c; i++) { - Refxyzcat02[i].Xrefcat = CAM02BB00 * Refxyz[i].Xref + CAM02BB01 * Refxyz[i].Yref + CAM02BB02 * Refxyz[i].Zref ; - Refxyzcat02[i].Yrefcat = CAM02BB10 * Refxyz[i].Xref + CAM02BB11 * Refxyz[i].Yref + CAM02BB12 * Refxyz[i].Zref ; - Refxyzcat02[i].Zrefcat = CAM02BB20 * Refxyz[i].Xref + CAM02BB21 * Refxyz[i].Yref + CAM02BB22 * Refxyz[i].Zref; - } - } - -//end CAT02 - for (int i = 0; i < N_c; i++) { - /* float X = 65535.f * Refxyzcat02[i].Xrefcat; - float Y = 65535.f * Refxyzcat02[i].Yrefcat; - float Z = 65535.f * Refxyzcat02[i].Zrefcat; - float L, a, b; - Color::XYZ2Lab(X, Y, Z, L, a, b); - - double som = (Refxyzcat02[i].Xrefcat + Refxyzcat02[i].Yrefcat + Refxyzcat02[i].Zrefcat); - L /= 327.68f; - a /= 327.68f; - b /= 327.68f; - Ta[i][tt] = a; - Tb[i][tt] = b; - TL[i][tt] = L; - TX[i][tt] = X; - TY[i][tt] = Y; - TZ[i][tt] = Z; - */ - //som = 1.; -// Tx[i][tt] = (float) Refxyz[i].Xref; -// Ty[i][tt] = (float) Refxyz[i].Yref; -// Tz[i][tt] = (float) Refxyz[i].Zref; - -// if (wbpar.wbcat02Method == "none") { - if (wbcat02Method == "none") { - - Tx[i][tt] = (float) Refxyz[i].Xref; - Ty[i][tt] = (float) Refxyz[i].Yref; - Tz[i][tt] = (float) Refxyz[i].Zref; - } else { - Tx[i][tt] = (float) Refxyzcat02[i].Xrefcat; - Ty[i][tt] = (float) Refxyzcat02[i].Yrefcat; - Tz[i][tt] = (float) Refxyzcat02[i].Zrefcat; - } - + Tx[i][tt] = Refxyz[i].Xref; + Ty[i][tt] = Refxyz[i].Yref; + Tz[i][tt] = Refxyz[i].Zref; } } } diff --git a/rtengine/rawimagesource.cc b/rtengine/rawimagesource.cc index daba0be2a..9f7b9a850 100644 --- a/rtengine/rawimagesource.cc +++ b/rtengine/rawimagesource.cc @@ -4292,54 +4292,49 @@ static void histoxyY(int bfhitc, int bfwitc, const array2D & xc, const ar } } -void static studentXY(const array2D & YYcurr, const array2D & reffYY, int sizcurr, int Nc, int tt, float & student) +float static studentXY(const array2D & YYcurr, const array2D & reffYY, int sizcurr, int Nc, int tt) { //calculate Student coeff YY float somcurrY = 0.f; float somreffY = 0.f; float somcurr2Y = 0.f; float somreff2Y = 0.f; - float somsqueccurrY = 0.f; - float somsquecreffY = 0.f; - int sizestucurrY = sizcurr; - int sizestureffY = Nc; - for (int i = 0; i < sizestucurrY; i++) { - somcurrY += 100.f * YYcurr[i][tt]; + for (int i = 0; i < sizcurr; i++) { + somcurrY += YYcurr[i][tt]; //sum observations first group } + somcurrY *= 100.f; - for (int i = 0; i < sizestureffY; i++) { - somreffY += 100.f * reffYY[i][tt]; + for (int i = 0; i < Nc; i++) { + somreffY += reffYY[i][tt]; //sum observations second group - } + somreffY *= 100.f; - - for (int i = 0; i < sizestucurrY; i++) { - somcurr2Y += SQR(100.f * YYcurr[i][tt]); + for (int i = 0; i < sizcurr; i++) { + somcurr2Y += SQR(YYcurr[i][tt]); //sum sqr observations first group - } + somreffY *= SQR(100.f); - for (int i = 0; i < sizestureffY; i++) { - somreff2Y += SQR(100.f * reffYY[i][tt]); + for (int i = 0; i < Nc; i++) { + somreff2Y += SQR(reffYY[i][tt]); //sum sqr observations second group - } + somreff2Y *= SQR(100.f); - somsqueccurrY = somcurr2Y - (SQR(somcurrY)) / sizestucurrY; + const float somsqueccurrY = somcurr2Y - (SQR(somcurrY)) / sizcurr; //sum sqr differences first - somsquecreffY = somreff2Y - (SQR(somreffY)) / sizestureffY; + const float somsquecreffY = somreff2Y - (SQR(somreffY)) / Nc; //sum sqr differences second - float diviY = std::sqrt(((somsqueccurrY + somsquecreffY) * (1.f / (float)sizestucurrY + 1.f / (float)sizestureffY)) / (sizestucurrY + sizestureffY - 2)); + const float diviY = std::sqrt(((somsqueccurrY + somsquecreffY) * (1.f / sizcurr + 1.f / Nc)) / (sizcurr + Nc - 2)); //divisor student - float numerY = ((float)somcurrY / (float)sizestucurrY) - ((float)somreffY / (float)sizestureffY); + const float numerY = somcurrY / sizcurr - somreffY / Nc; //numerator student -// printf("num=%f divY=%f \n", numerY, diviY); - student = numerY / diviY ; + return numerY / diviY ; //student coeeficient } @@ -4404,9 +4399,7 @@ void RawImageSource::ItcWB(bool extra, double &tempref, double &greenref, double Itcwb_sizereference : 3 by default, can be set to 5 ==> size of reference color compare to size of histogram real color itcwb_delta : 1 by default can be set between 0 to 5 ==> delta temp to build histogram xy - if camera temp is not probably good */ - // BENCHFUN BENCHFUN - TMatrix wprof = ICCStore::getInstance()->workingSpaceMatrix("sRGB"); const float wp[3][3] = { @@ -4423,49 +4416,19 @@ void RawImageSource::ItcWB(bool extra, double &tempref, double &greenref, double {wiprof[2][0], wiprof[2][1], wiprof[2][2]} }; - array2D xc; - array2D yc; - array2D Yc; + const int bfwitc = bfw / 10 + 1 ;// 10 arbitrary value ; perhaps 4 or 5 or 20 + const int bfhitc = bfh / 10 + 1; - array2D histcurr; - array2D histcurrref; - - array2D xxyycurr; - array2D xxyycurr_reduc; - array2D xx_curref; - array2D yy_curref; - array2D YY_curref; - array2D xx_curref_reduc; - array2D yy_curref_reduc; - array2D R_curref_reduc; - array2D G_curref_reduc; - array2D B_curref_reduc; - - array2D reff_spect_xxyy; - array2D reff_spect_xxyy_prov; - array2D YYcurr; - array2D YY_curref_reduc; - array2D YYcurr_reduc; - // array2D reffYY; - // array2D reffYY_prov; - - array2D reff_spect_yy_camera; - array2D reff_spect_xx_camera; - - - int bfwitc = bfw / 10 + 1 ;// 10 arbitrary value ; perhaps 4 or 5 or 20 - int bfhitc = bfh / 10 + 1; - - xc(bfwitc, bfhitc); - yc(bfwitc, bfhitc); - Yc(bfwitc, bfhitc); + array2D xc(bfwitc, bfhitc); + array2D yc(bfwitc, bfhitc); + array2D Yc(bfwitc, bfhitc); typedef struct WbGreen { double green; float snedecor;//1. actually but put in case of confiance interval } WbGreen; - constexpr WbGreen gree[118] = {//symetric coefficient between 0.717 and 1.40 + constexpr WbGreen gree[118] = {//symmetric coefficient between 0.717 and 1.40 {0.400, 1.f}, {0.500, 1.f}, {0.550, 1.f}, @@ -4585,7 +4548,7 @@ void RawImageSource::ItcWB(bool extra, double &tempref, double &greenref, double {3.800, 1.f}, {4.000, 1.f} }; - int N_g = sizeof(gree) / sizeof(gree[0]); //number of green + const int N_g = sizeof(gree) / sizeof(gree[0]); //number of green typedef struct RangeGreen { int begin; @@ -4593,37 +4556,20 @@ void RawImageSource::ItcWB(bool extra, double &tempref, double &greenref, double int ng; } RangeGreen; - RangeGreen Rangestandard; - Rangestandard.begin = 8; - Rangestandard.end = 70; - Rangestandard.ng = 62; - - RangeGreen Rangeextand; - Rangeextand.begin = 4; - Rangeextand.end = 77; - Rangeextand.ng = 73; - - RangeGreen Rangemax; - Rangemax.begin = 0; - Rangemax.end = N_g; - Rangemax.ng = N_g; + constexpr RangeGreen Rangestandard = {8, 70, 62}; + constexpr RangeGreen Rangeextand = {4, 77, 73}; + const RangeGreen Rangemax = {0, N_g, N_g}; RangeGreen Rangegreenused; if (settings->itcwb_greenrange == 0) { Rangegreenused = Rangestandard; - } - - else if (settings->itcwb_greenrange == 1) { + } else if (settings->itcwb_greenrange == 1) { Rangegreenused = Rangeextand; } else { Rangegreenused = Rangemax; } - // printf("rangemin=%i rangmax=%i\n", Rangegreenused.begin, Rangegreenused.end); - - - typedef struct WbTxyz { double Tem; double XX; @@ -4785,8 +4731,8 @@ void RawImageSource::ItcWB(bool extra, double &tempref, double &greenref, double //calculate R G B multiplier in function illuminant and temperature 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 tt = 0; tt < N_t; tt++) { + || (ri->getSensorType() == ST_BAYER && raw.bayersensor.method == RAWParams::BayerSensor::getMethodString(RAWParams::BayerSensor::Method::MONO)); + for (int tt = 0; tt < N_t; ++tt) { double r, g, b; float rm, gm, bm; ColorTemp WBiter = ColorTemp(Txyz[tt].Tem, greenitc, 1.f, "Custom"); @@ -4845,11 +4791,11 @@ void RawImageSource::ItcWB(bool extra, double &tempref, double &greenref, double bool separated = true; int w = -1; - //printf("greenrefraw=%f\n", greenref); - reff_spect_xxyy(N_t, 2 * Nc + 2); - reff_spect_xxyy_prov(N_t, 2 * Nc + 2); - reff_spect_yy_camera(N_t, 2 * Nc + 2); - reff_spect_xx_camera(N_t, 2 * Nc + 2); + + array2D reff_spect_xxyy(N_t, 2 * Nc + 2); + array2D reff_spect_xxyy_prov(N_t, 2 * Nc + 2); + array2D reff_spect_yy_camera(N_t, 2 * Nc + 2); + array2D reff_spect_xx_camera(N_t, 2 * Nc + 2); //here we select the good spectral color inside the 113 values //call tempxy to calculate for 114 color references Temp and XYZ with cat02 @@ -4896,19 +4842,18 @@ void RawImageSource::ItcWB(bool extra, double &tempref, double &greenref, double //calculate x y Y const int sizcurrref = siza;//choice of number of correlate colors in image - histcurrref(N_t, sizcurrref); - xx_curref(N_t, sizcurrref); - yy_curref(N_t, sizcurrref); - YY_curref(N_t, sizcurrref); - xx_curref_reduc(N_t, sizcurrref); - yy_curref_reduc(N_t, sizcurrref); - YY_curref_reduc(N_t, sizcurrref); - R_curref_reduc(N_t, sizcurrref); - G_curref_reduc(N_t, sizcurrref); - B_curref_reduc(N_t, sizcurrref); + array2D histcurrref(N_t, sizcurrref); + array2D xx_curref(N_t, sizcurrref); + array2D yy_curref(N_t, sizcurrref); + array2D YY_curref(N_t, sizcurrref); + array2D xx_curref_reduc(N_t, sizcurrref); + array2D yy_curref_reduc(N_t, sizcurrref); + array2D YY_curref_reduc(N_t, sizcurrref); + array2D R_curref_reduc(N_t, sizcurrref); + array2D G_curref_reduc(N_t, sizcurrref); + array2D B_curref_reduc(N_t, sizcurrref); - - hiss Wbhis [siza]; + hiss Wbhis[siza]; for (int nh = 0; nh < siza; nh++) { Wbhis[nh].histnum = histxy[nh]; @@ -4995,7 +4940,7 @@ void RawImageSource::ItcWB(bool extra, double &tempref, double &greenref, double for (int i = 0; i < sizcurr2ref; ++i) { //is condition chroxy necessary ? - if (((wbchro[sizcu4 - (i + 1)].chrox > 0.1f) && (wbchro[sizcu4 - (i + 1)].chroy > 0.1f)) && wbchro[sizcu4 - (i + 1)].chroxy > 0.0f) { //suppress value too far from reference spectral + if (((wbchro[sizcu4 - (i + 1)].chrox > 0.1f) && (wbchro[sizcu4 - (i + 1)].chroy > 0.1f)) && wbchro[sizcu4 - (i + 1)].chroxy > 0.0f) { //suppress value too far from reference spectral w++; xx_curref_reduc[w][repref] = wbchro[sizcu4 - (i + 1)].chrox; yy_curref_reduc[w][repref] = wbchro[sizcu4 - (i + 1)].chroy; @@ -5045,21 +4990,20 @@ void RawImageSource::ItcWB(bool extra, double &tempref, double &greenref, double //end first part - //Now begin real calculations separated = false; ColorTemp::tempxy(separated, repref, Tx, Ty, Tz, Ta, Tb, TL, TX, TY, TZ, wbpar); //calculate chroma xy (xyY) for Z known colors on under 90 illuminants //calculate x y Y int sizcurr = siza;//choice of number of correlate colors in image - histcurr(N_t, sizcurr); - xxyycurr(N_t, 2 * sizcurr); - xxyycurr_reduc(N_t, 2 * sizcurr); + array2D histcurr(N_t, sizcurr); + array2D xxyycurr(N_t, 2 * sizcurr); + array2D xxyycurr_reduc(N_t, 2 * sizcurr); float minstud = 100000.f; int goodref = 1; - YYcurr(N_t, sizcurr); - YYcurr_reduc(N_t, sizcurr); + array2D YYcurr(N_t, sizcurr); + array2D YYcurr_reduc(N_t, sizcurr); //calculate x y z for each pixel with multiplier rmm gmm bmm @@ -5089,17 +5033,12 @@ void RawImageSource::ItcWB(bool extra, double &tempref, double &greenref, double } } - float student = 0.f; - - studentXY(xxyycurr_reduc, reff_spect_xxyy, 2 * w, 2 * kk, tt, student); //for xy - - const float abstud = std::fabs(student); + const float abstud = std::fabs(studentXY(xxyycurr_reduc, reff_spect_xxyy, 2 * w, 2 * kk, tt)); if (abstud < minstud) { // find the minimum Student minstud = abstud; goodref = tt; } - } if (extra) { @@ -5184,10 +5123,7 @@ void RawImageSource::ItcWB(bool extra, double &tempref, double &greenref, double } } - float studentgr = 0.f; - - studentXY(xxyycurr_reduc, reff_spect_xxyy, 2 * w, 2 * kkg, tt, studentgr); //for xy - const float abstudgr = std::fabs(studentgr); + const float abstudgr = std::fabs(studentXY(xxyycurr_reduc, reff_spect_xxyy, 2 * w, 2 * kkg, tt)); if (abstudgr < minstudgr) { // find the minimum Student minstudgr = abstudgr; diff --git a/rtgui/colorappearance.cc b/rtgui/colorappearance.cc index eed1c074b..1e7f76b44 100644 --- a/rtgui/colorappearance.cc +++ b/rtgui/colorappearance.cc @@ -823,7 +823,6 @@ void ColorAppearance::read (const ProcParams* pp, const ParamsEdited* pedited) nexttemp = pp->wb.temperature; nextgreen = pp->wb.green; - printf("temp=%f green=%f\n", nexttemp, nextgreen); if (pedited) { degree->setEditedState (pedited->colorappearance.degree ? Edited : UnEdited); degreeout->setEditedState (pedited->colorappearance.degreeout ? Edited : UnEdited);