From 1820978df4bc9b52d9d6d7ac33c44ad36cd2bece Mon Sep 17 00:00:00 2001 From: Emil Martinec Date: Tue, 14 Sep 2010 00:08:23 -0500 Subject: [PATCH] Added a threshold slider to the impulse NR tool. Large values can cause cratering, but otherwise this should be a good precursor to pyramid denoising. --- .hgignore | 13 --------- rtdata/languages/default | 4 +++ rtengine/dcrop.cc | 24 +++++++++++++++- rtengine/improccoordinator.cc | 54 +++++++++++++++++++++++++++++++++-- rtengine/improcfun.cc | 4 +++ rtengine/impulse_denoise.h | 12 ++++---- rtengine/procevents.h | 11 +++++++ rtengine/procparams.cc | 17 +++++++++++ rtengine/procparams.h | 4 +++ rtengine/refreshmap.cc | 4 +++ rtengine/refreshmap.h | 11 +++++++ rtgui/impulsedenoise.cc | 28 +++++++++--------- rtgui/impulsedenoise.h | 8 +++--- rtgui/paramsedited.cc | 12 ++++++++ rtgui/paramsedited.h | 4 +++ 15 files changed, 169 insertions(+), 41 deletions(-) delete mode 100644 .hgignore diff --git a/.hgignore b/.hgignore deleted file mode 100644 index 62f686c3d..000000000 --- a/.hgignore +++ /dev/null @@ -1,13 +0,0 @@ -syntax: glob - -CMakeFiles -Makefile -cmake_install.cmake -CMakeCache.txt -rtgui/config.h -release -rtengine/librtengine.a -rtexif/librtexif.a -rtgui/rt -install_manifest.txt - diff --git a/rtdata/languages/default b/rtdata/languages/default index 667b8acb2..962621854 100644 --- a/rtdata/languages/default +++ b/rtdata/languages/default @@ -566,6 +566,10 @@ TP_ICM_OUTPUTPROFILE;Output Profile TP_ICM_SAVEREFERENCE;Save reference image for profiling TP_ICM_WORKINGPROFILE;Working Profile TP_IMPULSEDENOISE_LABEL;Impulse Noise Reduction +<<<<<<< local +TP_IMPULSEDENOISE_THRESH;Threshold +======= +>>>>>>> other TP_LENSGEOM_AUTOCROP;Auto Crop TP_LENSGEOM_FILL;Auto Fill TP_LENSGEOM_LABEL;Lens / Geometry diff --git a/rtengine/dcrop.cc b/rtengine/dcrop.cc index c578976e9..3a2fc03f6 100644 --- a/rtengine/dcrop.cc +++ b/rtengine/dcrop.cc @@ -166,7 +166,7 @@ void Crop::update (int todo, bool internal) { if (skip==1) { parent->ipf.impulsedenoise (labnCrop); parent->ipf.lumadenoise (labnCrop, cbuffer); - parent->ipf.sharpening (labnCrop, (unsigned short**)cbuffer); + //parent->ipf.sharpening (labnCrop, (unsigned short**)cbuffer); parent->ipf.waveletEqualizer(labnCrop, true, false); } } @@ -177,9 +177,31 @@ void Crop::update (int todo, bool internal) { if (skip==1) { parent->ipf.colordenoise (labnCrop, cbuffer); parent->ipf.dirpyrdenoise (labnCrop); +<<<<<<< local + parent->ipf.sharpening (labnCrop, (unsigned short**)cbuffer); +======= +>>>>>>> other parent->ipf.waveletEqualizer(labnCrop, false, true); } } + + + // apply luminance operations + /*if (todo & M_LUMINANCE) { + parent->ipf.luminanceCurve (laboCrop, labnCrop, parent->lumacurve, 0, croph); + if (skip==1) { + parent->ipf.impulsedenoise (labnCrop); + parent->ipf.lumadenoise (labnCrop, cbuffer); + parent->ipf.colordenoise (labnCrop, cbuffer); + parent->ipf.dirpyrdenoise (labnCrop); + parent->ipf.sharpening (labnCrop, (unsigned short**)cbuffer); + parent->ipf.impulsedenoise (labnCrop); + parent->ipf.waveletEqualizer(labnCrop, true, false); + parent->ipf.waveletEqualizer(labnCrop, false, true); + } + parent->ipf.colorCurve (labnCrop, labnCrop); + + }*/ // switch back to rgb diff --git a/rtengine/improccoordinator.cc b/rtengine/improccoordinator.cc index af3265155..457076d7c 100644 --- a/rtengine/improccoordinator.cc +++ b/rtengine/improccoordinator.cc @@ -157,7 +157,8 @@ void ImProcCoordinator::updatePreviewImage (int todo) { if (todo & M_LUMACURVE) CurveFactory::complexCurve (0.0, 0.0, 0.0, 0.0, params.lumaCurve.brightness, params.lumaCurve.contrast, 0.0, 0.0, false, params.lumaCurve.curve, lhist16, lumacurve, bcLhist, scale==1 ? 1 : 16); - if (todo & M_LUMINANCE) { + + if (todo & M_LUMINANCE) { progress ("Applying Luminance Curve...",100*readyphase/numofphases); ipf.luminanceCurve (oprevl, nprevl, lumacurve, 0, pH); readyphase++; @@ -180,8 +181,8 @@ void ImProcCoordinator::updatePreviewImage (int todo) { } readyphase++; } - - + + if (todo & M_COLOR) { progress ("Applying Color Boost...",100*readyphase/numofphases); ipf.colorCurve (oprevl, nprevl); @@ -200,6 +201,53 @@ void ImProcCoordinator::updatePreviewImage (int todo) { } readyphase++; } + + + + + /*if (todo & M_LUMINANCE ) { + progress ("Applying Luminance Curve...",100*readyphase/numofphases); + ipf.luminanceCurve (oprevl, nprevl, lumacurve, 0, pH); + readyphase++; + if (scale==1) { + progress ("Denoising luminance impulse...",100*readyphase/numofphases); + ipf.impulsedenoise (nprevl); + } + if (scale==1) { + progress ("Denoising luminance...",100*readyphase/numofphases); + ipf.lumadenoise (nprevl, buffer); + } + readyphase++; + if (scale==1) { + progress ("Denoising color...",100*readyphase/numofphases); + ipf.colordenoise (nprevl, buffer); + } + if (scale==1) { + progress ("Denoising luma/chroma...",100*readyphase/numofphases); + ipf.dirpyrdenoise (nprevl); + } + if (scale==1) { + progress ("Sharpening...",100*readyphase/numofphases); + ipf.sharpening (nprevl, (unsigned short**)buffer); + } + //if (scale==1) { + // progress ("Denoising luminance impulse...",100*readyphase/numofphases); + // ipf.impulsedenoise (nprevl); + //} + if (scale==1) { + progress ("Wavelet...",100*readyphase/numofphases); + ipf.waveletEqualizer (nprevl, true, false); + } + if (scale==1) { + progress ("Wavelet...",100*readyphase/numofphases); + ipf.waveletEqualizer (nprevl, false, true); + } + readyphase++; + + progress ("Applying Color Boost...",100*readyphase/numofphases); + ipf.colorCurve (nprevl, nprevl); + readyphase++; + }*/ // process crop, if needed for (int i=0; iimpulseDenoise.enabled && lab->W>=8 && lab->H>=8) +<<<<<<< local + impulse_nr (lab->L, lab->L, lab->W, lab->H, (float)params->impulseDenoise.thresh/20.0 /*1024*/); +======= impulse_nr (lab->L, lab->L, lab->W, lab->H, 1024); +>>>>>>> other } void ImProcFunctions::dirpyrdenoise (LabImage* lab) { diff --git a/rtengine/impulse_denoise.h b/rtengine/impulse_denoise.h index 340d2100c..ed9d226fb 100644 --- a/rtengine/impulse_denoise.h +++ b/rtengine/impulse_denoise.h @@ -103,14 +103,14 @@ template void impulse_nr (T** src, T** dst, int width, int height, doub float wtdsum, dirwt, norm; int i1, j1; - rangeblur (src, lpf, impish /*used as buffer here*/, width, height, thresh, false); + //rangeblur (src, lpf, impish /*used as buffer here*/, width, height, thresh, false); - //AlignedBuffer* buffer = new AlignedBuffer (MAX(width,height)); + AlignedBuffer* buffer = new AlignedBuffer (MAX(width,height)); - //gaussHorizontal (src, lpf, buffer, width, height, 2.0, false /*multiThread*/); - //gaussVertical (lpf, lpf, buffer, width, height, 2.0, false); + gaussHorizontal (src, lpf, buffer, width, height, 2.0, false /*multiThread*/); + gaussVertical (lpf, lpf, buffer, width, height, 2.0, false); - //delete buffer; + delete buffer; //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -125,7 +125,7 @@ template void impulse_nr (T** src, T** dst, int width, int height, doub hfnbrave += fabs(src[i1][j1]-lpf[i1][j1]); } hfnbrave = (hfnbrave-hpfabs)/24; - hpfabs>(hfnbrave*3) ? impish[i][j]=1 : impish[i][j]=0; + hpfabs>(hfnbrave*(5.5-thresh)) ? impish[i][j]=1 : impish[i][j]=0; }//now impulsive values have been corrected diff --git a/rtengine/procevents.h b/rtengine/procevents.h index 7f4723d6d..579b2b6a5 100644 --- a/rtengine/procevents.h +++ b/rtengine/procevents.h @@ -21,7 +21,11 @@ #include +<<<<<<< local +#define NUMOFEVENTS 91 +======= #define NUMOFEVENTS 90 +>>>>>>> other namespace rtengine { @@ -113,9 +117,16 @@ enum ProcEvent { EvEqualizer=84, EvEqlEnabled=85, EvIDNEnabled=86, +<<<<<<< local + EvIDNThresh=87, + EvDPDNEnabled=88, + EvDPDNLuma=89, + EvDPDNChroma=90 +======= EvDPDNEnabled=87, EvDPDNLuma=88, EvDPDNChroma=89 +>>>>>>> other }; } #endif diff --git a/rtengine/procparams.cc b/rtengine/procparams.cc index aa67c7c76..cebb554c0 100644 --- a/rtengine/procparams.cc +++ b/rtengine/procparams.cc @@ -96,6 +96,10 @@ void ProcParams::setDefaults () { colorDenoise.edgetolerance = 2000; impulseDenoise.enabled = false; +<<<<<<< local + impulseDenoise.thresh = 50; +======= +>>>>>>> other dirpyrDenoise.enabled = false; dirpyrDenoise.luma = 10; @@ -245,7 +249,12 @@ int ProcParams::save (Glib::ustring fname) const { // save impulseDenoise keyFile.set_boolean ("Impulse Denoising", "Enabled", impulseDenoise.enabled); +<<<<<<< local + keyFile.set_integer ("Impulse Denoising", "Threshold", impulseDenoise.thresh); + +======= +>>>>>>> other // save dirpyrDenoise keyFile.set_boolean ("Directional Pyramid Denoising", "Enabled", dirpyrDenoise.enabled); keyFile.set_integer ("Directional Pyramid Denoising", "Luma", dirpyrDenoise.luma); @@ -461,6 +470,10 @@ if (keyFile.has_group ("Color Shift")) { // load impulseDenoise if (keyFile.has_group ("Impulse Denoising")) { if (keyFile.has_key ("Impulse Denoising", "Enabled")) impulseDenoise.enabled = keyFile.get_boolean ("Impulse Denoising", "Enabled"); +<<<<<<< local + if (keyFile.has_key ("Impulse Denoising", "Threshold")) impulseDenoise.thresh = keyFile.get_integer ("Impulse Denoising", "Threshold"); +======= +>>>>>>> other } // load dirpyrDenoise @@ -675,6 +688,10 @@ bool ProcParams::operator== (const ProcParams& other) { && colorShift.a == other.colorShift.a && colorShift.b == other.colorShift.b && impulseDenoise.enabled == other.impulseDenoise.enabled +<<<<<<< local + && impulseDenoise.thresh == other.impulseDenoise.thresh +======= +>>>>>>> other && dirpyrDenoise.enabled == other.dirpyrDenoise.enabled && dirpyrDenoise.luma == other.dirpyrDenoise.luma && dirpyrDenoise.chroma == other.dirpyrDenoise.chroma diff --git a/rtengine/procparams.h b/rtengine/procparams.h index 0efd06e49..9af8d9e95 100644 --- a/rtengine/procparams.h +++ b/rtengine/procparams.h @@ -140,6 +140,10 @@ class ColorDenoiseParams { public: bool enabled; +<<<<<<< local + int thresh; +======= +>>>>>>> other }; /** diff --git a/rtengine/refreshmap.cc b/rtengine/refreshmap.cc index 98f597376..88eeefcb3 100644 --- a/rtengine/refreshmap.cc +++ b/rtengine/refreshmap.cc @@ -106,6 +106,10 @@ TRANSFORM, // EvPerspCorr EQUALIZER, // EvEqualizer EQUALIZER, // EvEqlEnabled IMPULSEDENOISE, // EvIDNEnabled, +<<<<<<< local +IMPULSEDENOISE, // EvIDNThresh, +======= +>>>>>>> other DIRPYRDENOISE, // EvDPDNEnabled, DIRPYRDENOISE, // EvDPDNLuma, DIRPYRDENOISE // EvDPDNChroma, diff --git a/rtengine/refreshmap.h b/rtengine/refreshmap.h index 90073c563..5519dcd84 100644 --- a/rtengine/refreshmap.h +++ b/rtengine/refreshmap.h @@ -28,12 +28,23 @@ #define AUTOEXP 31 #define RGBCURVE 15 #define LUMINANCECURVE 6 +<<<<<<< local +#define SHARPENING 3//2 +#define IMPULSEDENOISE 3//2 +#define LUMADENOISE 3//2 +======= #define SHARPENING 2 #define IMPULSEDENOISE 2 #define LUMADENOISE 2 +>>>>>>> other #define WHITEBALANCE 255 +<<<<<<< local +#define COLORBOOST 3//1 +#define COLORDENOISE 3//1 +======= #define COLORBOOST 1 #define COLORDENOISE 1 +>>>>>>> other #define DIRPYRDENOISE 3 #define CROP 16384 #define EXIF 32768 diff --git a/rtgui/impulsedenoise.cc b/rtgui/impulsedenoise.cc index 40c6bcc4f..8f82e360e 100644 --- a/rtgui/impulsedenoise.cc +++ b/rtgui/impulsedenoise.cc @@ -29,14 +29,14 @@ ImpulseDenoise::ImpulseDenoise () : ToolPanel() { enabled = Gtk::manage (new Gtk::CheckButton (M("GENERAL_ENABLED"))); enabled->set_active (false); - //amount = Gtk::manage (new Adjuster (M("TP_DETAIL_AMOUNT"), 1, 100, 1, 30)); + thresh = Gtk::manage (new Adjuster (M("TP_DETAIL_AMOUNT"), 0, 100, 1, 10)); pack_start (*enabled); pack_start (*Gtk::manage (new Gtk::HSeparator())); - //pack_start (*amount); + pack_start (*thresh); enaConn = enabled->signal_toggled().connect( sigc::mem_fun(*this, &ImpulseDenoise::enabledChanged) ); - //amount->setAdjusterListener (this); + thresh->setAdjusterListener (this); show_all_children (); } @@ -46,7 +46,7 @@ void ImpulseDenoise::read (const ProcParams* pp, const ParamsEdited* pedited) { disableListener (); if (pedited) { - //amount->setEditedState (pedited->impulseDenoise.amount ? Edited : UnEdited); + thresh->setEditedState (pedited->impulseDenoise.thresh ? Edited : UnEdited); enabled->set_inconsistent (!pedited->impulseDenoise.enabled); } @@ -56,39 +56,39 @@ void ImpulseDenoise::read (const ProcParams* pp, const ParamsEdited* pedited) { lastEnabled = pp->impulseDenoise.enabled; - //amount->setValue (pp->impulseDenoise.amount); + thresh->setValue (pp->impulseDenoise.thresh); enableListener (); } void ImpulseDenoise::write (ProcParams* pp, ParamsEdited* pedited) { - //pp->impulseDenoise.amount = amount->getValue (); + pp->impulseDenoise.thresh = thresh->getValue (); pp->impulseDenoise.enabled = enabled->get_active(); if (pedited) { - //pedited->impulseDenoise.amount = amount->getEditedState (); + pedited->impulseDenoise.thresh = thresh->getEditedState (); pedited->impulseDenoise.enabled = !enabled->get_inconsistent(); } } void ImpulseDenoise::setDefaults (const ProcParams* defParams, const ParamsEdited* pedited) { - //amount->setDefault (defParams->impulseDenoise.amount); + thresh->setDefault (defParams->impulseDenoise.thresh); - /*if (pedited) - amount->setDefaultEditedState (pedited->impulseDenoise.amount ? Edited : UnEdited); + if (pedited) + thresh->setDefaultEditedState (pedited->impulseDenoise.thresh ? Edited : UnEdited); else - amount->setDefaultEditedState (Irrelevant);*/ + thresh->setDefaultEditedState (Irrelevant); } -/*void ImpulseDenoise::adjusterChanged (Adjuster* a, double newval) { +void ImpulseDenoise::adjusterChanged (Adjuster* a, double newval) { if (listener && enabled->get_active()) { listener->panelChanged (EvCDNRadius, Glib::ustring::format (std::setw(2), std::fixed, std::setprecision(1), a->getValue())); } -}*/ +} void ImpulseDenoise::enabledChanged () { @@ -116,5 +116,5 @@ void ImpulseDenoise::enabledChanged () { void ImpulseDenoise::setBatchMode (bool batchMode) { ToolPanel::setBatchMode (batchMode); - //amount->showEditedCB (); + thresh->showEditedCB (); } diff --git a/rtgui/impulsedenoise.h b/rtgui/impulsedenoise.h index d769c3995..8aefd5e48 100644 --- a/rtgui/impulsedenoise.h +++ b/rtgui/impulsedenoise.h @@ -23,10 +23,10 @@ #include #include -class ImpulseDenoise : public Gtk::VBox, /*public AdjusterListener,*/ public ToolPanel { +class ImpulseDenoise : public Gtk::VBox, public AdjusterListener, public ToolPanel { protected: - //Adjuster* radius; + Adjuster* thresh; //Adjuster* edge; Gtk::CheckButton* enabled; bool lastEnabled; @@ -42,10 +42,10 @@ class ImpulseDenoise : public Gtk::VBox, /*public AdjusterListener,*/ public Too void setDefaults (const rtengine::procparams::ProcParams* defParams, const ParamsEdited* pedited=NULL); void setBatchMode (bool batchMode); - //void adjusterChanged (Adjuster* a, double newval); + void adjusterChanged (Adjuster* a, double newval); void enabledChanged (); - //void setAdjusterBehavior (bool bedgetoladd); + void setAdjusterBehavior (bool bedgetoladd); }; #endif diff --git a/rtgui/paramsedited.cc b/rtgui/paramsedited.cc index 782312dce..b2e284ed0 100644 --- a/rtgui/paramsedited.cc +++ b/rtgui/paramsedited.cc @@ -69,6 +69,10 @@ void ParamsEdited::set (bool v) { colorDenoise.enabled = v; colorDenoise.amount = v; impulseDenoise.enabled = v; +<<<<<<< local + impulseDenoise.thresh = v; +======= +>>>>>>> other dirpyrDenoise.enabled = v; dirpyrDenoise.luma = v; dirpyrDenoise.chroma = v; @@ -186,6 +190,10 @@ void ParamsEdited::initFrom (const std::vector colorDenoise.amount = colorDenoise.amount && p.colorDenoise.amount == other.colorDenoise.amount; impulseDenoise.enabled = impulseDenoise.enabled && p.impulseDenoise.enabled == other.impulseDenoise.enabled; +<<<<<<< local + impulseDenoise.thresh = impulseDenoise.thresh && p.impulseDenoise.thresh == other.impulseDenoise.thresh; +======= +>>>>>>> other dirpyrDenoise.enabled = dirpyrDenoise.enabled && p.dirpyrDenoise.enabled == other.dirpyrDenoise.enabled; dirpyrDenoise.luma = dirpyrDenoise.luma && p.dirpyrDenoise.luma == other.dirpyrDenoise.luma; @@ -295,6 +303,10 @@ void ParamsEdited::combine (rtengine::procparams::ProcParams& toEdit, const rten if (colorDenoise.amount) toEdit.colorDenoise.amount = mods.colorDenoise.amount; if (impulseDenoise.enabled) toEdit.impulseDenoise.enabled = mods.impulseDenoise.enabled; +<<<<<<< local + if (impulseDenoise.thresh) toEdit.impulseDenoise.thresh = mods.impulseDenoise.thresh; +======= +>>>>>>> other if (dirpyrDenoise.enabled) toEdit.dirpyrDenoise.enabled = mods.dirpyrDenoise.enabled; if (dirpyrDenoise.luma) toEdit.dirpyrDenoise.luma = mods.dirpyrDenoise.luma; diff --git a/rtgui/paramsedited.h b/rtgui/paramsedited.h index ad8b2a68a..cc5d5e607 100644 --- a/rtgui/paramsedited.h +++ b/rtgui/paramsedited.h @@ -109,6 +109,10 @@ class ImpulseDenoiseParamsEdited { public: bool enabled; +<<<<<<< local + bool thresh; +======= +>>>>>>> other }; class DirPyrDenoiseParamsEdited {