From 1b70bb4de5f2f770ba07789cc8aa798babc75829 Mon Sep 17 00:00:00 2001 From: jdc Date: Sat, 26 Jan 2013 07:19:34 +0100 Subject: [PATCH] CIECAM02-CAT02 auto-degree display value issue1692 --- rtengine/dcrop.cc | 7 +++++-- rtengine/dcrop.h | 1 + rtengine/improccoordinator.cc | 14 ++++++++++---- rtengine/improccoordinator.h | 2 ++ rtengine/improcfun.cc | 17 ++++++++--------- rtengine/improcfun.h | 7 ++++--- rtengine/rtengine.h | 5 +++++ rtengine/rtthumbnail.cc | 5 +++-- rtengine/simpleprocess.cc | 12 ++++++++---- rtgui/colorappearance.cc | 27 +++++++++++++++++++++++++-- rtgui/colorappearance.h | 6 ++++-- rtgui/toolpanelcoord.cc | 2 ++ 12 files changed, 77 insertions(+), 28 deletions(-) diff --git a/rtengine/dcrop.cc b/rtengine/dcrop.cc index 64f03034e..1af138719 100644 --- a/rtengine/dcrop.cc +++ b/rtengine/dcrop.cc @@ -202,9 +202,12 @@ void Crop::update (int todo) { } int begh = 0, endh = labnCrop->H; bool execsharp=false; + float d; + double dd; if(skip==1) execsharp=true; - if(settings->ciecamfloat) {parent->ipf.ciecam_02float (cieCrop,begh, endh, 1,labnCrop, ¶ms,parent->customColCurve1,parent->customColCurve2,parent->customColCurve3, dummy, dummy, 5, 1,(float**)cbuffer, execsharp);} - else {parent->ipf.ciecam_02 (cieCrop,begh, endh, 1,labnCrop, ¶ms,parent->customColCurve1,parent->customColCurve2,parent->customColCurve3, dummy, dummy, 5, 1,(float**)cbuffer, execsharp);} + if(settings->ciecamfloat) {parent->ipf.ciecam_02float (cieCrop,begh, endh, 1,labnCrop, ¶ms,parent->customColCurve1,parent->customColCurve2,parent->customColCurve3, dummy, dummy, 5, 1,(float**)cbuffer, execsharp, d); + } + else {parent->ipf.ciecam_02 (cieCrop,begh, endh, 1,labnCrop, ¶ms,parent->customColCurve1,parent->customColCurve2,parent->customColCurve3, dummy, dummy, 5, 1,(float**)cbuffer, execsharp, dd);} } // switch back to rgb parent->ipf.lab2monitorRgb (labnCrop, cropImg); diff --git a/rtengine/dcrop.h b/rtengine/dcrop.h index f61c61b9f..344226f72 100644 --- a/rtengine/dcrop.h +++ b/rtengine/dcrop.h @@ -55,6 +55,7 @@ class Crop : public DetailedCrop { bool cropAllocated; DetailedCropListener* cropImageListener; + Glib::Mutex cropMutex; ImProcCoordinator* parent; diff --git a/rtengine/improccoordinator.cc b/rtengine/improccoordinator.cc index f0305b78d..244d450c0 100644 --- a/rtengine/improccoordinator.cc +++ b/rtengine/improccoordinator.cc @@ -70,7 +70,7 @@ ImProcCoordinator::ImProcCoordinator () bcurvehist(256), bcurvehistCropped(256), bbeforehist(256), pW(-1), pH(-1), - plistener(NULL), imageListener(NULL), aeListener(NULL), hListener(NULL), + plistener(NULL), imageListener(NULL), aeListener(NULL), hListener(NULL),acListener(NULL), resultValid(false), changeSinceLast(0), updaterRunning(false), destroying(false) {} @@ -424,12 +424,18 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) { int Iterates=0; int begh=0; int endh=pH; - + float d; + double dd; float **buffer = new float*[pH]; for (int i=0; iciecamfloat){ipf.ciecam_02float (ncie, begh, endh, pW, nprevl, ¶ms, customColCurve1,customColCurve2,customColCurve3, histLCAM, histCCAM, 5, 1, (float**)buffer, true);} - else {ipf.ciecam_02 (ncie, begh, endh, pW, nprevl, ¶ms, customColCurve1,customColCurve2,customColCurve3, histLCAM, histCCAM, 5, 1, (float**)buffer, true);} + + if(settings->ciecamfloat){ipf.ciecam_02float (ncie, begh, endh, pW, nprevl, ¶ms, customColCurve1,customColCurve2,customColCurve3, histLCAM, histCCAM, 5, 1, (float**)buffer, true, d); + if(params.colorappearance.autodegree && acListener && params.colorappearance.enabled) acListener->autoCamChanged(100.*(double)d); + } + else {ipf.ciecam_02 (ncie, begh, endh, pW, nprevl, ¶ms, customColCurve1,customColCurve2,customColCurve3, histLCAM, histCCAM, 5, 1, (float**)buffer, true, dd); + if(params.colorappearance.autodegree && acListener && params.colorappearance.enabled) acListener->autoCamChanged(100.*dd); + } for (int i=0; i sizeListeners; @@ -184,6 +185,7 @@ class ImProcCoordinator : public StagedImageProcessor { void delSizeListener (SizeListener* il) {std::vector::iterator it = std::find (sizeListeners.begin(), sizeListeners.end(), il); if (it!=sizeListeners.end()) sizeListeners.erase (it); } void setAutoExpListener (AutoExpListener* ael) {aeListener = ael; } void setHistogramListener(HistogramListener *h) {hListener = h; } + void setAutoCamListener (AutoCamListener* acl) {acListener = acl; } void saveInputICCReference (const Glib::ustring& fname); diff --git a/rtengine/improcfun.cc b/rtengine/improcfun.cc index aa4922d17..29191320c 100644 --- a/rtengine/improcfun.cc +++ b/rtengine/improcfun.cc @@ -40,6 +40,8 @@ #include "boxblur.h" #include "rt_math.h" #include "EdgePreservingDecomposition.h" +#include "improccoordinator.h" + #ifdef _OPENMP #include #endif @@ -62,10 +64,8 @@ namespace rtengine { extern const Settings* settings; - LUTf ImProcFunctions::cachef ; LUTf ImProcFunctions::gamma2curve = 0; - void ImProcFunctions::initCache () { int maxindex = 65536; @@ -237,7 +237,7 @@ void ImProcFunctions::firstAnalysis (Imagefloat* original, const ProcParams* par } // Copyright (c) 2012 Jacques Desmis -void ImProcFunctions::ciecam_02 (CieImage* ncie, int begh, int endh, int pW, LabImage* lab, const ProcParams* params , const ColorAppearance & customColCurve1, const ColorAppearance & customColCurve2,const ColorAppearance & customColCurve3, LUTu & histLCAM, LUTu & histCCAM, int Iterates, int scale, float** buffer, bool execsharp) +void ImProcFunctions::ciecam_02 (CieImage* ncie, int begh, int endh, int pW, LabImage* lab, const ProcParams* params , const ColorAppearance & customColCurve1, const ColorAppearance & customColCurve2,const ColorAppearance & customColCurve3, LUTu & histLCAM, LUTu & histCCAM, int Iterates, int scale, float** buffer, bool execsharp, double &d) { if(params->colorappearance.enabled) { @@ -283,7 +283,7 @@ if(params->colorappearance.enabled) { Yw=1.0; double Xw, Zw; double f,c,nc,yb,la,xw,yw,zw,f2,c2,nc2,yb2,la2; - double z,fl,n,nbb,ncb,d,aw; + double z,fl,n,nbb,ncb,aw; double xwd,ywd,zwd; int alg=0; float sum=0.f; @@ -951,11 +951,10 @@ if((params->colorappearance.tonecie || params->colorappearance.tonecie && (param // Copyright (c) 2012 Jacques Desmis -void ImProcFunctions::ciecam_02float (CieImage* ncie, int begh, int endh, int pW, LabImage* lab, const ProcParams* params , const ColorAppearance & customColCurve1, const ColorAppearance & customColCurve2,const ColorAppearance & customColCurve3, LUTu & histLCAM, LUTu & histCCAM, int Iterates, int scale, float** buffer, bool execsharp) +void ImProcFunctions::ciecam_02float (CieImage* ncie, int begh, int endh, int pW, LabImage* lab, const ProcParams* params , const ColorAppearance & customColCurve1, const ColorAppearance & customColCurve2,const ColorAppearance & customColCurve3, LUTu & histLCAM, LUTu & histCCAM, int Iterates, int scale, float** buffer, bool execsharp, float &d) { if(params->colorappearance.enabled) { //printf("ciecam float\n"); - #ifdef _DEBUG MyTime t1e,t2e; t1e.set(); @@ -997,8 +996,8 @@ if(params->colorappearance.enabled) { float Yw; Yw=1.0; double Xw, Zw; - float f,c,nc,yb,la,xw,yw,zw,f2,c2,nc2,yb2,la2; - float z,fl,n,nbb,ncb,d,aw; + float f,nc,yb,la,c,xw,yw,zw,f2,c2,nc2,yb2,la2; + float z,fl,n,nbb,ncb,aw;//d float xwd,ywd,zwd; int alg=0; float sum=0.f; @@ -1131,7 +1130,7 @@ if(params->colorappearance.enabled) { #ifndef _DEBUG -#pragma omp parallel default(shared) firstprivate(lab,xw1,xw2,yw1,yw2,zw1,zw2,pilot,jli,chr,yb,la,yb2,la2,fl,nc,f,c, height,width,begh, endh,nc2,f2,c2, alg, gamu, highlight, rstprotection, pW,nj, nbbj, ncbj, flj, czj, dj, awj, n, nbb, ncb, pfl, cz, d) +#pragma omp parallel default(shared) firstprivate(lab,xw1,xw2,yw1,yw2,zw1,zw2,pilot,jli,chr,yb,la,yb2,la2,fl,nc,f,c, height,width,begh, endh,nc2,f2,c2, alg, gamu, highlight, rstprotection, pW,nj, nbbj, ncbj, flj, czj, dj, awj, n, nbb, ncb, pfl, cz) #endif { //matrix for current working space TMatrix wiprof = iccStore->workingSpaceInverseMatrix (params->icm.working); diff --git a/rtengine/improcfun.h b/rtengine/improcfun.h index 92ef0c675..060091117 100644 --- a/rtengine/improcfun.h +++ b/rtengine/improcfun.h @@ -69,6 +69,7 @@ class ImProcFunctions { public: + bool iGamma; // true if inverse gamma has to be applied in rgbProc double g; @@ -82,7 +83,7 @@ class ImProcFunctions { ImProcFunctions (const ProcParams* iparams, bool imultiThread=true) : monitorTransform(NULL), params(iparams), scale(1), multiThread(imultiThread), iGamma(true), g(0.0) {} ~ImProcFunctions (); - + void setScale (double iscale); bool needsTransform (); @@ -94,8 +95,8 @@ class ImProcFunctions { SHMap* shmap, int sat, LUTf & rCurve, LUTf & gCurve, LUTf & bCurve, const ToneCurve & customToneCurve1, const ToneCurve & customToneCurve2, double expcomp, int hlcompr, int hlcomprthresh); void luminanceCurve (LabImage* lold, LabImage* lnew, LUTf &curve); - void ciecam_02float (CieImage* ncie, int begh, int endh, int pW, LabImage* lab, const ProcParams* params , const ColorAppearance & customColCurve1, const ColorAppearance & customColCurve, const ColorAppearance & customColCurve3, LUTu &histLCAM, LUTu &histCCAM,int Iterates, int scale, float** buffer, bool execsharp ); - void ciecam_02 (CieImage* ncie, int begh, int endh, int pW, LabImage* lab, const ProcParams* params , const ColorAppearance & customColCurve1, const ColorAppearance & customColCurve, const ColorAppearance & customColCurve3, LUTu &histLCAM, LUTu &histCCAM,int Iterates, int scale, float** buffer, bool execsharp ); + void ciecam_02float (CieImage* ncie, int begh, int endh, int pW, LabImage* lab, const ProcParams* params , const ColorAppearance & customColCurve1, const ColorAppearance & customColCurve, const ColorAppearance & customColCurve3, LUTu &histLCAM, LUTu &histCCAM,int Iterates, int scale, float** buffer, bool execsharp, float &d); + void ciecam_02 (CieImage* ncie, int begh, int endh, int pW, LabImage* lab, const ProcParams* params , const ColorAppearance & customColCurve1, const ColorAppearance & customColCurve, const ColorAppearance & customColCurve3, LUTu &histLCAM, LUTu &histCCAM,int Iterates, int scale, float** buffer, bool execsharp, double &d); void chromiLuminanceCurve (int pW, LabImage* lold, LabImage* lnew, LUTf &acurve, LUTf &bcurve, LUTf & satcurve,LUTf & satclcurve, LUTf &curve, bool utili, bool autili, bool butili, bool ccutili, bool cclutili, LUTu &histCCurve); void vibrance (LabImage* lab);//Jacques' vibrance void colorCurve (LabImage* lold, LabImage* lnew); diff --git a/rtengine/rtengine.h b/rtengine/rtengine.h index d89082b24..a417d7243 100644 --- a/rtengine/rtengine.h +++ b/rtengine/rtengine.h @@ -238,6 +238,10 @@ namespace rtengine { virtual void autoExpChanged (double brightness, int bright, int contrast, int black, int hlcompr, int hlcomprthresh) {} }; + class AutoCamListener { + public : + virtual void autoCamChanged (double ccam) {} + }; /** This class represents a detailed part of the image (looking through a kind of window). * It can be created and destroyed with the appropriate members of StagedImageProcessor. * Several crops can be assigned to the same image. */ @@ -316,6 +320,7 @@ namespace rtengine { virtual void setAutoExpListener (AutoExpListener* l) =0; virtual void setHistogramListener (HistogramListener *l) =0; virtual void setPreviewImageListener (PreviewImageListener* l) =0; + virtual void setAutoCamListener (AutoCamListener* l) =0; virtual ~StagedImageProcessor () {} diff --git a/rtengine/rtthumbnail.cc b/rtengine/rtthumbnail.cc index 33fd52c96..53be3611d 100644 --- a/rtengine/rtthumbnail.cc +++ b/rtengine/rtthumbnail.cc @@ -816,8 +816,9 @@ IImage8* Thumbnail::processImage (const procparams::ProcParams& params, int rhei float** buffer = new float*[fh]; for (int i=0; iciecamfloat) ipf.ciecam_02float (cieView, begh, endh,1, labView, ¶ms,customColCurve1,customColCurve2,customColCurve3, dummy, dummy, 5, 1, (float**)buffer, true); - else ipf.ciecam_02 (cieView, begh, endh,1, labView, ¶ms,customColCurve1,customColCurve2,customColCurve3, dummy, dummy, 5, 1, (float**)buffer, true); + if(settings->ciecamfloat) ipf.ciecam_02float (cieView, begh, endh,1, labView, ¶ms,customColCurve1,customColCurve2,customColCurve3, dummy, dummy, 5, 1, (float**)buffer, true, d); + else ipf.ciecam_02 (cieView, begh, endh,1, labView, ¶ms,customColCurve1,customColCurve2,customColCurve3, dummy, dummy, 5, 1, (float**)buffer, true, dd); for (int i=0; iciecamfloat) ipf.ciecam_02float (cieView, begh, endh,1, labView, ¶ms,customColCurve1,customColCurve2,customColCurve3, dummy, dummy, 5, 1, (float**)buffer, true); -else ipf.ciecam_02 (cieView, begh, endh,1, labView, ¶ms,customColCurve1,customColCurve2,customColCurve3, dummy, dummy, 5, 1, (float**)buffer, true); +if(settings->ciecamfloat) ipf.ciecam_02float (cieView, begh, endh,1, labView, ¶ms,customColCurve1,customColCurve2,customColCurve3, dummy, dummy, 5, 1, (float**)buffer, true, d); +else ipf.ciecam_02 (cieView, begh, endh,1, labView, ¶ms,customColCurve1,customColCurve2,customColCurve3, dummy, dummy, 5, 1, (float**)buffer, true, dd); for (int i=0; ipack_start (*wbmodel); p1VBox->pack_start (*wbmHBox); - adapscen = Gtk::manage (new Adjuster (M("TP_COLORAPP_ADAPTSCENE"), 1, 4000., 1., 2000.)); + adapscen = Gtk::manage (new Adjuster (M("TP_COLORAPP_ADAPTSCENE"), 0.1, 4000., 0.1, 2000.)); if (adapscen->delay < 1000) adapscen->delay = 1000; adapscen->throwOnButtonRelease(); adapscen->set_tooltip_markup (M("TP_COLORAPP_ADAPTSCENE_TOOLTIP")); @@ -830,6 +830,27 @@ void ColorAppearance::setDefaults (const ProcParams* defParams, const ParamsEdit } } +int autoCamChangedUI (void* data) { + (static_cast(data))->autoCamComputed_ (); + return 0; +} +void ColorAppearance::autoCamChanged (double ccam) +{ + nextCcam = ccam; + g_idle_add (autoCamChangedUI, this); + // Glib::signal_idle().connect (sigc::mem_fun(*this, &ColorAppearance::autoCamComputed_)); +} + +bool ColorAppearance::autoCamComputed_ () { + + disableListener (); +// degree->setEnabled (true); + degree->setValue (nextCcam); + enableListener (); + + return false; +} + void ColorAppearance::colorForValue (double valX, double valY, int callerId, ColorCaller *caller) { @@ -891,6 +912,7 @@ void ColorAppearance::adjusterAutoToggled (Adjuster* a, bool newval) { } if (listener && (multiImage||enabled->get_active()) ) { + if(a==degree) { if (degree->getAutoInconsistent()) listener->panelChanged (EvCATAutoDegree, M("GENERAL_UNCHANGED")); @@ -926,7 +948,8 @@ void ColorAppearance::enabledChanged () { toneCurveMode->set_sensitive (true); } else - listener->panelChanged (EvCATEnabled, M("GENERAL_DISABLED")); + {listener->panelChanged (EvCATEnabled, M("GENERAL_DISABLED")); + } } } diff --git a/rtgui/colorappearance.h b/rtgui/colorappearance.h index 0b69002a0..8767f2853 100644 --- a/rtgui/colorappearance.h +++ b/rtgui/colorappearance.h @@ -28,7 +28,7 @@ #include "guiutils.h" #include "colorprovider.h" -class ColorAppearance : public Gtk::VBox, public AdjusterListener, public FoldableToolPanel, public CurveListener, public ColorProvider { +class ColorAppearance : public Gtk::VBox, public AdjusterListener, public FoldableToolPanel, public rtengine::AutoCamListener, public CurveListener, public ColorProvider { protected: Glib::RefPtr bgTTips; @@ -76,7 +76,7 @@ class ColorAppearance : public Gtk::VBox, public AdjusterListener, public Foldab DiagonalCurveEditor* shape; DiagonalCurveEditor* shape2; DiagonalCurveEditor* shape3; - + double nextCcam; bool lastEnabled; bool lastAutoDegree; sigc::connection enaConn; @@ -109,6 +109,8 @@ class ColorAppearance : public Gtk::VBox, public AdjusterListener, public Foldab void datacie_toggled (); void tonecie_toggled (); // void sharpcie_toggled (); + void autoCamChanged (double ccam); + bool autoCamComputed_ (); void curveChanged (CurveEditor* ce); void curveMode1Changed (); diff --git a/rtgui/toolpanelcoord.cc b/rtgui/toolpanelcoord.cc index 41ff8a6b7..9631980a2 100644 --- a/rtgui/toolpanelcoord.cc +++ b/rtgui/toolpanelcoord.cc @@ -357,6 +357,8 @@ void ToolPanelCoordinator::initImage (rtengine::StagedImageProcessor* ipc_, bool if (ipc) { ipc->setAutoExpListener (toneCurve); + ipc->setAutoCamListener (colorappearance); + ipc->setSizeListener (crop); ipc->setSizeListener (resize); }