From ac700502db840c107ac311e1424438c21edee928 Mon Sep 17 00:00:00 2001 From: heckflosse Date: Wed, 24 Oct 2018 00:49:51 +0200 Subject: [PATCH 1/2] Flat field: Show auto calculated clip control value in ui --- rtengine/imagesource.h | 1 + rtengine/improccoordinator.cc | 5 ++++- rtengine/improccoordinator.h | 6 ++++++ rtengine/rawimagesource.cc | 7 ++----- rtengine/rawimagesource.h | 3 ++- rtengine/rtengine.h | 8 ++++++++ rtengine/stdimagesource.h | 1 + rtgui/flatfield.cc | 18 ++++++++++++++++++ rtgui/flatfield.h | 4 +++- rtgui/toolpanelcoord.cc | 1 + 10 files changed, 46 insertions(+), 8 deletions(-) diff --git a/rtengine/imagesource.h b/rtengine/imagesource.h index e01f22b16..a7c867e08 100644 --- a/rtengine/imagesource.h +++ b/rtengine/imagesource.h @@ -83,6 +83,7 @@ public: virtual void setBorder (unsigned int border) {} virtual void setCurrentFrame (unsigned int frameNum) = 0; virtual int getFrameCount () = 0; + virtual int getFlatFieldAutoClipValue () = 0; // use right after demosaicing image, add coarse transformation and put the result in the provided Imagefloat* diff --git a/rtengine/improccoordinator.cc b/rtengine/improccoordinator.cc index 8532a2382..b0e0e6632 100644 --- a/rtengine/improccoordinator.cc +++ b/rtengine/improccoordinator.cc @@ -93,7 +93,7 @@ ImProcCoordinator::ImProcCoordinator() fw(0), fh(0), tr(0), fullw(1), fullh(1), pW(-1), pH(-1), - plistener(nullptr), imageListener(nullptr), aeListener(nullptr), acListener(nullptr), abwListener(nullptr), awbListener(nullptr), frameCountListener(nullptr), imageTypeListener(nullptr), actListener(nullptr), adnListener(nullptr), awavListener(nullptr), dehaListener(nullptr), hListener(nullptr), + plistener(nullptr), imageListener(nullptr), aeListener(nullptr), acListener(nullptr), abwListener(nullptr), awbListener(nullptr), flatFieldAutoClipListener(nullptr), frameCountListener(nullptr), imageTypeListener(nullptr), actListener(nullptr), adnListener(nullptr), awavListener(nullptr), dehaListener(nullptr), hListener(nullptr), resultValid(false), lastOutputProfile("BADFOOD"), lastOutputIntent(RI__COUNT), lastOutputBPC(false), thread(nullptr), changeSinceLast(0), updaterRunning(false), destroying(false), utili(false), autili(false), butili(false), ccutili(false), cclutili(false), clcutili(false), opautili(false), wavcontlutili(false), colourToningSatLimit(0.f), colourToningSatLimitOpacity(0.f), highQualityComputed(false) {} @@ -199,6 +199,9 @@ void ImProcCoordinator::updatePreviewImage(int todo, bool panningRelatedChange) imgsrc->setCurrentFrame(params.raw.bayersensor.imageNum); imgsrc->preprocess(rp, params.lensProf, params.coarse); + if (flatFieldAutoClipListener && rp.ff_AutoClipControl) { + flatFieldAutoClipListener->flatFieldAutoClipValueChanged(imgsrc->getFlatFieldAutoClipValue()); + } imgsrc->getRAWHistogram(histRedRaw, histGreenRaw, histBlueRaw); highDetailPreprocessComputed = highDetailNeeded; diff --git a/rtengine/improccoordinator.h b/rtengine/improccoordinator.h index dba12cdd7..e4bb5f246 100644 --- a/rtengine/improccoordinator.h +++ b/rtengine/improccoordinator.h @@ -158,6 +158,7 @@ protected: AutoCamListener* acListener; AutoBWListener* abwListener; AutoWBListener* awbListener; + FlatFieldAutoClipListener *flatFieldAutoClipListener; FrameCountListener *frameCountListener; ImageTypeListener *imageTypeListener; @@ -344,6 +345,11 @@ public: frameCountListener = fcl; } + void setFlatFieldAutoClipListener (FlatFieldAutoClipListener* ffacl) + { + flatFieldAutoClipListener = ffacl; + } + void setImageTypeListener (ImageTypeListener* itl) { imageTypeListener = itl; diff --git a/rtengine/rawimagesource.cc b/rtengine/rawimagesource.cc index 1f84cad54..f980f245c 100644 --- a/rtengine/rawimagesource.cc +++ b/rtengine/rawimagesource.cc @@ -2872,8 +2872,6 @@ void RawImageSource::processFlatField(const RAWParams &raw, RawImage *riFlatFile float limitFactor = 1.f; if(raw.ff_AutoClipControl) { -// int clipControlGui = 0; - for (int m = 0; m < 2; m++) for (int n = 0; n < 2; n++) { float maxval = 0.f; @@ -2917,7 +2915,7 @@ void RawImageSource::processFlatField(const RAWParams &raw, RawImage *riFlatFile } } -// clipControlGui = (1.f - limitFactor) * 100.f; // this value can be used to set the clip control slider in gui + flatFieldAutoClipValue = (1.f - limitFactor) * 100.f; // this value can be used to set the clip control slider in gui } else { limitFactor = max((float)(100 - raw.ff_clipControl) / 100.f, 0.01f); } @@ -3003,7 +3001,6 @@ void RawImageSource::processFlatField(const RAWParams &raw, RawImage *riFlatFile if(raw.ff_AutoClipControl) { // determine maximum calculated value to avoid clipping -// int clipControlGui = 0; float maxval = 0.f; // xtrans files have only one black level actually, so we can simplify the code a bit #ifdef _OPENMP @@ -3038,7 +3035,7 @@ void RawImageSource::processFlatField(const RAWParams &raw, RawImage *riFlatFile // there's only one white level for xtrans if(maxval + black[0] > ri->get_white(0)) { limitFactor = ri->get_white(0) / (maxval + black[0]); -// clipControlGui = (1.f - limitFactor) * 100.f; // this value can be used to set the clip control slider in gui + flatFieldAutoClipValue = (1.f - limitFactor) * 100.f; // this value can be used to set the clip control slider in gui } } else { limitFactor = max((float)(100 - raw.ff_clipControl) / 100.f, 0.01f); diff --git a/rtengine/rawimagesource.h b/rtengine/rawimagesource.h index ad7807a44..e624b41e1 100644 --- a/rtengine/rawimagesource.h +++ b/rtengine/rawimagesource.h @@ -74,7 +74,7 @@ protected: RawImage* riFrames[4] = {nullptr}; unsigned int currFrame = 0; unsigned int numFrames = 0; - + int flatFieldAutoClipValue = 0; array2D rawData; // holds preprocessed pixel values, rowData[i][j] corresponds to the ith row and jth column array2D *rawDataFrames[4] = {nullptr}; array2D *rawDataBuffer[3] = {nullptr}; @@ -212,6 +212,7 @@ public: ri = riFrames[currFrame]; } int getFrameCount() {return numFrames;} + int getFlatFieldAutoClipValue() {return flatFieldAutoClipValue;} class GreenEqulibrateThreshold { public: diff --git a/rtengine/rtengine.h b/rtengine/rtengine.h index 7fc71b5b5..a8abea009 100644 --- a/rtengine/rtengine.h +++ b/rtengine/rtengine.h @@ -371,6 +371,13 @@ public: virtual void FrameCountChanged(int n, int frameNum) = 0; }; +class FlatFieldAutoClipListener +{ +public: + virtual ~FlatFieldAutoClipListener() = default; + virtual void flatFieldAutoClipValueChanged(int n) = 0; +}; + class ImageTypeListener { public: @@ -481,6 +488,7 @@ public: virtual void setHistogramListener (HistogramListener *l) = 0; virtual void setPreviewImageListener (PreviewImageListener* l) = 0; virtual void setAutoCamListener (AutoCamListener* l) = 0; + virtual void setFlatFieldAutoClipListener (FlatFieldAutoClipListener* l) = 0; virtual void setFrameCountListener (FrameCountListener* l) = 0; virtual void setAutoBWListener (AutoBWListener* l) = 0; virtual void setAutoWBListener (AutoWBListener* l) = 0; diff --git a/rtengine/stdimagesource.h b/rtengine/stdimagesource.h index 62cca7d4f..1dbb65001 100644 --- a/rtengine/stdimagesource.h +++ b/rtengine/stdimagesource.h @@ -100,6 +100,7 @@ public: } void setCurrentFrame(unsigned int frameNum) {} int getFrameCount() {return 1;} + int getFlatFieldAutoClipValue() {return 0;} void getRawValues(int x, int y, int rotate, int &R, int &G, int &B) { R = G = B = 0;} diff --git a/rtgui/flatfield.cc b/rtgui/flatfield.cc index 83ab15127..8df3db6f1 100644 --- a/rtgui/flatfield.cc +++ b/rtgui/flatfield.cc @@ -403,3 +403,21 @@ void FlatField::setShortcutPath(const Glib::ustring& path) } catch (Glib::Error&) {} } + +void FlatField::flatFieldAutoClipValueChanged(int n) +{ + struct Data { + FlatField *me; + int n; + }; + const auto func = [](gpointer data) -> gboolean { + Data *d = static_cast(data); + FlatField *me = d->me; + me->disableListener(); + me->flatFieldClipControl->setValue (d->n); + me->enableListener(); + return FALSE; + }; + + idle_register.add(func, new Data { this, n }); +} \ No newline at end of file diff --git a/rtgui/flatfield.h b/rtgui/flatfield.h index 4c0a33a54..e53274d85 100644 --- a/rtgui/flatfield.h +++ b/rtgui/flatfield.h @@ -35,7 +35,7 @@ public: // add other info here }; -class FlatField : public ToolParamBlock, public AdjusterListener, public FoldableToolPanel +class FlatField : public ToolParamBlock, public AdjusterListener, public FoldableToolPanel, public rtengine::FlatFieldAutoClipListener { protected: @@ -58,6 +58,7 @@ protected: bool b_filter_asCurrent; bool israw; + IdleRegister idle_register; public: FlatField (); @@ -80,6 +81,7 @@ public: { ffp = p; }; + void flatFieldAutoClipValueChanged(int n = 0); }; #endif diff --git a/rtgui/toolpanelcoord.cc b/rtgui/toolpanelcoord.cc index 18f81c155..e444f2812 100644 --- a/rtgui/toolpanelcoord.cc +++ b/rtgui/toolpanelcoord.cc @@ -521,6 +521,7 @@ void ToolPanelCoordinator::initImage (rtengine::StagedImageProcessor* ipc_, bool ipc->setAutoCamListener (colorappearance); ipc->setAutoBWListener (blackwhite); ipc->setFrameCountListener (bayerprocess); + ipc->setFlatFieldAutoClipListener (flatfield); ipc->setAutoWBListener (whitebalance); ipc->setAutoColorTonListener (colortoning); ipc->setAutoChromaListener (dirpyrdenoise); From b62673a40867a6de32e7256acb977cdbc45abfed Mon Sep 17 00:00:00 2001 From: heckflosse Date: Wed, 24 Oct 2018 13:07:53 +0200 Subject: [PATCH 2/2] =?UTF-8?q?Some=20changes=20suggested=20by=20Fl=C3=B6s?= =?UTF-8?q?sies=20code=20review,=20#4891?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rtgui/flatfield.cc | 6 ++++++ rtgui/flatfield.h | 1 + 2 files changed, 7 insertions(+) diff --git a/rtgui/flatfield.cc b/rtgui/flatfield.cc index 8df3db6f1..057ce731c 100644 --- a/rtgui/flatfield.cc +++ b/rtgui/flatfield.cc @@ -104,6 +104,11 @@ FlatField::FlatField () : FoldableToolPanel(this, "flatfield", M("TP_FLATFIELD_L } } +FlatField::~FlatField () +{ + idle_register.destroy(); +} + void FlatField::read(const rtengine::procparams::ProcParams* pp, const ParamsEdited* pedited) { disableListener (); @@ -416,6 +421,7 @@ void FlatField::flatFieldAutoClipValueChanged(int n) me->disableListener(); me->flatFieldClipControl->setValue (d->n); me->enableListener(); + delete d; return FALSE; }; diff --git a/rtgui/flatfield.h b/rtgui/flatfield.h index e53274d85..599589b68 100644 --- a/rtgui/flatfield.h +++ b/rtgui/flatfield.h @@ -62,6 +62,7 @@ protected: public: FlatField (); + ~FlatField (); void read (const rtengine::procparams::ProcParams* pp, const ParamsEdited* pedited = nullptr); void write (rtengine::procparams::ProcParams* pp, ParamsEdited* pedited = nullptr);