diff --git a/rtdata/languages/default b/rtdata/languages/default
index ad2c8ae28..c3b29f8f1 100644
--- a/rtdata/languages/default
+++ b/rtdata/languages/default
@@ -636,6 +636,12 @@ HISTORY_MSG_403;W - ES - Edge sensitivity
HISTORY_MSG_404;W - ES - Base amplification
HISTORY_MSG_405;W - Denoise - Level 4
HISTORY_MSG_406;W - ES - Neighboring pixels
+HISTORY_MSG_407;Dehaze met
+HISTORY_MSG_408;Dehaze neighboring
+HISTORY_MSG_409;Dehaze gain
+HISTORY_MSG_410;Dehaze offset
+HISTORY_MSG_411;Dehaze strength
+HISTORY_MSG_412;Dehaze scales
HISTORY_NEWSNAPSHOT;Add
HISTORY_NEWSNAPSHOT_TOOLTIP;Shortcut: Alt-s
HISTORY_SNAPSHOTS;Snapshots
@@ -1536,6 +1542,18 @@ TP_LABCURVE_LCREDSK;Restrict LC to red and skin-tones
TP_LABCURVE_LCREDSK_TIP;If enabled, the LC Curve affects only red and skin-tones.\nIf disabled, it applies to all tones.
TP_LABCURVE_RSTPROTECTION;Red and skin-tones protection
TP_LABCURVE_RSTPRO_TOOLTIP;Works on the Chromaticity slider and the CC curve.
+TP_LABCURVE_STR;Strength
+TP_LABCURVE_SCAL;Scales
+TP_LABCURVE_NEIGH;Neighboring pixels
+TP_LABCURVE_GAIN;Gain
+TP_LABCURVE_OFFS;Offset
+TP_DEHAZE_LAB;Dehaze
+TP_DEHAZE_LAB_TOOLTIP;Use Retinex algorithm (Lab) to improve dehaze..defog...
+TP_DEHAZE_MET;Dehaze method
+TP_DEHAZ_NONE;None
+TP_DEHAZ_UNI;Uniform
+TP_DEHAZ_LOW;Low
+TP_DEHAZ_HIGH;High
TP_LENSGEOM_AUTOCROP;Auto-Crop
TP_LENSGEOM_FILL;Auto-fill
TP_LENSGEOM_LABEL;Lens / Geometry
diff --git a/rtengine/CMakeLists.txt b/rtengine/CMakeLists.txt
index 0cda358e0..25d7717e1 100644
--- a/rtengine/CMakeLists.txt
+++ b/rtengine/CMakeLists.txt
@@ -18,7 +18,7 @@ set (RTENGINESOURCEFILES safegtk.cc colortemp.cc curves.cc flatcurves.cc diagona
EdgePreservingDecomposition.cc cplx_wavelet_dec.cc FTblockDN.cc
PF_correct_RT.cc previewimage.cc ipwavelet.cc
dirpyr_equalizer.cc
- calc_distort.cc lcp.cc dcp.cc
+ calc_distort.cc lcp.cc dcp.cc ipdehaz.cc
cJSON.c camconst.cc
klt/convolve.cc klt/error.cc klt/klt.cc klt/klt_util.cc klt/pnmio.cc klt/pyramid.cc klt/selectGoodFeatures.cc
klt/storeFeatures.cc klt/trackFeatures.cc klt/writeFeatures.cc
diff --git a/rtengine/dcrop.cc b/rtengine/dcrop.cc
index 138a03594..bfee6c61d 100644
--- a/rtengine/dcrop.cc
+++ b/rtengine/dcrop.cc
@@ -807,6 +807,8 @@ void Crop::update (int todo)
bool wavcontlutili = parent->wavcontlutili;
LUTu dummy;
+ parent->ipf.MSR(labnCrop, labnCrop->W, labnCrop->H, 1);
+
parent->ipf.chromiLuminanceCurve (this, 1, labnCrop, labnCrop, parent->chroma_acurve, parent->chroma_bcurve, parent->satcurve, parent->lhskcurve, parent->clcurve, parent->lumacurve, utili, autili, butili, ccutili, cclutili, clcutili, dummy, dummy, dummy, dummy);
parent->ipf.vibrance (labnCrop);
diff --git a/rtengine/improccoordinator.cc b/rtengine/improccoordinator.cc
index fa1fae502..6c9451874 100644
--- a/rtengine/improccoordinator.cc
+++ b/rtengine/improccoordinator.cc
@@ -576,6 +576,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall)
nprevl->CopyFrom(oprevl);
progress ("Applying Color Boost...", 100 * readyphase / numofphases);
+ ipf.MSR(nprevl, nprevl->W, nprevl->H, 1);
ipf.chromiLuminanceCurve (NULL, pW, nprevl, nprevl, chroma_acurve, chroma_bcurve, satcurve, lhskcurve, clcurve, lumacurve, utili, autili, butili, ccutili, cclutili, clcutili, histCCurve, histCLurve, histLLCurve, histLCurve);
ipf.vibrance(nprevl);
diff --git a/rtengine/improcfun.h b/rtengine/improcfun.h
index 8857677a8..fb7269fe5 100644
--- a/rtengine/improcfun.h
+++ b/rtengine/improcfun.h
@@ -305,6 +305,9 @@ public:
//void RGB_InputTransf(Imagefloat * src, LabImage * dst, const procparams::DirPyrDenoiseParams & dnparams, const procparams::DefringeParams & defringe);
//void RGB_OutputTransf(LabImage * src, Imagefloat * dst, const procparams::DirPyrDenoiseParams & dnparams);
//void output_tile_row (float *Lbloxrow, float ** Lhipassdn, float ** tilemask, int height, int width, int top, int blkrad );
+
+ void MSR(LabImage* lab, int width, int height, int skip);
+
void Tile_calc (int tilesize, int overlap, int kall, int imwidth, int imheight, int &numtiles_W, int &numtiles_H, int &tilewidth, int &tileheight, int &tileWskip, int &tileHskip);
void ip_wavelet(LabImage * lab, LabImage * dst, int kall, const procparams::WaveletParams & waparams, const WavCurve & wavCLVCcurve, const WavOpacityCurveRG & waOpacityCurveRG, const WavOpacityCurveBY & waOpacityCurveBY, const WavOpacityCurveW & waOpacityCurveW, const WavOpacityCurveWL & waOpacityCurveWL, LUTf &wavclCurve, bool wavcontlutili, int skip);
diff --git a/rtengine/ipdehaz.cc b/rtengine/ipdehaz.cc
new file mode 100644
index 000000000..a385d92eb
--- /dev/null
+++ b/rtengine/ipdehaz.cc
@@ -0,0 +1,281 @@
+ /*
+ * This file is part of RawTherapee.
+ *
+ * Copyright (c) 2004-2010 Gabor Horvath
+ *
+ * RawTherapee is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * RawTherapee is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with RawTherapee. If not, see .
+
+ * D. J. Jobson, Z. Rahman, and G. A. Woodell. A multi-scale
+ * Retinex for bridging the gap between color images and the
+ * human observation of scenes. IEEE Transactions on Image Processing,
+ * 1997, 6(7): 965-976
+ * inspired from 2003 Fabien Pelisson
+
+ */
+
+
+ # include
+ # include
+ # include
+ # include
+ # include
+ #include "rtengine.h"
+
+ #include "improcfun.h"
+ # define MAX_DEHAZE_SCALES 8
+ # define clipdehaz( val, minv, maxv ) (( val = (val < minv ? minv : val ) ) > maxv ? maxv : val )
+
+ namespace rtengine
+{
+
+extern const Settings* settings;
+
+ static float DehazeScales[MAX_DEHAZE_SCALES];
+
+ typedef struct
+ {
+ int N;
+ float sigma;
+ double B;
+ double b[4];
+ } gauss3;
+
+void dehaze_scales( float* scales, int nscales, int mode, int s)
+ {
+ if ( nscales == 1 )
+ {
+ scales[0] = (float)s / 2.f;
+ }
+ else if (nscales == 2)
+ {
+ scales[0] = (float) s / 2.f;
+ scales[1] = (float) s;
+ }
+ else
+ {
+ float size_step = (float) s / (float) nscales;
+
+ if(mode==0) {
+ for (int i = 0; i < nscales; ++i )
+ scales[i] = 2.0f + (float)i * size_step;
+ }
+ else if (mode==1) {
+ size_step = (float)log(s - 2.0f) / (float) nscales;
+ for (int i = 0; i < nscales; ++i )
+ scales[i] = 2.0f + (float)pow (10.f, (i * size_step) / log (10.f));
+ }
+ else if(mode==2){
+ size_step = (float) log(s - 2.0f) / (float) nscales;
+ for ( int i = 0; i < nscales; ++i )
+ scales[i] = s - (float)pow (10.f, (i * size_step) / log (10.f));
+ }
+ }
+}
+
+void mean_stddv( float *dst, float &mean, float &stddv, int W_L, int H_L )
+ {
+ float vsquared;
+ int i, j;
+
+ vsquared = 0.0f;
+ mean = 0.0f;
+ for (int i=0; i= 2.5f )
+ {
+ q = 0.98711f * sigma - 0.96330f;
+ }
+ else if ( (sigma >= 0.5f) && (sigma < 2.5f) )
+ {
+ q = 3.97156f - 4.14554f * (float) sqrt ((double) 1 - 0.26891 * sigma);
+ }
+ else
+ {
+ q = 0.1147705018520355224609375f;
+ }
+
+ q2 = q * q;
+ q3 = q * q2;
+ c->b[0] = (1.57825f+(2.44413f*q)+(1.4281f *q2)+(0.422205f*q3));
+ c->b[1] = ( (2.44413f*q)+(2.85619f*q2)+(1.26661f *q3));
+ c->b[2] = ( -((1.4281f*q2)+(1.26661f *q3)));
+ c->b[3] = ( (0.422205f*q3));
+ c->B = 1.0f-((c->b[1]+c->b[2]+c->b[3])/c->b[0]);
+ c->sigma = sigma;
+ c->N = 3;
+ }
+
+
+void gausssmooth( float *in, float *out, int size, int rowstride, gauss3 *c )
+ {
+ int i,n, bufsize;
+ float *w1,*w2;
+
+ bufsize = size+3;
+ size -= 1;
+ w1 = new float [bufsize];
+ w2 = new float [bufsize];
+ w1[0] = in[0];
+ w1[1] = in[0];
+ w1[2] = in[0];
+ for ( i = 0 , n=3; i <= size ; i++, n++)
+ {
+ w1[n] = (float)(c->B*in[i*rowstride] +
+ ((c->b[1]*w1[n-1] +
+ c->b[2]*w1[n-2] +
+ c->b[3]*w1[n-3] ) / c->b[0]));
+ }
+
+ w2[size+1]= w1[size+3];
+ w2[size+2]= w1[size+3];
+ w2[size+3]= w1[size+3];
+ for ( i = size, n = i; i >= 0; i--, n-- )
+ {
+ w2[n]= out[i * rowstride] = (float)(c->B*w1[n] +
+ ((c->b[1]*w2[n+1] +
+ c->b[2]*w2[n+2] +
+ c->b[3]*w2[n+3] ) / c->b[0]));
+ }
+ delete [] w1;
+ delete [] w2;
+ }
+
+void ImProcFunctions::MSR(LabImage* lab, int width, int height, int skip)
+
+ {
+ int Is;
+ float weight;
+ gauss3 coef;
+ float mean, stddv;
+ float mini, delta, maxi;
+ float eps = 5.f;
+ float gain = (float) params->labCurve.gain;//def =1 not use
+ float offset = (float) params->labCurve.offs;//def = 0 not use
+ float strength = (float) params->labCurve.str;
+ int scal = params->labCurve.scal;//def=3
+ int nei = (int) 2.5f*params->labCurve.neigh;//def = 200
+ int modedehaz;
+ if(params->labCurve.dehazmet=="none") modedehaz=-1;//enabled disabled
+ if(params->labCurve.dehazmet=="uni") modedehaz=0;
+ if(params->labCurve.dehazmet=="low") modedehaz=1;
+ if(params->labCurve.dehazmet=="high") modedehaz=2;
+ if (modedehaz !=-1) {//enabled
+ int H_L=height;
+ int W_L=width;
+ float *src = new float[H_L*W_L];
+ memset( src, 0, H_L*W_L * sizeof (float) );
+
+ float *dst = new float[H_L*W_L];
+ memset( dst, 0, H_L*W_L * sizeof (float) );
+
+ float *out = new float[H_L*W_L];
+ memset( out, 0, H_L*W_L * sizeof (float) );
+
+ float *in = new float[H_L*W_L];
+ memset( in, 0, H_L*W_L * sizeof (float) );
+
+ for (int i=0; i< H_L; i++) {
+ for (int j=0; jL[i][j] + eps;
+ }
+ }
+ Is = width * height ;
+ dehaze_scales( DehazeScales, scal, modedehaz, nei );
+
+ weight = 1.0f / (float) scal;
+
+ int posw = 0;
+ for (int i = 0; i < Is ; i++ )
+ {
+ in[i] = (float)(src[i] + eps); //avoid log(0)
+ }
+ for ( int scale = 0; scale < scal; scale++ )
+ {
+ compute_coefs3( &coef, DehazeScales[scale] );
+ for (int row = 0; row < height; row++ )
+ {
+ posw = row * width;
+ gausssmooth( in + posw, out + posw, width, 1, &coef);
+ }
+ memcpy( in, out, Is * sizeof(float) );
+ memset( out, 0 , Is * sizeof(float) );
+
+ for (int col = 0; col < width; col++ )
+ {
+ posw = col;
+ gausssmooth( in + posw, out + posw, height, width, &coef );
+ }
+
+ for ( int i = 0; i < Is; i++ )
+ {
+ dst[i] += weight * (float)( log(src[i] + eps) - log(out[i]) );
+ }
+ }
+ delete [] in;
+ delete [] out;
+
+
+ // Ci(x,y)=log[a Ii(x,y)]-log[ Ei=1-s Ii(x,y)]
+
+ float beta = 16384.0f;
+ for ( int i = 0; i < Is; i ++ )
+ {
+ float logsrc = (float)log( (float) src[i] + eps );
+ dst[i] = gain * ((float)(log(beta * (src[i] + eps)) - logsrc) * dst[i]) + offset;
+ }
+
+ mean=0.f;stddv=0.f;
+ mean_stddv( dst, mean, stddv, W_L, H_L);
+ float dd=1.25f;
+
+ mini = mean - dd*stddv;
+ maxi = mean + dd*stddv;
+ delta = maxi - mini;
+ printf("maxi=%f mini=%f mean=%f std=%f delta=%f\n", maxi, mini, mean, stddv, delta);
+
+ if ( !delta ) delta = 1.0f;
+ for(int i=0;iL[ii][jj]=((100.f - strength)* lab->L[ii][jj] + strength * src[i])/100.f;
+ }
+
+ delete [] dst;
+ delete [] src;
+
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/rtengine/procevents.h b/rtengine/procevents.h
index cb2868dd6..d33c1f8a1 100644
--- a/rtengine/procevents.h
+++ b/rtengine/procevents.h
@@ -432,6 +432,13 @@ enum ProcEvent {
EvWavedgeampli = 403,
EvWavlev3nois = 404,
EvWavNPmet = 405,
+ Evdehazmet = 406,
+ EvLneigh = 407,
+ EvLgain = 408,
+ EvLoffs = 409,
+ EvLstr = 410,
+ EvLscal = 411,
+
NUMOFEVENTS
};
}
diff --git a/rtengine/procparams.cc b/rtengine/procparams.cc
index 66cb76b3b..006b1ad2d 100644
--- a/rtengine/procparams.cc
+++ b/rtengine/procparams.cc
@@ -882,6 +882,11 @@ void ProcParams::setDefaults ()
labCurve.brightness = 0;
labCurve.contrast = 0;
labCurve.chromaticity = 0;
+ labCurve.str = 70;
+ labCurve.scal = 3;
+ labCurve.neigh = 80;
+ labCurve.gain = 1;
+ labCurve.offs = 0;
labCurve.avoidcolorshift = false;
labCurve.lcredsk = true;
labCurve.rstprotection = 0;
@@ -899,6 +904,7 @@ void ProcParams::setDefaults ()
labCurve.lhcurve.push_back(FCT_Linear);
labCurve.hhcurve.clear ();
labCurve.hhcurve.push_back(FCT_Linear);
+ labCurve.dehazmet = "none";
labCurve.lccurve.clear ();
labCurve.lccurve.push_back(DCT_Linear);
@@ -1537,6 +1543,22 @@ int ProcParams::save (Glib::ustring fname, Glib::ustring fname2, bool fnameAbsol
if (!pedited || pedited->labCurve.chromaticity) {
keyFile.set_integer ("Luminance Curve", "Chromaticity", labCurve.chromaticity);
}
+ if (!pedited || pedited->labCurve.str) {
+ keyFile.set_integer ("Luminance Curve", "Str", labCurve.str);
+ }
+ if (!pedited || pedited->labCurve.scal) {
+ keyFile.set_integer ("Luminance Curve", "Scal", labCurve.scal);
+ }
+
+ if (!pedited || pedited->labCurve.neigh) {
+ keyFile.set_integer ("Luminance Curve", "Neigh", labCurve.neigh);
+ }
+ if (!pedited || pedited->labCurve.gain) {
+ keyFile.set_integer ("Luminance Curve", "Gain", labCurve.gain);
+ }
+ if (!pedited || pedited->labCurve.offs) {
+ keyFile.set_integer ("Luminance Curve","Offs", labCurve.offs);
+ }
if (!pedited || pedited->labCurve.avoidcolorshift) {
keyFile.set_boolean ("Luminance Curve", "AvoidColorShift", labCurve.avoidcolorshift);
@@ -1589,6 +1611,9 @@ int ProcParams::save (Glib::ustring fname, Glib::ustring fname2, bool fnameAbsol
Glib::ArrayHandle lccurve = labCurve.lccurve;
keyFile.set_double_list("Luminance Curve", "LcCurve", lccurve);
}
+ if (!pedited || pedited->labCurve.dehazmet) {
+ keyFile.set_string ("Luminance Curve", "Dehazmet",labCurve.dehazmet);
+ }
if (!pedited || pedited->labCurve.clcurve) {
Glib::ArrayHandle clcurve = labCurve.clcurve;
@@ -3653,6 +3678,42 @@ int ProcParams::load (Glib::ustring fname, ParamsEdited* pedited)
pedited->labCurve.contrast = true;
}
}
+ if (keyFile.has_key ("Luminance Curve", "Neigh")) {
+ labCurve.neigh = keyFile.get_integer ("Luminance Curve", "Neigh");
+
+ if (pedited) {
+ pedited->labCurve.neigh = true;
+ }
+ }
+ if (keyFile.has_key ("Luminance Curve", "Str")) {
+ labCurve.str = keyFile.get_integer ("Luminance Curve", "Str");
+
+ if (pedited) {
+ pedited->labCurve.str = true;
+ }
+ }
+ if (keyFile.has_key ("Luminance Curve", "Scal")) {
+ labCurve.scal = keyFile.get_integer ("Luminance Curve", "Scal");
+
+ if (pedited) {
+ pedited->labCurve.scal = true;
+ }
+ }
+
+ if (keyFile.has_key ("Luminance Curve", "Gain")) {
+ labCurve.gain = keyFile.get_integer ("Luminance Curve", "Gain");
+
+ if (pedited) {
+ pedited->labCurve.gain = true;
+ }
+ }
+ if (keyFile.has_key ("Luminance Curve", "Offs")) {
+ labCurve.offs = keyFile.get_integer ("Luminance Curve", "Offs");
+
+ if (pedited) {
+ pedited->labCurve.offs = true;
+ }
+ }
if (ppVersion < 303) {
// transform Saturation into Chromaticity
@@ -3768,6 +3829,13 @@ int ProcParams::load (Glib::ustring fname, ParamsEdited* pedited)
pedited->labCurve.lhcurve = true;
}
}
+ if (keyFile.has_key ("Luminance Curve", "Dehazmet")) {
+ labCurve.dehazmet = keyFile.get_string ("Luminance Curve", "Dehazmet");
+
+ if (pedited) {
+ pedited->labCurve.dehazmet = true;
+ }
+ }
if (keyFile.has_key ("Luminance Curve", "hhCurve")) {
labCurve.hhcurve = keyFile.get_double_list ("Luminance Curve", "hhCurve");
@@ -7004,6 +7072,13 @@ bool ProcParams::operator== (const ProcParams& other)
&& labCurve.hhcurve == other.labCurve.hhcurve
&& labCurve.lccurve == other.labCurve.lccurve
&& labCurve.clcurve == other.labCurve.clcurve
+ && labCurve.str == other.labCurve.str
+ && labCurve.scal == other.labCurve.scal
+ && labCurve.neigh == other.labCurve.neigh
+ && labCurve.gain == other.labCurve.gain
+ && labCurve.offs == other.labCurve.offs
+ && labCurve.dehazmet == other.labCurve.dehazmet
+
&& labCurve.brightness == other.labCurve.brightness
&& labCurve.contrast == other.labCurve.contrast
&& labCurve.chromaticity == other.labCurve.chromaticity
diff --git a/rtengine/procparams.h b/rtengine/procparams.h
index 47dccb47f..4e31a477d 100644
--- a/rtengine/procparams.h
+++ b/rtengine/procparams.h
@@ -283,6 +283,13 @@ public:
bool avoidcolorshift;
double rstprotection;
bool lcredsk;
+ int str;
+ int scal;
+ int neigh;
+ int gain;
+ int offs;
+ Glib::ustring dehazmet;
+
};
/**
diff --git a/rtengine/refreshmap.cc b/rtengine/refreshmap.cc
index c22cf25fa..600d5e902 100644
--- a/rtengine/refreshmap.cc
+++ b/rtengine/refreshmap.cc
@@ -427,7 +427,13 @@ int refreshmap[rtengine::NUMOFEVENTS] = {
DIRPYREQUALIZER, // EvWavedgesensi
DIRPYREQUALIZER, // EvWavedgeampli
DIRPYREQUALIZER, //EvWavlev3nois
- DIRPYREQUALIZER //EvWavNPmet
+ DIRPYREQUALIZER, //EvWavNPmet
+ LUMINANCECURVE, // Evdehazmet
+ LUMINANCECURVE, // EvLneigh
+ LUMINANCECURVE, // EvLgain
+ LUMINANCECURVE, // EvLoffs
+ LUMINANCECURVE, // EvLstr
+ LUMINANCECURVE // EvLscal
};
diff --git a/rtengine/simpleprocess.cc b/rtengine/simpleprocess.cc
index 048fca0c2..bffef9f14 100644
--- a/rtengine/simpleprocess.cc
+++ b/rtengine/simpleprocess.cc
@@ -901,6 +901,7 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
params.labCurve.acurve, params.labCurve.bcurve, params.labCurve.cccurve, params.labCurve.lccurve, curve1, curve2, satcurve, lhskcurve,
hist16C, hist16C, dummy, dummy,
1);
+ ipf.MSR(labView, labView->W, labView->H, 1);
ipf.chromiLuminanceCurve (NULL, 1, labView, labView, curve1, curve2, satcurve, lhskcurve, clcurve, lumacurve, utili, autili, butili, ccutili, cclutili, clcutili, dummy, dummy, dummy, dummy);
diff --git a/rtgui/labcurve.cc b/rtgui/labcurve.cc
index f5b11f0e9..bf0e892e6 100644
--- a/rtgui/labcurve.cc
+++ b/rtgui/labcurve.cc
@@ -206,6 +206,61 @@ LCurve::LCurve () : FoldableToolPanel(this, "labcurves", M("TP_LABCURVE_LABEL"))
curveEditorG->curveListComplete();
pack_start (*curveEditorG, Gtk::PACK_SHRINK, 4);
+ Gtk::HSeparator *hsepdh = Gtk::manage (new Gtk::HSeparator());
+ hsepdh->show ();
+ pack_start (*hsepdh, Gtk::PACK_EXPAND_WIDGET, 4);
+
+ Gtk::Frame* dehazFrame = Gtk::manage (new Gtk::Frame (M("TP_DEHAZE_LAB")) );
+ dehazFrame->set_tooltip_text(M("TP_DEHAZE_LAB_TOOLTIP"));
+ dehazFrame->set_border_width(0);
+ dehazFrame->set_label_align(0.025, 0.5);
+
+ Gtk::VBox * dehazVBox = Gtk::manage ( new Gtk::VBox());
+ dehazVBox->set_border_width(4);
+ dehazVBox->set_spacing(2);
+
+ dhbox = Gtk::manage (new Gtk::HBox ());
+ labmdh = Gtk::manage (new Gtk::Label (M("TP_DEHAZE_MET") + ":"));
+ dhbox->pack_start (*labmdh, Gtk::PACK_SHRINK, 1);
+
+ dehazmet = Gtk::manage (new MyComboBoxText ());
+ dehazmet->append_text (M("TP_DEHAZ_NONE"));
+ dehazmet->append_text (M("TP_DEHAZ_UNI"));
+ dehazmet->append_text (M("TP_DEHAZ_LOW"));
+ dehazmet->append_text (M("TP_DEHAZ_HIGH"));
+ dehazmet->set_active(0);
+ dehazmetConn = dehazmet->signal_changed().connect ( sigc::mem_fun(*this, &LCurve::dehazmetChanged) );
+ // dehazmet->set_tooltip_markup (M("TP_DEHAZ_MET_TOOLTIP"));
+ dhbox->pack_start(*dehazmet);
+ dehazVBox->pack_start(*dhbox);
+
+ str = Gtk::manage (new Adjuster (M("TP_LABCURVE_STR"), 0, 100., 1., 70.));
+ scal = Gtk::manage (new Adjuster (M("TP_LABCURVE_SCAL"), 1, 8., 1., 3.));
+ neigh = Gtk::manage (new Adjuster (M("TP_LABCURVE_NEIGH"), 6, 100., 1., 80.));
+ gain = Gtk::manage (new Adjuster (M("TP_LABCURVE_GAIN"), 0.9, 1.1, 0.01, 1.));
+ offs = Gtk::manage (new Adjuster (M("TP_LABCURVE_OFFS"), -50, 50, 1, 0));
+ dehazVBox->pack_start (*str);
+ str->show ();
+
+ dehazVBox->pack_start (*scal);
+ scal->show ();
+
+ dehazVBox->pack_start (*neigh);
+ neigh->show ();
+
+ // dehazVBox->pack_start (*gain);
+ // gain->show ();
+
+ // dehazVBox->pack_start (*offs);
+ // offs->show ();
+
+ str->setAdjusterListener (this);
+ scal->setAdjusterListener (this);
+ neigh->setAdjusterListener (this);
+ gain->setAdjusterListener (this);
+ offs->setAdjusterListener (this);
+ dehazFrame->add(*dehazVBox);
+ pack_start (*dehazFrame);
}
@@ -218,16 +273,26 @@ void LCurve::read (const ProcParams* pp, const ParamsEdited* pedited)
{
disableListener ();
+ dehazmetConn.block(true);
if (pedited) {
brightness->setEditedState (pedited->labCurve.brightness ? Edited : UnEdited);
contrast->setEditedState (pedited->labCurve.contrast ? Edited : UnEdited);
- chromaticity->setEditedState (pedited->labCurve.chromaticity ? Edited : UnEdited);
+ chromaticity->setEditedState (pedited->labCurve.chromaticity ? Edited : UnEdited);
//%%%%%%%%%%%%%%%%%%%%%%
rstprotection->setEditedState (pedited->labCurve.rstprotection ? Edited : UnEdited);
avoidcolorshift->set_inconsistent (!pedited->labCurve.avoidcolorshift);
lcredsk->set_inconsistent (!pedited->labCurve.lcredsk);
+ str->setEditedState (pedited->labCurve.str ? Edited : UnEdited);
+ scal->setEditedState (pedited->labCurve.scal ? Edited : UnEdited);
+ neigh->setEditedState (pedited->labCurve.neigh ? Edited : UnEdited);
+ gain->setEditedState (pedited->labCurve.gain ? Edited : UnEdited);
+ offs->setEditedState (pedited->labCurve.offs ? Edited : UnEdited);
+
+ if (!pedited->labCurve.dehazmet) {
+ dehazmet->set_active (3);
+ }
//%%%%%%%%%%%%%%%%%%%%%%
@@ -246,6 +311,23 @@ void LCurve::read (const ProcParams* pp, const ParamsEdited* pedited)
contrast->setValue (pp->labCurve.contrast);
chromaticity->setValue (pp->labCurve.chromaticity);
adjusterChanged(chromaticity, pp->labCurve.chromaticity); // To update the GUI sensitiveness
+ neigh->setValue (pp->labCurve.neigh);
+ gain->setValue (pp->labCurve.gain);
+ offs->setValue (pp->labCurve.offs);
+ str->setValue (pp->labCurve.str);
+ scal->setValue (pp->labCurve.scal);
+
+ dehazmet->set_active (0);
+ if (pp->labCurve.dehazmet == "none") {
+ dehazmet->set_active (0);
+ } else if (pp->labCurve.dehazmet == "uni") {
+ dehazmet->set_active (1);
+ } else if (pp->labCurve.dehazmet == "low") {
+ dehazmet->set_active (2);
+ } else if (pp->labCurve.dehazmet == "high") {
+ dehazmet->set_active (3);
+ }
+ dehazmetChanged ();
//%%%%%%%%%%%%%%%%%%%%%%
rstprotection->setValue (pp->labCurve.rstprotection);
@@ -275,6 +357,7 @@ void LCurve::read (const ProcParams* pp, const ParamsEdited* pedited)
clshape->setCurve (pp->labCurve.clcurve);
queue_draw();
+ dehazmetConn.block(false);
enableListener ();
}
@@ -338,6 +421,11 @@ void LCurve::write (ProcParams* pp, ParamsEdited* pedited)
pp->labCurve.brightness = brightness->getValue ();
pp->labCurve.contrast = (int)contrast->getValue ();
pp->labCurve.chromaticity = (int)chromaticity->getValue ();
+ pp->labCurve.str = str->getValue ();
+ pp->labCurve.scal = (int)scal->getValue ();
+ pp->labCurve.neigh = neigh->getValue ();
+ pp->labCurve.gain = (int)gain->getValue ();
+ pp->labCurve.offs = (int)offs->getValue ();
//%%%%%%%%%%%%%%%%%%%%%%
pp->labCurve.avoidcolorshift = avoidcolorshift->get_active ();
@@ -366,7 +454,15 @@ void LCurve::write (ProcParams* pp, ParamsEdited* pedited)
pedited->labCurve.lcredsk = !lcredsk->get_inconsistent();
pedited->labCurve.rstprotection = rstprotection->getEditedState ();
+ pedited->labCurve.dehazmet = dehazmet->get_active_row_number() != 3;
+
//%%%%%%%%%%%%%%%%%%%%%%
+ pedited->labCurve.str = str->getEditedState ();
+ pedited->labCurve.scal = scal->getEditedState ();
+ pedited->labCurve.neigh = neigh->getEditedState ();
+ pedited->labCurve.gain = gain->getEditedState ();
+ pedited->labCurve.offs = offs->getEditedState ();
+
pedited->labCurve.lcurve = !lshape->isUnChanged ();
pedited->labCurve.acurve = !ashape->isUnChanged ();
@@ -377,9 +473,28 @@ void LCurve::write (ProcParams* pp, ParamsEdited* pedited)
pedited->labCurve.hhcurve = !hhshape->isUnChanged ();
pedited->labCurve.lccurve = !lcshape->isUnChanged ();
pedited->labCurve.clcurve = !clshape->isUnChanged ();
+ if (dehazmet->get_active_row_number() == 0) {
+ pp->labCurve.dehazmet = "none";
+ } else if (dehazmet->get_active_row_number() == 1) {
+ pp->labCurve.dehazmet = "uni";
+ } else if (dehazmet->get_active_row_number() == 2) {
+ pp->labCurve.dehazmet = "low";
+ } else if (dehazmet->get_active_row_number() == 3) {
+ pp->labCurve.dehazmet = "high";
+ }
+
+
}
}
+void LCurve::dehazmetChanged()
+{
+ if (listener) {
+ listener->panelChanged (Evdehazmet, dehazmet->get_active_text ());
+ }
+ }
+
+
void LCurve::setDefaults (const ProcParams* defParams, const ParamsEdited* pedited)
{
@@ -387,18 +502,33 @@ void LCurve::setDefaults (const ProcParams* defParams, const ParamsEdited* pedit
contrast->setDefault (defParams->labCurve.contrast);
chromaticity->setDefault (defParams->labCurve.chromaticity);
rstprotection->setDefault (defParams->labCurve.rstprotection);
+ neigh->setDefault (defParams->labCurve.neigh);
+ gain->setDefault (defParams->labCurve.gain);
+ offs->setDefault (defParams->labCurve.offs);
+ str->setDefault (defParams->labCurve.str);
+ scal->setDefault (defParams->labCurve.scal);
if (pedited) {
brightness->setDefaultEditedState (pedited->labCurve.brightness ? Edited : UnEdited);
contrast->setDefaultEditedState (pedited->labCurve.contrast ? Edited : UnEdited);
chromaticity->setDefaultEditedState (pedited->labCurve.chromaticity ? Edited : UnEdited);
rstprotection->setDefaultEditedState (pedited->labCurve.rstprotection ? Edited : UnEdited);
+ neigh->setDefaultEditedState (pedited->labCurve.neigh ? Edited : UnEdited);
+ gain->setDefaultEditedState (pedited->labCurve.gain ? Edited : UnEdited);
+ offs->setDefaultEditedState (pedited->labCurve.offs ? Edited : UnEdited);
+ str->setDefaultEditedState (pedited->labCurve.str ? Edited : UnEdited);
+ scal->setDefaultEditedState (pedited->labCurve.scal ? Edited : UnEdited);
} else {
brightness->setDefaultEditedState (Irrelevant);
contrast->setDefaultEditedState (Irrelevant);
chromaticity->setDefaultEditedState (Irrelevant);
rstprotection->setDefaultEditedState (Irrelevant);
+ neigh->setDefaultEditedState (Irrelevant);
+ gain->setDefaultEditedState (Irrelevant);
+ offs->setDefaultEditedState (Irrelevant);
+ str->setDefaultEditedState (Irrelevant);
+ scal->setDefaultEditedState (Irrelevant);
}
}
@@ -531,6 +661,28 @@ void LCurve::adjusterChanged (Adjuster* a, double newval)
if (listener) {
listener->panelChanged (EvLRSTProtection, costr);
}
+ } else if (a == neigh) {
+ if (listener) {
+ listener->panelChanged (EvLneigh, costr);
+ }
+ } else if (a == str) {
+ if (listener) {
+ listener->panelChanged (EvLstr, costr);
+ }
+ } else if (a == scal) {
+ if (listener) {
+ listener->panelChanged (EvLscal, costr);
+ }
+
+ } else if (a == gain) {
+ if (listener) {
+ listener->panelChanged (EvLgain, costr);
+ }
+ } else if (a == offs) {
+ if (listener) {
+ listener->panelChanged (EvLoffs, costr);
+ }
+
} else if (a == chromaticity) {
if (multiImage) {
//if chromaticity==-100 (lowest value), we enter the B&W mode and avoid color shift and rstprotection has no effect
@@ -616,6 +768,12 @@ void LCurve::setBatchMode (bool batchMode)
contrast->showEditedCB ();
chromaticity->showEditedCB ();
rstprotection->showEditedCB ();
+ dehazmet->append_text (M("GENERAL_UNCHANGED"));
+ neigh->showEditedCB ();
+ gain->showEditedCB ();
+ offs->showEditedCB ();
+ str->showEditedCB ();
+ scal->showEditedCB ();
curveEditorG->setBatchMode (batchMode);
lcshape->setBottomBarColorProvider(NULL, -1);
@@ -647,4 +805,9 @@ void LCurve::trimValues (rtengine::procparams::ProcParams* pp)
brightness->trimValue(pp->labCurve.brightness);
contrast->trimValue(pp->labCurve.contrast);
chromaticity->trimValue(pp->labCurve.chromaticity);
+ str->trimValue(pp->labCurve.str);
+ scal->trimValue(pp->labCurve.scal);
+ neigh->trimValue(pp->labCurve.neigh);
+ gain->trimValue(pp->labCurve.gain);
+ offs->trimValue(pp->labCurve.offs);
}
diff --git a/rtgui/labcurve.h b/rtgui/labcurve.h
index f679fc020..9546005a1 100644
--- a/rtgui/labcurve.h
+++ b/rtgui/labcurve.h
@@ -34,6 +34,12 @@ protected:
Adjuster* brightness;
Adjuster* contrast;
Adjuster* chromaticity;
+ Adjuster* str;
+ Adjuster* scal;
+ Adjuster* neigh;
+ Adjuster* gain;
+ Adjuster* offs;
+
DiagonalCurveEditor* lshape;
DiagonalCurveEditor* ashape;
DiagonalCurveEditor* bshape;
@@ -42,6 +48,9 @@ protected:
FlatCurveEditor* chshape;
FlatCurveEditor* lhshape;
FlatCurveEditor* hhshape;
+ Gtk::Label* labmdh;
+ Gtk::HBox* dhbox;
+ MyComboBoxText* dehazmet;
DiagonalCurveEditor* clshape;
@@ -50,7 +59,7 @@ protected:
Gtk::CheckButton* lcredsk;
Adjuster* rstprotection;
- sigc::connection bwtconn, acconn, lcconn;
+ sigc::connection bwtconn, acconn, lcconn, dehazmetConn;
bool lastACVal, lastLCVal;
//%%%%%%%%%%%%%%%%
@@ -77,6 +86,12 @@ public:
void updateCurveBackgroundHistogram (LUTu & histToneCurve, LUTu & histLCurve, LUTu & histCCurve,/* LUTu & histCLurve, LUTu & histLLCurve,*/ LUTu & histLCAM, LUTu & histCCAM, LUTu & histRed, LUTu & histGreen, LUTu & histBlue, LUTu & histLuma);
virtual void colorForValue (double valX, double valY, enum ColorCaller::ElemType elemType, int callerId, ColorCaller* caller);
+
+ private:
+ void dehazmetChanged();
+
+
+
};
#endif
diff --git a/rtgui/paramsedited.cc b/rtgui/paramsedited.cc
index a597662b7..c699766f1 100644
--- a/rtgui/paramsedited.cc
+++ b/rtgui/paramsedited.cc
@@ -58,6 +58,12 @@ void ParamsEdited::set (bool v)
labCurve.hhcurve = v;
labCurve.lccurve = v;
labCurve.clcurve = v;
+ labCurve.dehazmet = v;
+ labCurve.str = v;
+ labCurve.scal = v;
+ labCurve.neigh = v;
+ labCurve.gain = v;
+ labCurve.offs = v;
labCurve.brightness = v;
labCurve.contrast = v;
labCurve.chromaticity = v;
@@ -513,6 +519,12 @@ void ParamsEdited::initFrom (const std::vector
labCurve.hhcurve = labCurve.hhcurve && p.labCurve.hhcurve == other.labCurve.hhcurve;
labCurve.lccurve = labCurve.lccurve && p.labCurve.lccurve == other.labCurve.lccurve;
labCurve.clcurve = labCurve.clcurve && p.labCurve.clcurve == other.labCurve.clcurve;
+ labCurve.dehazmet = labCurve.dehazmet && p.labCurve.dehazmet == other.labCurve.dehazmet;
+ labCurve.str = labCurve.str && p.labCurve.str == other.labCurve.str;
+ labCurve.scal = labCurve.scal && p.labCurve.scal == other.labCurve.scal;
+ labCurve.neigh = labCurve.neigh && p.labCurve.neigh == other.labCurve.neigh;
+ labCurve.gain = labCurve.gain && p.labCurve.gain == other.labCurve.gain;
+ labCurve.offs = labCurve.offs && p.labCurve.offs == other.labCurve.offs;
labCurve.brightness = labCurve.brightness && p.labCurve.brightness == other.labCurve.brightness;
labCurve.contrast = labCurve.contrast && p.labCurve.contrast == other.labCurve.contrast;
labCurve.chromaticity = labCurve.chromaticity && p.labCurve.chromaticity == other.labCurve.chromaticity;
@@ -1026,7 +1038,9 @@ void ParamsEdited::combine (rtengine::procparams::ProcParams& toEdit, const rten
if (labCurve.lccurve) {
toEdit.labCurve.lccurve = mods.labCurve.lccurve;
}
-
+ if (labCurve.dehazmet) {
+ toEdit.labCurve.dehazmet = mods.labCurve.dehazmet;
+ }
if (labCurve.clcurve) {
toEdit.labCurve.clcurve = mods.labCurve.clcurve;
}
@@ -1042,6 +1056,23 @@ void ParamsEdited::combine (rtengine::procparams::ProcParams& toEdit, const rten
if (labCurve.chromaticity) {
toEdit.labCurve.chromaticity = dontforceSet && options.baBehav[ADDSET_LC_CHROMATICITY] ? toEdit.labCurve.chromaticity + mods.labCurve.chromaticity : mods.labCurve.chromaticity;
}
+ if (labCurve.str) {
+ toEdit.labCurve.str = mods.labCurve.str;
+ }
+
+ if (labCurve.scal) {
+ toEdit.labCurve.scal = mods.labCurve.scal;
+ }
+
+ if (labCurve.neigh) {
+ toEdit.labCurve.neigh = mods.labCurve.neigh;
+ }
+ if (labCurve.gain) {
+ toEdit.labCurve.gain = mods.labCurve.gain;
+ }
+ if (labCurve.offs) {
+ toEdit.labCurve.offs = mods.labCurve.offs;
+ }
if (labCurve.avoidcolorshift) {
toEdit.labCurve.avoidcolorshift = mods.labCurve.avoidcolorshift;
diff --git a/rtgui/paramsedited.h b/rtgui/paramsedited.h
index d1f5124b1..c5516317c 100644
--- a/rtgui/paramsedited.h
+++ b/rtgui/paramsedited.h
@@ -61,6 +61,13 @@ public:
bool brightness;
bool contrast;
bool chromaticity;
+ bool str;
+ bool scal;
+ bool neigh;
+ bool gain;
+ bool offs;
+ bool dehazmet;
+
bool avoidcolorshift;
bool rstprotection;
bool lcurve;