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.

This commit is contained in:
Emil Martinec
2010-09-14 00:08:23 -05:00
parent da0faec489
commit 1820978df4
15 changed files with 169 additions and 41 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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; i<crops.size(); i++)

View File

@@ -434,7 +434,11 @@ void ImProcFunctions::colorCurve (LabImage* lold, LabImage* lnew) {
if (params->impulseDenoise.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) {

View File

@@ -103,14 +103,14 @@ template<class T> void impulse_nr (T** src, T** dst, int width, int height, doub
float wtdsum, dirwt, norm;
int i1, j1;
rangeblur<unsigned short, unsigned int> (src, lpf, impish /*used as buffer here*/, width, height, thresh, false);
//rangeblur<unsigned short, unsigned int> (src, lpf, impish /*used as buffer here*/, width, height, thresh, false);
//AlignedBuffer<double>* buffer = new AlignedBuffer<double> (MAX(width,height));
AlignedBuffer<double>* buffer = new AlignedBuffer<double> (MAX(width,height));
//gaussHorizontal<unsigned short> (src, lpf, buffer, width, height, 2.0, false /*multiThread*/);
//gaussVertical<unsigned short> (lpf, lpf, buffer, width, height, 2.0, false);
gaussHorizontal<unsigned short> (src, lpf, buffer, width, height, 2.0, false /*multiThread*/);
gaussVertical<unsigned short> (lpf, lpf, buffer, width, height, 2.0, false);
//delete buffer;
delete buffer;
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -125,7 +125,7 @@ template<class T> 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

View File

@@ -21,7 +21,11 @@
#include <rtengine.h>
<<<<<<< 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

View File

@@ -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

View File

@@ -140,6 +140,10 @@ class ColorDenoiseParams {
public:
bool enabled;
<<<<<<< local
int thresh;
=======
>>>>>>> other
};
/**

View File

@@ -106,6 +106,10 @@ TRANSFORM, // EvPerspCorr
EQUALIZER, // EvEqualizer
EQUALIZER, // EvEqlEnabled
IMPULSEDENOISE, // EvIDNEnabled,
<<<<<<< local
IMPULSEDENOISE, // EvIDNThresh,
=======
>>>>>>> other
DIRPYRDENOISE, // EvDPDNEnabled,
DIRPYRDENOISE, // EvDPDNLuma,
DIRPYRDENOISE // EvDPDNChroma,

View File

@@ -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

View File

@@ -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 ();
}

View File

@@ -23,10 +23,10 @@
#include <adjuster.h>
#include <toolpanel.h>
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

View File

@@ -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<rtengine::procparams::ProcParams>
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;

View File

@@ -109,6 +109,10 @@ class ImpulseDenoiseParamsEdited {
public:
bool enabled;
<<<<<<< local
bool thresh;
=======
>>>>>>> other
};
class DirPyrDenoiseParamsEdited {