diff --git a/rtdata/languages/default b/rtdata/languages/default index 5ea726218..8a650d4ba 100644 --- a/rtdata/languages/default +++ b/rtdata/languages/default @@ -2222,6 +2222,8 @@ TP_WAVELET_TMSTRENGTH_TOOLTIP;Control the strength of tone mapping or contrast c TP_WAVELET_TMTYPE;Compression method TP_WAVELET_TON;Toning TP_WBALANCE_AUTO;Auto +TP_WBALANCE_STUDLABEL_TOOLTIP;Display calculated Student correlation\nThe lower the student value, the better the correlation\nValues below 0.002 are excellent\nValues below 0.005 are very good\nValues below 0.01 are good\nValues below 0.05 are good enough\nValues above 0.5 are poor\nVery good Student test results does not mean that the WB is good, if the illuminant is non-standard the results are erratic. +TP_WBALANCE_STUDLABEL;Student Itcwb: %1 TP_WBALANCE_CAMERA;Camera TP_WBALANCE_CLOUDY;Cloudy TP_WBALANCE_CUSTOM;Custom @@ -2231,6 +2233,9 @@ TP_WBALANCE_EQBLUERED_TOOLTIP;Allows to deviate from the normal behavior of "whi TP_WBALANCE_FLASH55;Leica TP_WBALANCE_FLASH60;Standard, Canon, Pentax, Olympus TP_WBALANCE_FLASH65;Nikon, Panasonic, Sony, Minolta +TP_WBALANCE_AUTO_HEADER;Autos +TP_WBALANCE_AUTOOLD;Auto grey old +TP_WBALANCE_AUTOITCGREEN;Auto iterate temperature correlation TP_WBALANCE_FLASH_HEADER;Flash TP_WBALANCE_FLUO1;F1 - Daylight TP_WBALANCE_FLUO2;F2 - Cool White diff --git a/rtengine/imagesource.h b/rtengine/imagesource.h index 089cb3bae..11fdb1a66 100644 --- a/rtengine/imagesource.h +++ b/rtengine/imagesource.h @@ -103,6 +103,7 @@ public: virtual void convertColorSpace (Imagefloat* image, const ColorManagementParams &cmp, const ColorTemp &wb) = 0; // DIRTY HACK: this method is derived in rawimagesource and strimagesource, but (...,RAWParams raw) will be used ONLY for raw images virtual void getAutoWBMultipliers (double &rm, double &gm, double &bm) = 0; + virtual void getAutoWBMultipliersloc(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) = 0; virtual ColorTemp getWB () const = 0; virtual ColorTemp getSpotWB (std::vector &red, std::vector &green, std::vector &blue, int tran, double equal) = 0; virtual void WBauto(double &tempref, double &greenref, array2D &redloc, array2D &greenloc, array2D &blueloc, int bfw, int bfh, double &avg_rm, double &avg_gm, double &avg_bm, double &tempitc, double &greenitc, float &studgood, bool &twotimes, const WBParams & wbpar, int begx, int begy, int yEn, int xEn, int cx, int cy, const ColorManagementParams &cmp, const RAWParams &raw) = 0; diff --git a/rtengine/improccoordinator.cc b/rtengine/improccoordinator.cc index e718087ec..2ee24f750 100644 --- a/rtengine/improccoordinator.cc +++ b/rtengine/improccoordinator.cc @@ -332,17 +332,17 @@ void ImProcCoordinator::updatePreviewImage(int todo, bool panningRelatedChange) bool autowb0 = false; // bool autoitc = false; - autowb0 = (params->wb.method == "autold" || params->wb.method == "aut" || params->wb.method == "autosdw" || params->wb.method == "autedgsdw" || params->wb.method == "autitcgreen" || params->wb.method == "autedgrob" || params->wb.method == "autedg" || params->wb.method == "autorobust"); - // autoitc = (params.wb.method == "autitcgreen"); - // bool gamma = false; - // bool cat = false; -// if (params.wb.wbcat02Method == "cam" && autoitc) { -// cat = true; -// } + // autowb0 = (params->wb.method == "autold" || params->wb.method == "aut" || params->wb.method == "autosdw" || params->wb.method == "autedgsdw" || params->wb.method == "autitcgreen" || params->wb.method == "autedgrob" || params->wb.method == "autedg" || params->wb.method == "autorobust"); + autowb0 = (params->wb.method == "autold" || params->wb.method == "autitcgreen"); + if(autowb0) printf("autoOKOKOK\n"); + if(!autowb0) printf("NOOOOOOONNNNNN\n"); - if (autowb0) { + + // if (autowb0) { + // printf("OK rgbloc avant\n"); imgsrc->getrgbloc(false, false, false, 0, 0, fh, fw, 0, 0, fh, fw); - } + // printf("OK rgbloc apres\n"); + // } if (highDetailNeeded) { @@ -377,7 +377,9 @@ void ImProcCoordinator::updatePreviewImage(int todo, bool panningRelatedChange) bool autowb = false; autowb = (params->wb.method == "autold" || params->wb.method == "aut" || params->wb.method == "autosdw" || params->wb.method == "autedgsdw" || params->wb.method == "autitcgreen" || params->wb.method == "autedgrob" || params->wb.method == "autedg" || params->wb.method == "autorobust"); - + if(autowb) printf("AUTOAUTO\n"); + if(!autowb) printf("PAS--NON\n"); + if (todo & (M_INIT | M_LINDENOISE | M_HDR)) { MyMutex::MyLock initLock(minit); // Also used in crop window @@ -389,16 +391,27 @@ void ImProcCoordinator::updatePreviewImage(int todo, bool panningRelatedChange) } currWB = ColorTemp(params->wb.temperature, params->wb.green, params->wb.equal, params->wb.method); + float studgood = 1000.f; if (!params->wb.enabled) { currWB = ColorTemp(); } else if (params->wb.method == "Camera") { currWB = imgsrc->getWB(); - } else if (params->wb.method == "Auto") { + // } else if (params->wb.method == "Auto") { + } else if (autowb) { if (lastAwbEqual != params->wb.equal || lastAwbTempBias != params->wb.tempBias) { double rm, gm, bm; - imgsrc->getAutoWBMultipliers(rm, gm, bm); + double tempitc = 5000.f; + double greenitc = 1.; + // imgsrc->getAutoWBMultipliers(rm, gm, bm); + currWBitc = imgsrc->getWB(); + double tempref = currWBitc.getTemp() * (1. + params->wb.tempBias); + double greenref = currWBitc.getGreen(); + printf("tempref=%f greref=%f\n", tempref, greenref); + imgsrc->getAutoWBMultipliersloc(tempref, greenref, tempitc, greenitc, studgood, 0, 0, fh, fw, 0, 0, fh, fw, rm, gm, bm, params->wb, params->icm, params->raw); + +/* if (rm != -1.) { autoWB.update(rm, gm, bm, params->wb.equal, params->wb.tempBias); lastAwbEqual = params->wb.equal; @@ -408,9 +421,39 @@ void ImProcCoordinator::updatePreviewImage(int todo, bool panningRelatedChange) lastAwbTempBias = 0.0; autoWB.useDefaults(params->wb.equal); } - +*/ //double rr,gg,bb; //autoWB.getMultipliers(rr,gg,bb); + if (params->wb.method == "autitcgreen") { + params->wb.temperature = tempitc; + params->wb.green = greenitc; + currWB = ColorTemp(params->wb.temperature, params->wb.green, 1., params->wb.method); + currWB.getMultipliers(rm, gm, bm); + } + + if (rm != -1.) { + double bias = params->wb.tempBias; + + if (params->wb.method == "autitcgreen") { + bias = 0.; + } + + autoWB.update(rm, gm, bm, params->wb.equal, bias); + //double temper = autoWB.getTemp(); + //double gre = autoWB.getGreen(); + //printf("temper=%f gre=%f \n", temper, gre); + + lastAwbEqual = params->wb.equal; + lastAwbTempBias = params->wb.tempBias; + lastAwbauto = params->wb.method; + } else { + lastAwbEqual = -1.; + lastAwbTempBias = 0.0; + lastAwbauto = ""; + autoWB.useDefaults(params->wb.equal); + } + + } currWB = autoWB; @@ -421,8 +464,9 @@ void ImProcCoordinator::updatePreviewImage(int todo, bool panningRelatedChange) params->wb.green = currWB.getGreen(); } - if (params->wb.method == "Auto" && awbListener && params->wb.enabled) { - awbListener->WBChanged(params->wb.temperature, params->wb.green); + // if (params->wb.method == "Auto" && awbListener && params->wb.enabled) { + if (autowb && awbListener) { + awbListener->WBChanged(params->wb.temperature, params->wb.green, studgood); } /* @@ -1198,18 +1242,27 @@ bool ImProcCoordinator::getAutoWB(double& temp, double& green, double equal, dou { if (imgsrc) { - if (lastAwbEqual != equal || lastAwbTempBias != tempBias) { + if (lastAwbEqual != equal || lastAwbTempBias != tempBias || lastAwbauto != params->wb.method) { // Issue 2500 MyMutex::MyLock lock(minit); // Also used in crop window double rm, gm, bm; - imgsrc->getAutoWBMultipliers(rm, gm, bm); + params->wb.method = "autold";//same result as before muliple Auto WB + + // imgsrc->getAutoWBMultipliers(rm, gm, bm); + double tempitc = 5000.; + double greenitc = 1.; + float studgood = 1000.f; + double tempref, greenref; + imgsrc->getAutoWBMultipliersloc(tempref, greenref, tempitc, greenitc, studgood, 0, 0, fh, fw, 0, 0, fh, fw, rm, gm, bm, params->wb, params->icm, params->raw); if (rm != -1) { autoWB.update(rm, gm, bm, equal, tempBias); lastAwbEqual = equal; lastAwbTempBias = tempBias; + lastAwbauto = params->wb.method; } else { lastAwbEqual = -1.; autoWB.useDefaults(equal); + lastAwbauto = ""; lastAwbTempBias = 0.0; } } diff --git a/rtengine/improccoordinator.h b/rtengine/improccoordinator.h index c293f0c16..dd91187db 100644 --- a/rtengine/improccoordinator.h +++ b/rtengine/improccoordinator.h @@ -68,9 +68,13 @@ protected: ColorTemp currWB; ColorTemp autoWB; + ColorTemp currWBloc; + ColorTemp autoWBloc; + ColorTemp currWBitc; double lastAwbEqual; double lastAwbTempBias; + Glib::ustring lastAwbauto; Glib::ustring monitorProfile; RenderingIntent monitorIntent; diff --git a/rtengine/procparams.cc b/rtengine/procparams.cc index cfa35ee01..21124f7bf 100644 --- a/rtengine/procparams.cc +++ b/rtengine/procparams.cc @@ -1233,12 +1233,12 @@ const std::vector& WBParams::getWbEntries() // {"Auto", WBEntry::Type::AUTO, M("TP_WBALANCE_AUTO"), 0, 1.f, 1.f, 0.f}, {"autitcgreen", WBEntry::Type::AUTO, M("TP_WBALANCE_AUTOITCGREEN"), 0, 1.f, 1.f, 0.f}, {"autold", WBEntry::Type::AUTO, M("TP_WBALANCE_AUTOOLD"), 0, 1.f, 1.f, 0.f}, - {"aut", WBEntry::Type::AUTO, M("TP_WBALANCE_AUTODEM"), 0, 1.f, 1.f, 0.f}, - {"autedg", WBEntry::Type::AUTO, M("TP_WBALANCE_AUTOEDGE"), 0, 1.f, 1.f, 0.f}, - {"autorobust", WBEntry::Type::AUTO, M("TP_WBALANCE_AUTOROB"), 0, 1.f, 1.f, 0.f}, - {"autosdw", WBEntry::Type::AUTO, M("TP_WBALANCE_AUTOSDW"), 0, 1.f, 1.f, 0.f}, - {"autedgsdw", WBEntry::Type::AUTO, M("TP_WBALANCE_AUTOEDGESW"), 0, 1.f, 1.f, 0.f}, - {"autedgrob", WBEntry::Type::AUTO, M("TP_WBALANCE_AUTOEDGEROB"), 0, 1.f, 1.f, 0.f}, + // {"aut", WBEntry::Type::AUTO, M("TP_WBALANCE_AUTODEM"), 0, 1.f, 1.f, 0.f}, + // {"autedg", WBEntry::Type::AUTO, M("TP_WBALANCE_AUTOEDGE"), 0, 1.f, 1.f, 0.f}, + // {"autorobust", WBEntry::Type::AUTO, M("TP_WBALANCE_AUTOROB"), 0, 1.f, 1.f, 0.f}, + // {"autosdw", WBEntry::Type::AUTO, M("TP_WBALANCE_AUTOSDW"), 0, 1.f, 1.f, 0.f}, + // {"autedgsdw", WBEntry::Type::AUTO, M("TP_WBALANCE_AUTOEDGESW"), 0, 1.f, 1.f, 0.f}, + // {"autedgrob", WBEntry::Type::AUTO, M("TP_WBALANCE_AUTOEDGEROB"), 0, 1.f, 1.f, 0.f}, {"Daylight", WBEntry::Type::DAYLIGHT, M("TP_WBALANCE_DAYLIGHT"), 5300, 1.f, 1.f, 0.f}, {"Cloudy", WBEntry::Type::CLOUDY, M("TP_WBALANCE_CLOUDY"), 6200, 1.f, 1.f, 0.f}, {"Shade", WBEntry::Type::SHADE, M("TP_WBALANCE_SHADE"), 7600, 1.f, 1.f, 0.f}, diff --git a/rtengine/rawimagesource.cc b/rtengine/rawimagesource.cc index 7d4f613f9..e6f50336b 100644 --- a/rtengine/rawimagesource.cc +++ b/rtengine/rawimagesource.cc @@ -6726,7 +6726,6 @@ void RawImageSource::ItcWB(bool extra, double &tempref, double &greenref, double {12001., 0.960440, 1.601019} }; int N_t = sizeof(Txyz) / sizeof(Txyz[0]); //number of temperature White point - int nbt = N_t; float **Tx = nullptr; float **Ty = nullptr; @@ -7591,7 +7590,7 @@ void RawImageSource::WBauto(double & tempref, double & greenref, array2D } - +printf("ok avant itc\n"); if (wbpar.method == "autitcgreen") { bool extra = false; @@ -7612,9 +7611,11 @@ void RawImageSource::WBauto(double & tempref, double & greenref, array2D tempitc = 5000.; // greenitc = greenref; itc = true; +printf("ok avant itc 2\n"); if (itc) { ItcWB(extra, tempref, greenref, tempitc, greenitc, studgood, redloc, greenloc, blueloc, bfw, bfh, avg_rm, avg_gm, avg_bm, cmp, raw, wbpar); +printf("ok apres itc \n"); } } @@ -7733,6 +7734,7 @@ 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 + printf("OK RGBLOC\n"); // int bfh = bf_h + 3, bfw = bf_w + 3; int bfh = H, bfw = W; @@ -8081,7 +8083,9 @@ void RawImageSource::getAutoWBMultipliersloc(double & tempref, double & greenref if (wbpar.method == "aut" || wbpar.method == "autosdw" || wbpar.method == "autedgsdw" || wbpar.method == "autitcgreen" || wbpar.method == "autedgrob" || wbpar.method == "autedg" || wbpar.method == "autorobust") { bool twotimes = false; + printf("OK avant auto\n"); WBauto(tempref, greenref, redloc, greenloc, blueloc, bfw, bfh, avg_rm, avg_gm, avg_bm, tempitc, greenitc, studgood, twotimes, wbpar, begx, begy, yEn, xEn, cx, cy, cmp, raw); + printf("OK apres auto\n"); } diff --git a/rtengine/rtengine.h b/rtengine/rtengine.h index 6264d43ae..e08a2a613 100644 --- a/rtengine/rtengine.h +++ b/rtengine/rtengine.h @@ -376,7 +376,7 @@ class AutoWBListener { public: virtual ~AutoWBListener() = default; - virtual void WBChanged(double temp, double green) = 0; + virtual void WBChanged(double temp, double green, float studgood) = 0; }; class FrameCountListener diff --git a/rtgui/whitebalance.cc b/rtgui/whitebalance.cc index 226edab0b..b04b1f136 100644 --- a/rtgui/whitebalance.cc +++ b/rtgui/whitebalance.cc @@ -324,6 +324,9 @@ WhiteBalance::WhiteBalance () : FoldableToolPanel(this, "whitebalance", M("TP_WB Gtk::Image* itempbiasL = Gtk::manage (new RTImage ("circle-blue-small.png")); Gtk::Image* itempbiasR = Gtk::manage (new RTImage ("circle-yellow-small.png")); + StudLabel = Gtk::manage(new Gtk::Label("---", Gtk::ALIGN_CENTER)); + StudLabel->set_tooltip_text(M("TP_WBALANCE_STUDLABEL_TOOLTIP")); + temp = Gtk::manage (new Adjuster (M("TP_WBALANCE_TEMPERATURE"), MINTEMP, MAXTEMP, 5, CENTERTEMP, itempL, itempR, &wbSlider2Temp, &wbTemp2Slider)); green = Gtk::manage (new Adjuster (M("TP_WBALANCE_GREEN"), MINGREEN, MAXGREEN, 0.001, 1.0, igreenL, igreenR)); equal = Gtk::manage (new Adjuster (M("TP_WBALANCE_EQBLUERED"), MINEQUAL, MAXEQUAL, 0.001, 1.0, iblueredL, iblueredR)); @@ -344,6 +347,7 @@ WhiteBalance::WhiteBalance () : FoldableToolPanel(this, "whitebalance", M("TP_WB boxgreen->pack_start(*igreenL); boxgreen->pack_start(*green); boxgreen->pack_start(*igreenR);*/ + pack_start(*StudLabel); pack_start (*temp); //pack_start (*boxgreen); @@ -477,6 +481,12 @@ void WhiteBalance::optChanged () const WBEntry& currMethod = WBParams::getWbEntries()[methodId]; tempBias->set_sensitive(currMethod.type == WBEntry::Type::AUTO); + bool autit = (currMethod.ppLabel == "autitcgreen"); + if (autit) { + StudLabel->show(); + } else { + StudLabel->hide(); + } switch (currMethod.type) { case WBEntry::Type::CAMERA: @@ -697,6 +707,13 @@ void WhiteBalance::read (const ProcParams* pp, const ParamsEdited* pedited) } tempBias->set_sensitive(wbValues.type == WBEntry::Type::AUTO); + bool autit = (wbValues.ppLabel == "autitcgreen"); + if (autit) { + StudLabel->show(); + } else { + StudLabel->hide(); + } + } setEnabled(pp->wb.enabled); @@ -915,15 +932,19 @@ inline Gtk::TreeRow WhiteBalance::getActiveMethod () return *(method->get_active()); } -void WhiteBalance::WBChanged(double temperature, double greenVal) +void WhiteBalance::WBChanged(double temperature, double greenVal, float studgood) { idle_register.add( - [this, temperature, greenVal]() -> bool + [this, temperature, greenVal, studgood]() -> bool { disableListener(); setEnabled(true); temp->setValue(temperature); green->setValue(greenVal); + StudLabel->set_text( + Glib::ustring::compose(M("TP_WBALANCE_STUDLABEL"), + Glib::ustring::format(std::fixed, std::setprecision(4), studgood)) + ); temp->setDefault(temperature); green->setDefault(greenVal); enableListener(); diff --git a/rtgui/whitebalance.h b/rtgui/whitebalance.h index 2db46b7af..71dce989d 100644 --- a/rtgui/whitebalance.h +++ b/rtgui/whitebalance.h @@ -41,6 +41,9 @@ class WhiteBalance : public ToolParamBlock, public AdjusterListener, public Fold WBLT_PP }; +private: + Gtk::Label* StudLabel; + protected: class MethodColumns : public Gtk::TreeModel::ColumnRecord { @@ -118,7 +121,7 @@ public: wblistener = l; } void setWB (int temp, double green); - void WBChanged (double temp, double green) override; + void WBChanged (double temp, double green, float studgood) override; void setAdjusterBehavior (bool tempadd, bool greenadd, bool equaladd, bool tempbiasadd); void trimValues (rtengine::procparams::ProcParams* pp) override;