diff --git a/rtdata/dcpprofiles/Nikon D750.dcp b/rtdata/dcpprofiles/Nikon D750.dcp index ad9cd5679..6dcef8386 100644 Binary files a/rtdata/dcpprofiles/Nikon D750.dcp and b/rtdata/dcpprofiles/Nikon D750.dcp differ diff --git a/rtdata/languages/default b/rtdata/languages/default index b404f1e52..5bd472cdc 100644 --- a/rtdata/languages/default +++ b/rtdata/languages/default @@ -675,6 +675,71 @@ HISTORY_MSG_440;CbDL - Method HISTORY_MSG_441;Retinex - Gain transmission HISTORY_MSG_442;Retinex - Scale HISTORY_MSG_443;Output Black Point Compensation +HISTORY_MSG_444;Local L*a*b* +HISTORY_MSG_445;Local - Bottom +HISTORY_MSG_446;Local - Right +HISTORY_MSG_447;Local - Center +HISTORY_MSG_448;Local - Lightness/ +HISTORY_MSG_449;Local - Lightness +HISTORY_MSG_450;Local - Contrast +HISTORY_MSG_451;Local - Chrominance +HISTORY_MSG_452;Local - Transition +HISTORY_MSG_453;Local - Avoid color shift +HISTORY_MSG_454;Local - Top +HISTORY_MSG_455;Local - Left +HISTORY_MSG_456;Local - Method +HISTORY_MSG_457;Local - Color Inverse +HISTORY_MSG_458;Local - Radius +HISTORY_MSG_459;Local - Blur Inverse +HISTORY_MSG_460;Local - Noise +HISTORY_MSG_461;Local - Scope +HISTORY_MSG_462;Local - Retinex method +HISTORY_MSG_463;Local - Retinex strength +HISTORY_MSG_464;Local - Retinex radius +HISTORY_MSG_465;Local - Retinex contrast +HISTORY_MSG_466;Local - Retinex Gain curve +HISTORY_MSG_467;Local - Retinex chroma +HISTORY_MSG_468;Local - Retinex Inverse +HISTORY_MSG_469;Local - Hue scope +HISTORY_MSG_470;Local - Spot +HISTORY_MSG_471;Local - Blur Luminance only +HISTORY_MSG_472;Local - Update GUI and Mip -1 +HISTORY_MSG_473;Local - Sh Radius +HISTORY_MSG_474;Local - Sh Amount +HISTORY_MSG_475;Local - Sh Damping +HISTORY_MSG_476;Local - Sh Iterations +HISTORY_MSG_477;Local - Sh Scope +HISTORY_MSG_478;Local - Sh Inverse +HISTORY_MSG_479;Local - Spot size +HISTORY_MSG_480;Local - Hue theshold +HISTORY_MSG_481;Local - Hue proximity +HISTORY_MSG_482;Local - Quality +HISTORY_MSG_483;Local - Noise lum f +HISTORY_MSG_484;Local - Noise lum c +HISTORY_MSG_485;Local - Noise chro f +HISTORY_MSG_486;Local - Noise chro c +HISTORY_MSG_487;Local - cbdl threshold +HISTORY_MSG_488;Local - cbdl mult +HISTORY_MSG_489;Local - cbdl scope +HISTORY_MSG_490;Local - Blur scope +HISTORY_MSG_491;Local - TM strength +HISTORY_MSG_492;Local - TM gamma +HISTORY_MSG_493;Local - TM edge stopping +HISTORY_MSG_494;Local - TM scale +HISTORY_MSG_495;Local - TM Reweighting +HISTORY_MSG_496;Local - TM scope +HISTORY_MSG_497;Local - Update GUI and Mip -2 +HISTORY_MSG_498;Local - Update GUI and Mip -3 +HISTORY_MSG_499;Local - LL Curve +HISTORY_MSG_500;Local - Color and light +HISTORY_MSG_501;Local - Blur and noise +HISTORY_MSG_502;Local - Tone mapping +HISTORY_MSG_503;Local - Retinex +HISTORY_MSG_504;Local - Sharpening +HISTORY_MSG_505;Local - CBDL +HISTORY_MSG_506;Local - Denoise +HISTORY_MSG_507;Local - LH Curve +HISTORY_MSG_508;Local - Enable curve HISTORY_NEWSNAPSHOT;Add HISTORY_NEWSNAPSHOT_TOOLTIP;Shortcut: Alt-s HISTORY_SNAPSHOT;Snapshot @@ -846,6 +911,7 @@ PARTIALPASTE_IPTCINFO;IPTC PARTIALPASTE_LABCURVE;L*a*b* adjustments PARTIALPASTE_LENSGROUP;Lens Related Settings PARTIALPASTE_LENSPROFILE;Lens correction profile +PARTIALPASTE_LOCALLAB;Local L*a*b* PARTIALPASTE_METAGROUP;Metadata PARTIALPASTE_PCVIGNETTE;Vignette filter PARTIALPASTE_PERSPECTIVE;Perspective @@ -1003,6 +1069,11 @@ PREFERENCES_MENUGROUPRANK;Group "Rank" PREFERENCES_MENUOPTIONS;Context Menu Options PREFERENCES_METADATA;Metadata PREFERENCES_MIN;Mini (100x115) +PREFERENCES_MIP;Mip Profiles +PREFERENCES_MIP_LABEL;Mip profiles: +PREFERENCES_MIP_OPT;In Profiles - near Cache +PREFERENCES_MIP_PREV;Next Input file +PREFERENCES_MIP_TOOLTIP;Next input file allow multiple sessions of the same file, but do not allow path with NON ASCII characters.\nIn Profiles - near Cache, allow NON ASCII characters in path, but allow only one session for the same file. PREFERENCES_MONINTENT;Default rendering intent PREFERENCES_MONITOR;Monitor PREFERENCES_MONPROFILE;Default color profile @@ -1603,7 +1674,82 @@ TP_LENSPROFILE_LABEL;Lens Correction Profile TP_LENSPROFILE_USECA;Chromatic aberration correction TP_LENSPROFILE_USEDIST;Distortion correction TP_LENSPROFILE_USEVIGN;Vignetting correction -TP_NEUTRAL;Reset +TP_LOCALLAB_ACTIV;Blur luminance only +TP_LOCALLAB_AVOID;Avoid color shift +TP_LOCALLAB_BLUFR;Blur & Noise +TP_LOCALLAB_CENTER_X;Center X +TP_LOCALLAB_CENTER_Y;Center Y +TP_LOCALLAB_CBDL;Contrast by detail levels +TP_LOCALLAB_CHROMA;Chrominance +TP_LOCALLAB_CHRRT;Chroma +TP_LOCALLAB_CIRCRADIUS;Spot size +TP_LOCALLAB_COFR;Color & Light +TP_LOCALLAB_CONTRAST;Contrast +TP_LOCALLAB_CURV;Enable curves +TP_LOCALLAB_DENOIS;Denoise +TP_LOCALLAB_LUM;Curves +TP_LOCALLAB_CURVEEDITOR_LL_TOOLTIP;To be active, you must check button 'Enable curves' +TP_LOCALLAB_NOISELUMFINE;Luminance fine +TP_LOCALLAB_NOISELUMCOARSE;Luminance coarse +TP_LOCALLAB_NOISECHROFINE;Chroma fine +TP_LOCALLAB_NOISECHROCOARSE;Chroma coarse +TP_LOCALLAB_GAM;Gamma +TP_LOCALLAB_ESTOP;Edge stopping +TP_LOCALLAB_SCALTM;Scale +TP_LOCALLAB_REWEI;Reweighting iterates +TP_LOCALLAB_INDSL;Independent (mouse + sliders) +TP_LOCALLAB_IND;Independent (mouse) +TP_LOCALLAB_INVERS;Inverse +TP_LOCALLAB_LABEL;Local L*a*b* +TP_LOCALLAB_NEUTRAL;Reset +TP_LOCALLAB_NEUTRAL_TIP;Reset Current Control point +TP_LOCALLAB_NBSPOT;Control points +TP_LOCALLAB_NBSPOT_TOOLTIP;Add multiple control points and select +TP_LOCALLAB_STD;Quality Standard +TP_LOCALLAB_ENH;Quality Enhanced +TP_LOCALLAB_ENHDEN;Quality Enhanced + chroma denoise +TP_LOCALLAB_THRES;Hue threshold +TP_LOCALLAB_PROXI;Hue proximity radius +TP_LOCALLAB_ANBSPOT;Help to Move Control point +TP_LOCALLAB_ANBSPOT_TOOLTIP;Provisory control (I hope somebody can help to manage events!! and suppress this bad function) +TP_LOCALLAB_LIGHTNESS;Lightness +TP_LOCALLAB_METHOD_TOOLTIP;Default - standard.\nIf you select Enhanced or enhanced chroma denoise - only for Color Light-Sharpening-Retinex-CBDL in normal mode, algorithm will detect the variations of hue in the select area and improve shape detection.\nHue threshold define since what value is exclude (* 100 radians).\nHue proximity radius define the radius around each point to calculate variations.\nEnhanced and Hue threshold significantly increases processing times. +TP_LOCALLAB_RADIUS;Radius +TP_LOCALLAB_RETI;Retinex +TP_LOCALLAB_TRANSMISSIONGAIN;Transmission gain +TP_LOCRETI_METHOD;Method +TP_LOCALLAB_STREN;Strength +TP_LOCALLAB_TM;Tone Mapping +TP_LOCALLAB_STR;Strength +TP_LOCALLAB_NEIGH;Radius +TP_LOCALLAB_VART;Contrast +TP_LOCALLAB_SENSI;Scope +TP_LOCALLAB_SENSI_TOOLTIP;Adjust scope of action:\nSmall values limit action to colors very similar to those under the center spot.\nHigh values let the tool act upon a wider range of colors.\nValues smaller than 20 lead to a better algorithm. +TP_LOCALLAB_SENSIH;Hue Scope +TP_LOCALLAB_SENSIH_TOOLTIP;Adjust scope of action:\nSmall values limit action to colors very similar to those under the center spot.\nHigh values let the tool act upon a wider range of colors.\nValues smaller than 20 lead to a better algorithm. +TP_LOCALLAB_SHARP;Sharpening +TP_LOCALLAB_SHARRADIUS;Radius +TP_LOCALLAB_SHARAMOUNT;Amount +TP_LOCALLAB_SHARDAMPING;Damping +TP_LOCALLAB_SHARITER;Iterations +TP_LOCALLAB_SENSIS;Scope +TP_LOCALLAB_SENSICB;Scope +TP_LOCALLAB_SENSIBN;Scope +TP_LOCALLAB_SENSIS_TOOLTIP;Adjust scope of action:\nSmall values limit action to colors very similar to those under the center spot.\nHigh values let the tool act upon a wider range of colors.\nValues smaller than 20 lead to a better algorithm. +TP_LOCALLAB_SHFR;Shape +TP_LOCALLAB_STRENGTH;Noise +TP_LOCALLAB_STYPE;Shape method +TP_LOCALLAB_STYPE_TOOLTIP;You can choose between:\nSymmetrical - left handle linked to right, top handle linked to bottom.\nIndependent - all handles are independent. +TP_LOCALLAB_SYMSL;Symmetrical (mouse + sliders) +TP_LOCALLAB_SYM;Symmetrical (mouse) +TP_LOCALLAB_TRANSIT;Transition +TP_LOCALLAB_TRANSIT_TOOLTIP;Adjust smoothness of transition between affected and unaffected areas. +TP_LOCAL_HEIGHT;Bottom +TP_LOCAL_HEIGHT_T;Top +TP_LOCAL_WIDTH;Right +TP_LOCAL_WIDTH_L;Left +TP_LOCRETI_METHOD_TOOLTIP;Low = Reinforce low light.\nUniform = Equalize action.\nHigh = Reinforce high light.\n +TP_NEUTRAL;Neutral TP_NEUTRAL_TIP;Resets exposure sliders to neutral values.\nApplies to the same controls that Auto Levels applies to, regardless of whether you used Auto Levels or not. TP_PCVIGNETTE_FEATHER;Feather TP_PCVIGNETTE_FEATHER_TOOLTIP;Feathering:\n0 = corners only,\n50 = halfway to center,\n100 = to center. diff --git a/rtengine/CMakeLists.txt b/rtengine/CMakeLists.txt index 477ccecae..35e8c7e01 100644 --- a/rtengine/CMakeLists.txt +++ b/rtengine/CMakeLists.txt @@ -12,7 +12,7 @@ set (RTENGINESOURCEFILES colortemp.cc curves.cc flatcurves.cc diagonalcurves.cc loadinitial.cc procparams.cc rawimagesource.cc demosaic_algos.cc shmap.cc simpleprocess.cc refreshmap.cc fast_demo.cc amaze_demosaic_RT.cc CA_correct_RT.cc cfa_linedn_RT.cc green_equil_RT.cc hilite_recon.cc expo_before_b.cc stdimagesource.cc myfile.cc iccjpeg.cc improccoordinator.cc pipettebuffer.cc coord.cc - processingjob.cc rtthumbnail.cc utils.cc labimage.cc slicer.cc cieimage.cc + processingjob.cc rtthumbnail.cc utils.cc labimage.cc slicer.cc cieimage.cc iplocallab.cc iplab2rgb.cc ipsharpen.cc iptransform.cc ipresize.cc ipvibrance.cc imagedimensions.cc jpeg_ijg/jpeg_memsrc.cc jdatasrc.cc iimage.cc EdgePreservingDecomposition.cc cplx_wavelet_dec.cc FTblockDN.cc diff --git a/rtengine/FTblockDN.cc b/rtengine/FTblockDN.cc index 6bb0c4c3c..30a8e92c6 100644 --- a/rtengine/FTblockDN.cc +++ b/rtengine/FTblockDN.cc @@ -1142,7 +1142,7 @@ SSEFUNCTION void ImProcFunctions::RGB_denoise(int kall, Imagefloat * src, Imagef if (!memoryAllocationFailed) { if (nrQuality == QUALITY_STANDARD) { - if (!WaveletDenoiseAllAB(*Ldecomp, *adecomp, noisevarchrom, madL, noisevarab_r, useNoiseCCurve, autoch, denoiseMethodRgb)) { //enhance mode + if (!WaveletDenoiseAllAB(*Ldecomp, *adecomp, noisevarchrom, madL, nullptr, 0, noisevarab_r, useNoiseCCurve, autoch, denoiseMethodRgb)) { //enhance mode memoryAllocationFailed = true; } } else { /*if (nrQuality==QUALITY_HIGH)*/ @@ -1151,7 +1151,7 @@ SSEFUNCTION void ImProcFunctions::RGB_denoise(int kall, Imagefloat * src, Imagef } if (!memoryAllocationFailed) { - if (!WaveletDenoiseAllAB(*Ldecomp, *adecomp, noisevarchrom, madL, noisevarab_r, useNoiseCCurve, autoch, denoiseMethodRgb)) { + if (!WaveletDenoiseAllAB(*Ldecomp, *adecomp, noisevarchrom, madL, nullptr, 0, noisevarab_r, useNoiseCCurve, autoch, denoiseMethodRgb)) { memoryAllocationFailed = true; } } @@ -1179,7 +1179,7 @@ SSEFUNCTION void ImProcFunctions::RGB_denoise(int kall, Imagefloat * src, Imagef if (!memoryAllocationFailed) { if (nrQuality == QUALITY_STANDARD) { - if (!WaveletDenoiseAllAB(*Ldecomp, *bdecomp, noisevarchrom, madL, noisevarab_b, useNoiseCCurve, autoch, denoiseMethodRgb)) { //enhance mode + if (!WaveletDenoiseAllAB(*Ldecomp, *bdecomp, noisevarchrom, madL, nullptr, 0, noisevarab_b, useNoiseCCurve, autoch, denoiseMethodRgb)) { //enhance mode memoryAllocationFailed = true; } } else { /*if (nrQuality==QUALITY_HIGH)*/ @@ -1188,7 +1188,7 @@ SSEFUNCTION void ImProcFunctions::RGB_denoise(int kall, Imagefloat * src, Imagef } if (!memoryAllocationFailed) { - if (!WaveletDenoiseAllAB(*Ldecomp, *bdecomp, noisevarchrom, madL, noisevarab_b, useNoiseCCurve, autoch, denoiseMethodRgb)) { + if (!WaveletDenoiseAllAB(*Ldecomp, *bdecomp, noisevarchrom, madL, nullptr, 0, noisevarab_b, useNoiseCCurve, autoch, denoiseMethodRgb)) { memoryAllocationFailed = true; } } @@ -2408,7 +2408,7 @@ SSEFUNCTION bool ImProcFunctions::WaveletDenoiseAll_BiShrinkAB(wavelet_decomposi float ** WavCoeffs_ab = WaveletCoeffs_ab.level_coeffs(lvl); if (lvl == maxlvl - 1) { - ShrinkAllAB(WaveletCoeffs_L, WaveletCoeffs_ab, buffer, lvl, dir, noisevarchrom, noisevar_ab, useNoiseCCurve, autoch, denoiseMethodRgb, madL[lvl], madab[lvl], true); + ShrinkAllAB(WaveletCoeffs_L, WaveletCoeffs_ab, buffer, lvl, dir, noisevarchrom, noisevar_ab, useNoiseCCurve, autoch, denoiseMethodRgb, madL[lvl], nullptr, 0, madab[lvl], true); } else { //simple wavelet shrinkage @@ -2482,8 +2482,12 @@ bool ImProcFunctions::WaveletDenoiseAllL(wavelet_decomposition &WaveletCoeffs_L, int maxlvl = min(WaveletCoeffs_L.maxlevel(), 5); - if (edge == 1) { - maxlvl = 4; //for refine denoise edge wavelet + if (edge == 1 || edge == 3) { + maxlvl = 4; //for refine denoise edge wavelet + } + + if (edge == 2) { + maxlvl = 7; //for locallab denoise } int maxWL = 0, maxHL = 0; @@ -2536,11 +2540,20 @@ bool ImProcFunctions::WaveletDenoiseAllL(wavelet_decomposition &WaveletCoeffs_L, bool ImProcFunctions::WaveletDenoiseAllAB(wavelet_decomposition &WaveletCoeffs_L, wavelet_decomposition &WaveletCoeffs_ab, - float *noisevarchrom, float madL[8][3], float noisevar_ab, const bool useNoiseCCurve, bool autoch, bool denoiseMethodRgb)//mod JD + float *noisevarchrom, float madL[8][3], float *variC, int local, float noisevar_ab, const bool useNoiseCCurve, bool autoch, bool denoiseMethodRgb)//mod JD { int maxlvl = WaveletCoeffs_L.maxlevel(); + + if (local == 2) { + maxlvl = 7; //for local denoise + } + + if (local == 3) { + maxlvl = 4; //for shape detection + } + int maxWL = 0, maxHL = 0; for (int lvl = 0; lvl < maxlvl; ++lvl) { @@ -2574,7 +2587,7 @@ bool ImProcFunctions::WaveletDenoiseAllAB(wavelet_decomposition &WaveletCoeffs_L for (int lvl = 0; lvl < maxlvl; ++lvl) { for (int dir = 1; dir < 4; ++dir) { - ShrinkAllAB(WaveletCoeffs_L, WaveletCoeffs_ab, buffer, lvl, dir, noisevarchrom, noisevar_ab, useNoiseCCurve, autoch, denoiseMethodRgb, madL[lvl]); + ShrinkAllAB(WaveletCoeffs_L, WaveletCoeffs_ab, buffer, lvl, dir, noisevarchrom, noisevar_ab, useNoiseCCurve, autoch, denoiseMethodRgb, madL[lvl], nullptr, 0); } } } @@ -2610,7 +2623,7 @@ SSEFUNCTION void ImProcFunctions::ShrinkAllL(wavelet_decomposition &WaveletCoeff // printf("OK lev=%d\n",level); float mad_L = madL[dir - 1] ; - if (edge == 1 && vari) { + if ((edge == 1 || edge == 2 || edge == 3) && vari) { noisevarlum = blurBuffer; // we need one buffer, but fortunately we don't have to allocate a new one because we can use blurBuffer for (int i = 0; i < W_L * H_L; ++i) { @@ -2684,7 +2697,7 @@ SSEFUNCTION void ImProcFunctions::ShrinkAllL(wavelet_decomposition &WaveletCoeff SSEFUNCTION void ImProcFunctions::ShrinkAllAB(wavelet_decomposition &WaveletCoeffs_L, wavelet_decomposition &WaveletCoeffs_ab, float **buffer, int level, int dir, float *noisevarchrom, float noisevar_ab, const bool useNoiseCCurve, bool autoch, - bool denoiseMethodRgb, float * madL, float * madaab, bool madCalculated) + bool denoiseMethodRgb, float * madL, float * variC, int local, float * madaab, bool madCalculated) { //simple wavelet shrinkage @@ -2717,8 +2730,17 @@ SSEFUNCTION void ImProcFunctions::ShrinkAllAB(wavelet_decomposition &WaveletCoef } } - if (noisevar_ab > 0.001f) { - madab = useNoiseCCurve ? madab : madab * noisevar_ab; + float noisevarfc; + + if ((local == 2 || local == 3) && variC) { + noisevarfc = variC[level]; + } else { + noisevarfc = noisevar_ab; + } + + if (noisevarfc > 0.001f) {//noisevar_ab + // madab = useNoiseCCurve ? madab : madab * noisevar_ab; + madab = useNoiseCCurve ? madab : madab * noisevarfc; #ifdef __SSE2__ __m128 onev = _mm_set1_ps(1.f); __m128 mad_abrv = _mm_set1_ps(madab); @@ -3041,7 +3063,7 @@ void ImProcFunctions::calcautodn_info (float &chaut, float &delta, int Nb, int l delta *= 0.15f; } else if (chaut < 650.f) { delta *= 0.1f; - } else /*if (chaut >= 650.f)*/ { + } else { /*if (chaut >= 650.f)*/ delta *= 0.07f; } @@ -3079,7 +3101,7 @@ void ImProcFunctions::calcautodn_info (float &chaut, float &delta, int Nb, int l delta *= 0.3f; } else if (chaut < 650.f) { delta *= 0.2f; - } else /*if (chaut >= 650.f)*/ { + } else { /*if (chaut >= 650.f)*/ delta *= 0.15f; } diff --git a/rtengine/color.h b/rtengine/color.h index 77db1f4f7..363c8f81f 100644 --- a/rtengine/color.h +++ b/rtengine/color.h @@ -1352,6 +1352,56 @@ public: static void skinredfloat ( float J, float h, float sres, float Sp, float dred, float protect_red, int sk, float rstprotection, float ko, float &s); // static void scaleredcdbl ( float skinprot, float param, float limit, float HH, float deltaHH, float &scale,float &scaleext); + static inline void pregamutlab (float lum, float hue, float &chr)//big approximation to limit gamut (Prophoto) before good gamut procedure for locallab chroma, to avoid crash + { + if (lum >= 95.0f) { + if(hue > 1.5f && hue < 2.f ) { + chr = 120.f; + } else if(hue > 0.7f && hue <= 1.5f) { + chr = 60.f; + } else { + chr = 40.f; + } + } else if(lum > 75.f) { + if(hue > 1.f && hue < 3.14f ) { + chr = 130.f; + } else if(hue > -0.4f && hue <= 1.f) { + chr = 80.f; + } else if(hue > -3.15f && hue > -2.f) { + chr = 80.f; + } else { + chr = 60.f; + } + + } else if(lum > 35.f) { + chr = 100.f; + } else if(lum > 20.f) { + if(hue < -1.f && hue > -2.f ) { + chr = 120.f; + } else { + chr = 80.f; + } + } else if(lum > 7.f) { + if(hue < -1.f && hue > -1.8f ) { + chr = 120.f; + } else { + chr = 60.f; + } + + } else { + if(hue < -1.f && hue > -1.6f ) { + chr = 80.f; + } else { + chr = 40.f; + } + + } + + // if(lum < 4.f) { + // chr = 0.1f; + // } + } + static inline void SkinSatCbdl (float lum, float hue, float chrom, float skinprot, float &scale, bool neg, float b_l, float t_l, float t_r) { diff --git a/rtengine/curves.cc b/rtengine/curves.cc index cf2fd0d04..0d6896940 100644 --- a/rtengine/curves.cc +++ b/rtengine/curves.cc @@ -45,13 +45,13 @@ using namespace std; namespace rtengine { -Curve::Curve () : N(0), ppn(0), x(nullptr), y(nullptr), mc(0.0), mfc(0.0), msc(0.0), mhc(0.0), ypp(nullptr), x1(0.0), y1(0.0), x2(0.0), y2(0.0), x3(0.0), y3(0.0), firstPointIncluded(false), increment(0.0), nbr_points(0), hashSize(1000 /* has to be initialized to the maximum value */) {} +Curve::Curve () : N (0), ppn (0), x (nullptr), y (nullptr), mc (0.0), mfc (0.0), msc (0.0), mhc (0.0), ypp (nullptr), x1 (0.0), y1 (0.0), x2 (0.0), y2 (0.0), x3 (0.0), y3 (0.0), firstPointIncluded (false), increment (0.0), nbr_points (0), hashSize (1000 /* has to be initialized to the maximum value */) {} void Curve::AddPolygons () { if (firstPointIncluded) { - poly_x.push_back(x1); - poly_y.push_back(y1); + poly_x.push_back (x1); + poly_y.push_back (y1); } for (int k = 1; k < (nbr_points - 1); k++) { @@ -62,20 +62,20 @@ void Curve::AddPolygons () double tr2t = tr * 2 * t; // adding a point to the polyline - poly_x.push_back( tr2 * x1 + tr2t * x2 + t2 * x3); - poly_y.push_back( tr2 * y1 + tr2t * y2 + t2 * y3); + poly_x.push_back ( tr2 * x1 + tr2t * x2 + t2 * x3); + poly_y.push_back ( tr2 * y1 + tr2t * y2 + t2 * y3); } // adding the last point of the sub-curve - poly_x.push_back(x3); - poly_y.push_back(y3); + poly_x.push_back (x3); + poly_y.push_back (y3); } void Curve::fillDyByDx () { - dyByDx.resize(poly_x.size() - 1); + dyByDx.resize (poly_x.size() - 1); - for(unsigned int i = 0; i < poly_x.size() - 1; i++) { + for (unsigned int i = 0; i < poly_x.size() - 1; i++) { double dx = poly_x[i + 1] - poly_x[i]; double dy = poly_y[i + 1] - poly_y[i]; dyByDx[i] = dy / dx; @@ -85,18 +85,18 @@ void Curve::fillDyByDx () void Curve::fillHash() { - hash.resize(hashSize + 2); + hash.resize (hashSize + 2); unsigned int polyIter = 0; double const increment = 1. / hashSize; double milestone = 0.; for (unsigned short i = 0; i < (hashSize + 1);) { - while(poly_x[polyIter] <= milestone) { + while (poly_x[polyIter] <= milestone) { ++polyIter; } - hash.at(i).smallerValue = polyIter - 1; + hash.at (i).smallerValue = polyIter - 1; ++i; milestone = i * increment; } @@ -105,17 +105,17 @@ void Curve::fillHash() polyIter = 0; for (unsigned int i = 0; i < (hashSize + 1);) { - while(poly_x[polyIter] < (milestone + increment)) { + while (poly_x[polyIter] < (milestone + increment)) { ++polyIter; } - hash.at(i).higherValue = polyIter; + hash.at (i).higherValue = polyIter; ++i; milestone = i * increment; } - hash.at(hashSize + 1).smallerValue = poly_x.size() - 1; - hash.at(hashSize + 1).higherValue = poly_x.size(); + hash.at (hashSize + 1).smallerValue = poly_x.size() - 1; + hash.at (hashSize + 1).higherValue = poly_x.size(); /* * Uncoment the code below to dump the polygon points and the hash table in files @@ -153,7 +153,7 @@ int Curve::getSize () const * @param x Y value of the control points, or -1 if invalid * @param y Y value of the control points, or -1 if invalid */ -void Curve::getControlPoint(int cpNum, double &x, double &y) const +void Curve::getControlPoint (int cpNum, double &x, double &y) const { if (this->x && cpNum < N) { x = this->x[cpNum]; @@ -169,7 +169,7 @@ void Curve::getControlPoint(int cpNum, double &x, double &y) const const double CurveFactory::sRGBGamma = 2.2; const double CurveFactory::sRGBGammaCurve = 2.4; -void fillCurveArray(DiagonalCurve* diagCurve, LUTf &outCurve, int skip, bool needed) +void fillCurveArray (DiagonalCurve* diagCurve, LUTf &outCurve, int skip, bool needed) { if (needed) { @@ -187,7 +187,7 @@ void fillCurveArray(DiagonalCurve* diagCurve, LUTf &outCurve, int skip, bool nee float skipmul = 1.f / (float) skip; for (int i = 0; i <= 0x10000 - skip; i += skip) { - for(int j = 1; j < skip; j++) { + for (int j = 1; j < skip; j++) { outCurve[i + j] = ( outCurve[i] * (skip - j) + outCurve[i + skip] * j ) * skipmul; } } @@ -211,14 +211,14 @@ void CurveFactory::curveLightBrightColor (const std::vector& curvePoints customColCurve3.Reset(); if (!curvePoints3.empty() && curvePoints3[0] > DCT_Linear && curvePoints3[0] < DCT_Unchanged) { - DiagonalCurve tcurve(curvePoints3, CURVES_MIN_POLY_POINTS / skip); + DiagonalCurve tcurve (curvePoints3, CURVES_MIN_POLY_POINTS / skip); if (outBeforeCCurveHistogramC) { - histogramC.compressTo(outBeforeCCurveHistogramC, 48000); + histogramC.compressTo (outBeforeCCurveHistogramC, 48000); } if (!tcurve.isIdentity()) { - customColCurve3.Set(tcurve); + customColCurve3.Set (tcurve); } } @@ -226,14 +226,14 @@ void CurveFactory::curveLightBrightColor (const std::vector& curvePoints customColCurve2.Reset(); if (!curvePoints2.empty() && curvePoints2[0] > DCT_Linear && curvePoints2[0] < DCT_Unchanged) { - DiagonalCurve tcurve(curvePoints2, CURVES_MIN_POLY_POINTS / skip); + DiagonalCurve tcurve (curvePoints2, CURVES_MIN_POLY_POINTS / skip); if (outBeforeCCurveHistogram) { histNeeded = true; } if (!tcurve.isIdentity()) { - customColCurve2.Set(tcurve); + customColCurve2.Set (tcurve); } } @@ -242,19 +242,19 @@ void CurveFactory::curveLightBrightColor (const std::vector& curvePoints customColCurve1.Reset(); if (!curvePoints1.empty() && curvePoints1[0] > DCT_Linear && curvePoints1[0] < DCT_Unchanged) { - DiagonalCurve tcurve(curvePoints1, CURVES_MIN_POLY_POINTS / skip); + DiagonalCurve tcurve (curvePoints1, CURVES_MIN_POLY_POINTS / skip); if (outBeforeCCurveHistogram) { histNeeded = true; } if (!tcurve.isIdentity()) { - customColCurve1.Set(tcurve); + customColCurve1.Set (tcurve); } } if (histNeeded) { - histogram.compressTo(outBeforeCCurveHistogram, 32768); + histogram.compressTo (outBeforeCCurveHistogram, 32768); } } @@ -271,14 +271,14 @@ void CurveFactory::curveBW ( const std::vector& curvePointsbw, const std customToneCurvebw2.Reset(); if (!curvePointsbw2.empty() && curvePointsbw2[0] > DCT_Linear && curvePointsbw2[0] < DCT_Unchanged) { - DiagonalCurve tcurve(curvePointsbw2, CURVES_MIN_POLY_POINTS / skip); + DiagonalCurve tcurve (curvePointsbw2, CURVES_MIN_POLY_POINTS / skip); if (outBeforeCCurveHistogrambw) { histNeeded = true; } if (!tcurve.isIdentity()) { - customToneCurvebw2.Set(tcurve, gamma_); + customToneCurvebw2.Set (tcurve, gamma_); } } @@ -286,21 +286,21 @@ void CurveFactory::curveBW ( const std::vector& curvePointsbw, const std customToneCurvebw1.Reset(); if (!curvePointsbw.empty() && curvePointsbw[0] > DCT_Linear && curvePointsbw[0] < DCT_Unchanged) { - DiagonalCurve tcurve(curvePointsbw, CURVES_MIN_POLY_POINTS / skip); + DiagonalCurve tcurve (curvePointsbw, CURVES_MIN_POLY_POINTS / skip); if (outBeforeCCurveHistogrambw ) { histNeeded = true; } if (!tcurve.isIdentity()) { - customToneCurvebw1.Set(tcurve, gamma_); + customToneCurvebw1.Set (tcurve, gamma_); } } // create first curve if needed if (histNeeded) { - histogrambw.compressTo(outBeforeCCurveHistogrambw, 32768); + histogrambw.compressTo (outBeforeCCurveHistogrambw, 32768); } } @@ -311,14 +311,14 @@ void CurveFactory::curveCL ( bool & clcutili, const std::vector& clcurve std::unique_ptr dCurve; if (!clcurvePoints.empty() && clcurvePoints[0] != 0) { - dCurve = std::unique_ptr(new DiagonalCurve(clcurvePoints, CURVES_MIN_POLY_POINTS / skip)); + dCurve = std::unique_ptr (new DiagonalCurve (clcurvePoints, CURVES_MIN_POLY_POINTS / skip)); if (dCurve && !dCurve->isIdentity()) { clcutili = true; } } - fillCurveArray(dCurve.get(), clCurve, skip, clcutili); + fillCurveArray (dCurve.get(), clCurve, skip, clcutili); } void CurveFactory::mapcurve ( bool & mapcontlutili, const std::vector& mapcurvePoints, LUTf & mapcurve, int skip, const LUTu & histogram, LUTu & outBeforeCurveHistogram) @@ -329,7 +329,7 @@ void CurveFactory::mapcurve ( bool & mapcontlutili, const std::vector& m bool histNeeded = false; if (!mapcurvePoints.empty() && mapcurvePoints[0] != 0) { - dCurve = std::unique_ptr(new DiagonalCurve(mapcurvePoints, CURVES_MIN_POLY_POINTS / skip)); + dCurve = std::unique_ptr (new DiagonalCurve (mapcurvePoints, CURVES_MIN_POLY_POINTS / skip)); if (outBeforeCurveHistogram) { histNeeded = true; @@ -342,10 +342,10 @@ void CurveFactory::mapcurve ( bool & mapcontlutili, const std::vector& m } if (histNeeded) { - histogram.compressTo(outBeforeCurveHistogram, 32768); + histogram.compressTo (outBeforeCurveHistogram, 32768); } - fillCurveArray(dCurve.get(), mapcurve, skip, needed); + fillCurveArray (dCurve.get(), mapcurve, skip, needed); } void CurveFactory::curveDehaContL ( bool & dehacontlutili, const std::vector& dehaclcurvePoints, LUTf & dehaclCurve, int skip, const LUTu & histogram, LUTu & outBeforeCurveHistogram) @@ -356,7 +356,7 @@ void CurveFactory::curveDehaContL ( bool & dehacontlutili, const std::vector(new DiagonalCurve(dehaclcurvePoints, CURVES_MIN_POLY_POINTS / skip)); + dCurve = std::unique_ptr (new DiagonalCurve (dehaclcurvePoints, CURVES_MIN_POLY_POINTS / skip)); if (outBeforeCurveHistogram) { histNeeded = true; @@ -369,10 +369,10 @@ void CurveFactory::curveDehaContL ( bool & dehacontlutili, const std::vector dCurve; if (!wavclcurvePoints.empty() && wavclcurvePoints[0] != 0) { - dCurve = std::unique_ptr(new DiagonalCurve(wavclcurvePoints, CURVES_MIN_POLY_POINTS / skip)); + dCurve = std::unique_ptr (new DiagonalCurve (wavclcurvePoints, CURVES_MIN_POLY_POINTS / skip)); if (dCurve && !dCurve->isIdentity()) { needed = true; @@ -390,7 +390,7 @@ void CurveFactory::curveWavContL ( bool & wavcontlutili, const std::vector& curvePoints, LUTf & std::unique_ptr dCurve; if (!curvePoints.empty() && curvePoints[0] != 0) { - dCurve = std::unique_ptr(new DiagonalCurve(curvePoints, CURVES_MIN_POLY_POINTS / skip)); + dCurve = std::unique_ptr (new DiagonalCurve (curvePoints, CURVES_MIN_POLY_POINTS / skip)); if (dCurve && !dCurve->isIdentity()) { needed = true; } } - fillCurveArray(dCurve.get(), ToningCurve, skip, needed); + fillCurveArray (dCurve.get(), ToningCurve, skip, needed); } +void CurveFactory::curveLocal (bool & locallutili, const std::vector& curvePoints, LUTf & LocalLCurve, int skip) +{ + bool needed = false; + std::unique_ptr dCurve; + + if (!curvePoints.empty() && curvePoints[0] != 0) { + dCurve = std::unique_ptr (new DiagonalCurve (curvePoints, CURVES_MIN_POLY_POINTS / skip)); + + if (dCurve && !dCurve->isIdentity()) { + needed = true; + locallutili = true; + } + } + + fillCurveArray (dCurve.get(), LocalLCurve, skip, needed); + //LocalLCurve.dump("wav"); + +} + + + +void CurveFactory::localLCurve (double br, double contr, /*const std::vector& curvePoints,*/ + LUTu & histogram, LUTf & outCurve, + int skip, bool & utili) +{ + + // curve without contrast + LUTf dcurve (65536, 0); + + // clear array that stores histogram valid before applying the custom curve + + //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + // tone curve base. a: slope (from exp.comp.), b: black, def_mul: max. x value (can be>1), hr,sr: highlight,shadow recovery + //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + // check if brightness curve is needed + if (br > 0.00001 || br < -0.00001) { + utili = true; + + std::vector brightcurvePoints; + brightcurvePoints.resize (9); + brightcurvePoints.at (0) = double (DCT_NURBS); + + brightcurvePoints.at (1) = 0.; // black point. Value in [0 ; 1] range + brightcurvePoints.at (2) = 0.; // black point. Value in [0 ; 1] range + + if (br > 0) { + brightcurvePoints.at (3) = 0.1; // toe point + brightcurvePoints.at (4) = 0.1 + br / 150.0; //value at toe point + + brightcurvePoints.at (5) = 0.7; // shoulder point + brightcurvePoints.at (6) = min (1.0, 0.7 + br / 300.0); //value at shoulder point + } else { + brightcurvePoints.at (3) = 0.1 - br / 150.0; // toe point + brightcurvePoints.at (4) = 0.1; // value at toe point + + brightcurvePoints.at (5) = min (1.0, 0.7 - br / 300.0); // shoulder point + brightcurvePoints.at (6) = 0.7; // value at shoulder point + } + + brightcurvePoints.at (7) = 1.; // white point + brightcurvePoints.at (8) = 1.; // value at white point + + DiagonalCurve* brightcurve = new DiagonalCurve (brightcurvePoints, CURVES_MIN_POLY_POINTS / skip); + //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + // Applying brightness curve + for (int i = 0; i < 32768; i++) { // L values range up to 32767, higher values are for highlight overflow + + // change to [0,1] range + float val = (float)i / 32767.0; + + // apply brightness curve + val = brightcurve->getVal (val); + + // store result in a temporary array + dcurve[i] = CLIPD (val); + } + + delete brightcurve; + } else { + for (int i = 0; i < 32768; i++) { // L values range up to 32767, higher values are for highlight overflow + // set the identity curve in the temporary array + dcurve[i] = (float)i / 32767.0; + } + } + + //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + // check if contrast curve is needed + if (contr > 0.00001 || contr < -0.00001) { + utili = true; + + DiagonalCurve* contrastcurve = NULL; + + // compute mean luminance of the image with the curve applied + int sum = 0; + float avg = 0; + + //float sqavg = 0; + for (int i = 0; i < 32768; i++) { + avg += dcurve[i] * histogram[i]; + //sqavg += dcurve[i]*dcurve[i] * histogram[i]; + sum += histogram[i]; + } + + if (sum) { + avg /= sum; + //sqavg /= sum; + //float stddev = sqrt(sqavg-avg*avg); + // printf("avg=%f\n",avg); + + //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + std::vector contrastcurvePoints; + contrastcurvePoints.resize (9); + contrastcurvePoints.at (0) = double (DCT_NURBS); + + contrastcurvePoints.at (1) = 0.; // black point. Value in [0 ; 1] range + contrastcurvePoints.at (2) = 0.; // black point. Value in [0 ; 1] range + + contrastcurvePoints.at (3) = avg - avg * (0.6 - contr / 250.0); // toe point + contrastcurvePoints.at (4) = avg - avg * (0.6 + contr / 250.0); // value at toe point + + contrastcurvePoints.at (5) = avg + (1 - avg) * (0.6 - contr / 250.0); // shoulder point + contrastcurvePoints.at (6) = avg + (1 - avg) * (0.6 + contr / 250.0); // value at shoulder point + + contrastcurvePoints.at (7) = 1.; // white point + contrastcurvePoints.at (8) = 1.; // value at white point + + contrastcurve = new DiagonalCurve (contrastcurvePoints, CURVES_MIN_POLY_POINTS / skip); + //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + } else { + //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + // sum has an invalid value (next to 0, producing a division by zero, so we create a fake contrast curve, producing a white image + std::vector contrastcurvePoints; + contrastcurvePoints.resize (5); + contrastcurvePoints.at (0) = double (DCT_NURBS); + + contrastcurvePoints.at (1) = 0.; // black point. Value in [0 ; 1] range + contrastcurvePoints.at (2) = 1.; // black point. Value in [0 ; 1] range + + contrastcurvePoints.at (3) = 1.; // white point + contrastcurvePoints.at (4) = 1.; // value at white point + + contrastcurve = new DiagonalCurve (contrastcurvePoints, CURVES_MIN_POLY_POINTS / skip); + //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + } + + // apply contrast enhancement + for (int i = 0; i < 32768; i++) { + dcurve[i] = contrastcurve->getVal (dcurve[i]); + } + + delete contrastcurve; + } + + //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + // create a curve if needed + /* DiagonalCurve* tcurve = NULL; + bool histNeeded = false; + if (!curvePoints.empty() && curvePoints[0]!=0) { + tcurve = new DiagonalCurve (curvePoints, CURVES_MIN_POLY_POINTS/skip); + } + if (tcurve && tcurve->isIdentity()) { + delete tcurve; + tcurve = NULL; + } + + if (tcurve) { + utili=true;//if active + + // L values go up to 32767, last stop is for highlight overflow + for (int i=0; i<32768; i++) { + float val; + // apply custom/parametric/NURBS curve, if any + val = tcurve->getVal (dcurve[i]); + + outCurve[i] = (32767.0 * val); + } + } + else + */ + { + // Skip the slow getval method if no curve is used (or an identity curve) + // L values go up to 32767, last stop is for highlight overflow + for (int i = 0; i < 32768; i++) { + outCurve[i] = 32767.0 * dcurve[i]; + } + } + + for (int i = 32768; i < 65536; i++) { + outCurve[i] = (float)i; + } + + // if (tcurve) + // delete tcurve; + +} + + + + + //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% void CurveFactory::complexsgnCurve (bool & autili, bool & butili, bool & ccutili, bool & cclutili, @@ -423,56 +629,56 @@ void CurveFactory::complexsgnCurve (bool & autili, bool & butili, bool & ccutil // create a curve if needed if (!acurvePoints.empty() && acurvePoints[0] != 0) { - dCurve = std::unique_ptr(new DiagonalCurve(acurvePoints, CURVES_MIN_POLY_POINTS / skip)); + dCurve = std::unique_ptr (new DiagonalCurve (acurvePoints, CURVES_MIN_POLY_POINTS / skip)); if (dCurve && !dCurve->isIdentity()) { autili = true; } } - fillCurveArray(dCurve.get(), aoutCurve, skip, autili); + fillCurveArray (dCurve.get(), aoutCurve, skip, autili); dCurve = nullptr; //----------------------------------------------------- if (!bcurvePoints.empty() && bcurvePoints[0] != 0) { - dCurve = std::unique_ptr(new DiagonalCurve(bcurvePoints, CURVES_MIN_POLY_POINTS / skip)); + dCurve = std::unique_ptr (new DiagonalCurve (bcurvePoints, CURVES_MIN_POLY_POINTS / skip)); if (dCurve && !dCurve->isIdentity()) { butili = true; } } - fillCurveArray(dCurve.get(), boutCurve, skip, butili); + fillCurveArray (dCurve.get(), boutCurve, skip, butili); dCurve = nullptr; //----------------------------------------------- if (!cccurvePoints.empty() && cccurvePoints[0] != 0) { - dCurve = std::unique_ptr(new DiagonalCurve(cccurvePoints, CURVES_MIN_POLY_POINTS / skip)); + dCurve = std::unique_ptr (new DiagonalCurve (cccurvePoints, CURVES_MIN_POLY_POINTS / skip)); if (dCurve && !dCurve->isIdentity()) { ccutili = true; } } - fillCurveArray(dCurve.get(), satCurve, skip, ccutili); + fillCurveArray (dCurve.get(), satCurve, skip, ccutili); dCurve = nullptr; //---------------------------- if (!lccurvePoints.empty() && lccurvePoints[0] != 0) { - dCurve = std::unique_ptr(new DiagonalCurve(lccurvePoints, CURVES_MIN_POLY_POINTS / skip)); + dCurve = std::unique_ptr (new DiagonalCurve (lccurvePoints, CURVES_MIN_POLY_POINTS / skip)); if (dCurve && !dCurve->isIdentity()) { cclutili = true; } } - fillCurveArray(dCurve.get(), lhskCurve, skip, cclutili); + fillCurveArray (dCurve.get(), lhskCurve, skip, cclutili); } @@ -495,7 +701,7 @@ SSEFUNCTION void CurveFactory::complexCurve (double ecomp, double black, double // the curve shapes are defined in sRGB gamma, but the output curves will operate on linear floating point data, // hence we do both forward and inverse gamma conversions here. const float gamma_ = Color::sRGBGammaCurve; - const float start = expf(gamma_ * logf( -0.055 / ((1.0 / gamma_ - 1.0) * 1.055 ))); + const float start = expf (gamma_ * logf ( -0.055 / ((1.0 / gamma_ - 1.0) * 1.055 ))); const float slope = 1.055 * powf (start, 1.0 / gamma_ - 1) - 0.055 / start; const float mul = 1.055; const float add = 0.055; @@ -515,20 +721,20 @@ SSEFUNCTION void CurveFactory::complexCurve (double ecomp, double black, double // check if brightness curve is needed if (br > 0.00001 || br < -0.00001) { - std::vector brightcurvePoints(9); + std::vector brightcurvePoints (9); brightcurvePoints[0] = DCT_NURBS; brightcurvePoints[1] = 0.; //black point. Value in [0 ; 1] range brightcurvePoints[2] = 0.; //black point. Value in [0 ; 1] range - if(br > 0) { + if (br > 0) { brightcurvePoints[3] = 0.1; //toe point brightcurvePoints[4] = 0.1 + br / 150.0; //value at toe point brightcurvePoints[5] = 0.7; //shoulder point - brightcurvePoints[6] = min(1.0, 0.7 + br / 300.0); //value at shoulder point + brightcurvePoints[6] = min (1.0, 0.7 + br / 300.0); //value at shoulder point } else { - brightcurvePoints[3] = max(0.0, 0.1 - br / 150.0); //toe point + brightcurvePoints[3] = max (0.0, 0.1 - br / 150.0); //toe point brightcurvePoints[4] = 0.1; //value at toe point brightcurvePoints[5] = 0.7 - br / 300.0; //shoulder point @@ -538,47 +744,47 @@ SSEFUNCTION void CurveFactory::complexCurve (double ecomp, double black, double brightcurvePoints[7] = 1.; // white point brightcurvePoints[8] = 1.; // value at white point - brightcurve = std::unique_ptr(new DiagonalCurve(brightcurvePoints, CURVES_MIN_POLY_POINTS / skip)); + brightcurve = std::unique_ptr (new DiagonalCurve (brightcurvePoints, CURVES_MIN_POLY_POINTS / skip)); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - hlCurve.setClip(LUT_CLIP_BELOW); // used LUT_CLIP_BELOW, because we want to have a baseline of 2^expcomp in this curve. If we don't clip the lut we get wrong values, see Issue 2621 #14 for details + hlCurve.setClip (LUT_CLIP_BELOW); // used LUT_CLIP_BELOW, because we want to have a baseline of 2^expcomp in this curve. If we don't clip the lut we get wrong values, see Issue 2621 #14 for details float exp_scale = a; float scale = 65536.0; - float comp = (max(0.0, ecomp) + 1.0) * hlcompr / 100.0; - float shoulder = ((scale / max(1.0f, exp_scale)) * (hlcomprthresh / 200.0)) + 0.1; + float comp = (max (0.0, ecomp) + 1.0) * hlcompr / 100.0; + float shoulder = ((scale / max (1.0f, exp_scale)) * (hlcomprthresh / 200.0)) + 0.1; if (comp <= 0.0f) { - hlCurve.makeConstant(exp_scale); + hlCurve.makeConstant (exp_scale); } else { - hlCurve.makeConstant(exp_scale, shoulder + 1); + hlCurve.makeConstant (exp_scale, shoulder + 1); float scalemshoulder = scale - shoulder; #ifdef __SSE2__ int i = shoulder + 1; - if(i & 1) { // original formula, slower than optimized formulas below but only used once or none, so I let it as is for reference + if (i & 1) { // original formula, slower than optimized formulas below but only used once or none, so I let it as is for reference // change to [0,1] range float val = (float)i - shoulder; float R = val * comp / (scalemshoulder); - hlCurve[i] = xlog(1.0 + R * exp_scale) / R; // don't use xlogf or 1.f here. Leads to errors caused by too low precision + hlCurve[i] = xlog (1.0 + R * exp_scale) / R; // don't use xlogf or 1.f here. Leads to errors caused by too low precision i++; } - vdouble onev = _mm_set1_pd(1.0); - vdouble Rv = _mm_set_pd((i + 1 - shoulder) * (double)comp / scalemshoulder, (i - shoulder) * (double)comp / scalemshoulder); - vdouble incrementv = _mm_set1_pd(2.0 * comp / scalemshoulder); - vdouble exp_scalev = _mm_set1_pd(exp_scale); + vdouble onev = _mm_set1_pd (1.0); + vdouble Rv = _mm_set_pd ((i + 1 - shoulder) * (double)comp / scalemshoulder, (i - shoulder) * (double)comp / scalemshoulder); + vdouble incrementv = _mm_set1_pd (2.0 * comp / scalemshoulder); + vdouble exp_scalev = _mm_set1_pd (exp_scale); for (; i < 0x10000; i += 2) { // change to [0,1] range - vdouble resultv = xlog(onev + Rv * exp_scalev) / Rv; - vfloat resultfv = _mm_cvtpd_ps(resultv); - _mm_store_ss(&hlCurve[i], resultfv); - resultfv = PERMUTEPS(resultfv, _MM_SHUFFLE(1, 1, 1, 1)); - _mm_store_ss(&hlCurve[i + 1], resultfv); + vdouble resultv = xlog (onev + Rv * exp_scalev) / Rv; + vfloat resultfv = _mm_cvtpd_ps (resultv); + _mm_store_ss (&hlCurve[i], resultfv); + resultfv = PERMUTEPS (resultfv, _MM_SHUFFLE (1, 1, 1, 1)); + _mm_store_ss (&hlCurve[i + 1], resultfv); Rv += incrementv; } @@ -588,7 +794,7 @@ SSEFUNCTION void CurveFactory::complexCurve (double ecomp, double black, double for (int i = shoulder + 1; i < 0x10000; i++) { // change to [0,1] range - hlCurve[i] = xlog(1.0 + R * exp_scale) / R; // don't use xlogf or 1.f here. Leads to errors caused by too low precision + hlCurve[i] = xlog (1.0 + R * exp_scale) / R; // don't use xlogf or 1.f here. Leads to errors caused by too low precision R += increment; } @@ -598,14 +804,14 @@ SSEFUNCTION void CurveFactory::complexCurve (double ecomp, double black, double // curve without contrast - LUTf dcurve(0x10000); + LUTf dcurve (0x10000); //%%%%%%%%%%%%%%%%%%%%%%%%%% // change to [0,1] range - shCurve.setClip(LUT_CLIP_ABOVE); // used LUT_CLIP_ABOVE, because the curve converges to 1.0 at the upper end and we don't want to exceed this value. + shCurve.setClip (LUT_CLIP_ABOVE); // used LUT_CLIP_ABOVE, because the curve converges to 1.0 at the upper end and we don't want to exceed this value. float val = 1.f / 65535.f; float val2 = simplebasecurve (val, black, 0.015 * shcompr); - shCurve[0] = CLIPD(val2) / val; + shCurve[0] = CLIPD (val2) / val; // gamma correction val = Color::gammatab_srgb[0] / 65535.f; @@ -616,7 +822,7 @@ SSEFUNCTION void CurveFactory::complexCurve (double ecomp, double black, double } // store result in a temporary array - dcurve[0] = CLIPD(val); + dcurve[0] = CLIPD (val); for (int i = 1; i < 0x10000; i++) { float val = i / 65535.f; @@ -629,7 +835,7 @@ SSEFUNCTION void CurveFactory::complexCurve (double ecomp, double black, double // apply brightness curve if (brightcurve) { - val = CLIPD(brightcurve->getVal (val)); // TODO: getVal(double) is very slow! Optimize with a LUTf + val = CLIPD (brightcurve->getVal (val)); // TODO: getVal(double) is very slow! Optimize with a LUTf } // store result in a temporary array @@ -651,14 +857,14 @@ SSEFUNCTION void CurveFactory::complexCurve (double ecomp, double black, double for (int i = 0; i <= 0xffff; i++) { float fi = i * hlCurve[i]; - avg += dcurve[(int)(shCurve[fi] * fi)] * histogram[i]; + avg += dcurve[ (int) (shCurve[fi] * fi)] * histogram[i]; sum += histogram[i]; } avg /= sum; //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - std::vector contrastcurvePoints(9); + std::vector contrastcurvePoints (9); contrastcurvePoints[0] = DCT_NURBS; contrastcurvePoints[1] = 0; //black point. Value in [0 ; 1] range @@ -673,7 +879,7 @@ SSEFUNCTION void CurveFactory::complexCurve (double ecomp, double black, double contrastcurvePoints[7] = 1.; // white point contrastcurvePoints[8] = 1.; // value at white point - const DiagonalCurve contrastcurve(contrastcurvePoints, CURVES_MIN_POLY_POINTS / skip); + const DiagonalCurve contrastcurve (contrastcurvePoints, CURVES_MIN_POLY_POINTS / skip); //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // apply contrast enhancement @@ -689,10 +895,10 @@ SSEFUNCTION void CurveFactory::complexCurve (double ecomp, double black, double customToneCurve2.Reset(); if (!curvePoints2.empty() && curvePoints2[0] > DCT_Linear && curvePoints2[0] < DCT_Unchanged) { - const DiagonalCurve tcurve(curvePoints2, CURVES_MIN_POLY_POINTS / skip); + const DiagonalCurve tcurve (curvePoints2, CURVES_MIN_POLY_POINTS / skip); if (!tcurve.isIdentity()) { - customToneCurve2.Set(tcurve, gamma_); + customToneCurve2.Set (tcurve, gamma_); } if (outBeforeCCurveHistogram ) { @@ -708,10 +914,10 @@ SSEFUNCTION void CurveFactory::complexCurve (double ecomp, double black, double customToneCurve1.Reset(); if (!curvePoints.empty() && curvePoints[0] > DCT_Linear && curvePoints[0] < DCT_Unchanged) { - const DiagonalCurve tcurve(curvePoints, CURVES_MIN_POLY_POINTS / skip); + const DiagonalCurve tcurve (curvePoints, CURVES_MIN_POLY_POINTS / skip); if (!tcurve.isIdentity()) { - customToneCurve1.Set(tcurve, gamma_); + customToneCurve1.Set (tcurve, gamma_); } if (outBeforeCCurveHistogram) { @@ -722,17 +928,17 @@ SSEFUNCTION void CurveFactory::complexCurve (double ecomp, double black, double //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% #ifdef __SSE2__ - vfloat gamma_v = F2V(gamma_); - vfloat startv = F2V(start); - vfloat slopev = F2V(slope); - vfloat mulv = F2V(mul); - vfloat addv = F2V(add); - vfloat c65535v = F2V(65535.f); + vfloat gamma_v = F2V (gamma_); + vfloat startv = F2V (start); + vfloat slopev = F2V (slope); + vfloat mulv = F2V (mul); + vfloat addv = F2V (add); + vfloat c65535v = F2V (65535.f); for (int i = 0; i <= 0xffff; i += 4) { - vfloat valv = LVFU(dcurve[i]); + vfloat valv = LVFU (dcurve[i]); valv = igamma (valv, gamma_v, startv, slopev, mulv, addv); - STVFU(outCurve[i], c65535v * valv); + STVFU (outCurve[i], c65535v * valv); } #else @@ -750,7 +956,7 @@ SSEFUNCTION void CurveFactory::complexCurve (double ecomp, double black, double float fi = i; float hval = hlCurve[i] * fi; hval = dcurve[shCurve[hval] * hval]; - int hi = (int)(255.f * (hval)); + int hi = (int) (255.f * (hval)); outBeforeCCurveHistogram[hi] += histogram[i] ; } } @@ -767,6 +973,7 @@ void CurveFactory::complexLCurve (double br, double contr, const std::vector brightcurvePoints; - brightcurvePoints.resize(9); - brightcurvePoints.at(0) = double(DCT_NURBS); + brightcurvePoints.resize (9); + brightcurvePoints.at (0) = double (DCT_NURBS); - brightcurvePoints.at(1) = 0.; // black point. Value in [0 ; 1] range - brightcurvePoints.at(2) = 0.; // black point. Value in [0 ; 1] range + brightcurvePoints.at (1) = 0.; // black point. Value in [0 ; 1] range + brightcurvePoints.at (2) = 0.; // black point. Value in [0 ; 1] range if (br > 0) { - brightcurvePoints.at(3) = 0.1; // toe point - brightcurvePoints.at(4) = 0.1 + br / 150.0; //value at toe point + brightcurvePoints.at (3) = 0.1; // toe point + brightcurvePoints.at (4) = 0.1 + br / 150.0; //value at toe point - brightcurvePoints.at(5) = 0.7; // shoulder point - brightcurvePoints.at(6) = min(1.0, 0.7 + br / 300.0); //value at shoulder point + brightcurvePoints.at (5) = 0.7; // shoulder point + brightcurvePoints.at (6) = min (1.0, 0.7 + br / 300.0); //value at shoulder point } else { - brightcurvePoints.at(3) = 0.1 - br / 150.0; // toe point - brightcurvePoints.at(4) = 0.1; // value at toe point + brightcurvePoints.at (3) = 0.1 - br / 150.0; // toe point + brightcurvePoints.at (4) = 0.1; // value at toe point - brightcurvePoints.at(5) = min(1.0, 0.7 - br / 300.0); // shoulder point - brightcurvePoints.at(6) = 0.7; // value at shoulder point + brightcurvePoints.at (5) = min (1.0, 0.7 - br / 300.0); // shoulder point + brightcurvePoints.at (6) = 0.7; // value at shoulder point } - brightcurvePoints.at(7) = 1.; // white point - brightcurvePoints.at(8) = 1.; // value at white point + brightcurvePoints.at (7) = 1.; // white point + brightcurvePoints.at (8) = 1.; // value at white point - DiagonalCurve brightcurve(brightcurvePoints, CURVES_MIN_POLY_POINTS / skip); + DiagonalCurve brightcurve (brightcurvePoints, CURVES_MIN_POLY_POINTS / skip); //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // Applying brightness curve @@ -817,11 +1024,11 @@ void CurveFactory::complexLCurve (double br, double contr, const std::vector contrastcurvePoints; - if(sum) { + if (sum) { avg /= sum; //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - contrastcurvePoints.resize(9); - contrastcurvePoints.at(0) = double(DCT_NURBS); + contrastcurvePoints.resize (9); + contrastcurvePoints.at (0) = double (DCT_NURBS); - contrastcurvePoints.at(1) = 0.; // black point. Value in [0 ; 1] range - contrastcurvePoints.at(2) = 0.; // black point. Value in [0 ; 1] range + contrastcurvePoints.at (1) = 0.; // black point. Value in [0 ; 1] range + contrastcurvePoints.at (2) = 0.; // black point. Value in [0 ; 1] range - contrastcurvePoints.at(3) = avg - avg * (0.6 - contr / 250.0); // toe point - contrastcurvePoints.at(4) = avg - avg * (0.6 + contr / 250.0); // value at toe point + contrastcurvePoints.at (3) = avg - avg * (0.6 - contr / 250.0); // toe point + contrastcurvePoints.at (4) = avg - avg * (0.6 + contr / 250.0); // value at toe point - contrastcurvePoints.at(5) = avg + (1 - avg) * (0.6 - contr / 250.0); // shoulder point - contrastcurvePoints.at(6) = avg + (1 - avg) * (0.6 + contr / 250.0); // value at shoulder point + contrastcurvePoints.at (5) = avg + (1 - avg) * (0.6 - contr / 250.0); // shoulder point + contrastcurvePoints.at (6) = avg + (1 - avg) * (0.6 + contr / 250.0); // value at shoulder point - contrastcurvePoints.at(7) = 1.; // white point - contrastcurvePoints.at(8) = 1.; // value at white point + contrastcurvePoints.at (7) = 1.; // white point + contrastcurvePoints.at (8) = 1.; // value at white point //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% } else { //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // sum has an invalid value (next to 0, producing a division by zero, so we create a fake contrast curve, producing a white image - contrastcurvePoints.resize(5); - contrastcurvePoints.at(0) = double(DCT_NURBS); + contrastcurvePoints.resize (5); + contrastcurvePoints.at (0) = double (DCT_NURBS); - contrastcurvePoints.at(1) = 0.; // black point. Value in [0 ; 1] range - contrastcurvePoints.at(2) = 1.; // black point. Value in [0 ; 1] range + contrastcurvePoints.at (1) = 0.; // black point. Value in [0 ; 1] range + contrastcurvePoints.at (2) = 1.; // black point. Value in [0 ; 1] range - contrastcurvePoints.at(3) = 1.; // white point - contrastcurvePoints.at(4) = 1.; // value at white point + contrastcurvePoints.at (3) = 1.; // white point + contrastcurvePoints.at (4) = 1.; // value at white point //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% } - DiagonalCurve contrastcurve(contrastcurvePoints, CURVES_MIN_POLY_POINTS / skip); + DiagonalCurve contrastcurve (contrastcurvePoints, CURVES_MIN_POLY_POINTS / skip); // apply contrast enhancement for (int i = 0; i < 32768; i++) { @@ -894,7 +1101,7 @@ void CurveFactory::complexLCurve (double br, double contr, const std::vector(new DiagonalCurve (curvePoints, CURVES_MIN_POLY_POINTS / skip)); + tcurve = std::unique_ptr (new DiagonalCurve (curvePoints, CURVES_MIN_POLY_POINTS / skip)); if (outBeforeCCurveHistogram) { histNeeded = true; @@ -914,7 +1121,7 @@ void CurveFactory::complexLCurve (double br, double contr, const std::vector& curvePoints, LUTf & outC std::unique_ptr tcurve; if (!curvePoints.empty() && curvePoints[0] != 0) { - tcurve = std::unique_ptr(new DiagonalCurve(curvePoints, CURVES_MIN_POLY_POINTS / skip)); + tcurve = std::unique_ptr (new DiagonalCurve (curvePoints, CURVES_MIN_POLY_POINTS / skip)); } if (tcurve && tcurve->isIdentity()) { @@ -961,14 +1168,14 @@ void CurveFactory::RGBCurve (const std::vector& curvePoints, LUTf & outC if (tcurve) { if (!outCurve) { - outCurve(65536, 0); + outCurve (65536, 0); } for (int i = 0; i < 65536; i++) { // apply custom/parametric/NURBS curve, if any // RGB curves are defined with sRGB gamma, but operate on linear data float val = Color::gamma2curve[i] / 65535.f; - val = tcurve->getVal(val); + val = tcurve->getVal (val); outCurve[i] = Color::igammatab_srgb[val * 65535.f]; } } else { // let the LUTf empty for identity curves @@ -977,18 +1184,149 @@ void CurveFactory::RGBCurve (const std::vector& curvePoints, LUTf & outC } +LocretigainCurverab::LocretigainCurverab() : sum (0.f) {}; + +void LocretigainCurverab::Reset() +{ + lutLocretigainCurverab.reset(); + sum = 0.f; +} + +void LocretigainCurverab::Set (const Curve &pCurve) +{ + if (pCurve.isIdentity()) { + Reset(); // raise this value if the quality suffers from this number of samples + return; + } + + lutLocretigainCurverab (501); // raise this value if the quality suffers from this number of samples + sum = 0.f; + + for (int i = 0; i < 501; i++) { + lutLocretigainCurverab[i] = pCurve.getVal (double (i) / 500.); + + if (lutLocretigainCurverab[i] < 0.02f) { + lutLocretigainCurverab[i] = 0.02f; //avoid 0.f for wavelet : under 0.01f quasi no action for each value + } + + sum += lutLocretigainCurverab[i]; + } + + //lutLocCurve.dump("wav"); +} + +void LocretigainCurverab::Set (const std::vector &curvePoints) +{ + + if (!curvePoints.empty() && curvePoints[0] > FCT_Linear && curvePoints[0] < FCT_Unchanged) { + FlatCurve tcurve (curvePoints, false, CURVES_MIN_POLY_POINTS / 2); + tcurve.setIdentityValue (0.); + Set (tcurve); + } else { + Reset(); + } +} + +LocLHCurve::LocLHCurve() : sum (0.f) {}; + +void LocLHCurve::Reset() +{ + lutLocLHCurve.reset(); + sum = 0.f; +} + +void LocLHCurve::Set (const Curve &pCurve) +{ + if (pCurve.isIdentity()) { + Reset(); // raise this value if the quality suffers from this number of samples + return; + } + + lutLocLHCurve (501); // raise this value if the quality suffers from this number of samples + sum = 0.f; + + for (int i = 0; i < 501; i++) { + lutLocLHCurve[i] = pCurve.getVal (double (i) / 500.); + + if (lutLocLHCurve[i] < 0.02f) { + lutLocLHCurve[i] = 0.02f; //avoid 0.f for wavelet : under 0.01f quasi no action for each value + } + + sum += lutLocLHCurve[i]; + } + + //lutLocCurve.dump("wav"); +} + +void LocLHCurve::Set (const std::vector &curvePoints) +{ + + if (!curvePoints.empty() && curvePoints[0] > FCT_Linear && curvePoints[0] < FCT_Unchanged) { + FlatCurve tcurve (curvePoints, false, CURVES_MIN_POLY_POINTS / 2); + tcurve.setIdentityValue (0.); + Set (tcurve); + } else { + Reset(); + } +} + + +LocretigainCurve::LocretigainCurve() : sum (0.f) {}; + +void LocretigainCurve::Reset() +{ + lutLocretigainCurve.reset(); + sum = 0.f; +} + +void LocretigainCurve::Set (const Curve &pCurve) +{ + if (pCurve.isIdentity()) { + Reset(); // raise this value if the quality suffers from this number of samples + return; + } + + lutLocretigainCurve (501); // raise this value if the quality suffers from this number of samples + sum = 0.f; + + for (int i = 0; i < 501; i++) { + lutLocretigainCurve[i] = pCurve.getVal (double (i) / 500.); + + if (lutLocretigainCurve[i] < 0.02f) { + lutLocretigainCurve[i] = 0.02f; //avoid 0.f for wavelet : under 0.01f quasi no action for each value + } + + sum += lutLocretigainCurve[i]; + } + + //lutLocCurve.dump("wav"); +} +void LocretigainCurve::Set (const std::vector &curvePoints) +{ + + if (!curvePoints.empty() && curvePoints[0] > FCT_Linear && curvePoints[0] < FCT_Unchanged) { + FlatCurve tcurve (curvePoints, false, CURVES_MIN_POLY_POINTS / 2); + tcurve.setIdentityValue (0.); + Set (tcurve); + } else { + Reset(); + } +} + + + void ColorAppearance::Reset() { lutColCurve.reset(); } // Fill a LUT with X/Y, ranged 0xffff -void ColorAppearance::Set(const Curve &pCurve) +void ColorAppearance::Set (const Curve &pCurve) { - lutColCurve(65536); + lutColCurve (65536); for (int i = 0; i < 65536; i++) { - lutColCurve[i] = pCurve.getVal(double(i) / 65535.) * 65535.; + lutColCurve[i] = pCurve.getVal (double (i) / 65535.) * 65535.; } } @@ -1000,26 +1338,26 @@ void RetinextransmissionCurve::Reset() luttransmission.reset(); } -void RetinextransmissionCurve::Set(const Curve &pCurve) +void RetinextransmissionCurve::Set (const Curve &pCurve) { if (pCurve.isIdentity()) { luttransmission.reset(); // raise this value if the quality suffers from this number of samples return; } - luttransmission(501); // raise this value if the quality suffers from this number of samples + luttransmission (501); // raise this value if the quality suffers from this number of samples for (int i = 0; i < 501; i++) { - luttransmission[i] = pCurve.getVal(double(i) / 500.); + luttransmission[i] = pCurve.getVal (double (i) / 500.); } } -void RetinextransmissionCurve::Set(const std::vector &curvePoints) +void RetinextransmissionCurve::Set (const std::vector &curvePoints) { if (!curvePoints.empty() && curvePoints[0] > FCT_Linear && curvePoints[0] < FCT_Unchanged) { - FlatCurve tcurve(curvePoints, false, CURVES_MIN_POLY_POINTS / 2); - tcurve.setIdentityValue(0.); - Set(tcurve); + FlatCurve tcurve (curvePoints, false, CURVES_MIN_POLY_POINTS / 2); + tcurve.setIdentityValue (0.); + Set (tcurve); } else { Reset(); } @@ -1033,26 +1371,26 @@ void RetinexgaintransmissionCurve::Reset() lutgaintransmission.reset(); } -void RetinexgaintransmissionCurve::Set(const Curve &pCurve) +void RetinexgaintransmissionCurve::Set (const Curve &pCurve) { if (pCurve.isIdentity()) { lutgaintransmission.reset(); // raise this value if the quality suffers from this number of samples return; } - lutgaintransmission(501); // raise this value if the quality suffers from this number of samples + lutgaintransmission (501); // raise this value if the quality suffers from this number of samples for (int i = 0; i < 501; i++) { - lutgaintransmission[i] = pCurve.getVal(double(i) / 500.); + lutgaintransmission[i] = pCurve.getVal (double (i) / 500.); } } -void RetinexgaintransmissionCurve::Set(const std::vector &curvePoints) +void RetinexgaintransmissionCurve::Set (const std::vector &curvePoints) { if (!curvePoints.empty() && curvePoints[0] > FCT_Linear && curvePoints[0] < FCT_Unchanged) { - FlatCurve tcurve(curvePoints, false, CURVES_MIN_POLY_POINTS / 2); - tcurve.setIdentityValue(0.); - Set(tcurve); + FlatCurve tcurve (curvePoints, false, CURVES_MIN_POLY_POINTS / 2); + tcurve.setIdentityValue (0.); + Set (tcurve); } else { Reset(); } @@ -1064,34 +1402,34 @@ void ToneCurve::Reset() } // Fill a LUT with X/Y, ranged 0xffff -void ToneCurve::Set(const Curve &pCurve, float gamma) +void ToneCurve::Set (const Curve &pCurve, float gamma) { - lutToneCurve(65536); + lutToneCurve (65536); if (gamma <= 0.0 || gamma == 1.) { for (int i = 0; i < 65536; i++) { - lutToneCurve[i] = (float)pCurve.getVal(float(i) / 65535.f) * 65535.f; + lutToneCurve[i] = (float)pCurve.getVal (float (i) / 65535.f) * 65535.f; } - } else if(gamma == (float)Color::sRGBGammaCurve) { + } else if (gamma == (float)Color::sRGBGammaCurve) { // for sRGB gamma we can use luts, which is much faster for (int i = 0; i < 65536; i++) { float val = Color::gammatab_srgb[i] / 65535.f; - val = pCurve.getVal(val); + val = pCurve.getVal (val); val = Color::igammatab_srgb[val * 65535.f]; lutToneCurve[i] = val; } } else { - const float start = expf(gamma * logf( -0.055 / ((1.0 / gamma - 1.0) * 1.055 ))); + const float start = expf (gamma * logf ( -0.055 / ((1.0 / gamma - 1.0) * 1.055 ))); const float slope = 1.055 * powf (start, 1.0 / gamma - 1) - 0.055 / start; const float mul = 1.055; const float add = 0.055; // apply gamma, that is 'pCurve' is defined with the given gamma and here we convert it to a curve in linear space for (int i = 0; i < 65536; i++) { - float val = float(i) / 65535.f; + float val = float (i) / 65535.f; val = CurveFactory::gamma (val, gamma, start, slope, mul, add); - val = pCurve.getVal(val); + val = pCurve.getVal (val); val = CurveFactory::igamma (val, gamma, start, slope, mul, add); lutToneCurve[i] = val * 65535.f; } @@ -1103,40 +1441,40 @@ void OpacityCurve::Reset() lutOpacityCurve.reset(); } -void OpacityCurve::Set(const Curve *pCurve) +void OpacityCurve::Set (const Curve *pCurve) { if (pCurve->isIdentity()) { lutOpacityCurve.reset(); // raise this value if the quality suffers from this number of samples return; } - lutOpacityCurve(501); // raise this value if the quality suffers from this number of samples + lutOpacityCurve (501); // raise this value if the quality suffers from this number of samples for (int i = 0; i < 501; i++) { - lutOpacityCurve[i] = pCurve->getVal(double(i) / 500.); + lutOpacityCurve[i] = pCurve->getVal (double (i) / 500.); } //lutOpacityCurve.dump("opacity"); } -void OpacityCurve::Set(const std::vector &curvePoints, bool &opautili) +void OpacityCurve::Set (const std::vector &curvePoints, bool &opautili) { std::unique_ptr tcurve; if (!curvePoints.empty() && curvePoints[0] > FCT_Linear && curvePoints[0] < FCT_Unchanged) { - tcurve = std::unique_ptr(new FlatCurve(curvePoints, false, CURVES_MIN_POLY_POINTS / 2)); - tcurve->setIdentityValue(0.); + tcurve = std::unique_ptr (new FlatCurve (curvePoints, false, CURVES_MIN_POLY_POINTS / 2)); + tcurve->setIdentityValue (0.); } if (tcurve) { - Set(tcurve.get()); + Set (tcurve.get()); opautili = true; tcurve = nullptr; } } -WavCurve::WavCurve() : sum(0.f) {}; +WavCurve::WavCurve() : sum (0.f) {}; void WavCurve::Reset() { @@ -1144,20 +1482,20 @@ void WavCurve::Reset() sum = 0.f; } -void WavCurve::Set(const Curve &pCurve) +void WavCurve::Set (const Curve &pCurve) { if (pCurve.isIdentity()) { Reset(); // raise this value if the quality suffers from this number of samples return; } - lutWavCurve(501); // raise this value if the quality suffers from this number of samples + lutWavCurve (501); // raise this value if the quality suffers from this number of samples sum = 0.f; for (int i = 0; i < 501; i++) { - lutWavCurve[i] = pCurve.getVal(double(i) / 500.); + lutWavCurve[i] = pCurve.getVal (double (i) / 500.); - if(lutWavCurve[i] < 0.02f) { + if (lutWavCurve[i] < 0.02f) { lutWavCurve[i] = 0.02f; //avoid 0.f for wavelet : under 0.01f quasi no action for each value } @@ -1166,13 +1504,13 @@ void WavCurve::Set(const Curve &pCurve) //lutWavCurve.dump("wav"); } -void WavCurve::Set(const std::vector &curvePoints) +void WavCurve::Set (const std::vector &curvePoints) { if (!curvePoints.empty() && curvePoints[0] > FCT_Linear && curvePoints[0] < FCT_Unchanged) { - FlatCurve tcurve(curvePoints, false, CURVES_MIN_POLY_POINTS / 2); - tcurve.setIdentityValue(0.); - Set(tcurve); + FlatCurve tcurve (curvePoints, false, CURVES_MIN_POLY_POINTS / 2); + tcurve.setIdentityValue (0.); + Set (tcurve); } else { Reset(); } @@ -1186,26 +1524,26 @@ void WavOpacityCurveRG::Reset() lutOpacityCurveRG.reset(); } -void WavOpacityCurveRG::Set(const Curve &pCurve) +void WavOpacityCurveRG::Set (const Curve &pCurve) { if (pCurve.isIdentity()) { Reset(); // raise this value if the quality suffers from this number of samples return; } - lutOpacityCurveRG(501); // raise this value if the quality suffers from this number of samples + lutOpacityCurveRG (501); // raise this value if the quality suffers from this number of samples for (int i = 0; i < 501; i++) { - lutOpacityCurveRG[i] = pCurve.getVal(double(i) / 500.); + lutOpacityCurveRG[i] = pCurve.getVal (double (i) / 500.); } } -void WavOpacityCurveRG::Set(const std::vector &curvePoints) +void WavOpacityCurveRG::Set (const std::vector &curvePoints) { if (!curvePoints.empty() && curvePoints[0] > FCT_Linear && curvePoints[0] < FCT_Unchanged) { - FlatCurve tcurve(curvePoints, false, CURVES_MIN_POLY_POINTS / 2); - tcurve.setIdentityValue(0.); - Set(tcurve); + FlatCurve tcurve (curvePoints, false, CURVES_MIN_POLY_POINTS / 2); + tcurve.setIdentityValue (0.); + Set (tcurve); } else { Reset(); } @@ -1219,26 +1557,26 @@ void WavOpacityCurveBY::Reset() lutOpacityCurveBY.reset(); } -void WavOpacityCurveBY::Set(const Curve &pCurve) +void WavOpacityCurveBY::Set (const Curve &pCurve) { if (pCurve.isIdentity()) { lutOpacityCurveBY.reset(); // raise this value if the quality suffers from this number of samples return; } - lutOpacityCurveBY(501); // raise this value if the quality suffers from this number of samples + lutOpacityCurveBY (501); // raise this value if the quality suffers from this number of samples for (int i = 0; i < 501; i++) { - lutOpacityCurveBY[i] = pCurve.getVal(double(i) / 500.); + lutOpacityCurveBY[i] = pCurve.getVal (double (i) / 500.); } } -void WavOpacityCurveBY::Set(const std::vector &curvePoints) +void WavOpacityCurveBY::Set (const std::vector &curvePoints) { if (!curvePoints.empty() && curvePoints[0] > FCT_Linear && curvePoints[0] < FCT_Unchanged) { - FlatCurve tcurve(curvePoints, false, CURVES_MIN_POLY_POINTS / 2); - tcurve.setIdentityValue(0.); - Set(tcurve); + FlatCurve tcurve (curvePoints, false, CURVES_MIN_POLY_POINTS / 2); + tcurve.setIdentityValue (0.); + Set (tcurve); } else { Reset(); } @@ -1251,26 +1589,26 @@ void WavOpacityCurveW::Reset() lutOpacityCurveW.reset(); } -void WavOpacityCurveW::Set(const Curve &pCurve) +void WavOpacityCurveW::Set (const Curve &pCurve) { if (pCurve.isIdentity()) { lutOpacityCurveW.reset(); // raise this value if the quality suffers from this number of samples return; } - lutOpacityCurveW(501); // raise this value if the quality suffers from this number of samples + lutOpacityCurveW (501); // raise this value if the quality suffers from this number of samples for (int i = 0; i < 501; i++) { - lutOpacityCurveW[i] = pCurve.getVal(double(i) / 500.); + lutOpacityCurveW[i] = pCurve.getVal (double (i) / 500.); } } -void WavOpacityCurveW::Set(const std::vector &curvePoints) +void WavOpacityCurveW::Set (const std::vector &curvePoints) { if (!curvePoints.empty() && curvePoints[0] > FCT_Linear && curvePoints[0] < FCT_Unchanged) { - FlatCurve tcurve(curvePoints, false, CURVES_MIN_POLY_POINTS / 2); - tcurve.setIdentityValue(0.); - Set(tcurve); + FlatCurve tcurve (curvePoints, false, CURVES_MIN_POLY_POINTS / 2); + tcurve.setIdentityValue (0.); + Set (tcurve); } else { Reset(); } @@ -1283,33 +1621,33 @@ void WavOpacityCurveWL::Reset() lutOpacityCurveWL.reset(); } -void WavOpacityCurveWL::Set(const Curve &pCurve) +void WavOpacityCurveWL::Set (const Curve &pCurve) { if (pCurve.isIdentity()) { lutOpacityCurveWL.reset(); // raise this value if the quality suffers from this number of samples return; } - lutOpacityCurveWL(501); // raise this value if the quality suffers from this number of samples + lutOpacityCurveWL (501); // raise this value if the quality suffers from this number of samples for (int i = 0; i < 501; i++) { - lutOpacityCurveWL[i] = pCurve.getVal(double(i) / 500.); + lutOpacityCurveWL[i] = pCurve.getVal (double (i) / 500.); } } -void WavOpacityCurveWL::Set(const std::vector &curvePoints) +void WavOpacityCurveWL::Set (const std::vector &curvePoints) { if (!curvePoints.empty() && curvePoints[0] > FCT_Linear && curvePoints[0] < FCT_Unchanged) { - FlatCurve tcurve(curvePoints, false, CURVES_MIN_POLY_POINTS / 2); - tcurve.setIdentityValue(0.); - Set(tcurve); + FlatCurve tcurve (curvePoints, false, CURVES_MIN_POLY_POINTS / 2); + tcurve.setIdentityValue (0.); + Set (tcurve); } else { Reset(); } } -NoiseCurve::NoiseCurve() : sum(0.f) {}; +NoiseCurve::NoiseCurve() : sum (0.f) {}; void NoiseCurve::Reset() { @@ -1317,20 +1655,20 @@ void NoiseCurve::Reset() sum = 0.f; } -void NoiseCurve::Set(const Curve &pCurve) +void NoiseCurve::Set (const Curve &pCurve) { if (pCurve.isIdentity()) { Reset(); // raise this value if the quality suffers from this number of samples return; } - lutNoiseCurve(501); // raise this value if the quality suffers from this number of samples + lutNoiseCurve (501); // raise this value if the quality suffers from this number of samples sum = 0.f; for (int i = 0; i < 501; i++) { - lutNoiseCurve[i] = pCurve.getVal(double(i) / 500.); + lutNoiseCurve[i] = pCurve.getVal (double (i) / 500.); - if(lutNoiseCurve[i] < 0.01f) { + if (lutNoiseCurve[i] < 0.01f) { lutNoiseCurve[i] = 0.01f; //avoid 0.f for wavelet : under 0.01f quasi no action for each value } @@ -1340,13 +1678,13 @@ void NoiseCurve::Set(const Curve &pCurve) //lutNoisCurve.dump("Nois"); } -void NoiseCurve::Set(const std::vector &curvePoints) +void NoiseCurve::Set (const std::vector &curvePoints) { if (!curvePoints.empty() && curvePoints[0] > FCT_Linear && curvePoints[0] < FCT_Unchanged) { - FlatCurve tcurve(curvePoints, false, CURVES_MIN_POLY_POINTS / 2); - tcurve.setIdentityValue(0.); - Set(tcurve); + FlatCurve tcurve (curvePoints, false, CURVES_MIN_POLY_POINTS / 2); + tcurve.setIdentityValue (0.); + Set (tcurve); } else { Reset(); } @@ -1360,7 +1698,7 @@ void ColorGradientCurve::Reset() lut3.reset(); } -void ColorGradientCurve::SetXYZ(const Curve *pCurve, const double xyz_rgb[3][3], const double rgb_xyz[3][3], float satur, float lumin) +void ColorGradientCurve::SetXYZ (const Curve *pCurve, const double xyz_rgb[3][3], const double rgb_xyz[3][3], float satur, float lumin) { if (pCurve->isIdentity()) { lut1.reset(); @@ -1370,9 +1708,9 @@ void ColorGradientCurve::SetXYZ(const Curve *pCurve, const double xyz_rgb[3][3], } if (!lut1) { - lut1(501); - lut2(501); - lut3(501); + lut1 (501); + lut2 (501); + lut3 (501); } float r, g, b, xx, yy, zz; @@ -1380,8 +1718,8 @@ void ColorGradientCurve::SetXYZ(const Curve *pCurve, const double xyz_rgb[3][3], int upperBound = lut1.getUpperBound(); if (pCurve->isIdentity()) { - Color::hsv2rgb(0.5f, satur, lumin, r, g, b); - Color::rgbxyz(r, g, b, xx, yy, zz, xyz_rgb); + Color::hsv2rgb (0.5f, satur, lumin, r, g, b); + Color::rgbxyz (r, g, b, xx, yy, zz, xyz_rgb); for (int i = 0; i <= 500; ++i) { // WARNING: set the identity value according to what is set in the GUI @@ -1396,7 +1734,7 @@ void ColorGradientCurve::SetXYZ(const Curve *pCurve, const double xyz_rgb[3][3], int nPoints = pCurve->getSize(); int ptNum = 0; double nextX, nextY; - pCurve->getControlPoint(ptNum, nextX, nextY); + pCurve->getControlPoint (ptNum, nextX, nextY); double prevY = nextY; double dY = 0.; low = nextX; @@ -1404,14 +1742,14 @@ void ColorGradientCurve::SetXYZ(const Curve *pCurve, const double xyz_rgb[3][3], //lr1=low; for (int i = 0; i <= upperBound; ++i) { - double x = double(i) / double(upperBound); + double x = double (i) / double (upperBound); if (x > nextX) { ++ptNum; if (ptNum < nPoints) { prevY = nextY; - pCurve->getControlPoint(ptNum, nextX, nextY); + pCurve->getControlPoint (ptNum, nextX, nextY); dY = nextY - prevY; high = nextX; lr2 = (0.5f + high) / 2.f; //optimize use of gamut in high light..one can optimize more using directly high ? @@ -1420,70 +1758,70 @@ void ColorGradientCurve::SetXYZ(const Curve *pCurve, const double xyz_rgb[3][3], } if (!ptNum) { - Color::hsv2rgb(float(prevY), satur, lr1, r, g, b); - Color::rgbxyz(r, g, b, xx, yy, zz, xyz_rgb); + Color::hsv2rgb (float (prevY), satur, lr1, r, g, b); + Color::rgbxyz (r, g, b, xx, yy, zz, xyz_rgb); lut1[i] = xx; lut2[i] = yy; lut3[i] = zz; } else if (ptNum >= nPoints) { - Color::hsv2rgb(float(nextY), satur, lr2, r, g, b); - Color::rgbxyz(r, g, b, xx, yy, zz, xyz_rgb); + Color::hsv2rgb (float (nextY), satur, lr2, r, g, b); + Color::rgbxyz (r, g, b, xx, yy, zz, xyz_rgb); lut1[i] = xx; lut2[i] = yy; lut3[i] = zz; } else { - double currY = pCurve->getVal(x) - prevY; + double currY = pCurve->getVal (x) - prevY; if (dY > 0.000001 || dY < -0.000001) { float r1, g1, b1, r2, g2, b2; - Color::hsv2rgb(float(prevY), satur, lr1, r1, g1, b1); - Color::hsv2rgb(float(nextY), satur, lr2, r2, g2, b2); + Color::hsv2rgb (float (prevY), satur, lr1, r1, g1, b1); + Color::hsv2rgb (float (nextY), satur, lr2, r2, g2, b2); LUTf dum; float X1, X2, Y1, Y2, Z1, Z2, L1, a_1, b_1, c1, h1; - Color::rgbxyz(r2, g2, b2, X2, Y2, Z2, xyz_rgb); - Color::rgbxyz(r1, g1, b1, X1, Y1, Z1, xyz_rgb); + Color::rgbxyz (r2, g2, b2, X2, Y2, Z2, xyz_rgb); + Color::rgbxyz (r1, g1, b1, X1, Y1, Z1, xyz_rgb); //I use XYZ to mix color 1 and 2 rather than rgb (gamut) and rather than Lab artifacts X1 = X1 + (X2 - X1) * currY / dY; - if(X1 < 0.f) { + if (X1 < 0.f) { X1 = 0.f; //negative value not good } Y1 = Y1 + (Y2 - Y1) * currY / dY; - if(Y1 < 0.f) { + if (Y1 < 0.f) { Y1 = 0.f; } Z1 = Z1 + (Z2 - Z1) * currY / dY; - if(Z1 < 0.f) { + if (Z1 < 0.f) { Z1 = 0.f; } - Color::XYZ2Lab(X1, Y1, Z1, L1, a_1, b_1);//prepare to gamut control - Color::Lab2Lch(a_1, b_1, c1, h1); + Color::XYZ2Lab (X1, Y1, Z1, L1, a_1, b_1); //prepare to gamut control + Color::Lab2Lch (a_1, b_1, c1, h1); float Lr = L1 / 327.68f; float RR, GG, BB; #ifndef NDEBUG bool neg = false; bool more_rgb = false; //gamut control : Lab values are in gamut - Color::gamutLchonly(h1, Lr, c1, RR, GG, BB, xyz_rgb, false, 0.15f, 0.96f, neg, more_rgb); + Color::gamutLchonly (h1, Lr, c1, RR, GG, BB, xyz_rgb, false, 0.15f, 0.96f, neg, more_rgb); #else - Color::gamutLchonly(h1, Lr, c1, RR, GG, BB, xyz_rgb, false, 0.15f, 0.96f); + Color::gamutLchonly (h1, Lr, c1, RR, GG, BB, xyz_rgb, false, 0.15f, 0.96f); #endif L1 = Lr * 327.68f; float a, b, X, Y, Z; // converting back to rgb - Color::Lch2Lab(c1, h1, a, b); - Color::Lab2XYZ(L1, a, b, X, Y, Z); + Color::Lch2Lab (c1, h1, a, b); + Color::Lab2XYZ (L1, a, b, X, Y, Z); lut1[i] = X; lut2[i] = Y; lut3[i] = Z; } else { - Color::hsv2rgb(float(nextY), satur, lumin, r, g, b); - Color::rgbxyz(r, g, b, xx, yy, zz, xyz_rgb); + Color::hsv2rgb (float (nextY), satur, lumin, r, g, b); + Color::rgbxyz (r, g, b, xx, yy, zz, xyz_rgb); lut1[i] = xx; lut2[i] = yy; lut3[i] = zz; @@ -1500,20 +1838,20 @@ void ColorGradientCurve::SetXYZ(const Curve *pCurve, const double xyz_rgb[3][3], */ } -void ColorGradientCurve::SetXYZ(const std::vector &curvePoints, const double xyz_rgb[3][3], const double rgb_xyz[3][3], float satur, float lumin) +void ColorGradientCurve::SetXYZ (const std::vector &curvePoints, const double xyz_rgb[3][3], const double rgb_xyz[3][3], float satur, float lumin) { std::unique_ptr tcurve; if (!curvePoints.empty() && curvePoints[0] > FCT_Linear && curvePoints[0] < FCT_Unchanged) { - tcurve = std::unique_ptr(new FlatCurve(curvePoints, false, CURVES_MIN_POLY_POINTS / 2)); + tcurve = std::unique_ptr (new FlatCurve (curvePoints, false, CURVES_MIN_POLY_POINTS / 2)); } if (tcurve) { - SetXYZ(tcurve.get(), xyz_rgb, rgb_xyz, satur, lumin); + SetXYZ (tcurve.get(), xyz_rgb, rgb_xyz, satur, lumin); } } -void ColorGradientCurve::SetRGB(const Curve *pCurve, const double xyz_rgb[3][3], const double rgb_xyz[3][3]) +void ColorGradientCurve::SetRGB (const Curve *pCurve, const double xyz_rgb[3][3], const double rgb_xyz[3][3]) { if (pCurve->isIdentity()) { lut1.reset(); @@ -1523,9 +1861,9 @@ void ColorGradientCurve::SetRGB(const Curve *pCurve, const double xyz_rgb[3][3], } if (!lut1) { - lut1(501); - lut2(501); - lut3(501); + lut1 (501); + lut2 (501); + lut3 (501); } float r, g, b; @@ -1535,54 +1873,54 @@ void ColorGradientCurve::SetRGB(const Curve *pCurve, const double xyz_rgb[3][3], int nPoints = pCurve->getSize(); int ptNum = 0; double nextX, nextY; - pCurve->getControlPoint(ptNum, nextX, nextY); + pCurve->getControlPoint (ptNum, nextX, nextY); double prevY = nextY; double dY = 0.; Color::eInterpolationDirection dir = Color::ID_DOWN; for (int i = 0; i <= upperBound; ++i) { - double x = double(i) / double(upperBound); + double x = double (i) / double (upperBound); if (x > nextX) { ++ptNum; if (ptNum < nPoints) { prevY = nextY; - pCurve->getControlPoint(ptNum, nextX, nextY); + pCurve->getControlPoint (ptNum, nextX, nextY); dY = nextY - prevY; - dir = Color::getHueInterpolationDirection(prevY, nextY, Color::IP_SHORTEST); + dir = Color::getHueInterpolationDirection (prevY, nextY, Color::IP_SHORTEST); } } if (!ptNum) { - Color::hsv2rgb(float(prevY), 1.f, 1.f, r, g, b); + Color::hsv2rgb (float (prevY), 1.f, 1.f, r, g, b); lut1[i] = r; lut2[i] = g; lut3[i] = b; } else if (ptNum >= nPoints) { - Color::hsv2rgb(float(nextY), 1.f, 1.f, r, g, b); + Color::hsv2rgb (float (nextY), 1.f, 1.f, r, g, b); lut1[i] = r; lut2[i] = g; lut3[i] = b; } else { - double currY = pCurve->getVal(x) - prevY; + double currY = pCurve->getVal (x) - prevY; if (dY > 0.0000001 || dY < -0.0000001) { #if 1 float ro, go, bo; - double h2 = Color::interpolateHueHSV(prevY, nextY, currY / dY, dir); - Color::hsv2rgb(h2, 1.f, 1.f, ro, go, bo); + double h2 = Color::interpolateHueHSV (prevY, nextY, currY / dY, dir); + Color::hsv2rgb (h2, 1.f, 1.f, ro, go, bo); #else float r1, g1, b1, r2, g2, b2, ro, go, bo; - Color::hsv2rgb(float(prevY), 1., 1., r1, g1, b1); - Color::hsv2rgb(float(nextY), 1., 1., r2, g2, b2); - Color::interpolateRGBColor(currY / dY, r1, g1, b1, r2, g2, b2, Color::CHANNEL_LIGHTNESS | Color::CHANNEL_CHROMATICITY | Color::CHANNEL_HUE, xyz_rgb, rgb_xyz, ro, go, bo); + Color::hsv2rgb (float (prevY), 1., 1., r1, g1, b1); + Color::hsv2rgb (float (nextY), 1., 1., r2, g2, b2); + Color::interpolateRGBColor (currY / dY, r1, g1, b1, r2, g2, b2, Color::CHANNEL_LIGHTNESS | Color::CHANNEL_CHROMATICITY | Color::CHANNEL_HUE, xyz_rgb, rgb_xyz, ro, go, bo); #endif lut1[i] = ro; lut2[i] = go; lut3[i] = bo; } else { - Color::hsv2rgb(float(nextY), 1.f, 1.f, r, g, b); + Color::hsv2rgb (float (nextY), 1.f, 1.f, r, g, b); lut1[i] = r; lut2[i] = g; lut3[i] = b; @@ -1599,20 +1937,20 @@ void ColorGradientCurve::SetRGB(const Curve *pCurve, const double xyz_rgb[3][3], */ } -void ColorGradientCurve::SetRGB(const std::vector &curvePoints, const double xyz_rgb[3][3], const double rgb_xyz[3][3]) +void ColorGradientCurve::SetRGB (const std::vector &curvePoints, const double xyz_rgb[3][3], const double rgb_xyz[3][3]) { std::unique_ptr tcurve; if (!curvePoints.empty() && curvePoints[0] > FCT_Linear && curvePoints[0] < FCT_Unchanged) { - tcurve = std::unique_ptr(new FlatCurve(curvePoints, false, CURVES_MIN_POLY_POINTS / 2)); + tcurve = std::unique_ptr (new FlatCurve (curvePoints, false, CURVES_MIN_POLY_POINTS / 2)); } if (tcurve) { - SetRGB(tcurve.get(), xyz_rgb, rgb_xyz); + SetRGB (tcurve.get(), xyz_rgb, rgb_xyz); } } -void ColorGradientCurve::getVal(float index, float &r, float &g, float &b) const +void ColorGradientCurve::getVal (float index, float &r, float &g, float &b) const { r = lut1[index * 500.f]; g = lut2[index * 500.f]; @@ -1620,15 +1958,15 @@ void ColorGradientCurve::getVal(float index, float &r, float &g, float &b) const } // this is a generic cubic spline implementation, to clean up we could probably use something already existing elsewhere -void PerceptualToneCurve::cubic_spline(const float x[], const float y[], const int len, const float out_x[], float out_y[], const int out_len) +void PerceptualToneCurve::cubic_spline (const float x[], const float y[], const int len, const float out_x[], float out_y[], const int out_len) { int i, j; - float **A = (float **)malloc(2 * len * sizeof(*A)); - float *As = (float *)calloc(1, 2 * len * 2 * len * sizeof(*As)); - float *b = (float *)calloc(1, 2 * len * sizeof(*b)); - float *c = (float *)calloc(1, 2 * len * sizeof(*c)); - float *d = (float *)calloc(1, 2 * len * sizeof(*d)); + float **A = (float **)malloc (2 * len * sizeof (*A)); + float *As = (float *)calloc (1, 2 * len * 2 * len * sizeof (*As)); + float *b = (float *)calloc (1, 2 * len * sizeof (*b)); + float *c = (float *)calloc (1, 2 * len * sizeof (*c)); + float *d = (float *)calloc (1, 2 * len * sizeof (*d)); for (i = 0; i < 2 * len; i++) { A[i] = &As[2 * len * i]; @@ -1650,18 +1988,18 @@ void PerceptualToneCurve::cubic_spline(const float x[], const float y[], const i A[i][len - 1] = 6 * (b[i + 1] - b[i]); } - for(i = 1; i < len - 2; i++) { + for (i = 1; i < len - 2; i++) { float v = A[i + 1][i] / A[i][i]; - for(j = 1; j <= len - 1; j++) { + for (j = 1; j <= len - 1; j++) { A[i + 1][j] -= v * A[i][j]; } } - for(i = len - 2; i > 0; i--) { + for (i = len - 2; i > 0; i--) { float acc = 0; - for(j = i; j <= len - 2; j++) { + for (j = i; j <= len - 2; j++) { acc += A[i][j] * c[j]; } @@ -1685,35 +2023,35 @@ void PerceptualToneCurve::cubic_spline(const float x[], const float y[], const i out_y[i] = y_out; } - free(A); - free(As); - free(b); - free(c); - free(d); + free (A); + free (As); + free (b); + free (c); + free (d); } // generic function for finding minimum of f(x) in the a-b range using the interval halving method -float PerceptualToneCurve::find_minimum_interval_halving(float (*func)(float x, void *arg), void *arg, float a, float b, float tol, int nmax) +float PerceptualToneCurve::find_minimum_interval_halving (float (*func) (float x, void *arg), void *arg, float a, float b, float tol, int nmax) { float L = b - a; float x = (a + b) * 0.5; for (int i = 0; i < nmax; i++) { - float f_x = func(x, arg); + float f_x = func (x, arg); if ((b - a) * 0.5 < tol) { return x; } float x1 = a + L / 4; - float f_x1 = func(x1, arg); + float f_x1 = func (x1, arg); if (f_x1 < f_x) { b = x; x = x1; } else { float x2 = b - L / 4; - float f_x2 = func(x2, arg); + float f_x2 = func (x2, arg); if (f_x2 < f_x) { a = x; @@ -1734,7 +2072,7 @@ struct find_tc_slope_fun_arg { const ToneCurve * tc; }; -float PerceptualToneCurve::find_tc_slope_fun(float k, void *arg) +float PerceptualToneCurve::find_tc_slope_fun (float k, void *arg) { struct find_tc_slope_fun_arg *a = (struct find_tc_slope_fun_arg *)arg; float areasum = 0; @@ -1742,7 +2080,7 @@ float PerceptualToneCurve::find_tc_slope_fun(float k, void *arg) for (int i = 0; i < steps; i++) { float x = 0.1 + ((float)i / (steps - 1)) * 0.5; // testing (sRGB) range [0.1 - 0.6], ie ignore highligths and dark shadows - float y = CurveFactory::gamma2(a->tc->lutToneCurve[CurveFactory::igamma2(x) * 65535] / 65535.0); + float y = CurveFactory::gamma2 (a->tc->lutToneCurve[CurveFactory::igamma2 (x) * 65535] / 65535.0); float y1 = k * x; if (y1 > 1) { @@ -1755,7 +2093,7 @@ float PerceptualToneCurve::find_tc_slope_fun(float k, void *arg) return areasum; } -float PerceptualToneCurve::get_curve_val(float x, float range[2], float lut[], size_t lut_size) +float PerceptualToneCurve::get_curve_val (float x, float range[2], float lut[], size_t lut_size) { float xm = (x - range[0]) / (range[1] - range[0]) * (lut_size - 1); @@ -1781,7 +2119,7 @@ float PerceptualToneCurve::calculateToneCurveContrastValue() const // Note: the analysis is made on the gamma encoded curve, as the LUT is linear we make backwards gamma to struct find_tc_slope_fun_arg arg = { this }; - float k = find_minimum_interval_halving(find_tc_slope_fun, &arg, 0.1, 5.0, 0.01, 20); // normally found in 8 iterations + float k = find_minimum_interval_halving (find_tc_slope_fun, &arg, 0.1, 5.0, 0.01, 20); // normally found in 8 iterations //fprintf(stderr, "average slope: %f\n", k); float maxslope = 0; @@ -1790,11 +2128,11 @@ float PerceptualToneCurve::calculateToneCurveContrastValue() const const float xd = 0.07; const float tx[] = { 0.30, 0.35, 0.40, 0.45 }; // we only look in the midtone range - for (int i = 0; i < sizeof(tx) / sizeof(tx[0]); i++) { + for (int i = 0; i < sizeof (tx) / sizeof (tx[0]); i++) { float x0 = tx[i] - xd; - float y0 = CurveFactory::gamma2(lutToneCurve[CurveFactory::igamma2(x0) * 65535.f] / 65535.f) - k * x0; + float y0 = CurveFactory::gamma2 (lutToneCurve[CurveFactory::igamma2 (x0) * 65535.f] / 65535.f) - k * x0; float x1 = tx[i] + xd; - float y1 = CurveFactory::gamma2(lutToneCurve[CurveFactory::igamma2(x1) * 65535.f] / 65535.f) - k * x1; + float y1 = CurveFactory::gamma2 (lutToneCurve[CurveFactory::igamma2 (x1) * 65535.f] / 65535.f) - k * x1; float slope = 1.0 + (y1 - y0) / (x1 - x0); if (slope > maxslope) { @@ -1807,11 +2145,11 @@ float PerceptualToneCurve::calculateToneCurveContrastValue() const { const float tx[] = { 0.20, 0.25, 0.50, 0.55 }; // we only look in the midtone range - for (int i = 0; i < sizeof(tx) / sizeof(tx[0]); i++) { + for (int i = 0; i < sizeof (tx) / sizeof (tx[0]); i++) { float x0 = tx[i] - xd; - float y0 = CurveFactory::gamma2(lutToneCurve[CurveFactory::igamma2(x0) * 65535.f] / 65535.f) - k * x0; + float y0 = CurveFactory::gamma2 (lutToneCurve[CurveFactory::igamma2 (x0) * 65535.f] / 65535.f) - k * x0; float x1 = tx[i] + xd; - float y1 = CurveFactory::gamma2(lutToneCurve[CurveFactory::igamma2(x1) * 65535.f] / 65535.f) - k * x1; + float y1 = CurveFactory::gamma2 (lutToneCurve[CurveFactory::igamma2 (x1) * 65535.f] / 65535.f) - k * x1; float slope = 1.0 + (y1 - y0) / (x1 - x0); if (slope > e_maxslope) { @@ -1826,7 +2164,7 @@ float PerceptualToneCurve::calculateToneCurveContrastValue() const return maxslope; } -void PerceptualToneCurve::Apply(float &r, float &g, float &b, PerceptualToneCurveState & state) const +void PerceptualToneCurve::Apply (float &r, float &g, float &b, PerceptualToneCurveState & state) const { float x, y, z; @@ -1840,11 +2178,11 @@ void PerceptualToneCurve::Apply(float &r, float &g, float &b, PerceptualToneCurv b = newb; } - const AdobeToneCurve& adobeTC = static_cast((const ToneCurve&) * this); + const AdobeToneCurve& adobeTC = static_cast ((const ToneCurve&) * this); float ar = r; float ag = g; float ab = b; - adobeTC.Apply(ar, ag, ab); + adobeTC.Apply (ar, ag, ab); if (ar >= 65535.f && ag >= 65535.f && ab >= 65535.f) { // clip fast path, will also avoid strange colors of clipped highlights @@ -1867,22 +2205,22 @@ void PerceptualToneCurve::Apply(float &r, float &g, float &b, PerceptualToneCurv float oldLuminance = r * Yr + g * Yg + b * Yb; float newLuminance = ar * Yr + ag * Yg + ab * Yb; float Lcoef = newLuminance / oldLuminance; - r = LIM(r * Lcoef, 0.f, 65535.f); - g = LIM(g * Lcoef, 0.f, 65535.f); - b = LIM(b * Lcoef, 0.f, 65535.f); + r = LIM (r * Lcoef, 0.f, 65535.f); + g = LIM (g * Lcoef, 0.f, 65535.f); + b = LIM (b * Lcoef, 0.f, 65535.f); // move to JCh so we can modulate chroma based on the global contrast-related chroma scaling factor - Color::Prophotoxyz(r, g, b, x, y, z); + Color::Prophotoxyz (r, g, b, x, y, z); float J, C, h; - Ciecam02::xyz2jch_ciecam02float( J, C, h, - aw, fl, - x * 0.0015259022f, y * 0.0015259022f, z * 0.0015259022f, - xw, yw, zw, - c, nc, pow1, nbb, ncb, cz, d); + Ciecam02::xyz2jch_ciecam02float ( J, C, h, + aw, fl, + x * 0.0015259022f, y * 0.0015259022f, z * 0.0015259022f, + xw, yw, zw, + c, nc, pow1, nbb, ncb, cz, d); - if (!isfinite(J) || !isfinite(C) || !isfinite(h)) { + if (!isfinite (J) || !isfinite (C) || !isfinite (h)) { // this can happen for dark noise colors or colors outside human gamut. Then we just return the curve's result. if (!state.isProphoto) { float newr = state.Prophoto2Working[0][0] * r + state.Prophoto2Working[0][1] * g + state.Prophoto2Working[0][2] * b; @@ -1914,9 +2252,9 @@ void PerceptualToneCurve::Apply(float &r, float &g, float &b, PerceptualToneCurv float x = (C - lolim) / (hilim - lolim); // x = [0..1], 0 at lolim, 1 at hilim if (x < 0.5f) { - x = 2.f * SQR(x); + x = 2.f * SQR (x); } else { - x = 1.f - 2.f * SQR(1 - x); + x = 1.f - 2.f * SQR (1 - x); } saturated_scale_factor = (1.f - x) + saturated_scale_factor * x; @@ -1942,9 +2280,9 @@ void PerceptualToneCurve::Apply(float &r, float &g, float &b, PerceptualToneCurv float x = (nL - lolim) / (hilim - lolim); // x = [0..1], 0 at lolim, 1 at hilim if (x < 0.5f) { - x = 2.f * SQR(x); + x = 2.f * SQR (x); } else { - x = 1.f - 2.f * SQR(1 - x); + x = 1.f - 2.f * SQR (1 - x); } dark_scale_factor = dark_scale_factor * (1.0f - x) + x; @@ -1968,9 +2306,9 @@ void PerceptualToneCurve::Apply(float &r, float &g, float &b, PerceptualToneCurv float x = (J - lolim) / (hilim - lolim); if (x < 0.5f) { - x = 2.f * SQR(x); + x = 2.f * SQR (x); } else { - x = 1.f - 2.f * SQR(1 - x); + x = 1.f - 2.f * SQR (1 - x); } dark_scale_factor = dark_scale_factor * (1.f - x) + x; @@ -1983,12 +2321,12 @@ void PerceptualToneCurve::Apply(float &r, float &g, float &b, PerceptualToneCurv C *= cmul; - Ciecam02::jch2xyz_ciecam02float( x, y, z, - J, C, h, - xw, yw, zw, - f, c, nc, 1, pow1, nbb, ncb, fl, cz, d, aw ); + Ciecam02::jch2xyz_ciecam02float ( x, y, z, + J, C, h, + xw, yw, zw, + f, c, nc, 1, pow1, nbb, ncb, fl, cz, d, aw ); - if (!isfinite(x) || !isfinite(y) || !isfinite(z)) { + if (!isfinite (x) || !isfinite (y) || !isfinite (z)) { // can happen for colors on the rim of being outside gamut, that worked without chroma scaling but not with. Then we return only the curve's result. if (!state.isProphoto) { float newr = state.Prophoto2Working[0][0] * r + state.Prophoto2Working[0][1] * g + state.Prophoto2Working[0][2] * b; @@ -2002,13 +2340,13 @@ void PerceptualToneCurve::Apply(float &r, float &g, float &b, PerceptualToneCurv return; } - Color::xyz2Prophoto(x, y, z, r, g, b); + Color::xyz2Prophoto (x, y, z, r, g, b); r *= 655.35f; g *= 655.35f; b *= 655.35f; - r = LIM(r, 0.f, 65535.f); - g = LIM(g, 0.f, 65535.f); - b = LIM(b, 0.f, 65535.f); + r = LIM (r, 0.f, 65535.f); + g = LIM (g, 0.f, 65535.f); + b = LIM (b, 0.f, 65535.f); { // limit saturation increase in rgb space to avoid severe clipping and flattening in extreme highlights @@ -2017,8 +2355,8 @@ void PerceptualToneCurve::Apply(float &r, float &g, float &b, PerceptualToneCurv // saturation greatly, but desaturates extreme highlights and thus provide a smooth transition to // the white point. However the desaturation effect is quite strong so we make a weighting float ah, as, av, h, s, v; - Color::rgb2hsv(ar, ag, ab, ah, as, av); - Color::rgb2hsv(r, g, b, h, s, v); + Color::rgb2hsv (ar, ag, ab, ah, as, av); + Color::rgb2hsv (r, g, b, h, s, v); float sat_scale = as <= 0.f ? 1.f : s / as; // saturation scale compared to Adobe curve float keep = 0.2f; @@ -2033,9 +2371,9 @@ void PerceptualToneCurve::Apply(float &r, float &g, float &b, PerceptualToneCurv float x = (sat_scale - lolim) / (hilim - lolim); // x = [0..1], 0 at lolim, 1 at hilim if (x < 0.5f) { - x = 2.f * SQR(x); + x = 2.f * SQR (x); } else { - x = 1.f - 2.f * SQR(1 - x); + x = 1.f - 2.f * SQR (1 - x); } keep = (1.f - x) + keep * x; @@ -2079,9 +2417,9 @@ void PerceptualToneCurve::init() c = 0.69f; nc = 1.00f; - Ciecam02::initcam1float(gamut, yb, 1.f, f, la, xw, yw, zw, n, d, nbb, ncb, - cz, aw, wh, pfl, fl, c); - pow1 = pow_F( 1.64f - pow_F( 0.29f, n ), 0.73f ); + Ciecam02::initcam1float (gamut, yb, 1.f, f, la, xw, yw, zw, n, d, nbb, ncb, + cz, aw, wh, pfl, fl, c); + pow1 = pow_F ( 1.64f - pow_F ( 0.29f, n ), 0.73f ); { // init contrast-value-to-chroma-scaling conversion curve @@ -2105,7 +2443,7 @@ void PerceptualToneCurve::init() 2.00, 1.22 // highest contrast }; - const size_t in_len = sizeof(p) / sizeof(p[0]) / 2; + const size_t in_len = sizeof (p) / sizeof (p[0]) / 2; float in_x[in_len]; float in_y[in_len]; @@ -2114,25 +2452,25 @@ void PerceptualToneCurve::init() in_y[i] = p[2 * i + 1]; } - const size_t out_len = sizeof(cf) / sizeof(cf[0]); + const size_t out_len = sizeof (cf) / sizeof (cf[0]); float out_x[out_len]; for (size_t i = 0; i < out_len; i++) { out_x[i] = in_x[0] + (in_x[in_len - 1] - in_x[0]) * (float)i / (out_len - 1); } - cubic_spline(in_x, in_y, in_len, out_x, cf, out_len); + cubic_spline (in_x, in_y, in_len, out_x, cf, out_len); cf_range[0] = in_x[0]; cf_range[1] = in_x[in_len - 1]; } } -void PerceptualToneCurve::initApplyState(PerceptualToneCurveState & state, Glib::ustring workingSpace) const +void PerceptualToneCurve::initApplyState (PerceptualToneCurveState & state, Glib::ustring workingSpace) const { // Get the curve's contrast value, and convert to a chroma scaling const float contrast_value = calculateToneCurveContrastValue(); - state.cmul_contrast = get_curve_val(contrast_value, cf_range, cf, sizeof(cf) / sizeof(cf[0])); + state.cmul_contrast = get_curve_val (contrast_value, cf_range, cf, sizeof (cf) / sizeof (cf[0])); //fprintf(stderr, "contrast value: %f => chroma scaling %f\n", contrast_value, state.cmul_contrast); // Create state for converting to/from prophoto (if necessary) @@ -2140,8 +2478,8 @@ void PerceptualToneCurve::initApplyState(PerceptualToneCurveState & state, Glib: state.isProphoto = true; } else { state.isProphoto = false; - TMatrix Work = iccStore->workingSpaceMatrix(workingSpace); - memset(state.Working2Prophoto, 0, sizeof(state.Working2Prophoto)); + TMatrix Work = iccStore->workingSpaceMatrix (workingSpace); + memset (state.Working2Prophoto, 0, sizeof (state.Working2Prophoto)); for (int i = 0; i < 3; i++) for (int j = 0; j < 3; j++) @@ -2150,7 +2488,7 @@ void PerceptualToneCurve::initApplyState(PerceptualToneCurveState & state, Glib: } Work = iccStore->workingSpaceInverseMatrix (workingSpace); - memset(state.Prophoto2Working, 0, sizeof(state.Prophoto2Working)); + memset (state.Prophoto2Working, 0, sizeof (state.Prophoto2Working)); for (int i = 0; i < 3; i++) for (int j = 0; j < 3; j++) diff --git a/rtengine/curves.h b/rtengine/curves.h index 348772075..773fecc53 100644 --- a/rtengine/curves.h +++ b/rtengine/curves.h @@ -67,13 +67,13 @@ protected: double k = sqrt ((m1 - 1.0) * (m1 - m2) * 0.5) / (1.0 - m2); double l = (m1 - m2) / (1.0 - m2) + k; - double lx = xlog(x); - return m2 * x + (1.0 - m2) * (2.0 - xexp(k * lx)) * xexp(l * lx); + double lx = xlog (x); + return m2 * x + (1.0 - m2) * (2.0 - xexp (k * lx)) * xexp (l * lx); } // basic concave function between (0,0) and (1,1). m1 and m2 controls the slope at the start and end point static inline double baseu (double x, double m1, double m2) { - return 1.0 - basel(1.0 - x, m1, m2); + return 1.0 - basel (1.0 - x, m1, m2); } // convex curve between (0,0) and (1,1) with slope m at (0,0). hr controls the highlight recovery static inline double cupper (double x, double m, double hr) @@ -93,12 +93,12 @@ protected: return x * m; } - return 1.0 - hr + hr * baseu((x - x1) / hr, m, 0); + return 1.0 - hr + hr * baseu ((x - x1) / hr, m, 0); } // concave curve between (0,0) and (1,1) with slope m at (1,1). sr controls the shadow recovery static inline double clower (double x, double m, double sr) { - return 1.0 - cupper(1.0 - x, m, sr); + return 1.0 - cupper (1.0 - x, m, sr); } // convex curve between (0,0) and (1,1) with slope m at (0,0). hr controls the highlight recovery static inline double cupper2 (double x, double m, double hr) @@ -114,7 +114,7 @@ protected: return x * m; } - return 1.0 - hr + hr * baseu((x - x1) / hr, m, 0.3 * hr); + return 1.0 - hr + hr * baseu ((x - x1) / hr, m, 0.3 * hr); } static inline double clower2 (double x, double m, double sr) { @@ -125,7 +125,7 @@ protected: return 1 - (1 - x) * m; } else { double y1 = 1 - (1 - x1) * m; - return y1 + m * (x - x1) - (1 - m) * SQR(SQR(1 - x / x1)); + return y1 + m * (x - x1) - (1 - m) * SQR (SQR (1 - x / x1)); } } // tone curve base. a: slope (from exp.comp.), b: black point normalized by 65535, @@ -140,7 +140,7 @@ protected: if (x > m) { return y + (x - m) * slope; //value on straight line between (m,y) and (1,1) } else { - return y * clower2(x / m, slope * m / y, 2.0 - sr); + return y * clower2 (x / m, slope * m / y, 2.0 - sr); } } else { double slope = a / (1.0 - b); @@ -150,7 +150,7 @@ protected: if (x <= m) { return b == 0 ? x * slope : clower (x / m, slope * m / y, sr) * y; } else if (a * D > 1.0) { - return y + (1.0 - y) * cupper2((x - m) / (D - m), slope * (D - m) / (1.0 - y), hr); + return y + (1.0 - y) * cupper2 ((x - m) / (D - m), slope * (D - m) / (1.0 - y), hr); } else { return y + (x - m) * slope; } @@ -169,7 +169,7 @@ protected: if (x > m) { return y + (x - m) * slope; //value on straight line between (m,y) and (1,1) } else { - return y * clower2(x / m, slope * m / y, 2.0 - sr); + return y * clower2 (x / m, slope * m / y, 2.0 - sr); } } else { double slope = 1.0 / (1.0 - b); @@ -193,18 +193,18 @@ public: //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // accurately determine value from integer array with float as index //linearly interpolate from ends of range if arg is out of bounds - static inline float interp(int *array, float f) + static inline float interp (int *array, float f) { - int index = CLIPI(floor(f)); - float part = (float)((f) - index) * (float)(array[index + 1] - array[index]); + int index = CLIPI (floor (f)); + float part = (float) ((f) - index) * (float) (array[index + 1] - array[index]); return (float)array[index] + part; } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // accurately determine value from float array with float as index //linearly interpolate from ends of range if arg is out of bounds - static inline float flinterp(float *array, float f) + static inline float flinterp (float *array, float f) { - int index = CLIPI(floor(f)); + int index = CLIPI (floor (f)); float part = ((f) - (float)index) * (array[index + 1] - array[index]); return array[index] + part; } @@ -215,44 +215,44 @@ public: // standard srgb gamma and its inverse static inline double gamma2 (double x) { - return x <= 0.00304 ? x * 12.92 : 1.055 * exp(log(x) / sRGBGammaCurve) - 0.055; + return x <= 0.00304 ? x * 12.92 : 1.055 * exp (log (x) / sRGBGammaCurve) - 0.055; } static inline double igamma2 (double x) { - return x <= 0.03928 ? x / 12.92 : exp(log((x + 0.055) / 1.055) * sRGBGammaCurve); + return x <= 0.03928 ? x / 12.92 : exp (log ((x + 0.055) / 1.055) * sRGBGammaCurve); } static inline float gamma2 (float x) { - return x <= 0.00304 ? x * 12.92 : 1.055 * expf(logf(x) / sRGBGammaCurve) - 0.055; + return x <= 0.00304 ? x * 12.92 : 1.055 * expf (logf (x) / sRGBGammaCurve) - 0.055; } static inline float igamma2 (float x) { - return x <= 0.03928 ? x / 12.92 : expf(logf((x + 0.055) / 1.055) * sRGBGammaCurve); + return x <= 0.03928 ? x / 12.92 : expf (logf ((x + 0.055) / 1.055) * sRGBGammaCurve); } // gamma function with adjustable parameters static inline double gamma (double x, double gamma, double start, double slope, double mul, double add) { - return (x <= start ? x*slope : exp(log(x) / gamma) * mul - add); + return (x <= start ? x*slope : exp (log (x) / gamma) * mul - add); } static inline double igamma (double x, double gamma, double start, double slope, double mul, double add) { - return (x <= start * slope ? x / slope : exp(log((x + add) / mul) * gamma) ); + return (x <= start * slope ? x / slope : exp (log ((x + add) / mul) * gamma) ); } static inline float gamma (float x, float gamma, float start, float slope, float mul, float add) { - return (x <= start ? x*slope : xexpf(xlogf(x) / gamma) * mul - add); + return (x <= start ? x*slope : xexpf (xlogf (x) / gamma) * mul - add); } static inline float igamma (float x, float gamma, float start, float slope, float mul, float add) { - return (x <= start * slope ? x / slope : xexpf(xlogf((x + add) / mul) * gamma) ); + return (x <= start * slope ? x / slope : xexpf (xlogf ((x + add) / mul) * gamma) ); } #ifdef __SSE2__ static inline vfloat igamma (vfloat x, vfloat gamma, vfloat start, vfloat slope, vfloat mul, vfloat add) { #if !defined(__clang__) - return (x <= start * slope ? x / slope : xexpf(xlogf((x + add) / mul) * gamma) ); + return (x <= start * slope ? x / slope : xexpf (xlogf ((x + add) / mul) * gamma) ); #else - return vself(vmaskf_le(x, start * slope), x / slope, xexpf(xlogf((x + add) / mul) * gamma)); + return vself (vmaskf_le (x, start * slope), x / slope, xexpf (xlogf ((x + add) / mul) * gamma)); #endif } #endif @@ -261,19 +261,19 @@ public: if (comp > 0.0) { float val = level + (hlrange - 65536.0); - if(val == 0.0f) { // to avoid division by zero + if (val == 0.0f) { // to avoid division by zero val = 0.000001f; } float Y = val * exp_scale / hlrange; Y *= comp; - if(Y <= -1.0) { // to avoid log(<=0) + if (Y <= -1.0) { // to avoid log(<=0) Y = -.999999f; } float R = hlrange / (val * comp); - return log(1.0 + Y) * R; + return log (1.0 + Y) * R; } else { return exp_scale; } @@ -296,9 +296,18 @@ public: static void curveToning ( const std::vector& curvePoints, LUTf & ToningCurve, int skip); + static void curveLocal ( bool & locallutili, const std::vector& curvePoints, LUTf & LocalLCurve, int skip); + static void complexsgnCurve ( bool & autili, bool & butili, bool & ccutili, bool & clcutili, const std::vector& acurvePoints, const std::vector& bcurvePoints, const std::vector& cccurvePoints, const std::vector& lccurvePoints, LUTf & aoutCurve, LUTf & boutCurve, LUTf & satCurve, LUTf & lhskCurve, int skip = 1); + + static void localLCurve (double br, double contr,/* const std::vector& curvePoints,*/ LUTu & histogram, LUTf & outCurve, int skip, bool & utili); + + static void updatechroma ( + const std::vector& cccurvePoints, + LUTu & histogramC, LUTu & outBeforeCCurveHistogramC,//for chroma + int skip = 1); static void complexLCurve (double br, double contr, const std::vector& curvePoints, const LUTu & histogram, LUTf & outCurve, LUTu & outBeforeCCurveHistogram, int skip, bool & utili); static void curveLightBrightColor ( @@ -367,7 +376,7 @@ protected: } static inline double pfull (double x, double prot, double sh, double hl) { - return (1 - sh) * (1 - hl) * p00(x, prot) + sh * hl * p11(x, prot) + (1 - sh) * hl * p01(x, prot) + sh * (1 - hl) * p10(x, prot); + return (1 - sh) * (1 - hl) * p00 (x, prot) + sh * hl * p11 (x, prot) + (1 - sh) * hl * p01 (x, prot) + sh * (1 - hl) * p10 (x, prot); } void fillHash(); @@ -378,7 +387,7 @@ public: virtual ~Curve () {}; void AddPolygons (); int getSize () const; // return the number of control points - void getControlPoint(int cpNum, double &x, double &y) const; + void getControlPoint (int cpNum, double &x, double &y) const; virtual double getVal (double t) const = 0; virtual void getVal (const std::vector& t, std::vector& res) const = 0; @@ -436,16 +445,16 @@ class RetinextransmissionCurve { private: LUTf luttransmission; // 0xffff range - void Set(const Curve &pCurve); + void Set (const Curve &pCurve); public: virtual ~RetinextransmissionCurve() {}; RetinextransmissionCurve(); void Reset(); - void Set(const Curve *pCurve); - void Set(const std::vector &curvePoints); - float operator[](float index) const + void Set (const Curve *pCurve); + void Set (const std::vector &curvePoints); + float operator[] (float index) const { return luttransmission[index]; } @@ -460,16 +469,16 @@ class RetinexgaintransmissionCurve { private: LUTf lutgaintransmission; // 0xffff range - void Set(const Curve &pCurve); + void Set (const Curve &pCurve); public: virtual ~RetinexgaintransmissionCurve() {}; RetinexgaintransmissionCurve(); void Reset(); - void Set(const Curve *pCurve); - void Set(const std::vector &curvePoints); - float operator[](float index) const + void Set (const Curve *pCurve); + void Set (const std::vector &curvePoints); + float operator[] (float index) const { return lutgaintransmission[index]; } @@ -490,7 +499,7 @@ public: virtual ~ToneCurve() {}; void Reset(); - void Set(const Curve &pCurve, float gamma = 0); + void Set (const Curve &pCurve, float gamma = 0); operator bool (void) const { return lutToneCurve; @@ -505,8 +514,8 @@ public: virtual ~OpacityCurve() {}; void Reset(); - void Set(const Curve *pCurve); - void Set(const std::vector &curvePoints, bool &opautili); + void Set (const Curve *pCurve); + void Set (const std::vector &curvePoints, bool &opautili); // TODO: transfer this method to the Color class... float blend (float x, float lower, float upper) const @@ -527,11 +536,97 @@ public: } }; +class LocLHCurve +{ +private: + LUTf lutLocLHCurve; // 0xffff range + void Set (const Curve &pCurve); + +public: + float sum; + + virtual ~LocLHCurve() {}; + LocLHCurve(); + void Reset(); + void Set (const std::vector &curvePoints); + float getSum() const + { + return sum; + } + + float operator[] (float index) const + { + return lutLocLHCurve[index]; + } + operator bool (void) const + { + return lutLocLHCurve; + } +}; + + +class LocretigainCurve +{ +private: + LUTf lutLocretigainCurve; // 0xffff range + void Set (const Curve &pCurve); + +public: + float sum; + + virtual ~LocretigainCurve() {}; + LocretigainCurve(); + void Reset(); + void Set (const std::vector &curvePoints); + float getSum() const + { + return sum; + } + + float operator[] (float index) const + { + return lutLocretigainCurve[index]; + } + operator bool (void) const + { + return lutLocretigainCurve; + } +}; + +class LocretigainCurverab +{ +private: + LUTf lutLocretigainCurverab; // 0xffff range + void Set (const Curve &pCurve); + +public: + float sum; + + virtual ~LocretigainCurverab() {}; + LocretigainCurverab(); + void Reset(); + void Set (const std::vector &curvePoints); + float getSum() const + { + return sum; + } + + float operator[] (float index) const + { + return lutLocretigainCurverab[index]; + } + operator bool (void) const + { + return lutLocretigainCurverab; + } +}; + + class WavCurve { private: LUTf lutWavCurve; // 0xffff range - void Set(const Curve &pCurve); + void Set (const Curve &pCurve); public: float sum; @@ -539,13 +634,13 @@ public: virtual ~WavCurve() {}; WavCurve(); void Reset(); - void Set(const std::vector &curvePoints); + void Set (const std::vector &curvePoints); float getSum() const { return sum; } - float operator[](float index) const + float operator[] (float index) const { return lutWavCurve[index]; } @@ -559,15 +654,15 @@ class WavOpacityCurveRG { private: LUTf lutOpacityCurveRG; // 0xffff range - void Set(const Curve &pCurve); + void Set (const Curve &pCurve); public: virtual ~WavOpacityCurveRG() {}; WavOpacityCurveRG(); void Reset(); // void Set(const std::vector &curvePoints, bool &opautili); - void Set(const std::vector &curvePoints); - float operator[](float index) const + void Set (const std::vector &curvePoints); + float operator[] (float index) const { return lutOpacityCurveRG[index]; } @@ -581,16 +676,16 @@ class WavOpacityCurveBY { private: LUTf lutOpacityCurveBY; // 0xffff range - void Set(const Curve &pCurve); + void Set (const Curve &pCurve); public: virtual ~WavOpacityCurveBY() {}; WavOpacityCurveBY(); void Reset(); - void Set(const Curve *pCurve); - void Set(const std::vector &curvePoints); - float operator[](float index) const + void Set (const Curve *pCurve); + void Set (const std::vector &curvePoints); + float operator[] (float index) const { return lutOpacityCurveBY[index]; } @@ -604,16 +699,16 @@ class WavOpacityCurveW { private: LUTf lutOpacityCurveW; // 0xffff range - void Set(const Curve &pCurve); + void Set (const Curve &pCurve); public: virtual ~WavOpacityCurveW() {}; WavOpacityCurveW(); void Reset(); - void Set(const Curve *pCurve); - void Set(const std::vector &curvePoints); - float operator[](float index) const + void Set (const Curve *pCurve); + void Set (const std::vector &curvePoints); + float operator[] (float index) const { return lutOpacityCurveW[index]; } @@ -628,16 +723,16 @@ class WavOpacityCurveWL { private: LUTf lutOpacityCurveWL; // 0xffff range - void Set(const Curve &pCurve); + void Set (const Curve &pCurve); public: virtual ~WavOpacityCurveWL() {}; WavOpacityCurveWL(); void Reset(); - void Set(const Curve *pCurve); - void Set(const std::vector &curvePoints); - float operator[](float index) const + void Set (const Curve *pCurve); + void Set (const std::vector &curvePoints); + float operator[] (float index) const { return lutOpacityCurveWL[index]; } @@ -653,19 +748,19 @@ class NoiseCurve private: LUTf lutNoiseCurve; // 0xffff range float sum; - void Set(const Curve &pCurve); + void Set (const Curve &pCurve); public: virtual ~NoiseCurve() {}; NoiseCurve(); void Reset(); - void Set(const std::vector &curvePoints); + void Set (const std::vector &curvePoints); float getSum() const { return sum; } - float operator[](float index) const + float operator[] (float index) const { return lutNoiseCurve[index]; } @@ -687,10 +782,10 @@ public: virtual ~ColorGradientCurve() {}; void Reset(); - void SetXYZ(const Curve *pCurve, const double xyz_rgb[3][3], const double rgb_xyz[3][3], float satur, float lumin); - void SetXYZ(const std::vector &curvePoints, const double xyz_rgb[3][3], const double rgb_xyz[3][3], float satur, float lumin); - void SetRGB(const Curve *pCurve, const double xyz_rgb[3][3], const double rgb_xyz[3][3]); - void SetRGB(const std::vector &curvePoints, const double xyz_rgb[3][3], const double rgb_xyz[3][3]); + void SetXYZ (const Curve *pCurve, const double xyz_rgb[3][3], const double rgb_xyz[3][3], float satur, float lumin); + void SetXYZ (const std::vector &curvePoints, const double xyz_rgb[3][3], const double rgb_xyz[3][3], float satur, float lumin); + void SetRGB (const Curve *pCurve, const double xyz_rgb[3][3], const double rgb_xyz[3][3]); + void SetRGB (const std::vector &curvePoints, const double xyz_rgb[3][3], const double rgb_xyz[3][3]); /** * @brief Get the value of Red, Green and Blue corresponding to the requested index @@ -699,7 +794,7 @@ public: * @param g corresponding green value [0 ; 65535] (return value) * @param b corresponding blue value [0 ; 65535] (return value) */ - void getVal(float index, float &r, float &g, float &b) const; + void getVal (float index, float &r, float &g, float &b) const; operator bool (void) const { return lut1 && lut2 && lut3; @@ -714,7 +809,7 @@ public: virtual ~ColorAppearance() {}; void Reset(); - void Set(const Curve &pCurve); + void Set (const Curve &pCurve); operator bool (void) const { return lutColCurve; @@ -724,7 +819,7 @@ public: class Lightcurve : public ColorAppearance { public: - void Apply(float& Li) const; + void Apply (float& Li) const; }; //lightness curve @@ -739,7 +834,7 @@ inline void Lightcurve::Apply (float& Li) const class Brightcurve : public ColorAppearance { public: - void Apply(float& Br) const; + void Apply (float& Br) const; }; //brightness curve @@ -754,7 +849,7 @@ inline void Brightcurve::Apply (float& Br) const class Chromacurve : public ColorAppearance { public: - void Apply(float& Cr) const; + void Apply (float& Cr) const; }; //Chroma curve @@ -768,7 +863,7 @@ inline void Chromacurve::Apply (float& Cr) const class Saturcurve : public ColorAppearance { public: - void Apply(float& Sa) const; + void Apply (float& Sa) const; }; //Saturation curve @@ -783,7 +878,7 @@ inline void Saturcurve::Apply (float& Sa) const class Colorfcurve : public ColorAppearance { public: - void Apply(float& Cf) const; + void Apply (float& Cf) const; }; //Colorfullness curve @@ -799,56 +894,56 @@ inline void Colorfcurve::Apply (float& Cf) const class StandardToneCurve : public ToneCurve { public: - void Apply(float& r, float& g, float& b) const; + void Apply (float& r, float& g, float& b) const; }; class StandardToneCurvebw : public ToneCurve { public: - void Apply(float& r, float& g, float& b) const; + void Apply (float& r, float& g, float& b) const; }; class AdobeToneCurve : public ToneCurve { private: - void RGBTone(float& r, float& g, float& b) const; // helper for tone curve + void RGBTone (float& r, float& g, float& b) const; // helper for tone curve public: - void Apply(float& r, float& g, float& b) const; + void Apply (float& r, float& g, float& b) const; }; class AdobeToneCurvebw : public ToneCurve { private: - void RGBTone(float& r, float& g, float& b) const; // helper for tone curve + void RGBTone (float& r, float& g, float& b) const; // helper for tone curve public: - void Apply(float& r, float& g, float& b) const; + void Apply (float& r, float& g, float& b) const; }; class SatAndValueBlendingToneCurve : public ToneCurve { public: - void Apply(float& r, float& g, float& b) const; + void Apply (float& r, float& g, float& b) const; }; class SatAndValueBlendingToneCurvebw : public ToneCurve { public: - void Apply(float& r, float& g, float& b) const; + void Apply (float& r, float& g, float& b) const; }; class WeightedStdToneCurve : public ToneCurve { private: - float Triangle(float refX, float refY, float X2) const; + float Triangle (float refX, float refY, float X2) const; public: - void Apply(float& r, float& g, float& b) const; + void Apply (float& r, float& g, float& b) const; }; class LuminanceToneCurve : public ToneCurve { public: - void Apply(float& r, float& g, float& b) const; + void Apply (float& r, float& g, float& b) const; }; class PerceptualToneCurveState @@ -873,23 +968,23 @@ private: static float f, c, nc, yb, la, xw, yw, zw, gamut; static float n, d, nbb, ncb, cz, aw, wh, pfl, fl, pow1; - static void cubic_spline(const float x[], const float y[], const int len, const float out_x[], float out_y[], const int out_len); - static float find_minimum_interval_halving(float (*func)(float x, void *arg), void *arg, float a, float b, float tol, int nmax); - static float find_tc_slope_fun(float k, void *arg); - static float get_curve_val(float x, float range[2], float lut[], size_t lut_size); + static void cubic_spline (const float x[], const float y[], const int len, const float out_x[], float out_y[], const int out_len); + static float find_minimum_interval_halving (float (*func) (float x, void *arg), void *arg, float a, float b, float tol, int nmax); + static float find_tc_slope_fun (float k, void *arg); + static float get_curve_val (float x, float range[2], float lut[], size_t lut_size); float calculateToneCurveContrastValue() const; public: static void init(); - void initApplyState(PerceptualToneCurveState & state, Glib::ustring workingSpace) const; - void Apply(float& r, float& g, float& b, PerceptualToneCurveState & state) const; + void initApplyState (PerceptualToneCurveState & state, Glib::ustring workingSpace) const; + void Apply (float& r, float& g, float& b, PerceptualToneCurveState & state) const; }; class WeightedStdToneCurvebw : public ToneCurve { private: - float Triangle(float refX, float refY, float X2) const; + float Triangle (float refX, float refY, float X2) const; public: - void Apply(float& r, float& g, float& b) const; + void Apply (float& r, float& g, float& b) const; }; // Standard tone curve @@ -989,19 +1084,19 @@ inline void AdobeToneCurvebw::RGBTone (float& r, float& g, float& b) const } // Modifying the Luminance channel only -inline void LuminanceToneCurve::Apply(float &r, float &g, float &b) const +inline void LuminanceToneCurve::Apply (float &r, float &g, float &b) const { assert (lutToneCurve); float currLuminance = r * 0.2126729f + g * 0.7151521f + b * 0.0721750f; float newLuminance = lutToneCurve[currLuminance]; float coef = newLuminance / currLuminance; - r = LIM(r * coef, 0.f, 65535.f); - g = LIM(g * coef, 0.f, 65535.f); - b = LIM(b * coef, 0.f, 65535.f); + r = LIM (r * coef, 0.f, 65535.f); + g = LIM (g * coef, 0.f, 65535.f); + b = LIM (b * coef, 0.f, 65535.f); } -inline float WeightedStdToneCurve::Triangle(float a, float a1, float b) const +inline float WeightedStdToneCurve::Triangle (float a, float a1, float b) const { if (a != b) { float b1; @@ -1018,7 +1113,7 @@ inline float WeightedStdToneCurve::Triangle(float a, float a1, float b) const return a1; } -inline float WeightedStdToneCurvebw::Triangle(float a, float a1, float b) const +inline float WeightedStdToneCurvebw::Triangle (float a, float a1, float b) const { if (a != b) { float b1; @@ -1044,20 +1139,20 @@ inline void WeightedStdToneCurve::Apply (float& r, float& g, float& b) const assert (lutToneCurve); float r1 = lutToneCurve[r]; - float g1 = Triangle(r, r1, g); - float b1 = Triangle(r, r1, b); + float g1 = Triangle (r, r1, g); + float b1 = Triangle (r, r1, b); float g2 = lutToneCurve[g]; - float r2 = Triangle(g, g2, r); - float b2 = Triangle(g, g2, b); + float r2 = Triangle (g, g2, r); + float b2 = Triangle (g, g2, b); float b3 = lutToneCurve[b]; - float r3 = Triangle(b, b3, r); - float g3 = Triangle(b, b3, g); + float r3 = Triangle (b, b3, r); + float g3 = Triangle (b, b3, g); - r = CLIP( r1 * 0.50f + r2 * 0.25f + r3 * 0.25f); - g = CLIP(g1 * 0.25f + g2 * 0.50f + g3 * 0.25f); - b = CLIP(b1 * 0.25f + b2 * 0.25f + b3 * 0.50f); + r = CLIP ( r1 * 0.50f + r2 * 0.25f + r3 * 0.25f); + g = CLIP (g1 * 0.25f + g2 * 0.50f + g3 * 0.25f); + b = CLIP (b1 * 0.25f + b2 * 0.25f + b3 * 0.50f); } inline void WeightedStdToneCurvebw::Apply (float& r, float& g, float& b) const @@ -1066,20 +1161,20 @@ inline void WeightedStdToneCurvebw::Apply (float& r, float& g, float& b) const assert (lutToneCurve); float r1 = lutToneCurve[r]; - float g1 = Triangle(r, r1, g); - float b1 = Triangle(r, r1, b); + float g1 = Triangle (r, r1, g); + float b1 = Triangle (r, r1, b); float g2 = lutToneCurve[g]; - float r2 = Triangle(g, g2, r); - float b2 = Triangle(g, g2, b); + float r2 = Triangle (g, g2, r); + float b2 = Triangle (g, g2, b); float b3 = lutToneCurve[b]; - float r3 = Triangle(b, b3, r); - float g3 = Triangle(b, b3, g); + float r3 = Triangle (b, b3, r); + float g3 = Triangle (b, b3, g); - r = CLIP( r1 * 0.50f + r2 * 0.25f + r3 * 0.25f); - g = CLIP(g1 * 0.25f + g2 * 0.50f + g3 * 0.25f); - b = CLIP(b1 * 0.25f + b2 * 0.25f + b3 * 0.50f); + r = CLIP ( r1 * 0.50f + r2 * 0.25f + r3 * 0.25f); + g = CLIP (g1 * 0.25f + g2 * 0.50f + g3 * 0.25f); + b = CLIP (b1 * 0.25f + b2 * 0.25f + b3 * 0.50f); } // Tone curve modifying the value channel only, preserving hue and saturation @@ -1100,19 +1195,19 @@ inline void SatAndValueBlendingToneCurve::Apply (float& r, float& g, float& b) c bool increase = newLum > lum; - Color::rgb2hsv(r, g, b, h, s, v); + Color::rgb2hsv (r, g, b, h, s, v); if (increase) { // Linearly targeting Value = 1 and Saturation = 0 float coef = (newLum - lum) / (65535.f - lum); float dV = (1.f - v) * coef; s *= 1.f - coef; - Color::hsv2rgb(h, s, v + dV, r, g, b); + Color::hsv2rgb (h, s, v + dV, r, g, b); } else { // Linearly targeting Value = 0 float coef = (lum - newLum) / lum ; float dV = v * coef; - Color::hsv2rgb(h, s, v - dV, r, g, b); + Color::hsv2rgb (h, s, v - dV, r, g, b); } } @@ -1132,19 +1227,19 @@ inline void SatAndValueBlendingToneCurvebw::Apply (float& r, float& g, float& b) bool increase = newLum > lum; - Color::rgb2hsv(r, g, b, h, s, v); + Color::rgb2hsv (r, g, b, h, s, v); if (increase) { // Linearly targeting Value = 1 and Saturation = 0 float coef = (newLum - lum) / (65535.f - lum); float dV = (1.f - v) * coef; s *= 1.f - coef; - Color::hsv2rgb(h, s, v + dV, r, g, b); + Color::hsv2rgb (h, s, v + dV, r, g, b); } else { // Linearly targeting Value = 0 float coef = (lum - newLum) / lum ; float dV = v * coef; - Color::hsv2rgb(h, s, v - dV, r, g, b); + Color::hsv2rgb (h, s, v - dV, r, g, b); } } diff --git a/rtengine/dcrop.cc b/rtengine/dcrop.cc index a90c78069..6a07d23cd 100644 --- a/rtengine/dcrop.cc +++ b/rtengine/dcrop.cc @@ -22,6 +22,11 @@ #include "mytime.h" #include "refreshmap.h" #include "rt_math.h" +#include +#include +#include +#include +//#include // "ceil" rounding #define SKIPS(a,b) ((a) / (b) + ((a) % (b) > 0)) @@ -31,15 +36,15 @@ namespace rtengine extern const Settings* settings; Crop::Crop (ImProcCoordinator* parent, EditDataProvider *editDataProvider, bool isDetailWindow) - : PipetteBuffer(editDataProvider), origCrop(nullptr), laboCrop(nullptr), labnCrop(nullptr), - cropImg(nullptr), cbuf_real(nullptr), cshmap(nullptr), transCrop(nullptr), cieCrop(nullptr), cbuffer(nullptr), - updating(false), newUpdatePending(false), skip(10), padding(0), - cropx(0), cropy(0), cropw(-1), croph(-1), - trafx(0), trafy(0), trafw(-1), trafh(-1), - rqcropx(0), rqcropy(0), rqcropw(-1), rqcroph(-1), - borderRequested(32), upperBorder(0), leftBorder(0), - cropAllocated(false), - cropImageListener(nullptr), parent(parent), isDetailWindow(isDetailWindow) + : PipetteBuffer (editDataProvider), origCrop (nullptr), laboCrop (nullptr), labnCrop (nullptr), + cropImg (nullptr), cbuf_real (nullptr), shbuf_real (nullptr), cshmap (nullptr), transCrop (nullptr), cieCrop (nullptr), cbuffer (nullptr), shbuffer (nullptr), + updating (false), newUpdatePending (false), skip (10), padding (0), + cropx (0), cropy (0), cropw (-1), croph (-1), + trafx (0), trafy (0), trafw (-1), trafh (-1), + rqcropx (0), rqcropy (0), rqcropw (-1), rqcroph (-1), + borderRequested (32), upperBorder (0), leftBorder (0), + cropAllocated (false), + cropImageListener (nullptr), parent (parent), isDetailWindow (isDetailWindow) { parent->crops.push_back (this); } @@ -47,7 +52,7 @@ Crop::Crop (ImProcCoordinator* parent, EditDataProvider *editDataProvider, bool Crop::~Crop () { - MyMutex::MyLock cropLock(cropMutex); + MyMutex::MyLock cropLock (cropMutex); std::vector::iterator i = std::find (parent->crops.begin(), parent->crops.end(), this); @@ -55,14 +60,14 @@ Crop::~Crop () parent->crops.erase (i); } - MyMutex::MyLock processingLock(parent->mProcessing); + MyMutex::MyLock processingLock (parent->mProcessing); freeAll (); } void Crop::destroy () { - MyMutex::MyLock lock(cropMutex); - MyMutex::MyLock processingLock(parent->mProcessing); + MyMutex::MyLock lock (cropMutex); + MyMutex::MyLock processingLock (parent->mProcessing); freeAll(); } @@ -70,7 +75,7 @@ void Crop::setListener (DetailedCropListener* il) { // We can make reads in the IF, because the mProcessing lock is only needed for change if (cropImageListener != il) { - MyMutex::MyLock lock(cropMutex); + MyMutex::MyLock lock (cropMutex); cropImageListener = il; } } @@ -85,9 +90,9 @@ EditUniqueID Crop::getCurrEditID() * Delete the edit image buffer if there's no subscriber anymore. * If allocation has to be done, it is deferred to Crop::update */ -void Crop::setEditSubscriber(EditSubscriber* newSubscriber) +void Crop::setEditSubscriber (EditSubscriber* newSubscriber) { - MyMutex::MyLock lock(cropMutex); + MyMutex::MyLock lock (cropMutex); // At this point, editCrop.dataProvider->currSubscriber is the old subscriber EditSubscriber *oldSubscriber = PipetteBuffer::dataProvider ? PipetteBuffer::dataProvider->getCurrSubscriber() : nullptr; @@ -113,7 +118,7 @@ void Crop::setEditSubscriber(EditSubscriber* newSubscriber) void Crop::update (int todo) { - MyMutex::MyLock cropLock(cropMutex); + MyMutex::MyLock cropLock (cropMutex); ProcParams& params = parent->params; // CropGUIListener* cropgl; @@ -153,16 +158,16 @@ void Crop::update (int todo) bool needstransform = parent->ipf.needsTransform(); if (todo & (M_INIT | M_LINDENOISE)) { - MyMutex::MyLock lock(parent->minit); // Also used in improccoord + MyMutex::MyLock lock (parent->minit); // Also used in improccoord - int tr = getCoarseBitMask(params.coarse); + int tr = getCoarseBitMask (params.coarse); if (!needsinitupdate) { setCropSizes (rqcropx, rqcropy, rqcropw, rqcroph, skip, true); } - // printf("x=%d y=%d crow=%d croh=%d skip=%d\n",rqcropx, rqcropy, rqcropw, rqcroph, skip); - // printf("trafx=%d trafyy=%d trafwsk=%d trafHs=%d \n",trafx, trafy, trafw*skip, trafh*skip); + // printf("x=%d y=%d crow=%d croh=%d skip=%d\n",rqcropx, rqcropy, rqcropw, rqcroph, skip); + // printf("trafx=%d trafyy=%d trafwsk=%d trafHs=%d \n",trafx, trafy, trafw*skip, trafh*skip); Imagefloat *calclum = nullptr;//for Luminance denoise curve NoiseCurve noiseLCurve; @@ -170,17 +175,17 @@ void Crop::update (int todo) float autoNR = (float) settings->nrauto;// float autoNRmax = (float) settings->nrautomax;// - params.dirpyrDenoise.getCurves(noiseLCurve, noiseCCurve); + params.dirpyrDenoise.getCurves (noiseLCurve, noiseCCurve); int tilesize; int overlap; - if(settings->leveldnti == 0) { + if (settings->leveldnti == 0) { tilesize = 1024; overlap = 128; } - if(settings->leveldnti == 1) { + if (settings->leveldnti == 1) { tilesize = 768; overlap = 96; } @@ -201,35 +206,35 @@ void Crop::update (int todo) int *centerTile_X = new int [numtiles_W]; int *centerTile_Y = new int [numtiles_H]; - for(int cX = 0; cX < numtiles_W; cX++) { + for (int cX = 0; cX < numtiles_W; cX++) { centerTile_X[cX] = tileWskip / 2 + tileWskip * cX; } - for(int cY = 0; cY < numtiles_H; cY++) { + for (int cY = 0; cY < numtiles_H; cY++) { centerTile_Y[cY] = tileHskip / 2 + tileHskip * cY; } - if(settings->leveldnautsimpl == 1) { - if(params.dirpyrDenoise.Cmethod == "MAN" || params.dirpyrDenoise.Cmethod == "PON" ) { + if (settings->leveldnautsimpl == 1) { + if (params.dirpyrDenoise.Cmethod == "MAN" || params.dirpyrDenoise.Cmethod == "PON" ) { PreviewProps pp (trafx, trafy, trafw * skip, trafh * skip, skip); parent->imgsrc->getImage (parent->currWB, tr, origCrop, pp, params.toneCurve, params.icm, params.raw ); } } else { - if(params.dirpyrDenoise.C2method == "MANU") { + if (params.dirpyrDenoise.C2method == "MANU") { PreviewProps pp (trafx, trafy, trafw * skip, trafh * skip, skip); parent->imgsrc->getImage (parent->currWB, tr, origCrop, pp, params.toneCurve, params.icm, params.raw ); } } - if((settings->leveldnautsimpl == 1 && params.dirpyrDenoise.Cmethod == "PRE") || (settings->leveldnautsimpl == 0 && params.dirpyrDenoise.C2method == "PREV")) { + if ((settings->leveldnautsimpl == 1 && params.dirpyrDenoise.Cmethod == "PRE") || (settings->leveldnautsimpl == 0 && params.dirpyrDenoise.C2method == "PREV")) { PreviewProps pp (trafx, trafy, trafw * skip, trafh * skip, skip); parent->imgsrc->getImage (parent->currWB, tr, origCrop, pp, params.toneCurve, params.icm, params.raw ); - if((!isDetailWindow) && parent->adnListener && skip == 1 && params.dirpyrDenoise.enabled) { + if ((!isDetailWindow) && parent->adnListener && skip == 1 && params.dirpyrDenoise.enabled) { float lowdenoise = 1.f; int levaut = settings->leveldnaut; - if(levaut == 1) { //Standard + if (levaut == 1) { //Standard lowdenoise = 0.7f; } @@ -240,16 +245,16 @@ void Crop::update (int todo) int poscenterX = 0; int poscenterY = 0; - for(int cc = 0; cc < numtiles_W; cc++) { - if(abs(centerTile_X[cc] - CenterPreview_X) < minimuX) { - minimuX = abs(centerTile_X[cc] - CenterPreview_X); + for (int cc = 0; cc < numtiles_W; cc++) { + if (abs (centerTile_X[cc] - CenterPreview_X) < minimuX) { + minimuX = abs (centerTile_X[cc] - CenterPreview_X); poscenterX = cc; } } - for(int cc = 0; cc < numtiles_H; cc++) { - if(abs(centerTile_Y[cc] - CenterPreview_Y) < minimuY) { - minimuY = abs(centerTile_Y[cc] - CenterPreview_Y); + for (int cc = 0; cc < numtiles_H; cc++) { + if (abs (centerTile_Y[cc] - CenterPreview_Y) < minimuY) { + minimuY = abs (centerTile_Y[cc] - CenterPreview_Y); poscenterY = cc; } } @@ -257,20 +262,20 @@ void Crop::update (int todo) // printf("TileCX=%d TileCY=%d prevX=%d prevY=%d \n",centerTile_X[poscenterX],centerTile_Y[poscenterY],CenterPreview_X,CenterPreview_Y); int crW; - if(settings->leveldnv == 0) { + if (settings->leveldnv == 0) { crW = 100; } - if(settings->leveldnv == 1) { + if (settings->leveldnv == 1) { crW = 250; } // if(settings->leveldnv ==2) {crW=int(tileWskip/2);crH=int((tileWskip/2));}//adapted to scale of preview - if(settings->leveldnv == 2) { - crW = int(tileWskip / 2); + if (settings->leveldnv == 2) { + crW = int (tileWskip / 2); } - if(settings->leveldnv == 3) { + if (settings->leveldnv == 3) { crW = tileWskip - 10; } @@ -292,7 +297,7 @@ void Crop::update (int todo) adjustr = 1.f / 1.2f; } - if(parent->adnListener) { + if (parent->adnListener) { parent->adnListener->noiseTilePrev (centerTile_X[poscenterX], centerTile_Y[poscenterY], CenterPreview_X, CenterPreview_Y, crW, trafw * skip); } @@ -309,15 +314,15 @@ void Crop::update (int todo) int H = origCrop->getHeight(); Imagefloat *provicalc = new Imagefloat ((W + 1) / 2, (H + 1) / 2); //for denoise curves - for(int ii = 0; ii < H; ii += 2) { - for(int jj = 0; jj < W; jj += 2) { - provicalc->r(ii >> 1, jj >> 1) = origCrop->r(ii, jj); - provicalc->g(ii >> 1, jj >> 1) = origCrop->g(ii, jj); - provicalc->b(ii >> 1, jj >> 1) = origCrop->b(ii, jj); + for (int ii = 0; ii < H; ii += 2) { + for (int jj = 0; jj < W; jj += 2) { + provicalc->r (ii >> 1, jj >> 1) = origCrop->r (ii, jj); + provicalc->g (ii >> 1, jj >> 1) = origCrop->g (ii, jj); + provicalc->b (ii >> 1, jj >> 1) = origCrop->b (ii, jj); } } - parent->imgsrc->convertColorSpace(provicalc, params.icm, parent->currWB);//for denoise luminance curve + parent->imgsrc->convertColorSpace (provicalc, params.icm, parent->currWB); //for denoise luminance curve float maxr = 0.f; float maxb = 0.f; @@ -331,19 +336,19 @@ void Crop::update (int todo) maxblueaut = 0.f; minredaut = 0.f; minblueaut = 0.f; - LUTf gamcurve(65536, 0); + LUTf gamcurve (65536, 0); float gam, gamthresh, gamslope; - parent->ipf.RGB_denoise_infoGamCurve(params.dirpyrDenoise, parent->imgsrc->isRAW(), gamcurve, gam, gamthresh, gamslope); - parent->ipf.RGB_denoise_info(origCrop, provicalc, parent->imgsrc->isRAW(), gamcurve, gam, gamthresh, gamslope, params.dirpyrDenoise, parent->imgsrc->getDirPyrDenoiseExpComp(), chaut, Nb, redaut, blueaut, maxredaut, maxblueaut, minredaut, minblueaut, chromina, sigma, lumema, sigma_L, redyel, skinc, nsknc, true); + parent->ipf.RGB_denoise_infoGamCurve (params.dirpyrDenoise, parent->imgsrc->isRAW(), gamcurve, gam, gamthresh, gamslope); + parent->ipf.RGB_denoise_info (origCrop, provicalc, parent->imgsrc->isRAW(), gamcurve, gam, gamthresh, gamslope, params.dirpyrDenoise, parent->imgsrc->getDirPyrDenoiseExpComp(), chaut, Nb, redaut, blueaut, maxredaut, maxblueaut, minredaut, minblueaut, chromina, sigma, lumema, sigma_L, redyel, skinc, nsknc, true); // printf("redy=%f skin=%f pcskin=%f\n",redyel, skinc,nsknc); // printf("DCROP skip=%d cha=%4.0f Nb=%d red=%4.0f bl=%4.0f redM=%4.0f bluM=%4.0f L=%4.0f sigL=%4.0f Ch=%4.0f Si=%4.0f\n",skip, chaut,Nb, redaut,blueaut, maxredaut, maxblueaut, lumema, sigma_L, chromina, sigma); float multip = 1.f; - if(!parent->imgsrc->isRAW()) { + if (!parent->imgsrc->isRAW()) { multip = 2.f; //take into account gamma for TIF / JPG approximate value...not good for gamma=1 } - float maxmax = max(maxredaut, maxblueaut); + float maxmax = max (maxredaut, maxblueaut); float delta; int mode = 0; // float redyel, skinc, nsknc; @@ -351,18 +356,18 @@ void Crop::update (int todo) parent->ipf.calcautodn_info (chaut, delta, Nb, levaut, maxmax, lumema, chromina, mode, lissage, redyel, skinc, nsknc); - if(maxredaut > maxblueaut) { + if (maxredaut > maxblueaut) { // maxr=(maxredaut-chaut)/((autoNRmax*multip*adjustr)/2.f); maxr = (delta) / ((autoNRmax * multip * adjustr * lowdenoise) / 2.f); - if(minblueaut <= minredaut && minblueaut < chaut) { + if (minblueaut <= minredaut && minblueaut < chaut) { maxb = (-chaut + minblueaut) / (autoNRmax * multip * adjustr * lowdenoise); } } else { // maxb=(maxblueaut-chaut)/((autoNRmax*multip*adjustr)/2.f); maxb = (delta) / ((autoNRmax * multip * adjustr * lowdenoise) / 2.f); - if(minredaut <= minblueaut && minredaut < chaut) { + if (minredaut <= minblueaut && minredaut < chaut) { maxr = (-chaut + minredaut) / (autoNRmax * multip * adjustr * lowdenoise); } }//maxb mxr - empirical evaluation red / blue @@ -371,35 +376,35 @@ void Crop::update (int todo) params.dirpyrDenoise.chroma = chaut / (autoNR * multip * adjustr * lowdenoise); params.dirpyrDenoise.redchro = maxr; params.dirpyrDenoise.bluechro = maxb; - parent->adnListener->chromaChanged(params.dirpyrDenoise.chroma, params.dirpyrDenoise.redchro, params.dirpyrDenoise.bluechro); + parent->adnListener->chromaChanged (params.dirpyrDenoise.chroma, params.dirpyrDenoise.redchro, params.dirpyrDenoise.bluechro); delete provicalc; } } - if(skip == 1 && params.dirpyrDenoise.enabled && !parent->denoiseInfoStore.valid && ((settings->leveldnautsimpl == 1 && params.dirpyrDenoise.Cmethod == "AUT") || (settings->leveldnautsimpl == 0 && params.dirpyrDenoise.C2method == "AUTO"))) { + if (skip == 1 && params.dirpyrDenoise.enabled && !parent->denoiseInfoStore.valid && ((settings->leveldnautsimpl == 1 && params.dirpyrDenoise.Cmethod == "AUT") || (settings->leveldnautsimpl == 0 && params.dirpyrDenoise.C2method == "AUTO"))) { MyTime t1aue, t2aue; t1aue.set(); int crW, crH; - if(settings->leveldnv == 0) { + if (settings->leveldnv == 0) { crW = 100; crH = 100; } - if(settings->leveldnv == 1) { + if (settings->leveldnv == 1) { crW = 250; crH = 250; } // if(settings->leveldnv ==2) {crW=int(tileWskip/2);crH=int((tileWskip/2));}//adapted to scale of preview - if(settings->leveldnv == 2) { - crW = int(tileWskip / 2); - crH = int(tileHskip / 2); + if (settings->leveldnv == 2) { + crW = int (tileWskip / 2); + crH = int (tileHskip / 2); } - if(settings->leveldnv == 3) { + if (settings->leveldnv == 3) { crW = tileWskip - 10; crH = tileHskip - 10; } @@ -407,13 +412,13 @@ void Crop::update (int todo) float lowdenoise = 1.f; int levaut = settings->leveldnaut; - if(levaut == 1) { //Standard + if (levaut == 1) { //Standard lowdenoise = 0.7f; } - LUTf gamcurve(65536, 0); + LUTf gamcurve (65536, 0); float gam, gamthresh, gamslope; - parent->ipf.RGB_denoise_infoGamCurve(params.dirpyrDenoise, parent->imgsrc->isRAW(), gamcurve, gam, gamthresh, gamslope); + parent->ipf.RGB_denoise_infoGamCurve (params.dirpyrDenoise, parent->imgsrc->isRAW(), gamcurve, gam, gamthresh, gamslope); int Nb[9]; #ifdef _OPENMP #pragma omp parallel @@ -436,26 +441,26 @@ void Crop::update (int todo) #pragma omp for schedule(dynamic) collapse(2) nowait #endif - for(int wcr = 0; wcr <= 2; wcr++) { - for(int hcr = 0; hcr <= 2; hcr++) { + for (int wcr = 0; wcr <= 2; wcr++) { + for (int hcr = 0; hcr <= 2; hcr++) { PreviewProps ppP (coordW[wcr] , coordH[hcr], crW, crH, 1); parent->imgsrc->getImage (parent->currWB, tr, origCropPart, ppP, params.toneCurve, params.icm, params.raw ); // we only need image reduced to 1/4 here - for(int ii = 0; ii < crH; ii += 2) { - for(int jj = 0; jj < crW; jj += 2) { - provicalc->r(ii >> 1, jj >> 1) = origCropPart->r(ii, jj); - provicalc->g(ii >> 1, jj >> 1) = origCropPart->g(ii, jj); - provicalc->b(ii >> 1, jj >> 1) = origCropPart->b(ii, jj); + for (int ii = 0; ii < crH; ii += 2) { + for (int jj = 0; jj < crW; jj += 2) { + provicalc->r (ii >> 1, jj >> 1) = origCropPart->r (ii, jj); + provicalc->g (ii >> 1, jj >> 1) = origCropPart->g (ii, jj); + provicalc->b (ii >> 1, jj >> 1) = origCropPart->b (ii, jj); } } - parent->imgsrc->convertColorSpace(provicalc, params.icm, parent->currWB);//for denoise luminance curve + parent->imgsrc->convertColorSpace (provicalc, params.icm, parent->currWB); //for denoise luminance curve float pondcorrec = 1.0f; float chaut = 0.f, redaut = 0.f, blueaut = 0.f, maxredaut = 0.f, maxblueaut = 0.f, minredaut = 0.f, minblueaut = 0.f, chromina = 0.f, sigma = 0.f, lumema = 0.f, sigma_L = 0.f, redyel = 0.f, skinc = 0.f, nsknc = 0.f; int nb = 0; - parent->ipf.RGB_denoise_info(origCropPart, provicalc, parent->imgsrc->isRAW(), gamcurve, gam, gamthresh, gamslope, params.dirpyrDenoise, parent->imgsrc->getDirPyrDenoiseExpComp(), chaut, nb, redaut, blueaut, maxredaut, maxblueaut, minredaut, minblueaut, chromina, sigma, lumema, sigma_L, redyel, skinc, nsknc); + parent->ipf.RGB_denoise_info (origCropPart, provicalc, parent->imgsrc->isRAW(), gamcurve, gam, gamthresh, gamslope, params.dirpyrDenoise, parent->imgsrc->getDirPyrDenoiseExpComp(), chaut, nb, redaut, blueaut, maxredaut, maxblueaut, minredaut, minblueaut, chromina, sigma, lumema, sigma_L, redyel, skinc, nsknc); //printf("DCROP skip=%d cha=%f red=%f bl=%f redM=%f bluM=%f chrom=%f sigm=%f lum=%f\n",skip, chaut,redaut,blueaut, maxredaut, maxblueaut, chromina, sigma, lumema); Nb[hcr * 3 + wcr] = nb; @@ -494,7 +499,7 @@ void Crop::update (int todo) float multip = 1.f; - if(!parent->imgsrc->isRAW()) { + if (!parent->imgsrc->isRAW()) { multip = 2.f; //take into account gamma for TIF / JPG approximate value...not good fot gamma=1 } @@ -521,15 +526,15 @@ void Crop::update (int todo) int lissage = settings->leveldnliss; for (int k = 0; k < 9; k++) { - float maxmax = max(parent->denoiseInfoStore.max_r[k], parent->denoiseInfoStore.max_b[k]); + float maxmax = max (parent->denoiseInfoStore.max_r[k], parent->denoiseInfoStore.max_b[k]); parent->ipf.calcautodn_info (parent->denoiseInfoStore.ch_M[k], delta[k], Nb[k], levaut, maxmax, lumL[k], chromC[k], mode, lissage, ry[k], sk[k], pcsk[k]); // printf("ch_M=%f delta=%f\n",ch_M[k], delta[k]); } for (int k = 0; k < 9; k++) { - if(parent->denoiseInfoStore.max_r[k] > parent->denoiseInfoStore.max_b[k]) { + if (parent->denoiseInfoStore.max_r[k] > parent->denoiseInfoStore.max_b[k]) { Max_R[k] = (delta[k]) / ((autoNRmax * multip * adjustr * lowdenoise) / 2.f); - Min_B[k] = -(parent->denoiseInfoStore.ch_M[k] - min_b[k]) / (autoNRmax * multip * adjustr * lowdenoise); + Min_B[k] = - (parent->denoiseInfoStore.ch_M[k] - min_b[k]) / (autoNRmax * multip * adjustr * lowdenoise); Max_B[k] = 0.f; Min_R[k] = 0.f; } else { @@ -548,19 +553,19 @@ void Crop::update (int todo) MinRMoy += Min_R[k]; MinBMoy += Min_B[k]; - if(Max_R[k] > MaxR) { + if (Max_R[k] > MaxR) { MaxR = Max_R[k]; } - if(Max_B[k] > MaxB) { + if (Max_B[k] > MaxB) { MaxB = Max_B[k]; } - if(Min_R[k] < MinR) { + if (Min_R[k] < MinR) { MinR = Min_R[k]; } - if(Min_B[k] < MinB) { + if (Min_B[k] < MinB) { MinB = Min_B[k]; } } @@ -571,7 +576,7 @@ void Crop::update (int todo) MinBMoy /= 9; MinRMoy /= 9; - if(MaxR > MaxB) { + if (MaxR > MaxB) { maxr = MaxRMoy + (MaxR - MaxRMoy) * 0.66f; //#std Dev //maxb=MinB; maxb = MinBMoy + (MinB - MinBMoy) * 0.66f; @@ -585,55 +590,56 @@ void Crop::update (int todo) params.dirpyrDenoise.redchro = maxr; params.dirpyrDenoise.bluechro = maxb; parent->denoiseInfoStore.valid = true; - if(parent->adnListener) { - parent->adnListener->chromaChanged(params.dirpyrDenoise.chroma, params.dirpyrDenoise.redchro, params.dirpyrDenoise.bluechro); + + if (parent->adnListener) { + parent->adnListener->chromaChanged (params.dirpyrDenoise.chroma, params.dirpyrDenoise.redchro, params.dirpyrDenoise.bluechro); } if (settings->verbose) { t2aue.set(); - printf("Info denoise auto performed in %d usec:\n", t2aue.etime(t1aue)); + printf ("Info denoise auto performed in %d usec:\n", t2aue.etime (t1aue)); } //end evaluate noise } // if(params.dirpyrDenoise.Cmethod=="AUT" || params.dirpyrDenoise.Cmethod=="PON") {//reinit origCrop after Auto - if((settings->leveldnautsimpl == 1 && params.dirpyrDenoise.Cmethod == "AUT") || (settings->leveldnautsimpl == 0 && params.dirpyrDenoise.C2method == "AUTO")) { //reinit origCrop after Auto + if ((settings->leveldnautsimpl == 1 && params.dirpyrDenoise.Cmethod == "AUT") || (settings->leveldnautsimpl == 0 && params.dirpyrDenoise.C2method == "AUTO")) { //reinit origCrop after Auto PreviewProps pp (trafx, trafy, trafw * skip, trafh * skip, skip); parent->imgsrc->getImage (parent->currWB, tr, origCrop, pp, params.toneCurve, params.icm, params.raw ); } DirPyrDenoiseParams denoiseParams = params.dirpyrDenoise; - if(params.dirpyrDenoise.Lmethod == "CUR") { - if(noiseLCurve) { + if (params.dirpyrDenoise.Lmethod == "CUR") { + if (noiseLCurve) { denoiseParams.luma = 0.5f; //very small value to init process - select curve or slider } else { denoiseParams.luma = 0.0f; } - } else if(denoiseParams.Lmethod == "SLI") { + } else if (denoiseParams.Lmethod == "SLI") { noiseLCurve.Reset(); } - if((noiseLCurve || noiseCCurve ) && skip == 1 && denoiseParams.enabled) { //only allocate memory if enabled and skip + if ((noiseLCurve || noiseCCurve ) && skip == 1 && denoiseParams.enabled) { //only allocate memory if enabled and skip // we only need image reduced to 1/4 here int W = origCrop->getWidth(); int H = origCrop->getHeight(); calclum = new Imagefloat ((W + 1) / 2, (H + 1) / 2); //for denoise curves - for(int ii = 0; ii < H; ii += 2) { - for(int jj = 0; jj < W; jj += 2) { - calclum->r(ii >> 1, jj >> 1) = origCrop->r(ii, jj); - calclum->g(ii >> 1, jj >> 1) = origCrop->g(ii, jj); - calclum->b(ii >> 1, jj >> 1) = origCrop->b(ii, jj); + for (int ii = 0; ii < H; ii += 2) { + for (int jj = 0; jj < W; jj += 2) { + calclum->r (ii >> 1, jj >> 1) = origCrop->r (ii, jj); + calclum->g (ii >> 1, jj >> 1) = origCrop->g (ii, jj); + calclum->b (ii >> 1, jj >> 1) = origCrop->b (ii, jj); } } - parent->imgsrc->convertColorSpace(calclum, params.icm, parent->currWB);//for denoise luminance curve + parent->imgsrc->convertColorSpace (calclum, params.icm, parent->currWB); //for denoise luminance curve } - if(skip != 1) if(parent->adnListener) { - parent->adnListener->noiseChanged(0.f, 0.f); + if (skip != 1) if (parent->adnListener) { + parent->adnListener->noiseChanged (0.f, 0.f); } if (todo & M_LINDENOISE) { @@ -641,26 +647,26 @@ void Crop::update (int todo) int kall = 0; float chaut, redaut, blueaut, maxredaut, maxblueaut, nresi, highresi; - parent->ipf.RGB_denoise(kall, origCrop, origCrop, calclum, parent->denoiseInfoStore.ch_M, parent->denoiseInfoStore.max_r, parent->denoiseInfoStore.max_b, parent->imgsrc->isRAW(), /*Roffset,*/ denoiseParams, parent->imgsrc->getDirPyrDenoiseExpComp(), noiseLCurve, noiseCCurve, chaut, redaut, blueaut, maxredaut, maxblueaut, nresi, highresi); + parent->ipf.RGB_denoise (kall, origCrop, origCrop, calclum, parent->denoiseInfoStore.ch_M, parent->denoiseInfoStore.max_r, parent->denoiseInfoStore.max_b, parent->imgsrc->isRAW(), /*Roffset,*/ denoiseParams, parent->imgsrc->getDirPyrDenoiseExpComp(), noiseLCurve, noiseCCurve, chaut, redaut, blueaut, maxredaut, maxblueaut, nresi, highresi); if (parent->adnListener) { - parent->adnListener->noiseChanged(nresi, highresi); + parent->adnListener->noiseChanged (nresi, highresi); } if (settings->leveldnautsimpl == 1) { if ((denoiseParams.Cmethod == "AUT" || denoiseParams.Cmethod == "PRE") && (parent->adnListener)) { // force display value of sliders - parent->adnListener->chromaChanged(denoiseParams.chroma, denoiseParams.redchro, denoiseParams.bluechro); + parent->adnListener->chromaChanged (denoiseParams.chroma, denoiseParams.redchro, denoiseParams.bluechro); } } else { - if((denoiseParams.C2method == "AUTO" || denoiseParams.C2method == "PREV") && (parent->adnListener)) { // force display value of sliders - parent->adnListener->chromaChanged(denoiseParams.chroma, denoiseParams.redchro, denoiseParams.bluechro); + if ((denoiseParams.C2method == "AUTO" || denoiseParams.C2method == "PREV") && (parent->adnListener)) { // force display value of sliders + parent->adnListener->chromaChanged (denoiseParams.chroma, denoiseParams.redchro, denoiseParams.bluechro); } } } } - parent->imgsrc->convertColorSpace(origCrop, params.icm, parent->currWB); + parent->imgsrc->convertColorSpace (origCrop, params.icm, parent->currWB); delete [] min_r; delete [] min_b; @@ -675,7 +681,7 @@ void Crop::update (int todo) } // has to be called after setCropSizes! Tools prior to this point can't handle the Edit mechanism, but that shouldn't be a problem. - createBuffer(cropw, croph); + createBuffer (cropw, croph); // transform if (needstransform || ((todo & (M_TRANSFORM | M_RGBCURVE)) && params.dirpyrequalizer.cbdlMethod == "bef" && params.dirpyrequalizer.enabled && !params.colorappearance.enabled)) { @@ -684,11 +690,12 @@ void Crop::update (int todo) } if (needstransform) - parent->ipf.transform (baseCrop, transCrop, cropx / skip, cropy / skip, trafx / skip, trafy / skip, SKIPS(parent->fw, skip), SKIPS(parent->fh, skip), parent->getFullWidth(), parent->getFullHeight(), + parent->ipf.transform (baseCrop, transCrop, cropx / skip, cropy / skip, trafx / skip, trafy / skip, SKIPS (parent->fw, skip), SKIPS (parent->fh, skip), parent->getFullWidth(), parent->getFullHeight(), parent->imgsrc->getMetaData()->getFocalLen(), parent->imgsrc->getMetaData()->getFocalLen35mm(), parent->imgsrc->getMetaData()->getFocusDist(), parent->imgsrc->getRotateDegree(), false); - else - baseCrop->copyData(transCrop); + else { + baseCrop->copyData (transCrop); + } if (transCrop) { baseCrop = transCrop; @@ -705,29 +712,29 @@ void Crop::update (int todo) const int W = baseCrop->getWidth(); const int H = baseCrop->getHeight(); - LabImage labcbdl(W, H); - parent->ipf.rgb2lab(*baseCrop, labcbdl, params.icm.working); + LabImage labcbdl (W, H); + parent->ipf.rgb2lab (*baseCrop, labcbdl, params.icm.working); parent->ipf.dirpyrequalizer (&labcbdl, skip); - parent->ipf.lab2rgb(labcbdl, *baseCrop, params.icm.working); + parent->ipf.lab2rgb (labcbdl, *baseCrop, params.icm.working); } // blurmap for shadow & highlights if ((todo & M_BLURMAP) && params.sh.enabled) { - double radius = sqrt (double(SKIPS(parent->fw, skip) * SKIPS(parent->fw, skip) + SKIPS(parent->fh, skip) * SKIPS(parent->fh, skip))) / 2.0; + double radius = sqrt (double (SKIPS (parent->fw, skip) * SKIPS (parent->fw, skip) + SKIPS (parent->fh, skip) * SKIPS (parent->fh, skip))) / 2.0; double shradius = params.sh.radius; if (!params.sh.hq) { shradius *= radius / 1800.0; } - if(!cshmap) { + if (!cshmap) { cshmap = new SHMap (cropw, croph, true); } cshmap->update (baseCrop, shradius, parent->ipf.lumimul, params.sh.hq, skip); - if(parent->shmap->min_f < 65535.f) { // don't call forceStat with wrong values + if (parent->shmap->min_f < 65535.f) { // don't call forceStat with wrong values cshmap->forceStat (parent->shmap->max_f, parent->shmap->min_f, parent->shmap->avg); } } @@ -749,7 +756,7 @@ void Crop::update (int todo) if (todo & M_RGBCURVE) { double rrm, ggm, bbm; DCPProfile::ApplyState as; - DCPProfile *dcpProf = parent->imgsrc->getDCP(params.icm, parent->currWB, as); + DCPProfile *dcpProf = parent->imgsrc->getDCP (params.icm, parent->currWB, as); LUTu histToneCurve; parent->ipf.rgbProc (baseCrop, laboCrop, this, parent->hltonecurve, parent->shtonecurve, parent->tonecurve, cshmap, @@ -775,9 +782,11 @@ void Crop::update (int todo) }*/ // apply luminance operations - if (todo & (M_LUMINANCE + M_COLOR)) { + //bool tutu = true; + if (todo & (M_LUMINANCE + M_COLOR)) { // + //if (tutu) { // //I made a little change here. Rather than have luminanceCurve (and others) use in/out lab images, we can do more if we copy right here. - labnCrop->CopyFrom(laboCrop); + labnCrop->CopyFrom (laboCrop); //parent->ipf.luminanceCurve (labnCrop, labnCrop, parent->lumacurve); @@ -788,31 +797,441 @@ void Crop::update (int todo) bool clcutili = parent->clcutili; bool cclutili = parent->cclutili; bool wavcontlutili = parent->wavcontlutili; + bool locallutili = parent->locallutili; + LUTf lllocalcurve2 (65536, 0); LUTu dummy; + bool needslocal = params.locallab.enabled; + LocretigainCurve locRETgainCurve; + LocLHCurve loclhCurve; + + LocretigainCurverab locRETgainCurverab; + locallutili = false; + int sca = skip; + + bool tyty = false; + int maxspot = settings->nspot + 1; + + if (needslocal ) { + // if(tyty ) { + //Glib::ustring datalab2 = parent->imgsrc->getFileName() + ".mip"; + Glib::ustring pop = options.getUserProfilePath() + "/"; + + Glib::ustring datalab; + + if (options.mip == MI_opt) { + datalab = pop + Glib::path_get_basename (parent->imgsrc->getFileName () + ".mip"); + } + + if (options.mip == MI_prev) { + datalab = parent->imgsrc->getFileName() + ".mip"; + } + + + ifstream fich (datalab, ios::in); + + if (fich && parent->versionmip != 0) {//to avoid crash in some cases + int **dataspotd; + + int realspot = params.locallab.nbspot; + bool tata = true; + bool locutili = parent->locutili; + + + for (int sp = 1; sp < maxspot; sp++) { + if (sp != realspot) { + + params.locallab.circrad = parent->circrads[sp] ; + params.locallab.locX = parent->locx[sp] ; + params.locallab.locY = parent->locy[sp]; + params.locallab.locYT = parent->locyt[sp]; + params.locallab.locXL = parent->locxl[sp]; + params.locallab.centerX = parent->centerx[sp]; + params.locallab.centerY = parent->centery[sp]; + params.locallab.lightness = parent->lights[sp]; + params.locallab.contrast = parent->contrs[sp]; + params.locallab.chroma = parent->chroms[sp]; + params.locallab.sensi = parent->sensis[sp]; + params.locallab.transit = parent->transits[sp]; + + if (parent->inverss[sp] == 0) { + params.locallab.invers = false; + } else { + params.locallab.invers = true; + } + + if (parent->smeths[sp] == 0) { + params.locallab.Smethod = "IND" ; + } else if (parent->smeths[sp] == 1) { + params.locallab.Smethod = "SYM" ; + } else if (parent->smeths[sp] == 2) { + params.locallab.Smethod = "INDSL"; + } else if (parent->smeths[sp] == 3) { + params.locallab.Smethod = "SYMSL"; + } + + params.locallab.radius = parent->radiuss[sp]; + params.locallab.strength = parent->strengths[sp]; + params.locallab.sensibn = parent->sensibns[sp]; + + if ( parent->inversrads[sp] == 0) { + params.locallab.inversrad = false; + } else { + params.locallab.inversrad = true; + } + + params.locallab.str = parent->strs[sp]; + params.locallab.chrrt = parent->chrrts[sp]; + params.locallab.neigh = parent->neighs[sp]; + params.locallab.vart = parent->varts[sp]; + params.locallab.sensih = parent->sensihs[sp]; + + if (parent->inversrets[sp] == 0) { + params.locallab.inversret = false; + } else { + params.locallab.inversret = true; + } + + if (parent->retinexs[sp] == 0) { + params.locallab.retinexMethod = "low" ; + } else if (parent->retinexs[sp] == 1) { + params.locallab.retinexMethod = "uni" ; + } else if (parent->retinexs[sp] == 2) { + params.locallab.retinexMethod = "high"; + } + + params.locallab.sharradius = parent->sharradiuss[sp]; + params.locallab.sharamount = parent->sharamounts[sp]; + params.locallab.shardamping = parent->shardampings[sp]; + params.locallab.shariter = parent->shariters[sp]; + params.locallab.sensisha = parent->sensishas[sp]; + + if (parent->inversshas[sp] == 0) { + params.locallab.inverssha = false; + } else { + params.locallab.inverssha = true; + } + + if (parent->qualitys[sp] == 0) { + params.locallab.qualityMethod = "std" ; + } else if (parent->qualitys[sp] == 1) { + params.locallab.qualityMethod = "enh" ; + } else if (parent->qualitys[sp] == 2) { + params.locallab.qualityMethod = "enhden" ; + } + + params.locallab.thres = parent->thress[sp]; + params.locallab.proxi = parent->proxis[sp]; + + params.locallab.noiselumf = parent->noiselumfs[sp]; + params.locallab.noiselumc = parent->noiselumcs[sp]; + params.locallab.noisechrof = parent->noisechrofs[sp]; + params.locallab.noisechroc = parent->noisechrocs[sp]; + params.locallab.mult[0] = parent->mult0s[sp]; + params.locallab.mult[1] = parent->mult1s[sp]; + params.locallab.mult[2] = parent->mult2s[sp]; + params.locallab.mult[3] = parent->mult3s[sp]; + params.locallab.mult[4] = parent->mult4s[sp]; + params.locallab.threshold = parent->thresholds[sp]; + params.locallab.sensicb = parent->sensicbs[sp]; + + if (parent->activlums[sp] == 0) { + params.locallab.activlum = false; + } else { + params.locallab.activlum = true; + } + + params.locallab.stren = parent->strens[sp]; + params.locallab.gamma = parent->gammas[sp]; + params.locallab.estop = parent->estops[sp]; + params.locallab.scaltm = parent->scaltms[sp]; + params.locallab.rewei = parent->reweis[sp]; + params.locallab.sensitm = parent->sensitms[sp]; + params.locallab.retrab = parent->retrabs[sp]; + + if (parent->curvactivs[sp] == 0) { + params.locallab.curvactiv = false; + } else { + params.locallab.curvactiv = true; + } + + std::vector cretie; + + for (int j = 0; j < parent->sizeretics[sp]; j++) { + cretie.push_back ((double) (parent->reticurvs[sp * 500 + j]) / 1000.); + } + + params.locallab.localTgaincurve.clear(); + params.locallab.localTgaincurve = cretie; + + std::vector llc; + + for (int j = 0; j < parent->sizellcs[sp]; j++) { + llc.push_back ((double) (parent->llcurvs[sp * 500 + j]) / 1000.); + } + + params.locallab.llcurve.clear(); + params.locallab.llcurve = llc; + + std::vector lhc; + + for (int j = 0; j < parent->sizelhcs[sp]; j++) { + lhc.push_back ((double) (parent->lhcurvs[sp * 500 + j]) / 1000.); + } + + params.locallab.LHcurve.clear(); + params.locallab.LHcurve = lhc; + + params.locallab.getCurves (locRETgainCurve, locRETgainCurverab, loclhCurve); + locallutili = false; + CurveFactory::curveLocal (locallutili, params.locallab.llcurve, lllocalcurve2, sca); + + params.locallab.hueref = (parent->huerefs[sp]) / 100.f; + params.locallab.chromaref = parent->chromarefs[sp]; + params.locallab.lumaref = parent->lumarefs[sp]; + + parent->ipf.Lab_Local (1, sp, (float**)shbuffer, labnCrop, labnCrop, trafx / skip, trafy / skip, cropx / skip, cropy / skip, SKIPS (parent->fw, skip), SKIPS (parent->fh, skip), parent->fw, parent->fh, locutili, skip, locRETgainCurve, locallutili, lllocalcurve2, loclhCurve, params.locallab.hueref, params.locallab.chromaref, params.locallab.lumaref); + lllocalcurve2.clear(); + + if (skip <= 2) { + usleep (settings->cropsleep); //wait to avoid crash when crop 100% and move window + } + } + } + + + + int sp ; + sp = realspot; + bool locutili2 = parent->locutili; + locallutili = false; + + parent->sps[sp] = sp; + parent->circrads[sp] = params.locallab.circrad = parent->circrads[0]; + parent->locx[sp] = params.locallab.locX = parent->locx[0]; + parent->locy[sp] = params.locallab.locY = parent->locy[0]; + parent->locyt[sp] = params.locallab.locYT = parent->locyt[0]; + parent->locxl[sp] = params.locallab.locXL = parent->locxl[0]; + parent->centerx[sp] = params.locallab.centerX = parent->centerx[0]; + parent->centery[sp] = params.locallab.centerY = parent->centery[0]; + parent->lights[sp] = params.locallab.lightness = parent->lights[0]; + parent->contrs[sp] = params.locallab.contrast = parent->contrs[0]; + parent->chroms[sp] = params.locallab.chroma = parent->chroms[0]; + parent->sensis[sp] = params.locallab.sensi = parent->sensis[0]; + parent->transits[sp] = params.locallab.transit = parent->transits[0]; + + if (parent->inverss[0] == 0) { + params.locallab.invers = false; + parent->inverss[sp] = 0; + + } else { + params.locallab.invers = true; + parent->inverss[sp] = 1; + + } + + if (parent->smeths[0] == 0) { + params.locallab.Smethod = "IND" ; + parent->smeths[sp] = 0; + + } else if (parent->smeths[0] == 1) { + params.locallab.Smethod = "SYM" ; + parent->smeths[sp] = 1; + + } else if (parent->smeths[0] == 2) { + params.locallab.Smethod = "INDSL"; + parent->smeths[2] = 0; + + + } else if (parent->smeths[0] == 3) { + params.locallab.Smethod = "SYMSL"; + parent->smeths[sp] = 3; + + } + + params.locallab.radius = parent->radiuss[0]; + params.locallab.strength = parent->strengths[0]; + params.locallab.sensibn = parent->sensibns[0]; + + parent->radiuss[sp] = params.locallab.radius; + parent->strengths[sp] = params.locallab.strength; + parent->sensibns[sp] = params.locallab.sensibn; + + if ( parent->inversrads[0] == 0) { + params.locallab.inversrad = false; + parent->inversrads[sp] = 0; + } else { + params.locallab.inversrad = true; + parent->inversrads[sp] = 1; + } + + parent->strs[sp] = params.locallab.str = parent->strs[0]; + parent->chrrts[sp] = params.locallab.chrrt = parent->chrrts[0]; + parent->neighs[sp] = params.locallab.neigh = parent->neighs[0]; + parent->varts[sp] = params.locallab.vart = parent->varts[0]; + parent->sensihs[sp] = params.locallab.sensih = parent->sensihs[0]; + + if (parent->inversrets[0] == 0) { + params.locallab.inversret = false; + parent->inversrets[sp] = 0; + } else { + params.locallab.inversret = true; + parent->inversrets[sp] = 1; + + } + + if (parent->retinexs[sp] == 0) { + params.locallab.retinexMethod = "low" ; + parent->retinexs[sp] = 0; + } else if (parent->retinexs[sp] == 1) { + params.locallab.retinexMethod = "uni" ; + parent->retinexs[sp] = 1; + + } else if (parent->retinexs[sp] == 2) { + params.locallab.retinexMethod = "high"; + parent->retinexs[sp] = 2; + + } + + parent->sharradiuss[sp] = params.locallab.sharradius = parent->sharradiuss[0]; + + parent->sharamounts[sp] = params.locallab.sharamount = parent->sharamounts[0]; + parent->shardampings[sp] = params.locallab.shardamping = parent->shardampings[0]; + parent->shariters[sp] = params.locallab.shariter = parent->shariters[0]; + parent->sensishas[sp] = params.locallab.sensisha = parent->sensishas[0]; + + if (parent->inversshas[0] == 0) { + params.locallab.inverssha = false; + parent->inversshas[sp] = 0; + } else { + params.locallab.inverssha = true; + parent->inversshas[sp] = 1; + + } + + if (parent->qualitys[sp] == 0) { + params.locallab.qualityMethod = "std" ; + parent->qualitys[sp] = 0; + } else if (parent->qualitys[sp] == 1) { + params.locallab.qualityMethod = "enh" ; + parent->qualitys[sp] = 1; + } else if (parent->qualitys[sp] == 2) { + params.locallab.qualityMethod = "enhden" ; + parent->qualitys[sp] = 2; + } + + parent->thress[sp] = params.locallab.thres = parent->thress[0]; + parent->proxis[sp] = params.locallab.proxi = parent->proxis[0]; + + parent->noiselumfs[sp] = params.locallab.noiselumf = parent->noiselumfs[0]; + parent->noiselumcs[sp] = params.locallab.noiselumc = parent->noiselumcs[0]; + parent->noisechrofs[sp] = params.locallab.noisechrof = parent->noisechrofs[0]; + parent->noisechrocs[sp] = params.locallab.noisechroc = parent->noisechrocs[0]; + parent->mult0s[sp] = params.locallab.mult[0] = parent->mult0s[0]; + parent->mult1s[sp] = params.locallab.mult[1] = parent->mult1s[0]; + parent->mult2s[sp] = params.locallab.mult[2] = parent->mult2s[0]; + parent->mult3s[sp] = params.locallab.mult[3] = parent->mult3s[0]; + parent->mult4s[sp] = params.locallab.mult[4] = parent->mult4s[0]; + parent->thresholds[sp] = params.locallab.threshold = parent->thresholds[0]; + parent->sensicbs[sp] = params.locallab.sensicb = parent->sensicbs[0]; + + if (parent->activlums[0] == 0) { + params.locallab.activlum = false; + parent->activlums[sp] = 0; + } else { + params.locallab.activlum = true; + parent->activlums[sp] = 1; + + } + + parent->strens[sp] = params.locallab.stren = parent->strens[0]; + parent->gammas[sp] = params.locallab.gamma = parent->gammas[0]; + parent->estops[sp] = params.locallab.estop = parent->estops[0]; + parent->scaltms[sp] = params.locallab.scaltm = parent->scaltms[0]; + parent->reweis[sp] = params.locallab.rewei = parent->reweis[0]; + parent->sensitms[sp] = params.locallab.sensitm = parent->sensitms[0]; + parent->retrabs[sp] = params.locallab.retrab = parent->retrabs[0]; + + if (parent->curvactivs[0] == 0) { + params.locallab.curvactiv = false; + parent->curvactivs[sp] = 0; + + } else { + params.locallab.curvactiv = true; + parent->curvactivs[sp] = 1; + + } + + std::vector ccret; + + for (int j = 0; j < parent->sizeretics[sp]; j++) { + ccret.push_back ((double) (parent->reticurvs[0 * 500 + j]) / 1000.); + parent->reticurvs[sp * 500 + j] = parent->reticurvs[0 * 500 + j]; + } + + params.locallab.localTgaincurve.clear(); + params.locallab.localTgaincurve = ccret; + + std::vector llcL; + + for (int j = 0; j < parent->sizellcs[sp]; j++) { + llcL.push_back ((double) (parent->llcurvs[0 * 500 + j]) / 1000.); + parent->llcurvs[sp * 500 + j] = parent->llcurvs[0 * 500 + j] ; + } + + params.locallab.llcurve.clear(); + params.locallab.llcurve = llcL; + + std::vector lhcL; + + for (int j = 0; j < parent->sizelhcs[sp]; j++) { + lhcL.push_back ((double) (parent->lhcurvs[0 * 500 + j]) / 1000.); + parent->lhcurvs[sp * 500 + j] = parent->lhcurvs[0 * 500 + j] ; + } + + params.locallab.LHcurve.clear(); + params.locallab.LHcurve = lhcL; + + params.locallab.getCurves (locRETgainCurve, locRETgainCurverab, loclhCurve); + locallutili = false; + + CurveFactory::curveLocal (locallutili, params.locallab.llcurve, lllocalcurve2, sca); // skip == 1 ? 1 : 16); + + + params.locallab.hueref = (parent->huerefs[sp]) / 100.f; + params.locallab.chromaref = parent->chromarefs[sp]; + params.locallab.lumaref = parent->lumarefs[sp]; + + parent->ipf.Lab_Local (1, sp, (float**)shbuffer, labnCrop, labnCrop, trafx / skip, trafy / skip, cropx / skip, cropy / skip, SKIPS (parent->fw, skip), SKIPS (parent->fh, skip), parent->getFullWidth(), parent->getFullHeight(), locutili2, skip, locRETgainCurve, locallutili, lllocalcurve2, loclhCurve, params.locallab.hueref, params.locallab.chromaref, params.locallab.lumaref); + lllocalcurve2.clear(); + + + } + } + int moderetinex; // 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); parent->ipf.vibrance (labnCrop); - if((params.colorappearance.enabled && !params.colorappearance.tonecie) || (!params.colorappearance.enabled)) { - parent->ipf.EPDToneMap(labnCrop, 5, 1); + if ((params.colorappearance.enabled && !params.colorappearance.tonecie) || (!params.colorappearance.enabled)) { + parent->ipf.EPDToneMap (labnCrop, 5, 1); } //parent->ipf.EPDToneMap(labnCrop, 5, 1); //Go with much fewer than normal iterates for fast redisplay. // for all treatments Defringe, Sharpening, Contrast detail , Microcontrast they are activated if "CIECAM" function are disabled if (skip == 1) { - if((params.colorappearance.enabled && !settings->autocielab) || (!params.colorappearance.enabled)) { + if ((params.colorappearance.enabled && !settings->autocielab) || (!params.colorappearance.enabled)) { parent->ipf.impulsedenoise (labnCrop); } - if((params.colorappearance.enabled && !settings->autocielab) || (!params.colorappearance.enabled) ) { + if ((params.colorappearance.enabled && !settings->autocielab) || (!params.colorappearance.enabled) ) { parent->ipf.defringe (labnCrop); } parent->ipf.MLsharpen (labnCrop); - if((params.colorappearance.enabled && !settings->autocielab) || (!params.colorappearance.enabled)) { + if ((params.colorappearance.enabled && !settings->autocielab) || (!params.colorappearance.enabled)) { parent->ipf.MLmicrocontrast (labnCrop); parent->ipf.sharpening (labnCrop, (float**)cbuffer, params.sharpening); } @@ -821,46 +1240,46 @@ void Crop::update (int todo) // if (skip==1) { WaveletParams WaveParams = params.wavelet; - if(params.dirpyrequalizer.cbdlMethod == "aft") { - if(((params.colorappearance.enabled && !settings->autocielab) || (!params.colorappearance.enabled))) { + if (params.dirpyrequalizer.cbdlMethod == "aft") { + if (((params.colorappearance.enabled && !settings->autocielab) || (!params.colorappearance.enabled))) { parent->ipf.dirpyrequalizer (labnCrop, skip); // parent->ipf.Lanczoslab (labnCrop,labnCrop , 1.f/skip); } } int kall = 0; - int minwin = min(labnCrop->W, labnCrop->H); + int minwin = min (labnCrop->W, labnCrop->H); int maxlevelcrop = 10; // if(cp.mul[9]!=0)maxlevelcrop=10; // adap maximum level wavelet to size of crop - if(minwin * skip < 1024) { + if (minwin * skip < 1024) { maxlevelcrop = 9; //sampling wavelet 512 } - if(minwin * skip < 512) { + if (minwin * skip < 512) { maxlevelcrop = 8; //sampling wavelet 256 } - if(minwin * skip < 256) { + if (minwin * skip < 256) { maxlevelcrop = 7; //sampling 128 } - if(minwin * skip < 128) { + if (minwin * skip < 128) { maxlevelcrop = 6; } - if(minwin < 64) { + if (minwin < 64) { maxlevelcrop = 5; } int realtile; - if(params.wavelet.Tilesmethod == "big") { + if (params.wavelet.Tilesmethod == "big") { realtile = 22; } - if(params.wavelet.Tilesmethod == "lit") { + if (params.wavelet.Tilesmethod == "lit") { realtile = 12; } @@ -872,69 +1291,70 @@ void Crop::update (int todo) parent->ipf.Tile_calc (tilesize, overlap, kall, labnCrop->W, labnCrop->H, numtiles_W, numtiles_H, tilewidth, tileheight, tileWskip, tileHskip); //now we have tile dimensions, overlaps //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - int minsizetile = min(tilewidth, tileheight); + int minsizetile = min (tilewidth, tileheight); int maxlev2 = 10; - if(minsizetile < 1024 && maxlevelcrop == 10) { + if (minsizetile < 1024 && maxlevelcrop == 10) { maxlev2 = 9; } - if(minsizetile < 512) { + if (minsizetile < 512) { maxlev2 = 8; } - if(minsizetile < 256) { + if (minsizetile < 256) { maxlev2 = 7; } - if(minsizetile < 128) { + if (minsizetile < 128) { maxlev2 = 6; } - int maxL = min(maxlev2, maxlevelcrop); + int maxL = min (maxlev2, maxlevelcrop); - if(parent->awavListener) { - parent->awavListener->wavChanged(float(maxL)); + if (parent->awavListener) { + parent->awavListener->wavChanged (float (maxL)); } - if((params.wavelet.enabled)) { + if ((params.wavelet.enabled)) { WavCurve wavCLVCurve; WavOpacityCurveRG waOpacityCurveRG; WavOpacityCurveBY waOpacityCurveBY; WavOpacityCurveW waOpacityCurveW; WavOpacityCurveWL waOpacityCurveWL; + LUTf wavclCurve; LUTu dummy; - params.wavelet.getCurves(wavCLVCurve, waOpacityCurveRG, waOpacityCurveBY, waOpacityCurveW, waOpacityCurveWL); + params.wavelet.getCurves (wavCLVCurve, waOpacityCurveRG, waOpacityCurveBY, waOpacityCurveW, waOpacityCurveWL); - parent->ipf.ip_wavelet(labnCrop, labnCrop, kall, WaveParams, wavCLVCurve, waOpacityCurveRG, waOpacityCurveBY, waOpacityCurveW, waOpacityCurveWL, parent->wavclCurve, wavcontlutili, skip); + parent->ipf.ip_wavelet (labnCrop, labnCrop, kall, WaveParams, wavCLVCurve, waOpacityCurveRG, waOpacityCurveBY, waOpacityCurveW, waOpacityCurveWL, parent->wavclCurve, wavcontlutili, skip); } // } // } - if(params.colorappearance.enabled) { + if (params.colorappearance.enabled) { float fnum = parent->imgsrc->getMetaData()->getFNumber (); // F number float fiso = parent->imgsrc->getMetaData()->getISOSpeed () ; // ISO float fspeed = parent->imgsrc->getMetaData()->getShutterSpeed () ; // Speed double fcomp = parent->imgsrc->getMetaData()->getExpComp (); // Compensation +/- double adap; // Scene's luminosity adaptation factor - if(fnum < 0.3f || fiso < 5.f || fspeed < 0.00001f) { //if no exif data or wrong + if (fnum < 0.3f || fiso < 5.f || fspeed < 0.00001f) { //if no exif data or wrong adap = 2000.; } else { - double E_V = fcomp + log2 (double((fnum * fnum) / fspeed / (fiso / 100.f))); + double E_V = fcomp + log2 (double ((fnum * fnum) / fspeed / (fiso / 100.f))); E_V += params.toneCurve.expcomp;// exposure compensation in tonecurve ==> direct EV - E_V += log2(params.raw.expos);// exposure raw white point ; log2 ==> linear to EV - adap = pow(2., E_V - 3.); // cd / m2 + E_V += log2 (params.raw.expos); // exposure raw white point ; log2 ==> linear to EV + adap = pow (2., E_V - 3.); // cd / m2 // end calculation adaptation scene luminosity } int begh = 0, endh = labnCrop->H; bool execsharp = false; - if(skip == 1) { + if (skip == 1) { execsharp = true; } @@ -942,9 +1362,9 @@ void Crop::update (int todo) cieCrop = new CieImage (cropw, croph); } - if(settings->ciecamfloat) { + if (settings->ciecamfloat) { float d; // not used after this block - parent->ipf.ciecam_02float (cieCrop, float(adap), begh, endh, 1, 2, labnCrop, ¶ms, parent->customColCurve1, parent->customColCurve2, parent->customColCurve3, + parent->ipf.ciecam_02float (cieCrop, float (adap), begh, endh, 1, 2, labnCrop, ¶ms, parent->customColCurve1, parent->customColCurve2, parent->customColCurve3, dummy, dummy, parent->CAMBrightCurveJ, parent->CAMBrightCurveQ, parent->CAMMean, 5, 1, execsharp, d, skip, 1); } else { double dd; // not used after this block @@ -1024,11 +1444,17 @@ void Crop::freeAll () laboCrop = nullptr; } + if (labnCrop ) { delete labnCrop; labnCrop = nullptr; } + /* if (lablocCrop ) { + delete lablocCrop; + lablocCrop = NULL; + } + */ if (cropImg ) { delete cropImg; cropImg = nullptr; @@ -1049,6 +1475,11 @@ void Crop::freeAll () cbuffer = nullptr; } + if (shbuffer ) { + delete [] shbuffer; + shbuffer = nullptr; + } + if (cshmap ) { delete cshmap; cshmap = nullptr; @@ -1083,12 +1514,12 @@ bool Crop::setCropSizes (int rcx, int rcy, int rcw, int rch, int skip, bool inte rqcroph = rch; // store and set requested crop size - int rqx1 = LIM(rqcropx, 0, parent->fullw - 1); - int rqy1 = LIM(rqcropy, 0, parent->fullh - 1); + int rqx1 = LIM (rqcropx, 0, parent->fullw - 1); + int rqy1 = LIM (rqcropy, 0, parent->fullh - 1); int rqx2 = rqx1 + rqcropw - 1; int rqy2 = rqy1 + rqcroph - 1; - rqx2 = LIM(rqx2, 0, parent->fullw - 1); - rqy2 = LIM(rqy2, 0, parent->fullh - 1); + rqx2 = LIM (rqx2, 0, parent->fullw - 1); + rqy2 = LIM (rqy2, 0, parent->fullh - 1); this->skip = skip; @@ -1098,10 +1529,10 @@ bool Crop::setCropSizes (int rcx, int rcy, int rcw, int rch, int skip, bool inte int bx2 = rqx2 + skip * borderRequested; int by2 = rqy2 + skip * borderRequested; // clip it to fit into image area - bx1 = LIM(bx1, 0, parent->fullw - 1); - by1 = LIM(by1, 0, parent->fullh - 1); - bx2 = LIM(bx2, 0, parent->fullw - 1); - by2 = LIM(by2, 0, parent->fullh - 1); + bx1 = LIM (bx1, 0, parent->fullw - 1); + by1 = LIM (by1, 0, parent->fullh - 1); + bx2 = LIM (bx2, 0, parent->fullw - 1); + by2 = LIM (by2, 0, parent->fullh - 1); int bw = bx2 - bx1 + 1; int bh = by2 - by1 + 1; @@ -1114,17 +1545,18 @@ bool Crop::setCropSizes (int rcx, int rcy, int rcw, int rch, int skip, bool inte int orW, orH; parent->imgsrc->getSize (cp, orW, orH); - int cw = SKIPS(bw, skip); - int ch = SKIPS(bh, skip); + int cw = SKIPS (bw, skip); + int ch = SKIPS (bh, skip); - leftBorder = SKIPS(rqx1 - bx1, skip); - upperBorder = SKIPS(rqy1 - by1, skip); + leftBorder = SKIPS (rqx1 - bx1, skip); + upperBorder = SKIPS (rqy1 - by1, skip); if (settings->verbose) { printf ("setsizes starts (%d, %d, %d, %d, %d, %d)\n", orW, orH, trafw, trafh, cw, ch); } EditType editType = ET_PIPETTE; + if (const auto editProvider = PipetteBuffer::getDataProvider ()) { if (const auto editSubscriber = editProvider->getCurrSubscriber ()) { editType = editSubscriber->getEditingType (); @@ -1142,11 +1574,11 @@ bool Crop::setCropSizes (int rcx, int rcy, int rcw, int rch, int skip, bool inte origCrop = new Imagefloat; } - origCrop->allocate(trafw, trafh); // Resizing the buffer (optimization) + origCrop->allocate (trafw, trafh); // Resizing the buffer (optimization) // if transCrop doesn't exist yet, it'll be created where necessary if (transCrop) { - transCrop->allocate(cropw, croph); + transCrop->allocate (cropw, croph); } if (laboCrop) { @@ -1155,17 +1587,25 @@ bool Crop::setCropSizes (int rcx, int rcy, int rcw, int rch, int skip, bool inte laboCrop = new LabImage (cropw, croph); + // if (translabCrop) translabCrop->reallocLab(); + if (labnCrop) { delete labnCrop; // labnCrop can't be resized } labnCrop = new LabImage (cropw, croph); + /* if (lablocCrop) { + delete lablocCrop; // labnCrop can't be resized + } + + lablocCrop = new LabImage (cropw, croph); + */ if (!cropImg) { cropImg = new Image8; } - cropImg->allocate(cropw, croph); // Resizing the buffer (optimization) + cropImg->allocate (cropw, croph); // Resizing the buffer (optimization) //cieCrop is only used in Crop::update, it is destroyed now but will be allocated on first use if (cieCrop) { @@ -1177,28 +1617,43 @@ bool Crop::setCropSizes (int rcx, int rcy, int rcw, int rch, int skip, bool inte delete [] cbuffer; } + if (shbuffer ) { + delete [] shbuffer; + } + if (cbuf_real) { delete [] cbuf_real; } + if (shbuf_real) { + delete [] shbuf_real; + } + if (cshmap ) { delete cshmap; cshmap = nullptr; } cbuffer = new float*[croph]; - cbuf_real = new float[(croph + 2)*cropw]; + cbuf_real = new float[ (croph + 2)*cropw]; for (int i = 0; i < croph; i++) { cbuffer[i] = cbuf_real + cropw * i + cropw; } - if(params.sh.enabled) { + shbuffer = new float*[croph]; + shbuf_real = new float[ (croph + 2)*cropw]; + + for (int i = 0; i < croph; i++) { + shbuffer[i] = shbuf_real + cropw * i + cropw; + } + + if (params.sh.enabled) { cshmap = new SHMap (cropw, croph, true); } if (editType == ET_PIPETTE) { - PipetteBuffer::resize(cropw, croph); + PipetteBuffer::resize (cropw, croph); } else if (PipetteBuffer::bufferCreated()) { PipetteBuffer::flush(); } diff --git a/rtengine/dcrop.h b/rtengine/dcrop.h index 450c659f0..c2fcc2a63 100644 --- a/rtengine/dcrop.h +++ b/rtengine/dcrop.h @@ -47,12 +47,14 @@ protected: Image8* cropImg; // "one chunk" allocation ; displayed image in monitor color space, showing the output profile as well (soft-proofing enabled, which then correspond to workimg) or not float * cbuf_real; // "one chunk" allocation SHMap* cshmap; // per line allocation + float * shbuf_real; // "one chunk" allocation // --- automatically allocated and deleted when necessary, and only renewed on size changes Imagefloat* transCrop; // "one chunk" allocation, allocated if necessary CieImage* cieCrop; // allocating 6 images, each in "one chunk" allocation // ----------------------------------------------------------------- float** cbuffer; + float** shbuffer; bool updating; /// Flag telling if an updater thread is currently processing bool newUpdatePending; /// Flag telling the updater thread that a new update is pending @@ -77,6 +79,7 @@ protected: public: Crop (ImProcCoordinator* parent, EditDataProvider *editDataProvider, bool isDetailWindow); virtual ~Crop (); +// MyMutex* locMutex; void mLock () { @@ -86,7 +89,7 @@ public: { cropMutex.lock(); } - void setEditSubscriber(EditSubscriber* newSubscriber); + void setEditSubscriber (EditSubscriber* newSubscriber); bool hasListener () { return cropImageListener; diff --git a/rtengine/dirpyr_equalizer.cc b/rtengine/dirpyr_equalizer.cc index a3a6d81b0..dd7211667 100644 --- a/rtengine/dirpyr_equalizer.cc +++ b/rtengine/dirpyr_equalizer.cc @@ -42,10 +42,14 @@ namespace rtengine { static const int maxlevel = 6; +static const int maxlevelloc = 5; + static const float noise = 2000; //sequence of scales static const int scales[6] = {1, 2, 4, 8, 16, 32}; +static const int scalesloc[5] = {1, 2, 4, 8, 16}; + extern const Settings* settings; //sequence of scales @@ -257,6 +261,212 @@ SSEFUNCTION void ImProcFunctions :: dirpyr_equalizer(float ** src, float ** dst, } +SSEFUNCTION void ImProcFunctions :: cbdl_local_temp(float ** src, float ** dst, float ** loctemp, int srcwidth, int srcheight, const float * mult, const double dirpyrThreshold, const double skinprot, const bool gamutlab, float b_l, float t_l, float t_r, float b_r, int choice, int scaleprev) +{ + int lastlevel = maxlevelloc; + + if(settings->verbose) { + printf("Dirpyr scaleprev=%i\n", scaleprev); + } + + float atten123 = (float) settings->level123_cbdl; + + if(atten123 > 50.f) { + atten123 = 50.f; + } + + if(atten123 < 0.f) { + atten123 = 0.f; + } + + float atten0 = (float) settings->level0_cbdl; + + if(atten0 > 40.f) { + atten123 = 40.f; + } + + if(atten0 < 0.f) { + atten0 = 0.f; + } + + if((t_r - t_l) < 0.55f) { + t_l = t_r + 0.55f; //avoid too small range + } + + while (lastlevel > 0 && fabs(mult[lastlevel - 1] - 1) < 0.001) { + + lastlevel--; + //printf("last level to process %d \n",lastlevel); + } + + if (lastlevel == 0) { + return; + } + + int level; + float multi[5] = {1.f, 1.f, 1.f, 1.f, 1.f}; + float scalefl[5]; + + for(int lv = 0; lv < 5; lv++) { + scalefl[lv] = ((float) scalesloc[lv]) / (float) scaleprev; + + if(lv >= 1) { + if(scalefl[lv] < 1.f) { + multi[lv] = (atten123 * ((float) mult[lv] - 1.f) / 100.f) + 1.f; //modulate action if zoom < 100% + } else { + multi[lv] = (float) mult[lv]; + } + } else { + if(scalefl[lv] < 1.f) { + multi[lv] = (atten0 * ((float) mult[lv] - 1.f) / 100.f) + 1.f; //modulate action if zoom < 100% + } else { + multi[lv] = (float) mult[lv]; + } + } + + } + + if(settings->verbose) { + printf("CbDL local mult0=%f 1=%f 2=%f 3=%f 4=%f\n", multi[0], multi[1], multi[2], multi[3], multi[4]); + } + + multi_array2D dirpyrlo (srcwidth, srcheight); + + level = 0; + + //int thresh = 100 * mult[5]; + int scale = (int)(scalesloc[level]) / scaleprev; + + if(scale < 1) { + scale = 1; + } + + + dirpyr_channel(src, dirpyrlo[0], srcwidth, srcheight, 0, scale); + + level = 1; + + while(level < lastlevel) { + + scale = (int)(scalesloc[level]) / scaleprev; + + if(scale < 1) { + scale = 1; + } + + dirpyr_channel(dirpyrlo[level - 1], dirpyrlo[level], srcwidth, srcheight, level, scale); + + level ++; + } + + float **tmpHue, **tmpChr; + /* + if(skinprot != 0.f) { + // precalculate hue and chroma, use SSE, if available + // by precalculating these values we can greatly reduce the number of calculations in idirpyr_eq_channel() + // but we need two additional buffers for this preprocessing + tmpHue = new float*[srcheight]; + + for (int i = 0; i < srcheight; i++) { + tmpHue[i] = new float[srcwidth]; + } + + #ifdef __SSE2__ + #pragma omp parallel for + + for(int i = 0; i < srcheight; i++) { + int j; + + for(j = 0; j < srcwidth - 3; j += 4) { + _mm_storeu_ps(&tmpHue[i][j], xatan2f(LVFU(l_b[i][j]), LVFU(l_a[i][j]))); + } + + for(; j < srcwidth; j++) { + tmpHue[i][j] = xatan2f(l_b[i][j], l_a[i][j]); + } + } + + #else + #pragma omp parallel for + + for(int i = 0; i < srcheight; i++) { + for(int j = 0; j < srcwidth; j++) { + tmpHue[i][j] = xatan2f(l_b[i][j], l_a[i][j]); + } + } + + #endif + tmpChr = new float*[srcheight]; + + for (int i = 0; i < srcheight; i++) { + tmpChr[i] = new float[srcwidth]; + } + + #ifdef __SSE2__ + #pragma omp parallel + { + __m128 div = _mm_set1_ps(327.68f); + #pragma omp for + + for(int i = 0; i < srcheight; i++) { + int j; + + for(j = 0; j < srcwidth - 3; j += 4) { + _mm_storeu_ps(&tmpChr[i][j], _mm_sqrt_ps(SQRV(LVFU(l_b[i][j])) + SQRV(LVFU(l_a[i][j]))) / div); + } + + for(; j < srcwidth; j++) { + tmpChr[i][j] = sqrtf(SQR((l_b[i][j])) + SQR((l_a[i][j]))) / 327.68f; + } + } + } + #else + #pragma omp parallel for + + for(int i = 0; i < srcheight; i++) { + for(int j = 0; j < srcwidth; j++) { + tmpChr[i][j] = sqrtf(SQR((l_b[i][j])) + SQR((l_a[i][j]))) / 327.68f; + } + } + + #endif + } + */ + // with the current implementation of idirpyr_eq_channel we can safely use the buffer from last level as buffer, saves some memory + float ** buffer = dirpyrlo[lastlevel - 1]; + + for(int level = lastlevel - 1; level > 0; level--) { + idirpyr_eq_channel_loc(dirpyrlo[level], dirpyrlo[level - 1], loctemp, buffer, srcwidth, srcheight, level, multi, dirpyrThreshold, tmpHue, tmpChr, skinprot, gamutlab, b_l, t_l, t_r, b_r, choice ); + } + + scale = scalesloc[0]; + + idirpyr_eq_channel_loc(dirpyrlo[0], dst, loctemp, buffer, srcwidth, srcheight, 0, multi, dirpyrThreshold, tmpHue, tmpChr, skinprot, gamutlab, b_l, t_l, t_r, b_r, choice ); + /* + if(skinprot != 0.f) { + for (int i = 0; i < srcheight; i++) { + delete [] tmpChr[i]; + } + + delete [] tmpChr; + + for (int i = 0; i < srcheight; i++) { + delete [] tmpHue[i]; + } + + delete [] tmpHue; + } + */ + //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + #pragma omp parallel for + + for (int i = 0; i < srcheight; i++) + for (int j = 0; j < srcwidth; j++) { + dst[i][j] = src[i][j]; + loctemp[i][j] = CLIP(buffer[i][j]); // TODO: Really a clip necessary? + } + +} void ImProcFunctions :: dirpyr_equalizercam (CieImage *ncie, float ** src, float ** dst, int srcwidth, int srcheight, float ** h_p, float ** C_p, const double * mult, const double dirpyrThreshold, const double skinprot, bool execdir, const bool gamutlab, float b_l, float t_l, float t_r, float b_r, int choice, int scaleprev) @@ -624,6 +834,102 @@ SSEFUNCTION void ImProcFunctions::dirpyr_channel(float ** data_fine, float ** da } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +void ImProcFunctions::idirpyr_eq_channel_loc(float ** data_coarse, float ** data_fine, float ** loctemp, float ** buffer, int width, int height, int level, float mult[5], const double dirpyrThreshold, float ** hue, float ** chrom, const double skinprot, const bool gamutlab, float b_l, float t_l, float t_r, float b_r , int choice) +{ + const float skinprotneg = -skinprot; + const float factorHard = (1.f - skinprotneg / 100.f); + + float offs; + + if(skinprot == 0.f) { + offs = 0.f; + } else { + offs = -1.f; + } + + float multbis[5]; + + multbis[level] = mult[level]; //multbis to reduce artifacts for high values mult + + if(level == 4 && mult[level] > 1.f) { + multbis[level] = 1.f + 0.65f * (mult[level] - 1.f); + } + + // if(level == 5 && mult[level] > 1.f) { + // multbis[level] = 1.f + 0.45f * (mult[level] - 1.f); + // } + + LUTf irangefn (0x20000); + { + const float noisehi = 1.33f * noise * dirpyrThreshold / expf(level * log(3.0)), noiselo = 0.66f * noise * dirpyrThreshold / expf(level * log(3.0)); + //printf("level=%i multlev=%f noisehi=%f noiselo=%f skinprot=%f\n",level,mult[level], noisehi, noiselo, skinprot); + + for (int i = 0; i < 0x20000; i++) { + if (abs(i - 0x10000) > noisehi || multbis[level] < 1.0) { + irangefn[i] = multbis[level] + offs; + } else { + if (abs(i - 0x10000) < noiselo) { + irangefn[i] = 1.f + offs ; + } else { + irangefn[i] = 1.f + offs + (multbis[level] - 1.f) * (noisehi - abs(i - 0x10000)) / (noisehi - noiselo + 0.01f) ; + } + } + } + } + + if(skinprot == 0.f) +#ifdef _OPENMP + #pragma omp parallel for schedule(dynamic,16) +#endif + for(int i = 0; i < height; i++) { + for(int j = 0; j < width; j++) { + float hipass = (data_fine[i][j] - data_coarse[i][j]); + buffer[i][j] += irangefn[hipass + 0x10000] * hipass; + } + } + + /* + else if(skinprot > 0.f) + #ifdef _OPENMP + #pragma omp parallel for schedule(dynamic,16) + #endif + for(int i = 0; i < height; i++) { + for(int j = 0; j < width; j++) { + float scale = 1.f; + float hipass = (data_fine[i][j] - data_coarse[i][j]); + // These values are precalculated now + float modhue = hue[i][j]; + float modchro = chrom[i][j]; + Color::SkinSatCbdl ((data_fine[i][j]) / 327.68f, modhue, modchro, skinprot, scale, true, b_l, t_l, t_r); + buffer[i][j] += (1.f + (irangefn[hipass + 0x10000]) * scale) * hipass ; + } + } + else + #ifdef _OPENMP + #pragma omp parallel for schedule(dynamic,16) + #endif + for(int i = 0; i < height; i++) { + for(int j = 0; j < width; j++) { + float scale = 1.f; + float hipass = (data_fine[i][j] - data_coarse[i][j]); + // These values are precalculated now + float modhue = hue[i][j]; + float modchro = chrom[i][j]; + Color::SkinSatCbdl ((data_fine[i][j]) / 327.68f, modhue, modchro, skinprotneg, scale, false, b_l, t_l, t_r); + float correct = irangefn[hipass + 0x10000]; + + if (scale == 1.f) {//image hard + buffer[i][j] += (1.f + (correct) * (factorHard)) * hipass ; + } else { //image soft with scale < 1 ==> skin + buffer[i][j] += (1.f + (correct)) * hipass ; + } + } + } + */ +} + + + void ImProcFunctions::idirpyr_eq_channel(float ** data_coarse, float ** data_fine, float ** buffer, int width, int height, int level, float mult[5], const double dirpyrThreshold, float ** hue, float ** chrom, const double skinprot, const bool gamutlab, float b_l, float t_l, float t_r, float b_r , int choice) { diff --git a/rtengine/gauss.cc b/rtengine/gauss.cc index 4b84a125a..22339d27c 100644 --- a/rtengine/gauss.cc +++ b/rtengine/gauss.cc @@ -1141,7 +1141,6 @@ template void gaussVerticalmult (T** src, T** dst, const int W, const i template void gaussianBlurImpl(T** src, T** dst, const int W, const int H, const double sigma, T *buffer = nullptr, eGaussType gausstype = GAUSS_STANDARD, T** buffer2 = nullptr) { - static constexpr auto GAUSS_SKIP = 0.25; static constexpr auto GAUSS_3X3_LIMIT = 0.6; static constexpr auto GAUSS_DOUBLE = 70.0; @@ -1189,6 +1188,9 @@ template void gaussianBlurImpl(T** src, T** dst, const int W, const int } else { if (sigma < GAUSS_SKIP) { // don't perform filtering +#ifdef _OPENMP +#pragma omp single +#endif if (src != dst) { memcpy (dst[0], src[0], W * H * sizeof(T)); } diff --git a/rtengine/gauss.h b/rtengine/gauss.h index 72f115cc4..a8cd26161 100644 --- a/rtengine/gauss.h +++ b/rtengine/gauss.h @@ -20,6 +20,8 @@ #define _GAUSS_H_ enum eGaussType {GAUSS_STANDARD, GAUSS_MULT, GAUSS_DIV}; +static constexpr auto GAUSS_SKIP = 0.25; + void gaussianBlur(float** src, float** dst, const int W, const int H, const double sigma, float *buffer = nullptr, eGaussType gausstype = GAUSS_STANDARD, float** buffer2 = nullptr); diff --git a/rtengine/improccoordinator.cc b/rtengine/improccoordinator.cc index 46cf031bd..a7c2144fb 100644 --- a/rtengine/improccoordinator.cc +++ b/rtengine/improccoordinator.cc @@ -23,6 +23,9 @@ #include "../rtgui/ppversion.h" #include "colortemp.h" #include "improcfun.h" +#include +#include +#include #include "iccstore.h" #ifdef _OPENMP #include @@ -33,63 +36,136 @@ namespace rtengine extern const Settings* settings; ImProcCoordinator::ImProcCoordinator () - : orig_prev(nullptr), oprevi(nullptr), oprevl(nullptr), nprevl(nullptr), previmg(nullptr), workimg(nullptr), - ncie(nullptr), imgsrc(nullptr), shmap(nullptr), lastAwbEqual(0.), ipf(¶ms, true), monitorIntent(RI_RELATIVE), - softProof(false), gamutCheck(false), scale(10), highDetailPreprocessComputed(false), highDetailRawComputed(false), - allocated(false), bwAutoR(-9000.f), bwAutoG(-9000.f), bwAutoB(-9000.f), CAMMean(NAN), - + : orig_prev (nullptr), oprevi (nullptr), oprevl (nullptr), nprevl (nullptr), previmg (nullptr), workimg (nullptr), + ncie (nullptr), imgsrc (nullptr), shmap (nullptr), lastAwbEqual (0.), ipf (¶ms, true), monitorIntent (RI_RELATIVE), + softProof (false), gamutCheck (false), scale (10), highDetailPreprocessComputed (false), highDetailRawComputed (false), + allocated (false), bwAutoR (-9000.f), bwAutoG (-9000.f), bwAutoB (-9000.f), CAMMean (NAN), coordX (0), coordY (0), localX (0), localY (0), + dataspot (nullptr), retistr (nullptr), retistrsav (nullptr), llstr (nullptr), lhstr (nullptr), ctColorCurve(), - hltonecurve(65536), - shtonecurve(65536), - tonecurve(65536, 0), //,1); - lumacurve(32770, 0), // lumacurve[32768] and lumacurve[32769] will be set to 32768 and 32769 later to allow linear interpolation - chroma_acurve(65536, 0), - chroma_bcurve(65536, 0), - satcurve(65536, 0), - lhskcurve(65536, 0), - clcurve(65536, 0), - wavclCurve(65536, 0), - clToningcurve(65536, 0), - cl2Toningcurve(65536, 0), - Noisecurve(65536, 0), - NoiseCCcurve(65536, 0), - vhist16(65536), vhist16bw(65536), - lhist16CAM(65536), - lhist16CCAM(65536), +// localcurve(65536, 0), + hltonecurve (65536), + shtonecurve (65536), + tonecurve (65536, 0), //,1); + lumacurve (32770, 0), // lumacurve[32768] and lumacurve[32769] will be set to 32768 and 32769 later to allow linear interpolation + chroma_acurve (65536, 0), + chroma_bcurve (65536, 0), + satcurve (65536, 0), + lhskcurve (65536, 0), + clcurve (65536, 0), + wavclCurve (65536, 0), + clToningcurve (65536, 0), + lllocalcurve (65536, 0), + + cl2Toningcurve (65536, 0), + Noisecurve (65536, 0), + NoiseCCcurve (65536, 0), + vhist16 (65536), vhist16bw (65536), + lhist16CAM (65536), + lhist16CCAM (65536), lhist16RETI(), - lhist16LClad(65536), - histRed(256), histRedRaw(256), - histGreen(256), histGreenRaw(256), - histBlue(256), histBlueRaw(256), - histLuma(256), - histToneCurve(256), - histToneCurveBW(256), - histLCurve(256), - histCCurve(256), - histLLCurve(256), + lhist16LClad (65536), + histRed (256), histRedRaw (256), + histGreen (256), histGreenRaw (256), + histBlue (256), histBlueRaw (256), + histLuma (256), + histToneCurve (256), + histToneCurveBW (256), + histLCurve (256), + histCCurve (256), + histLLCurve (256), - histLCAM(256), - histCCAM(256), - histClad(256), - bcabhist(256), - histChroma(256), + histLCAM (256), + histCCAM (256), + histClad (256), + bcabhist (256), + histChroma (256), - histLRETI(256), + histLRETI (256), CAMBrightCurveJ(), CAMBrightCurveQ(), + circrads (500, -10000), + locx (500, -10000), + locy (500, -10000), + centerx (500, -10000), + centery (500, -10000), + locxl (500, -10000), + locyt (500, -10000), + lights (500, -100000), + contrs (500, -10000), + chroms (500, -10000), + sensis (500, -10000), + transits (500, -10000), + inverss (500, -10000), + curvactivs (500, -10000), + smeths (500, -10000), + curens (500, -10000), + radiuss (500, -10000), + strengths (500, -10000), + sensibns (500, -10000), + inversrads (500, -10000), + strs (500, 10000), + chrrts (500, -10000), + neighs (500, -10000), + varts (500, -10000), + sensihs (500, -10000), + inversrets (500, -10000), + retinexs (500, -10000), + sps (500, -10000), + sharradiuss (500, -10000), + sharamounts (500, -10000), + shardampings (500, -10000), + shariters (500, -10000), + inversshas (500, -10000), + sensishas (500, -10000), + qualitys (500, -10000), + proxis (500, -10000), + thress (500, -10000), + noiselumfs (500, -10000), + noiselumcs (500, -10000), + noisechrofs (500, -10000), + noisechrocs (500, -10000), + mult0s (500, -10000), + mult1s (500, -10000), + mult2s (500, -10000), + mult3s (500, -10000), + mult4s (500, -10000), + thresholds (500, -10000), + sensicbs (500, -10000), + activlums (500, -10000), + versionmip (0), + strens (500, -10000), + gammas (500, -10000), + estops (500, -10000), + scaltms (500, -10000), + reweis (500, -10000), + sensitms (500, -10000), + reticurvs (25000, -10000), //allow 500 values for each control point * 500 + sizeretics (500, -10000), + retrabs (500, -10000), + llcurvs (25000, -10000), //allow 500 values for each control point * 500 + sizellcs (500, -10000), + lhcurvs (25000, -10000), //allow 500 values for each control point * 500 + sizelhcs (500, -10000), + + lumarefs (500, -100000.f), + chromarefs (500, -100000.f), + huerefs (500, -100000.f), + rCurve(), gCurve(), bCurve(), - rcurvehist(256), rcurvehistCropped(256), rbeforehist(256), - gcurvehist(256), gcurvehistCropped(256), gbeforehist(256), - bcurvehist(256), bcurvehistCropped(256), bbeforehist(256), - fw(0), fh(0), tr(0), - fullw(1), fullh(1), - pW(-1), pH(-1), - plistener(nullptr), imageListener(nullptr), aeListener(nullptr), acListener(nullptr), abwListener(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), wavcontlutili(false), - butili(false), ccutili(false), cclutili(false), clcutili(false), opautili(false), conversionBuffer(1, 1), colourToningSatLimit(0.f), colourToningSatLimitOpacity(0.f) + rcurvehist (256), rcurvehistCropped (256), rbeforehist (256), + gcurvehist (256), gcurvehistCropped (256), gbeforehist (256), + bcurvehist (256), bcurvehistCropped (256), bbeforehist (256), + fw (0), fh (0), tr (0), + fullw (1), fullh (1), + pW (-1), pH (-1), + plistener (nullptr), imageListener (nullptr), aeListener (nullptr), acListener (nullptr), abwListener (nullptr), aloListener (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), wavcontlutili (false), + butili (false), ccutili (false), cclutili (false), clcutili (false), opautili (false), conversionBuffer (1, 1), colourToningSatLimit (0.f), colourToningSatLimitOpacity (0.f) + + {} void ImProcCoordinator::assign (ImageSource* imgsrc) @@ -133,7 +209,7 @@ DetailedCrop* ImProcCoordinator::createCrop (::EditDataProvider *editDataProvid void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) { - MyMutex::MyLock processingLock(mProcessing); + MyMutex::MyLock processingLock (mProcessing); int numofphases = 14; int readyphase = 0; @@ -164,15 +240,15 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) ColorManagementParams cmp = params.icm; LCurveParams lcur = params.labCurve; - if( !highDetailNeeded ) { + if ( !highDetailNeeded ) { // if below 100% magnification, take a fast path - if(rp.bayersensor.method != RAWParams::BayerSensor::methodstring[RAWParams::BayerSensor::none] && rp.bayersensor.method != RAWParams::BayerSensor::methodstring[RAWParams::BayerSensor::mono]) { + if (rp.bayersensor.method != RAWParams::BayerSensor::methodstring[RAWParams::BayerSensor::none] && rp.bayersensor.method != RAWParams::BayerSensor::methodstring[RAWParams::BayerSensor::mono]) { rp.bayersensor.method = RAWParams::BayerSensor::methodstring[RAWParams::BayerSensor::fast]; } //bayerrp.all_enhance = false; - if(rp.xtranssensor.method != RAWParams::XTransSensor::methodstring[RAWParams::XTransSensor::none] && rp.xtranssensor.method != RAWParams::XTransSensor::methodstring[RAWParams::XTransSensor::mono]) { + if (rp.xtranssensor.method != RAWParams::XTransSensor::methodstring[RAWParams::XTransSensor::none] && rp.xtranssensor.method != RAWParams::XTransSensor::methodstring[RAWParams::XTransSensor::mono]) { rp.xtranssensor.method = RAWParams::XTransSensor::methodstring[RAWParams::XTransSensor::fast]; } @@ -185,8 +261,8 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) // raw auto CA is bypassed if no high detail is needed, so we have to compute it when high detail is needed if ( (todo & M_PREPROC) || (!highDetailPreprocessComputed && highDetailNeeded)) { - imgsrc->preprocess( rp, params.lensProf, params.coarse ); - imgsrc->getRAWHistogram( histRedRaw, histGreenRaw, histBlueRaw ); + imgsrc->preprocess ( rp, params.lensProf, params.coarse ); + imgsrc->getRAWHistogram ( histRedRaw, histGreenRaw, histBlueRaw ); if (highDetailNeeded) { highDetailPreprocessComputed = true; @@ -214,13 +290,13 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) if (settings->verbose) { if (imgsrc->getSensorType() == ST_BAYER) { - printf("Demosaic Bayer image using method: %s\n", rp.bayersensor.method.c_str()); + printf ("Demosaic Bayer image using method: %s\n", rp.bayersensor.method.c_str()); } else if (imgsrc->getSensorType() == ST_FUJI_XTRANS) { - printf("Demosaic X-Trans image with using method: %s\n", rp.xtranssensor.method.c_str()); + printf ("Demosaic X-Trans image with using method: %s\n", rp.xtranssensor.method.c_str()); } } - imgsrc->demosaic( rp);//enabled demosaic + imgsrc->demosaic ( rp); //enabled demosaic // if a demosaic happened we should also call getimage later, so we need to set the M_INIT flag todo |= M_INIT; @@ -231,10 +307,10 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) } if (params.retinex.enabled) { - lhist16RETI(32768); + lhist16RETI (32768); lhist16RETI.clear(); - imgsrc->retinexPrepareBuffers(params.icm, params.retinex, conversionBuffer, lhist16RETI); + imgsrc->retinexPrepareBuffers (params.icm, params.retinex, conversionBuffer, lhist16RETI); } } @@ -245,12 +321,12 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) LUTf cdcurve (65536, 0); LUTf mapcurve (65536, 0); - imgsrc->retinexPrepareCurves(params.retinex, cdcurve, mapcurve, dehatransmissionCurve, dehagaintransmissionCurve, dehacontlutili, mapcontlutili, useHsl, lhist16RETI, histLRETI); + imgsrc->retinexPrepareCurves (params.retinex, cdcurve, mapcurve, dehatransmissionCurve, dehagaintransmissionCurve, dehacontlutili, mapcontlutili, useHsl, lhist16RETI, histLRETI); float minCD, maxCD, mini, maxi, Tmean, Tsigma, Tmin, Tmax; - imgsrc->retinex( params.icm, params.retinex, params.toneCurve, cdcurve, mapcurve, dehatransmissionCurve, dehagaintransmissionCurve, conversionBuffer, dehacontlutili, mapcontlutili, useHsl, minCD, maxCD, mini, maxi, Tmean, Tsigma, Tmin, Tmax, histLRETI);//enabled Retinex + imgsrc->retinex ( params.icm, params.retinex, params.toneCurve, cdcurve, mapcurve, dehatransmissionCurve, dehagaintransmissionCurve, conversionBuffer, dehacontlutili, mapcontlutili, useHsl, minCD, maxCD, mini, maxi, Tmean, Tsigma, Tmin, Tmax, histLRETI); //enabled Retinex - if(dehaListener) { - dehaListener->minmaxChanged(maxCD, minCD, mini, maxi, Tmean, Tsigma, Tmin, Tmax); + if (dehaListener) { + dehaListener->minmaxChanged (maxCD, minCD, mini, maxi, Tmean, Tsigma, Tmin, Tmax); } } @@ -259,7 +335,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) // It has to be done there, because the next 'if' statement will use the value computed here if (todo & M_AUTOEXP) { if (params.toneCurve.autoexp) {// this enabled HLRecovery - if (ToneCurveParams::HLReconstructionNecessary(histRedRaw, histGreenRaw, histBlueRaw) && !params.toneCurve.hrenabled) { + if (ToneCurveParams::HLReconstructionNecessary (histRedRaw, histGreenRaw, histBlueRaw) && !params.toneCurve.hrenabled) { // switching params.toneCurve.hrenabled to true -> shouting in listener's ears! params.toneCurve.hrenabled = true; @@ -270,9 +346,9 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) } if (todo & (M_INIT | M_LINDENOISE)) { - MyMutex::MyLock initLock(minit); // Also used in crop window + MyMutex::MyLock initLock (minit); // Also used in crop window - imgsrc->HLRecovery_Global( params.toneCurve); // this handles Color HLRecovery + imgsrc->HLRecovery_Global ( params.toneCurve); // this handles Color HLRecovery if (settings->verbose) { @@ -286,14 +362,14 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) } else if (params.wb.method == "Auto") { if (lastAwbEqual != params.wb.equal) { double rm, gm, bm; - imgsrc->getAutoWBMultipliers(rm, gm, bm); + imgsrc->getAutoWBMultipliers (rm, gm, bm); if (rm != -1.) { - autoWB.update(rm, gm, bm, params.wb.equal); + autoWB.update (rm, gm, bm, params.wb.equal); lastAwbEqual = params.wb.equal; } else { lastAwbEqual = -1.; - autoWB.useDefaults(params.wb.equal); + autoWB.useDefaults (params.wb.equal); } //double rr,gg,bb; @@ -306,7 +382,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) params.wb.temperature = currWB.getTemp (); params.wb.green = currWB.getGreen (); - int tr = getCoarseBitMask(params.coarse); + int tr = getCoarseBitMask (params.coarse); imgsrc->getFullSize (fw, fh, tr); @@ -361,7 +437,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) } } */ - imgsrc->convertColorSpace(orig_prev, params.icm, currWB); + imgsrc->convertColorSpace (orig_prev, params.icm, currWB); ipf.firstAnalysis (orig_prev, params, vhist16); } @@ -372,42 +448,45 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) // Remove transformation if unneeded bool needstransform = ipf.needsTransform(); - if (!needstransform && !((todo & (M_TRANSFORM | M_RGBCURVE)) && params.dirpyrequalizer.cbdlMethod == "bef" && params.dirpyrequalizer.enabled && !params.colorappearance.enabled) && orig_prev != oprevi) { + if (!needstransform && ! ((todo & (M_TRANSFORM | M_RGBCURVE)) && params.dirpyrequalizer.cbdlMethod == "bef" && params.dirpyrequalizer.enabled && !params.colorappearance.enabled) && orig_prev != oprevi) { delete oprevi; oprevi = orig_prev; } if ((needstransform || ((todo & (M_TRANSFORM | M_RGBCURVE)) && params.dirpyrequalizer.cbdlMethod == "bef" && params.dirpyrequalizer.enabled && !params.colorappearance.enabled)) ) { - if(!oprevi || oprevi == orig_prev) + if (!oprevi || oprevi == orig_prev) { oprevi = new Imagefloat (pW, pH); + } + if (needstransform) ipf.transform (orig_prev, oprevi, 0, 0, 0, 0, pW, pH, fw, fh, imgsrc->getMetaData()->getFocalLen(), imgsrc->getMetaData()->getFocalLen35mm(), imgsrc->getMetaData()->getFocusDist(), imgsrc->getRotateDegree(), false); - else - orig_prev->copyData(oprevi); + else { + orig_prev->copyData (oprevi); + } } if ((todo & (M_TRANSFORM | M_RGBCURVE)) && params.dirpyrequalizer.cbdlMethod == "bef" && params.dirpyrequalizer.enabled && !params.colorappearance.enabled) { const int W = oprevi->getWidth(); const int H = oprevi->getHeight(); - LabImage labcbdl(W, H); - ipf.rgb2lab(*oprevi, labcbdl, params.icm.working); + LabImage labcbdl (W, H); + ipf.rgb2lab (*oprevi, labcbdl, params.icm.working); ipf.dirpyrequalizer (&labcbdl, scale); - ipf.lab2rgb(labcbdl, *oprevi, params.icm.working); + ipf.lab2rgb (labcbdl, *oprevi, params.icm.working); } readyphase++; progress ("Preparing shadow/highlight map...", 100 * readyphase / numofphases); if ((todo & M_BLURMAP) && params.sh.enabled) { - double radius = sqrt (double(pW * pW + pH * pH)) / 2.0; + double radius = sqrt (double (pW * pW + pH * pH)) / 2.0; double shradius = params.sh.radius; if (!params.sh.hq) { shradius *= radius / 1800.0; } - if(!shmap) { + if (!shmap) { shmap = new SHMap (pW, pH, true); } @@ -451,7 +530,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) opautili = false; - if(params.colorToning.enabled) { + if (params.colorToning.enabled) { TMatrix wprof = iccStore->workingSpaceMatrix (params.icm.working); double wp[3][3] = { {wprof[0][0], wprof[0][1], wprof[0][2]}, @@ -464,34 +543,34 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) {wiprof[1][0], wiprof[1][1], wiprof[1][2]}, {wiprof[2][0], wiprof[2][1], wiprof[2][2]} }; - params.colorToning.getCurves(ctColorCurve, ctOpacityCurve, wp, wip, opautili); - CurveFactory::curveToning(params.colorToning.clcurve, clToningcurve, scale == 1 ? 1 : 16); - CurveFactory::curveToning(params.colorToning.cl2curve, cl2Toningcurve, scale == 1 ? 1 : 16); + params.colorToning.getCurves (ctColorCurve, ctOpacityCurve, wp, wip, opautili); + CurveFactory::curveToning (params.colorToning.clcurve, clToningcurve, scale == 1 ? 1 : 16); + CurveFactory::curveToning (params.colorToning.cl2curve, cl2Toningcurve, scale == 1 ? 1 : 16); } - if(params.blackwhite.enabled) { + if (params.blackwhite.enabled) { CurveFactory::curveBW (params.blackwhite.beforeCurve, params.blackwhite.afterCurve, vhist16bw, histToneCurveBW, beforeToneCurveBW, afterToneCurveBW, 1); } - colourToningSatLimit = float(params.colorToning.satProtectionThreshold) / 100.f * 0.7f + 0.3f; - colourToningSatLimitOpacity = 1.f - (float(params.colorToning.saturatedOpacity) / 100.f); + colourToningSatLimit = float (params.colorToning.satProtectionThreshold) / 100.f * 0.7f + 0.3f; + colourToningSatLimitOpacity = 1.f - (float (params.colorToning.saturatedOpacity) / 100.f); int satTH = 80; int satPR = 30; int indi = 0; - if(params.colorToning.enabled && params.colorToning.autosat) { //for colortoning evaluation of saturation settings + if (params.colorToning.enabled && params.colorToning.autosat) { //for colortoning evaluation of saturation settings float moyS = 0.f; float eqty = 0.f; ipf.moyeqt (oprevi, moyS, eqty);//return image : mean saturation and standard dev of saturation //printf("moy=%f ET=%f\n", moyS,eqty); float satp = ((moyS + 1.5f * eqty) - 0.3f) / 0.7f; //1.5 sigma ==> 93% pixels with high saturation -0.3 / 0.7 convert to Hombre scale - if(satp >= 0.92f) { + if (satp >= 0.92f) { satp = 0.92f; //avoid values too high (out of gamut) } - if(satp <= 0.15f) { + if (satp <= 0.15f) { satp = 0.15f; //avoid too low values } @@ -504,22 +583,22 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) satPR = (int) 100.f * (moyS - 0.85f * eqty); } - if(actListener) { + if (actListener) { //if(params.blackwhite.enabled) {actListener->autoColorTonChanged(0, satTH, satPR);} - if(params.blackwhite.enabled && params.colorToning.autosat) { - actListener->autoColorTonChanged(0, satTH, satPR); //hide sliders only if autosat + if (params.blackwhite.enabled && params.colorToning.autosat) { + actListener->autoColorTonChanged (0, satTH, satPR); //hide sliders only if autosat indi = 0; } else { - if(params.colorToning.autosat) { + if (params.colorToning.autosat) { if (params.colorToning.method == "Lab") { indi = 1; - } else if(params.colorToning.method == "RGBCurves") { + } else if (params.colorToning.method == "RGBCurves") { indi = 1; - } else if(params.colorToning.method == "RGBSliders") { + } else if (params.colorToning.method == "RGBSliders") { indi = 1; - } else if(params.colorToning.method == "Splico") { + } else if (params.colorToning.method == "Splico") { indi = 2; - } else if(params.colorToning.method == "Splitlr") { + } else if (params.colorToning.method == "Splitlr") { indi = 2; } @@ -536,46 +615,48 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) double bbm = 33.; DCPProfile::ApplyState as; - DCPProfile *dcpProf = imgsrc->getDCP(params.icm, currWB, as); + DCPProfile *dcpProf = imgsrc->getDCP (params.icm, currWB, as); ipf.rgbProc (oprevi, oprevl, nullptr, hltonecurve, shtonecurve, tonecurve, shmap, params.toneCurve.saturation, rCurve, gCurve, bCurve, colourToningSatLimit , colourToningSatLimitOpacity, ctColorCurve, ctOpacityCurve, opautili, clToningcurve, cl2Toningcurve, customToneCurve1, customToneCurve2, beforeToneCurveBW, afterToneCurveBW, rrm, ggm, bbm, bwAutoR, bwAutoG, bwAutoB, params.toneCurve.expcomp, params.toneCurve.hlcompr, params.toneCurve.hlcomprthresh, dcpProf, as, histToneCurve); - if(params.blackwhite.enabled && params.blackwhite.autoc && abwListener) { + if (params.blackwhite.enabled && params.blackwhite.autoc && abwListener) { if (settings->verbose) { - printf("ImProcCoordinator / Auto B&W coefs: R=%.2f G=%.2f B=%.2f\n", bwAutoR, bwAutoG, bwAutoB); + printf ("ImProcCoordinator / Auto B&W coefs: R=%.2f G=%.2f B=%.2f\n", bwAutoR, bwAutoG, bwAutoB); } - abwListener->BWChanged((float) rrm, (float) ggm, (float) bbm); + abwListener->BWChanged ((float) rrm, (float) ggm, (float) bbm); } - if(params.colorToning.autosat && actListener) { + if (params.colorToning.autosat && actListener) { if (settings->verbose) { - printf("ImProcCoordinator / Auto CT: indi=%d satH=%d satPR=%d\n", indi, (int)colourToningSatLimit , (int) colourToningSatLimitOpacity); + printf ("ImProcCoordinator / Auto CT: indi=%d satH=%d satPR=%d\n", indi, (int)colourToningSatLimit , (int) colourToningSatLimitOpacity); } - actListener->autoColorTonChanged(indi, (int) colourToningSatLimit, (int)colourToningSatLimitOpacity);//change sliders autosat + actListener->autoColorTonChanged (indi, (int) colourToningSatLimit, (int)colourToningSatLimitOpacity); //change sliders autosat } // correct GUI black and white with value } + // ipf.Lab_Tile(oprevl, oprevl, scale); + // compute L channel histogram int x1, y1, x2, y2; - params.crop.mapToResized(pW, pH, scale, x1, x2, y1, y2); + params.crop.mapToResized (pW, pH, scale, x1, x2, y1, y2); } readyphase++; + LUTu lhist16 (32768); if (todo & (M_LUMACURVE | M_CROP)) { - LUTu lhist16(32768); lhist16.clear(); #ifdef _OPENMP - const int numThreads = min(max(pW * pH / (int)lhist16.getSize(), 1), omp_get_max_threads()); + const int numThreads = min (max (pW * pH / (int)lhist16.getSize(), 1), omp_get_max_threads()); #pragma omp parallel num_threads(numThreads) if(numThreads>1) #endif { - LUTu lhist16thr(lhist16.getSize()); + LUTu lhist16thr (lhist16.getSize()); lhist16thr.clear(); #ifdef _OPENMP #pragma omp for nowait @@ -583,7 +664,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) for (int x = 0; x < pH; x++) for (int y = 0; y < pW; y++) { - int pos = (int)(oprevl->L[x][y]); + int pos = (int) (oprevl->L[x][y]); lhist16thr[pos]++; } @@ -597,24 +678,1592 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) if (todo & M_LUMACURVE) { - CurveFactory::curveCL(clcutili, params.labCurve.clcurve, clcurve, scale == 1 ? 1 : 16); + CurveFactory::curveCL (clcutili, params.labCurve.clcurve, clcurve, scale == 1 ? 1 : 16); CurveFactory::complexsgnCurve (autili, butili, ccutili, cclutili, params.labCurve.acurve, params.labCurve.bcurve, params.labCurve.cccurve, params.labCurve.lccurve, chroma_acurve, chroma_bcurve, satcurve, lhskcurve, scale == 1 ? 1 : 16); } + //scale = 1; if (todo & (M_LUMINANCE + M_COLOR) ) { - nprevl->CopyFrom(oprevl); - + nprevl->CopyFrom (oprevl); + int maxspot = settings->nspot + 1; progress ("Applying Color Boost...", 100 * readyphase / numofphases); - // ipf.MSR(nprevl, nprevl->W, nprevl->H, 1); + + + if (params.locallab.enabled) { + /* + * 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 . + * 2017 Jacques Desmis + */ + + + // Glib::ustring datalab = imgsrc->getFileName() + ".mip"; + // printf("mip file=%s \n", datalab.c_str()); + Glib::ustring pop = options.getUserProfilePath() + "/"; + Glib::ustring datal; + + if (options.mip == MI_opt) { + datal = pop + Glib::path_get_basename (imgsrc->getFileName () + ".mip"); + } + + if (options.mip == MI_prev) { + datal = imgsrc->getFileName() + ".mip"; + } + + /* + //test to see if wofstream and wifstream works with NON ASCII, but it's bad + wofstream test(datal, ios::out); + if(test.fail()) printf("ca va pas\n"); + else ("ca va bien\n"); + test.close(); + */ + ifstream fic0 (datal, ios::in); + + printf ("mip files in=%s\n", datal.c_str()); + // if(! fic0.fail()) { + float **shbuffer; + versionmip = 0; + int maxdat; + int sca = 1; + //string delim ==> delimiter to separate integer in a string, 70 is lagely enough for curves : noramlly 3 to 21 must be suffisant + std::string delim[69] = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", + "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", + "&", "#", "{", "[", "]", "}", "$", "*", "?", ">", "!", ";", "<", "(", ")", "+", "-" + }; + + + + if (fic0) { + //find current version mip + std::string line; + std::string spotline; + int cont = 0; + + while (getline (fic0, line)) { + spotline = line; + std::size_t pos = spotline.find ("="); + std::size_t posend = spotline.find ("@"); //in case of for futur use + + if (spotline.substr (0, pos) == "Mipversion") { + std::string strversion = spotline.substr (pos + 1, (posend - pos)); + versionmip = std::stoi (strversion.c_str()); + } + + if (spotline.substr (0, pos) == "Spot") { + // string str2 = spotline.substr (pos + 1, (posend - pos)); + cont = 0; + } + + + } + + fic0.close(); + } + + printf ("mipvers=%i\n", versionmip); + ifstream fic (datal, ios::in); + bool reinit = false; + + //printf("versionmip=%i nbspot=%i\n", versionmip, params.locallab.nbspot) ; + + + if (fic.fail() || versionmip == 0 || params.locallab.nbspot == 0) { //initialize mip with default values if no file or old file to prevent crash + + ofstream fic (datal, ios::out | ios::trunc); // ouverture en écriture avec effacement du fichier ouvert + + if (params.locallab.nbspot == 0) { + params.locallab.nbspot = 1; + } + + + if (fic) + + { + for (int sp = 1; sp < maxspot; sp++) { // spots default + int t_sp = sp; + int t_mipversion = 10005;//new value for tone mapping + int t_circrad = 18; + int t_locX = 250; + int t_locY = 250; + int t_locYT = 250; + int t_locXL = 250; + int t_centerX = 0; + int t_centerY = 0; + int t_lightness = 0; + int t_contrast = 0; + int t_chroma = 0; + int t_sensi = 19; + int t_transit = 60; + int t_invers = 0; + int t_Smeth = 0; + int t_currentspot = 1; + int t_radius = 0; + int t_strength = 0; + int t_sensibn = 60; + int t_inversrad = 0; + int t_str = 0; + int t_chrrt = 0; + int t_neigh = 50; + int t_vart = 200; + int t_sensih = 19; + int t_inversret = 0; + int t_retinexMethod = 2; + int t_sharradius = 40; + int t_sharamount = 75; + int t_shardamping = 75; + int t_shariter = 30; + int t_sensisha = 19; + int t_inverssha = 0; + int t_qualityMethod = 0; + int t_thres = 50; + int t_proxi = 2; + int t_noiselumf = 0; + int t_noiselumc = 0; + int t_noisechrof = 0; + int t_noisechroc = 0; + int t_mult0 = 100; + int t_mult1 = 100; + int t_mult2 = 100; + int t_mult3 = 100; + int t_mult4 = 100; + int t_threshold = 20; + int t_sensicb = 19; + int t_activlum = 0; + // end versionmip = 10000 + + //begin versionmip = 10001 Tone mapping + int t_stren = 0; + int t_gamma = 100; + int t_estop = 140; + int t_scaltm = 3; + int t_rewei = 0; + int t_sensitm = 40; + + //versionmip = 10002 Reticurv + int t_retrab = 500; + + std::string t_curvret = "1000A0B120C350D350E700F500G350H350I1000J120K350L350M";//12 points + //10003 + //std::string t_curvll = "0A"; + std::string t_curvll = "3000A0B0C1000D1000E"; //"3000A0B0C499D501E1000F1000G";// "3000A0B0C1000D1000E";//with that it works ! + + //versionmip = 10004 LHcurv + std::string t_curvlh = "1000A0B500C350D350E166F500G350H350I333J500K350L350M500N500O350P350Q666R500S350T350U833V500W350X350Y"; + //10005 + int t_curvactiv = 0; + + //all variables except locRETgainCurve 'coomon for all) + fic << "Mipversion=" << t_mipversion << '@' << endl; + fic << "Spot=" << t_sp << '@' << endl; + fic << "Circrad=" << t_circrad << '@' << endl; + fic << "LocX=" << t_locX << '@' << endl; + fic << "LocY=" << t_locY << '@' << endl; + fic << "LocYT=" << t_locYT << '@' << endl; + fic << "LocXL=" << t_locXL << '@' << endl ; + fic << "CenterX=" << t_centerX << '@' << endl; + fic << "CenterY=" << t_centerY << '@' << endl; + fic << "Lightness=" << t_lightness << '@' << endl; + fic << "Contrast=" << t_contrast << '@' << endl; + fic << "Chroma=" << t_chroma << '@' << endl; + fic << "Sensi=" << t_sensi << '@' << endl; + fic << "Transit=" << t_transit << '@' << endl; + fic << "Invers=" << t_invers << '@' << endl; + fic << "Smethod=" << t_Smeth << '@' << endl; + fic << "Currentspot=" << t_currentspot << '@' << endl; + fic << "Radius=" << t_radius << '@' << endl; + fic << "Strength=" << t_strength << '@' << endl; + fic << "Sensibn=" << t_sensibn << '@' << endl; + fic << "Inversrad=" << t_inversrad << '@' << endl; + fic << "Str=" << t_str << '@' << endl; + fic << "Chroma=" << t_chrrt << '@' << endl; + fic << "Neigh=" << t_neigh << '@' << endl; + fic << "Vart=" << t_vart << '@' << endl; + fic << "Sensih=" << t_sensih << '@' << endl; + fic << "Inversret=" << t_inversret << '@' << endl; + fic << "retinexMethod=" << t_retinexMethod << '@' << endl; + fic << "Sharradius=" << t_sharradius << '@' << endl; + fic << "Sharamount=" << t_sharamount << '@' << endl; + fic << "Shardamping=" << t_shardamping << '@' << endl; + fic << "Shariter=" << t_shariter << '@' << endl; + fic << "Sensisha=" << t_sensisha << '@' << endl; + fic << "Inverssha=" << t_inverssha << '@' << endl; + fic << "qualityMethod=" << t_qualityMethod << '@' << endl; + fic << "Thres=" << t_thres << '@' << endl; + fic << "Proxi=" << t_proxi << '@' << endl; + fic << "Noiselumf=" << t_noiselumf << '@' << endl; + fic << "Noiselumc=" << t_noiselumc << '@' << endl; + fic << "Noisechrof=" << t_noisechrof << '@' << endl; + fic << "Noisechroc=" << t_noisechroc << '@' << endl; + fic << "Mult0=" << t_mult0 << '@' << endl; + fic << "Mult1=" << t_mult1 << '@' << endl; + fic << "Mult2=" << t_mult2 << '@' << endl; + fic << "Mult3=" << t_mult3 << '@' << endl; + fic << "Mult4=" << t_mult4 << '@' << endl; + fic << "Threshold=" << t_threshold << '@' << endl; + fic << "Sensicb=" << t_sensicb << '@' << endl; + fic << "Activblurlum=" << t_activlum << '@' << endl; + + fic << "Stren=" << t_stren << '@' << endl; + fic << "Gamma=" << t_gamma << '@' << endl; + fic << "Estop=" << t_estop << '@' << endl; + fic << "Scaltm=" << t_scaltm << '@' << endl; + fic << "Rewei=" << t_rewei << '@' << endl; + fic << "Sensitm=" << t_sensitm << '@' << endl; + + fic << "Retrab=" << t_retrab << '@' << endl; + fic << "Curvactiv=" << t_curvactiv << '@' << endl; + + fic << "curveReti=" << t_curvret << '@' << endl; + fic << "curveLL=" << t_curvll << '@' << endl; + fic << "curveLH=" << t_curvlh << '@' << endl; + + fic << endl; + } + + fic.close(); + + } else + + { + cerr << "can't open file !" << endl; + } + + } + + + + int realspot = params.locallab.nbspot; + std::string inser; + dataspot = new int*[60]; + + for (int i = 0; i < 60; i++) { + dataspot[i] = new int[maxspot]; + } + + retistr = new std::string[maxspot]; + llstr = new std::string[maxspot]; + lhstr = new std::string[maxspot]; + + + { + sps[0] = 0; + dataspot[2][0] = circrads[0] = params.locallab.circrad; + dataspot[3][0] = locx[0] = params.locallab.locX; + dataspot[4][0] = locy[0] = params.locallab.locY; + dataspot[5][0] = locyt[0] = params.locallab.locYT; + dataspot[6][0] = locxl[0] = params.locallab.locXL; + dataspot[7][0] = centerx[0] = params.locallab.centerX; + dataspot[8][0] = centery[0] = params.locallab.centerY; + dataspot[9][0] = lights[0] = params.locallab.lightness; + dataspot[10][0] = contrs[0] = params.locallab.contrast; + dataspot[11][0] = chroms[0] = params.locallab.chroma; + dataspot[12][0] = sensis[0] = params.locallab.sensi; + dataspot[13][0] = transits[0] = params. locallab.transit; + + if (!params.locallab.invers) { + dataspot[14][0] = inverss[0] = 0; + } else { + dataspot[14][0] = inverss[0] = 1; + } + + if (params.locallab.Smethod == "IND") { + dataspot[15][0] = smeths[0] = 0; + } else if (params.locallab.Smethod == "SYM") { + dataspot[15][0] = smeths[0] = 1; + } else if (params.locallab.Smethod == "INDSL") { + dataspot[15][0] = smeths[0] = 2; + } else if (params.locallab.Smethod == "SYMSL") { + dataspot[15][0] = smeths[0] = 3; + } + + dataspot[16][0] = curens[0] = params.locallab.nbspot; + dataspot[17][0] = radiuss[0] = params.locallab.radius; + dataspot[18][0] = strengths[0] = params.locallab.strength; + dataspot[19][0] = sensibns[0] = params.locallab.sensibn; + + + if (!params.locallab.inversrad) { + dataspot[20][0] = inversrads[0] = 0; + } else { + dataspot[20][0] = inversrads[0] = 1; + } + + dataspot[21][0] = strs[0] = params.locallab.str; + dataspot[22][0] = chrrts[0] = params.locallab.chrrt; + dataspot[23][0] = neighs[0] = params.locallab.neigh; + dataspot[24][0] = varts[0] = params.locallab.vart; + dataspot[25][0] = sensihs[0] = params.locallab.sensih; + + if (!params.locallab.inversret) { + dataspot[26][0] = inversrets[0] = 0; + } else { + dataspot[26][0] = inversrets[0] = 1; + } + + if (params.locallab.retinexMethod == "low") { + dataspot[27][0] = retinexs[0] = 0; + } else if (params.locallab.retinexMethod == "uni") { + dataspot[27][0] = retinexs[0] = 1; + } else if (params.locallab.retinexMethod == "high") { + dataspot[27][0] = retinexs[0] = 2; + } + + dataspot[28][0] = sharradiuss[0] = params.locallab.sharradius; + dataspot[29][0] = sharamounts[0] = params.locallab.sharamount; + dataspot[30][0] = shardampings[0] = params.locallab.shardamping; + dataspot[31][0] = shariters[0] = params.locallab.shariter; + dataspot[32][0] = sensishas[0] = params.locallab.sensisha; + + if (!params.locallab.inverssha) { + dataspot[33][0] = inversshas[0] = 0; + } else { + dataspot[33][0] = inversshas[0] = 1; + } + + if (params.locallab.qualityMethod == "std") { + dataspot[34][0] = qualitys[0] = 0; + } else if (params.locallab.qualityMethod == "enh") { + dataspot[34][0] = qualitys[0] = 1; + } else if (params.locallab.qualityMethod == "enhden") { + dataspot[34][0] = qualitys[0] = 2; + } + + dataspot[35][0] = thress[0] = params.locallab.thres; + dataspot[36][0] = proxis[0] = params.locallab.proxi; + dataspot[37][0] = noiselumfs[0] = params.locallab.noiselumf; + dataspot[38][0] = noiselumcs[0] = params.locallab.noiselumc; + dataspot[39][0] = noisechrofs[0] = params.locallab.noisechrof; + dataspot[40][0] = noisechrocs[0] = params.locallab.noisechroc; + + dataspot[41][0] = mult0s[0] = params.locallab.mult[0]; + dataspot[42][0] = mult1s[0] = params.locallab.mult[1]; + dataspot[43][0] = mult2s[0] = params.locallab.mult[2]; + dataspot[44][0] = mult3s[0] = params.locallab.mult[3]; + dataspot[45][0] = mult4s[0] = params.locallab.mult[4]; + dataspot[46][0] = thresholds[0] = params.locallab.threshold; + dataspot[47][0] = sensicbs[0] = params.locallab.sensicb; + + if (!params.locallab.activlum) { + dataspot[48][0] = activlums[0] = 0; + } else { + dataspot[48][0] = activlums[0] = 1; + } + + dataspot[49][0] = strens[0] = params.locallab.stren; + dataspot[50][0] = gammas[0] = params.locallab.gamma; + dataspot[51][0] = estops[0] = params.locallab.estop; + dataspot[52][0] = scaltms[0] = params.locallab.scaltm; + dataspot[53][0] = reweis[0] = params.locallab.rewei; + dataspot[54][0] = sensitms[0] = params.locallab.sensitm; + dataspot[55][0] = retrabs[0] = params.locallab.retrab; + + if (!params.locallab.curvactiv) { + dataspot[56][0] = curvactivs[0] = 0; + } else { + dataspot[56][0] = curvactivs[0] = 1; + } + + //curve Reti local + int siz = params.locallab.localTgaincurve.size(); + + if (siz > 69) { + siz = 69; //to avoid crash + } + + int s_cur[siz + 1]; + int s_datcur[siz + 1]; + + for (int j = 0; j < siz; j++) { + s_datcur[j] = reticurvs[0 + j] = (int) (1000. * params.locallab.localTgaincurve[j]); + } + + std::string cur_str = ""; + + for (int j = 0; j < siz; j++) { + cur_str = cur_str + std::to_string (s_datcur[j]) + delim[j]; + } + + inser = retistr[0] = cur_str + "@"; + //end retistr + + //curve local L Lum + int sizl = params.locallab.llcurve.size(); + + if (sizl > 69) { + sizl = 69;//to avoid crash + } + + int s_curl[sizl + 1]; + int s_datcurl[sizl + 1]; + + for (int j = 0; j < sizl; j++) { + s_datcurl[j] = llcurvs[0 + j] = (int) (1000. * params.locallab.llcurve[j]); + } + + std::string ll_str = ""; + + for (int j = 0; j < sizl; j++) { + ll_str = ll_str + std::to_string (s_datcurl[j]) + delim[j]; + } + + llstr[0] = ll_str + "@"; + //end local L f(L) + + //curve local L f(H) + int sizh = params.locallab.LHcurve.size(); + + if (sizh > 69) { + sizh = 69;//to avoid crash + } + + int s_curh[sizh + 1]; + int s_datcurh[sizh + 1]; + + for (int j = 0; j < sizh; j++) { + s_datcurh[j] = lhcurvs[0 + j] = (int) (1000. * params.locallab.LHcurve[j]); + } + + std::string lh_str = ""; + + for (int j = 0; j < sizh; j++) { + lh_str = lh_str + std::to_string (s_datcurh[j]) + delim[j]; + } + + lhstr[0] = lh_str + "@"; + //end local L = f(H) + + + + + if (params.locallab.anbspot == 0) { + //update GUI and MIP after current spot ==> params, shift with the other alolistener + if (aloListener && params.locallab.anbspot == 0) { + aloListener->localretChanged (dataspot, retistr[0], llstr[0], lhstr[0], 0, 1); + } + } + + locallutili = false; + + } + + + + //end save + + + int ns; + int realsp = params.locallab.nbspot; + bool excurvret = true; + bool excurvll = true; + bool excurvlh = true; + + ifstream fich (datal, ios::in); + + if (fich) {//may be a file with versionmip = 10000 + // if(versionmip == 10000) add new blank fields for tone-mapping because TM is 10001 + //we must add new fields at the good place + std::string line; + std::string spotline; + int cont = 0; + int maxind = 57; + + if (versionmip == 10000) { + maxind = 49; + excurvret = false; + excurvll = false; + excurvlh = false; + } + + if (versionmip == 10001) { + maxind = 55; + excurvret = false; + excurvll = false; + excurvlh = false; + + } + + if (versionmip == 10004) { + maxind = 56; + } + + int sizecu; + int sizell; + int sizelh; + + while (getline (fich, line)) { + spotline = line; + std::size_t pos = spotline.find ("="); + std::size_t posend = spotline.find ("@"); //in case of for futur use + + if (spotline.substr (0, pos) == "Mipversion") { + std::string strversion = spotline.substr (pos + 1, (posend - pos)); + versionmip = std::stoi (strversion.c_str()); + } + + if (spotline.substr (0, pos) == "Spot") { + cont = 0; + } + + cont++; + std::string str3 = spotline.substr (pos + 1, (posend - pos)); + + if (cont == 1) { + ns = std::stoi (str3.c_str()); + } + + if (cont >= 2 && cont < 16) { + dataspot[cont][ns] = std::stoi (str3.c_str()); + + } + + if (spotline.substr (0, pos) == "Currentspot") { + dataspot[16][0] = std::stoi (str3.c_str()); + } + + if (cont > 16 && cont < maxind) { + dataspot[cont][ns] = std::stoi (str3.c_str()); + + } + + + if (excurvret && spotline.substr (0, pos) == "curveReti") { + std::string curstr; + int longecur; + std::string strend = spotline.substr (posend - 1, 1); + std::size_t posz = spotline.find (strend); + int longe; + + for (int sl = 0; sl < 69; sl++) { + if (delim[sl] == strend) { + longe = sl + 1; + } + } + + retistr[ns] = str3; + sizecu = longe; + + // printf("lecture str=%s ns=%i si=%i\n", retistr[ns].c_str(), ns, sizecu); + } + + if (excurvll && spotline.substr (0, pos) == "curveLL") { + std::string curstrl; + int longecurl; + std::string strendl = spotline.substr (posend - 1, 1); + std::size_t poszl = spotline.find (strendl); + int longel; + + for (int sl = 0; sl < 69; sl++) { + if (delim[sl] == strendl) { + longel = sl + 1; + } + } + + llstr[ns] = str3; + sizell = longel; + // printf("lecture strLL=%s ns=%i si=%i\n", llstr[ns].c_str(), ns, sizell); + } + + if (excurvlh && spotline.substr (0, pos) == "curveLH") { + std::string curstrh; + int longecurh; + std::string strendh = spotline.substr (posend - 1, 1); + std::size_t poszh = spotline.find (strendh); + int longeh; + + for (int sh = 0; sh < 69; sh++) { + if (delim[sh] == strendh) { + longeh = sh + 1; + } + } + + lhstr[ns] = str3; + sizelh = longeh; + //printf("lecture strLH=%s ns=%i si=%i\n", lhstr[ns].c_str(), ns, sizelh); + } + + + } + + fich.close(); + } + + + + //new fields for TM + if (versionmip == 10000) { + for (int sp = 1; sp < maxspot; sp++) { // spots default + dataspot[49][sp] = 0; //stren + dataspot[50][sp] = 100; //gamma + dataspot[51][sp] = 140; //estop + dataspot[52][sp] = 3; //scaltm + dataspot[53][sp] = 0; //rewei + dataspot[54][sp] = 40; //sensitm + + } + } + + if (versionmip == 10001) { + + for (int sp = 1; sp < maxspot; sp++) { // spots default + dataspot[55][sp] = 500; //retrab + std::string cur_str = "1000A0B120C350D350E700F500G350H350I1000J120K350L350M";//12 points + retistr[sp] = cur_str + "@"; + } + } + + if (versionmip == 10002) { + + for (int sp = 1; sp < maxspot; sp++) { // spots default + std::string ll_str = "3000A0B0C1000D1000E"; //"3000A0B0C499D501E1000F1000G"; //"3000A0B0C1000D1000E"; //"3000A0B0C200D200E800F800G1000H1000I";//"0A" + llstr[sp] = ll_str + "@"; + } + } + + if (versionmip == 10003) { + + for (int sp = 1; sp < maxspot; sp++) { // spots default + std::string lh_str = "1000A0B500C350D350E166F500G350H350I333J500K350L350M500N500O350P350Q666R500S350T350U833V500W350X350Y"; + lhstr[sp] = lh_str + "@"; + } + } + + if (versionmip == 10004) { + + for (int sp = 1; sp < maxspot; sp++) { // spots default + dataspot[56][sp] = 0; //curvactiv + } + } + + if (ns < (maxspot - 1)) { + ofstream fic (datal, ios::out | ios::app); // ouverture en écriture avec effacement du fichier ouvert + + + for (int sp = ns + 1 ; sp < maxspot; sp++) { // spots default + int t_sp = sp; + int t_mipversion = 10005; + int t_circrad = 18; + int t_locX = 250; + int t_locY = 250; + int t_locYT = 250; + int t_locXL = 250; + int t_centerX = 0; + int t_centerY = 0; + int t_lightness = 0; + int t_contrast = 0; + int t_chroma = 0; + int t_sensi = 19; + int t_transit = 60; + int t_invers = 0; + int t_Smeth = 0; + int t_currentspot = 1; + int t_radius = 0; + int t_strength = 0; + int t_sensibn = 60; + int t_inversrad = 0; + int t_str = 0; + int t_chrrt = 0; + int t_neigh = 50; + int t_vart = 200; + int t_sensih = 19; + int t_inversret = 0; + int t_retinexMethod = 2; + int t_sharradius = 40; + int t_sharamount = 75; + int t_shardamping = 75; + int t_shariter = 30; + int t_sensisha = 19; + int t_inverssha = 0; + int t_qualityMethod = 0; + int t_thres = 50; + int t_proxi = 2; + int t_noiselumf = 0; + int t_noiselumc = 0; + int t_noisechrof = 0; + int t_noisechroc = 0; + int t_mult0 = 100; + int t_mult1 = 100; + int t_mult2 = 100; + int t_mult3 = 100; + int t_mult4 = 100; + int t_threshold = 20; + int t_sensicb = 19; + int t_activlum = 0; + //10001 TM + int t_stren = 0; + int t_gamma = 100; + int t_estop = 140; + int t_scaltm = 3; + int t_rewei = 0; + int t_sensitm = 40; + + //10002 curve + int t_retrab = 500; + + std::string t_curvret = "1000A0B120C350D350E700F500G350H350I1000J120K350L350M";//12 points + //10003 + std::string t_curvll = "3000A0B0C1000D1000E"; //"3000A0B0C499D501E1000F1000G"; //"3000A0B0C1000D1000E";//0 points with marks + //10004 + std::string t_curvlh = "1000A0B500C350D350E166F500G350H350I333J500K350L350M500N500O350P350Q666R500S350T350U833V500W350X350Y"; + //10005 + int t_curvactiv = 0; + + fic << "Mipversion=" << t_mipversion << '@' << endl; + fic << "Spot=" << t_sp << '@' << endl; + fic << "Circrad=" << t_circrad << '@' << endl; + fic << "LocX=" << t_locX << '@' << endl; + fic << "LocY=" << t_locY << '@' << endl; + fic << "LocYT=" << t_locYT << '@' << endl; + fic << "LocXL=" << t_locXL << '@' << endl ; + fic << "CenterX=" << t_centerX << '@' << endl; + fic << "CenterY=" << t_centerY << '@' << endl; + fic << "Lightness=" << t_lightness << '@' << endl; + fic << "Contrast=" << t_contrast << '@' << endl; + fic << "Chroma=" << t_chroma << '@' << endl; + fic << "Sensi=" << t_sensi << '@' << endl; + fic << "Transit=" << t_transit << '@' << endl; + fic << "Invers=" << t_invers << '@' << endl; + fic << "Smethod=" << t_Smeth << '@' << endl; + fic << "Currentspot=" << t_currentspot << '@' << endl; + fic << "Radius=" << t_radius << '@' << endl; + fic << "Strength=" << t_strength << '@' << endl; + fic << "Sensibn=" << t_sensibn << '@' << endl; + fic << "Inversrad=" << t_inversrad << '@' << endl; + fic << "Str=" << t_str << '@' << endl; + fic << "Chroma=" << t_chrrt << '@' << endl; + fic << "Neigh=" << t_neigh << '@' << endl; + fic << "Vart=" << t_vart << '@' << endl; + fic << "Sensih=" << t_sensih << '@' << endl; + fic << "Inversret=" << t_inversret << '@' << endl; + fic << "retinexMethod=" << t_retinexMethod << '@' << endl; + fic << "Sharradius=" << t_sharradius << '@' << endl; + fic << "Sharamount=" << t_sharamount << '@' << endl; + fic << "Shardamping=" << t_shardamping << '@' << endl; + fic << "Shariter=" << t_shariter << '@' << endl; + fic << "Sensisha=" << t_sensisha << '@' << endl; + fic << "Inverssha=" << t_inverssha << '@' << endl; + fic << "qualityMethod=" << t_qualityMethod << '@' << endl; + fic << "Thres=" << t_thres << '@' << endl; + fic << "Proxi=" << t_proxi << '@' << endl; + fic << "Noiselumf=" << t_noiselumf << '@' << endl; + fic << "Noiselumc=" << t_noiselumc << '@' << endl; + fic << "Noisechrof=" << t_noisechrof << '@' << endl; + fic << "Noisechroc=" << t_noisechroc << '@' << endl; + fic << "Mult0=" << t_mult0 << '@' << endl; + fic << "Mult1=" << t_mult1 << '@' << endl; + fic << "Mult2=" << t_mult2 << '@' << endl; + fic << "Mult3=" << t_mult3 << '@' << endl; + fic << "Mult4=" << t_mult4 << '@' << endl; + fic << "Threshold=" << t_threshold << '@' << endl; + fic << "Sensicb=" << t_sensicb << '@' << endl; + fic << "Activblurlum=" << t_activlum << '@' << endl; + + fic << "Stren=" << t_stren << '@' << endl; + fic << "Gamma=" << t_gamma << '@' << endl; + fic << "Estop=" << t_estop << '@' << endl; + fic << "Scaltm=" << t_scaltm << '@' << endl; + fic << "Rewei=" << t_rewei << '@' << endl; + fic << "Sensitm=" << t_sensitm << '@' << endl; + fic << "Retrab=" << t_retrab << '@' << endl; + fic << "Curvactiv=" << t_curvactiv << '@' << endl; + + fic << "curveReti=" << t_curvret << '@' << endl; + fic << "curveLL=" << t_curvll << '@' << endl; + fic << "curveLH=" << t_curvlh << '@' << endl; + + fic << endl; + } + + fic.close(); + + + ifstream fich2 (datal, ios::in); + + if (fich2) { + + std::string line2; + std::string spotline2; + int cont2 = 0; + int ns2; + int maxin = 57; + int sizecu2; + int sizell2; + int sizelh2; + + while (getline (fich2, line2)) { + spotline2 = line2; + std::size_t pos2 = spotline2.find ("="); + std::size_t posend2 = spotline2.find ("@"); //in case of for futur use + + if (spotline2.substr (0, pos2) == "Mipversion") { + std::string strversion = spotline2.substr (pos2 + 1, (posend2 - pos2)); + versionmip = std::stoi (strversion.c_str()); + } + + if (spotline2.substr (0, pos2) == "Spot") { + cont2 = 0; + } + + cont2++; + std::string str32 = spotline2.substr (pos2 + 1, (posend2 - pos2)); + + if (cont2 == 1) { + ns2 = std::stoi (str32.c_str()); + } + + if (cont2 >= 2 && cont2 < 16) { + dataspot[cont2][ns2] = std::stoi (str32.c_str()); + + } + + if (spotline2.substr (0, pos2) == "Currentspot") { + dataspot[16][0] = std::stoi (str32.c_str()); + } + + if (cont2 > 16 && cont2 < maxin) { + dataspot[cont2][ns2] = std::stoi (str32.c_str()); + + } + + if (spotline2.substr (0, pos2) == "curveReti") { + std::string curstr2; + int longecur2; + std::string strend2 = spotline2.substr (posend2 - 1, 1); + std::size_t posz2 = spotline2.find (strend2); + int longe2; + + for (int sl = 0; sl < 69; sl++) { + if (delim[sl] == strend2) { + longe2 = sl + 1; + } + } + + retistr[ns] = str32; + sizecu2 = longe2; + + } + + if (spotline2.substr (0, pos2) == "curveLL") { + std::string curstr2l; + int longecur2l; + std::string strend2l = spotline2.substr (posend2 - 1, 1); + std::size_t posz2l = spotline2.find (strend2l); + int longe2l; + + for (int sl = 0; sl < 69; sl++) { + if (delim[sl] == strend2l) { + longe2l = sl + 1; + } + } + + llstr[ns] = str32; + sizell2 = longe2l; + + } + + if (spotline2.substr (0, pos2) == "curveLH") { + std::string curstr2h; + int longecur2h; + std::string strend2h = spotline2.substr (posend2 - 1, 1); + std::size_t posz2h = spotline2.find (strend2h); + int longe2h; + + for (int sh = 0; sh < 69; sh++) { + if (delim[sh] == strend2h) { + longe2h = sh + 1; + } + } + + lhstr[ns] = str32; + sizelh2 = longe2h; + + } + + } + + fich2.close() ; + + } + + + } + + + + for (int sp = 1; sp < maxspot; sp++) { //spots default + params.locallab.hueref = INFINITY; + params.locallab.chromaref = INFINITY; + bool locutili = locutili; + params.locallab.lumaref = INFINITY; + params.locallab.circrad = circrads[sp] = dataspot[2][sp]; + params.locallab.locX = locx[sp] = dataspot[3][sp]; + params.locallab.locY = locy[sp] = dataspot[4][sp]; + params.locallab.locYT = locyt[sp] = dataspot[5][sp]; + params.locallab.locXL = locxl[sp] = dataspot[6][sp]; + params.locallab.centerX = centerx[sp] = dataspot[7][sp]; + params.locallab.centerY = centery[sp] = dataspot[8][sp]; + params.locallab.lightness = lights[sp] = dataspot[9][sp]; + params.locallab.contrast = contrs[sp] = dataspot[10][sp]; + params.locallab.chroma = chroms[sp] = dataspot[11][sp]; + params.locallab.sensi = sensis[sp] = dataspot[12][sp]; + params.locallab.transit = transits[sp] = dataspot[13][sp]; + sps[sp] = sp; + + if (dataspot[14][sp] == 0) { + inverss[sp] = 0; + params.locallab.invers = false; + } else { + inverss[sp] = 1; + params.locallab.invers = true; + } + + if (dataspot[15][sp] == 0) { + smeths[sp] = 0; + params.locallab.Smethod = "IND" ; + } else if (dataspot[15][sp] == 1) { + smeths[sp] = 1; + params.locallab.Smethod = "SYM" ; + } else if (dataspot[15][sp] == 2) { + smeths[sp] = 2; + params.locallab.Smethod = "INDSL"; + } else if (dataspot[15][sp] == 3) { + smeths[sp] = 3; + params.locallab.Smethod = "SYMSL"; + } + + radiuss[sp] = dataspot[17][sp]; + strengths[sp] = dataspot[18][sp]; + params.locallab.radius = dataspot[17][sp]; + params.locallab.strength = dataspot[18][sp]; + params.locallab.sensibn = dataspot[19][sp]; + + if (dataspot[20][sp] == 0) { + inversrads[sp] = 0; + params.locallab.inversrad = false; + } else { + inversrads[sp] = 1; + params.locallab.inversrad = true; + } + + + params.locallab.str = strs[sp] = dataspot[21][sp]; + params.locallab.chrrt = chrrts[sp] = dataspot[22][sp]; + params.locallab.neigh = neighs[sp] = dataspot[23][sp]; + params.locallab.vart = varts[sp] = dataspot[24][sp]; + params.locallab.sensih = sensihs[sp] = dataspot[25][sp]; + + if (dataspot[26][sp] == 0) { + inversrets[sp] = 0; + params.locallab.inversret = false; + } else { + inversrets[sp] = 1; + params.locallab.inversret = true; + } + + if (dataspot[27][sp] == 0) { + retinexs[sp] = 0; + params.locallab.retinexMethod = "low" ; + } else if (dataspot[27][sp] == 1) { + retinexs[sp] = 1; + params.locallab.retinexMethod = "uni" ; + } else if (dataspot[27][sp] == 2) { + retinexs[sp] = 2; + params.locallab.retinexMethod = "high"; + } + + sharradiuss[sp] = dataspot[28][sp]; + params.locallab.sharradius = dataspot[28][sp]; + + params.locallab.sharamount = sharamounts[sp] = dataspot[29][sp]; + params.locallab.shardamping = shardampings[sp] = dataspot[30][sp]; + params.locallab.shariter = shariters[sp] = dataspot[31][sp]; + params.locallab.sensisha = sensishas[sp] = dataspot[32][sp]; + + if (dataspot[33][sp] == 0) { + inversshas[sp] = 0; + params.locallab.inverssha = false; + } else { + inversshas[sp] = 1; + params.locallab.inverssha = true; + } + + if (dataspot[34][sp] == 0) { + qualitys[sp] = 0; + params.locallab.qualityMethod = "std" ; + } else if (dataspot[34][sp] == 1) { + qualitys[sp] = 1; + params.locallab.qualityMethod = "enh" ; + } else if (dataspot[34][sp] == 2) { + qualitys[sp] = 2; + params.locallab.qualityMethod = "enhden" ; + } + + params.locallab.thres = thress[sp] = dataspot[35][sp]; + params.locallab.proxi = proxis[sp] = dataspot[36][sp]; + params.locallab.noiselumf = noiselumfs[sp] = dataspot[37][sp]; + params.locallab.noiselumc = noiselumcs[sp] = dataspot[38][sp]; + params.locallab.noisechrof = noisechrofs[sp] = dataspot[39][sp]; + params.locallab.noisechroc = noisechrocs[sp] = dataspot[40][sp]; + params.locallab.mult[0] = mult0s[sp] = dataspot[41][sp]; + params.locallab.mult[1] = mult1s[sp] = dataspot[42][sp]; + params.locallab.mult[2] = mult2s[sp] = dataspot[43][sp]; + params.locallab.mult[3] = mult3s[sp] = dataspot[44][sp]; + params.locallab.mult[4] = mult4s[sp] = dataspot[45][sp]; + params.locallab.threshold = thresholds[sp] = dataspot[46][sp]; + params.locallab.sensicb = sensicbs[sp] = dataspot[47][sp]; + + if (dataspot[48][sp] == 0) { + activlums[sp] = 0; + params.locallab.activlum = false; + } else { + activlums[sp] = 1; + params.locallab.activlum = true; + } + + params.locallab.stren = strens[sp] = dataspot[49][sp]; + params.locallab.gamma = gammas[sp] = dataspot[50][sp]; + params.locallab.estop = estops[sp] = dataspot[51][sp]; + params.locallab.scaltm = scaltms[sp] = dataspot[52][sp]; + params.locallab.rewei = reweis[sp] = dataspot[53][sp]; + params.locallab.sensitm = sensitms[sp] = dataspot[54][sp]; + params.locallab.retrab = retrabs[sp] = dataspot[55][sp]; + + if (dataspot[56][sp] == 0) { + curvactivs[sp] = 0; + params.locallab.curvactiv = false; + } else { + curvactivs[sp] = 1; + params.locallab.curvactiv = true; + } + + int *s_datc; + s_datc = new int[70]; + int siz; + + ipf.strcurv_data (retistr[sp], s_datc, siz); + + sizeretics[sp] = siz; + + std::vector cretiend; + + for (int j = 0; j < siz; j++) { + reticurvs[sp * 500 + j] = s_datc[j]; + cretiend.push_back ((double) (s_datc[j]) / 1000.); + } + + delete [] s_datc; + + int *s_datcl; + s_datcl = new int[70]; + int sizl; + + ipf.strcurv_data (llstr[sp], s_datcl, sizl); + + sizellcs[sp] = sizl; + + std::vector cllend; + + for (int j = 0; j < sizl; j++) { + llcurvs[sp * 500 + j] = s_datcl[j]; + cllend.push_back ((double) (s_datcl[j]) / 1000.); + } + + delete [] s_datcl; + + int *s_datch; + s_datch = new int[70]; + int sizh; + + ipf.strcurv_data (lhstr[sp], s_datch, sizh); + + sizelhcs[sp] = sizh; + + std::vector clhend; + + for (int j = 0; j < sizh; j++) { + lhcurvs[sp * 500 + j] = s_datch[j]; + clhend.push_back ((double) (s_datch[j]) / 1000.); + } + + delete [] s_datch; + + params.locallab.localTgaincurve.clear(); + params.locallab.localTgaincurve = cretiend; + + int lenc = params.locallab.localTgaincurve.size(); + + params.locallab.llcurve.clear(); + params.locallab.llcurve = cllend; + + params.locallab.LHcurve.clear(); + params.locallab.LHcurve = clhend; + + + locallutili = false; + params.locallab.getCurves (locRETgainCurve, locRETgainCurverab, loclhCurve); + CurveFactory::curveLocal (locallutili, params.locallab.llcurve, lllocalcurve, sca); //scale == 1 ? 1 : 16); + + ipf.Lab_Local (3, sp, (float**)shbuffer, nprevl, nprevl, 0, 0, 0, 0, pW, pH, fw, fh, locutili, scale, locRETgainCurve, locallutili, lllocalcurve, loclhCurve, params.locallab.hueref, params.locallab.chromaref, params.locallab.lumaref); + dataspot[57][sp] = huerefs[sp] = 100.f * params.locallab.hueref; + dataspot[58][sp] = chromarefs[sp] = params.locallab.chromaref; + dataspot[59][sp] = lumarefs[sp] = params.locallab.lumaref; + nextParams.locallab.hueref = params.locallab.hueref; + nextParams.locallab.chromaref = params.locallab.chromaref; + nextParams.locallab.lumaref = params.locallab.lumaref; + lllocalcurve.clear(); + + } + + + + int sp ; + sp = realspot; + + + int maxreal = 1;//do nothing..in case of + + if (aloListener && realspot != dataspot[16][0]) { + //update GUI and MIP + aloListener->localChanged (dataspot, retistr[sp], llstr[sp], lhstr[sp], sp, maxreal); + } + + + int sis = 1; + params.locallab.hueref = INFINITY; + params.locallab.chromaref = INFINITY; + params.locallab.lumaref = INFINITY; + locallutili = false; + + sps[sp] = sp; + dataspot[2][sp] = circrads[sp] = params.locallab.circrad = dataspot[2][0]; + dataspot[3][sp] = locx[sp] = params.locallab.locX = dataspot[3][0]; + dataspot[4][sp] = locy[sp] = params.locallab.locY = dataspot[4][0]; + dataspot[5][sp] = locyt[sp] = params.locallab.locYT = dataspot[5][0]; + dataspot[6][sp] = locxl[sp] = params.locallab.locXL = dataspot[6][0]; + dataspot[7][sp] = centerx[sp] = params.locallab.centerX = dataspot[7][0]; + dataspot[8][sp] = centery[sp] = params.locallab.centerY = dataspot[8][0]; + dataspot[9][sp] = lights[sp] = params.locallab.lightness = dataspot[9][0]; + dataspot[10][sp] = contrs[sp] = params.locallab.contrast = dataspot[10][0]; + dataspot[11][sp] = chroms[sp] = params.locallab.chroma = dataspot[11][0]; + dataspot[12][sp] = sensis[sp] = params.locallab.sensi = dataspot[12][0]; + dataspot[13][sp] = transits[sp] = params.locallab.transit = dataspot[13][0]; + + if (dataspot[14][0] == 0) { + params.locallab.invers = false; + dataspot[14][sp] = 0; + inverss[sp] = 0; + } else { + params.locallab.invers = true; + dataspot[14][sp] = 1; + inverss[sp] = 1; + } + + if (dataspot[15][0] == 0) { + params.locallab.Smethod = "IND" ; + smeths[sp] = 0; + dataspot[15][sp] = 0; + } else if (dataspot[15][0] == 1) { + params.locallab.Smethod = "SYM" ; + smeths[sp] = 1; + dataspot[15][sp] = 1; + + } else if (dataspot[15][0] == 2) { + params.locallab.Smethod = "INDSL" ; + smeths[sp] = 2; + dataspot[15][sp] = 2; + } else if (dataspot[15][0] == 3) { + params.locallab.Smethod = "SYMSL" ; + smeths[sp] = 3; + dataspot[15][sp] = 3; + } + + params.locallab.radius = dataspot[17][0]; + params.locallab.strength = dataspot[18][0]; + params.locallab.sensibn = dataspot[19][0]; + + dataspot[17][sp] = radiuss[sp] = params.locallab.radius; + dataspot[18][sp] = strengths[sp] = params.locallab.strength; + dataspot[19][sp] = sensibns[sp] = params.locallab.sensibn; + + if (dataspot[20][0] == 0) { + params.locallab.inversrad = false; + dataspot[20][sp] = 0; + inversrads[sp] = 0; + } else { + params.locallab.inversrad = true; + dataspot[20][sp] = 1; + inversrads[sp] = 1; + } + + dataspot[21][sp] = strs[sp] = params.locallab.str = dataspot[21][0]; + dataspot[22][sp] = chrrts[sp] = params.locallab.chrrt = dataspot[22][0]; + dataspot[23][sp] = neighs[sp] = params.locallab.neigh = dataspot[23][0]; + dataspot[24][sp] = varts[sp] = params.locallab.vart = dataspot[24][0]; + dataspot[25][sp] = sensihs[sp] = params.locallab.sensih = dataspot[25][0]; + + if (dataspot[26][0] == 0) { + params.locallab.inversret = false; + inversrets[sp] = 0; + dataspot[26][sp] = 0; + } else { + params.locallab.inversret = true; + inversrets[sp] = 1; + dataspot[26][sp] = 1; + } + + if (dataspot[27][0] == 0) { + params.locallab.retinexMethod = "low" ; + retinexs[sp] = 0; + dataspot[27][sp] = 0; + } else if (dataspot[27][0] == 1) { + params.locallab.retinexMethod = "uni" ; + retinexs[sp] = 1; + dataspot[27][sp] = 1; + } else if (dataspot[27][0] == 2) { + params.locallab.Smethod = "high" ; + retinexs[sp] = 2; + dataspot[27][sp] = 2; + } + + dataspot[28][sp] = sharradiuss[sp] = params.locallab.sharradius = dataspot[28][0]; + + dataspot[29][sp] = sharamounts[sp] = params.locallab.sharamount = dataspot[29][0]; + dataspot[30][sp] = shardampings[sp] = params.locallab.shardamping = dataspot[30][0]; + dataspot[31][sp] = shariters[sp] = params.locallab.shariter = dataspot[31][0]; + dataspot[32][sp] = sensishas[sp] = params.locallab.sensisha = dataspot[32][0]; + + if (dataspot[33][0] == 0) { + params.locallab.inverssha = 0; + inversshas[sp] = 0; + dataspot[33][sp] = 0; + } else { + params.locallab.inverssha = 1; + inversshas[sp] = 1; + dataspot[33][sp] = 1; + } + + if (dataspot[34][0] == 0) { + params.locallab.qualityMethod = "std" ; + qualitys[sp] = 0; + dataspot[34][sp] = 0; + } else if (dataspot[34][0] == 1) { + params.locallab.qualityMethod = "enh" ; + qualitys[sp] = 1; + dataspot[34][sp] = 1; + } else if (dataspot[34][0] == 2) { + params.locallab.qualityMethod = "enhden" ; + qualitys[sp] = 2; + dataspot[34][sp] = 2; + } + + dataspot[35][sp] = thress[sp] = params.locallab.thres = dataspot[35][0]; + dataspot[36][sp] = proxis[sp] = params.locallab.proxi = dataspot[36][0]; + dataspot[37][sp] = noiselumfs[sp] = params.locallab.noiselumf = dataspot[37][0]; + dataspot[38][sp] = noiselumcs[sp] = params.locallab.noiselumc = dataspot[38][0]; + dataspot[39][sp] = noisechrofs[sp] = params.locallab.noisechrof = dataspot[39][0]; + dataspot[40][sp] = noisechrocs[sp] = params.locallab.noisechroc = dataspot[40][0]; + dataspot[41][sp] = mult0s[sp] = params.locallab.mult[0] = dataspot[41][0]; + dataspot[42][sp] = mult1s[sp] = params.locallab.mult[1] = dataspot[42][0]; + dataspot[43][sp] = mult2s[sp] = params.locallab.mult[2] = dataspot[43][0]; + dataspot[44][sp] = mult3s[sp] = params.locallab.mult[3] = dataspot[44][0]; + dataspot[45][sp] = mult4s[sp] = params.locallab.mult[4] = dataspot[45][0]; + dataspot[46][sp] = thresholds[sp] = params.locallab.threshold = dataspot[46][0]; + dataspot[47][sp] = sensicbs[sp] = params.locallab.sensicb = dataspot[47][0]; + + if (dataspot[48][0] == 0) { + params.locallab.activlum = 0; + activlums[sp] = 0; + dataspot[48][sp] = 0; + } else { + params.locallab.activlum = 1; + activlums[sp] = 1; + dataspot[48][sp] = 1; + } + + dataspot[49][sp] = strens[sp] = params.locallab.stren = dataspot[49][0]; + dataspot[50][sp] = gammas[sp] = params.locallab.gamma = dataspot[50][0]; + dataspot[51][sp] = estops[sp] = params.locallab.estop = dataspot[51][0]; + dataspot[52][sp] = scaltms[sp] = params.locallab.scaltm = dataspot[52][0]; + dataspot[53][sp] = reweis[sp] = params.locallab.rewei = dataspot[53][0]; + dataspot[54][sp] = sensitms[sp] = params.locallab.sensitm = dataspot[54][0]; + dataspot[55][sp] = retrabs[sp] = params.locallab.retrab = dataspot[55][0]; + + if (dataspot[56][0] == 0) { + params.locallab.curvactiv = false; + dataspot[56][sp] = 0; + curvactivs[sp] = 0; + } else { + params.locallab.curvactiv = true; + dataspot[56][sp] = 1; + curvactivs[sp] = 1; + } + + int *s_datc; + s_datc = new int[70]; + int siz; + + ipf.strcurv_data (retistr[0], s_datc, siz); + sizeretics[sp] = siz; + std::vector cretiend; + + retistr[sp] = retistr[0]; + + for (int j = 0; j < siz; j++) { + reticurvs[sp * 500 + j] = s_datc[j]; + cretiend.push_back ((double) (s_datc[j]) / 1000.); + + } + + params.locallab.localTgaincurve.clear(); + params.locallab.localTgaincurve = cretiend; + + int lenc = params.locallab.localTgaincurve.size(); + + + delete [] s_datc; + + int *s_datcl; + s_datcl = new int[70]; + int sizl; + + ipf.strcurv_data (llstr[0], s_datcl, sizl); + sizellcs[sp] = sizl; + std::vector cllend; + + llstr[sp] = llstr[0]; + + for (int j = 0; j < sizl; j++) { + llcurvs[sp * 500 + j] = s_datcl[j]; + cllend.push_back ((double) (s_datcl[j]) / 1000.); + + } + + params.locallab.llcurve.clear(); + params.locallab.llcurve = cllend; + + delete [] s_datcl; + + int *s_datch; + s_datch = new int[70]; + int sizh; + + ipf.strcurv_data (lhstr[0], s_datch, sizh); + sizelhcs[sp] = sizh; + std::vector clhend; + + lhstr[sp] = lhstr[0]; + + for (int j = 0; j < sizh; j++) { + lhcurvs[sp * 500 + j] = s_datch[j]; + clhend.push_back ((double) (s_datch[j]) / 1000.); + + } + + params.locallab.LHcurve.clear(); + params.locallab.LHcurve = clhend; + + delete [] s_datch; + + params.locallab.getCurves (locRETgainCurve, locRETgainCurverab, loclhCurve); + locallutili = false; + CurveFactory::curveLocal (locallutili, params.locallab.llcurve, lllocalcurve, sca); //scale == 1 ? 1 : 16); + + ipf.Lab_Local (3, sp, (float**)shbuffer, nprevl, nprevl, 0, 0, 0, 0, pW, pH, fw, fh, locutili, scale, locRETgainCurve, locallutili, lllocalcurve, loclhCurve, params.locallab.hueref, params.locallab.chromaref, params.locallab.lumaref); + dataspot[57][sp] = huerefs[sp] = 100.f * params.locallab.hueref; + dataspot[58][sp] = chromarefs[sp] = params.locallab.chromaref; + dataspot[59][sp] = lumarefs[sp] = params.locallab.lumaref; + lllocalcurve.clear(); + nextParams.locallab.hueref = params.locallab.hueref; + nextParams.locallab.chromaref = params.locallab.chromaref; + nextParams.locallab.lumaref = params.locallab.lumaref; + + + ofstream fou (datal, ios::out | ios::trunc); + + if (fou) + + { + + for (int spe = 1; spe < maxspot; spe++) { + int t_sp = spe; + int t_mipversion = 10005; + int t_circrad = dataspot[2][spe]; + int t_locX = dataspot[3][spe]; + int t_locY = dataspot[4][spe]; + int t_locYT = dataspot[5][spe]; + int t_locXL = dataspot[6][spe]; + int t_centerX = dataspot[7][spe]; + int t_centerY = dataspot[8][spe]; + int t_lightness = dataspot[9][spe]; + int t_contrast = dataspot[10][spe]; + int t_chroma = dataspot[11][spe]; + int t_sensi = dataspot[12][spe]; + int t_transit = dataspot[13][spe]; + int t_invers = dataspot[14][spe]; + int t_Smeth = dataspot[15][spe]; + int t_currentspot = realspot; + int t_radius = dataspot[17][spe]; + int t_strength = dataspot[18][spe]; + int t_sensibn = dataspot[19][spe]; + int t_inversrad = dataspot[20][spe]; + int t_str = dataspot[21][spe]; + int t_chrrt = dataspot[22][spe]; + int t_neigh = dataspot[23][spe]; + int t_vart = dataspot[24][spe]; + int t_sensih = dataspot[25][spe]; + int t_inversret = dataspot[26][spe]; + int t_retinexMethod = dataspot[27][spe]; + int t_sharradius = dataspot[28][spe]; + int t_sharamount = dataspot[29][spe]; + int t_shardamping = dataspot[30][spe]; + int t_shariter = dataspot[31][spe]; + int t_sensisha = dataspot[32][spe]; + int t_inverssha = dataspot[33][spe]; + int t_qualityMethod = dataspot[34][spe]; + int t_thres = dataspot[35][spe]; + int t_proxi = dataspot[36][spe]; + int t_noiselumf = dataspot[37][spe]; + int t_noiselumc = dataspot[38][spe]; + int t_noisechrof = dataspot[39][spe]; + int t_noisechroc = dataspot[40][spe]; + int t_mult0 = dataspot[41][spe]; + int t_mult1 = dataspot[42][spe]; + int t_mult2 = dataspot[43][spe]; + int t_mult3 = dataspot[44][spe]; + int t_mult4 = dataspot[45][spe]; + int t_threshold = dataspot[46][spe]; + int t_sensicb = dataspot[47][spe]; + int t_activlum = dataspot[48][spe]; + + int t_stren = dataspot[49][spe]; + int t_gamma = dataspot[50][spe]; + int t_estop = dataspot[51][spe]; + int t_scaltm = dataspot[52][spe]; + int t_rewei = dataspot[53][spe]; + int t_sensitm = dataspot[54][spe]; + int t_retrab = dataspot[55][spe]; + int t_curvactiv = dataspot[56][spe]; + + int t_hueref = dataspot[57][spe]; + int t_chromaref = dataspot[58][spe]; + int t_lumaref = dataspot[59][spe]; + + std::string t_curvret = retistr[spe]; + std::string t_curvll = llstr[spe]; + std::string t_curvlh = lhstr[spe]; + + fou << "Mipversion=" << t_mipversion << '@' << endl; + fou << "Spot=" << t_sp << '@' << endl; + fou << "Circrad=" << t_circrad << '@' << endl; + fou << "LocX=" << t_locX << '@' << endl; + fou << "LocY=" << t_locY << '@' << endl; + fou << "LocYT=" << t_locYT << '@' << endl; + fou << "LocXL=" << t_locXL << '@' << endl ; + fou << "CenterX=" << t_centerX << '@' << endl; + fou << "CenterY=" << t_centerY << '@' << endl; + fou << "Lightness=" << t_lightness << '@' << endl; + fou << "Contrast=" << t_contrast << '@' << endl; + fou << "Chroma=" << t_chroma << '@' << endl; + fou << "Sensi=" << t_sensi << '@' << endl; + fou << "Transit=" << t_transit << '@' << endl; + fou << "Invers=" << t_invers << '@' << endl; + fou << "Smethod=" << t_Smeth << '@' << endl; + fou << "Currentspot=" << t_currentspot << '@' << endl; + fou << "Radius=" << t_radius << '@' << endl; + fou << "Strength=" << t_strength << '@' << endl; + fou << "Sesibn=" << t_sensibn << '@' << endl; + fou << "Inversrad=" << t_inversrad << '@' << endl; + fou << "Str=" << t_str << '@' << endl; + fou << "Chroma=" << t_chrrt << '@' << endl; + fou << "Neigh=" << t_neigh << '@' << endl; + fou << "Vart=" << t_vart << '@' << endl; + fou << "Sensih=" << t_sensih << '@' << endl; + fou << "Inversret=" << t_inversret << '@' << endl; + fou << "retinexMethod=" << t_retinexMethod << '@' << endl; + fou << "Sharradius=" << t_sharradius << '@' << endl; + fou << "Sharamount=" << t_sharamount << '@' << endl; + fou << "Shardamping=" << t_shardamping << '@' << endl; + fou << "Shariter=" << t_shariter << '@' << endl; + fou << "Sensisha=" << t_sensisha << '@' << endl; + fou << "Inverssha=" << t_inverssha << '@' << endl; + fou << "qualityMethod=" << t_qualityMethod << '@' << endl; + fou << "Thres=" << t_thres << '@' << endl; + fou << "Proxi=" << t_proxi << '@' << endl; + fou << "Noiselumf=" << t_noiselumf << '@' << endl; + fou << "Noiselumc=" << t_noiselumc << '@' << endl; + fou << "Noisechrof=" << t_noisechrof << '@' << endl; + fou << "Noisechroc=" << t_noisechroc << '@' << endl; + fou << "Mult0=" << t_mult0 << '@' << endl; + fou << "Mult1=" << t_mult1 << '@' << endl; + fou << "Mult2=" << t_mult2 << '@' << endl; + fou << "Mult3=" << t_mult3 << '@' << endl; + fou << "Mult4=" << t_mult4 << '@' << endl; + fou << "Threshold=" << t_threshold << '@' << endl; + fou << "Sensicb=" << t_sensicb << '@' << endl; + fou << "Activblurlum=" << t_activlum << '@' << endl; + + fou << "Stren=" << t_stren << '@' << endl; + fou << "Gamma=" << t_gamma << '@' << endl; + fou << "Estop=" << t_estop << '@' << endl; + fou << "Scaltm=" << t_scaltm << '@' << endl; + fou << "Rewei=" << t_rewei << '@' << endl; + fou << "Sensitm=" << t_sensitm << '@' << endl; + + fou << "Retrab=" << t_retrab << '@' << endl; + fou << "Curvactiv=" << t_curvactiv << '@' << endl; + + fou << "hueref=" << t_hueref << '@' << endl; + fou << "chromaref=" << t_chromaref << '@' << endl; + fou << "lumaref=" << t_lumaref << '@' << endl; + fou << "curveReti=" << t_curvret << endl; + fou << "curveLL=" << t_curvll << endl; + fou << "curveLH=" << t_curvlh << endl; + + fou << endl; + } + + fou.close(); + } + + + + for (int i = 0; i < 60; i++) { + delete [] dataspot[i]; + } + + delete [] dataspot; + + delete [] retistr; + delete [] llstr; + delete [] lhstr; + + + // } + } + + histCCurve.clear(); histLCurve.clear(); ipf.chromiLuminanceCurve (nullptr, pW, nprevl, nprevl, chroma_acurve, chroma_bcurve, satcurve, lhskcurve, clcurve, lumacurve, utili, autili, butili, ccutili, cclutili, clcutili, histCCurve, histLCurve); - ipf.vibrance(nprevl); + ipf.vibrance (nprevl); - if((params.colorappearance.enabled && !params.colorappearance.tonecie) || (!params.colorappearance.enabled)) { - ipf.EPDToneMap(nprevl, 5, 1); + if ((params.colorappearance.enabled && !params.colorappearance.tonecie) || (!params.colorappearance.enabled)) { + ipf.EPDToneMap (nprevl, 5, 1); } // for all treatments Defringe, Sharpening, Contrast detail , Microcontrast they are activated if "CIECAM" function are disabled @@ -660,8 +2309,8 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) } } */ - if(params.dirpyrequalizer.cbdlMethod == "aft") { - if(((params.colorappearance.enabled && !settings->autocielab) || (!params.colorappearance.enabled)) ) { + if (params.dirpyrequalizer.cbdlMethod == "aft") { + if (((params.colorappearance.enabled && !settings->autocielab) || (!params.colorappearance.enabled)) ) { progress ("Pyramid wavelet...", 100 * readyphase / numofphases); ipf.dirpyrequalizer (nprevl, scale); //ipf.Lanczoslab (ip_wavelet(LabImage * lab, LabImage * dst, const procparams::EqualizerParams & eqparams), nprevl, 1.f/scale); @@ -672,35 +2321,35 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) wavcontlutili = false; //CurveFactory::curveWavContL ( wavcontlutili,params.wavelet.lcurve, wavclCurve, LUTu & histogramwavcl, LUTu & outBeforeWavCLurveHistogram,int skip); - CurveFactory::curveWavContL(wavcontlutili, params.wavelet.wavclCurve, wavclCurve, scale == 1 ? 1 : 16); + CurveFactory::curveWavContL (wavcontlutili, params.wavelet.wavclCurve, wavclCurve, scale == 1 ? 1 : 16); - if((params.wavelet.enabled)) { + if ((params.wavelet.enabled)) { WaveletParams WaveParams = params.wavelet; // WaveParams.getCurves(wavCLVCurve, waOpacityCurveRG, waOpacityCurveBY); - WaveParams.getCurves(wavCLVCurve, waOpacityCurveRG, waOpacityCurveBY, waOpacityCurveW, waOpacityCurveWL); + WaveParams.getCurves (wavCLVCurve, waOpacityCurveRG, waOpacityCurveBY, waOpacityCurveW, waOpacityCurveWL); int kall = 0; progress ("Wavelet...", 100 * readyphase / numofphases); // ipf.ip_wavelet(nprevl, nprevl, kall, WaveParams, wavCLVCurve, waOpacityCurveRG, waOpacityCurveBY, scale); - ipf.ip_wavelet(nprevl, nprevl, kall, WaveParams, wavCLVCurve, waOpacityCurveRG, waOpacityCurveBY, waOpacityCurveW, waOpacityCurveWL, wavclCurve, wavcontlutili, scale); + ipf.ip_wavelet (nprevl, nprevl, kall, WaveParams, wavCLVCurve, waOpacityCurveRG, waOpacityCurveBY, waOpacityCurveW, waOpacityCurveWL, wavclCurve, wavcontlutili, scale); } - if(params.colorappearance.enabled) { + if (params.colorappearance.enabled) { //L histo and Chroma histo for ciecam // histogram well be for Lab (Lch) values, because very difficult to do with J,Q, M, s, C int x1, y1, x2, y2; - params.crop.mapToResized(pW, pH, scale, x1, x2, y1, y2); + params.crop.mapToResized (pW, pH, scale, x1, x2, y1, y2); lhist16CAM.clear(); lhist16CCAM.clear(); - if(!params.colorappearance.datacie) { + if (!params.colorappearance.datacie) { for (int x = 0; x < pH; x++) for (int y = 0; y < pW; y++) { - int pos = CLIP((int)(nprevl->L[x][y])); - int posc = CLIP((int)sqrt(nprevl->a[x][y] * nprevl->a[x][y] + nprevl->b[x][y] * nprevl->b[x][y])); + int pos = CLIP ((int) (nprevl->L[x][y])); + int posc = CLIP ((int)sqrt (nprevl->a[x][y] * nprevl->a[x][y] + nprevl->b[x][y] * nprevl->b[x][y])); lhist16CAM[pos]++; lhist16CCAM[posc]++; } @@ -715,13 +2364,13 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) double fcomp = imgsrc->getMetaData()->getExpComp (); // Compensation +/- double adap; - if(fnum < 0.3f || fiso < 5.f || fspeed < 0.00001f) { //if no exif data or wrong + if (fnum < 0.3f || fiso < 5.f || fspeed < 0.00001f) { //if no exif data or wrong adap = 2000.; } else { - double E_V = fcomp + log2 (double((fnum * fnum) / fspeed / (fiso / 100.f))); + double E_V = fcomp + log2 (double ((fnum * fnum) / fspeed / (fiso / 100.f))); E_V += params.toneCurve.expcomp;// exposure compensation in tonecurve ==> direct EV - E_V += log2(params.raw.expos);// exposure raw white point ; log2 ==> linear to EV - adap = powf(2.f, E_V - 3.f); // cd / m2 + E_V += log2 (params.raw.expos); // exposure raw white point ; log2 ==> linear to EV + adap = powf (2.f, E_V - 3.f); // cd / m2 // end calculation adaptation scene luminosity } @@ -730,16 +2379,16 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) float d; bool execsharp = false; - if(!ncie) { + if (!ncie) { ncie = new CieImage (pW, pH); } if (!CAMBrightCurveJ && (params.colorappearance.algo == "JC" || params.colorappearance.algo == "JS" || params.colorappearance.algo == "ALL")) { - CAMBrightCurveJ(32768, 0); + CAMBrightCurveJ (32768, 0); } if (!CAMBrightCurveQ && (params.colorappearance.algo == "QM" || params.colorappearance.algo == "ALL")) { - CAMBrightCurveQ(32768, 0); + CAMBrightCurveQ (32768, 0); } // Issue 2785, only float version of ciecam02 for navigator and pan background @@ -747,14 +2396,14 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) CAMBrightCurveJ.dirty = true; CAMBrightCurveQ.dirty = true; - ipf.ciecam_02float (ncie, float(adap), begh, endh, pW, 2, nprevl, ¶ms, customColCurve1, customColCurve2, customColCurve3, histLCAM, histCCAM, CAMBrightCurveJ, CAMBrightCurveQ, CAMMean, 5, 1, execsharp, d, scale, 1); + ipf.ciecam_02float (ncie, float (adap), begh, endh, pW, 2, nprevl, ¶ms, customColCurve1, customColCurve2, customColCurve3, histLCAM, histCCAM, CAMBrightCurveJ, CAMBrightCurveQ, CAMMean, 5, 1, execsharp, d, scale, 1); - if(params.colorappearance.autodegree && acListener && params.colorappearance.enabled) { - acListener->autoCamChanged(100.*(double)d); + if (params.colorappearance.autodegree && acListener && params.colorappearance.enabled) { + acListener->autoCamChanged (100.* (double)d); } - if(params.colorappearance.autoadapscen && acListener && params.colorappearance.enabled) { - acListener->adapCamChanged(adap); //real value of adapt scene luminosity + if (params.colorappearance.autoadapscen && acListener && params.colorappearance.enabled) { + acListener->adapCamChanged (adap); //real value of adapt scene luminosity } readyphase++; @@ -776,15 +2425,15 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) } } - // Update the monitor color transform if necessary - if ((todo & M_MONITOR) || (lastOutputProfile!=params.icm.output) || lastOutputIntent!=params.icm.outputIntent || lastOutputBPC!=params.icm.outputBPC) { +// Update the monitor color transform if necessary + if ((todo & M_MONITOR) || (lastOutputProfile != params.icm.output) || lastOutputIntent != params.icm.outputIntent || lastOutputBPC != params.icm.outputBPC) { lastOutputProfile = params.icm.output; lastOutputIntent = params.icm.outputIntent; lastOutputBPC = params.icm.outputBPC; - ipf.updateColorProfiles(monitorProfile, monitorIntent, softProof, gamutCheck); + ipf.updateColorProfiles (monitorProfile, monitorIntent, softProof, gamutCheck); } - // process crop, if needed +// process crop, if needed for (size_t i = 0; i < crops.size(); i++) if (crops[i]->hasListener () && cropCall != crops[i] ) { crops[i]->update (todo); // may call ourselves @@ -793,7 +2442,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) progress ("Conversion to RGB...", 100 * readyphase / numofphases); if ((todo != CROP && todo != MINUPDATE) || (todo & M_MONITOR)) { - MyMutex::MyLock prevImgLock(previmg->getMutex()); + MyMutex::MyLock prevImgLock (previmg->getMutex()); try { // Computing the preview image, i.e. converting from WCS->Monitor color space (soft-proofing disabled) or WCS->Output profile->Monitor color space (soft-proofing enabled) @@ -802,7 +2451,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) // Computing the internal image for analysis, i.e. conversion from WCS->Output profile delete workimg; workimg = ipf.lab2rgb (nprevl, 0, 0, pW, pH, params.icm); - } catch(char * str) { + } catch (char * str) { progress ("Error converting file...", 0); return; } @@ -865,7 +2514,7 @@ void ImProcCoordinator::freeAll () delete workimg; - if(shmap) { + if (shmap) { delete shmap; } @@ -889,7 +2538,7 @@ void ImProcCoordinator::setScale (int prevscale) printf ("setscale before lock\n"); } - tr = getCoarseBitMask(params.coarse); + tr = getCoarseBitMask (params.coarse); int nW, nH; imgsrc->getFullSize (fw, fh, tr); @@ -900,7 +2549,7 @@ void ImProcCoordinator::setScale (int prevscale) prevscale--; PreviewProps pp (0, 0, fw, fh, prevscale); imgsrc->getSize (pp, nW, nH); - } while(nH < 400 && prevscale > 1 && (nW * nH < 1000000) ); // sctually hardcoded values, perhaps a better choice is possible + } while (nH < 400 && prevscale > 1 && (nW * nH < 1000000) ); // sctually hardcoded values, perhaps a better choice is possible if (settings->verbose) { printf ("setscale starts (%d, %d)\n", nW, nH); @@ -917,11 +2566,12 @@ void ImProcCoordinator::setScale (int prevscale) oprevi = orig_prev; oprevl = new LabImage (pW, pH); nprevl = new LabImage (pW, pH); + // nprevloc = new LabImage (pW, pH); //ncie is only used in ImProcCoordinator::updatePreviewImage, it will be allocated on first use and deleted if not used anymore previmg = new Image8 (pW, pH); workimg = new Image8 (pW, pH); - if(params.sh.enabled) { + if (params.sh.enabled) { shmap = new SHMap (pW, pH, true); } @@ -953,7 +2603,7 @@ void ImProcCoordinator::updateLRGBHistograms () { int x1, y1, x2, y2; - params.crop.mapToResized(pW, pH, scale, x1, x2, y1, y2); + params.crop.mapToResized (pW, pH, scale, x1, x2, y1, y2); #pragma omp parallel sections { @@ -964,7 +2614,7 @@ void ImProcCoordinator::updateLRGBHistograms () for (int i = y1; i < y2; i++) for (int j = x1; j < x2; j++) { - histChroma[(int)(sqrtf(SQR(nprevl->a[i][j]) + SQR(nprevl->b[i][j])) / 188.f)]++; //188 = 48000/256 + histChroma[ (int) (sqrtf (SQR (nprevl->a[i][j]) + SQR (nprevl->b[i][j])) / 188.f)]++; //188 = 48000/256 } } #pragma omp section @@ -974,7 +2624,7 @@ void ImProcCoordinator::updateLRGBHistograms () for (int i = y1; i < y2; i++) for (int j = x1; j < x2; j++) { - histLuma[(int)(nprevl->L[i][j] / 128.f)]++; + histLuma[ (int) (nprevl->L[i][j] / 128.f)]++; } } #pragma omp section @@ -1011,21 +2661,21 @@ void ImProcCoordinator::progress (Glib::ustring str, int pr) }*/ } -bool ImProcCoordinator::getAutoWB (double& temp, double& green, double equal) +bool ImProcCoordinator::getAutoWB (double & temp, double & green, double equal) { if (imgsrc) { if (lastAwbEqual != equal) { // Issue 2500 MyMutex::MyLock lock(minit); // Also used in crop window double rm, gm, bm; - imgsrc->getAutoWBMultipliers(rm, gm, bm); + imgsrc->getAutoWBMultipliers (rm, gm, bm); if (rm != -1) { - autoWB.update(rm, gm, bm, equal); + autoWB.update (rm, gm, bm, equal); lastAwbEqual = equal; } else { lastAwbEqual = -1.; - autoWB.useDefaults(equal); + autoWB.useDefaults (equal); } } @@ -1040,7 +2690,7 @@ bool ImProcCoordinator::getAutoWB (double& temp, double& green, double equal) } } -void ImProcCoordinator::getCamWB (double& temp, double& green) +void ImProcCoordinator::getCamWB (double & temp, double & green) { if (imgsrc) { @@ -1049,13 +2699,13 @@ void ImProcCoordinator::getCamWB (double& temp, double& green) } } -void ImProcCoordinator::getSpotWB (int x, int y, int rect, double& temp, double& tgreen) +void ImProcCoordinator::getSpotWB (int x, int y, int rect, double & temp, double & tgreen) { ColorTemp ret; { - MyMutex::MyLock lock(mProcessing); + MyMutex::MyLock lock (mProcessing); std::vector points, red, green, blue; for (int i = y - rect; i <= y + rect; i++) @@ -1065,7 +2715,7 @@ void ImProcCoordinator::getSpotWB (int x, int y, int rect, double& temp, double& ipf.transCoord (fw, fh, points, red, green, blue); - int tr = getCoarseBitMask(params.coarse); + int tr = getCoarseBitMask (params.coarse); ret = imgsrc->getSpotWB (red, green, blue, tr, params.wb.equal); currWB = ColorTemp (params.wb.temperature, params.wb.green, params.wb.equal, params.wb.method); @@ -1086,15 +2736,15 @@ void ImProcCoordinator::getSpotWB (int x, int y, int rect, double& temp, double& void ImProcCoordinator::getAutoCrop (double ratio, int &x, int &y, int &w, int &h) { - MyMutex::MyLock lock(mProcessing); + MyMutex::MyLock lock (mProcessing); LCPMapper *pLCPMap = nullptr; if (params.lensProf.lcpFile.length() && imgsrc->getMetaData()->getFocalLen() > 0) { - LCPProfile *pLCPProf = lcpStore->getProfile(params.lensProf.lcpFile); + LCPProfile *pLCPProf = lcpStore->getProfile (params.lensProf.lcpFile); - if (pLCPProf) pLCPMap = new LCPMapper(pLCPProf, imgsrc->getMetaData()->getFocalLen(), imgsrc->getMetaData()->getFocalLen35mm(), imgsrc->getMetaData()->getFocusDist(), - 0, false, params.lensProf.useDist, fullw, fullh, params.coarse, imgsrc->getRotateDegree()); + if (pLCPProf) pLCPMap = new LCPMapper (pLCPProf, imgsrc->getMetaData()->getFocalLen(), imgsrc->getMetaData()->getFocalLen35mm(), imgsrc->getMetaData()->getFocusDist(), + 0, false, params.lensProf.useDist, fullw, fullh, params.coarse, imgsrc->getRotateDegree()); } double fillscale = ipf.getTransformAutoFill (fullw, fullh, pLCPMap); @@ -1116,13 +2766,13 @@ void ImProcCoordinator::getAutoCrop (double ratio, int &x, int &y, int &w, int & y = (fullh - h) / 2; } -void ImProcCoordinator::setMonitorProfile (const Glib::ustring& profile, RenderingIntent intent) +void ImProcCoordinator::setMonitorProfile (const Glib::ustring & profile, RenderingIntent intent) { monitorProfile = profile; monitorIntent = intent; } -void ImProcCoordinator::getMonitorProfile (Glib::ustring& profile, RenderingIntent& intent) const +void ImProcCoordinator::getMonitorProfile (Glib::ustring & profile, RenderingIntent & intent) const { profile = monitorProfile; intent = monitorIntent; @@ -1134,20 +2784,20 @@ void ImProcCoordinator::setSoftProofing (bool softProof, bool gamutCheck) this->gamutCheck = gamutCheck; } -void ImProcCoordinator::getSoftProofing (bool &softProof, bool &gamutCheck) +void ImProcCoordinator::getSoftProofing (bool & softProof, bool & gamutCheck) { softProof = this->softProof; gamutCheck = this->gamutCheck; } -void ImProcCoordinator::saveInputICCReference (const Glib::ustring& fname, bool apply_wb) +void ImProcCoordinator::saveInputICCReference (const Glib::ustring & fname, bool apply_wb) { - MyMutex::MyLock lock(mProcessing); + MyMutex::MyLock lock (mProcessing); int fW, fH; - int tr = getCoarseBitMask(params.coarse); + int tr = getCoarseBitMask (params.coarse); imgsrc->getFullSize (fW, fH, tr); PreviewProps pp (0, 0, fW, fH, 1); @@ -1155,8 +2805,8 @@ void ImProcCoordinator::saveInputICCReference (const Glib::ustring& fname, bool ppar.toneCurve.hrenabled = false; ppar.icm.input = "(none)"; Imagefloat* im = new Imagefloat (fW, fH); - imgsrc->preprocess( ppar.raw, ppar.lensProf, ppar.coarse ); - imgsrc->demosaic(ppar.raw ); + imgsrc->preprocess ( ppar.raw, ppar.lensProf, ppar.coarse ); + imgsrc->demosaic (ppar.raw ); ColorTemp currWB = ColorTemp (params.wb.temperature, params.wb.green, params.wb.equal, params.wb.method); if (params.wb.method == "Camera") { @@ -1164,14 +2814,14 @@ void ImProcCoordinator::saveInputICCReference (const Glib::ustring& fname, bool } else if (params.wb.method == "Auto") { if (lastAwbEqual != params.wb.equal) { double rm, gm, bm; - imgsrc->getAutoWBMultipliers(rm, gm, bm); + imgsrc->getAutoWBMultipliers (rm, gm, bm); if (rm != -1.) { - autoWB.update(rm, gm, bm, params.wb.equal); + autoWB.update (rm, gm, bm, params.wb.equal); lastAwbEqual = params.wb.equal; } else { lastAwbEqual = -1.; - autoWB.useDefaults(params.wb.equal); + autoWB.useDefaults (params.wb.equal); } } @@ -1203,9 +2853,9 @@ void ImProcCoordinator::saveInputICCReference (const Glib::ustring& fname, bool for (int i = cy; i < cy + ch; i++) { for (int j = cx; j < cx + cw; j++) { - tmpim->r(i - cy, j - cx) = im->r(i, j); - tmpim->g(i - cy, j - cx) = im->g(i, j); - tmpim->b(i - cy, j - cx) = im->b(i, j); + tmpim->r (i - cy, j - cx) = im->r (i, j); + tmpim->g (i - cy, j - cx) = im->g (i, j); + tmpim->b (i - cy, j - cx) = im->b (i, j); } } @@ -1216,11 +2866,11 @@ void ImProcCoordinator::saveInputICCReference (const Glib::ustring& fname, bool // image may contain out of range samples, clip them to avoid wrap-arounds #pragma omp parallel for - for(int i = 0; i < im->height; i++) { - for(int j = 0; j < im->width; j++) { - im->r(i, j) = CLIP(im->r(i, j)); - im->g(i, j) = CLIP(im->g(i, j)); - im->b(i, j) = CLIP(im->b(i, j)); + for (int i = 0; i < im->height; i++) { + for (int j = 0; j < im->width; j++) { + im->r (i, j) = CLIP (im->r (i, j)); + im->g (i, j) = CLIP (im->g (i, j)); + im->b (i, j) = CLIP (im->b (i, j)); } } @@ -1228,7 +2878,7 @@ void ImProcCoordinator::saveInputICCReference (const Glib::ustring& fname, bool delete im; int imw, imh; - double tmpScale = ipf.resizeScale(¶ms, fW, fH, imw, imh); + double tmpScale = ipf.resizeScale (¶ms, fW, fH, imw, imh); if (tmpScale != 1.0) { Image16* tempImage = new Image16 (imw, imh); @@ -1274,13 +2924,13 @@ void ImProcCoordinator::startProcessing () //batchThread->yield(); //the running batch should wait other threads to avoid conflict - thread = Glib::Thread::create(sigc::mem_fun(*this, &ImProcCoordinator::process), 0, true, true, Glib::THREAD_PRIORITY_NORMAL); + thread = Glib::Thread::create (sigc::mem_fun (*this, &ImProcCoordinator::process), 0, true, true, Glib::THREAD_PRIORITY_NORMAL); } } } -void ImProcCoordinator::startProcessing(int changeCode) +void ImProcCoordinator::startProcessing (int changeCode) { paramsUpdateMutex.lock(); changeSinceLast |= changeCode; @@ -1328,7 +2978,7 @@ ProcParams* ImProcCoordinator::beginUpdateParams () void ImProcCoordinator::endUpdateParams (ProcEvent change) { - endUpdateParams( refreshmap[(int)change] ); + endUpdateParams ( refreshmap[ (int)change] ); } void ImProcCoordinator::endUpdateParams (int changeFlags) diff --git a/rtengine/improccoordinator.h b/rtengine/improccoordinator.h index 2cc767b39..5303f28e9 100644 --- a/rtengine/improccoordinator.h +++ b/rtengine/improccoordinator.h @@ -51,6 +51,8 @@ class ImProcCoordinator : public StagedImageProcessor { friend class Crop; +private: + protected: Imagefloat *orig_prev; @@ -87,12 +89,14 @@ protected: // Precomputed values used by DetailedCrop ---------------------------------------------- float bwAutoR, bwAutoG, bwAutoB; + int coordX, coordY, localX, localY; float CAMMean; LUTf hltonecurve; LUTf shtonecurve; LUTf tonecurve; LUTf lumacurve; +// LUTf localcurve; LUTf chroma_acurve; LUTf chroma_bcurve; LUTf satcurve; @@ -102,6 +106,7 @@ protected: multi_array2D conversionBuffer; LUTf wavclCurve; LUTf clToningcurve; + LUTf lllocalcurve; LUTf cl2Toningcurve; LUTf Noisecurve; LUTf NoiseCCcurve; @@ -135,6 +140,9 @@ protected: WavOpacityCurveWL waOpacityCurveWL; RetinextransmissionCurve dehatransmissionCurve; RetinexgaintransmissionCurve dehagaintransmissionCurve; + LocretigainCurve locRETgainCurve; + LocretigainCurverab locRETgainCurverab; + LocLHCurve loclhCurve; ColorAppearance customColCurve1; ColorAppearance customColCurve2; @@ -156,6 +164,8 @@ protected: AutoExpListener* aeListener; AutoCamListener* acListener; AutoBWListener* abwListener; + localListener* aloListener; + AutoColorTonListener* actListener; AutoChromaListener* adnListener; WaveletListener* awavListener; @@ -193,8 +203,10 @@ protected: int changeSinceLast; bool updaterRunning; ProcParams nextParams; + ProcParams nextParams2; bool destroying; bool utili; + bool locutili; bool autili; bool butili; bool ccutili; @@ -202,6 +214,82 @@ protected: bool clcutili; bool opautili; bool wavcontlutili; + bool locallutili; + int **dataspot; + std::string *retistr; + std::string *llstr; + std::string *lhstr; + + LUTi circrads; + LUTi centerx; + LUTi centery; + LUTi locx; + LUTi locy; + LUTi locxl; + LUTi locyt; + LUTi lights; + LUTi contrs; + LUTi chroms; + LUTi sensis; + LUTi transits; + LUTi inverss; + LUTi curvactivs; + LUTi smeths; + LUTi curens; + LUTi radiuss; + LUTi strengths; + LUTi sensibns; + LUTi inversrads; + LUTi strs; + LUTi chrrts; + LUTi neighs; + LUTi varts; + LUTi sensihs; + LUTi inversrets; + LUTi retinexs; + LUTi sps; + LUTi sharradiuss; + LUTi sharamounts; + LUTi shardampings; + LUTi inversshas; + LUTi shariters; + LUTi sensishas; + LUTi qualitys; + LUTi thress; + LUTi proxis; + LUTi noiselumfs; + LUTi noiselumcs; + LUTi noisechrofs; + LUTi noisechrocs; + LUTi mult0s; + LUTi mult1s; + LUTi mult2s; + LUTi mult3s; + LUTi mult4s; + LUTi thresholds; + LUTi sensicbs; + LUTi activlums; + LUTi strens; + LUTi gammas; + LUTi estops; + LUTi scaltms; + LUTi reweis; + LUTi sensitms; + + int versionmip; + LUTi sizeretics; + LUTi reticurvs; + LUTi retrabs; + LUTi llcurvs; + LUTi sizellcs; + LUTi lhcurvs; + LUTi sizelhcs; + + LUTf huerefs; + LUTf chromarefs; + LUTf lumarefs; + + void startProcessing (); void process (); float colourToningSatLimit; @@ -218,12 +306,14 @@ public: *dst = params; } - void startProcessing(int changeCode); + void startProcessing (int changeCode); ProcParams* beginUpdateParams (); void endUpdateParams (ProcEvent change); // must be called after beginUpdateParams, triggers update void endUpdateParams (int changeFlags); void stopProcessing (); +// void updatePreviewImage (int todo, Crop* cropCall = NULL); + std::string *retistrsav; void setPreviewScale (int scale) { @@ -299,7 +389,7 @@ public: { aeListener = ael; } - void setHistogramListener(HistogramListener *h) + void setHistogramListener (HistogramListener *h) { hListener = h; } @@ -311,6 +401,11 @@ public: { abwListener = abw; } + void setlocalListener (localListener* alo) + { + aloListener = alo; + } + void setAutoColorTonListener (AutoColorTonListener* bwct) { actListener = bwct; @@ -336,7 +431,7 @@ public: } struct DenoiseInfoStore { - DenoiseInfoStore () : chM(0), max_r{}, max_b{}, ch_M{}, valid(false) {} + DenoiseInfoStore () : chM (0), max_r{}, max_b{}, ch_M{}, valid (false) {} float chM; float max_r[9]; float max_b[9]; diff --git a/rtengine/improcfun.cc b/rtengine/improcfun.cc index 1a3a969ae..852a11f0a 100644 --- a/rtengine/improcfun.cc +++ b/rtengine/improcfun.cc @@ -78,6 +78,7 @@ void ImProcFunctions::updateColorProfiles (const Glib::ustring& monitorProfile, monitorTransform = nullptr; cmsHPROFILE monitor = nullptr; + if (!monitorProfile.empty()) { #if !defined(__APPLE__) // No support for monitor profiles on OS X, all data is sRGB monitor = iccStore->getProfile (monitorProfile); @@ -96,6 +97,7 @@ void ImProcFunctions::updateColorProfiles (const Glib::ustring& monitorProfile, if (softProof) { cmsHPROFILE oprof = nullptr; + if (!settings->printerProfile.empty()) { oprof = iccStore->getProfile(settings->printerProfile); } @@ -103,19 +105,23 @@ void ImProcFunctions::updateColorProfiles (const Glib::ustring& monitorProfile, if (oprof) { // NOCACHE is for thread safety, NOOPTIMIZE for precision flags = cmsFLAGS_SOFTPROOFING | cmsFLAGS_NOOPTIMIZE | cmsFLAGS_NOCACHE; + if (settings->printerBPC) { flags |= cmsFLAGS_BLACKPOINTCOMPENSATION; } + if (gamutCheck) { flags |= cmsFLAGS_GAMUTCHECK; } + monitorTransform = cmsCreateProofingTransform( - iprof, TYPE_Lab_FLT, - monitor, TYPE_RGB_8, - oprof, - monitorIntent, settings->printerIntent, - flags - ); + iprof, TYPE_Lab_FLT, + monitor, TYPE_RGB_8, + oprof, + monitorIntent, settings->printerIntent, + flags + ); + if (monitorTransform) { softProofCreated = true; } @@ -124,9 +130,11 @@ void ImProcFunctions::updateColorProfiles (const Glib::ustring& monitorProfile, if (!softProofCreated) { flags = cmsFLAGS_NOOPTIMIZE | cmsFLAGS_NOCACHE; + if (settings->monitorBPC) { flags |= cmsFLAGS_BLACKPOINTCOMPENSATION; } + monitorTransform = cmsCreateTransform (iprof, TYPE_Lab_FLT, monitor, TYPE_RGB_8, monitorIntent, flags); } @@ -196,6 +204,7 @@ void ImProcFunctions::firstAnalysis (const Imagefloat* const original, const Pro } } + // Copyright (c) 2012 Jacques Desmis void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh, int pW, int pwb, LabImage* lab, const ProcParams* params , const ColorAppearance & customColCurve1, const ColorAppearance & customColCurve2, const ColorAppearance & customColCurve3, @@ -535,7 +544,7 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh xw2 = xwd; yw2 = ywd; zw2 = zwd; - } else /*if(params->colorappearance.wbmodel == "RawTCAT02")*/ { + } else { /*if(params->colorappearance.wbmodel == "RawTCAT02")*/ xw1 = xw; // Settings RT WB are used for CAT02 => mix , CAT02 is use for output device (screen: D50 D65, projector: lamp, LED) see preferences yw1 = yw; zw1 = zw; @@ -1076,9 +1085,10 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh if(pW != 1) { //only with improccoordinator int posl; + if(libr == 1) { posl = CLIP((int)(Q * brli)); //40.0 to 100.0 approximative factor for Q - 327 for J - } else /*if(libr == 0)*/ { + } else { /*if(libr == 0)*/ posl = CLIP((int)(J * brli)); //327 for J } @@ -1089,11 +1099,12 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh if(pW != 1) { //only with improccoordinator int posc; + if(colch == 0) { posc = CLIP((int)(C * chsacol)); //450.0 approximative factor for s 320 for M } else if(colch == 1) { posc = CLIP((int)(s * chsacol)); - } else /*if(colch == 2)*/ { + } else { /*if(colch == 2)*/ posc = CLIP((int)(M * chsacol)); } @@ -1347,9 +1358,10 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh if(pW != 1) { //only with improccoordinator int posl; + if(libr == 1) { posl = CLIP((int)(ncie->Q_p[i][j] * brli)); //40.0 to 100.0 approximative factor for Q - 327 for J - } else /*if(libr == 0)*/ { + } else { /*if(libr == 0)*/ posl = CLIP((int)(ncie->J_p[i][j] * brli)); //327 for J } @@ -1360,12 +1372,13 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh if(pW != 1) { //only with improccoordinator int posc; + if(colch == 0) { posc = CLIP((int)(ncie->C_p[i][j] * chsacol)); //450.0 approximative factor for s 320 for M } else if(colch == 1) { sa_t = 100.f * sqrt(ncie->C_p[i][j] / ncie->Q_p[i][j]); //Q_p always > 0 posc = CLIP((int)(sa_t * chsacol)); - } else /*if(colch == 2)*/ { + } else { /*if(colch == 2)*/ posc = CLIP((int)(ncie->M_p[i][j] * chsacol)); } @@ -1835,7 +1848,7 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int begh, int xw2 = xwd; yw2 = ywd; zw2 = zwd; - } else /*if(params->colorappearance.wbmodel == "RawTCAT02")*/ { + } else { /*if(params->colorappearance.wbmodel == "RawTCAT02")*/ xw1 = xw; // Settings RT WB are used for CAT02 => mix , CAT02 is use for output device (screen: D50 D65, projector: lamp, LED) see preferences yw1 = yw; zw1 = zw; @@ -3004,7 +3017,7 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer static_cast( wprof[2][2] / Color::D50z) } }; - float maxFactorToxyz = max(toxyz[1][0],toxyz[1][1],toxyz[1][2]); + float maxFactorToxyz = max(toxyz[1][0], toxyz[1][1], toxyz[1][2]); float equalR = maxFactorToxyz / toxyz[1][0]; float equalG = maxFactorToxyz / toxyz[1][1]; float equalB = maxFactorToxyz / toxyz[1][2]; @@ -3331,6 +3344,7 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer float out_rgbx[4 * TS] ALIGNED16; // Line buffer for CLUT LUTu histToneCurveThr; + if(toneCurveHistSize > 0) { histToneCurveThr(toneCurveHistSize); histToneCurveThr.clear(); @@ -3484,9 +3498,10 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer rtemp[ti * TS + tj] = tonecurve[ rtemp[ti * TS + tj] ]; gtemp[ti * TS + tj] = tonecurve[ gtemp[ti * TS + tj] ]; btemp[ti * TS + tj] = tonecurve[ btemp[ti * TS + tj] ]; + if(histToneCurveThr) { int y = CLIP(lumimulf[0] * Color::gamma2curve[rtemp[ti * TS + tj]] + lumimulf[1] * Color::gamma2curve[gtemp[ti * TS + tj]] + lumimulf[2] * Color::gamma2curve[btemp[ti * TS + tj]]); - histToneCurveThr[y>>histToneCurveCompression]++; + histToneCurveThr[y >> histToneCurveCompression]++; } } } @@ -3731,7 +3746,7 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer //gamut control : Lab values are in gamut Color::gamutLchonly(HH, sincosval, Lpro, Chpro, rtemp[ti * TS + tj], gtemp[ti * TS + tj], btemp[ti * TS + tj], wip, highlight, 0.15f, 0.96f); #endif - //end of gamut control + //end of gamut control } else { float x_, y_, z_; //calculate RGB with L_2 and old value of a and b @@ -4134,20 +4149,25 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer // -------------------------------------------------- #ifndef __SSE2__ + //gamma correction: pseudo TRC curve if (hasgammabw) { Color::trcGammaBW (r, g, b, gammabwr, gammabwg, gammabwb); } + #endif rtemp[ti * TS + tj] = r; gtemp[ti * TS + tj] = g; btemp[ti * TS + tj] = b; } + #ifdef __SSE2__ + if (hasgammabw) { //gamma correction: pseudo TRC curve Color::trcGammaBWRow (&rtemp[ti * TS], >emp[ti * TS], &btemp[ti * TS], tW - jstart, gammabwr, gammabwg, gammabwb); } + #endif } @@ -4185,6 +4205,7 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer } else { L *= (1.f + valparam); //for negative } + L *= 32768.f; } @@ -4206,17 +4227,22 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer Color::xyz2r(X, Y, Z, newRed, wip); rtemp[ti * TS + tj] = gtemp[ti * TS + tj] = btemp[ti * TS + tj] = newRed; #ifndef __SSE2__ + if (hasgammabw) { //gamma correction: pseudo TRC curve Color::trcGammaBW (rtemp[ti * TS + tj], gtemp[ti * TS + tj], btemp[ti * TS + tj], gammabwr, gammabwg, gammabwb); } + #endif } + #ifdef __SSE2__ + if (hasgammabw) { //gamma correction: pseudo TRC curve Color::trcGammaBWRow (&rtemp[ti * TS], >emp[ti * TS], &btemp[ti * TS], tW - jstart, gammabwr, gammabwg, gammabwb); } + #endif } } @@ -4413,13 +4439,14 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer if (editWhateverBuffer) { free (editWhateverBuffer); } + #ifdef _OPENMP -#pragma omp critical -{ - if(toneCurveHistSize > 0) { - histToneCurve += histToneCurveThr; - } -} + #pragma omp critical + { + if(toneCurveHistSize > 0) { + histToneCurve += histToneCurveThr; + } + } #endif // _OPENMP } @@ -4483,17 +4510,22 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer tmpImage->r(i, j) = tmpImage->g(i, j) = tmpImage->b(i, j) = CLIP((bwr * tmpImage->r(i, j) + bwg * tmpImage->g(i, j) + bwb * tmpImage->b(i, j)) * kcorec); #ifndef __SSE2__ + //gamma correction: pseudo TRC curve if (hasgammabw) { Color::trcGammaBW (tmpImage->r(i, j), tmpImage->g(i, j), tmpImage->b(i, j), gammabwr, gammabwg, gammabwb); } + #endif } + #ifdef __SSE2__ + if (hasgammabw) { //gamma correction: pseudo TRC curve Color::trcGammaBWRow (tmpImage->r(i), tmpImage->g(i), tmpImage->b(i), tW, gammabwr, gammabwg, gammabwb); } + #endif } } @@ -6492,6 +6524,109 @@ void ImProcFunctions::EPDToneMapCIE(CieImage *ncie, float a_w, float c_, float w */ } +void ImProcFunctions::EPDToneMaplocal(LabImage *lab, LabImage *tmp1, unsigned int Iterates, int skip) +{ + + float stren = ((float)params->locallab.stren) / 100.f; + float edgest = ((float)params->locallab.estop) / 100.f; + float sca = ((float)params->locallab.scaltm) / 10.f; + float gamm = ((float)params->locallab.gamma) / 100.f; + float rew = ((float)params->locallab.rewei); + //Pointers to whole data and size of it. + float *L = lab->L[0]; + float *a = lab->a[0]; + float *b = lab->b[0]; + unsigned int i, N = lab->W * lab->H; + int WW = lab->W ; + int HH = lab->H ; + EdgePreservingDecomposition epd(lab->W, lab->H); + + //Due to the taking of logarithms, L must be nonnegative. Further, scale to 0 to 1 using nominal range of L, 0 to 15 bit. + float minL = FLT_MAX; + float maxL = 0.f; + #pragma omp parallel + { + float lminL = FLT_MAX; + float lmaxL = 0.f; + #pragma omp for + + for(i = 0; i < N; i++) { + if(L[i] < lminL) { + lminL = L[i]; + } + + if(L[i] > lmaxL) { + lmaxL = L[i]; + } + } + + #pragma omp critical + + if(lminL < minL) { + minL = lminL; + } + + if(lmaxL > maxL) { + maxL = lmaxL; + } + + } + + if(minL > 0.0f) { + minL = 0.0f; //Disable the shift if there are no negative numbers. I wish there were just no negative numbers to begin with. + } + + #pragma omp parallel for + + for(i = 0; i < N; i++) + //{L[i] = (L[i] - minL)/32767.0f; + { + L[i] = (L[i] - minL) / maxL; + L[i] *= gamm; + } + + //Some interpretations. + float Compression = expf(-stren); //This modification turns numbers symmetric around 0 into exponents. + float DetailBoost = stren; + + if(stren < 0.0f) { + DetailBoost = 0.0f; //Go with effect of exponent only if uncompressing. + } + + //Auto select number of iterates. Note that p->EdgeStopping = 0 makes a Gaussian blur. + if(Iterates == 0) { + Iterates = (unsigned int)(edgest * 15.0f); + } + + /* Debuggery. Saves L for toying with outside of RT. + char nm[64]; + sprintf(nm, "%ux%ufloat.bin", lab->W, lab->H); + FILE *f = fopen(nm, "wb"); + fwrite(L, N, sizeof(float), f); + fclose(f);*/ + + epd.CompressDynamicRange(L, sca / float(skip), edgest, Compression, DetailBoost, Iterates, rew, L); + + //Restore past range, also desaturate a bit per Mantiuk's Color correction for tone mapping. + float s = (1.0f + 38.7889f) * powf(Compression, 1.5856f) / (1.0f + 38.7889f * powf(Compression, 1.5856f)); +#ifdef _OPENMP + #pragma omp parallel for // removed schedule(dynamic,10) +#endif + + for(int i = 0; i < N; i++) { + int x = i / WW; + int y = i - x * WW; + + tmp1->L[x][y] = L[i] * maxL * (1.f / gamm) + minL; + tmp1->a[x][y] = s * a[i]; + tmp1->b[x][y] = s * b[i]; + + } +} + + + + //Map tones by way of edge preserving decomposition. Is this the right way to include source? //#include "EdgePreservingDecomposition.cc" @@ -6602,6 +6737,12 @@ void ImProcFunctions::EPDToneMap(LabImage *lab, unsigned int Iterates, int skip) } + + + + + + void ImProcFunctions::getAutoExp (const LUTu &histogram, int histcompr, double defgain, double clip, double& expcomp, int& bright, int& contr, int& black, int& hlcompr, int& hlcomprthresh) { diff --git a/rtengine/improcfun.h b/rtengine/improcfun.h index e70083b0b..09183b9cc 100644 --- a/rtengine/improcfun.h +++ b/rtengine/improcfun.h @@ -52,7 +52,7 @@ class ImProcFunctions double scale; bool multiThread; - void calcVignettingParams(int oW, int oH, const VignettingParams& vignetting, double &w2, double &h2, double& maxRadius, double &v, double &b, double &mul); + void calcVignettingParams (int oW, int oH, const VignettingParams& vignetting, double &w2, double &h2, double& maxRadius, double &v, double &b, double &mul); void transformPreview (Imagefloat* original, Imagefloat* transformed, int cx, int cy, int sx, int sy, int oW, int oH, int fW, int fH, const LCPMapper *pLCPMap); void transformLuminanceOnly (Imagefloat* original, Imagefloat* transformed, int cx, int cy, int oW, int oH, int fW, int fH); @@ -95,9 +95,9 @@ class ImProcFunctions rd = gd = bd = 0.0; for (int i = xs, ix = 0; i < xs + 4; i++, ix++) { - rd += src->r(k, i) * w[ix]; - gd += src->g(k, i) * w[ix]; - bd += src->b(k, i) * w[ix]; + rd += src->r (k, i) * w[ix]; + gd += src->g (k, i) * w[ix]; + bd += src->b (k, i) * w[ix]; } yr[kx] = rd; @@ -196,7 +196,7 @@ public: double lumimul[3]; ImProcFunctions (const ProcParams* iparams, bool imultiThread = true) - : monitorTransform(nullptr), lab2outputTransform(nullptr), output2monitorTransform(nullptr), params(iparams), scale(1), multiThread(imultiThread), lumimul{} {} + : monitorTransform (nullptr), lab2outputTransform (nullptr), output2monitorTransform (nullptr), params (iparams), scale (1), multiThread (imultiThread), lumimul{} {} ~ImProcFunctions (); void setScale (double iscale); @@ -244,10 +244,12 @@ public: void Lanczos (const Image16* src, Image16* dst, float scale); void deconvsharpening (float** luminance, float** buffer, int W, int H, const SharpeningParams &sharpenParam); + void deconvsharpeningloc (float** luminance, float** buffer, int W, int H, float** loctemp, int damp, double radi, int ite, int amo); + void MLsharpen (LabImage* lab);// Manuel's clarity / sharpening - void MLmicrocontrast(float** luminance, int W, int H ); //Manuel's microcontrast - void MLmicrocontrast(LabImage* lab ); //Manuel's microcontrast - void MLmicrocontrastcam(CieImage* ncie ); //Manuel's microcontrast + void MLmicrocontrast (float** luminance, int W, int H ); //Manuel's microcontrast + void MLmicrocontrast (LabImage* lab ); //Manuel's microcontrast + void MLmicrocontrastcam (CieImage* ncie ); //Manuel's microcontrast void impulsedenoise (LabImage* lab);//Emil's impulse denoise void impulsedenoisecam (CieImage* ncie, float **buffers[3]); @@ -258,13 +260,14 @@ public: void dirpyrequalizer (LabImage* lab, int scale);//Emil's wavelet - void EPDToneMapResid(float * WavCoeffs_L0, unsigned int Iterates, int skip, struct cont_params& cp, int W_L, int H_L, float max0, float min0); - float *CompressDR(float *Source, int skip, struct cont_params &cp, int W_L, int H_L, float Compression, float DetailBoost, float max0, float min0, float ave, float ah, float bh, float al, float bl, float factorx, float *Compressed); - void ContrastResid(float * WavCoeffs_L0, unsigned int Iterates, int skip, struct cont_params &cp, int W_L, int H_L, float max0, float min0, float ave, float ah, float bh, float al, float bl, float factorx); - float *ContrastDR(float *Source, int skip, struct cont_params &cp, int W_L, int H_L, float Compression, float DetailBoost, float max0, float min0, float ave, float ah, float bh, float al, float bl, float factorx, float *Contrast = nullptr); + void EPDToneMapResid (float * WavCoeffs_L0, unsigned int Iterates, int skip, struct cont_params& cp, int W_L, int H_L, float max0, float min0); + float *CompressDR (float *Source, int skip, struct cont_params &cp, int W_L, int H_L, float Compression, float DetailBoost, float max0, float min0, float ave, float ah, float bh, float al, float bl, float factorx, float *Compressed); + void ContrastResid (float * WavCoeffs_L0, unsigned int Iterates, int skip, struct cont_params &cp, int W_L, int H_L, float max0, float min0, float ave, float ah, float bh, float al, float bl, float factorx); + float *ContrastDR (float *Source, int skip, struct cont_params &cp, int W_L, int H_L, float Compression, float DetailBoost, float max0, float min0, float ave, float ah, float bh, float al, float bl, float factorx, float *Contrast = nullptr); - void EPDToneMap(LabImage *lab, unsigned int Iterates = 0, int skip = 1); - void EPDToneMapCIE(CieImage *ncie, float a_w, float c_, float w_h, int Wid, int Hei, int begh, int endh, float minQ, float maxQ, unsigned int Iterates = 0, int skip = 1); + void EPDToneMap (LabImage *lab, unsigned int Iterates = 0, int skip = 1); + void EPDToneMapCIE (CieImage *ncie, float a_w, float c_, float w_h, int Wid, int Hei, int begh, int endh, float minQ, float maxQ, unsigned int Iterates = 0, int skip = 1); + void EPDToneMaplocal (LabImage *lab, LabImage *tmp1, unsigned int Iterates, int skip); // pyramid denoise procparams::DirPyrDenoiseParams dnparams; @@ -272,66 +275,93 @@ public: int pitch, int scale, const int luma, int chroma ); void idirpyr (LabImage* data_coarse, LabImage* data_fine, int level, LUTf &rangefn_L, LUTf & nrwt_l, LUTf & nrwt_ab, int pitch, int scale, const int luma, const int chroma/*, LUTf & Lcurve, LUTf & abcurve*/ ); + //locallab + void MSRLocal (float** luminance, float** templ, const float* const *originalLuminance, const int width, const int height, const LocallabParams &loc, const int skip, const LocretigainCurve &locRETgainCcurve, const int chrome, const int scall, const float krad, float &minCD, float &maxCD, float &mini, float &maxi, float &Tmean, float &Tsigma, float &Tmin, float &Tmax); + + void Lab_Local (int call, int sp, float** shbuffer, LabImage* original, LabImage* transformed, int sx, int sy, int cx, int cy, int oW, int oH, int fw, int fh, bool locutili, int sk, const LocretigainCurve & locRETgainCcurve, bool locallutili, LUTf & lllocalcurve, const LocLHCurve & loclhCurve, double &hueref, double &chromaref, double &lumaref); + void addGaNoise (LabImage *lab, LabImage *dst, const float mean, const float variance, const int sk); + void BlurNoise_Localold (int call, const struct local_params& lp, LabImage* original, LabImage* transformed, const LabImage* const tmp1, int cx, int cy); + void InverseBlurNoise_Local (const struct local_params& lp, LabImage* original, LabImage* transformed, const LabImage* const tmp1, int cx, int cy); + void Reti_Local (int call, const float hueplus, const float huemoins, const float hueref, const float dhue, const float chromaref, const float lumaref, const struct local_params& lp, float **deltE, LabImage* original, LabImage* transformed, const LabImage* const tmp1, int cx, int cy, int chro); + void InverseReti_Local (const struct local_params& lp, LabImage* original, LabImage* transformed, const LabImage* const tmp1, int cx, int cy, int chro); + void Contrast_Local (int call, float moy, const float hueplus, const float huemoins, const float hueref, const float dhue, const float chromaref, float pm, struct local_contra &lco, float lumaref, float av, const struct local_params& lp, float **deltE, LabImage* original, LabImage* transformed, int cx, int cy); + void cbdl_Local (int call, int sp, float **loctemp, const float hueplus, const float huemoins, const float hueref, const float dhue, const float chromaref, const float lumaref, const local_params& lp, float **deltE, LabImage* original, LabImage* transformed, int cx, int cy); + void BlurNoise_Local (int call, int sp, LabImage* tmp1, const float hueplus, const float huemoins, const float hueref, const float dhue, const float chromaref, const float lumaref, const local_params& lp, float **deltE, LabImage* original, LabImage* transformed, int cx, int cy); + void TM_Local (int call, int sp, LabImage* tmp1, const float hueplus, const float huemoins, const float hueref, const float dhue, const float chromaref, const float lumaref, const local_params& lp, float **deltE, LabImage* original, LabImage* transformed, int cx, int cy); + static void strcurv_data (std::string retistr, int *s_datc, int &siz); + void InverseContrast_Local (float ave, const struct local_contra& lco, const struct local_params& lp, LabImage* original, LabImage* transformed, int cx, int cy); + + void DeNoise_Local (int call, const struct local_params& lp, LabImage* original, LabImage* transformed, const LabImage* const tmp1, int cx, int cy); + + void ColorLight_Local (int call, LabImage * bufcolorig, LabImage * bufcoltra, int sp, float moy, const float hueplus, const float huemoins, const float hueref, const float dhue, const float chromaref, const float lumaref, bool locallutili, LUTf & lllocalcurve, const LocLHCurve & loclhCurve, const local_params& lp, float **deltE, LabImage* original, LabImage* transformed, int cx, int cy); + void InverseColorLight_Local (const struct local_params& lp, LabImage* original, LabImage* transformed, int cx, int cy); + + void Sharp_Local (int call, int sp, float **loctemp, const float hueplus, const float huemoins, const float hueref, const float dhue, const float chromaref, const float lumaref, const local_params& lp, float **deltE, LabImage* original, LabImage* transformed, int cx, int cy); + void InverseSharp_Local (int sp, float **loctemp, const float hueplus, const float huemoins, const float hueref, const float dhue, const float chromaref, const float lumaref, const local_params& lp, float **deltE, LabImage* original, LabImage* transformed, int cx, int cy); + 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); + 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); - void WaveletcontAllL(LabImage * lab, float **varhue, float **varchrom, wavelet_decomposition &WaveletCoeffs_L, - struct cont_params &cp, int skip, float *mean, float *meanN, float *sigma, float *sigmaN, float *MaxP, float *MaxN, const WavCurve & wavCLVCcurve, const WavOpacityCurveW & waOpacityCurveW, const WavOpacityCurveWL & waOpacityCurveWL, FlatCurve* ChCurve, bool Chutili); - void WaveletcontAllLfinal(wavelet_decomposition &WaveletCoeffs_L, struct cont_params &cp, float *mean, float *sigma, float *MaxP, const WavOpacityCurveWL & waOpacityCurveWL); - void WaveletcontAllAB(LabImage * lab, float **varhue, float **varchrom, wavelet_decomposition &WaveletCoeffs_a, const WavOpacityCurveW & waOpacityCurveW, - struct cont_params &cp, const bool useChannelA); - void WaveletAandBAllAB(LabImage * lab, float **varhue, float **varchrom, wavelet_decomposition &WaveletCoeffs_a, wavelet_decomposition &WaveletCoeffs_b, - struct cont_params &cp, const WavOpacityCurveW & waOpacityCurveW, FlatCurve* hhcurve, bool hhutili); + void WaveletcontAllL (LabImage * lab, float **varhue, float **varchrom, wavelet_decomposition &WaveletCoeffs_L, + struct cont_params &cp, int skip, float *mean, float *meanN, float *sigma, float *sigmaN, float *MaxP, float *MaxN, const WavCurve & wavCLVCcurve, const WavOpacityCurveW & waOpacityCurveW, const WavOpacityCurveWL & waOpacityCurveWL, FlatCurve* ChCurve, bool Chutili); + void WaveletcontAllLfinal (wavelet_decomposition &WaveletCoeffs_L, struct cont_params &cp, float *mean, float *sigma, float *MaxP, const WavOpacityCurveWL & waOpacityCurveWL); + void WaveletcontAllAB (LabImage * lab, float **varhue, float **varchrom, wavelet_decomposition &WaveletCoeffs_a, const WavOpacityCurveW & waOpacityCurveW, + struct cont_params &cp, const bool useChannelA); + void WaveletAandBAllAB (LabImage * lab, float **varhue, float **varchrom, wavelet_decomposition &WaveletCoeffs_a, wavelet_decomposition &WaveletCoeffs_b, + struct cont_params &cp, const WavOpacityCurveW & waOpacityCurveW, FlatCurve* hhcurve, bool hhutili); void ContAllL (float **koeLi, float *maxkoeLi, bool lipschitz, int maxlvl, LabImage * lab, float **varhue, float **varchrom, float ** WavCoeffs_L, float * WavCoeffs_L0, int level, int dir, struct cont_params &cp, int W_L, int H_L, int skip, float *mean, float *meanN, float *sigma, float *sigmaN, float *MaxP, float *MaxN, const WavCurve & wavCLVCcurve, const WavOpacityCurveW & waOpacityCurveW, FlatCurve* ChCurve, bool Chutili); void finalContAllL (float ** WavCoeffs_L, float * WavCoeffs_L0, int level, int dir, struct cont_params &cp, int W_L, int H_L, float *mean, float *sigma, float *MaxP, const WavOpacityCurveWL & waOpacityCurveWL); void ContAllAB (LabImage * lab, int maxlvl, float **varhue, float **varchrom, float ** WavCoeffs_a, float * WavCoeffs_a0, int level, int dir, const WavOpacityCurveW & waOpacityCurveW, struct cont_params &cp, int W_ab, int H_ab, const bool useChannelA); - void Evaluate2(wavelet_decomposition &WaveletCoeffs_L, - const struct cont_params& cp, int ind, float *mean, float *meanN, float *sigma, float *sigmaN, float *MaxP, float *MaxN, float madL[8][3]); + void Evaluate2 (wavelet_decomposition &WaveletCoeffs_L, + const struct cont_params& cp, int ind, float *mean, float *meanN, float *sigma, float *sigmaN, float *MaxP, float *MaxN, float madL[8][3]); void Eval2 (float ** WavCoeffs_L, int level, const struct cont_params& cp, int W_L, int H_L, int skip_L, int ind, float *mean, float *meanN, float *sigma, float *sigmaN, float *MaxP, float *MaxN, float *madL); - void Aver(float * HH_Coeffs, int datalen, float &averagePlus, float &averageNeg, float &max, float &min); - void Sigma(float * HH_Coeffs, int datalen, float averagePlus, float averageNeg, float &sigmaPlus, float &sigmaNeg); - void calckoe(float ** WavCoeffs_LL, const struct cont_params& cp, float ** koeLi, int level, int dir, int W_L, int H_L, float edd, float *maxkoeLi, float **tmC = nullptr); + void Aver (float * HH_Coeffs, int datalen, float &averagePlus, float &averageNeg, float &max, float &min); + void Sigma (float * HH_Coeffs, int datalen, float averagePlus, float averageNeg, float &sigmaPlus, float &sigmaNeg); + void calckoe (float ** WavCoeffs_LL, const struct cont_params& cp, float ** koeLi, int level, int dir, int W_L, int H_L, float edd, float *maxkoeLi, float **tmC = nullptr); - void Median_Denoise( float **src, float **dst, int width, int height, Median medianType, int iterations, int numThreads, float **buffer = nullptr); - void RGB_denoise(int kall, Imagefloat * src, Imagefloat * dst, Imagefloat * calclum, float * ch_M, float *max_r, float *max_b, bool isRAW, const procparams::DirPyrDenoiseParams & dnparams, const double expcomp, const NoiseCurve & noiseLCurve , const NoiseCurve & noiseCCurve , float &chaut, float &redaut, float &blueaut, float &maxredaut, float & maxblueaut, float &nresi, float &highresi); - void RGB_denoise_infoGamCurve(const procparams::DirPyrDenoiseParams & dnparams, const bool isRAW, LUTf &gamcurve, float &gam, float &gamthresh, float &gamslope); - void RGB_denoise_info(Imagefloat * src, Imagefloat * provicalc, bool isRAW, LUTf &gamcurve, float gam, float gamthresh, float gamslope, const procparams::DirPyrDenoiseParams & dnparams, const double expcomp, float &chaut, int &Nb, float &redaut, float &blueaut, float &maxredaut, float & maxblueaut, float &minredaut, float & minblueaut, float &chromina, float &sigma, float &lumema, float &sigma_L, float &redyel, float &skinc, float &nsknc, bool multiThread = false); + void Median_Denoise ( float **src, float **dst, int width, int height, Median medianType, int iterations, int numThreads, float **buffer = nullptr); + void RGB_denoise (int kall, Imagefloat * src, Imagefloat * dst, Imagefloat * calclum, float * ch_M, float *max_r, float *max_b, bool isRAW, const procparams::DirPyrDenoiseParams & dnparams, const double expcomp, const NoiseCurve & noiseLCurve , const NoiseCurve & noiseCCurve , float &chaut, float &redaut, float &blueaut, float &maxredaut, float & maxblueaut, float &nresi, float &highresi); + void RGB_denoise_infoGamCurve (const procparams::DirPyrDenoiseParams & dnparams, const bool isRAW, LUTf &gamcurve, float &gam, float &gamthresh, float &gamslope); + void RGB_denoise_info (Imagefloat * src, Imagefloat * provicalc, bool isRAW, LUTf &gamcurve, float gam, float gamthresh, float gamslope, const procparams::DirPyrDenoiseParams & dnparams, const double expcomp, float &chaut, int &Nb, float &redaut, float &blueaut, float &maxredaut, float & maxblueaut, float &minredaut, float & minblueaut, float &chromina, float &sigma, float &lumema, float &sigma_L, float &redyel, float &skinc, float &nsknc, bool multiThread = false); void RGBtile_denoise (float * fLblox, int hblproc, float noisevar_Ldetail, float * nbrwt, float * blurbuffer ); //for DCT void RGBoutput_tile_row (float *bloxrow_L, float ** Ldetail, float ** tilemask_out, int height, int width, int top ); - bool WaveletDenoiseAllL(wavelet_decomposition &WaveletCoeffs_L, float *noisevarlum, float madL[8][3], float * vari, int edge); - bool WaveletDenoiseAllAB(wavelet_decomposition &WaveletCoeffs_L, wavelet_decomposition &WaveletCoeffs_ab, float *noisevarchrom, float madL[8][3], float noisevar_ab, const bool useNoiseCCurve, bool autoch, bool denoiseMethodRgb); - void WaveletDenoiseAll_info(int levwav, wavelet_decomposition &WaveletCoeffs_a, - wavelet_decomposition &WaveletCoeffs_b, float **noisevarlum, float **noisevarchrom, float **noisevarhue, int width, int height, float noisevar_abr, float noisevar_abb, LabImage * noi, float &chaut, int &Nb, float &redaut, float &blueaut, float &maxredaut, float &maxblueaut, float &minredaut, float & minblueaut, int schoice, bool autoch, float &chromina, float &sigma, float &lumema, float &sigma_L, float &redyel, float &skinc, float &nsknc, - float &maxchred, float &maxchblue, float &minchred, float &minchblue, int &nb, float &chau, float &chred, float &chblue, bool denoiseMethodRgb, bool multiThread); + bool WaveletDenoiseAllL (wavelet_decomposition &WaveletCoeffs_L, float *noisevarlum, float madL[8][3], float * vari, int edge); + bool WaveletDenoiseAllAB (wavelet_decomposition &WaveletCoeffs_L, wavelet_decomposition &WaveletCoeffs_ab, float *noisevarchrom, float madL[8][3], float *variC, int local, float noisevar_ab, const bool useNoiseCCurve, bool autoch, bool denoiseMethodRgb); + void WaveletDenoiseAll_info (int levwav, wavelet_decomposition &WaveletCoeffs_a, + wavelet_decomposition &WaveletCoeffs_b, float **noisevarlum, float **noisevarchrom, float **noisevarhue, int width, int height, float noisevar_abr, float noisevar_abb, LabImage * noi, float &chaut, int &Nb, float &redaut, float &blueaut, float &maxredaut, float &maxblueaut, float &minredaut, float & minblueaut, int schoice, bool autoch, float &chromina, float &sigma, float &lumema, float &sigma_L, float &redyel, float &skinc, float &nsknc, + float &maxchred, float &maxchblue, float &minchred, float &minchblue, int &nb, float &chau, float &chred, float &chblue, bool denoiseMethodRgb, bool multiThread); - bool WaveletDenoiseAll_BiShrinkL(wavelet_decomposition &WaveletCoeffs_L, float *noisevarlum, float madL[8][3]); - bool WaveletDenoiseAll_BiShrinkAB(wavelet_decomposition &WaveletCoeffs_L, wavelet_decomposition &WaveletCoeffs_ab, float *noisevarchrom, float madL[8][3], float noisevar_ab, - const bool useNoiseCCurve, bool autoch, bool denoiseMethodRgb); - void ShrinkAllL(wavelet_decomposition &WaveletCoeffs_L, float **buffer, int level, int dir, float *noisevarlum, float * madL, float * vari, int edge); - void ShrinkAllAB(wavelet_decomposition &WaveletCoeffs_L, wavelet_decomposition &WaveletCoeffs_ab, float **buffer, int level, int dir, - float *noisevarchrom, float noisevar_ab, const bool useNoiseCCurve, bool autoch, bool denoiseMethodRgb, float * madL, float * madaab = nullptr, bool madCalculated = false); - void ShrinkAll_info(float ** WavCoeffs_a, float ** WavCoeffs_b, int level, - int W_ab, int H_ab, int skip_ab, float **noisevarlum, float **noisevarchrom, float **noisevarhue, int width, int height, float noisevar_abr, float noisevar_abb, LabImage * noi, float &chaut, int &Nb, float &redaut, float &blueaut, float &maxredaut, float &maxblueaut, float &minredaut, float &minblueaut, bool autoch, int schoice, int lvl, float &chromina, float &sigma, float &lumema, float &sigma_L, float &redyel, float &skinc, float &nsknc, - float &maxchred, float &maxchblue, float &minchred, float &minchblue, int &nb, float &chau, float &chred, float &chblue, bool denoiseMethodRgb, bool multiThread); - void Noise_residualAB(wavelet_decomposition &WaveletCoeffs_ab, float &chresid, float &chmaxresid, bool denoiseMethodRgb); + bool WaveletDenoiseAll_BiShrinkL (wavelet_decomposition &WaveletCoeffs_L, float *noisevarlum, float madL[8][3]); + bool WaveletDenoiseAll_BiShrinkAB (wavelet_decomposition &WaveletCoeffs_L, wavelet_decomposition &WaveletCoeffs_ab, float *noisevarchrom, float madL[8][3], float noisevar_ab, + const bool useNoiseCCurve, bool autoch, bool denoiseMethodRgb); + void ShrinkAllL (wavelet_decomposition &WaveletCoeffs_L, float **buffer, int level, int dir, float *noisevarlum, float * madL, float * vari, int edge); + void ShrinkAllAB (wavelet_decomposition &WaveletCoeffs_L, wavelet_decomposition &WaveletCoeffs_ab, float **buffer, int level, int dir, + float *noisevarchrom, float noisevar_ab, const bool useNoiseCCurve, bool autoch, bool denoiseMethodRgb, float * madL, float * variC, int local, float * madaab = nullptr, bool madCalculated = false); + + void ShrinkAll_info (float ** WavCoeffs_a, float ** WavCoeffs_b, int level, + int W_ab, int H_ab, int skip_ab, float **noisevarlum, float **noisevarchrom, float **noisevarhue, int width, int height, float noisevar_abr, float noisevar_abb, LabImage * noi, float &chaut, int &Nb, float &redaut, float &blueaut, float &maxredaut, float &maxblueaut, float &minredaut, float &minblueaut, bool autoch, int schoice, int lvl, float &chromina, float &sigma, float &lumema, float &sigma_L, float &redyel, float &skinc, float &nsknc, + float &maxchred, float &maxchblue, float &minchred, float &minchblue, int &nb, float &chau, float &chred, float &chblue, bool denoiseMethodRgb, bool multiThread); + void Noise_residualAB (wavelet_decomposition &WaveletCoeffs_ab, float &chresid, float &chmaxresid, bool denoiseMethodRgb); void calcautodn_info (float &chaut, float &delta, int Nb, int levaut, float maxmax, float lumema, float chromina, int mode, int lissage, float redyel, float skinc, float nsknc); - float MadMax(float * DataList, int &max, int datalen); - float Mad(float * DataList, const int datalen); - float MadRgb(float * DataList, const int datalen); + float MadMax (float * DataList, int &max, int datalen); + float Mad (float * DataList, const int datalen); + float MadRgb (float * DataList, const int datalen); // pyramid wavelet void dirpyr_equalizer (float ** src, float ** dst, int srcwidth, int srcheight, float ** l_a, float ** l_b, float ** dest_a, float ** dest_b, const double * mult, const double dirpyrThreshold, const double skinprot, const bool gamutlab, float b_l, float t_l, float t_r, float b_r, int choice, int scale);//Emil's directional pyramid wavelet + void cbdl_local_temp (float ** src, float ** dst, float ** loctemp, int srcwidth, int srcheight, const float * mult, const double dirpyrThreshold, const double skinprot, const bool gamutlab, float b_l, float t_l, float t_r, float b_r, int choice, int scale); void dirpyr_equalizercam (CieImage* ncie, float ** src, float ** dst, int srcwidth, int srcheight, float ** h_p, float ** C_p, const double * mult, const double dirpyrThreshold, const double skinprot, bool execdir, const bool gamutlab, float b_l, float t_l, float t_r, float b_r, int choice, int scale);//Emil's directional pyramid wavelet void dirpyr_channel (float ** data_fine, float ** data_coarse, int width, int height, int level, int scale); void idirpyr_eq_channel (float ** data_coarse, float ** data_fine, float ** buffer, int width, int height, int level, float multi[5], const double dirpyrThreshold, float ** l_a_h, float ** l_b_c, const double skinprot, const bool gamutlab, float b_l, float t_l, float t_r, float b_r, int choice); + void idirpyr_eq_channel_loc (float ** data_coarse, float ** data_fine, float ** loctemp, float ** buffer, int width, int height, int level, float multi[5], const double dirpyrThreshold, float ** l_a_h, float ** l_b_c, const double skinprot, const bool gamutlab, float b_l, float t_l, float t_r, float b_r, int choice); void idirpyr_eq_channelcam (float ** data_coarse, float ** data_fine, float ** buffer, int width, int height, int level, float multi[5], const double dirpyrThreshold, float ** l_a_h, float ** l_b_c, const double skinprot, float b_l, float t_l, float t_r); void defringe (LabImage* lab); void defringecam (CieImage* ncie); @@ -340,11 +370,11 @@ public: void PF_correct_RT (LabImage * src, LabImage * dst, double radius, int thresh); void PF_correct_RTcam (CieImage * src, CieImage * dst, double radius, int thresh); - void Badpixelscam(CieImage * src, CieImage * dst, double radius, int thresh, int mode, float b_l, float t_l, float t_r, float b_r, float skinprot, float chrom, int hotbad); - void BadpixelsLab(LabImage * src, LabImage * dst, double radius, int thresh, int mode, float b_l, float t_l, float t_r, float b_r, float skinprot, float chrom); + void Badpixelscam (CieImage * src, CieImage * dst, double radius, int thresh, int mode, float b_l, float t_l, float t_r, float b_r, float skinprot, float chrom, int hotbad); + void BadpixelsLab (LabImage * src, LabImage * dst, double radius, int thresh, int mode, float b_l, float t_l, float t_r, float b_r, float skinprot, float chrom); Image8* lab2rgb (LabImage* lab, int cx, int cy, int cw, int ch, const procparams::ColorManagementParams &icm); - Image16* lab2rgb16 (LabImage* lab, int cx, int cy, int cw, int ch, const procparams::ColorManagementParams &icm, bool bw, GammaValues *ga=nullptr); + Image16* lab2rgb16 (LabImage* lab, int cx, int cy, int cw, int ch, const procparams::ColorManagementParams &icm, bool bw, GammaValues *ga = nullptr); // CieImage *ciec; bool transCoord (int W, int H, int x, int y, int w, int h, int& xv, int& yv, int& wv, int& hv, double ascaleDef = -1, const LCPMapper *pLCPMap = nullptr); @@ -352,8 +382,8 @@ public: static void getAutoExp (const LUTu & histogram, int histcompr, double defgain, double clip, double& expcomp, int& bright, int& contr, int& black, int& hlcompr, int& hlcomprthresh); static double getAutoDistor (const Glib::ustring& fname, int thumb_size); double getTransformAutoFill (int oW, int oH, const LCPMapper *pLCPMap = nullptr); - void rgb2lab(const Imagefloat &src, LabImage &dst, const Glib::ustring &workingSpace); - void lab2rgb(const LabImage &src, Imagefloat &dst, const Glib::ustring &workingSpace); + void rgb2lab (const Imagefloat &src, LabImage &dst, const Glib::ustring &workingSpace); + void lab2rgb (const LabImage &src, Imagefloat &dst, const Glib::ustring &workingSpace); }; } #endif diff --git a/rtengine/iplocallab.cc b/rtengine/iplocallab.cc new file mode 100644 index 000000000..049c5fdf4 --- /dev/null +++ b/rtengine/iplocallab.cc @@ -0,0 +1,5068 @@ +/* + * 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 . + * 2016 Jacques Desmis + * 2016 Ingo Weyrich + + */ +#include +#include +#include + +#include "rtengine.h" +#include "improcfun.h" +#include "curves.h" +#include "gauss.h" +#include "iccstore.h" +#include "iccmatrices.h" +#include "color.h" +#include "rt_math.h" +#ifdef _DEBUG +#include "mytime.h" +#endif + +#include "cplx_wavelet_dec.h" + +//#define BENCHMARK +//#include "StopWatch.h" + +#define cliploc( val, minv, maxv ) (( val = (val < minv ? minv : val ) ) > maxv ? maxv : val ) + +#define CLIPC(a) ((a)>-42000?((a)<42000?(a):42000):-42000) // limit a and b to 130 probably enough ? +#define CLIPL(x) LIM(x,0.f,40000.f) // limit L to about L=120 probably enough ? +#define CLIPLOC(x) LIM(x,0.f,32767.f) +namespace rtengine +{ +using namespace procparams; + +extern const Settings* settings; + +struct local_params { + float yc, xc; + float lx, ly; + float lxL, lyT; + float dxx, dyy; + int cir; + float thr; + int prox; + int chro, cont, sens, sensh, senscb, sensbn, senstm; + float ligh; + int shamo, shdamp, shiter, senssha; + double shrad; + double rad; + double stren; + int trans; + bool inv; + bool curvact; + bool invrad; + bool invret; + bool invshar; + bool actsp; + float str; + int qualmet; + float noiself; + float noiselc; + float noisecf; + float noisecc; + float mulloc[5]; + float threshol; + float strengt; + float gamm; + float esto; + float scalt; + float rewe; + bool colorena; + bool blurena; + bool tonemapena; + bool retiena; + bool sharpena; + bool cbdlena; + bool denoiena; + + + +}; + +static void calcLocalParams (int oW, int oH, const LocallabParams& locallab, struct local_params& lp) +{ + int w = oW; + int h = oH; + int circr = locallab.circrad; + float streng = ((float)locallab.stren) / 100.f; + float gam = ((float)locallab.gamma) / 100.f; + float est = ((float)locallab.estop) / 100.f; + float scal_tm = ((float)locallab.scaltm) / 10.f; + float rewe = ((float)locallab.rewei); + + float thre = locallab.thres / 100.f; + double local_x = locallab.locX / 2000.0; + double local_y = locallab.locY / 2000.0; + double local_xL = locallab.locXL / 2000.0; + double local_yT = locallab.locYT / 2000.0; + double local_center_x = locallab.centerX / 2000.0 + 0.5; + double local_center_y = locallab.centerY / 2000.0 + 0.5; +// double local_dxx = locallab.proxi / 8000.0;//for proxi = 2==> # 1 pixel +// double local_dyy = locallab.proxi / 8000.0; + float local_dxx = locallab.proxi; + double local_dyy = locallab.proxi; + + if (locallab.qualityMethod == "std") { + lp.qualmet = 0; + } else if (locallab.qualityMethod == "enh") { + lp.qualmet = 1; + } else if (locallab.qualityMethod == "enhden") { + lp.qualmet = 2; + } + + float local_noiself = locallab.noiselumf; + float local_noiselc = locallab.noiselumc; + float local_noisecf = locallab.noisechrof; + float local_noisecc = locallab.noisechroc; + float multi[5]; + + for (int y = 0; y < 5; y++) { + multi[y] = ((float) locallab.mult[y]) / 100.f; + } + + float thresho = ((float)locallab.threshold ) / 100.f; + int local_chroma = locallab.chroma; + int local_sensi = locallab.sensi; + int local_sensibn = locallab.sensibn; + int local_sensitm = locallab.sensitm; + int local_sensih = locallab.sensih; + int local_sensicb = locallab.sensicb; + int local_contrast = locallab.contrast; + float local_lightness = (float) locallab.lightness; + int local_transit = locallab.transit; + double radius = (double) locallab.radius; + double sharradius = ((double) locallab.sharradius) / 100. ; + int local_sensisha = locallab.sensisha; + int local_sharamount = locallab.sharamount; + int local_shardamping = locallab.shardamping; + int local_shariter = locallab.shariter; + bool inverse = locallab.invers; + bool curvacti = locallab.curvactiv; + bool acti = locallab.activlum; + + bool inverserad = locallab.inversrad; + bool inverseret = locallab.inversret; + bool inversesha = locallab.inverssha; + double strength = (double) locallab.strength; + float str = (float)locallab.str; + lp.cir = circr; + lp.actsp = acti; + lp.xc = w * local_center_x; + lp.yc = h * local_center_y; + lp.lx = w * local_x; + lp.ly = h * local_y; + lp.lxL = w * local_xL; + lp.lyT = h * local_yT; + lp.chro = local_chroma; + lp.sens = local_sensi; + lp.sensh = local_sensih; + lp.senscb = local_sensicb; + lp.cont = local_contrast; + lp.ligh = local_lightness; + + if (lp.ligh >= -2.f && lp.ligh <= 2.f) { + lp.ligh /= 5.f; + } + + lp.trans = local_transit; + lp.rad = radius; + lp.stren = strength; + lp.sensbn = local_sensibn; + lp.inv = inverse; + lp.curvact = curvacti; + lp.invrad = inverserad; + lp.invret = inverseret; + lp.invshar = inversesha; + lp.str = str; + lp.shrad = sharradius; + lp.senssha = local_sensisha; + lp.shamo = local_sharamount; + lp.shdamp = local_shardamping; + lp.shiter = local_shariter; + lp.dxx = local_dxx; + lp.dyy = h * local_dyy; + lp.thr = thre; + lp.noiself = local_noiself; + lp.noiselc = local_noiselc; + lp.noisecf = local_noisecf; + lp.noisecc = local_noisecc; + + + lp.strengt = streng; + lp.gamm = gam; + lp.esto = est; + lp.scalt = scal_tm; + lp.rewe = rewe; + lp.senstm = local_sensitm; + + for (int y = 0; y < 5; y++) { + lp.mulloc[y] = multi[y]; + } + + lp.threshol = thresho; + lp.colorena = locallab.expcolor; + lp.blurena = locallab.expblur; + lp.tonemapena = locallab.exptonemap; + lp.retiena = locallab.expreti; + lp.sharpena = locallab.expsharp; + lp.cbdlena = locallab.expcbdl; + lp.denoiena = locallab.expdenoi; + +} + +inline static float calcLocalFactor (const float lox, const float loy, const float lcx, const float dx, const float lcy, const float dy, const float ach) +{ +//elipse x2/a2 + y2/b2=1 +//transition elipsoidal +//x==>lox y==>loy +// a==> dx b==>dy + + float kelip = dx / dy; + float belip = sqrt ((SQR ((lox - lcx) / kelip) + SQR (loy - lcy))); //determine position ellipse ==> a and b + float aelip = belip * kelip; + float degrad = aelip / dx; + float ap = M_PI / (1.f - ach); + float bp = M_PI - ap; + return 0.5f * (1.f + xcosf (degrad * ap + bp)); //trigo cos transition + +} + + +static void calcTransition (const float lox, const float loy, const float ach, const local_params& lp, int &zone, float &localFactor) +{ + // returns the zone (0 = outside selection, 1 = transition zone between outside and inside selection, 2 = inside selection) + // and a factor to calculate the transition in case zone == 1 + + zone = 0; + + if (lox >= lp.xc && lox < (lp.xc + lp.lx) && loy >= lp.yc && loy < lp.yc + lp.ly) { + zone = ( (SQR (lox - lp.xc) / SQR (ach * lp.lx) + SQR (loy - lp.yc) / SQR (ach * lp.ly)) < 1.f) ? 2 : 0; + + if (!zone) { + zone = (((SQR (lox - lp.xc) / SQR (ach * lp.lx) + SQR (loy - lp.yc) / SQR (ach * lp.ly)) > 1.f) && ((SQR (lox - lp.xc) / SQR (lp.lx) + SQR (loy - lp.yc) / SQR (lp.ly)) < 1.f)) ? 1 : 0; + + if (zone) { + localFactor = calcLocalFactor (lox, loy, lp.xc, lp.lx, lp.yc, lp.ly, ach); + } + } + } else if (lox >= lp.xc && lox < lp.xc + lp.lx && loy < lp.yc && loy > lp.yc - lp.lyT) { + zone = (SQR (lox - lp.xc) / SQR (ach * lp.lx) + SQR (loy - lp.yc) / SQR (ach * lp.lyT)) < 1.f ? 2 : 0; + + if (!zone) { + zone = (((SQR (lox - lp.xc) / SQR (ach * lp.lx) + SQR (loy - lp.yc) / SQR (ach * lp.lyT)) > 1.f) && ((SQR (lox - lp.xc) / SQR (lp.lx) + SQR (loy - lp.yc) / SQR (lp.lyT)) < 1.f)) ? 1 : 0; + + if (zone) { + localFactor = calcLocalFactor (lox, loy, lp.xc, lp.lx, lp.yc, lp.lyT, ach); + } + } + } else if (lox < lp.xc && lox > lp.xc - lp.lxL && loy <= lp.yc && loy > lp.yc - lp.lyT) { + zone = (SQR (lox - lp.xc) / SQR (ach * lp.lxL) + SQR (loy - lp.yc) / SQR (ach * lp.lyT)) < 1.f ? 2 : 0; + + if (!zone) { + zone = (((SQR (lox - lp.xc) / SQR (ach * lp.lxL) + SQR (loy - lp.yc) / SQR (ach * lp.lyT)) > 1.f) && ((SQR (lox - lp.xc) / SQR (lp.lxL) + SQR (loy - lp.yc) / SQR (lp.lyT)) < 1.f)) ? 1 : 0; + + if (zone) { + localFactor = calcLocalFactor (lox, loy, lp.xc, lp.lxL, lp.yc, lp.lyT, ach); + } + } + } else if (lox < lp.xc && lox > lp.xc - lp.lxL && loy > lp.yc && loy < lp.yc + lp.ly) { + zone = (SQR (lox - lp.xc) / SQR (ach * lp.lxL) + SQR (loy - lp.yc) / SQR (ach * lp.ly)) < 1.f ? 2 : 0; + + if (!zone) { + zone = (((SQR (lox - lp.xc) / SQR (ach * lp.lxL) + SQR (loy - lp.yc) / SQR (ach * lp.ly)) > 1.f) && ((SQR (lox - lp.xc) / SQR (lp.lxL) + SQR (loy - lp.yc) / SQR (lp.ly)) < 1.f)) ? 1 : 0; + + if (zone) { + localFactor = calcLocalFactor (lox, loy, lp.xc, lp.lxL, lp.yc, lp.ly, ach); + } + } + } +} + +void ImProcFunctions::strcurv_data (std::string retistr, int *s_datc, int &siz) +{ + std::string delim[69] = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", + "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", + "&", "#", "{", "[", "]", "}", "$", "*", "?", ">", "!", ";", "<", "(", ")", "+", "-" + }; + + int s_size; + std::size_t posend = retistr.find ("@"); + + std::string strend = retistr.substr (posend - 1, 1); + // printf("stren=%s posz=%i\n", strend.c_str(), posz); + int longe; + + for (int sl = 0; sl < 69; sl++) { + if (delim[sl] == strend) { + longe = sl + 1; + } + } + + s_size = longe; + + // printf("sp=%i stren=%s reti=%s long=%i\n", sp, strend.c_str(), retistr[sp].c_str(), longe); + + int s_cur[s_size + 1]; + int s_datcu[s_size + 1]; + + std::size_t pose[s_size + 1]; + std::size_t valstr[s_size + 1]; + pose[0] = -1; + + for (int z = 1; z < s_size + 1; z++) { + pose[z] = retistr.find (delim[z - 1]); + } + + + for (int z = 1; z < s_size + 1; z++) { + std::string sval = retistr.substr (pose[z - 1] + 1, (pose[z] - pose[z - 1])); + s_datc[z - 1] = s_datcu[z - 1] = std::stoi (sval.c_str()); + + } + + /* + //here to verify process is good + std::string cur_str = ""; + + for(int j = 0; j < s_size; j++) { + cur_str = cur_str + std::to_string(s_datcu[j]) + delim[j]; + } + printf("calc str=%s\n", cur_str.c_str()); + */ + siz = longe; + +} + + + +void ImProcFunctions::addGaNoise (LabImage *lab, LabImage *dst, const float mean, const float variance, const int sk) +{ +// BENCHFUN +//Box-Muller method. +// add luma noise to image + + srand (1); + + const float variaFactor = SQR (variance) / sk; + const float randFactor = 1.f / RAND_MAX; +#ifdef _OPENMP + #pragma omp parallel +#endif + { + float z0, z1; + bool generate = false; +#ifdef _OPENMP + #pragma omp for schedule(static) // static scheduling is important to avoid artefacts +#endif + + for (int y = 0; y < lab->H; y++) { + for (int x = 0; x < lab->W; x++) { + generate = !generate; + float kvar = 1.f; + + if (lab->L[y][x] < 12000.f) { + constexpr float ah = -0.5f / 12000.f; + constexpr float bh = 1.5f; + kvar = ah * lab->L[y][x] + bh; //increase effect for low lights < 12000.f + } else if (lab->L[y][x] > 20000.f) { + constexpr float ah = -0.5f / 12768.f; + constexpr float bh = 1.f - 20000.f * ah; + kvar = ah * lab->L[y][x] + bh; //decrease effect for high lights > 20000.f + kvar = kvar < 0.5f ? 0.5f : kvar; + } + + float varia = SQR (kvar) * variaFactor; + + if (!generate) { + dst->L[y][x] = LIM (lab->L[y][x] + mean + varia * z1, 0.f, 32768.f); + continue; + } + + int u1 = 0; + int u2; + + while (u1 == 0) { + u1 = rand(); + u2 = rand(); + } + + float u1f = u1 * randFactor; + float u2f = u2 * randFactor; + + float2 sincosval = xsincosf (2.f * M_PI * u2f); + float factor = sqrtf (-2.f * xlogf (u1f)); + z0 = factor * sincosval.y; + z1 = factor * sincosval.x; + + dst->L[y][x] = LIM (lab->L[y][x] + mean + varia * z0, 0.f, 32768.f); + + } + } + } +} + +void ImProcFunctions::DeNoise_Local (int call, const struct local_params& lp, LabImage* original, LabImage* transformed, const LabImage* const tmp1, int cx, int cy) +{ + // local denoise + // BENCHFUN + const float ach = (float)lp.trans / 100.f; + + #pragma omp parallel for schedule(dynamic,16) if (multiThread) + + for (int y = 0; y < transformed->H; y++) { + int loy = cy + y; + + for (int x = 0; x < transformed->W; x++) { + int lox = cx + x; + + int zone; + float localFactor; + calcTransition (lox, loy, ach, lp, zone, localFactor); + int begx = int (lp.xc - lp.lxL); + int begy = int (lp.yc - lp.lyT); + + switch (zone) { + case 0: { // outside selection and outside transition zone => no effect, keep original values + transformed->L[y][x] = original->L[y][x]; + transformed->a[y][x] = original->a[y][x]; + transformed->b[y][x] = original->b[y][x]; + break; + } + + case 1: { // inside transition zone + float factorx = localFactor; + float difL, difa, difb; + + if (call == 2) { //simpleprocess + if (lox >= (lp.xc - lp.lxL) && lox < (lp.xc + lp.lx) && loy >= (lp.yc - lp.lyT) && loy < (lp.yc + lp.ly)) { + difL = tmp1->L[loy - begy - 1][lox - begx - 1] - original->L[y][x]; + difa = tmp1->a[loy - begy - 1][lox - begx - 1] - original->a[y][x]; + difb = tmp1->b[loy - begy - 1][lox - begx - 1] - original->b[y][x]; + } + } else if (call == 1) { //dcrop + difL = tmp1->L[y][x] - original->L[y][x]; + difa = tmp1->a[y][x] - original->a[y][x]; + difb = tmp1->b[y][x] - original->b[y][x]; + + } + + difL *= factorx; + difa *= factorx; + difb *= factorx; + transformed->L[y][x] = original->L[y][x] + difL; + transformed->a[y][x] = original->a[y][x] + difa; + transformed->b[y][x] = original->b[y][x] + difb; + break; + } + + case 2: { // inside selection => full effect, no transition + float difL, difa, difb; + + if (call == 2) { //simpleprocess + + if (lox >= (lp.xc - lp.lxL) && lox < (lp.xc + lp.lx) && loy >= (lp.yc - lp.lyT) && loy < (lp.yc + lp.ly)) { + difL = tmp1->L[loy - begy - 1][lox - begx - 1] - original->L[y][x]; + difa = tmp1->a[loy - begy - 1][lox - begx - 1] - original->a[y][x]; + difb = tmp1->b[loy - begy - 1][lox - begx - 1] - original->b[y][x]; + } + } else if (call == 1) { //dcrop + difL = tmp1->L[y][x] - original->L[y][x]; + difa = tmp1->a[y][x] - original->a[y][x]; + difb = tmp1->b[y][x] - original->b[y][x]; + + } + + transformed->L[y][x] = original->L[y][x] + difL; + transformed->a[y][x] = original->a[y][x] + difa; + transformed->b[y][x] = original->b[y][x] + difb; + } + } + } + } + + + +} + + +void ImProcFunctions::cbdl_Local (int call, int sp, float **loctemp, const float hueplus, const float huemoins, const float hueref, const float dhue, const float chromaref, const float lumaref, const local_params & lp, float **deltE, LabImage * original, LabImage * transformed, int cx, int cy) +{ +//local CBDL + // BENCHFUN + const float localtype = lumaref; // always spot area + const float ach = (float)lp.trans / 100.f; + float reducac; + + //constant and variable to prepare shape detection + if (lp.senscb < 30.f) { + reducac = 0.2f * (lp.senscb / 100.f); + } else { + float areduc = 0.6285714f; //0.44f/0.7f; + float breduc = 0.5f - areduc; + reducac = areduc * (lp.senscb / 100.f) + breduc; + } + + + constexpr float delhu = 0.1f; //between 0.05 and 0.2 + + const float apl = (-1.f) / delhu; + const float bpl = - apl * hueplus; + const float amo = 1.f / delhu; + const float bmo = - amo * huemoins; + + + const float pb = 4.f; + const float pa = (1.f - pb) / 40.f; + + const float ahu = 1.f / (2.8f * lp.senscb - 280.f); + const float bhu = 1.f - ahu * 2.8f * lp.senscb; + +#ifdef _OPENMP + #pragma omp parallel if (multiThread) +#endif + { +#ifdef __SSE2__ + float atan2Buffer[transformed->W] ALIGNED16; + float sqrtBuffer[transformed->W] ALIGNED16; + vfloat c327d68v = F2V (327.68f); +#endif + +#ifdef _OPENMP + #pragma omp for schedule(dynamic,16) +#endif + + for (int y = 0; y < transformed->H; y++) { +#ifdef __SSE2__ + int i = 0; + + for (; i < transformed->W - 3; i += 4) { + vfloat av = LVFU (original->a[y][i]); + vfloat bv = LVFU (original->b[y][i]); + STVF (atan2Buffer[i], xatan2f (bv, av)); + STVF (sqrtBuffer[i], _mm_sqrt_ps (SQRV (bv) + SQRV (av)) / c327d68v); + } + + for (; i < transformed->W; i++) { + atan2Buffer[i] = xatan2f (original->b[y][i], original->a[y][i]); + sqrtBuffer[i] = sqrt (SQR (original->b[y][i]) + SQR (original->a[y][i])) / 327.68f; + } + +#endif + + int loy = cy + y; + + for (int x = 0; x < transformed->W; x++) { + int lox = cx + x; +#ifdef __SSE2__ + float rhue = atan2Buffer[x]; + float rchro = sqrtBuffer[x]; +#else + float rhue = xatan2f (original->b[y][x], original->a[y][x]); + float rchro = sqrt (SQR (original->b[y][x]) + SQR (original->a[y][x])) / 327.68f; +#endif + int zone; + float localFactor = 1.f; + calcTransition (lox, loy, ach, lp, zone, localFactor); + //prepare shape detection + float khu = 0.f; + float kch = 1.f; + bool kzon = false; + float fach = 1.f; + float deltachro = fabs (rchro - chromaref); + float deltahue = fabs (rhue - hueref); + + if (deltahue > M_PI) { + deltahue = - (deltahue - 2.f * M_PI); + } + + float deltaE = 20.f * deltahue + deltachro; //pseudo deltaE between 0 and 280 + + //kch to modulate action with chroma + if (deltachro < 160.f * SQR (lp.senscb / 100.f)) { + kch = 1.f; + } else { + float ck = 160.f * SQR (lp.senscb / 100.f); + float ak = 1.f / (ck - 160.f); + float bk = -160.f * ak; + kch = ak * deltachro + bk; + } + + if (lp.senscb < 40.f ) { + kch = pow (kch, pa * lp.senscb + pb); //increase under 40 + } + + + // algo with detection of hue ==> artifacts for noisy images ==> denoise before + if (lp.senscb < 20.f) { //to try... + //hue detection + if ((hueref + dhue) < M_PI && rhue < hueplus && rhue > huemoins) { //transition are good + if (rhue >= hueplus - delhu ) { + khu = apl * rhue + bpl; + } else if (rhue < huemoins + delhu) { + khu = amo * rhue + bmo; + } else { + khu = 1.f; + } + + + kzon = true; + } else if ((hueref + dhue) >= M_PI && (rhue > huemoins || rhue < hueplus )) { + if (rhue >= hueplus - delhu && rhue < hueplus) { + khu = apl * rhue + bpl; + } else if (rhue >= huemoins && rhue < huemoins + delhu) { + khu = amo * rhue + bmo; + } else { + khu = 1.f; + } + + kzon = true; + } + + if ((hueref - dhue) > -M_PI && rhue < hueplus && rhue > huemoins ) { + if (rhue >= hueplus - delhu && rhue < hueplus) { + khu = apl * rhue + bpl; + } else if (rhue >= huemoins && rhue < huemoins + delhu) { + khu = amo * rhue + bmo; + } else { + khu = 1.f; + } + + kzon = true; + } else if ((hueref - dhue) <= -M_PI && (rhue > huemoins || rhue < hueplus )) { + if (rhue >= hueplus - delhu && rhue < hueplus) { + khu = apl * rhue + bpl; + } else if (rhue >= huemoins && rhue < huemoins + delhu) { + khu = amo * rhue + bmo; + } else { + khu = 1.f; + } + + kzon = true; + } + + if (deltaE < 2.8f * lp.senscb) { + fach = khu; + } else { + fach = khu * (ahu * deltaE + bhu); + } + + + float kcr = 10.f; + + if (rchro < kcr) { + fach *= (1.f / (kcr * kcr)) * rchro * rchro; + } + + if (lp.qualmet == 1) { + if (deltE[y][x] > lp.thr) { + fach = 1.f; + } + } else { + fach = 1.f; + } + + //fach = khu ; + + } else { + /* + float kcr = 8.f; + if(lp.senssha > 30.f){ + if (rchro < kcr) { + fach *= (1.f / (kcr)) * rchro; + + } + } + */ + } + + int begx = int (lp.xc - lp.lxL); + int begy = int (lp.yc - lp.lyT); + + switch (zone) { + case 0: { // outside selection and outside transition zone => no effect, keep original values + transformed->L[y][x] = original->L[y][x]; + break; + } + + case 1: { // inside transition zone + float factorx = localFactor; + float difL; + + if (call == 2) { + if (lox >= (lp.xc - lp.lxL) && lox < (lp.xc + lp.lx) && loy >= (lp.yc - lp.lyT) && loy < (lp.yc + lp.ly)) { + difL = loctemp[loy - begy - 1][lox - begx - 1] - original->L[y][x]; + } + } else if (call == 1) { + difL = loctemp[y][x] - original->L[y][x]; + + } + + //float difL = loctemp[y][x] - original->L[y][x]; + difL *= factorx; + transformed->L[y][x] = original->L[y][x] + difL * kch * fach; + + break; + } + + case 2: { // inside selection => full effect, no transition + // float difL = loctemp[y][x] - original->L[y][x]; + float difL; + + if (call == 2) { + + if (lox >= (lp.xc - lp.lxL) && lox < (lp.xc + lp.lx) && loy >= (lp.yc - lp.lyT) && loy < (lp.yc + lp.ly)) { + // bufsh[loy - begy - 1][lox - begx - 1] + difL = loctemp[loy - begy - 1][lox - begx - 1] - original->L[y][x]; + } + } else if (call == 1) { + difL = loctemp[y][x] - original->L[y][x]; + } + + transformed->L[y][x] = original->L[y][x] + difL * kch * fach; + } + } + } + } + } +} + + +void ImProcFunctions::TM_Local (int call, int sp, LabImage * tmp1, const float hueplus, const float huemoins, const float hueref, const float dhue, const float chromaref, const float lumaref, const local_params & lp, float **deltE, LabImage * original, LabImage * transformed, int cx, int cy) +{ +//local TM + // BENCHFUN + const float localtype = lumaref; // always spot area + const float ach = (float)lp.trans / 100.f; + float reducac; + + //constant and variable to prepare shape detection + if (lp.senstm < 30.f) { + reducac = 0.2f * (lp.senstm / 100.f); + } else { + float areduc = 0.6285714f; //0.44f/0.7f; + float breduc = 0.5f - areduc; + reducac = areduc * (lp.senstm / 100.f) + breduc; + } + + + constexpr float delhu = 0.1f; //between 0.05 and 0.2 + + const float apl = (-1.f) / delhu; + const float bpl = - apl * hueplus; + const float amo = 1.f / delhu; + const float bmo = - amo * huemoins; + + + const float pb = 4.f; + const float pa = (1.f - pb) / 40.f; + + const float ahu = 1.f / (2.8f * lp.senstm - 280.f); + const float bhu = 1.f - ahu * 2.8f * lp.senstm; + +#ifdef _OPENMP + #pragma omp parallel if (multiThread) +#endif + { +#ifdef __SSE2__ + float atan2Buffer[transformed->W] ALIGNED16; + float sqrtBuffer[transformed->W] ALIGNED16; + vfloat c327d68v = F2V (327.68f); +#endif + +#ifdef _OPENMP + #pragma omp for schedule(dynamic,16) +#endif + + for (int y = 0; y < transformed->H; y++) { +#ifdef __SSE2__ + int i = 0; + + for (; i < transformed->W - 3; i += 4) { + vfloat av = LVFU (original->a[y][i]); + vfloat bv = LVFU (original->b[y][i]); + STVF (atan2Buffer[i], xatan2f (bv, av)); + STVF (sqrtBuffer[i], _mm_sqrt_ps (SQRV (bv) + SQRV (av)) / c327d68v); + } + + for (; i < transformed->W; i++) { + atan2Buffer[i] = xatan2f (original->b[y][i], original->a[y][i]); + sqrtBuffer[i] = sqrt (SQR (original->b[y][i]) + SQR (original->a[y][i])) / 327.68f; + } + +#endif + + int loy = cy + y; + + for (int x = 0; x < transformed->W; x++) { + int lox = cx + x; +#ifdef __SSE2__ + float rhue = atan2Buffer[x]; + float rchro = sqrtBuffer[x]; +#else + float rhue = xatan2f (original->b[y][x], original->a[y][x]); + float rchro = sqrt (SQR (original->b[y][x]) + SQR (original->a[y][x])) / 327.68f; +#endif + int zone; + float localFactor = 1.f; + calcTransition (lox, loy, ach, lp, zone, localFactor); + //prepare shape detection + float khu = 0.f; + float kch = 1.f; + bool kzon = false; + float fach = 1.f; + float deltachro = fabs (rchro - chromaref); + float deltahue = fabs (rhue - hueref); + + if (deltahue > M_PI) { + deltahue = - (deltahue - 2.f * M_PI); + } + + float deltaE = 20.f * deltahue + deltachro; //pseudo deltaE between 0 and 280 + + //kch to modulate action with chroma + if (deltachro < 160.f * SQR (lp.senstm / 100.f)) { + kch = 1.f; + } else { + float ck = 160.f * SQR (lp.senstm / 100.f); + float ak = 1.f / (ck - 160.f); + float bk = -160.f * ak; + kch = ak * deltachro + bk; + } + + if (lp.senstm < 40.f ) { + kch = pow (kch, pa * lp.senstm + pb); //increase under 40 + } + + + // algo with detection of hue ==> artifacts for noisy images ==> denoise before + if (lp.senstm < 20.f) { //to try... + //hue detection + if ((hueref + dhue) < M_PI && rhue < hueplus && rhue > huemoins) { //transition are good + if (rhue >= hueplus - delhu ) { + khu = apl * rhue + bpl; + } else if (rhue < huemoins + delhu) { + khu = amo * rhue + bmo; + } else { + khu = 1.f; + } + + + kzon = true; + } else if ((hueref + dhue) >= M_PI && (rhue > huemoins || rhue < hueplus )) { + if (rhue >= hueplus - delhu && rhue < hueplus) { + khu = apl * rhue + bpl; + } else if (rhue >= huemoins && rhue < huemoins + delhu) { + khu = amo * rhue + bmo; + } else { + khu = 1.f; + } + + kzon = true; + } + + if ((hueref - dhue) > -M_PI && rhue < hueplus && rhue > huemoins ) { + if (rhue >= hueplus - delhu && rhue < hueplus) { + khu = apl * rhue + bpl; + } else if (rhue >= huemoins && rhue < huemoins + delhu) { + khu = amo * rhue + bmo; + } else { + khu = 1.f; + } + + kzon = true; + } else if ((hueref - dhue) <= -M_PI && (rhue > huemoins || rhue < hueplus )) { + if (rhue >= hueplus - delhu && rhue < hueplus) { + khu = apl * rhue + bpl; + } else if (rhue >= huemoins && rhue < huemoins + delhu) { + khu = amo * rhue + bmo; + } else { + khu = 1.f; + } + + kzon = true; + } + + if (deltaE < 2.8f * lp.senstm) { + fach = khu; + } else { + fach = khu * (ahu * deltaE + bhu); + } + + + float kcr = 10.f; + + if (rchro < kcr) { + fach *= (1.f / (kcr * kcr)) * rchro * rchro; + } + + if (lp.qualmet == 1) { + if (deltE[y][x] > lp.thr) { + fach = 1.f; + } + } else { + fach = 1.f; + } + + //fach = khu ; + + } else { + } + + int begx = int (lp.xc - lp.lxL); + int begy = int (lp.yc - lp.lyT); + + switch (zone) { + case 0: { // outside selection and outside transition zone => no effect, keep original values + transformed->L[y][x] = original->L[y][x]; + + if (!lp.actsp) { + transformed->a[y][x] = original->a[y][x]; + transformed->b[y][x] = original->b[y][x]; + } + + break; + } + + case 1: { // inside transition zone + float factorx = localFactor; + float difL, difa, difb; + + if (call == 2) { + if (lox >= (lp.xc - lp.lxL) && lox < (lp.xc + lp.lx) && loy >= (lp.yc - lp.lyT) && loy < (lp.yc + lp.ly)) { + difL = tmp1->L[loy - begy - 1][lox - begx - 1] - original->L[y][x]; + difa = tmp1->a[loy - begy - 1][lox - begx - 1] - original->a[y][x]; + difb = tmp1->b[loy - begy - 1][lox - begx - 1] - original->b[y][x]; + + } + } else { + difL = tmp1->L[y][x] - original->L[y][x]; + difa = tmp1->a[y][x] - original->a[y][x]; + difb = tmp1->b[y][x] - original->b[y][x]; + + + } + + difL *= factorx; + difa *= factorx; + difb *= factorx; + + transformed->L[y][x] = original->L[y][x] + difL * kch * fach; + + + transformed->a[y][x] = original->a[y][x] + difa * kch * fach;//same as Luma + transformed->b[y][x] = original->b[y][x] + difb * kch * fach;//same as Luma + + break; + } + + case 2: { // inside selection => full effect, no transition + float difL, difa, difb; + + if (call == 2) { + + if (lox >= (lp.xc - lp.lxL) && lox < (lp.xc + lp.lx) && loy >= (lp.yc - lp.lyT) && loy < (lp.yc + lp.ly)) { + // bufsh[loy - begy - 1][lox - begx - 1] + difL = tmp1->L[loy - begy - 1][lox - begx - 1] - original->L[y][x]; + difa = tmp1->a[loy - begy - 1][lox - begx - 1] - original->a[y][x]; + difb = tmp1->b[loy - begy - 1][lox - begx - 1] - original->b[y][x]; + + } + } else { + difL = tmp1->L[y][x] - original->L[y][x]; + difa = tmp1->a[y][x] - original->a[y][x]; + difb = tmp1->b[y][x] - original->b[y][x]; + + } + + transformed->L[y][x] = original->L[y][x] + difL * kch * fach; + + + transformed->a[y][x] = original->a[y][x] + difa * kch * fach;//same as Luma + transformed->b[y][x] = original->b[y][x] + difb * kch * fach;//same as Luma + } + } + } + } + } +} + + + + +void ImProcFunctions::BlurNoise_Local (int call, int sp, LabImage * tmp1, const float hueplus, const float huemoins, const float hueref, const float dhue, const float chromaref, const float lumaref, const local_params & lp, float **deltE, LabImage * original, LabImage * transformed, int cx, int cy) +{ +//local BLUR + // BENCHFUN + const float localtype = lumaref; // always spot area + const float ach = (float)lp.trans / 100.f; + float reducac; + + //constant and variable to prepare shape detection + if (lp.sensbn < 30.f) { + reducac = 0.2f * (lp.sensbn / 100.f); + } else { + float areduc = 0.6285714f; //0.44f/0.7f; + float breduc = 0.5f - areduc; + reducac = areduc * (lp.sensbn / 100.f) + breduc; + } + + + constexpr float delhu = 0.1f; //between 0.05 and 0.2 + + const float apl = (-1.f) / delhu; + const float bpl = - apl * hueplus; + const float amo = 1.f / delhu; + const float bmo = - amo * huemoins; + + + const float pb = 4.f; + const float pa = (1.f - pb) / 40.f; + + const float ahu = 1.f / (2.8f * lp.sensbn - 280.f); + const float bhu = 1.f - ahu * 2.8f * lp.sensbn; + +#ifdef _OPENMP + #pragma omp parallel if (multiThread) +#endif + { +#ifdef __SSE2__ + float atan2Buffer[transformed->W] ALIGNED16; + float sqrtBuffer[transformed->W] ALIGNED16; + vfloat c327d68v = F2V (327.68f); +#endif + +#ifdef _OPENMP + #pragma omp for schedule(dynamic,16) +#endif + + for (int y = 0; y < transformed->H; y++) { +#ifdef __SSE2__ + int i = 0; + + for (; i < transformed->W - 3; i += 4) { + vfloat av = LVFU (original->a[y][i]); + vfloat bv = LVFU (original->b[y][i]); + STVF (atan2Buffer[i], xatan2f (bv, av)); + STVF (sqrtBuffer[i], _mm_sqrt_ps (SQRV (bv) + SQRV (av)) / c327d68v); + } + + for (; i < transformed->W; i++) { + atan2Buffer[i] = xatan2f (original->b[y][i], original->a[y][i]); + sqrtBuffer[i] = sqrt (SQR (original->b[y][i]) + SQR (original->a[y][i])) / 327.68f; + } + +#endif + + int loy = cy + y; + + for (int x = 0; x < transformed->W; x++) { + int lox = cx + x; +#ifdef __SSE2__ + float rhue = atan2Buffer[x]; + float rchro = sqrtBuffer[x]; +#else + float rhue = xatan2f (original->b[y][x], original->a[y][x]); + float rchro = sqrt (SQR (original->b[y][x]) + SQR (original->a[y][x])) / 327.68f; +#endif + int zone; + float localFactor = 1.f; + calcTransition (lox, loy, ach, lp, zone, localFactor); + //prepare shape detection + float khu = 0.f; + float kch = 1.f; + bool kzon = false; + float fach = 1.f; + float deltachro = fabs (rchro - chromaref); + float deltahue = fabs (rhue - hueref); + + if (deltahue > M_PI) { + deltahue = - (deltahue - 2.f * M_PI); + } + + float deltaE = 20.f * deltahue + deltachro; //pseudo deltaE between 0 and 280 + + //kch to modulate action with chroma + if (deltachro < 160.f * SQR (lp.sensbn / 100.f)) { + kch = 1.f; + } else { + float ck = 160.f * SQR (lp.sensbn / 100.f); + float ak = 1.f / (ck - 160.f); + float bk = -160.f * ak; + kch = ak * deltachro + bk; + } + + if (lp.sensbn < 40.f ) { + kch = pow (kch, pa * lp.sensbn + pb); //increase under 40 + } + + + // algo with detection of hue ==> artifacts for noisy images ==> denoise before + if (lp.sensbn < 20.f) { //to try... + //hue detection + if ((hueref + dhue) < M_PI && rhue < hueplus && rhue > huemoins) { //transition are good + if (rhue >= hueplus - delhu ) { + khu = apl * rhue + bpl; + } else if (rhue < huemoins + delhu) { + khu = amo * rhue + bmo; + } else { + khu = 1.f; + } + + + kzon = true; + } else if ((hueref + dhue) >= M_PI && (rhue > huemoins || rhue < hueplus )) { + if (rhue >= hueplus - delhu && rhue < hueplus) { + khu = apl * rhue + bpl; + } else if (rhue >= huemoins && rhue < huemoins + delhu) { + khu = amo * rhue + bmo; + } else { + khu = 1.f; + } + + kzon = true; + } + + if ((hueref - dhue) > -M_PI && rhue < hueplus && rhue > huemoins ) { + if (rhue >= hueplus - delhu && rhue < hueplus) { + khu = apl * rhue + bpl; + } else if (rhue >= huemoins && rhue < huemoins + delhu) { + khu = amo * rhue + bmo; + } else { + khu = 1.f; + } + + kzon = true; + } else if ((hueref - dhue) <= -M_PI && (rhue > huemoins || rhue < hueplus )) { + if (rhue >= hueplus - delhu && rhue < hueplus) { + khu = apl * rhue + bpl; + } else if (rhue >= huemoins && rhue < huemoins + delhu) { + khu = amo * rhue + bmo; + } else { + khu = 1.f; + } + + kzon = true; + } + + if (deltaE < 2.8f * lp.sensbn) { + fach = khu; + } else { + fach = khu * (ahu * deltaE + bhu); + } + + + float kcr = 10.f; + + if (rchro < kcr) { + fach *= (1.f / (kcr * kcr)) * rchro * rchro; + } + + if (lp.qualmet == 1) { + if (deltE[y][x] > lp.thr) { + fach = 1.f; + } + } else { + fach = 1.f; + } + + //fach = khu ; + + } else { + } + + int begx = int (lp.xc - lp.lxL); + int begy = int (lp.yc - lp.lyT); + + switch (zone) { + case 0: { // outside selection and outside transition zone => no effect, keep original values + transformed->L[y][x] = original->L[y][x]; + + if (!lp.actsp) { + transformed->a[y][x] = original->a[y][x]; + transformed->b[y][x] = original->b[y][x]; + } + + break; + } + + case 1: { // inside transition zone + float factorx = localFactor; + float difL, difa, difb; + + if (call == 2) { + if (lox >= (lp.xc - lp.lxL) && lox < (lp.xc + lp.lx) && loy >= (lp.yc - lp.lyT) && loy < (lp.yc + lp.ly)) { + difL = tmp1->L[loy - begy - 1][lox - begx - 1] - original->L[y][x]; + difa = tmp1->a[loy - begy - 1][lox - begx - 1] - original->a[y][x]; + difb = tmp1->b[loy - begy - 1][lox - begx - 1] - original->b[y][x]; + + } + } else { + difL = tmp1->L[y][x] - original->L[y][x]; + difa = tmp1->a[y][x] - original->a[y][x]; + difb = tmp1->b[y][x] - original->b[y][x]; + + + } + + difL *= factorx; + difa *= factorx; + difb *= factorx; + + transformed->L[y][x] = original->L[y][x] + difL * kch * fach; + + if (!lp.actsp) { + + transformed->a[y][x] = original->a[y][x] + difa * kch * fach;//same as Luma + transformed->b[y][x] = original->b[y][x] + difb * kch * fach;//same as Luma + } + + break; + } + + case 2: { // inside selection => full effect, no transition + float difL, difa, difb; + + if (call == 2) { + + if (lox >= (lp.xc - lp.lxL) && lox < (lp.xc + lp.lx) && loy >= (lp.yc - lp.lyT) && loy < (lp.yc + lp.ly)) { + // bufsh[loy - begy - 1][lox - begx - 1] + difL = tmp1->L[loy - begy - 1][lox - begx - 1] - original->L[y][x]; + difa = tmp1->a[loy - begy - 1][lox - begx - 1] - original->a[y][x]; + difb = tmp1->b[loy - begy - 1][lox - begx - 1] - original->b[y][x]; + + } + } else { + difL = tmp1->L[y][x] - original->L[y][x]; + difa = tmp1->a[y][x] - original->a[y][x]; + difb = tmp1->b[y][x] - original->b[y][x]; + + } + + transformed->L[y][x] = original->L[y][x] + difL * kch * fach; + + if (!lp.actsp) { + + transformed->a[y][x] = original->a[y][x] + difa * kch * fach;//same as Luma + transformed->b[y][x] = original->b[y][x] + difb * kch * fach;//same as Luma + } + } + } + } + } + } +} + +void ImProcFunctions::InverseReti_Local (const struct local_params& lp, LabImage* original, LabImage* transformed, const LabImage* const tmp1, int cx, int cy, int chro) +{ + // BENCHFUN +//inverse local retinex + float ach = (float)lp.trans / 100.f; + + #pragma omp parallel for schedule(dynamic,16) if (multiThread) + + for (int y = 0; y < transformed->H; y++) { + int loy = cy + y; + + for (int x = 0; x < transformed->W; x++) { + int lox = cx + x; + + int zone; + float localFactor; + calcTransition (lox, loy, ach, lp, zone, localFactor); + + switch (zone) { + case 0: { // outside selection and outside transition zone => full effect, no transition + if (chro == 0) { + transformed->L[y][x] = tmp1->L[y][x]; + } + + if (chro == 1) { + + transformed->a[y][x] = tmp1->a[y][x]; + transformed->b[y][x] = tmp1->b[y][x]; + } + + break; + } + + case 1: { // inside transition zone + float factorx = 1.f - localFactor; + + if (chro == 0) { + float difL = tmp1->L[y][x] - original->L[y][x]; + difL *= factorx; + transformed->L[y][x] = original->L[y][x] + difL; + } + + if (chro == 1) { + float difa = tmp1->a[y][x] - original->a[y][x]; + float difb = tmp1->b[y][x] - original->b[y][x]; + + difa *= factorx; + difb *= factorx; + + transformed->a[y][x] = original->a[y][x] + difa; + transformed->b[y][x] = original->b[y][x] + difb; + } + + break; + } + + case 2: { // inside selection => no effect, keep original values + if (chro == 0) { + transformed->L[y][x] = original->L[y][x]; + } + + if (chro == 1) { + transformed->a[y][x] = original->a[y][x]; + transformed->b[y][x] = original->b[y][x]; + } + } + } + } + } +} + + + +void ImProcFunctions::Reti_Local (int call, const float hueplus, const float huemoins, const float hueref, const float dhue, const float chromaref, const float lumaref, const struct local_params& lp, float **deltE, LabImage* original, LabImage* transformed, const LabImage* const tmp1, int cx, int cy, int chro) +{ + +//local retinex + //BENCHFUN + { + const float ach = (float)lp.trans / 100.f; + + //chroma + constexpr float amplchsens = 2.5f; + constexpr float achsens = (amplchsens - 1.f) / (100.f - 20.f); //20. default locallab.sensih + constexpr float bchsens = 1.f - 20.f * achsens; + const float multchro = lp.sensh * achsens + bchsens; + + //luma + constexpr float ampllumsens = 2.f; + constexpr float alumsens = (ampllumsens - 1.f) / (100.f - 20.f); //20. default locallab.sensih + constexpr float blumsens = 1.f - 20.f * alumsens; + const float multlum = lp.sensh * alumsens + blumsens; + + //skin + constexpr float amplchsensskin = 1.6f; + constexpr float achsensskin = (amplchsensskin - 1.f) / (100.f - 20.f); //20. default locallab.sensih + constexpr float bchsensskin = 1.f - 20.f * achsensskin; + const float multchroskin = lp.sensh * achsensskin + bchsensskin; + + //transition = difficult to avoid artifact with scope on flat area (sky...) + float strn = lp.str / 1.f; // we can chnage 1.f by 2 or...to chnage effect + + constexpr float delhu = 0.1f; //between 0.05 and 0.2 + const float aplus = (1.f - strn) / delhu; + const float bplus = 1.f - aplus * hueplus; + const float amoins = (strn - 1.f) / delhu; + const float bmoins = 1.f - amoins * huemoins; + + const float apl = (-1.f) / delhu; + const float bpl = - apl * hueplus; + const float amo = 1.f / delhu; + const float bmo = - amo * huemoins; + + + const float pb = 4.f; + const float pa = (1.f - pb) / 40.f; + + const float ahu = 1.f / (2.8f * lp.sensh - 280.f); + const float bhu = 1.f - ahu * 2.8f * lp.sensh; + + const float alum = 1.f / (lp.sensh - 100.f); + const float blum = 1.f - alum * lp.sensh; + + +#ifdef _OPENMP + #pragma omp parallel if (multiThread) +#endif + { +#ifdef __SSE2__ + float atan2Buffer[transformed->W] ALIGNED16; + float sqrtBuffer[transformed->W] ALIGNED16; + vfloat c327d68v = F2V (327.68f); +#endif + +#ifdef _OPENMP + #pragma omp for schedule(dynamic,16) +#endif + + for (int y = 0; y < transformed->H; y++) { +#ifdef __SSE2__ + int i = 0; + + for (; i < transformed->W - 3; i += 4) { + vfloat av = LVFU (original->a[y][i]); + vfloat bv = LVFU (original->b[y][i]); + STVF (atan2Buffer[i], xatan2f (bv, av)); + STVF (sqrtBuffer[i], _mm_sqrt_ps (SQRV (bv) + SQRV (av)) / c327d68v); + } + + for (; i < transformed->W; i++) { + atan2Buffer[i] = xatan2f (original->b[y][i], original->a[y][i]); + sqrtBuffer[i] = sqrt (SQR (original->b[y][i]) + SQR (original->a[y][i])) / 327.68f; + } + +#endif + int loy = cy + y; + + for (int x = 0; x < transformed->W; x++) { + int lox = cx + x; +#ifdef __SSE2__ + float rhue = atan2Buffer[x]; + float rchro = sqrtBuffer[x]; +#else + float rhue = xatan2f (original->b[y][x], original->a[y][x]); + float rchro = sqrt (SQR (original->b[y][x]) + SQR (original->a[y][x])) / 327.68f; +#endif + float rL = original->L[y][x] / 327.68f; + float eps = 0.f; + + if (fabs (original->b[y][x]) < 0.001f) { + eps = 0.01f; + } + + float kab = original->a[y][x] / (original->b[y][x] + eps); + + float realstr = 1.f; + float realstrch = 1.f; + //prepare shape detection + float deltachro = fabs (rchro - chromaref); + float deltahue = fabs (rhue - hueref); + + if (deltahue > M_PI) { + deltahue = - (deltahue - 2.f * M_PI); + } + + float deltaE = 20.f * deltahue + deltachro; //between 0 and 280 + float deltaL = fabs (lumaref - rL); //between 0 and 100 + + float kch = 1.f; + float khu = 0.f; + float fach = 1.f; + float falu = 1.f; + + if (deltachro < 160.f * SQR (lp.sensh / 100.f)) { + kch = 1.f; + } else { + float ck = 160.f * SQR (lp.sensh / 100.f); + float ak = 1.f / (ck - 160.f); + float bk = -160.f * ak; + kch = ak * deltachro + bk; + } + + if (lp.sensh < 40.f ) { + kch = pow (kch, pa * lp.sensh + pb); //increase under 40 + } + + bool kzon = false; + + //transition = difficult to avoid artifact with scope on flat area (sky...) + //hue detection + if ((hueref + dhue) < M_PI && rhue < hueplus && rhue > huemoins) { //transition are good + if (rhue >= hueplus - delhu) { + realstr = aplus * rhue + bplus; + khu = apl * rhue + bpl; + + } else if (rhue < huemoins + delhu) { + realstr = amoins * rhue + bmoins; + khu = amo * rhue + bmo; + + } else { + realstr = strn; + khu = 1.f; + + } + + kzon = true; + } else if ((hueref + dhue) >= M_PI && (rhue > huemoins || rhue < hueplus )) { + if (rhue >= hueplus - delhu && rhue < hueplus) { + realstr = aplus * rhue + bplus; + khu = apl * rhue + bpl; + + } else if (rhue >= huemoins && rhue < huemoins + delhu) { + realstr = amoins * rhue + bmoins; + khu = amo * rhue + bmo; + + } else { + realstr = strn; + khu = 1.f; + + } + + kzon = true; + } + + if ((hueref - dhue) > -M_PI && rhue < hueplus && rhue > huemoins) { + if (rhue >= hueplus - delhu && rhue < hueplus) { + realstr = aplus * rhue + bplus; + khu = apl * rhue + bpl; + + } else if (rhue >= huemoins && rhue < huemoins + delhu) { + realstr = amoins * rhue + bmoins; + khu = amo * rhue + bmo; + + } else { + realstr = strn; + khu = 1.f; + + } + + kzon = true; + } else if ((hueref - dhue) <= -M_PI && (rhue > huemoins || rhue < hueplus )) { + if (rhue >= hueplus - delhu && rhue < hueplus) { + realstr = aplus * rhue + bplus; + khu = apl * rhue + bpl; + + } else if (rhue >= huemoins && rhue < huemoins + delhu) { + realstr = amoins * rhue + bmoins; + khu = amo * rhue + bmo; + + } else { + realstr = strn; + khu = 1.f; + + } + + kzon = true; + } + + //shape detection for hue chroma and luma + if (lp.sensh <= 20.f) { //to try... + + if (deltaE < 2.8f * lp.sensh) { + fach = khu; + } else { + fach = khu * (ahu * deltaE + bhu); + } + + float kcr = 10.f; + + if (rchro < kcr) { + fach *= (1.f / (kcr * kcr)) * rchro * rchro; + } + + if (lp.qualmet >= 1) { + if (deltE[y][x] > lp.thr) { + fach = 1.f; + } + } else { + fach = 1.f; + } + + if (deltaL < lp.sensh) { + falu = 1.f; + } else { + falu = alum * deltaL + blum; + } + + } + + + // float kdiff = 0.f; + // I add these functions...perhaps not good + if (kzon) { + if (lp.sensh < 60.f) { //arbitrary value + if (hueref < -1.1f && hueref > -2.8f) { // detect blue sky + if (chromaref > 0.f && chromaref < 35.f * multchro) { // detect blue sky + if ( (rhue > -2.79f && rhue < -1.11f) && (rchro < 35.f * multchro)) { + realstr *= 0.9f; + } else { + realstr = 1.f; + } + } + } else { + realstr = strn; + } + + if (lp.sensh < 50.f) { //&& lp.chro > 0.f + if (hueref > -0.1f && hueref < 1.6f) { // detect skin + if (chromaref > 0.f && chromaref < 55.f * multchroskin) { // detect skin + if ( (rhue > -0.09f && rhue < 1.59f) && (rchro < 55.f * multchroskin)) { + realstr *= 0.7f; + } else { + realstr = 1.f; + } + } + } else { + realstr = strn; + } + } + } + + } + + int zone; + float localFactor; + calcTransition (lox, loy, ach, lp, zone, localFactor); + int begx = int (lp.xc - lp.lxL); + int begy = int (lp.yc - lp.lyT); + + if (rL > 0.1f) { //to avoid crash with very low gamut in rare cases ex : L=0.01 a=0.5 b=-0.9 + switch (zone) { + case 0: { // outside selection and outside transition zone => no effect, keep original values + if (chro == 0) { + transformed->L[y][x] = original->L[y][x]; + } + + if (chro == 1) { + transformed->a[y][x] = original->a[y][x]; + transformed->b[y][x] = original->b[y][x]; + } + + break; + } + + case 1: { // inside transition zone + float factorx = localFactor; + + if (chro == 0) { + float difL; + + if (call <= 3) { + if (lox >= (lp.xc - lp.lxL) && lox < (lp.xc + lp.lx) && loy >= (lp.yc - lp.lyT) && loy < (lp.yc + lp.ly)) { + difL = tmp1->L[loy - begy - 1][lox - begx - 1] - original->L[y][x]; + difL *= factorx * (100.f + realstr * (1.f - factorx)) / 100.f; + difL *= kch * fach; + + transformed->L[y][x] = original->L[y][x] + difL; + } + } else { + difL = (tmp1->L[y][x]) - original->L[y][x]; + difL *= factorx * (100.f + realstr * (1.f - factorx)) / 100.f; + difL *= kch * fach; + transformed->L[y][x] = original->L[y][x] + difL; + } + } + + if (chro == 1) { + float difa, difb; + + if (call <= 3) { + if (lox >= (lp.xc - lp.lxL) && lox < (lp.xc + lp.lx) && loy >= (lp.yc - lp.lyT) && loy < (lp.yc + lp.ly)) { + difa = tmp1->a[loy - begy - 1][lox - begx - 1] - original->a[y][x]; + difb = tmp1->b[loy - begy - 1][lox - begx - 1] - original->b[y][x]; + difa *= factorx * (100.f + realstr * falu * (1.f - factorx)) / 100.f; + difb *= factorx * (100.f + realstr * falu * (1.f - factorx)) / 100.f; + transformed->a[y][x] = CLIPC (original->a[y][x] + difa); + transformed->b[y][x] = CLIPC (original->b[y][x] + difb); + } + + } else { + difa = tmp1->a[y][x] - original->a[y][x]; + difb = tmp1->b[y][x] - original->b[y][x]; + difa *= factorx * (100.f + realstr * falu * (1.f - factorx)) / 100.f; + difb *= factorx * (100.f + realstr * falu * (1.f - factorx)) / 100.f; + transformed->a[y][x] = CLIPC (original->a[y][x] + difa); + transformed->b[y][x] = CLIPC (original->b[y][x] + difb); + } + } + + break; + + } + + case 2: { // inside selection => full effect, no transition + if (chro == 0) { + float difL; + + if (call <= 3) { + if (lox >= (lp.xc - lp.lxL) && lox < (lp.xc + lp.lx) && loy >= (lp.yc - lp.lyT) && loy < (lp.yc + lp.ly)) { + difL = tmp1->L[loy - begy - 1][lox - begx - 1] - original->L[y][x]; + difL *= (100.f + realstr) / 100.f; + difL *= kch * fach; + transformed->L[y][x] = original->L[y][x] + difL; + } + + } else { + difL = tmp1->L[y][x] - original->L[y][x]; + difL *= (100.f + realstr) / 100.f; + difL *= kch * fach; + transformed->L[y][x] = original->L[y][x] + difL; + } + } + + if (chro == 1) { + float difa, difb; + + if (call <= 3) { + if (lox >= (lp.xc - lp.lxL) && lox < (lp.xc + lp.lx) && loy >= (lp.yc - lp.lyT) && loy < (lp.yc + lp.ly)) { + difa = tmp1->a[loy - begy - 1][lox - begx - 1] - original->a[y][x]; + difb = tmp1->b[loy - begy - 1][lox - begx - 1] - original->b[y][x]; + difa *= (100.f + realstr * falu) / 100.f; + difb *= (100.f + realstr * falu) / 100.f; + transformed->a[y][x] = CLIPC (original->a[y][x] + difa); + transformed->b[y][x] = CLIPC (original->b[y][x] + difb); + } + } else { + difa = tmp1->a[y][x] - original->a[y][x]; + difb = tmp1->b[y][x] - original->b[y][x]; + difa *= (100.f + realstr * falu) / 100.f; + difb *= (100.f + realstr * falu) / 100.f; + transformed->a[y][x] = CLIPC (original->a[y][x] + difa); + transformed->b[y][x] = CLIPC (original->b[y][x] + difb); + } + + } + } + } + } + } + } + } + + } +} + +void ImProcFunctions::InverseBlurNoise_Local (const struct local_params & lp, LabImage * original, LabImage * transformed, const LabImage * const tmp1, int cx, int cy) +{ + // BENCHFUN +//inverse local blur and noise + float ach = (float)lp.trans / 100.f; + + #pragma omp parallel for schedule(dynamic,16) if (multiThread) + + for (int y = 0; y < transformed->H; y++) { + int loy = cy + y; + + for (int x = 0; x < transformed->W; x++) { + int lox = cx + x; + + int zone; + float localFactor; + calcTransition (lox, loy, ach, lp, zone, localFactor); + + switch (zone) { + case 0: { // outside selection and outside transition zone => full effect, no transition + transformed->L[y][x] = tmp1->L[y][x]; + + if (!lp.actsp) { + transformed->a[y][x] = tmp1->a[y][x]; + transformed->b[y][x] = tmp1->b[y][x]; + } + + break; + } + + case 1: { // inside transition zone + float difL = tmp1->L[y][x] - original->L[y][x]; + float difa = tmp1->a[y][x] - original->a[y][x]; + float difb = tmp1->b[y][x] - original->b[y][x]; + + float factorx = 1.f - localFactor; + difL *= factorx; + difa *= factorx; + difb *= factorx; + + transformed->L[y][x] = original->L[y][x] + difL; + + if (!lp.actsp) { + + transformed->a[y][x] = original->a[y][x] + difa; + transformed->b[y][x] = original->b[y][x] + difb; + } + + break; + } + + case 2: { // inside selection => no effect, keep original values + transformed->L[y][x] = original->L[y][x]; + + if (!lp.actsp) { + + transformed->a[y][x] = original->a[y][x]; + transformed->b[y][x] = original->b[y][x]; + } + } + } + } + } +} + +struct local_contra { + float alsup, blsup; + float alsup2, blsup2; + float alsup3, blsup3; + float alinf; + float aDY; + float aa; + float bb; + float aaa, bbb; + float ccc; +// float DY; + float dx, dy; + float ah, bh; + float al, bl; +}; + +void ImProcFunctions::Contrast_Local (int call, float moy, const float hueplus, const float huemoins, const float hueref, const float dhue, const float chromaref, float pm, struct local_contra & lco, float lumaref, float av, const struct local_params & lp, float **deltE, LabImage * original, LabImage * transformed, int cx, int cy) +{ + // BENCHFUN +// contrast - perhaps for 4 areas if need +// I tried shmap adaptaed to Lab, but no real gain and artifacts + const float localtype = lumaref; // always spot area + const float ach = (float)lp.trans / 100.f; + float reducac; + + //constant and variable to prepare shape detection + if (lp.sens < 30.f) { + reducac = 0.2f * (lp.sens / 100.f); + } else { + float areduc = 0.6285714f; //0.44f/0.7f; + float breduc = 0.5f - areduc; + reducac = areduc * (lp.sens / 100.f) + breduc; + } + + const float realcox = lco.dx, realcoy = lco.dy; + + lco.alsup = (-realcox) / (localtype / 2.f); + lco.blsup = -lco.alsup * localtype; + lco.alsup2 = (realcoy) / (50.f - localtype / 2.f); + lco.blsup2 = -lco.alsup2 * localtype; + lco.alsup3 = (realcoy) / (localtype / 2.f - 50.f); + lco.blsup3 = -lco.alsup3 * 100.f; + lco.aDY = realcoy; + + + + constexpr float delhu = 0.1f; //between 0.05 and 0.2 + + const float apl = (-1.f) / delhu; + const float bpl = - apl * hueplus; + const float amo = 1.f / delhu; + const float bmo = - amo * huemoins; + + + const float pb = 4.f; + const float pa = (1.f - pb) / 40.f; + + const float ahu = 1.f / (2.8f * lp.sens - 280.f); + const float bhu = 1.f - ahu * 2.8f * lp.sens; + + lco.alinf = realcox / (localtype / 2.f); + const float vi = (localtype / 2.f) / 100.f; + const float vinf = (50.f + localtype / 2.f) / 100.f; + ImProcFunctions::secondeg_begin (reducac, vi, lco.aa, lco.bb);//parabolic + ImProcFunctions::secondeg_end (reducac, vinf, lco.aaa, lco.bbb, lco.ccc);//parabolic + + if (call == 2) { + +#ifdef _OPENMP + #pragma omp parallel if (multiThread) +#endif + { + //Todo optimization in this first part with something equivalent to bufcolorig and bufcoltra in colorlight_local +#ifdef __SSE2__ + float atan2Buffer[transformed->W] ALIGNED16; + float sqrtBuffer[transformed->W] ALIGNED16; + vfloat c327d68v = F2V (327.68f); +#endif + +#ifdef _OPENMP + #pragma omp for schedule(dynamic,16) +#endif + + for (int y = 0; y < transformed->H; y++) + { +#ifdef __SSE2__ + int i = 0; + + for (; i < transformed->W - 3; i += 4) { + vfloat av = LVFU (original->a[y][i]); + vfloat bv = LVFU (original->b[y][i]); + STVF (atan2Buffer[i], xatan2f (bv, av)); + STVF (sqrtBuffer[i], _mm_sqrt_ps (SQRV (bv) + SQRV (av)) / c327d68v); + } + + for (; i < transformed->W; i++) { + atan2Buffer[i] = xatan2f (original->b[y][i], original->a[y][i]); + sqrtBuffer[i] = sqrt (SQR (original->b[y][i]) + SQR (original->a[y][i])) / 327.68f; + } + +#endif + + int loy = cy + y; + + for (int x = 0; x < transformed->W; x++) { + int lox = cx + x; +#ifdef __SSE2__ + float rhue = atan2Buffer[x]; + float rchro = sqrtBuffer[x]; +#else + float rhue = xatan2f (original->b[y][x], original->a[y][x]); + float rchro = sqrt (SQR (original->b[y][x]) + SQR (original->a[y][x])) / 327.68f; +#endif + int zone; + int begx = int (lp.xc - lp.lxL); + int begy = int (lp.yc - lp.lyT); + + if (lox >= (lp.xc - lp.lxL) && lox < (lp.xc + lp.lx) && loy >= (lp.yc - lp.lyT) && loy < (lp.yc + lp.ly)) { + float localFactor = 1.f; + calcTransition (lox, loy, ach, lp, zone, localFactor); + //prepare shape detection + float khu = 0.f; + float kch = 1.f; + bool kzon = false; + float fach = 1.f; + float deltachro = fabs (rchro - chromaref); + float deltahue = fabs (rhue - hueref); + + if (deltahue > M_PI) { + deltahue = - (deltahue - 2.f * M_PI); + } + + float deltaE = 20.f * deltahue + deltachro; //pseudo deltaE between 0 and 280 + float rL = original->L[y][x] / 327.68f; + + //kch to modulate action with chroma + if (deltachro < 160.f * SQR (lp.sens / 100.f)) { + kch = 1.f; + } else { + float ck = 160.f * SQR (lp.sens / 100.f); + float ak = 1.f / (ck - 160.f); + float bk = -160.f * ak; + kch = ak * deltachro + bk; + } + + if (lp.sens < 40.f ) { + kch = pow (kch, pa * lp.sens + pb); //increase under 40 + } + + + // algo with detection of hue ==> artifacts for noisy images ==> denoise before + if (lp.sens < 20.f) { //to try... + //hue detection + if ((hueref + dhue) < M_PI && rhue < hueplus && rhue > huemoins) { //transition are good + if (rhue >= hueplus - delhu ) { + khu = apl * rhue + bpl; + } else if (rhue < huemoins + delhu) { + khu = amo * rhue + bmo; + } else { + khu = 1.f; + } + + + kzon = true; + } else if ((hueref + dhue) >= M_PI && (rhue > huemoins || rhue < hueplus )) { + if (rhue >= hueplus - delhu && rhue < hueplus) { + khu = apl * rhue + bpl; + } else if (rhue >= huemoins && rhue < huemoins + delhu) { + khu = amo * rhue + bmo; + } else { + khu = 1.f; + } + + kzon = true; + } + + if ((hueref - dhue) > -M_PI && rhue < hueplus && rhue > huemoins ) { + if (rhue >= hueplus - delhu && rhue < hueplus) { + khu = apl * rhue + bpl; + } else if (rhue >= huemoins && rhue < huemoins + delhu) { + khu = amo * rhue + bmo; + } else { + khu = 1.f; + } + + kzon = true; + } else if ((hueref - dhue) <= -M_PI && (rhue > huemoins || rhue < hueplus )) { + if (rhue >= hueplus - delhu && rhue < hueplus) { + khu = apl * rhue + bpl; + } else if (rhue >= huemoins && rhue < huemoins + delhu) { + khu = amo * rhue + bmo; + } else { + khu = 1.f; + } + + kzon = true; + } + + if (deltaE < 2.8f * lp.sens) { + fach = khu; + } else { + fach = khu * (ahu * deltaE + bhu); + } + + float kcr = 10.f; + + if (rchro < kcr) { + fach *= (1.f / (kcr * kcr)) * rchro * rchro; + } + + if (lp.qualmet >= 1) { + if (deltE[y][x] > lp.thr) { + fach = 1.f; + } + } else { + fach = 1.f; + } + + //fach = khu ; + + } else { + /* + float kcr = 8.f; + if(lp.sensh > 30.f){ + if (rchro < kcr) { + fach *= (1.f / (kcr)) * rchro; + + } + } + */ + } + + if (rL > 0.01f) { //to avoid crash with very low gamut in rare cases ex : L=0.01 a=0.5 b=-0.9 + + switch (zone) { + case 0: { // outside selection and outside transition zone => no effect, keep original values + transformed->L[y][x] = original->L[y][x]; + transformed->a[y][x] = original->a[y][x]; + transformed->b[y][x] = original->b[y][x]; + break; + } + + case 1: { // inside transition zone + if (original->L[y][x] < 32768.f) { + float factorx = localFactor; + float prov100 = original->L[y][x] / 32768.f; + float prov = prov100 * 100.f; + bool contin = true; + + + if (contin) { + + if (prov > localtype) { + if (prov >= localtype && prov < 50.f + localtype / 2.f) { + float core = (lco.alsup2 * prov + lco.blsup2) ; + core *= factorx; + + transformed->L[y][x] = 327.68f * (prov + pm * (prov - localtype) * (core) * kch * fach); + } else { + float core = lco.aDY * (lco.aaa * prov100 * prov100 + lco.bbb * prov100 + lco.ccc); + + core *= factorx; + transformed->L[y][x] = 327.68f * (prov + pm * (prov - localtype) * (core) * kch * fach); + } + } else { //inferior + if (2.f * prov > localtype && prov < localtype) { + float core = (lco.alsup * prov + lco.blsup) ; + core *= factorx; + transformed->L[y][x] = 327.68f * (prov - pm * (localtype - prov) * core * kch * fach); + } else if (2.f * prov <= localtype) { + float core = prov * lco.alinf * (lco.aa * prov100 * prov100 + lco.bb * prov100); + + core *= factorx; + transformed->L[y][x] = 327.68f * (prov - pm * (localtype - prov) * core * kch * fach); + } + } + } + } else { + transformed->L[y][x] = original->L[y][x]; + } + + break; + } + + case 2: { // inside selection => full effect, no transition + if (original->L[y][x] < 32768.f) { + float prov100 = original->L[y][x] / 32768.f; + float prov = prov100 * 100.f; + + bool contin = true; + + if (contin) { + + + + if (prov > localtype ) { + if (prov >= localtype && prov < 50.f + localtype / 2.f) { + float core = (lco.alsup2 * prov + lco.blsup2) ; + transformed->L[y][x] = 327.68f * (prov + pm * (prov - localtype) * core * kch * fach); + } else { + float core = lco.aDY * (lco.aaa * prov100 * prov100 + lco.bbb * prov100 + lco.ccc); + transformed->L[y][x] = 327.68f * (prov + pm * (prov - localtype) * core * kch * fach); + } + } else { //inferior + if (2.f * prov > localtype && prov < localtype) { + float core = (lco.alsup * prov + lco.blsup) ; + transformed->L[y][x] = 327.68f * (prov - pm * (localtype - prov) * core * kch * fach); + } else if (2.f * prov <= localtype) { + float core = prov * lco.alinf * (lco.aa * prov100 * prov100 + lco.bb * prov100); + transformed->L[y][x] = 327.68f * (prov - pm * (localtype - prov) * core * kch * fach); + } + } + } + } else { + transformed->L[y][x] = original->L[y][x]; + } + } + } + } + } + } + } + } + } else { + +#ifdef _OPENMP + #pragma omp parallel if (multiThread) +#endif + { +#ifdef __SSE2__ + float atan2Buffer[transformed->W] ALIGNED16; + float sqrtBuffer[transformed->W] ALIGNED16; + vfloat c327d68v = F2V (327.68f); +#endif + +#ifdef _OPENMP + #pragma omp for schedule(dynamic,16) +#endif + + for (int y = 0; y < transformed->H; y++) + { +#ifdef __SSE2__ + int i = 0; + + for (; i < transformed->W - 3; i += 4) { + vfloat av = LVFU (original->a[y][i]); + vfloat bv = LVFU (original->b[y][i]); + STVF (atan2Buffer[i], xatan2f (bv, av)); + STVF (sqrtBuffer[i], _mm_sqrt_ps (SQRV (bv) + SQRV (av)) / c327d68v); + } + + for (; i < transformed->W; i++) { + atan2Buffer[i] = xatan2f (original->b[y][i], original->a[y][i]); + sqrtBuffer[i] = sqrt (SQR (original->b[y][i]) + SQR (original->a[y][i])) / 327.68f; + } + +#endif + + int loy = cy + y; + + for (int x = 0; x < transformed->W; x++) { + int lox = cx + x; +#ifdef __SSE2__ + float rhue = atan2Buffer[x]; + float rchro = sqrtBuffer[x]; +#else + float rhue = xatan2f (original->b[y][x], original->a[y][x]); + float rchro = sqrt (SQR (original->b[y][x]) + SQR (original->a[y][x])) / 327.68f; +#endif + int zone; + int begx = int (lp.xc - lp.lxL); + int begy = int (lp.yc - lp.lyT); + float localFactor = 1.f; + calcTransition (lox, loy, ach, lp, zone, localFactor); + //prepare shape detection + float khu = 0.f; + float kch = 1.f; + bool kzon = false; + float fach = 1.f; + float deltachro = fabs (rchro - chromaref); + float deltahue = fabs (rhue - hueref); + + if (deltahue > M_PI) { + deltahue = - (deltahue - 2.f * M_PI); + } + + float deltaE = 20.f * deltahue + deltachro; //pseudo deltaE between 0 and 280 + float rL = original->L[y][x] / 327.68f; + + //kch to modulate action with chroma + if (deltachro < 160.f * SQR (lp.sens / 100.f)) { + kch = 1.f; + } else { + float ck = 160.f * SQR (lp.sens / 100.f); + float ak = 1.f / (ck - 160.f); + float bk = -160.f * ak; + kch = ak * deltachro + bk; + } + + if (lp.sens < 40.f ) { + kch = pow (kch, pa * lp.sens + pb); //increase under 40 + } + + + // algo with detection of hue ==> artifacts for noisy images ==> denoise before + if (lp.sens < 20.f) { //to try... + //hue detection + if ((hueref + dhue) < M_PI && rhue < hueplus && rhue > huemoins) { //transition are good + if (rhue >= hueplus - delhu ) { + khu = apl * rhue + bpl; + } else if (rhue < huemoins + delhu) { + khu = amo * rhue + bmo; + } else { + khu = 1.f; + } + + + kzon = true; + } else if ((hueref + dhue) >= M_PI && (rhue > huemoins || rhue < hueplus )) { + if (rhue >= hueplus - delhu && rhue < hueplus) { + khu = apl * rhue + bpl; + } else if (rhue >= huemoins && rhue < huemoins + delhu) { + khu = amo * rhue + bmo; + } else { + khu = 1.f; + } + + kzon = true; + } + + if ((hueref - dhue) > -M_PI && rhue < hueplus && rhue > huemoins ) { + if (rhue >= hueplus - delhu && rhue < hueplus) { + khu = apl * rhue + bpl; + } else if (rhue >= huemoins && rhue < huemoins + delhu) { + khu = amo * rhue + bmo; + } else { + khu = 1.f; + } + + kzon = true; + } else if ((hueref - dhue) <= -M_PI && (rhue > huemoins || rhue < hueplus )) { + if (rhue >= hueplus - delhu && rhue < hueplus) { + khu = apl * rhue + bpl; + } else if (rhue >= huemoins && rhue < huemoins + delhu) { + khu = amo * rhue + bmo; + } else { + khu = 1.f; + } + + kzon = true; + } + + if (deltaE < 2.8f * lp.sens) { + fach = khu; + } else { + fach = khu * (ahu * deltaE + bhu); + } + + float kcr = 10.f; + + if (rchro < kcr) { + fach *= (1.f / (kcr * kcr)) * rchro * rchro; + } + + if (lp.qualmet >= 1) { + if (deltE[y][x] > lp.thr) { + fach = 1.f; + } + } else { + fach = 1.f; + } + + //fach = khu ; + + } else { + /* + float kcr = 8.f; + if(lp.sensh > 30.f){ + if (rchro < kcr) { + fach *= (1.f / (kcr)) * rchro; + + } + } + */ + } + + if (rL > 0.01f) { //to avoid crash with very low gamut in rare cases ex : L=0.01 a=0.5 b=-0.9 + + switch (zone) { + case 0: { // outside selection and outside transition zone => no effect, keep original values + transformed->L[y][x] = original->L[y][x]; + transformed->a[y][x] = original->a[y][x]; + transformed->b[y][x] = original->b[y][x]; + break; + } + + case 1: { // inside transition zone + if (original->L[y][x] < 32768.f) { + float factorx = localFactor; + float prov100 = original->L[y][x] / 32768.f; + float prov = prov100 * 100.f; + bool contin = true; + + + if (contin) { + + if (prov > localtype) { + if (prov >= localtype && prov < 50.f + localtype / 2.f) { + float core = (lco.alsup2 * prov + lco.blsup2) ; + core *= factorx; + + transformed->L[y][x] = 327.68f * (prov + pm * (prov - localtype) * (core) * kch * fach); + } else { + float core = lco.aDY * (lco.aaa * prov100 * prov100 + lco.bbb * prov100 + lco.ccc); + + core *= factorx; + transformed->L[y][x] = 327.68f * (prov + pm * (prov - localtype) * (core) * kch * fach); + } + } else { //inferior + if (2.f * prov > localtype && prov < localtype) { + float core = (lco.alsup * prov + lco.blsup) ; + core *= factorx; + transformed->L[y][x] = 327.68f * (prov - pm * (localtype - prov) * core * kch * fach); + } else if (2.f * prov <= localtype) { + float core = prov * lco.alinf * (lco.aa * prov100 * prov100 + lco.bb * prov100); + + core *= factorx; + transformed->L[y][x] = 327.68f * (prov - pm * (localtype - prov) * core * kch * fach); + } + } + } + } else { + transformed->L[y][x] = original->L[y][x]; + } + + break; + } + + case 2: { // inside selection => full effect, no transition + if (original->L[y][x] < 32768.f) { + float prov100 = original->L[y][x] / 32768.f; + float prov = prov100 * 100.f; + + bool contin = true; + + if (contin) { + + + + if (prov > localtype ) { + if (prov >= localtype && prov < 50.f + localtype / 2.f) { + float core = (lco.alsup2 * prov + lco.blsup2) ; + transformed->L[y][x] = 327.68f * (prov + pm * (prov - localtype) * core * kch * fach); + } else { + float core = lco.aDY * (lco.aaa * prov100 * prov100 + lco.bbb * prov100 + lco.ccc); + transformed->L[y][x] = 327.68f * (prov + pm * (prov - localtype) * core * kch * fach); + } + } else { //inferior + if (2.f * prov > localtype && prov < localtype) { + float core = (lco.alsup * prov + lco.blsup) ; + transformed->L[y][x] = 327.68f * (prov - pm * (localtype - prov) * core * kch * fach); + } else if (2.f * prov <= localtype) { + float core = prov * lco.alinf * (lco.aa * prov100 * prov100 + lco.bb * prov100); + transformed->L[y][x] = 327.68f * (prov - pm * (localtype - prov) * core * kch * fach); + } + } + } + } else { + transformed->L[y][x] = original->L[y][x]; + } + } + } + } + } + } + + } + } +} + + +void ImProcFunctions::InverseContrast_Local (float ave, const local_contra & lco, const struct local_params & lp, LabImage * original, LabImage * transformed, int cx, int cy) +{ + // BENCHFUN + float ach = (float)lp.trans / 100.f; + + #pragma omp parallel for schedule(dynamic,16) if (multiThread) + + for (int y = 0; y < transformed->H; y++) { + int loy = cy + y; + + for (int x = 0; x < transformed->W; x++) { + int lox = cx + x; + + int zone; + float localFactor; + calcTransition (lox, loy, ach, lp, zone, localFactor); + + switch (zone) { + case 0: { // outside selection and outside transition zone => full effect, no transition + if (original->L[y][x] < 32768.f) { + float prov = original->L[y][x]; + + if (original->L[y][x] > ave) { + float kh = lco.ah * (original->L[y][x] / 327.68f) + lco.bh; + original->L[y][x] = ave + kh * (original->L[y][x] - ave); + } else { + float kl = lco.al * (original->L[y][x] / 327.68f) + 1.f; + original->L[y][x] = ave - kl * (ave - original->L[y][x]); + } + + float diflc = original->L[y][x] - prov; + transformed->L[y][x] = prov + diflc; + } else { + transformed->L[y][x] = original->L[y][x]; + } + + break; + } + + case 1: { // inside transition zone + if (original->L[y][x] < 32768.f) { + float factorx = localFactor; + factorx = 1.f - factorx; + float prov = original->L[y][x]; + + if (original->L[y][x] > ave) { + float kh = lco.ah * (original->L[y][x] / 327.68f) + lco.bh; + original->L[y][x] = ave + kh * (original->L[y][x] - ave); + } else { + float kl = lco.al * (original->L[y][x] / 327.68f) + 1.f; + original->L[y][x] = ave - kl * (ave - original->L[y][x]); + } + + float diflc = original->L[y][x] - prov; + diflc *= factorx; + transformed->L[y][x] = prov + diflc; + + } else { + transformed->L[y][x] = original->L[y][x]; + } + + break; + } + + case 2: { // inside selection => no effect, keep original values + transformed->L[y][x] = original->L[y][x]; + } + } + } + } +} + +static void calclight (float lum, float koef, float & lumnew, bool inv) +//replace L-curve that does not work in local or bad +{ + + float blac = 0.3f; + + if (inv == false) { + blac = 0.99f; + } + + if (koef > 0.f) { + lumnew = lum + 0.2f * (33000.f - lum) * koef / 100.f; + } + + if (koef < 0.f) { + lumnew = lum + blac * lum * koef / 100.f;//0.999 instead of 0.2 + + if (lumnew < 0.f) { + float kc = lum / (lum - lumnew); + lumnew = lum + kc * 0.2f * lum * koef / 100.f; + + } + + if (inv == false && koef == -100.f) { + lumnew = 0.f; + } + + } + + lumnew = CLIPLOC (lumnew); + +} + +void ImProcFunctions::InverseSharp_Local (int sp, float **loctemp, const float hueplus, const float huemoins, const float hueref, const float dhue, const float chromaref, const float lumaref, const local_params & lp, float **deltE, LabImage * original, LabImage * transformed, int cx, int cy) +{ +//local sharp + // BENCHFUN + const float localtype = lumaref; // always spot area + const float ach = (float)lp.trans / 100.f; + float reducac; + + //constant and variable to prepare shape detection + if (lp.senssha < 30.f) { + reducac = 0.2f * (lp.senssha / 100.f); + } else { + float areduc = 0.6285714f; //0.44f/0.7f; + float breduc = 0.5f - areduc; + reducac = areduc * (lp.senssha / 100.f) + breduc; + } + + + + constexpr float delhu = 0.1f; //between 0.05 and 0.2 + + const float apl = (-1.f) / delhu; + const float bpl = - apl * hueplus; + const float amo = 1.f / delhu; + const float bmo = - amo * huemoins; + + + const float pb = 4.f; + const float pa = (1.f - pb) / 40.f; + + const float ahu = 1.f / (2.8f * lp.senssha - 280.f); + const float bhu = 1.f - ahu * 2.8f * lp.senssha; + +#ifdef _OPENMP + #pragma omp parallel if (multiThread) +#endif + { +#ifdef __SSE2__ + float atan2Buffer[transformed->W] ALIGNED16; + float sqrtBuffer[transformed->W] ALIGNED16; + vfloat c327d68v = F2V (327.68f); +#endif + +#ifdef _OPENMP + #pragma omp for schedule(dynamic,16) +#endif + + for (int y = 0; y < transformed->H; y++) { +#ifdef __SSE2__ + int i = 0; + + for (; i < transformed->W - 3; i += 4) { + vfloat av = LVFU (original->a[y][i]); + vfloat bv = LVFU (original->b[y][i]); + STVF (atan2Buffer[i], xatan2f (bv, av)); + STVF (sqrtBuffer[i], _mm_sqrt_ps (SQRV (bv) + SQRV (av)) / c327d68v); + } + + for (; i < transformed->W; i++) { + atan2Buffer[i] = xatan2f (original->b[y][i], original->a[y][i]); + sqrtBuffer[i] = sqrt (SQR (original->b[y][i]) + SQR (original->a[y][i])) / 327.68f; + } + +#endif + + int loy = cy + y; + + for (int x = 0; x < transformed->W; x++) { + int lox = cx + x; +#ifdef __SSE2__ + float rhue = atan2Buffer[x]; + float rchro = sqrtBuffer[x]; +#else + float rhue = xatan2f (original->b[y][x], original->a[y][x]); + float rchro = sqrt (SQR (original->b[y][x]) + SQR (original->a[y][x])) / 327.68f; +#endif + int zone; + float localFactor = 1.f; + calcTransition (lox, loy, ach, lp, zone, localFactor); + //prepare shape detection + float khu = 0.f; + float kch = 1.f; + bool kzon = false; + float fach = 1.f; + float deltachro = fabs (rchro - chromaref); + float deltahue = fabs (rhue - hueref); + + if (deltahue > M_PI) { + deltahue = - (deltahue - 2.f * M_PI); + } + + float deltaE = 20.f * deltahue + deltachro; //pseudo deltaE between 0 and 280 + + //kch to modulate action with chroma + if (deltachro < 160.f * SQR (lp.senssha / 100.f)) { + kch = 1.f; + } else { + float ck = 160.f * SQR (lp.senssha / 100.f); + float ak = 1.f / (ck - 160.f); + float bk = -160.f * ak; + kch = ak * deltachro + bk; + } + + if (lp.senssha < 40.f ) { + kch = pow (kch, pa * lp.senssha + pb); //increase under 40 + } + + + // algo with detection of hue ==> artifacts for noisy images ==> denoise before + if (lp.senssha < 20.f) { //to try... + //hue detection + if ((hueref + dhue) < M_PI && rhue < hueplus && rhue > huemoins) { //transition are good + if (rhue >= hueplus - delhu ) { + khu = apl * rhue + bpl; + } else if (rhue < huemoins + delhu) { + khu = amo * rhue + bmo; + } else { + khu = 1.f; + } + + + kzon = true; + } else if ((hueref + dhue) >= M_PI && (rhue > huemoins || rhue < hueplus )) { + if (rhue >= hueplus - delhu && rhue < hueplus) { + khu = apl * rhue + bpl; + } else if (rhue >= huemoins && rhue < huemoins + delhu) { + khu = amo * rhue + bmo; + } else { + khu = 1.f; + } + + kzon = true; + } + + if ((hueref - dhue) > -M_PI && rhue < hueplus && rhue > huemoins ) { + if (rhue >= hueplus - delhu && rhue < hueplus) { + khu = apl * rhue + bpl; + } else if (rhue >= huemoins && rhue < huemoins + delhu) { + khu = amo * rhue + bmo; + } else { + khu = 1.f; + } + + kzon = true; + } else if ((hueref - dhue) <= -M_PI && (rhue > huemoins || rhue < hueplus )) { + if (rhue >= hueplus - delhu && rhue < hueplus) { + khu = apl * rhue + bpl; + } else if (rhue >= huemoins && rhue < huemoins + delhu) { + khu = amo * rhue + bmo; + } else { + khu = 1.f; + } + + kzon = true; + } + + if (deltaE < 2.8f * lp.senssha) { + fach = khu; + } else { + fach = khu * (ahu * deltaE + bhu); + } + + + float kcr = 10.f; + + if (rchro < kcr) { + fach *= (1.f / (kcr * kcr)) * rchro * rchro; + } + + if (lp.qualmet >= 1) { + if (deltE[y][x] > lp.thr) { + fach = 1.f; + } + } else { + fach = 1.f; + } + + //fach = khu ; + + } else { + /* + float kcr = 8.f; + if(lp.senssha > 30.f){ + if (rchro < kcr) { + fach *= (1.f / (kcr)) * rchro; + + } + } + */ + } + + + + switch (zone) { + case 0: { // outside selection and outside transition zone => full effect, no transition + float difL = loctemp[y][x] - original->L[y][x]; + transformed->L[y][x] = original->L[y][x] + difL * kch * fach; + + break; + } + + case 1: { // inside transition zone + float difL = loctemp[y][x] - original->L[y][x]; + + float factorx = 1.f - localFactor; + difL *= factorx; + + transformed->L[y][x] = original->L[y][x] + difL * kch * fach; + break; + } + + case 2: { // inside selection => no effect, keep original values + transformed->L[y][x] = original->L[y][x]; + } + } + } + } + } +} + + +void ImProcFunctions::Sharp_Local (int call, int sp, float **loctemp, const float hueplus, const float huemoins, const float hueref, const float dhue, const float chromaref, const float lumaref, const local_params & lp, float **deltE, LabImage * original, LabImage * transformed, int cx, int cy) +{ + // BENCHFUN + const float localtype = lumaref; // always spot area + const float ach = (float)lp.trans / 100.f; + float reducac; + + //constant and variable to prepare shape detection + if (lp.senssha < 30.f) { + reducac = 0.2f * (lp.senssha / 100.f); + } else { + float areduc = 0.6285714f; //0.44f/0.7f; + float breduc = 0.5f - areduc; + reducac = areduc * (lp.senssha / 100.f) + breduc; + } + + //printf("call=%i\n", call); + + constexpr float delhu = 0.1f; //between 0.05 and 0.2 + + const float apl = (-1.f) / delhu; + const float bpl = - apl * hueplus; + const float amo = 1.f / delhu; + const float bmo = - amo * huemoins; + + + const float pb = 4.f; + const float pa = (1.f - pb) / 40.f; + + const float ahu = 1.f / (2.8f * lp.senssha - 280.f); + const float bhu = 1.f - ahu * 2.8f * lp.senssha; + +#ifdef _OPENMP + #pragma omp parallel if (multiThread) +#endif + { +#ifdef __SSE2__ + float atan2Buffer[transformed->W] ALIGNED16; + float sqrtBuffer[transformed->W] ALIGNED16; + vfloat c327d68v = F2V (327.68f); +#endif + +#ifdef _OPENMP + #pragma omp for schedule(dynamic,16) +#endif + + for (int y = 0; y < transformed->H; y++) { +#ifdef __SSE2__ + int i = 0; + + for (; i < transformed->W - 3; i += 4) { + vfloat av = LVFU (original->a[y][i]); + vfloat bv = LVFU (original->b[y][i]); + STVF (atan2Buffer[i], xatan2f (bv, av)); + STVF (sqrtBuffer[i], _mm_sqrt_ps (SQRV (bv) + SQRV (av)) / c327d68v); + } + + for (; i < transformed->W; i++) { + atan2Buffer[i] = xatan2f (original->b[y][i], original->a[y][i]); + sqrtBuffer[i] = sqrt (SQR (original->b[y][i]) + SQR (original->a[y][i])) / 327.68f; + } + +#endif + + int loy = cy + y; + + for (int x = 0; x < transformed->W; x++) { + int lox = cx + x; +#ifdef __SSE2__ + float rhue = atan2Buffer[x]; + float rchro = sqrtBuffer[x]; +#else + float rhue = xatan2f (original->b[y][x], original->a[y][x]); + float rchro = sqrt (SQR (original->b[y][x]) + SQR (original->a[y][x])) / 327.68f; +#endif + int zone; + float localFactor = 1.f; + calcTransition (lox, loy, ach, lp, zone, localFactor); + //prepare shape detection + float khu = 0.f; + float kch = 1.f; + bool kzon = false; + float fach = 1.f; + float deltachro = fabs (rchro - chromaref); + float deltahue = fabs (rhue - hueref); + + if (deltahue > M_PI) { + deltahue = - (deltahue - 2.f * M_PI); + } + + float deltaE = 20.f * deltahue + deltachro; //pseudo deltaE between 0 and 280 + + //kch to modulate action with chroma + if (deltachro < 160.f * SQR (lp.senssha / 100.f)) { + kch = 1.f; + } else { + float ck = 160.f * SQR (lp.senssha / 100.f); + float ak = 1.f / (ck - 160.f); + float bk = -160.f * ak; + kch = ak * deltachro + bk; + } + + if (lp.senssha < 40.f ) { + kch = pow (kch, pa * lp.senssha + pb); //increase under 40 + } + + + // algo with detection of hue ==> artifacts for noisy images ==> denoise before + if (lp.senssha < 20.f) { //to try... + //hue detection + if ((hueref + dhue) < M_PI && rhue < hueplus && rhue > huemoins) { //transition are good + if (rhue >= hueplus - delhu ) { + khu = apl * rhue + bpl; + } else if (rhue < huemoins + delhu) { + khu = amo * rhue + bmo; + } else { + khu = 1.f; + } + + + kzon = true; + } else if ((hueref + dhue) >= M_PI && (rhue > huemoins || rhue < hueplus )) { + if (rhue >= hueplus - delhu && rhue < hueplus) { + khu = apl * rhue + bpl; + } else if (rhue >= huemoins && rhue < huemoins + delhu) { + khu = amo * rhue + bmo; + } else { + khu = 1.f; + } + + kzon = true; + } + + if ((hueref - dhue) > -M_PI && rhue < hueplus && rhue > huemoins ) { + if (rhue >= hueplus - delhu && rhue < hueplus) { + khu = apl * rhue + bpl; + } else if (rhue >= huemoins && rhue < huemoins + delhu) { + khu = amo * rhue + bmo; + } else { + khu = 1.f; + } + + kzon = true; + } else if ((hueref - dhue) <= -M_PI && (rhue > huemoins || rhue < hueplus )) { + if (rhue >= hueplus - delhu && rhue < hueplus) { + khu = apl * rhue + bpl; + } else if (rhue >= huemoins && rhue < huemoins + delhu) { + khu = amo * rhue + bmo; + } else { + khu = 1.f; + } + + kzon = true; + } + + if (deltaE < 2.8f * lp.senssha) { + fach = khu; + } else { + fach = khu * (ahu * deltaE + bhu); + } + + + float kcr = 10.f; + + if (rchro < kcr) { + fach *= (1.f / (kcr * kcr)) * rchro * rchro; + } + + if (lp.qualmet == 1) { + if (deltE[y][x] > lp.thr) { + fach = 1.f; + } + } else { + fach = 1.f; + } + + //fach = khu ; + + } else { + /* + float kcr = 8.f; + if(lp.senssha > 30.f){ + if (rchro < kcr) { + fach *= (1.f / (kcr)) * rchro; + + } + } + */ + } + + int begx = int (lp.xc - lp.lxL); + int begy = int (lp.yc - lp.lyT); + + switch (zone) { + case 0: { // outside selection and outside transition zone => no effect, keep original values + transformed->L[y][x] = original->L[y][x]; + break; + } + + case 1: { // inside transition zone + float factorx = localFactor; + float difL; + + if (call == 2) { + if (lox >= (lp.xc - lp.lxL) && lox < (lp.xc + lp.lx) && loy >= (lp.yc - lp.lyT) && loy < (lp.yc + lp.ly)) { + difL = loctemp[loy - begy - 1][lox - begx - 1] - original->L[y][x]; + } + } else if (call == 1) { + difL = loctemp[y][x] - original->L[y][x]; + + } + + //float difL = loctemp[y][x] - original->L[y][x]; + difL *= factorx; + transformed->L[y][x] = original->L[y][x] + difL * kch * fach; + + break; + } + + case 2: { // inside selection => full effect, no transition + // float difL = loctemp[y][x] - original->L[y][x]; + float difL; + + if (call == 2) { + + if (lox >= (lp.xc - lp.lxL) && lox < (lp.xc + lp.lx) && loy >= (lp.yc - lp.lyT) && loy < (lp.yc + lp.ly)) { + // bufsh[loy - begy - 1][lox - begx - 1] + difL = loctemp[loy - begy - 1][lox - begx - 1] - original->L[y][x]; + } + } else if (call == 1) { + difL = loctemp[y][x] - original->L[y][x]; + } + + transformed->L[y][x] = original->L[y][x] + difL * kch * fach; + } + } + } + } + } +} + + + +void ImProcFunctions::ColorLight_Local (int call, LabImage * bufcolorig, LabImage * bufcoltra, int sp, float moy, const float hueplus, const float huemoins, const float hueref, const float dhue, const float chromaref, const float lumaref, bool locallutili, LUTf & lllocalcurve, const LocLHCurve & loclhCurve, const local_params & lp, float ** deltE, LabImage * original, LabImage * transformed, int cx, int cy) +{ + // BENCHFUN +// chroma and lightness + const float ach = (float)lp.trans / 100.f; + + //chroma + constexpr float amplchsens = 2.5f; + constexpr float achsens = (amplchsens - 1.f) / (100.f - 20.f); //20. default locallab.sensi + constexpr float bchsens = 1.f - 20.f * achsens; + const float multchro = lp.sens * achsens + bchsens; + + //luma + constexpr float ampllumsens = 2.f; + constexpr float alumsens = (ampllumsens - 1.f) / (100.f - 20.f); //20. default locallab.sensi + constexpr float blumsens = 1.f - 20.f * alumsens; + const float multlum = lp.sens * alumsens + blumsens; + + //skin + constexpr float amplchsensskin = 1.6f; + constexpr float achsensskin = (amplchsensskin - 1.f) / (100.f - 20.f); //20. default locallab.sensi + constexpr float bchsensskin = 1.f - 20.f * achsensskin; + const float multchroskin = lp.sens * achsensskin + bchsensskin; + + //transition = difficult to avoid artifact with scope on flat area (sky...) + constexpr float delhu = 0.1f; //between 0.05 and 0.2 + const float aplus = (1.f - lp.chro) / delhu; + const float bplus = 1.f - aplus * hueplus; + const float amoins = (lp.chro - 1.f) / delhu; + const float bmoins = 1.f - amoins * huemoins; + + + const float apl = (-1.f) / delhu; + const float bpl = - apl * hueplus; + const float amo = 1.f / delhu; + const float bmo = - amo * huemoins; + + + const float pb = 4.f; + const float pa = (1.f - pb) / 40.f; + + const float ahu = 1.f / (2.8f * lp.sens - 280.f); + const float bhu = 1.f - ahu * 2.8f * lp.sens; + + const float alum = 1.f / (lp.sens - 100.f); + const float blum = 1.f - alum * lp.sens; + + //luma + constexpr float lumdelta = 11.f; //11 + float modlum = lumdelta * multlum; +// printf("multlum=%f modlum=%f\n", multlum, modlum); + + // constant and varaibles to prepare shape detection + if (lumaref + modlum >= 100.f) { + modlum = (100.f - lumaref) / 2.f; + } + + if (lumaref - modlum <= 0.f) { + modlum = (lumaref) / 2.f; + } + + float alu = 1.f / (lumaref + modlum - 100.f); //linear + float aa, bb, aaa, bbb, ccc; + float reducac = settings->reduchigh;//0.85f; + float reducac2 = settings->reduclow;//0.2f; + + float vinf = (lumaref + modlum) / 100.f; + float vi = (lumaref - modlum) / 100.f; + ImProcFunctions::secondeg_begin (reducac, vi, aa, bb);//parabolic + ImProcFunctions::secondeg_end (reducac, vinf, aaa, bbb, ccc);//parabolic +// printf("vi=%f aa=%f bb=%f vinf=%f aaa=%f bbb=%f ccc=%f\n", vi,aa,bb, vinf, aaa, bbb, ccc); + float vinf2 = (lumaref + modlum) / 100.f; + float vi2 = (lumaref - modlum) / 100.f; + float aaaa, bbbb, cccc, aO, bO; + ImProcFunctions::secondeg_end (reducac2, vinf2, aaaa, bbbb, cccc);//parabolic + ImProcFunctions::secondeg_begin (reducac2, vi2, aO, bO);//parabolic + + if (call <= 3) { + // printf("actif\n"); + /* + if(lllocalcurve) { + printf("COURBE\n"); + } + + if(!lllocalcurve) { + printf("PAS DE COURBE\n"); + } + */ + //Todo optimization in this first part with bufcolorig and bufcoltra + +#ifdef _OPENMP + #pragma omp parallel if (multiThread) +#endif + { +#ifdef __SSE2__ + float atan2Buffer[transformed->W] ALIGNED16; + float sqrtBuffer[transformed->W] ALIGNED16; + vfloat c327d68v = F2V (327.68f); +#endif + + float maxl = -100000.f; + float maxa = -100000.f; + float maxb = -100000.f; + float minl = 100000.f; + float mina = 100000.f; + float minb = 100000.f; + float maxrl = -100000.f; + float minrl = 100000.f; + +#ifdef _OPENMP + #pragma omp for schedule(dynamic,16) +#endif + + for (int y = 0; y < transformed->H; y++) + { + +#ifdef __SSE2__ + int i = 0; + //Todo optimization in this first part with bufcolorig and bufcoltra + + for (; i < transformed->W - 3; i += 4) { + vfloat av = LVFU (original->a[y][i]); + vfloat bv = LVFU (original->b[y][i]); + STVF (atan2Buffer[i], xatan2f (bv, av)); + STVF (sqrtBuffer[i], _mm_sqrt_ps (SQRV (bv) + SQRV (av)) / c327d68v); + + } + + for (; i < transformed->W; i++) { + atan2Buffer[i] = xatan2f (original->b[y][i], original->a[y][i]); + sqrtBuffer[i] = sqrt (SQR (original->b[y][i]) + SQR (original->a[y][i])) / 327.68f; + } + +#endif + + int loy = cy + y; + + for (int x = 0; x < transformed->W; x++) { + int lox = cx + x; + int begx = int (lp.xc - lp.lxL); + int begy = int (lp.yc - lp.lyT); + + if (lox >= (lp.xc - lp.lxL) && lox < (lp.xc + lp.lx) && loy >= (lp.yc - lp.lyT) && loy < (lp.yc + lp.ly)) { + + +#ifdef __SSE2__ + float rhue = atan2Buffer[x]; + float rchro = sqrtBuffer[x]; +#else + + float rhue = xatan2f (original->b[y][x], original->a[y][x]); + + float rchro = sqrt (SQR (original->b[y][x]) + SQR (original->a[y][x])) / 327.68f; +#endif + + float rL = original->L[y][x] / 327.68f; + float rLL = original->L[y][x] / 327.68f; + + if (fabs (original->b[y][x]) < 0.01f) { + original->b[y][x] = 0.01f; + } + + float eps = 0.f; + + if (fabs (original->b[y][x]) < 0.001f) { + eps = 0.01f; + } + + float kab = (original->a[y][x] / (original->b[y][x] + eps)); + + //prepare shape detection +// printf("z"); + //end buf for square + float realchro = 1.f; + float deltachro = fabs (rchro - chromaref); + + float deltahue = fabs (rhue - hueref); + + if (deltahue > M_PI) { + deltahue = - (deltahue - 2.f * M_PI); + } + + float deltaE = 20.f * deltahue + deltachro; //pseudo deltaE between 0 and 280 + float deltaL = fabs (lumaref - rL); //between 0 and 100 + + float kch = 1.f; + float khu = 0.f; + float fach = 1.f; + float falu = 1.f; + + //kch acts on luma + if (deltachro < 160.f * SQR (lp.sens / 100.f)) { + kch = 1.f; + } else { + float ck = 160.f * SQR (lp.sens / 100.f); + float ak = 1.f / (ck - 160.f); + float bk = -160.f * ak; + kch = ak * deltachro + bk; + } + + if (lp.sens < 40.f ) { + kch = pow (kch, pa * lp.sens + pb); //increase under 40 + } + + bool kzon = false; + + //transition = difficult to avoid artifact with scope on flat area (sky...) + //hue detection + if ((hueref + dhue) < M_PI && rhue < hueplus && rhue > huemoins) { //transition are good + if (rhue >= hueplus - delhu) { + realchro = aplus * rhue + bplus; + khu = apl * rhue + bpl; + + } else if (rhue < huemoins + delhu) { + realchro = amoins * rhue + bmoins; + khu = amo * rhue + bmo; + + } else { + realchro = lp.chro; + khu = 1.f; + + } + + kzon = true; + } else if ((hueref + dhue) >= M_PI && (rhue > huemoins || rhue < hueplus )) { + if (rhue >= hueplus - delhu && rhue < hueplus) { + realchro = aplus * rhue + bplus; + khu = apl * rhue + bpl; + + } else if (rhue >= huemoins && rhue < huemoins + delhu) { + realchro = amoins * rhue + bmoins; + khu = amo * rhue + bmo; + + } else { + realchro = lp.chro; + khu = 1.f; + + } + + kzon = true; + } + + if ((hueref - dhue) > -M_PI && rhue < hueplus && rhue > huemoins) { + if (rhue >= hueplus - delhu && rhue < hueplus) { + realchro = aplus * rhue + bplus; + khu = apl * rhue + bpl; + + } else if (rhue >= huemoins && rhue < huemoins + delhu) { + realchro = amoins * rhue + bmoins; + khu = amo * rhue + bmo; + + } else { + realchro = lp.chro; + khu = 1.f; + + } + + kzon = true; + } else if ((hueref - dhue) <= -M_PI && (rhue > huemoins || rhue < hueplus )) { + if (rhue >= hueplus - delhu && rhue < hueplus) { + realchro = aplus * rhue + bplus; + khu = apl * rhue + bpl; + + } else if (rhue >= huemoins && rhue < huemoins + delhu) { + realchro = amoins * rhue + bmoins; + khu = amo * rhue + bmo; + + } else { + realchro = lp.chro; + khu = 1.f; + + } + + kzon = true; + } + + + //detection of deltaE and deltaL + if (lp.sens <= 20.f) { //to try... + //fach and kch acts on luma + if (deltaE < 2.8f * lp.sens) { + fach = khu; + } else { + fach = khu * (ahu * deltaE + bhu); + } + + float kcr = 10.f; + + if (rchro < kcr) { + fach *= (1.f / (kcr * kcr)) * rchro * rchro; + } + + //fach = 1.f;//to avoid artifacts in some cases + //can be probably improved + if (lp.qualmet >= 1) { + if (deltE[y][x] > lp.thr) { + fach = 1.f; + } + } else { + fach = 1.f; + } + + //falu acts on chroma + if (deltaL < lp.sens) { + falu = 1.f; + } else { + falu = 1.f;// alum * deltaL + blum; + } + + } + + if (kzon) { + if (lp.sens < 60.f) { //arbitrary value + if (hueref < -1.1f && hueref > -2.8f) { // detect blue sky + if (chromaref > 0.f && chromaref < 35.f * multchro) { // detect blue sky + if ( (rhue > -2.79f && rhue < -1.11f) && (rchro < 35.f * multchro)) { + realchro *= 0.9f; + } else { + realchro = 1.f; + } + } + } else { + realchro = lp.chro; + } + + if (lp.sens < 50.f && lp.chro > 0.f) { + if (hueref > -0.1f && hueref < 1.6f) { // detect skin + if (chromaref > 0.f && chromaref < 55.f * multchroskin) { // detect skin + if ( (rhue > -0.09f && rhue < 1.59f) && (rchro < 55.f * multchroskin)) { + realchro *= 0.9f; + } else { + realchro = 1.f; + } + } + } else { + realchro = lp.chro; + } + } + } + + } + + float kLinf = rLL / (100.f); + float kLsup = kLinf; + + float kdiff = 1.f; + + if (kzon) { ///rhue < hueplus && rhue > huemoins + + if ( (rLL > (lumaref - modlum) && rLL < (lumaref + modlum))) { + kdiff = 1.f; + } else if (rLL > 0.f && rLL <= (lumaref - modlum)) { + kdiff = (aa * kLinf * kLinf + bb * kLinf); //parabolic + + if (kdiff < 0.01f) { + kdiff = 0.01f; + } + } else if (rLL <= 100.f && rLL >= (lumaref + modlum)) { + + kdiff = (aaa * kLsup * kLsup + bbb * kLsup + ccc); //parabolic + + if (kdiff < 0.01f) { + kdiff = 0.01f; + } + + } + + //end luma + } else { + float ktes = 1.f; + + if ( (rLL > (lumaref - modlum) && rLL < (lumaref + modlum))) { + kdiff = ktes; + } else if (rLL > 0.f && rLL <= (lumaref - modlum)) { + + kdiff = (ktes * (aO * kLinf * kLinf + bO * kLinf)); //parabolic + + if (kdiff < 0.01f) { + kdiff = 0.01f; + } + + } else if (rLL <= 100.f && rLL >= (lumaref + modlum)) { + + kdiff = (ktes * (aaaa * kLsup * kLsup + bbbb * kLsup + cccc)); //parabolic + + if (kdiff < 0.01f) { + kdiff = 0.01f; + } + + } + + } + + int zone; + float localFactor; + calcTransition (lox, loy, ach, lp, zone, localFactor); + float th_r = 0.01f; + + if (rL > th_r) { //to avoid crash with very low gamut in rare cases ex : L=0.01 a=0.5 b=-0.9 + switch (zone) { + case 0: { // outside selection and outside transition zone => no effect, keep original values + transformed->L[y][x] = original->L[y][x]; + transformed->a[y][x] = original->a[y][x]; + transformed->b[y][x] = original->b[y][x]; + break; + } + + case 1: { // inside transition zone + // float lumnew = original->L[y][x]; + float lumnew = bufcolorig->L[loy - begy - 1][lox - begx - 1]; + + float lightcont; + + if (lp.curvact) { + if (lllocalcurve) { + float lumprov = lllocalcurve[lumnew * 1.9f]; + lumnew = 0.526316f * lumprov; + } + + if (loclhCurve) { + float l_r;//Luminance Lab in 0..1 + l_r = lumnew / 32768.f; + { + float khu = 1.9f; //in reserve in case of! + + float valparam = float ((loclhCurve[500.f * Color::huelab_to_huehsv2 (rhue)] - 0.5f)); //get l_r=f(H) + float valparamneg; + valparamneg = valparam; + + if (valparam > 0.f) { + l_r = (1.f - valparam) * l_r + valparam * (1.f - SQR (((SQR (1.f - min (l_r, 1.0f)))))); + } else + //for negative + { + l_r *= (1.f + khu * valparamneg); + } + } + + lumnew = l_r * 32768.f; + } + + } + + if (lp.ligh != 0.f) { + // calclight (bufcolorig->L[loy - begy - 1][lox - begx - 1], lp.ligh , lumnew, true);//replace L-curve + calclight (lumnew, lp.ligh , lumnew, true);//replace L-curve + lightcont = lumnew; + + } else { + lightcont = lumnew; + } + + float factorx = localFactor; + float fac = (100.f + factorx * realchro * falu) / 100.f; //chroma factor transition + // float diflc = lightcont - bufcolorig->L[loy - begy - 1][lox - begx - 1]; + float diflc = lightcont - original->L[y][x]; + kdiff *= fach * kch; + diflc *= kdiff ; + + diflc *= factorx; //transition lightess + // transformed->L[y][x] = CLIPL(bufcolorig->L[loy - begy - 1][lox - begx - 1] + diflc); + transformed->L[y][x] = CLIPL (original->L[y][x] + diflc); + + + if (fabs (kab) > 1.f) { + transformed->a[y][x] = CLIPC (original->a[y][x] * fac) ; + transformed->b[y][x] = CLIPC (original->a[y][x] * fac) / kab; + } else { + transformed->b[y][x] = CLIPC (original->b[y][x] * fac); + transformed->a[y][x] = CLIPC (original->b[y][x] * fac) * kab ; + + } + + break; + } + + case 2: { // inside selection => full effect, no transition + float lumnew = bufcolorig->L[loy - begy - 1][lox - begx - 1]; + float lightcont; + + if (lp.curvact) { + if (lllocalcurve) { + float lumprov = lllocalcurve[lumnew * 1.9f]; + lumnew = 0.526316f * lumprov; + } + + if (loclhCurve) { + float l_r;//Luminance Lab in 0..1 + l_r = lumnew / 32768.f; + { + float khu = 1.9f; + + float valparam = float ((loclhCurve[500.f * Color::huelab_to_huehsv2 (rhue)] - 0.5f)); //get l_r=f(H) + float valparamneg; + valparamneg = valparam; + + if (valparam > 0.f) { + l_r = (1.f - valparam) * l_r + valparam * (1.f - SQR (((SQR (1.f - min (l_r, 1.0f)))))); + } else + //for negative + { + l_r *= (1.f + khu * valparamneg); + } + } + + lumnew = l_r * 32768.f; + } + + } + + + if (lp.ligh != 0.f) { + // calclight (original->L[y][x], lp.ligh , lumnew); + // calclight (bufcolorig->L[loy - begy - 1][lox - begx - 1], lp.ligh , lumnew, true);//replace L-curve + calclight (lumnew, lp.ligh , lumnew, true);//replace L-curve + lightcont = lumnew; + + } else { + lightcont = lumnew; + } + + float fac = (100.f + realchro * falu) / 100.f; //chroma factor transition + float diflc = lightcont - original->L[y][x]; + //float diflc = lightcont - bufcolorig->L[loy - begy - 1][lox - begx - 1]; + + kdiff *= fach * kch; + diflc *= kdiff ; + transformed->L[y][x] = CLIPL (original->L[y][x] + diflc); + + if (fabs (kab) > 1.f) { + transformed->a[y][x] = CLIPC (original->a[y][x] * fac) ; + transformed->b[y][x] = CLIPC (original->a[y][x] * fac) / kab; + } else { + transformed->b[y][x] = CLIPC (original->b[y][x] * fac); + transformed->a[y][x] = CLIPC (original->b[y][x] * fac) * kab; + + } + + } + + } + } + } + } + } + } + + + } + +} + +void ImProcFunctions::InverseColorLight_Local (const struct local_params & lp, LabImage * original, LabImage * transformed, int cx, int cy) +{ + // BENCHFUN + float ach = (float)lp.trans / 100.f; + const float facc = (100.f + lp.chro) / 100.f; //chroma factor transition + + #pragma omp parallel for schedule(dynamic,16) if (multiThread) + + for (int y = 0; y < transformed->H; y++) { + int loy = cy + y; + + for (int x = 0; x < transformed->W; x++) { + int lox = cx + x; + + int zone; + float localFactor; + calcTransition (lox, loy, ach, lp, zone, localFactor); + + switch (zone) { + case 0: { // outside selection and outside transition zone => no effect, keep original values + float lumnew = original->L[y][x]; + + if (lp.ligh != 0.f) { + calclight (original->L[y][x], lp.ligh , lumnew, false); + } + + // float lightcont = localcurve[original->L[y][x]]; //apply lightness + float lightcont = lumnew ; //original->L[y][x] + (lp.ligh /100.f)*original->L[y][x] ; //apply lightness + + + + transformed->L[y][x] = lightcont; //localcurve[original->L[y][x]]; //apply lightness + transformed->a[y][x] = original->a[y][x] * facc; + transformed->b[y][x] = original->b[y][x] * facc; + break; + } + + case 1: { // inside transition zone + float factorx = 1.f - localFactor; + float fac = (100.f + factorx * lp.chro) / 100.f; //chroma factor transition + float lumnew = original->L[y][x]; + + if (lp.ligh != 0.f) { + calclight (original->L[y][x], lp.ligh , lumnew, false); + } + + // float lightcont = localcurve[original->L[y][x]]; //apply lightness + float lightcont = lumnew ; //original->L[y][x] + (lp.ligh /100.f)*original->L[y][x] ; //apply lightness + + //float lightcont = localcurve[original->L[y][x]]; //apply lightness + float diflc = lightcont - original->L[y][x]; + diflc *= factorx; + transformed->L[y][x] = original->L[y][x] + diflc; + transformed->a[y][x] = original->a[y][x] * fac; + transformed->b[y][x] = original->b[y][x] * fac; + break; + } + + case 2: { // inside selection => no effect, keep original values + transformed->L[y][x] = original->L[y][x]; + transformed->a[y][x] = original->a[y][x]; + transformed->b[y][x] = original->b[y][x]; + } + } + } + } + +} + +void ImProcFunctions::Lab_Local (int call, int sp, float** shbuffer, LabImage * original, LabImage * transformed, int sx, int sy, int cx, int cy, int oW, int oH, int fw, int fh, bool locutili, int sk, const LocretigainCurve & locRETgainCcurve, bool locallutili, LUTf & lllocalcurve, const LocLHCurve & loclhCurve, double & hueref, double & chromaref, double & lumaref) +{ + //general call of others functions : important return hueref, chromaref, lumaref + if (params->locallab.enabled) { + // BENCHFUN +#ifdef _DEBUG + MyTime t1e, t2e; + t1e.set(); +// init variables to display Munsell corrections + MunsellDebugInfo* MunsDebugInfo = new MunsellDebugInfo(); +#endif + + + int GW = transformed->W; + int GH = transformed->H; + float moy = 0.f; + float maxmad = -10000.f; + float minmad = 1000000.f; + + struct local_params lp; + calcLocalParams (oW, oH, params->locallab, lp); + + const float radius = lp.rad / (sk * 1.4f); //0 to 70 ==> see skip + GW = transformed->W; + GH = transformed->H; + float **deltE; + + if (lp.qualmet >= 1) { + + deltE = new float*[GH]; + + for (int i = 0; i < GH; i++) { + deltE[i] = new float[GW]; + } + + for (int ir = 0; ir < GH; ir++) + for (int jr = 0; jr < GW; jr++) { + deltE[ir][jr] = 0.f; + } + } + +//begin contrast and evalue hue +// double precision for large summations + double ave = 0.; + double aveA = 0.; + double aveB = 0.; + double aveL = 0.; + double aveChro = 0.; +// int precision for the counters + int n = 0; + int nab = 0; +// single precision for the result + float av, avA, avB, avL; + +//evauate mean luminance for contrast : actually one area +// evaluate also hue + int levred; + bool noiscfactiv = false; + + if (lp.qualmet == 2) { //suppress artifacts with quality enhanced + levred = 4; + noiscfactiv = true; + } else { + levred = 7; + noiscfactiv = false; + } + + + + + if ((!lp.inv || !lp.invret) && hueref == INFINITY && chromaref == INFINITY && lumaref == INFINITY) { + //evaluate hue, chroma, luma in center spot + int spotSize = 0.88623f * max (1, lp.cir / sk); //18 + //O.88623 = sqrt(PI / 4) ==> sqare equal to circle + + // very small region, don't use omp here + for (int y = max (cy, (int) (lp.yc - spotSize)); y < min (transformed->H + cy, (int) (lp.yc + spotSize + 1)); y++) { + for (int x = max (cx, (int) (lp.xc - spotSize)); x < min (transformed->W + cx, (int) (lp.xc + spotSize + 1)); x++) { + aveL += original->L[y - cy][x - cx]; + aveA += original->a[y - cy][x - cx]; + aveB += original->b[y - cy][x - cx]; + aveChro += sqrtf (SQR (original->b[y - cy][x - cx]) + SQR (original->a[y - cy][x - cx])); + + nab++; + } + } + + } else if (lp.inv || lp.invret) { //exterior + ave = 0.f; + n = 0; + #pragma omp parallel for reduction(+:ave,n) + + for (int y = 0; y < transformed->H; y++) { + for (int x = 0; x < transformed->W; x++) { + int lox = cx + x; + int loy = cy + y; + + if (lox >= lp.xc && lox < lp.xc + lp.lx && loy >= lp.yc && loy < lp.yc + lp.ly) { + } else if (lox >= lp.xc && lox < lp.xc + lp.lx && loy < lp.yc && loy > lp.yc - lp.lyT) { + } else if (lox < lp.xc && lox > lp.xc - lp.lxL && loy <= lp.yc && loy > lp.yc - lp.lyT) { + } else if (lox < lp.xc && lox > lp.xc - lp.lxL && loy > lp.yc && loy < lp.yc + lp.ly) { + } else { + ave += original->L[y][x]; + n++; + } + } + } + + if (n == 0) { + ave = 15000.f; + n = 1; + } + + ave = ave / n; + av = ave / 327.68f; + } + + aveL = aveL / nab; + aveA = aveA / nab; + aveB = aveB / nab; + aveChro = aveChro / nab; + aveChro /= 327.68f; + avA = aveA / 327.68f; + avB = aveB / 327.68f; + avL = aveL / 327.68f; + + if (hueref == INFINITY) { + hueref = xatan2f (avB, avA); //mean hue + } + + if (chromaref == INFINITY) { + chromaref = aveChro; + } + + if (lumaref == INFINITY) { + lumaref = avL; + } + + struct local_contra lco; + +// we must here detect : general case, skin, sky,...foliages ??? +// delta dhue, luminance and chroma + constexpr float ared = (M_PI - 0.05f) / 100.f; + + constexpr float bred = 0.05f; + + float dhue = ared * lp.sens + bred; //delta hue lght chroma + + float dhueret = ared * lp.sensh + bred; //delta hue retinex + + constexpr float maxh = 4.f; //amplification contrast above mean + + constexpr float maxl = 3.f; //reductio contrast under mean + + float multh = (float) fabs (lp.cont) * (maxh - 1.f) / 100.f + 1.f; + + float mult = (float)fabs (lp.cont) * (maxl - 1.f) / 100.f + 1.f; + + lco.dx = 1.f - 1.f / mult; + + lco.dy = 1.f - 1.f / multh; + + + + if ((radius >= GAUSS_SKIP || lp.stren > 0.1) && lp.blurena) { // radius < GAUSS_SKIP means no gauss, just copy of original image + LabImage *tmp1; + LabImage *bufgb; + int GW = transformed->W; + int GH = transformed->H; + + if (call == 2 && !lp.invrad) { //simpleprocess + int bfh = int (lp.ly + lp.lyT) + 1; //bfw bfh real size of square zone + int bfw = int (lp.lx + lp.lxL) + 1; + bufgb = new LabImage (bfw, bfh); + +#ifdef _OPENMP + #pragma omp parallel for +#endif + + for (int ir = 0; ir < bfh; ir++) //fill with 0 + for (int jr = 0; jr < bfw; jr++) { + bufgb->L[ir][jr] = 0.f; + bufgb->a[ir][jr] = 0.f; + bufgb->b[ir][jr] = 0.f; + } + +#ifdef _OPENMP +// #pragma omp parallel for +#endif + + for (int y = 0; y < transformed->H ; y++) //{ + for (int x = 0; x < transformed->W; x++) { + int lox = cx + x; + int loy = cy + y; + int begx = int (lp.xc - lp.lxL); + int begy = int (lp.yc - lp.lyT); + + if (lox >= (lp.xc - lp.lxL) && lox < (lp.xc + lp.lx) && loy >= (lp.yc - lp.lyT) && loy < (lp.yc + lp.ly)) { + bufgb->L[loy - begy - 1][lox - begx - 1] = original->L[y][x];//fill square buffer with datas + bufgb->a[loy - begy - 1][lox - begx - 1] = original->a[y][x];//fill square buffer with datas + bufgb->b[loy - begy - 1][lox - begx - 1] = original->b[y][x];//fill square buffer with datas + } + } + + tmp1 = new LabImage (bfw, bfh); +#ifdef _OPENMP + #pragma omp parallel +#endif + { + gaussianBlur (bufgb->L, tmp1->L, bfw, bfh, radius); + gaussianBlur (bufgb->a, tmp1->a, bfw, bfh, radius); + gaussianBlur (bufgb->b, tmp1->b, bfw, bfh, radius); + + } + + + } else { + tmp1 = new LabImage (transformed->W, transformed->H);; + +#ifdef _OPENMP + #pragma omp parallel +#endif + { + gaussianBlur (original->L, tmp1->L, GW, GH, radius); + gaussianBlur (original->a, tmp1->a, GW, GH, radius); + gaussianBlur (original->b, tmp1->b, GW, GH, radius); + + } + } + + if (lp.stren > 0.1f) { + float mean = 0.f;//0 best result + float variance = lp.stren ; //(double) SQR(lp.stren)/sk; + addGaNoise (tmp1, tmp1, mean, variance, sk) ; + } + + if (!lp.invrad) { //blur and noise (center) + // BlurNoise_Local(call, lp, original, transformed, tmp1, cx, cy); + float hueplus = hueref + dhue; + float huemoins = hueref - dhue; + + if (hueplus > M_PI) { + hueplus = hueref + dhue - 2.f * M_PI; + } + + if (huemoins < -M_PI) { + huemoins = hueref - dhue + 2.f * M_PI; + } + + BlurNoise_Local (call, sp, tmp1, hueplus, huemoins, hueref, dhue, chromaref, lumaref, lp, deltE, original, transformed, cx, cy); + + } else { + + InverseBlurNoise_Local (lp, original, transformed, tmp1, cx, cy); + + } + + if (call == 2 && !lp.invrad) { + delete bufgb; + } + + delete tmp1; + } + + // } + +//local denoise + if (lp.noiself > 0.f || lp.noiselc > 0.f || lp.noisecf > 0.f || lp.noisecc > 0.f && call < 3 || noiscfactiv && lp.denoiena) { + if (lp.noisecf > 0.1f || lp.noisecc > 0.1f) { + noiscfactiv = false; + levred = 7; + } + + if (call == 1) { + LabImage *tmp1 = new LabImage (transformed->W, transformed->H); + int GW = transformed->W; + int GH = transformed->H; + + + for (int ir = 0; ir < GH; ir++) + for (int jr = 0; jr < GW; jr++) { + tmp1->L[ir][jr] = original->L[ir][jr]; + tmp1->a[ir][jr] = original->a[ir][jr]; + tmp1->b[ir][jr] = original->b[ir][jr]; + } + + int DaubLen = 6; + int wavNestedLevels = 1; + + int levwavL = levred; + int skip = 1; + wavelet_decomposition* Ldecomp = new wavelet_decomposition (tmp1->L[0], tmp1->W, tmp1->H, levwavL, 1, skip, max (1, wavNestedLevels), DaubLen); + wavelet_decomposition* adecomp = new wavelet_decomposition (tmp1->a[0], tmp1->W, tmp1->H, levwavL, 1, skip, max (1, wavNestedLevels), DaubLen); + wavelet_decomposition* bdecomp = new wavelet_decomposition (tmp1->b[0], tmp1->W, tmp1->H, levwavL, 1, skip, max (1, wavNestedLevels), DaubLen); + + float madL[8][3]; + float madab[8][3]; + int edge; + + if (!Ldecomp->memoryAllocationFailed) { + + for (int lvl = 0; lvl < levred; lvl++) { + for (int dir = 1; dir < 4; dir++) { + int Wlvl_L = Ldecomp->level_W (lvl); + int Hlvl_L = Ldecomp->level_H (lvl); + + float ** WavCoeffs_L = Ldecomp->level_coeffs (lvl); + + madL[lvl][dir - 1] = SQR (Mad (WavCoeffs_L[dir], Wlvl_L * Hlvl_L)); + } + } + + + int ind = 0; + float vari[levred]; + + if (levred == 7) { + edge = 2; + vari[0] = 8.f * SQR ((lp.noiself / 125.0) * (1.0 + lp.noiself / 25.0)); + vari[1] = 8.f * SQR ((lp.noiself / 125.0) * (1.0 + lp.noiself / 25.0)); + vari[2] = 8.f * SQR ((lp.noiself / 125.0) * (1.0 + lp.noiself / 25.0)); + + vari[3] = 8.f * SQR ((lp.noiselc / 125.0) * (1.0 + lp.noiselc / 25.0)); + vari[4] = 8.f * SQR ((lp.noiselc / 125.0) * (1.0 + lp.noiselc / 25.0)); + vari[5] = 8.f * SQR ((lp.noiselc / 125.0) * (1.0 + lp.noiselc / 25.0)); + vari[6] = 8.f * SQR ((lp.noiselc / 125.0) * (1.0 + lp.noiselc / 25.0)); + } else if (levred == 4) { + edge = 3; + vari[0] = 8.f * SQR ((lp.noiself / 125.0) * (1.0 + lp.noiself / 25.0)); + vari[1] = 8.f * SQR ((lp.noiself / 125.0) * (1.0 + lp.noiself / 25.0)); + vari[2] = 8.f * SQR ((lp.noiself / 125.0) * (1.0 + lp.noiself / 25.0)); + vari[3] = 8.f * SQR ((lp.noiself / 125.0) * (1.0 + lp.noiselc / 25.0)); + + } + + if (( lp.noiself > 0.1f || lp.noiselc > 0.1f)) { + vari[0] = max (0.0001f, vari[0]); + vari[1] = max (0.0001f, vari[1]); + vari[2] = max (0.0001f, vari[2]); + vari[3] = max (0.0001f, vari[3]); + + if (levred == 7) { + vari[4] = max (0.0001f, vari[4]); + vari[5] = max (0.0001f, vari[5]); + vari[6] = max (0.0001f, vari[6]); + } + + float* noisevarlum = nullptr; // we need a dummy to pass it to WaveletDenoiseAllL + + WaveletDenoiseAllL (*Ldecomp, noisevarlum, madL, vari, edge); + } + } + + float variC[levred]; + + if (!adecomp->memoryAllocationFailed && !bdecomp->memoryAllocationFailed) { + if (levred == 7) { + edge = 2; + variC[0] = SQR (lp.noisecf / 10.0); + variC[1] = SQR (lp.noisecf / 10.0); + variC[2] = SQR (lp.noisecf / 10.0); + + variC[3] = SQR (lp.noisecf / 10.0); + variC[4] = SQR (lp.noisecf / 10.0); + variC[5] = SQR (lp.noisecc / 10.0); + variC[6] = SQR (lp.noisecc / 10.0); + } else if (levred == 4) { + edge = 3; + variC[0] = SQR (lp.noisecf / 10.0); + variC[1] = SQR (lp.noisecf / 10.0); + variC[2] = SQR (lp.noisecf / 10.0); + variC[3] = SQR (lp.noisecf / 10.0); + } + + + if (( lp.noisecf > 0.1f || lp.noisecc > 0.1f || noiscfactiv)) { + float minic = 0.0001f; + + if (noiscfactiv) { + minic = 0.01f;//only for artifact shape detection + } + + variC[0] = max (minic, variC[0]); + variC[1] = max (minic, variC[1]); + variC[2] = max (minic, variC[2]); + variC[3] = max (minic, variC[3]); + + if (levred == 7) { + + variC[4] = max (0.0001f, variC[4]); + variC[5] = max (0.0001f, variC[5]); + variC[6] = max (0.0001f, variC[6]); + } + + float* noisevarchrom = new float[GH * GW]; + + for (int q = 0; q < GH * GW; q++) { + noisevarchrom[q] = 1.f; + } + + float noisevarab_r = 100.f; //SQR(lp.noisecc / 10.0); + WaveletDenoiseAllAB (*Ldecomp, *adecomp, noisevarchrom, madL, variC, edge, noisevarab_r, false, false, false); + WaveletDenoiseAllAB (*Ldecomp, *bdecomp, noisevarchrom, madL, variC, edge, noisevarab_r, false, false, false); + delete[] noisevarchrom; + + } + } + + if (!Ldecomp->memoryAllocationFailed) { + + Ldecomp->reconstruct (tmp1->L[0]); + } + + if (!adecomp->memoryAllocationFailed) { + + adecomp->reconstruct (tmp1->a[0]); + } + + if (!bdecomp->memoryAllocationFailed) { + + bdecomp->reconstruct (tmp1->b[0]); + } + + DeNoise_Local (call, lp, original, transformed, tmp1, cx, cy); + delete tmp1; + delete Ldecomp; + delete adecomp; + delete bdecomp; + } + + if (call == 2) { //simpleprocess + LabImage *bufwv; + int GW = transformed->W; + int GH = transformed->H; + int bfh = int (lp.ly + lp.lyT) + 1; //bfw bfh real size of square zone + int bfw = int (lp.lx + lp.lxL) + 1; + bufwv = new LabImage (bfw, bfh); +#ifdef _OPENMP + #pragma omp parallel for +#endif + + for (int ir = 0; ir < bfh; ir++) //fill with 0 + for (int jr = 0; jr < bfw; jr++) { + bufwv->L[ir][jr] = 0.f; + bufwv->a[ir][jr] = 0.f; + bufwv->b[ir][jr] = 0.f; + + } + +#ifdef _OPENMP +// #pragma omp parallel for +#endif + + for (int y = 0; y < transformed->H ; y++) //{ + for (int x = 0; x < transformed->W; x++) { + int lox = cx + x; + int loy = cy + y; + int begx = int (lp.xc - lp.lxL); + int begy = int (lp.yc - lp.lyT); + + if (lox >= (lp.xc - lp.lxL) && lox < (lp.xc + lp.lx) && loy >= (lp.yc - lp.lyT) && loy < (lp.yc + lp.ly)) { + bufwv->L[loy - begy - 1][lox - begx - 1] = original->L[y][x];//fill square buffer with datas + bufwv->a[loy - begy - 1][lox - begx - 1] = original->a[y][x];//fill square buffer with datas + bufwv->b[loy - begy - 1][lox - begx - 1] = original->b[y][x];//fill square buffer with datas + } + } + + int DaubLen = 6; + int wavNestedLevels = 1; + + int levwavL = levred; + int skip = 1; + wavelet_decomposition* Ldecomp = new wavelet_decomposition (bufwv->L[0], bufwv->W, bufwv->H, levwavL, 1, skip, max (1, wavNestedLevels), DaubLen); + wavelet_decomposition* adecomp = new wavelet_decomposition (bufwv->a[0], bufwv->W, bufwv->H, levwavL, 1, skip, max (1, wavNestedLevels), DaubLen); + wavelet_decomposition* bdecomp = new wavelet_decomposition (bufwv->b[0], bufwv->W, bufwv->H, levwavL, 1, skip, max (1, wavNestedLevels), DaubLen); + + float madL[8][3]; + float madab[8][3]; + int edge; + + if (!Ldecomp->memoryAllocationFailed) { + + for (int lvl = 0; lvl < levred; lvl++) { + for (int dir = 1; dir < 4; dir++) { + int Wlvl_L = Ldecomp->level_W (lvl); + int Hlvl_L = Ldecomp->level_H (lvl); + + float ** WavCoeffs_L = Ldecomp->level_coeffs (lvl); + + madL[lvl][dir - 1] = SQR (Mad (WavCoeffs_L[dir], Wlvl_L * Hlvl_L)); + } + } + + + int ind = 0; + + float vari[levred]; + + if (levred == 7) { + edge = 2; + vari[0] = 8.f * SQR ((lp.noiself / 125.0) * (1.0 + lp.noiself / 25.0)); + vari[1] = 8.f * SQR ((lp.noiself / 125.0) * (1.0 + lp.noiself / 25.0)); + vari[2] = 8.f * SQR ((lp.noiself / 125.0) * (1.0 + lp.noiself / 25.0)); + + vari[3] = 8.f * SQR ((lp.noiselc / 125.0) * (1.0 + lp.noiselc / 25.0)); + vari[4] = 8.f * SQR ((lp.noiselc / 125.0) * (1.0 + lp.noiselc / 25.0)); + vari[5] = 8.f * SQR ((lp.noiselc / 125.0) * (1.0 + lp.noiselc / 25.0)); + vari[6] = 8.f * SQR ((lp.noiselc / 125.0) * (1.0 + lp.noiselc / 25.0)); + } else if (levred == 4) { + edge = 3; + vari[0] = 8.f * SQR ((lp.noiself / 125.0) * (1.0 + lp.noiself / 25.0)); + vari[1] = 8.f * SQR ((lp.noiself / 125.0) * (1.0 + lp.noiself / 25.0)); + vari[2] = 8.f * SQR ((lp.noiself / 125.0) * (1.0 + lp.noiself / 25.0)); + vari[3] = 8.f * SQR ((lp.noiself / 125.0) * (1.0 + lp.noiselc / 25.0)); + + } + + if (( lp.noiself > 0.1f || lp.noiselc > 0.1f)) { + vari[0] = max (0.0001f, vari[0]); + vari[1] = max (0.0001f, vari[1]); + vari[2] = max (0.0001f, vari[2]); + vari[3] = max (0.0001f, vari[3]); + + if (levred == 7) { + + vari[4] = max (0.0001f, vari[4]); + vari[5] = max (0.0001f, vari[5]); + vari[6] = max (0.0001f, vari[6]); + } + + float* noisevarlum = nullptr; // we need a dummy to pass it to WaveletDenoiseAllL + + WaveletDenoiseAllL (*Ldecomp, noisevarlum, madL, vari, edge); + } + } + + float variC[levred]; + + if (!adecomp->memoryAllocationFailed && !bdecomp->memoryAllocationFailed) { + + if (levred == 7) { + edge = 2; + variC[0] = SQR (lp.noisecf / 10.0); + variC[1] = SQR (lp.noisecf / 10.0); + variC[2] = SQR (lp.noisecf / 10.0); + + variC[3] = SQR (lp.noisecf / 10.0); + variC[4] = SQR (lp.noisecf / 10.0); + variC[5] = SQR (lp.noisecc / 10.0); + variC[6] = SQR (lp.noisecc / 10.0); + } else if (levred == 4) { + edge = 3; + variC[0] = SQR (lp.noisecf / 10.0); + variC[1] = SQR (lp.noisecf / 10.0); + variC[2] = SQR (lp.noisecf / 10.0); + variC[3] = SQR (lp.noisecf / 10.0); + } + + if (( lp.noisecf > 0.1f || lp.noisecc > 0.1f || noiscfactiv)) { + float minic = 0.0001f; + + if (noiscfactiv) { + minic = 0.01f;//only for artifact shape detection + } + + variC[0] = max (minic, variC[0]); + variC[1] = max (minic, variC[1]); + variC[2] = max (minic, variC[2]); + variC[3] = max (minic, variC[3]); + + if (levred == 7) { + + variC[4] = max (0.0001f, variC[4]); + variC[5] = max (0.0001f, variC[5]); + variC[6] = max (0.0001f, variC[6]); + } + + float* noisevarchrom = new float[bfh * bfw]; + + for (int q = 0; q < bfh * bfw; q++) { + noisevarchrom[q] = 1.f; + } + + float noisevarab_r = 100.f; //SQR(lp.noisecc / 10.0); + WaveletDenoiseAllAB (*Ldecomp, *adecomp, noisevarchrom, madL, variC, edge, noisevarab_r, false, false, false); + WaveletDenoiseAllAB (*Ldecomp, *bdecomp, noisevarchrom, madL, variC, edge, noisevarab_r, false, false, false); + delete[] noisevarchrom; + + } + } + + if (!Ldecomp->memoryAllocationFailed) { + + Ldecomp->reconstruct (bufwv->L[0]); + } + + if (!adecomp->memoryAllocationFailed) { + + adecomp->reconstruct (bufwv->a[0]); + } + + if (!bdecomp->memoryAllocationFailed) { + + bdecomp->reconstruct (bufwv->b[0]); + } + + DeNoise_Local (call, lp, original, transformed, bufwv, cx, cy); + delete bufwv; + delete Ldecomp; + delete adecomp; + delete bdecomp; + + + } + + } + + + if (!lp.inv && (lp.chro != 0 || lp.ligh != 0.f || lp.curvact) && lp.colorena) { // || lllocalcurve)) { //interior ellipse renforced lightness and chroma //locallutili + float maxhur = -10.f; + float minhur = 10.f; + float hueplus = hueref + dhue; + float huemoins = hueref - dhue; + + if (hueplus > M_PI) { + hueplus = hueref + dhue - 2.f * M_PI; + } + + if (huemoins < -M_PI) { + huemoins = hueref - dhue + 2.f * M_PI; + } + + LabImage *bufcolorig; + LabImage *bufcoltra; + + if (call <= 3) { //simpleprocess + int GW = transformed->W; + int GH = transformed->H; + int bfh = int (lp.ly + lp.lyT) + 1; //bfw bfh real size of square zone + int bfw = int (lp.lx + lp.lxL) + 1; + bufcolorig = new LabImage (bfw, bfh); + // bufcoltra = new LabImage(bfw, bfh); + +#ifdef _OPENMP + #pragma omp parallel for +#endif + + for (int ir = 0; ir < bfh; ir++) //fill with 0 + for (int jr = 0; jr < bfw; jr++) { + bufcolorig->L[ir][jr] = 0.f; + bufcolorig->a[ir][jr] = 0.f; + bufcolorig->b[ir][jr] = 0.f; + + } + +#ifdef _OPENMP +// #pragma omp parallel for +#endif + + for (int y = 0; y < transformed->H ; y++) //{ + for (int x = 0; x < transformed->W; x++) { + int lox = cx + x; + int loy = cy + y; + int begx = int (lp.xc - lp.lxL); + int begy = int (lp.yc - lp.lyT); + + if (lox >= (lp.xc - lp.lxL) && lox < (lp.xc + lp.lx) && loy >= (lp.yc - lp.lyT) && loy < (lp.yc + lp.ly)) { + bufcolorig->L[loy - begy - 1][lox - begx - 1] = original->L[y][x];//fill square buffer with datas + bufcolorig->a[loy - begy - 1][lox - begx - 1] = original->a[y][x];//fill square buffer with datas + bufcolorig->b[loy - begy - 1][lox - begx - 1] = original->b[y][x];//fill square buffer with datas + //float lumprov = bufcolorig->L[loy - begy - 1][lox - begx - 1]; + //float lumnew = lllocalcurve[lumprov]; + + //float lumnew = lllocalcurve[bufcolorig->L[loy - begy - 1][lox - begx - 1]]; + //bufcolorig->L[loy - begy - 1][lox - begx - 1] = lumnew; + + // bufcoltra->L[loy - begy - 1][lox - begx - 1] = transformed->L[y][x];//fill square buffer with datas + // bufcoltra->a[loy - begy - 1][lox - begx - 1] = transformed->a[y][x];//fill square buffer with datas + // bufcoltra->b[loy - begy - 1][lox - begx - 1] = transformed->b[y][x];//fill square buffer with datas + } + } + + + } + + /* + if(locallutili) printf("Courbe oui\n"); + if(!locallutili) printf("Courbe NON\n"); + if(lllocalcurve) printf("Courbe RE OUI\n"); + if(!lllocalcurve) printf("CouRE NON\n"); + */ + + ColorLight_Local (call, bufcolorig, bufcoltra, sp, moy, hueplus, huemoins, hueref, dhue, chromaref, lumaref, locallutili, lllocalcurve, loclhCurve, lp, deltE, original, transformed, cx, cy); + + if (call <= 3) { + + delete bufcolorig; + // delete bufcoltra; + } + } +//inverse + else if (lp.inv && (lp.chro != 0 || lp.ligh != 0.f) && lp.colorena) { + + InverseColorLight_Local (lp, original, transformed, cx, cy); + } + + + if (!lp.inv && lp.cont != 0 && lp.colorena) { //contrast interior ellipse + const float pm = lp.cont < 0.f ? -1.f : 1.f; + float hueplus = hueref + dhue; + float huemoins = hueref - dhue; + + if (hueplus > M_PI) { + hueplus = hueref + dhue - 2.f * M_PI; + } + + if (huemoins < -M_PI) { + huemoins = hueref - dhue + 2.f * M_PI; + } + + Contrast_Local (call, moy, hueplus, huemoins, hueref, dhue, chromaref, pm, lco, lumaref, av, lp, deltE, original, transformed, cx, cy); + } else if (lp.inv && lp.cont != 0 && lp.colorena) { + + float multL = (float)lp.cont * (maxl - 1.f) / 100.f + 1.f; + float multH = (float) lp.cont * (maxh - 1.f) / 100.f + 1.f; + + lco.ah = (multH - 1.f) / (av - 100.f); //av ==> lumaref + lco.bh = 1.f - 100.f * lco.ah; + lco.al = (multL - 1.f) / av; + lco.bl = 1.f; + + InverseContrast_Local (ave, lco, lp, original, transformed, cx, cy); + } + + // } + +// end contrast interior and exterior + +//Tone mapping + +//&& lp.tonemapena + if (lp.strengt != 0.f && lp.tonemapena) { + LabImage *tmp1; + LabImage *tmp; + + LabImage *bufgb; + + if (call == 2) { //simpleprocess + int GW = transformed->W; + int GH = transformed->H; + int bfh = int (lp.ly + lp.lyT) + 1; //bfw bfh real size of square zone + int bfw = int (lp.lx + lp.lxL) + 1; + bufgb = new LabImage (bfw, bfh); + +#ifdef _OPENMP + #pragma omp parallel for +#endif + + for (int ir = 0; ir < bfh; ir++) //fill with 0 + for (int jr = 0; jr < bfw; jr++) { + bufgb->L[ir][jr] = 0.f; + bufgb->a[ir][jr] = 0.f; + bufgb->b[ir][jr] = 0.f; + } + +#ifdef _OPENMP +// #pragma omp parallel for +#endif + + for (int y = 0; y < transformed->H ; y++) //{ + for (int x = 0; x < transformed->W; x++) { + int lox = cx + x; + int loy = cy + y; + int begx = int (lp.xc - lp.lxL); + int begy = int (lp.yc - lp.lyT); + + if (lox >= (lp.xc - lp.lxL) && lox < (lp.xc + lp.lx) && loy >= (lp.yc - lp.lyT) && loy < (lp.yc + lp.ly)) { + bufgb->L[loy - begy - 1][lox - begx - 1] = original->L[y][x];//fill square buffer with datas + bufgb->a[loy - begy - 1][lox - begx - 1] = original->a[y][x];//fill square buffer with datas + bufgb->b[loy - begy - 1][lox - begx - 1] = original->b[y][x];//fill square buffer with datas + } + } + + tmp1 = new LabImage (bfw, bfh); + ImProcFunctions::EPDToneMaplocal (bufgb, tmp1, 5 , 1); + } else { + tmp = new LabImage (transformed->W, transformed->H); + tmp->CopyFrom (original); + tmp1 = new LabImage (transformed->W, transformed->H); + ImProcFunctions::EPDToneMaplocal (tmp, tmp1, 5 , sk); + delete tmp; + } + + float hueplus = hueref + dhue; + float huemoins = hueref - dhue; + + if (hueplus > M_PI) { + hueplus = hueref + dhue - 2.f * M_PI; + } + + if (huemoins < -M_PI) { + huemoins = hueref - dhue + 2.f * M_PI; + } + + + TM_Local (call, sp, tmp1, hueplus, huemoins, hueref, dhue, chromaref, lumaref, lp, deltE, original, transformed, cx, cy); + + if (call == 2) { + delete bufgb; + } + + delete tmp1; + + + } + +//begin cbdl + if (lp.mulloc[0] != 1.f || lp.mulloc[1] != 1.f || lp.mulloc[2] != 1.f || lp.mulloc[3] != 1.f || lp.mulloc[4] != 1.f && lp.cbdlena) { + int GW = original->W; + int GH = original->H; + float **bufsh;//buffer por square zone + float **loctemp; + float **hbuffer; + int bfh = int (lp.ly + lp.lyT) + 1; //bfw bfh real size of square zone + int bfw = int (lp.lx + lp.lxL) + 1; + float b_l = -5.f; + float t_l = 25.f; + float t_r = 120.f; + float b_r = 170.f; + double skinprot = 0.; + int choice = 0; + + + if (call == 2) { //call from simpleprocess + bufsh = new float*[bfh]; + + for (int i = 0; i < bfh; i++) { + bufsh[i] = new float[bfw]; + } + +#ifdef _OPENMP + #pragma omp parallel for +#endif + + for (int ir = 0; ir < bfh; ir++) //fill with 0 + for (int jr = 0; jr < bfw; jr++) { + bufsh[ir][jr] = 0.f; + } + + +#ifdef _OPENMP +// #pragma omp parallel for +#endif + + for (int y = 0; y < transformed->H ; y++) //{ + for (int x = 0; x < transformed->W; x++) { + int lox = cx + x; + int loy = cy + y; + int begx = int (lp.xc - lp.lxL); + int begy = int (lp.yc - lp.lyT); + + if (lox >= (lp.xc - lp.lxL) && lox < (lp.xc + lp.lx) && loy >= (lp.yc - lp.lyT) && loy < (lp.yc + lp.ly)) { + bufsh[loy - begy - 1][lox - begx - 1] = original->L[y][x];//fill square buffer with datas + } + } + + loctemp = new float*[bfh];//allocate temp + + for (int i = 0; i < bfh; i++) { + loctemp[i] = new float[bfw]; + } + + hbuffer = new float*[bfh];//allocate buffer for sharp + + for (int i = 0; i < bfh; i++) { + hbuffer[i] = new float[bfw]; + } + + ImProcFunctions::cbdl_local_temp (bufsh, bufsh, loctemp, bfw, bfh, lp.mulloc, lp.threshol, skinprot, false, b_l, t_l, t_r, b_r, choice, sk); + + + } else { //call from dcrop.cc + loctemp = new float*[GH];//allocate temp + + for (int i = 0; i < GH; i++) { + loctemp[i] = new float[GW]; + } + + ImProcFunctions::cbdl_local_temp (original->L, original->L, loctemp, GW, GH, lp.mulloc, lp.threshol, skinprot, false, b_l, t_l, t_r, b_r, choice, sk); + + } + + + // I initialize these variable in case of ! + float hueplus = hueref + dhue; + float huemoins = hueref - dhue; + + if (hueplus > M_PI) { + hueplus = hueref + dhue - 2.f * M_PI; + } + + if (huemoins < -M_PI) { + huemoins = hueref - dhue + 2.f * M_PI; + } + + cbdl_Local (call, sp, loctemp, hueplus, huemoins, hueref, dhue, chromaref, lumaref, lp, deltE, original, transformed, cx, cy); + + if (call == 2) { + for (int i = 0; i < bfh; i++) { + delete [] loctemp[i]; + } + + delete [] loctemp; + + for (int i = 0; i < bfh; i++) { + delete [] bufsh[i]; + } + + delete [] bufsh; + + for (int i = 0; i < bfh; i++) { + delete [] hbuffer[i]; + } + + delete [] hbuffer; + } else { + for (int i = 0; i < GH; i++) { + delete [] loctemp[i]; + } + + delete [] loctemp; + + } + + + + } + +// } + +//end cbdl + if (!lp.invshar && lp.shrad > 0.42 && call < 3 && lp.sharpena) { //interior ellipse for sharpening, call = 1 and 2 only with Dcrop and simpleprocess + + int GW = original->W; + int GH = original->H; + float **bufsh;//buffer por square zone + float **loctemp; + float **hbuffer; + int bfh = int (lp.ly + lp.lyT) + 1; //bfw bfh real size of square zone + int bfw = int (lp.lx + lp.lxL) + 1; + + if (call == 2) { //call from simpleprocess + bufsh = new float*[bfh]; + + for (int i = 0; i < bfh; i++) { + bufsh[i] = new float[bfw]; + } + +#ifdef _OPENMP + #pragma omp parallel for +#endif + + for (int ir = 0; ir < bfh; ir++) //fill with 0 + for (int jr = 0; jr < bfw; jr++) { + bufsh[ir][jr] = 0.f; + } + + +#ifdef _OPENMP +// #pragma omp parallel for +#endif + + for (int y = 0; y < transformed->H ; y++) //{ + for (int x = 0; x < transformed->W; x++) { + int lox = cx + x; + int loy = cy + y; + int begx = int (lp.xc - lp.lxL); + int begy = int (lp.yc - lp.lyT); + + if (lox >= (lp.xc - lp.lxL) && lox < (lp.xc + lp.lx) && loy >= (lp.yc - lp.lyT) && loy < (lp.yc + lp.ly)) { + bufsh[loy - begy - 1][lox - begx - 1] = original->L[y][x];//fill square buffer with datas + } + } + + loctemp = new float*[bfh];//allocate temp + + for (int i = 0; i < bfh; i++) { + loctemp[i] = new float[bfw]; + } + + hbuffer = new float*[bfh];//allocate buffer for sharp + + for (int i = 0; i < bfh; i++) { + hbuffer[i] = new float[bfw]; + } + + //sharpen only square area instaed of all image + ImProcFunctions::deconvsharpeningloc (bufsh, hbuffer, bfw, bfh, loctemp, params->locallab.shardamping, (double)params->locallab.sharradius / 100., params->locallab.shariter, params->locallab.sharamount); + } else { //call from dcrop.cc + loctemp = new float*[GH];//allocate temp + + for (int i = 0; i < GH; i++) { + loctemp[i] = new float[GW]; + } + + ImProcFunctions::deconvsharpeningloc (original->L, shbuffer, GW, GH, loctemp, params->locallab.shardamping, (double)params->locallab.sharradius / 100., params->locallab.shariter, params->locallab.sharamount); + + } + + float hueplus = hueref + dhue; + float huemoins = hueref - dhue; + + if (hueplus > M_PI) { + hueplus = hueref + dhue - 2.f * M_PI; + } + + if (huemoins < -M_PI) { + huemoins = hueref - dhue + 2.f * M_PI; + } + + //sharpen ellipse and transition + Sharp_Local (call, sp, loctemp, hueplus, huemoins, hueref, dhue, chromaref, lumaref, lp, deltE, original, transformed, cx, cy); + + //cleann all + if (call == 2 && !lp.invshar) { + for (int i = 0; i < bfh; i++) { + delete [] loctemp[i]; + } + + delete [] loctemp; + + for (int i = 0; i < bfh; i++) { + delete [] bufsh[i]; + } + + delete [] bufsh; + + for (int i = 0; i < bfh; i++) { + delete [] hbuffer[i]; + } + + delete [] hbuffer; + } else { + for (int i = 0; i < GH; i++) { + delete [] loctemp[i]; + } + + delete [] loctemp; + + } + + /* for (int i = 0; i < GH; i++) { + delete [] hbuffer[i]; + } + + delete [] hbuffer; + */ + + } else if (lp.invshar && lp.shrad > 0.42 && call < 3 && lp.sharpena) { + int GW = original->W; + int GH = original->H; + + float **loctemp = new float*[GH]; + + for (int i = 0; i < GH; i++) { + loctemp[i] = new float[GW]; + } + + ImProcFunctions::deconvsharpeningloc (original->L, shbuffer, GW, GH, loctemp, params->locallab.shardamping, (double)params->locallab.sharradius / 100., params->locallab.shariter, params->locallab.sharamount); + + float hueplus = hueref + dhue; + float huemoins = hueref - dhue; + + if (hueplus > M_PI) { + hueplus = hueref + dhue - 2.f * M_PI; + } + + if (huemoins < -M_PI) { + huemoins = hueref - dhue + 2.f * M_PI; + } + + InverseSharp_Local (sp, loctemp, hueplus, huemoins, hueref, dhue, chromaref, lumaref, lp, deltE, original, transformed, cx, cy); + + for (int i = 0; i < GH; i++) { + delete [] loctemp[i]; + } + + delete [] loctemp; + + } + + // } +//&& lp.retiena + if (lp.str > 0.f && lp.retiena) { + int GW = transformed->W; + int GH = transformed->H; + + LabImage *bufreti; + + float **loctemp; + float **hbuffer; + int bfh = int (lp.ly + lp.lyT) + 1; //bfw bfh real size of square zone + int bfw = int (lp.lx + lp.lxL) + 1; + + float hueplus = hueref + dhueret; + float huemoins = hueref - dhueret; + + if (hueplus > M_PI) { + hueplus = hueref + dhueret - 2.f * M_PI; + } + + if (huemoins < -M_PI) { + huemoins = hueref - dhueret + 2.f * M_PI; + } + + int Hd, Wd; + Hd = GH; + Wd = GW; + + if (!lp.invret && call <= 3) { + + Hd = bfh; + Wd = bfw; + bufreti = new LabImage (bfw, bfh); + + /* bufreti = new float*[bfh]; + + for (int i = 0; i < bfh; i++) { + bufreti[i] = new float[bfw]; + } + */ +#ifdef _OPENMP + #pragma omp parallel for +#endif + + for (int ir = 0; ir < bfh; ir++) //fill with 0 + for (int jr = 0; jr < bfw; jr++) { + bufreti->L[ir][jr] = 0.f; + bufreti->a[ir][jr] = 0.f; + bufreti->b[ir][jr] = 0.f; + } + + + +#ifdef _OPENMP +// #pragma omp parallel for +#endif + + for (int y = 0; y < transformed->H ; y++) //{ + for (int x = 0; x < transformed->W; x++) { + int lox = cx + x; + int loy = cy + y; + int begx = int (lp.xc - lp.lxL); + int begy = int (lp.yc - lp.lyT); + + if (lox >= (lp.xc - lp.lxL) && lox < (lp.xc + lp.lx) && loy >= (lp.yc - lp.lyT) && loy < (lp.yc + lp.ly)) { + bufreti->L[loy - begy - 1][lox - begx - 1] = original->L[y][x];//fill square buffer with datas + bufreti->a[loy - begy - 1][lox - begx - 1] = original->a[y][x];//fill square buffer with datas + bufreti->b[loy - begy - 1][lox - begx - 1] = original->b[y][x];//fill square buffer with datas + } + } + + + + } + + float *orig[Hd] ALIGNED16; + float *origBuffer = new float[Hd * Wd]; + + for (int i = 0; i < Hd; i++) { + orig[i] = &origBuffer[i * Wd]; + } + + float *orig1[Hd] ALIGNED16; + float *origBuffer1 = new float[Hd * Wd]; + + for (int i = 0; i < Hd; i++) { + orig1[i] = &origBuffer1[i * Wd]; + } + + + LabImage *tmpl; + + // LabImage *tmpl = new LabImage(Wd, Hd); + if (!lp.invret && call <= 3) { + + +#ifdef _OPENMP + #pragma omp parallel for schedule(dynamic,16) +#endif + + for (int ir = 0; ir < Hd; ir += 1) + for (int jr = 0; jr < Wd; jr += 1) { + orig[ir][jr] = bufreti->L[ir][jr]; + orig1[ir][jr] = bufreti->L[ir][jr]; + } + + tmpl = new LabImage (Wd, Hd); + + } else { +#ifdef _OPENMP + #pragma omp parallel for schedule(dynamic,16) +#endif + + for (int ir = 0; ir < Hd; ir += 1) + for (int jr = 0; jr < Wd; jr += 1) { + orig[ir][jr] = original->L[ir][jr]; + orig1[ir][jr] = transformed->L[ir][jr]; + } + + tmpl = new LabImage (transformed->W, transformed->H); + + + } + + float minCD, maxCD, mini, maxi, Tmean, Tsigma, Tmin, Tmax; + ImProcFunctions::MSRLocal (orig, tmpl->L, orig1, Wd, Hd, params->locallab, sk, locRETgainCcurve, 0, 4, 0.8f, minCD, maxCD, mini, maxi, Tmean, Tsigma, Tmin, Tmax); +#ifdef _OPENMP + #pragma omp parallel for schedule(dynamic,16) +#endif + + for (int ir = 0; ir < Hd; ir += 1) + for (int jr = 0; jr < Wd; jr += 1) { + tmpl->L[ir][jr] = orig[ir][jr]; + } + + if (!lp.invret) { + + Reti_Local (call, hueplus, huemoins, hueref, dhueret, chromaref, lumaref, lp, deltE, original, transformed, tmpl, cx, cy, 0); + } else { + InverseReti_Local (lp, original, transformed, tmpl, cx, cy, 0); + } + + if (params->locallab.chrrt > 0) { + + if (!lp.invret && call <= 3) { + +#ifdef _OPENMP + #pragma omp parallel for schedule(dynamic,16) +#endif + + for (int ir = 0; ir < Hd; ir += 1) + for (int jr = 0; jr < Wd; jr += 1) { + + orig[ir][jr] = sqrt (SQR (bufreti->a[ir][jr]) + SQR (bufreti->b[ir][jr])); + orig1[ir][jr] = sqrt (SQR (bufreti->a[ir][jr]) + SQR (bufreti->b[ir][jr])); + } + + } else { + +#ifdef _OPENMP + #pragma omp parallel for schedule(dynamic,16) +#endif + + for (int ir = 0; ir < GH; ir += 1) + for (int jr = 0; jr < GW; jr += 1) { + orig[ir][jr] = sqrt (SQR (original->a[ir][jr]) + SQR (original->b[ir][jr])); + orig1[ir][jr] = sqrt (SQR (transformed->a[ir][jr]) + SQR (transformed->b[ir][jr])); + } + } + + ImProcFunctions::MSRLocal (orig, tmpl->L, orig1, Wd, Hd, params->locallab, sk, locRETgainCcurve, 1, 4, 0.8f, minCD, maxCD, mini, maxi, Tmean, Tsigma, Tmin, Tmax); + + if (!lp.invret && call <= 3) { + +#ifdef _OPENMP + #pragma omp parallel for schedule(dynamic,16) +#endif + + for (int ir = 0; ir < Hd; ir += 1) + for (int jr = 0; jr < Wd; jr += 1) { + float Chprov = orig1[ir][jr]; + float2 sincosval; + sincosval.y = Chprov == 0.0f ? 1.f : bufreti->a[ir][jr] / Chprov; + sincosval.x = Chprov == 0.0f ? 0.f : bufreti->b[ir][jr] / Chprov; + tmpl->a[ir][jr] = orig[ir][jr] * sincosval.y; + tmpl->b[ir][jr] = orig[ir][jr] * sincosval.x; + + } + + + } else { +#ifdef _OPENMP + #pragma omp parallel for schedule(dynamic,16) +#endif + + for (int ir = 0; ir < Hd; ir += 1) + for (int jr = 0; jr < Wd; jr += 1) { + float Chprov = orig1[ir][jr]; + float2 sincosval; + sincosval.y = Chprov == 0.0f ? 1.f : transformed->a[ir][jr] / Chprov; + sincosval.x = Chprov == 0.0f ? 0.f : transformed->b[ir][jr] / Chprov; + tmpl->a[ir][jr] = orig[ir][jr] * sincosval.y; + tmpl->b[ir][jr] = orig[ir][jr] * sincosval.x; + + } + } + + if (!lp.invret) { + + Reti_Local (call, hueplus, huemoins, hueref, dhueret, chromaref, lumaref, lp, deltE, original, transformed, tmpl, cx, cy, 1); + } else { + InverseReti_Local (lp, original, transformed, tmpl, cx, cy, 1); + } + + } + + delete tmpl; + delete [] origBuffer; + delete [] origBuffer1; + + if (!lp.invret && call <= 3) { + + delete bufreti; + } + } + + +// Gamut and Munsell control - very important do not desactivated to avoid crash + if (params->locallab.avoid) { + TMatrix wiprof = iccStore->workingSpaceInverseMatrix (params->icm.working); + float wip[3][3] = { + {static_cast (wiprof[0][0]), static_cast (wiprof[0][1]), static_cast (wiprof[0][2])}, + {static_cast (wiprof[1][0]), static_cast (wiprof[1][1]), static_cast (wiprof[1][2])}, + {static_cast (wiprof[2][0]), static_cast (wiprof[2][1]), static_cast (wiprof[2][2])} + }; + const bool highlight = params->toneCurve.hrenabled; + const bool needHH = (lp.chro != 0.f); +#ifdef _OPENMP + #pragma omp parallel if (multiThread) +#endif + { +#ifdef __SSE2__ + float atan2Buffer[transformed->W] ALIGNED16; + float sqrtBuffer[transformed->W] ALIGNED16; + float sincosyBuffer[transformed->W] ALIGNED16; + float sincosxBuffer[transformed->W] ALIGNED16; + vfloat c327d68v = F2V (327.68f); + vfloat onev = F2V (1.f); +#endif + +#ifdef _OPENMP +#ifdef _DEBUG + #pragma omp for schedule(dynamic,16) firstprivate(MunsDebugInfo) +#else + #pragma omp for schedule(dynamic,16) +#endif +#endif + + for (int y = 0; y < transformed->H; y++) { +#ifdef __SSE2__ + int i = 0; + + for (; i < transformed->W - 3; i += 4) { + vfloat av = LVFU (transformed->a[y][i]); + vfloat bv = LVFU (transformed->b[y][i]); + + if (needHH) { // only do expensive atan2 calculation if needed + STVF (atan2Buffer[i], xatan2f (bv, av)); + } + + vfloat Chprov1v = vsqrtf (SQRV (bv) + SQRV (av)); + STVF (sqrtBuffer[i], Chprov1v / c327d68v); + vfloat sincosyv = av / Chprov1v; + vfloat sincosxv = bv / Chprov1v; + vmask selmask = vmaskf_eq (Chprov1v, ZEROV); + sincosyv = vself (selmask, onev, sincosyv); + sincosxv = vselfnotzero (selmask, sincosxv); + STVF (sincosyBuffer[i], sincosyv); + STVF (sincosxBuffer[i], sincosxv); + } + + for (; i < transformed->W; i++) { + float aa = transformed->a[y][i]; + float bb = transformed->b[y][i]; + + if (needHH) { // only do expensive atan2 calculation if needed + atan2Buffer[i] = xatan2f (bb, aa); + } + + float Chprov1 = sqrtf (SQR (bb) + SQR (aa)); + sqrtBuffer[i] = Chprov1 / 327.68f; + + if (Chprov1 == 0.0f) { + sincosyBuffer[i] = 1.f; + sincosxBuffer[i] = 0.0f; + } else { + sincosyBuffer[i] = aa / Chprov1; + sincosxBuffer[i] = bb / Chprov1; + } + + } + +#endif + + for (int x = 0; x < transformed->W; x++) { + float Lprov1 = transformed->L[y][x] / 327.68f; + float2 sincosval; +#ifdef __SSE2__ + float HH = atan2Buffer[x]; // reading HH from line buffer even if line buffer is not filled is faster than branching + float Chprov1 = sqrtBuffer[x]; + sincosval.y = sincosyBuffer[x]; + sincosval.x = sincosxBuffer[x]; + float chr; + +#else + float aa = transformed->a[y][x]; + float bb = transformed->b[y][x]; + float HH, chr; + + if (needHH) { // only do expensive atan2 calculation if needed + HH = xatan2f (bb, aa); + } + + float Chprov1 = sqrtf (SQR (aa) + SQR (bb)) / 327.68f; + + if (Chprov1 == 0.0f) { + sincosval.y = 1.f; + sincosval.x = 0.0f; + } else { + sincosval.y = aa / (Chprov1 * 327.68f); + sincosval.x = bb / (Chprov1 * 327.68f); + } + +#endif + +#ifdef _DEBUG + bool neg = false; + bool more_rgb = false; +// Color::pregamutlab (Lprov1, HH, chr); + Chprov1 = min (Chprov1, chr); + + Color::gamutLchonly (sincosval, Lprov1, Chprov1, wip, highlight, 0.15f, 0.92f, neg, more_rgb); +#else + Color::pregamutlab (Lprov1, HH, chr); + Chprov1 = min (Chprov1, chr); + Color::gamutLchonly (sincosval, Lprov1, Chprov1, wip, highlight, 0.15f, 0.92f); +#endif + + transformed->L[y][x] = Lprov1 * 327.68f; + transformed->a[y][x] = 327.68f * Chprov1 * sincosval.y; + transformed->b[y][x] = 327.68f * Chprov1 * sincosval.x; + + if (needHH) { + float Lprov2 = original->L[y][x] / 327.68f; + float correctionHue = 0.f; // Munsell's correction + float correctlum = 0.f; + float memChprov = sqrtf (SQR (original->a[y][x]) + SQR (original->b[y][x])) / 327.68f; + float Chprov = sqrtf (SQR (transformed->a[y][x]) + SQR (transformed->b[y][x])) / 327.68f; +#ifdef _DEBUG + Color::AllMunsellLch (true, Lprov1, Lprov2, HH, Chprov, memChprov, correctionHue, correctlum, MunsDebugInfo); +#else + Color::AllMunsellLch (true, Lprov1, Lprov2, HH, Chprov, memChprov, correctionHue, correctlum); +#endif + + if (fabs (correctionHue) < 0.015f) { + HH += correctlum; // correct only if correct Munsell chroma very little. + } + + float2 sincosval = xsincosf (HH + correctionHue); + + transformed->a[y][x] = 327.68f * Chprov * sincosval.y; // apply Munsell + transformed->b[y][x] = 327.68f * Chprov * sincosval.x; + } + } + } + } + } + + if (lp.qualmet == 1) { + + for (int i = 0; i < GH; i++) { + delete [] deltE[i]; + } + + delete [] deltE; + } + +#ifdef _DEBUG + + if (settings->verbose) { + t2e.set(); + printf ("Color::AllMunsellLch (correction performed in %d usec):\n", t2e.etime (t1e)); + // printf(" Munsell chrominance: MaxBP=%1.2frad MaxRY=%1.2frad MaxGY=%1.2frad MaxRP=%1.2frad dep=%i\n", MunsDebugInfo->maxdhue[0], MunsDebugInfo->maxdhue[1], MunsDebugInfo->maxdhue[2], MunsDebugInfo->maxdhue[3], MunsDebugInfo->depass); + // printf(" Munsell luminance : MaxBP=%1.2frad MaxRY=%1.2frad MaxGY=%1.2frad MaxRP=%1.2frad dep=%i\n", MunsDebugInfo->maxdhuelum[0], MunsDebugInfo->maxdhuelum[1], MunsDebugInfo->maxdhuelum[2], MunsDebugInfo->maxdhuelum[3], MunsDebugInfo->depassLum); + } + + delete MunsDebugInfo; +#endif + + } + +} + +} diff --git a/rtengine/ipretinex.cc b/rtengine/ipretinex.cc index 2dbdbafb1..5ae650c54 100644 --- a/rtengine/ipretinex.cc +++ b/rtengine/ipretinex.cc @@ -52,7 +52,7 @@ namespace { -void retinex_scales( float* scales, int nscales, int mode, int s, float high) +void retinex_scales ( float* scales, int nscales, int mode, int s, float high) { if ( nscales == 1 ) { scales[0] = (float)s / 2.f; @@ -67,19 +67,19 @@ void retinex_scales( float* scales, int nscales, int mode, int s, float high) scales[nscales - i - 1] = 2.0f + (float)i * size_step; } } else if (mode == 1) { - size_step = (float)log(s - 2.0f) / (float) nscales; + size_step = (float)log (s - 2.0f) / (float) nscales; for (int i = 0; i < nscales; ++i ) { scales[nscales - i - 1] = 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; + 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)); } } else if (mode == 3) { - size_step = (float) log(s - 2.0f) / (float) nscales; + size_step = (float) log (s - 2.0f) / (float) nscales; for ( int i = 0; i < nscales; ++i ) { scales[i] = high * s - (float)pow (10.f, (i * size_step) / log (10.f)); @@ -88,7 +88,7 @@ void retinex_scales( float* scales, int nscales, int mode, int s, float high) } } -void mean_stddv2( float **dst, float &mean, float &stddv, int W_L, int H_L, float &maxtr, float &mintr) +void mean_stddv2 ( float **dst, float &mean, float &stddv, int W_L, int H_L, float &maxtr, float &mintr) { // summation using double precision to avoid too large summation error for large pictures double vsquared = 0.f; @@ -125,7 +125,7 @@ void mean_stddv2( float **dst, float &mean, float &stddv, int W_L, int H_L, floa mean = sum / (double) (W_L * H_L); vsquared /= (double) W_L * H_L; stddv = ( vsquared - (mean * mean) ); - stddv = (float)sqrt(stddv); + stddv = (float)sqrt (stddv); } } @@ -136,7 +136,7 @@ namespace rtengine extern const Settings* settings; -void RawImageSource::MSR(float** luminance, float** originalLuminance, float **exLuminance, LUTf & mapcurve, bool &mapcontlutili, int width, int height, RetinexParams deh, const RetinextransmissionCurve & dehatransmissionCurve, const RetinexgaintransmissionCurve & dehagaintransmissionCurve, float &minCD, float &maxCD, float &mini, float &maxi, float &Tmean, float &Tsigma, float &Tmin, float &Tmax) +void RawImageSource::MSR (float** luminance, float** originalLuminance, float **exLuminance, LUTf & mapcurve, bool &mapcontlutili, int width, int height, RetinexParams deh, const RetinextransmissionCurve & dehatransmissionCurve, const RetinexgaintransmissionCurve & dehagaintransmissionCurve, float &minCD, float &maxCD, float &mini, float &maxi, float &Tmean, float &Tsigma, float &Tmin, float &Tmax) { if (deh.enabled) {//enabled @@ -156,7 +156,7 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e float gradstr = (float)deh.grads; float strength = (float) deh.str / 100.f; // Blend with original L channel data float limD = (float) deh.limd; - limD = pow(limD, 1.7f);//about 2500 enough + limD = pow (limD, 1.7f); //about 2500 enough limD *= useHslLin ? 10.f : 1.f; float ilimD = 1.f / limD; float hig = ((float) deh.highl) / 100.f; @@ -164,8 +164,8 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e float hl = deh.baselog; scal = deh.skal; - if(hl >= 2.71828f) { - elogt = 2.71828f + SQR(SQR(hl - 2.71828f)); + if (hl >= 2.71828f) { + elogt = 2.71828f + SQR (SQR (hl - 2.71828f)); } else { elogt = hl; } @@ -179,7 +179,7 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e elogt = 2.71828f;//disabled baselog bool lhutili = false; - FlatCurve* shcurve = new FlatCurve(deh.lhcurve); //curve L=f(H) + FlatCurve* shcurve = new FlatCurve (deh.lhcurve); //curve L=f(H) if (!shcurve || shcurve->isIdentity()) { if (shcurve) { @@ -194,7 +194,7 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e bool higplus = false ; int moderetinex = 2; // default to 2 ( deh.retinexMethod == "high" ) - if(deh.retinexMethod == "highliplus") { + if (deh.retinexMethod == "highliplus") { higplus = true; moderetinex = 3; } else if (deh.retinexMethod == "uni") { @@ -208,29 +208,29 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e constexpr float aahi = 49.f / 99.f; ////reduce sensibility 50% constexpr float bbhi = 1.f - aahi; - for(int it = 1; it < iter + 1; it++) { //iter nb max of iterations + for (int it = 1; it < iter + 1; it++) { //iter nb max of iterations float high = bbhi + aahi * (float) deh.highl; float grad = 1.f; float sc = scal; - if(gradient == 0) { + if (gradient == 0) { grad = 1.f; sc = 3.f; - } else if(gradient == 1) { + } else if (gradient == 1) { grad = 0.25f * it + 0.75f; sc = -0.5f * it + 4.5f; - } else if(gradient == 2) { + } else if (gradient == 2) { grad = 0.5f * it + 0.5f; sc = -0.75f * it + 5.75f; - } else if(gradient == 3) { + } else if (gradient == 3) { grad = 0.666f * it + 0.333f; sc = -0.75f * it + 5.75f; - } else if(gradient == 4) { + } else if (gradient == 4) { grad = 0.8f * it + 0.2f; sc = -0.75f * it + 5.75f; - } else if(gradient == 5) { - if(moderetinex != 3) { + } else if (gradient == 5) { + if (moderetinex != 3) { grad = 2.5f * it - 1.5f; } else { float aa = (11.f * high - 1.f) / 4.f; @@ -239,8 +239,8 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e } sc = -0.75f * it + 5.75f; - } else if(gradient == 6) { - if(moderetinex != 3) { + } else if (gradient == 6) { + if (moderetinex != 3) { grad = 5.f * it - 4.f; } else { float aa = (21.f * high - 1.f) / 4.f; @@ -251,24 +251,24 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e sc = -0.75f * it + 5.75f; } - else if(gradient == -1) { + else if (gradient == -1) { grad = -0.125f * it + 1.125f; sc = 3.f; } - if(iter == 1) { + if (iter == 1) { sc = scal; } else { //adjust sc in function of choice of scale by user if iterations - if(scal < 3) { + if (scal < 3) { sc -= 1; - if(sc < 1.f) {//avoid 0 + if (sc < 1.f) { //avoid 0 sc = 1.f; } } - if(scal > 4) { + if (scal > 4) { sc += 1; } } @@ -276,20 +276,20 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e float varx; float limdx, ilimdx; - if(gradvart != 0) { - if(gradvart == 1) { + if (gradvart != 0) { + if (gradvart == 1) { varx = vart * (-0.125f * it + 1.125f); limdx = limD * (-0.125f * it + 1.125f); ilimdx = 1.f / limdx; - } else if(gradvart == 2) { + } else if (gradvart == 2) { varx = vart * (-0.2f * it + 1.2f); limdx = limD * (-0.2f * it + 1.2f); ilimdx = 1.f / limdx; - } else if(gradvart == -1) { + } else if (gradvart == -1) { varx = vart * (0.125f * it + 0.875f); limdx = limD * (0.125f * it + 0.875f); ilimdx = 1.f / limdx; - } else if(gradvart == -2) { + } else if (gradvart == -2) { varx = vart * (0.4f * it + 0.6f); limdx = limD * (0.4f * it + 0.6f); ilimdx = 1.f / limdx; @@ -300,30 +300,30 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e ilimdx = ilimD; } - scal = round(sc); + scal = round (sc); float ks = 1.f; - if(gradstr != 0) { - if(gradstr == 1) { - if(it <= 3) { + if (gradstr != 0) { + if (gradstr == 1) { + if (it <= 3) { ks = -0.3f * it + 1.6f; } else { ks = 0.5f; } - } else if(gradstr == 2) { - if(it <= 3) { + } else if (gradstr == 2) { + if (it <= 3) { ks = -0.6f * it + 2.2f; } else { ks = 0.3f; } - } else if(gradstr == -1) { - if(it <= 3) { + } else if (gradstr == -1) { + if (it <= 3) { ks = 0.2f * it + 0.6f; } else { ks = 1.2f; } - } else if(gradstr == -2) { - if(it <= 3) { + } else if (gradstr == -2) { + if (it <= 3) { ks = 0.4f * it + 0.2f; } else { ks = 1.5f; @@ -336,7 +336,7 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e constexpr auto maxRetinexScales = 8; float RetinexScales[maxRetinexScales]; - retinex_scales( RetinexScales, scal, moderetinex, nei / grad, high ); + retinex_scales ( RetinexScales, scal, moderetinex, nei / grad, high ); float *src[H_L] ALIGNED16; float *srcBuffer = new float[H_L * W_L]; @@ -352,11 +352,11 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e int mapmet = 0; - if(deh.mapMethod == "map") { + if (deh.mapMethod == "map") { mapmet = 2; - } else if(deh.mapMethod == "mapT") { + } else if (deh.mapMethod == "mapT") { mapmet = 3; - } else if(deh.mapMethod == "gaus") { + } else if (deh.mapMethod == "gaus") { mapmet = 4; } @@ -364,13 +364,13 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e int viewmet = 0; - if(deh.viewMethod == "mask") { + if (deh.viewMethod == "mask") { viewmet = 1; - } else if(deh.viewMethod == "tran") { + } else if (deh.viewMethod == "tran") { viewmet = 2; - } else if(deh.viewMethod == "tran2") { + } else if (deh.viewMethod == "tran2") { viewmet = 3; - } else if(deh.viewMethod == "unsharp") { + } else if (deh.viewMethod == "unsharp") { viewmet = 4; } @@ -391,7 +391,7 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e out[i] = &outBuffer[i * W_L]; } - if(viewmet == 3 || viewmet == 2) { + if (viewmet == 3 || viewmet == 2) { tranBuffer = new float[H_L * W_L]; for (int i = 0; i < H_L; i++) { @@ -399,11 +399,11 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e } } - const float logBetaGain = xlogf(16384.f); + const float logBetaGain = xlogf (16384.f); float pond = logBetaGain / (float) scal; - if(!useHslLin) { - pond /= log(elogt); + if (!useHslLin) { + pond /= log (elogt); } auto shmap = ((mapmet == 2 || mapmet == 3 || mapmet == 4) && it == 1) ? new SHMap (W_L, H_L, true) : nullptr; @@ -415,12 +415,12 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e #pragma omp parallel #endif { - if(scale == scal - 1) + if (scale == scal - 1) { gaussianBlur (src, out, W_L, H_L, RetinexScales[scale], buffer); } else { // reuse result of last iteration // out was modified in last iteration => restore it - if((((mapmet == 2 && scale > 1) || mapmet == 3 || mapmet == 4) || (mapmet > 0 && mapcontlutili)) && it == 1) + if ((((mapmet == 2 && scale > 1) || mapmet == 3 || mapmet == 4) || (mapmet > 0 && mapcontlutili)) && it == 1) { #ifdef _OPENMP #pragma omp for @@ -433,9 +433,9 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e } } - gaussianBlur (out, out, W_L, H_L, sqrtf(SQR(RetinexScales[scale]) - SQR(RetinexScales[scale + 1])), buffer); + gaussianBlur (out, out, W_L, H_L, sqrtf (SQR (RetinexScales[scale]) - SQR (RetinexScales[scale + 1])), buffer); } - if((((mapmet == 2 && scale > 2) || mapmet == 3 || mapmet == 4) || (mapmet > 0 && mapcontlutili)) && it == 1 && scale > 0) + if ((((mapmet == 2 && scale > 2) || mapmet == 3 || mapmet == 4) || (mapmet > 0 && mapcontlutili)) && it == 1 && scale > 0) { // out will be modified => store it for use in next iteration. We even don't need a new buffer because 'buffer' is free after gaussianBlur :) #ifdef _OPENMP @@ -450,20 +450,20 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e } } - if(((mapmet == 2 && scale > 2) || mapmet == 3 || mapmet == 4) && it == 1) { + if (((mapmet == 2 && scale > 2) || mapmet == 3 || mapmet == 4) && it == 1) { shmap->updateL (out, shradius, true, 1); h_th = shmap->max_f - deh.htonalwidth * (shmap->max_f - shmap->avg) / 100; s_th = deh.stonalwidth * (shmap->avg - shmap->min_f) / 100; } #ifdef __SSE2__ - vfloat pondv = F2V(pond); - vfloat limMinv = F2V(ilimdx); - vfloat limMaxv = F2V(limdx); + vfloat pondv = F2V (pond); + vfloat limMinv = F2V (ilimdx); + vfloat limMaxv = F2V (limdx); #endif - if(mapmet > 0 && mapcontlutili && it == 1) { + if (mapmet > 0 && mapcontlutili && it == 1) { // TODO: When rgbcurvespeedup branch is merged into master we can simplify the code by // 1) in rawimagesource.retinexPrepareCurves() insert // mapcurve *= 0.5f; @@ -482,7 +482,7 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e } - if(((mapmet == 2 && scale > 2) || mapmet == 3 || mapmet == 4) && it == 1) { + if (((mapmet == 2 && scale > 2) || mapmet == 3 || mapmet == 4) && it == 1) { float hWeight = (100.f - shHighlights) / 100.f; float sWeight = (100.f - shShadows) / 100.f; #ifdef _OPENMP @@ -515,32 +515,32 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e #ifdef __SSE2__ - if(useHslLin) { + if (useHslLin) { for (; j < W_L - 3; j += 4) { - _mm_storeu_ps(&luminance[i][j], LVFU(luminance[i][j]) + pondv * (LIMV(LVFU(src[i][j]) / LVFU(out[i][j]), limMinv, limMaxv) )); + _mm_storeu_ps (&luminance[i][j], LVFU (luminance[i][j]) + pondv * (LIMV (LVFU (src[i][j]) / LVFU (out[i][j]), limMinv, limMaxv) )); } } else { for (; j < W_L - 3; j += 4) { - _mm_storeu_ps(&luminance[i][j], LVFU(luminance[i][j]) + pondv * xlogf(LIMV(LVFU(src[i][j]) / LVFU(out[i][j]), limMinv, limMaxv) )); + _mm_storeu_ps (&luminance[i][j], LVFU (luminance[i][j]) + pondv * xlogf (LIMV (LVFU (src[i][j]) / LVFU (out[i][j]), limMinv, limMaxv) )); } } #endif - if(useHslLin) { + if (useHslLin) { for (; j < W_L; j++) { - luminance[i][j] += pond * (LIM(src[i][j] / out[i][j], ilimdx, limdx)); + luminance[i][j] += pond * (LIM (src[i][j] / out[i][j], ilimdx, limdx)); } } else { for (; j < W_L; j++) { - luminance[i][j] += pond * xlogf(LIM(src[i][j] / out[i][j], ilimdx, limdx)); // /logt ? + luminance[i][j] += pond * xlogf (LIM (src[i][j] / out[i][j], ilimdx, limdx)); // /logt ? } } } } - if(mapmet > 1) { - if(shmap) { + if (mapmet > 1) { + if (shmap) { delete shmap; } } @@ -554,7 +554,7 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e float stddv = 0.f; // I call mean_stddv2 instead of mean_stddv ==> logBetaGain - mean_stddv2( luminance, mean, stddv, W_L, H_L, maxtr, mintr); + mean_stddv2 ( luminance, mean, stddv, W_L, H_L, maxtr, mintr); //printf("mean=%f std=%f delta=%f maxtr=%f mintr=%f\n", mean, stddv, delta, maxtr, mintr); //mean_stddv( luminance, mean, stddv, W_L, H_L, logBetaGain, maxtr, mintr); @@ -584,7 +584,7 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e for (int i = 0; i < H_L; i++ ) for (int j = 0; j < W_L; j++) { //for mintr to maxtr evalate absciss in function of original transmission - if (LIKELY(fabsf(luminance[i][j] - mean) < stddv)) { + if (LIKELY (fabsf (luminance[i][j] - mean) < stddv)) { absciss = asig * luminance[i][j] + bsig; } else if (luminance[i][j] >= mean) { absciss = amax * luminance[i][j] + bmax; @@ -595,7 +595,7 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e //TODO : move multiplication by 4.f and subtraction of 1.f inside the curve luminance[i][j] *= (-1.f + 4.f * dehatransmissionCurve[absciss]); //new transmission - if(viewmet == 3 || viewmet == 2) { + if (viewmet == 3 || viewmet == 2) { tran[i][j] = luminance[i][j]; } } @@ -619,7 +619,7 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e for (int i = borderL; i < hei - borderL; i++) { for (int j = borderL; j < wid - borderL; j++) { - tmL[i][j] = median(luminance[i][j], luminance[i - 1][j], luminance[i + 1][j], luminance[i][j + 1], luminance[i][j - 1], luminance[i - 1][j - 1], luminance[i - 1][j + 1], luminance[i + 1][j - 1], luminance[i + 1][j + 1]); //3x3 + tmL[i][j] = median (luminance[i][j], luminance[i - 1][j], luminance[i + 1][j], luminance[i][j + 1], luminance[i][j - 1], luminance[i - 1][j - 1], luminance[i - 1][j + 1], luminance[i + 1][j - 1], luminance[i + 1][j + 1]); //3x3 } } @@ -639,7 +639,7 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e // I call mean_stddv2 instead of mean_stddv ==> logBetaGain //mean_stddv( luminance, mean, stddv, W_L, H_L, 1.f, maxtr, mintr); - mean_stddv2( luminance, mean, stddv, W_L, H_L, maxtr, mintr); + mean_stddv2 ( luminance, mean, stddv, W_L, H_L, maxtr, mintr); } @@ -689,7 +689,7 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e stddv = 0.f; // I call mean_stddv2 instead of mean_stddv ==> logBetaGain - mean_stddv2( luminance, mean, stddv, W_L, H_L, maxtr, mintr); + mean_stddv2 ( luminance, mean, stddv, W_L, H_L, maxtr, mintr); float asig = 0.f, bsig = 0.f, amax = 0.f, bmax = 0.f, amin = 0.f, bmin = 0.f; if (dehagaintransmissionCurve && mean != 0.f && stddv != 0.f) { //if curve @@ -724,7 +724,7 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e if (dehagaintransmissionCurve && mean != 0.f && stddv != 0.f) { float absciss; - if (LIKELY(fabsf(luminance[i][j] - mean) < stddv)) { + if (LIKELY (fabsf (luminance[i][j] - mean) < stddv)) { absciss = asig * luminance[i][j] + bsig; } else if (luminance[i][j] >= mean) { absciss = amax * luminance[i][j] + bmax; @@ -747,33 +747,33 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e float str = strengthx; - if(lhutili && it == 1) { // S=f(H) + if (lhutili && it == 1) { // S=f(H) { float HH = exLuminance[i][j]; float valparam; - if(useHsl || useHslLin) { - valparam = float((shcurve->getVal(HH) - 0.5f)); + if (useHsl || useHslLin) { + valparam = float ((shcurve->getVal (HH) - 0.5f)); } else { - valparam = float((shcurve->getVal(Color::huelab_to_huehsv2(HH)) - 0.5f)); + valparam = float ((shcurve->getVal (Color::huelab_to_huehsv2 (HH)) - 0.5f)); } str *= (1.f + 2.f * valparam); } } - if(higplus && exLuminance[i][j] > 65535.f * hig) { + if (higplus && exLuminance[i][j] > 65535.f * hig) { str *= hig; } - if(viewmet == 0) { - luminance[i][j] = intp(str, clipretinex( cd, 0.f, 32768.f ), originalLuminance[i][j]); - } else if(viewmet == 1) { + if (viewmet == 0) { + luminance[i][j] = intp (str, clipretinex ( cd, 0.f, 32768.f ), originalLuminance[i][j]); + } else if (viewmet == 1) { luminance[i][j] = out[i][j]; - } else if(viewmet == 4) { + } else if (viewmet == 4) { luminance[i][j] = originalLuminance[i][j] + str * (originalLuminance[i][j] - out[i][j]);//unsharp - } else if(viewmet == 2) { - if(tran[i][j] <= mean) { + } else if (viewmet == 2) { + if (tran[i][j] <= mean) { luminance[i][j] = azb + aza * tran[i][j]; //auto values } else { luminance[i][j] = bzb + bza * tran[i][j]; @@ -808,11 +808,444 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e } } - if(tranBuffer) { + if (tranBuffer) { delete [] tranBuffer; } } } +void ImProcFunctions::MSRLocal (float** luminance, float** templ, const float* const *originalLuminance, const int width, const int height, const LocallabParams &loc, const int skip, const LocretigainCurve &locRETgainCcurve, const int chrome, const int scall, const float krad, float &minCD, float &maxCD, float &mini, float &maxi, float &Tmean, float &Tsigma, float &Tmin, float &Tmax) +{ + BENCHFUN + bool py = true; + + if (py) {//enabled + float mean, stddv, maxtr, mintr; + float delta; + constexpr float eps = 2.f; + constexpr bool useHsl = false; //never used + constexpr bool useHslLin = false;//never used + const float offse = 0.f; //loc.offs; + const float chrT = (float) (loc.chrrt) / 100.f; + const int scal = scall;//3;//loc.scale;; + const float vart = loc.vart / 100.f;//variance + const float strength = loc.str / 100.f; // Blend with original L channel data + float limD = 10.f;//(float) loc.limd; + limD = pow (limD, 1.7f); //about 2500 enough + //limD *= useHslLin ? 10.f : 1.f; + float ilimD = 1.f / limD; + const float elogt = 2.71828f; + + //empirical skip evaluation : very difficult because quasi all parameters interfere + //to test on several images + int nei = (int) (krad * loc.neigh); + + if (skip >= 4) { + nei = (int) (0.1f * nei + 2.f); //not too bad + } else if (skip > 1 && skip < 4) { + nei = (int) (0.3f * nei + 2.f); + } + + int moderetinex; + + if (loc.retinexMethod == "uni") { + moderetinex = 0; + } else if (loc.retinexMethod == "low") { + moderetinex = 1; + } else { + if (loc.retinexMethod == "high") { // default to 2 ( deh.retinexMethod == "high" ) + moderetinex = 2; + } + } + + const float high = 0.f; // Dummy to pass to retinex_scales(...) + + constexpr auto maxRetinexScales = 8; + float RetinexScales[maxRetinexScales]; + + retinex_scales ( RetinexScales, scal, moderetinex, nei, high ); + + + const int H_L = height; + const int W_L = width; + float *src[H_L] ALIGNED16; + float *srcBuffer = new float[H_L * W_L]; + + for (int i = 0; i < H_L; i++) { + src[i] = &srcBuffer[i * W_L]; + } + + float hi = 0.f; + float lo = 0.f; + const float shHighlights = (100.f - 0.f) / 100.f; //loc.highlights + const float shShadows = (100.f - 0.f) / 100.f; //loc.shadows + const int mapmet = (hi > 0 || lo > 0) ? 4 : 0; + // const double shradius = mapmet == 4 ? loc.radius : 40.; + const double shradius = mapmet == 4 ? 40 : 40.; + constexpr int it = 1;//in case of !! + +#ifdef _OPENMP + #pragma omp parallel for +#endif + + for (int i = 0; i < H_L; i++) + for (int j = 0; j < W_L; j++) { + src[i][j] = luminance[i][j] + eps; + luminance[i][j] = 0.f; + } + + float *out[H_L] ALIGNED16; + float *outBuffer = new float[H_L * W_L]; + + for (int i = 0; i < H_L; i++) { + out[i] = &outBuffer[i * W_L]; + } + + const float logBetaGain = xlogf (16384.f); + float pond = logBetaGain / (float) scal; + + if (!useHslLin) { + pond /= log (elogt); + } + + auto shmap = mapmet == 4 ? new SHMap (W_L, H_L, true) : nullptr; + + float *buffer = new float[W_L * H_L]; + + for ( int scale = scal - 1; scale >= 0; scale-- ) { +#ifdef _OPENMP + #pragma omp parallel +#endif + { + + if (scale == scal - 1) + { + gaussianBlur (src, out, W_L, H_L, RetinexScales[scale], buffer); + } else { // reuse result of last iteration + // out was modified in last iteration => restore it + if (((mapmet == 4)) && it == 1) + { + +#ifdef _OPENMP + #pragma omp for +#endif + + for (int i = 0; i < H_L; i++) { + for (int j = 0; j < W_L; j++) { + out[i][j] = buffer[i * W_L + j]; + } + } + } + + gaussianBlur (out, out, W_L, H_L, sqrtf (SQR (RetinexScales[scale]) - SQR (RetinexScales[scale + 1])), buffer); + } + if ((mapmet == 4) && it == 1 && scale > 0) + { + // out will be modified => store it for use in next iteration. We even don't need a new buffer because 'buffer' is free after gaussianBlur :) +#ifdef _OPENMP + #pragma omp for +#endif + + for (int i = 0; i < H_L; i++) { + for (int j = 0; j < W_L; j++) { + buffer[i * W_L + j] = out[i][j]; + } + } + } + } + + float h_th, s_th; + float h_thcomp, s_thcomp; + + if ((mapmet == 4) && it == 1) { + shmap->updateL (out, shradius, true, 1); + h_thcomp = 0.f;//shmap->max_f - loc.htonalwidth * (shmap->max_f - shmap->avg) / 100.f; + h_th = h_thcomp - (shHighlights * h_thcomp); + s_thcomp = 0.f;//loc.stonalwidth * (shmap->avg - shmap->min_f) / 100.f; + s_th = s_thcomp - (shShadows * s_thcomp); + } + + if ((mapmet == 4) && it == 1) { + +#ifdef _OPENMP + #pragma omp parallel for schedule(dynamic,16) +#endif + + for (int i = 0; i < H_L; i++) { + for (int j = 0; j < W_L; j++) { + float mapval = 1.f + shmap->map[i][j]; + + if (mapval > h_thcomp) { + out[i][j] *= h_th / mapval + shHighlights; + } else if (mapval < s_thcomp) { + out[i][j] *= s_th / mapval + shShadows; + } + } + } + + } + +#ifdef __SSE2__ + vfloat pondv = F2V (pond); + vfloat limMinv = F2V (ilimD); + vfloat limMaxv = F2V (limD); + +#endif +#ifdef _OPENMP + #pragma omp parallel for +#endif + + for (int i = 0; i < H_L; i++) { + int j = 0; + +#ifdef __SSE2__ + + if (useHslLin) { //keep in case of ?? + for (; j < W_L - 3; j += 4) { + _mm_storeu_ps (&luminance[i][j], LVFU (luminance[i][j]) + pondv * (LIMV (LVFU (src[i][j]) / LVFU (out[i][j]), limMinv, limMaxv) )); + } + } else {//always Lab mode due to Wavelet + for (; j < W_L - 3; j += 4) { + _mm_storeu_ps (&luminance[i][j], LVFU (luminance[i][j]) + pondv * xlogf (LIMV (LVFU (src[i][j]) / LVFU (out[i][j]), limMinv, limMaxv) )); + } + } + +#endif + + if (useHslLin) { + for (; j < W_L; j++) { + luminance[i][j] += pond * (LIM (src[i][j] / out[i][j], ilimD, limD)); + } + } else { + for (; j < W_L; j++) { + luminance[i][j] += pond * xlogf (LIM (src[i][j] / out[i][j], ilimD, limD)); // /logt ? + } + } + } + } + + if (shmap) { + delete shmap; + } + + shmap = nullptr; + + delete [] buffer; + delete [] outBuffer; + outBuffer = nullptr; + delete [] srcBuffer; + + mean = 0.f; + stddv = 0.f; + + mean_stddv2 ( luminance, mean, stddv, W_L, H_L, maxtr, mintr); + //printf("mean=%f std=%f delta=%f maxtr=%f mintr=%f\n", mean, stddv, delta, maxtr, mintr); + + // mean_stddv( luminance, mean, stddv, W_L, H_L, logBetaGain, maxtr, mintr); + + bool retcurve = false;//wavRETCcurve + + if (retcurve && mean != 0.f && stddv != 0.f) { //if curve + float asig = 0.166666f / stddv; + float bsig = 0.5f - asig * mean; + float amax = 0.333333f / (maxtr - mean - stddv); + float bmax = 1.f - amax * maxtr; + float amin = 0.333333f / (mean - stddv - mintr); + float bmin = -amin * mintr; + + asig *= 500.f; + bsig *= 500.f; + amax *= 500.f; + bmax *= 500.f; + amin *= 500.f; + bmin *= 500.f; + +#ifdef _OPENMP + #pragma omp parallel for schedule(dynamic,16) +#endif + + for (int i = 0; i < H_L; i++ ) + for (int j = 0; j < W_L; j++) { //for mintr to maxtr evalate absciss in function of original transmission + float absciss; + + if (LIKELY (fabsf (luminance[i][j] - mean) < stddv)) { + absciss = asig * luminance[i][j] + bsig; + } else if (luminance[i][j] >= mean) { + absciss = amax * luminance[i][j] + bmax; + } else { + absciss = amin * luminance[i][j] + bmin; + } + + // luminance[i][j] *= (-1.f + 4.f * wavRETCcurve[absciss]); //new transmission + } + + // median filter on transmission ==> reduce artifacts + bool ty = false; + + if (ty) {//not used here to simplify interface + int wid = W_L; + int hei = H_L; + float *tmL[hei] ALIGNED16; + float *tmLBuffer = new float[wid * hei]; + int borderL = 1; + + for (int i = 0; i < hei; i++) { + tmL[i] = &tmLBuffer[i * wid]; + } + +#ifdef _OPENMP + #pragma omp parallel for +#endif + + for (int i = borderL; i < hei - borderL; i++) { + float pp[9], temp; + + for (int j = borderL; j < wid - borderL; j++) { + tmL[i][j] = median (luminance[i][j], luminance[i - 1][j], luminance[i + 1][j], luminance[i][j + 1], luminance[i][j - 1], luminance[i - 1][j - 1], luminance[i - 1][j + 1], luminance[i + 1][j - 1], luminance[i + 1][j + 1]); //3x3 + } + } + +#ifdef _OPENMP + #pragma omp parallel for +#endif + + for (int i = borderL; i < hei - borderL; i++ ) { + for (int j = borderL; j < wid - borderL; j++) { + luminance[i][j] = tmL[i][j]; + } + } + + delete [] tmLBuffer; + + } + + // I call mean_stddv2 instead of mean_stddv ==> logBetaGain + // mean_stddv( luminance, mean, stddv, W_L, H_L, 1.f, maxtr, mintr); + mean_stddv2 ( luminance, mean, stddv, W_L, H_L, maxtr, mintr); + + } + + float epsil = 0.1f; + + mini = mean - vart * stddv; + + if (mini < mintr) { + mini = mintr + epsil; + } + + maxi = mean + vart * stddv; + + if (maxi > maxtr) { + maxi = maxtr - epsil; + } + + delta = maxi - mini; + //printf("maxi=%f mini=%f mean=%f std=%f delta=%f maxtr=%f mintr=%f\n", maxi, mini, mean, stddv, delta, maxtr, mintr); + + if ( !delta ) { + delta = 1.0f; + } + + float cdfactor = 32768.f / delta; + maxCD = -9999999.f; + minCD = 9999999.f; + + //prepare work for curve gain +#ifdef _OPENMP + #pragma omp parallel for +#endif + + for (int i = 0; i < H_L; i++) { + for (int j = 0; j < W_L; j++) { + luminance[i][j] = luminance[i][j] - mini; + } + } + + mean = 0.f; + stddv = 0.f; + // I call mean_stddv2 instead of mean_stddv ==> logBetaGain + + mean_stddv2 ( luminance, mean, stddv, W_L, H_L, maxtr, mintr); + float asig, bsig, amax, bmax, amin, bmin; + // bool gaincurve = false; //wavRETgainCcurve + const bool hasWavRetGainCurve = locRETgainCcurve && mean != 0.f && stddv != 0.f; + + if (hasWavRetGainCurve) { //if curve + asig = 0.166666f / stddv; + bsig = 0.5f - asig * mean; + amax = 0.333333f / (maxtr - mean - stddv); + bmax = 1.f - amax * maxtr; + amin = 0.333333f / (mean - stddv - mintr); + bmin = -amin * mintr; + + asig *= 500.f; + bsig *= 500.f; + amax *= 500.f; + bmax *= 500.f; + amin *= 500.f; + bmin *= 500.f; + cdfactor *= 2.f; + } + + + const float maxclip = (chrome == 0 ? 32768.f : 50000.f); + float str = strength * (chrome == 0 ? 1.f : chrT); +#ifdef _OPENMP + #pragma omp parallel +#endif + { + // float absciss; + float cdmax = -999999.f, cdmin = 999999.f; + float gan = 0.5f; +#ifdef _OPENMP + #pragma omp for schedule(dynamic,16) +#endif + + for ( int i = 0; i < H_L; i ++ ) + for (int j = 0; j < W_L; j++) { + if (hasWavRetGainCurve) { + float absciss; + + if (LIKELY (fabsf (luminance[i][j] - mean) < stddv)) { + absciss = asig * luminance[i][j] + bsig; + } else if (luminance[i][j] >= mean) { + absciss = amax * luminance[i][j] + bmax; + } else { + absciss = amin * luminance[i][j] + bmin; + } + + gan = locRETgainCcurve[absciss]; //new gain function transmission + } + + float cd = gan * cdfactor * luminance[i][j] + offse; + + cdmax = cd > cdmax ? cd : cdmax; + cdmin = cd < cdmin ? cd : cdmin; + luminance[i][j] = LIM ( cd, 0.f, maxclip ) * str + (1.f - str) * originalLuminance[i][j]; + // templ[i][j] = LIM( cd, 0.f, maxclip ) * str + (1.f - str) * originalLuminance[i][j]; + // luminance[i][j] = LIM( cd, 0.f, maxclip ); + } + +#ifdef _OPENMP + #pragma omp critical +#endif + { + maxCD = maxCD > cdmax ? maxCD : cdmax; + minCD = minCD < cdmin ? minCD : cdmin; + } + + } + + Tmean = mean; + Tsigma = stddv; + Tmin = mintr; + Tmax = maxtr; + + + } + + + } +} \ No newline at end of file diff --git a/rtengine/ipsharpen.cc b/rtengine/ipsharpen.cc index c1a2f479e..56905ae70 100644 --- a/rtengine/ipsharpen.cc +++ b/rtengine/ipsharpen.cc @@ -23,6 +23,10 @@ #include "rt_math.h" #include "sleef.c" #include "opthelper.h" + +//#define BENCHMARK +//#include "StopWatch.h" + using namespace std; namespace rtengine @@ -114,7 +118,7 @@ void ImProcFunctions::deconvsharpening (float** luminance, float** tmp, int W, i float damping = sharpenParam.deconvdamping / 5.0; bool needdamp = sharpenParam.deconvdamping > 0; double sigma = sharpenParam.deconvradius / scale; - + // printf("sigma=%f \n", sigma); #ifdef _OPENMP #pragma omp parallel #endif @@ -150,6 +154,76 @@ void ImProcFunctions::deconvsharpening (float** luminance, float** tmp, int W, i } +void ImProcFunctions::deconvsharpeningloc (float** luminance, float** tmp, int W, int H, float** loctemp, int damp, double radi, int ite, int amo) +{ + // BENCHFUN + + if (amo < 1) { + return; + } + + float *tmpI[H] ALIGNED16; + + tmpI[0] = new float[W * H]; + + for (int i = 1; i < H; i++) { + tmpI[i] = tmpI[i - 1] + W; + } + + for (int i = 0; i < H; i++) { + for(int j = 0; j < W; j++) { + tmpI[i][j] = luminance[i][j]; + } + } + + float damping = (float) damp / 5.0; + bool needdamp = damp > 0; + double sigma = radi / scale; + + if(sigma < 0.26f) { + sigma = 0.26f; + } + + int itera = ite; + // printf("OK 2 damp=%f sigam=%f iter=%i\n", damping, sigma, itera); + +#ifdef _OPENMP + #pragma omp parallel +#endif + { + for (int k = 0; k < itera; k++) { + if (!needdamp) { + // apply gaussian blur and divide luminance by result of gaussian blur + gaussianBlur (tmpI, tmp, W, H, sigma, nullptr, GAUSS_DIV, luminance); + } else { + // apply gaussian blur + damping + gaussianBlur (tmpI, tmp, W, H, sigma); + dcdamping (tmp, luminance, damping, W, H); + } + + gaussianBlur (tmp, tmpI, W, H, sigma, nullptr, GAUSS_MULT); + } // end for + + float p2 = (float) amo / 100.0; + float p1 = 1.0 - p2; + +#ifdef _OPENMP + #pragma omp for +#endif + + for (int i = 0; i < H; i++) + for (int j = 0; j < W; j++) { + loctemp[i][j] = luminance[i][j] * p1 + max(tmpI[i][j], 0.0f) * p2; + } + } // end parallel + + delete [] tmpI[0]; + +} + + + + void ImProcFunctions::sharpening (LabImage* lab, float** b2, SharpeningParams &sharpenParam) { diff --git a/rtengine/procevents.h b/rtengine/procevents.h index 52517e527..3388b10f0 100644 --- a/rtengine/procevents.h +++ b/rtengine/procevents.h @@ -470,8 +470,75 @@ enum ProcEvent { EvRetinexgaintransmission = 440, EvLskal = 441, EvOBPCompens = 442, + EvlocallabEnabled = 443, + EvlocallablocY = 444, + EvlocallablocX = 445, + EvlocallabCenter = 446, + EvlocallabDegree = 447, + Evlocallablightness = 448, + Evlocallabcontrast = 449, + Evlocallabchroma = 450, + Evlocallabtransit = 451, + Evlocallabavoid = 452, + EvlocallablocYT = 453, + EvlocallablocXL = 454, + EvlocallabSmet = 455, + Evlocallabinvers = 456, + Evlocallabradius = 457, + Evlocallabinversrad = 458, + Evlocallabstrength = 459, + Evlocallabsensi = 460, + EvlocallabretinexMethod = 461, + Evlocallabstr = 462, + Evlocallabneigh = 463, + Evlocallabvart = 464, + EvlocallabCTgainCurve = 465, + Evlocallabchrrt = 466, + Evlocallabinversret = 467, + Evlocallabsensih = 468, + Evlocallabnbspot = 469, + Evlocallabactivlum = 470, + Evlocallabanbspot = 471, + Evlocallabsharradius = 472, + Evlocallabsharamount = 473, + Evlocallabshardamping = 474, + Evlocallabshariter = 475, + Evlocallabsensis = 476, + Evlocallabinverssha = 477, + Evlocallabcircrad = 478, + Evlocallabthres = 479, + Evlocallabproxi = 480, + EvlocallabqualityMethod = 481, + Evlocallabnoiselumf = 482, + Evlocallabnoiselumc = 483, + Evlocallabnoisechrof = 484, + Evlocallabnoisechroc = 485, + EvlocallabThresho = 486, + EvlocallabEqualizer = 487, + Evlocallabsensicb = 488, + Evlocallabsensibn = 489, + Evlocallabstren = 490, + Evlocallabgamma = 491, + Evlocallabestop = 492, + Evlocallabscaltm = 493, + Evlocallabrewei = 494, + Evlocallabsensitm = 495, + EvlocallabCTgainCurverab = 496, + Evlocallabretrab = 497, + Evlocallabllshape = 498, + EvLocenacolor = 499, + EvLocenablur = 500, + EvLocenatonemap = 501, + EvLocenareti = 502, + EvLocenasharp = 503, + EvLocenacbdl = 504, + EvLocenadenoi = 505, + EvlocallabLHshape = 506, + Evlocallabcurvactiv = 507, + NUMOFEVENTS + }; } #endif diff --git a/rtengine/procparams.cc b/rtengine/procparams.cc index 1ac3cbed2..568f2ecc6 100644 --- a/rtengine/procparams.cc +++ b/rtengine/procparams.cc @@ -46,11 +46,11 @@ const char *RAWParams::XTransSensor::methodstring[RAWParams::XTransSensor::numMe const char *RAWParams::ff_BlurTypestring[RAWParams::numFlatFileBlurTypes] = {/*"Parametric",*/ "Area Flatfield", "Vertical Flatfield", "Horizontal Flatfield", "V+H Flatfield"}; std::vector WBParams::wbEntries; -bool ToneCurveParams::HLReconstructionNecessary(LUTu &histRedRaw, LUTu &histGreenRaw, LUTu &histBlueRaw) +bool ToneCurveParams::HLReconstructionNecessary (LUTu &histRedRaw, LUTu &histGreenRaw, LUTu &histBlueRaw) { if (options.rtSettings.verbose) - printf("histRedRaw[ 0]=%07d, histGreenRaw[ 0]=%07d, histBlueRaw[ 0]=%07d\nhistRedRaw[255]=%07d, histGreenRaw[255]=%07d, histBlueRaw[255]=%07d\n", - histRedRaw[0], histGreenRaw[0], histBlueRaw[0], histRedRaw[255], histGreenRaw[255], histBlueRaw[255]); + printf ("histRedRaw[ 0]=%07d, histGreenRaw[ 0]=%07d, histBlueRaw[ 0]=%07d\nhistRedRaw[255]=%07d, histGreenRaw[255]=%07d, histBlueRaw[255]=%07d\n", + histRedRaw[0], histGreenRaw[0], histBlueRaw[0], histRedRaw[255], histGreenRaw[255], histBlueRaw[255]); return histRedRaw[255] > 50 || histGreenRaw[255] > 50 || histBlueRaw[255] > 50 || histRedRaw[0] > 50 || histGreenRaw[0] > 50 || histBlueRaw[0] > 50; } @@ -58,40 +58,40 @@ bool ToneCurveParams::HLReconstructionNecessary(LUTu &histRedRaw, LUTu &histGree void WBParams::init() { // Creation of the different methods and its associated temperature value - wbEntries.push_back(new WBEntry("Camera" , WBT_CAMERA, M("TP_WBALANCE_CAMERA"), 0, 1.f, 1.f)); - wbEntries.push_back(new WBEntry("Auto" , WBT_AUTO, M("TP_WBALANCE_AUTO"), 0, 1.f, 1.f)); - wbEntries.push_back(new WBEntry("Daylight" , WBT_DAYLIGHT, M("TP_WBALANCE_DAYLIGHT"), 5300, 1.f, 1.f)); - wbEntries.push_back(new WBEntry("Cloudy" , WBT_CLOUDY, M("TP_WBALANCE_CLOUDY"), 6200, 1.f, 1.f)); - wbEntries.push_back(new WBEntry("Shade" , WBT_SHADE, M("TP_WBALANCE_SHADE"), 7600, 1.f, 1.f)); - wbEntries.push_back(new WBEntry("Water 1" , WBT_WATER, M("TP_WBALANCE_WATER1"), 35000, 0.3f, 1.1f)); - wbEntries.push_back(new WBEntry("Water 2" , WBT_WATER, M("TP_WBALANCE_WATER2"), 48000, 0.63f, 1.38f)); - wbEntries.push_back(new WBEntry("Tungsten" , WBT_TUNGSTEN, M("TP_WBALANCE_TUNGSTEN"), 2856, 1.f, 1.f)); - wbEntries.push_back(new WBEntry("Fluo F1" , WBT_FLUORESCENT, M("TP_WBALANCE_FLUO1"), 6430, 1.f, 1.f)); - wbEntries.push_back(new WBEntry("Fluo F2" , WBT_FLUORESCENT, M("TP_WBALANCE_FLUO2"), 4230, 1.f, 1.f)); - wbEntries.push_back(new WBEntry("Fluo F3" , WBT_FLUORESCENT, M("TP_WBALANCE_FLUO3"), 3450, 1.f, 1.f)); - wbEntries.push_back(new WBEntry("Fluo F4" , WBT_FLUORESCENT, M("TP_WBALANCE_FLUO4"), 2940, 1.f, 1.f)); - wbEntries.push_back(new WBEntry("Fluo F5" , WBT_FLUORESCENT, M("TP_WBALANCE_FLUO5"), 6350, 1.f, 1.f)); - wbEntries.push_back(new WBEntry("Fluo F6" , WBT_FLUORESCENT, M("TP_WBALANCE_FLUO6"), 4150, 1.f, 1.f)); - wbEntries.push_back(new WBEntry("Fluo F7" , WBT_FLUORESCENT, M("TP_WBALANCE_FLUO7"), 6500, 1.f, 1.f)); - wbEntries.push_back(new WBEntry("Fluo F8" , WBT_FLUORESCENT, M("TP_WBALANCE_FLUO8"), 5020, 1.f, 1.f)); - wbEntries.push_back(new WBEntry("Fluo F9" , WBT_FLUORESCENT, M("TP_WBALANCE_FLUO9"), 4330, 1.f, 1.f)); - wbEntries.push_back(new WBEntry("Fluo F10" , WBT_FLUORESCENT, M("TP_WBALANCE_FLUO10"), 5300, 1.f, 1.f)); - wbEntries.push_back(new WBEntry("Fluo F11" , WBT_FLUORESCENT, M("TP_WBALANCE_FLUO11"), 4000, 1.f, 1.f)); - wbEntries.push_back(new WBEntry("Fluo F12" , WBT_FLUORESCENT, M("TP_WBALANCE_FLUO12"), 3000, 1.f, 1.f)); - wbEntries.push_back(new WBEntry("HMI Lamp" , WBT_LAMP, M("TP_WBALANCE_HMI"), 4800, 1.f, 1.f)); - wbEntries.push_back(new WBEntry("GTI Lamp" , WBT_LAMP, M("TP_WBALANCE_GTI"), 5000, 1.f, 1.f)); - wbEntries.push_back(new WBEntry("JudgeIII Lamp" , WBT_LAMP, M("TP_WBALANCE_JUDGEIII"), 5100, 1.f, 1.f)); - wbEntries.push_back(new WBEntry("Solux Lamp 3500K" , WBT_LAMP, M("TP_WBALANCE_SOLUX35"), 3480, 1.f, 1.f)); - wbEntries.push_back(new WBEntry("Solux Lamp 4100K" , WBT_LAMP, M("TP_WBALANCE_SOLUX41"), 3930, 1.f, 1.f)); - wbEntries.push_back(new WBEntry("Solux Lamp 4700K" , WBT_LAMP, M("TP_WBALANCE_SOLUX47"), 4700, 1.f, 1.f)); - wbEntries.push_back(new WBEntry("NG Solux Lamp 4700K" , WBT_LAMP, M("TP_WBALANCE_SOLUX47_NG"), 4480, 1.f, 1.f)); - wbEntries.push_back(new WBEntry("LED LSI Lumelex 2040", WBT_LED, M("TP_WBALANCE_LED_LSI"), 2970, 1.f, 1.f)); - wbEntries.push_back(new WBEntry("LED CRS SP12 WWMR16" , WBT_LED, M("TP_WBALANCE_LED_CRS"), 3050, 1.f, 1.f)); - wbEntries.push_back(new WBEntry("Flash 5500K" , WBT_FLASH, M("TP_WBALANCE_FLASH55"), 5500, 1.f, 1.f)); - wbEntries.push_back(new WBEntry("Flash 6000K" , WBT_FLASH, M("TP_WBALANCE_FLASH60"), 6000, 1.f, 1.f)); - wbEntries.push_back(new WBEntry("Flash 6500K" , WBT_FLASH, M("TP_WBALANCE_FLASH65"), 6500, 1.f, 1.f)); + wbEntries.push_back (new WBEntry ("Camera" , WBT_CAMERA, M ("TP_WBALANCE_CAMERA"), 0, 1.f, 1.f)); + wbEntries.push_back (new WBEntry ("Auto" , WBT_AUTO, M ("TP_WBALANCE_AUTO"), 0, 1.f, 1.f)); + wbEntries.push_back (new WBEntry ("Daylight" , WBT_DAYLIGHT, M ("TP_WBALANCE_DAYLIGHT"), 5300, 1.f, 1.f)); + wbEntries.push_back (new WBEntry ("Cloudy" , WBT_CLOUDY, M ("TP_WBALANCE_CLOUDY"), 6200, 1.f, 1.f)); + wbEntries.push_back (new WBEntry ("Shade" , WBT_SHADE, M ("TP_WBALANCE_SHADE"), 7600, 1.f, 1.f)); + wbEntries.push_back (new WBEntry ("Water 1" , WBT_WATER, M ("TP_WBALANCE_WATER1"), 35000, 0.3f, 1.1f)); + wbEntries.push_back (new WBEntry ("Water 2" , WBT_WATER, M ("TP_WBALANCE_WATER2"), 48000, 0.63f, 1.38f)); + wbEntries.push_back (new WBEntry ("Tungsten" , WBT_TUNGSTEN, M ("TP_WBALANCE_TUNGSTEN"), 2856, 1.f, 1.f)); + wbEntries.push_back (new WBEntry ("Fluo F1" , WBT_FLUORESCENT, M ("TP_WBALANCE_FLUO1"), 6430, 1.f, 1.f)); + wbEntries.push_back (new WBEntry ("Fluo F2" , WBT_FLUORESCENT, M ("TP_WBALANCE_FLUO2"), 4230, 1.f, 1.f)); + wbEntries.push_back (new WBEntry ("Fluo F3" , WBT_FLUORESCENT, M ("TP_WBALANCE_FLUO3"), 3450, 1.f, 1.f)); + wbEntries.push_back (new WBEntry ("Fluo F4" , WBT_FLUORESCENT, M ("TP_WBALANCE_FLUO4"), 2940, 1.f, 1.f)); + wbEntries.push_back (new WBEntry ("Fluo F5" , WBT_FLUORESCENT, M ("TP_WBALANCE_FLUO5"), 6350, 1.f, 1.f)); + wbEntries.push_back (new WBEntry ("Fluo F6" , WBT_FLUORESCENT, M ("TP_WBALANCE_FLUO6"), 4150, 1.f, 1.f)); + wbEntries.push_back (new WBEntry ("Fluo F7" , WBT_FLUORESCENT, M ("TP_WBALANCE_FLUO7"), 6500, 1.f, 1.f)); + wbEntries.push_back (new WBEntry ("Fluo F8" , WBT_FLUORESCENT, M ("TP_WBALANCE_FLUO8"), 5020, 1.f, 1.f)); + wbEntries.push_back (new WBEntry ("Fluo F9" , WBT_FLUORESCENT, M ("TP_WBALANCE_FLUO9"), 4330, 1.f, 1.f)); + wbEntries.push_back (new WBEntry ("Fluo F10" , WBT_FLUORESCENT, M ("TP_WBALANCE_FLUO10"), 5300, 1.f, 1.f)); + wbEntries.push_back (new WBEntry ("Fluo F11" , WBT_FLUORESCENT, M ("TP_WBALANCE_FLUO11"), 4000, 1.f, 1.f)); + wbEntries.push_back (new WBEntry ("Fluo F12" , WBT_FLUORESCENT, M ("TP_WBALANCE_FLUO12"), 3000, 1.f, 1.f)); + wbEntries.push_back (new WBEntry ("HMI Lamp" , WBT_LAMP, M ("TP_WBALANCE_HMI"), 4800, 1.f, 1.f)); + wbEntries.push_back (new WBEntry ("GTI Lamp" , WBT_LAMP, M ("TP_WBALANCE_GTI"), 5000, 1.f, 1.f)); + wbEntries.push_back (new WBEntry ("JudgeIII Lamp" , WBT_LAMP, M ("TP_WBALANCE_JUDGEIII"), 5100, 1.f, 1.f)); + wbEntries.push_back (new WBEntry ("Solux Lamp 3500K" , WBT_LAMP, M ("TP_WBALANCE_SOLUX35"), 3480, 1.f, 1.f)); + wbEntries.push_back (new WBEntry ("Solux Lamp 4100K" , WBT_LAMP, M ("TP_WBALANCE_SOLUX41"), 3930, 1.f, 1.f)); + wbEntries.push_back (new WBEntry ("Solux Lamp 4700K" , WBT_LAMP, M ("TP_WBALANCE_SOLUX47"), 4700, 1.f, 1.f)); + wbEntries.push_back (new WBEntry ("NG Solux Lamp 4700K" , WBT_LAMP, M ("TP_WBALANCE_SOLUX47_NG"), 4480, 1.f, 1.f)); + wbEntries.push_back (new WBEntry ("LED LSI Lumelex 2040", WBT_LED, M ("TP_WBALANCE_LED_LSI"), 2970, 1.f, 1.f)); + wbEntries.push_back (new WBEntry ("LED CRS SP12 WWMR16" , WBT_LED, M ("TP_WBALANCE_LED_CRS"), 3050, 1.f, 1.f)); + wbEntries.push_back (new WBEntry ("Flash 5500K" , WBT_FLASH, M ("TP_WBALANCE_FLASH55"), 5500, 1.f, 1.f)); + wbEntries.push_back (new WBEntry ("Flash 6000K" , WBT_FLASH, M ("TP_WBALANCE_FLASH60"), 6000, 1.f, 1.f)); + wbEntries.push_back (new WBEntry ("Flash 6500K" , WBT_FLASH, M ("TP_WBALANCE_FLASH65"), 6500, 1.f, 1.f)); // Should remain the last one - wbEntries.push_back(new WBEntry("Custom" , WBT_CUSTOM, M("TP_WBALANCE_CUSTOM"), 0, 1.f, 1.f)); + wbEntries.push_back (new WBEntry ("Custom" , WBT_CUSTOM, M ("TP_WBALANCE_CUSTOM"), 0, 1.f, 1.f)); } void WBParams::cleanup() @@ -102,15 +102,15 @@ void WBParams::cleanup() } // Maps crop to resized width (e.g. smaller previews) -void CropParams::mapToResized(int resizedWidth, int resizedHeight, int scale, int &x1, int &x2, int &y1, int &y2) const +void CropParams::mapToResized (int resizedWidth, int resizedHeight, int scale, int &x1, int &x2, int &y1, int &y2) const { x1 = 0, x2 = resizedWidth, y1 = 0, y2 = resizedHeight; if (enabled) { - x1 = min(resizedWidth - 1, max(0, x / scale)); - y1 = min(resizedHeight - 1, max(0, y / scale)); - x2 = min(resizedWidth, max(0, (x + w) / scale)); - y2 = min(resizedHeight, max(0, (y + h) / scale)); + x1 = min (resizedWidth - 1, max (0, x / scale)); + y1 = min (resizedHeight - 1, max (0, y / scale)); + x2 = min (resizedWidth, max (0, (x + w) / scale)); + y2 = min (resizedHeight, max (0, (y + h) / scale)); } } @@ -119,7 +119,7 @@ RetinexParams::RetinexParams () setDefaults (); } -void RetinexParams::getDefaulttransmissionCurve(std::vector &curve) +void RetinexParams::getDefaulttransmissionCurve (std::vector &curve) { double v[12] = { 0.00, 0.50, 0.35, 0.35, 0.60, 0.75, 0.35, 0.35, @@ -127,14 +127,14 @@ void RetinexParams::getDefaulttransmissionCurve(std::vector &curve) }; - curve.resize(13); - curve.at(0 ) = double(FCT_MinMaxCPoints); + curve.resize (13); + curve.at (0 ) = double (FCT_MinMaxCPoints); for (size_t i = 1; i < curve.size(); ++i) { - curve.at(i) = v[i - 1]; + curve.at (i) = v[i - 1]; } } -void RetinexParams::getDefaultgaintransmissionCurve(std::vector &curve) +void RetinexParams::getDefaultgaintransmissionCurve (std::vector &curve) { double v[16] = { 0.00, 0.1, 0.35, 0.00, 0.25, 0.25, 0.35, 0.35, @@ -143,11 +143,11 @@ void RetinexParams::getDefaultgaintransmissionCurve(std::vector &curve) }; - curve.resize(17); - curve.at(0 ) = double(FCT_MinMaxCPoints); + curve.resize (17); + curve.at (0 ) = double (FCT_MinMaxCPoints); for (size_t i = 1; i < curve.size(); ++i) { - curve.at(i) = v[i - 1]; + curve.at (i) = v[i - 1]; } } @@ -183,88 +183,88 @@ void RetinexParams::setDefaults() gammaretinex = "none"; medianmap = false; cdcurve.clear(); - cdcurve.push_back(DCT_Linear); + cdcurve.push_back (DCT_Linear); cdHcurve.clear(); - cdHcurve.push_back(DCT_Linear); + cdHcurve.push_back (DCT_Linear); lhcurve.clear(); - lhcurve.push_back(DCT_Linear); + lhcurve.push_back (DCT_Linear); mapcurve.clear(); - mapcurve.push_back(DCT_Linear); - getDefaultgaintransmissionCurve(gaintransmissionCurve); + mapcurve.push_back (DCT_Linear); + getDefaultgaintransmissionCurve (gaintransmissionCurve); - getDefaulttransmissionCurve(transmissionCurve); + getDefaulttransmissionCurve (transmissionCurve); } -void RetinexParams::getCurves(RetinextransmissionCurve &transmissionCurveLUT, RetinexgaintransmissionCurve &gaintransmissionCurveLUT) const +void RetinexParams::getCurves (RetinextransmissionCurve &transmissionCurveLUT, RetinexgaintransmissionCurve &gaintransmissionCurveLUT) const { - transmissionCurveLUT.Set(this->transmissionCurve); - gaintransmissionCurveLUT.Set(this->gaintransmissionCurve); + transmissionCurveLUT.Set (this->transmissionCurve); + gaintransmissionCurveLUT.Set (this->gaintransmissionCurve); } -ColorToningParams::ColorToningParams () : hlColSat(60, 80, false), shadowsColSat(80, 208, false) +ColorToningParams::ColorToningParams () : hlColSat (60, 80, false), shadowsColSat (80, 208, false) { setDefaults(); } -void ColorToningParams::getDefaultColorCurve(std::vector &curve) +void ColorToningParams::getDefaultColorCurve (std::vector &curve) { double v[8] = { 0.050, 0.62, 0.25, 0.25, 0.585, 0.11, 0.25, 0.25 }; - curve.resize(9); - curve.at(0) = double(FCT_MinMaxCPoints); + curve.resize (9); + curve.at (0) = double (FCT_MinMaxCPoints); for (size_t i = 1; i < curve.size(); ++i) { - curve.at(i) = v[i - 1]; + curve.at (i) = v[i - 1]; } } -void ColorToningParams::getDefaultOpacityCurve(std::vector &curve) +void ColorToningParams::getDefaultOpacityCurve (std::vector &curve) { double v[16] = { 0.00, 0.3, 0.35, 0.00, 0.25, 0.8, 0.35, 0.35, 0.70, 0.8, 0.35, 0.35, 1.00, 0.3, 0.00, 0.00 }; - curve.resize(17); - curve.at(0 ) = double(FCT_MinMaxCPoints); + curve.resize (17); + curve.at (0 ) = double (FCT_MinMaxCPoints); for (size_t i = 1; i < curve.size(); ++i) { - curve.at(i) = v[i - 1]; + curve.at (i) = v[i - 1]; } } -void ColorToningParams::getDefaultCLCurve(std::vector &curve) +void ColorToningParams::getDefaultCLCurve (std::vector &curve) { double v[6] = { 0.00, 0.00, 0.35, 0.65, 1.00, 1.00 }; - curve.resize(7); - curve.at(0) = double(DCT_NURBS); + curve.resize (7); + curve.at (0) = double (DCT_NURBS); for (size_t i = 1; i < curve.size(); ++i) { - curve.at(i) = v[i - 1]; + curve.at (i) = v[i - 1]; } } -void ColorToningParams::getDefaultCL2Curve(std::vector &curve) +void ColorToningParams::getDefaultCL2Curve (std::vector &curve) { double v[6] = { 0.00, 0.00, 0.35, 0.65, 1.00, 1.00 }; - curve.resize(7); - curve.at(0) = double(DCT_NURBS); + curve.resize (7); + curve.at (0) = double (DCT_NURBS); for (size_t i = 1; i < curve.size(); ++i) { - curve.at(i) = v[i - 1]; + curve.at (i) = v[i - 1]; } } @@ -274,13 +274,13 @@ void ColorToningParams::setDefaults() autosat = true; method = "Lab"; - getDefaultColorCurve(colorCurve); - getDefaultOpacityCurve(opacityCurve); - getDefaultCLCurve(clcurve); - getDefaultCL2Curve(cl2curve); + getDefaultColorCurve (colorCurve); + getDefaultOpacityCurve (opacityCurve); + getDefaultCLCurve (clcurve); + getDefaultCL2Curve (cl2curve); - hlColSat.setValues(60, 80); - shadowsColSat.setValues(80, 208); + hlColSat.setValues (60, 80); + shadowsColSat.setValues (80, 208); balance = 0; satProtectionThreshold = 30; saturatedOpacity = 80; @@ -300,14 +300,14 @@ void ColorToningParams::setDefaults() bluehigh = 0.0; } -void ColorToningParams::mixerToCurve(std::vector &colorCurve, std::vector &opacityCurve) const +void ColorToningParams::mixerToCurve (std::vector &colorCurve, std::vector &opacityCurve) const { // check if non null first if (!redlow && !greenlow && !bluelow && !redmed && !greenmed && !bluemed && !redhigh && !greenhigh && !bluehigh) { - colorCurve.resize(1); - colorCurve.at(0) = FCT_Linear; - opacityCurve.resize(1); - opacityCurve.at(0) = FCT_Linear; + colorCurve.resize (1); + colorCurve.at (0) = FCT_Linear; + opacityCurve.resize (1); + opacityCurve.at (0) = FCT_Linear; return; } @@ -320,11 +320,11 @@ void ColorToningParams::mixerToCurve(std::vector &colorCurve, std::vecto float minTmp, maxTmp; // Fill the shadow mixer values of the Color TOning tool - low[0] = float(redlow ) / 100.f; // [-1. ; +1.] - low[1] = float(greenlow) / 100.f; // [-1. ; +1.] - low[2] = float(bluelow ) / 100.f; // [-1. ; +1.] - minTmp = min(low[0], low[1], low[2]); - maxTmp = max(low[0], low[1], low[2]); + low[0] = float (redlow ) / 100.f; // [-1. ; +1.] + low[1] = float (greenlow) / 100.f; // [-1. ; +1.] + low[2] = float (bluelow ) / 100.f; // [-1. ; +1.] + minTmp = min (low[0], low[1], low[2]); + maxTmp = max (low[0], low[1], low[2]); if (maxTmp - minTmp > 0.005f) { float v[3]; @@ -362,11 +362,11 @@ void ColorToningParams::mixerToCurve(std::vector &colorCurve, std::vecto } // Fill the mid-tones mixer values of the Color TOning tool - med[0] = float(redmed ) / 100.f; // [-1. ; +1.] - med[1] = float(greenmed) / 100.f; // [-1. ; +1.] - med[2] = float(bluemed ) / 100.f; // [-1. ; +1.] - minTmp = min(med[0], med[1], med[2]); - maxTmp = max(med[0], med[1], med[2]); + med[0] = float (redmed ) / 100.f; // [-1. ; +1.] + med[1] = float (greenmed) / 100.f; // [-1. ; +1.] + med[2] = float (bluemed ) / 100.f; // [-1. ; +1.] + minTmp = min (med[0], med[1], med[2]); + maxTmp = max (med[0], med[1], med[2]); if (maxTmp - minTmp > 0.005f) { float v[3]; @@ -404,11 +404,11 @@ void ColorToningParams::mixerToCurve(std::vector &colorCurve, std::vecto } // Fill the highlight mixer values of the Color TOning tool - high[0] = float(redhigh ) / 100.f; // [-1. ; +1.] - high[1] = float(greenhigh) / 100.f; // [-1. ; +1.] - high[2] = float(bluehigh ) / 100.f; // [-1. ; +1.] - minTmp = min(high[0], high[1], high[2]); - maxTmp = max(high[0], high[1], high[2]); + high[0] = float (redhigh ) / 100.f; // [-1. ; +1.] + high[1] = float (greenhigh) / 100.f; // [-1. ; +1.] + high[2] = float (bluehigh ) / 100.f; // [-1. ; +1.] + minTmp = min (high[0], high[1], high[2]); + maxTmp = max (high[0], high[1], high[2]); if (maxTmp - minTmp > 0.005f) { float v[3]; @@ -454,100 +454,100 @@ void ColorToningParams::mixerToCurve(std::vector &colorCurve, std::vecto - colorCurve.resize( medSat != 0.f ? 13 : 9 ); - colorCurve.at(0) = FCT_MinMaxCPoints; - opacityCurve.resize(13); - opacityCurve.at(0) = FCT_MinMaxCPoints; + colorCurve.resize ( medSat != 0.f ? 13 : 9 ); + colorCurve.at (0) = FCT_MinMaxCPoints; + opacityCurve.resize (13); + opacityCurve.at (0) = FCT_MinMaxCPoints; float h, s, l; int idx = 1; if (lowSat == 0.f) { if (medSat != 0.f) { - Color::rgb2hsl(med[0], med[1], med[2], h, s, l); + Color::rgb2hsl (med[0], med[1], med[2], h, s, l); } else { // highSat can't be null if the 2 other ones are! - Color::rgb2hsl(high[0], high[1], high[2], h, s, l); + Color::rgb2hsl (high[0], high[1], high[2], h, s, l); } } else { - Color::rgb2hsl(low[0], low[1], low[2], h, s, l); + Color::rgb2hsl (low[0], low[1], low[2], h, s, l); } - colorCurve.at(idx++) = xPosLow; - colorCurve.at(idx++) = h; - colorCurve.at(idx++) = 0.35; - colorCurve.at(idx++) = 0.35; + colorCurve.at (idx++) = xPosLow; + colorCurve.at (idx++) = h; + colorCurve.at (idx++) = 0.35; + colorCurve.at (idx++) = 0.35; if (medSat != 0.f) { - Color::rgb2hsl(med[0], med[1], med[2], h, s, l); - colorCurve.at(idx++) = xPosMed; - colorCurve.at(idx++) = h; - colorCurve.at(idx++) = 0.35; - colorCurve.at(idx++) = 0.35; + Color::rgb2hsl (med[0], med[1], med[2], h, s, l); + colorCurve.at (idx++) = xPosMed; + colorCurve.at (idx++) = h; + colorCurve.at (idx++) = 0.35; + colorCurve.at (idx++) = 0.35; } if (highSat == 0.f) { if (medSat != 0.f) { - Color::rgb2hsl(med[0], med[1], med[2], h, s, l); + Color::rgb2hsl (med[0], med[1], med[2], h, s, l); } else { // lowSat can't be null if the 2 other ones are! - Color::rgb2hsl(low[0], low[1], low[2], h, s, l); + Color::rgb2hsl (low[0], low[1], low[2], h, s, l); } } else { - Color::rgb2hsl(high[0], high[1], high[2], h, s, l); + Color::rgb2hsl (high[0], high[1], high[2], h, s, l); } - colorCurve.at(idx++) = xPosHigh; - colorCurve.at(idx++) = h; - colorCurve.at(idx++) = 0.35; - colorCurve.at(idx) = 0.35; + colorCurve.at (idx++) = xPosHigh; + colorCurve.at (idx++) = h; + colorCurve.at (idx++) = 0.35; + colorCurve.at (idx) = 0.35; - opacityCurve.at(1) = xPosLow; - opacityCurve.at(2) = double(lowSat); - opacityCurve.at(3) = 0.35; - opacityCurve.at(4) = 0.35; - opacityCurve.at(5) = xPosMed; - opacityCurve.at(6) = double(medSat); - opacityCurve.at(7) = 0.35; - opacityCurve.at(8) = 0.35; - opacityCurve.at(9) = xPosHigh; - opacityCurve.at(10) = double(highSat); - opacityCurve.at(11) = 0.35; - opacityCurve.at(12) = 0.35; + opacityCurve.at (1) = xPosLow; + opacityCurve.at (2) = double (lowSat); + opacityCurve.at (3) = 0.35; + opacityCurve.at (4) = 0.35; + opacityCurve.at (5) = xPosMed; + opacityCurve.at (6) = double (medSat); + opacityCurve.at (7) = 0.35; + opacityCurve.at (8) = 0.35; + opacityCurve.at (9) = xPosHigh; + opacityCurve.at (10) = double (highSat); + opacityCurve.at (11) = 0.35; + opacityCurve.at (12) = 0.35; } -void ColorToningParams::slidersToCurve(std::vector &colorCurve, std::vector &opacityCurve) const +void ColorToningParams::slidersToCurve (std::vector &colorCurve, std::vector &opacityCurve) const { if (hlColSat.value[0] == 0 && shadowsColSat.value[0] == 0) { // if both opacity are null, set both curves to Linear - colorCurve.resize(1); - colorCurve.at(0) = FCT_Linear; - opacityCurve.resize(1); - opacityCurve.at(0) = FCT_Linear; + colorCurve.resize (1); + colorCurve.at (0) = FCT_Linear; + opacityCurve.resize (1); + opacityCurve.at (0) = FCT_Linear; return; } - colorCurve.resize(9); - colorCurve.at(0) = FCT_MinMaxCPoints; - colorCurve.at(1) = 0.26 + 0.12 * double(balance) / 100.; - colorCurve.at(2) = double(shadowsColSat.value[1]) / 360.; - colorCurve.at(3) = 0.35; - colorCurve.at(4) = 0.35; - colorCurve.at(5) = 0.64 + 0.12 * double(balance) / 100.; - colorCurve.at(6) = double(hlColSat.value[1]) / 360.; - colorCurve.at(7) = 0.35; - colorCurve.at(8) = 0.35; + colorCurve.resize (9); + colorCurve.at (0) = FCT_MinMaxCPoints; + colorCurve.at (1) = 0.26 + 0.12 * double (balance) / 100.; + colorCurve.at (2) = double (shadowsColSat.value[1]) / 360.; + colorCurve.at (3) = 0.35; + colorCurve.at (4) = 0.35; + colorCurve.at (5) = 0.64 + 0.12 * double (balance) / 100.; + colorCurve.at (6) = double (hlColSat.value[1]) / 360.; + colorCurve.at (7) = 0.35; + colorCurve.at (8) = 0.35; - opacityCurve.resize(9); - opacityCurve.at(0) = FCT_MinMaxCPoints; - opacityCurve.at(1) = colorCurve.at(1); - opacityCurve.at(2) = double(shadowsColSat.value[0]) / 100.; - opacityCurve.at(3) = 0.35; - opacityCurve.at(4) = 0.35; - opacityCurve.at(5) = colorCurve.at(5); - opacityCurve.at(6) = double(hlColSat.value[0]) / 100.; - opacityCurve.at(7) = 0.35; - opacityCurve.at(8) = 0.35; + opacityCurve.resize (9); + opacityCurve.at (0) = FCT_MinMaxCPoints; + opacityCurve.at (1) = colorCurve.at (1); + opacityCurve.at (2) = double (shadowsColSat.value[0]) / 100.; + opacityCurve.at (3) = 0.35; + opacityCurve.at (4) = 0.35; + opacityCurve.at (5) = colorCurve.at (5); + opacityCurve.at (6) = double (hlColSat.value[0]) / 100.; + opacityCurve.at (7) = 0.35; + opacityCurve.at (8) = 0.35; } -void ColorToningParams::getCurves(ColorGradientCurve &colorCurveLUT, OpacityCurve &opacityCurveLUT, const double xyz_rgb[3][3], const double rgb_xyz[3][3], bool &opautili) const +void ColorToningParams::getCurves (ColorGradientCurve &colorCurveLUT, OpacityCurve &opacityCurveLUT, const double xyz_rgb[3][3], const double rgb_xyz[3][3], bool &opautili) const { float satur = 0.8f; float lumin = 0.5f; //middle of luminance for optimization of gamut - no real importance...as we work in XYZ and gamut control @@ -556,85 +556,84 @@ void ColorToningParams::getCurves(ColorGradientCurve &colorCurveLUT, OpacityCurv std::vector cCurve, oCurve; if (method == "RGBSliders" || method == "Splitlr") { - slidersToCurve(cCurve, oCurve); + slidersToCurve (cCurve, oCurve); } else if (method == "Splitco") { - mixerToCurve(cCurve, oCurve); + mixerToCurve (cCurve, oCurve); } else { cCurve = this->colorCurve; oCurve = this->opacityCurve; } - if(method == "Lab") { - if(twocolor == "Separ") { + if (method == "Lab") { + if (twocolor == "Separ") { satur = 0.9f; } - if(twocolor == "All" || twocolor == "Two") { + if (twocolor == "All" || twocolor == "Two") { satur = 0.9f; } - colorCurveLUT.SetXYZ(cCurve, xyz_rgb, rgb_xyz, satur, lumin); - opacityCurveLUT.Set(oCurve, opautili); - } else if(method == "Splitlr" || method == "Splitco") { - colorCurveLUT.SetXYZ(cCurve, xyz_rgb, rgb_xyz, satur, lumin); - opacityCurveLUT.Set(oCurve, opautili); - } else if(method.substr(0, 3) == "RGB") { - colorCurveLUT.SetRGB(cCurve, xyz_rgb, rgb_xyz); - opacityCurveLUT.Set(oCurve, opautili); + colorCurveLUT.SetXYZ (cCurve, xyz_rgb, rgb_xyz, satur, lumin); + opacityCurveLUT.Set (oCurve, opautili); + } else if (method == "Splitlr" || method == "Splitco") { + colorCurveLUT.SetXYZ (cCurve, xyz_rgb, rgb_xyz, satur, lumin); + opacityCurveLUT.Set (oCurve, opautili); + } else if (method.substr (0, 3) == "RGB") { + colorCurveLUT.SetRGB (cCurve, xyz_rgb, rgb_xyz); + opacityCurveLUT.Set (oCurve, opautili); } } //WaveletParams::WaveletParams (): hueskin(-5, 25, 170, 120, false), hueskin2(-260, -250, -130, -140, false), hllev(50, 75, 100, 98, false), bllev(0, 2, 50, 25, false), pastlev(0, 2, 30, 20, false), satlev(30, 45, 130, 100, false), edgcont(0, 20, 100, 75, false){ -WaveletParams::WaveletParams (): hueskin(-5, 25, 170, 120, false), hueskin2(-260, -250, -130, -140, false), hllev(50, 75, 100, 98, false), bllev(0, 2, 50, 25, false), - pastlev(0, 2, 30, 20, false), satlev(30, 45, 130, 100, false), edgcont(bl, tl, br, tr, false), /* edgcont(0, 10, 75, 40, false),*/level0noise(0, 0, false), level1noise(0, 0, false), level2noise(0, 0, false), level3noise(0, 0, false) +WaveletParams::WaveletParams (): hueskin (-5, 25, 170, 120, false), hueskin2 (-260, -250, -130, -140, false), hllev (50, 75, 100, 98, false), bllev (0, 2, 50, 25, false), + pastlev (0, 2, 30, 20, false), satlev (30, 45, 130, 100, false), edgcont (bl, tl, br, tr, false), /* edgcont(0, 10, 75, 40, false),*/level0noise (0, 0, false), level1noise (0, 0, false), level2noise (0, 0, false), level3noise (0, 0, false) { setDefaults (); } -void WaveletParams::getDefaultOpacityCurveRG(std::vector &curve) +void WaveletParams::getDefaultOpacityCurveRG (std::vector &curve) { double v[8] = { 0.0, 0.50, 0.35, 0.35, 1.00, 0.50, 0.35, 0.35 }; - curve.resize(9); - curve.at(0) = double(FCT_MinMaxCPoints); + curve.resize (9); + curve.at (0) = double (FCT_MinMaxCPoints); for (size_t i = 1; i < curve.size(); ++i) { - curve.at(i) = v[i - 1]; + curve.at (i) = v[i - 1]; } } -void WaveletParams::getDefaultOpacityCurveBY(std::vector &curve) +void WaveletParams::getDefaultOpacityCurveBY (std::vector &curve) { double v[8] = { 0.0, 0.50, 0.35, 0.35, 1.00, 0.50, 0.35, 0.35 }; - curve.resize(9); - curve.at(0 ) = double(FCT_MinMaxCPoints); + curve.resize (9); + curve.at (0 ) = double (FCT_MinMaxCPoints); for (size_t i = 1; i < curve.size(); ++i) { - curve.at(i) = v[i - 1]; + curve.at (i) = v[i - 1]; } } - -void WaveletParams::getDefaultOpacityCurveW(std::vector &curve) +void WaveletParams::getDefaultOpacityCurveW (std::vector &curve) { double v[16] = { 0.00, 0.35, 0.35, 0.00, 0.35, 0.75, 0.35, 0.35, 0.60, 0.75, 0.35, 0.35, 1.00, 0.35, 0.00, 0.00 }; - curve.resize(17); - curve.at(0) = double(FCT_MinMaxCPoints); + curve.resize (17); + curve.at (0) = double (FCT_MinMaxCPoints); for (size_t i = 1; i < curve.size(); ++i) { - curve.at(i) = v[i - 1]; + curve.at (i) = v[i - 1]; } } -void WaveletParams::getDefaultOpacityCurveWL(std::vector &curve) +void WaveletParams::getDefaultOpacityCurveWL (std::vector &curve) { double v[8] = { 0.0, 0.50, 0.35, 0.35, 1.00, 0.50, 0.35, 0.35 @@ -644,47 +643,47 @@ void WaveletParams::getDefaultOpacityCurveWL(std::vector &curve) 0.42, 0.53, 0.35, 0.35, 1.00, 0.15, 0.00, 0.00 }; */ - curve.resize(9); - curve.at(0) = double(FCT_MinMaxCPoints); + curve.resize (9); + curve.at (0) = double (FCT_MinMaxCPoints); for (size_t i = 1; i < curve.size(); ++i) { - curve.at(i) = v[i - 1]; + curve.at (i) = v[i - 1]; } } -void WaveletParams::getDefaultCCWCurve(std::vector &curve) +void WaveletParams::getDefaultCCWCurve (std::vector &curve) { double v[12] = { 0.0, 0.25, 0.35, 0.35, 0.50, 0.75, 0.35, 0.35, 0.90, 0.0, 0.35, 0.35 }; - curve.resize(13); - curve.at(0 ) = double(FCT_MinMaxCPoints); + curve.resize (13); + curve.at (0 ) = double (FCT_MinMaxCPoints); for (size_t i = 1; i < curve.size(); ++i) { - curve.at(i) = v[i - 1]; + curve.at (i) = v[i - 1]; } } -void WaveletParams::getCurves(WavCurve &cCurve, WavOpacityCurveRG &opacityCurveLUTRG, WavOpacityCurveBY &opacityCurveLUTBY, WavOpacityCurveW &opacityCurveLUTW, WavOpacityCurveWL &opacityCurveLUTWL) const +void WaveletParams::getCurves (WavCurve &cCurve, WavOpacityCurveRG &opacityCurveLUTRG, WavOpacityCurveBY &opacityCurveLUTBY, WavOpacityCurveW &opacityCurveLUTW, WavOpacityCurveWL &opacityCurveLUTWL) const { - cCurve.Set(this->ccwcurve); - opacityCurveLUTRG.Set(this->opacityCurveRG); - opacityCurveLUTBY.Set(this->opacityCurveBY); - opacityCurveLUTW.Set(this->opacityCurveW); - opacityCurveLUTWL.Set(this->opacityCurveWL); + cCurve.Set (this->ccwcurve); + opacityCurveLUTRG.Set (this->opacityCurveRG); + opacityCurveLUTBY.Set (this->opacityCurveBY); + opacityCurveLUTW.Set (this->opacityCurveW); + opacityCurveLUTWL.Set (this->opacityCurveWL); } void WaveletParams::setDefaults() { - getDefaultCCWCurve(ccwcurve); - getDefaultOpacityCurveRG(opacityCurveRG); - getDefaultOpacityCurveBY(opacityCurveBY); - getDefaultOpacityCurveW(opacityCurveW); - getDefaultOpacityCurveWL(opacityCurveWL); + getDefaultCCWCurve (ccwcurve); + getDefaultOpacityCurveRG (opacityCurveRG); + getDefaultOpacityCurveBY (opacityCurveBY); + getDefaultOpacityCurveW (opacityCurveW); + getDefaultOpacityCurveWL (opacityCurveWL); enabled = false; median = false; medianlev = false; @@ -698,7 +697,7 @@ void WaveletParams::setDefaults() balance = 0; iter = 0; wavclCurve.clear (); - wavclCurve.push_back(DCT_Linear); + wavclCurve.push_back (DCT_Linear); Lmethod = "4_"; CHmethod = "without"; @@ -730,8 +729,8 @@ void WaveletParams::setDefaults() thr = 35; thrH = 65; skinprotect = 0.; - hueskin.setValues(-5, 25, 170, 120); - hueskin2.setValues(-260, -250, -130, -140); + hueskin.setValues (-5, 25, 170, 120); + hueskin2.setValues (-260, -250, -130, -140); threshold = 5; threshold2 = 4; edgedetect = 90; @@ -739,20 +738,20 @@ void WaveletParams::setDefaults() edgedetectthr2 = 0; edgesensi = 60; edgeampli = 10; - hllev.setValues(50, 75, 100, 98); - bllev.setValues(0, 2, 50, 25); - pastlev.setValues(0, 2, 30, 20); - satlev.setValues(30, 45, 130, 100); + hllev.setValues (50, 75, 100, 98); + bllev.setValues (0, 2, 50, 25); + pastlev.setValues (0, 2, 30, 20); + satlev.setValues (30, 45, 130, 100); // edgcont.setValues(bl, tl, br, tr); - edgcont.setValues(0, 10, 75, 40); - level0noise.setValues(0, 0); - level1noise.setValues(0, 0); - level2noise.setValues(0, 0); - level3noise.setValues(0, 0); + edgcont.setValues (0, 10, 75, 40); + level0noise.setValues (0, 0); + level1noise.setValues (0, 0); + level2noise.setValues (0, 0); + level3noise.setValues (0, 0); hhcurve.clear (); - hhcurve.push_back(FCT_Linear); + hhcurve.push_back (FCT_Linear); Chcurve.clear (); - Chcurve.push_back(FCT_Linear); + Chcurve.push_back (FCT_Linear); expcontrast = false; expchroma = false; expedge = false; @@ -761,11 +760,11 @@ void WaveletParams::setDefaults() exptoning = false; expnoise = false; - for(int i = 0; i < 9; i ++) { + for (int i = 0; i < 9; i ++) { c[i] = 0; } - for(int i = 0; i < 9; i ++) { + for (int i = 0; i < 9; i ++) { ch[i] = 0; } @@ -777,20 +776,20 @@ DirPyrDenoiseParams::DirPyrDenoiseParams () setDefaults (); } -void DirPyrDenoiseParams::getDefaultNoisCurve(std::vector &curve) +void DirPyrDenoiseParams::getDefaultNoisCurve (std::vector &curve) { double v[8] = { 0.05, 0.15, 0.35, 0.35, 0.55, 0.04, 0.35, 0.35 }; - curve.resize(9); - curve.at(0 ) = double(FCT_MinMaxCPoints); + curve.resize (9); + curve.at (0 ) = double (FCT_MinMaxCPoints); for (size_t i = 1; i < curve.size(); ++i) { - curve.at(i) = v[i - 1]; + curve.at (i) = v[i - 1]; } } -void DirPyrDenoiseParams::getDefaultCCCurve(std::vector &curve) +void DirPyrDenoiseParams::getDefaultCCCurve (std::vector &curve) { // double v[8]= { 0.15, 0.00,0.35,0.35, // 0.60, 0.05,0.35,0.35}; @@ -798,11 +797,11 @@ void DirPyrDenoiseParams::getDefaultCCCurve(std::vector &curve) 0.35, 0.05, 0.35, 0.35 }; - curve.resize(9); - curve.at(0 ) = double(FCT_MinMaxCPoints); + curve.resize (9); + curve.at (0 ) = double (FCT_MinMaxCPoints); for (size_t i = 1; i < curve.size(); ++i) { - curve.at(i) = v[i - 1]; + curve.at (i) = v[i - 1]; } } @@ -810,8 +809,8 @@ void DirPyrDenoiseParams::getDefaultCCCurve(std::vector &curve) void DirPyrDenoiseParams::setDefaults() { - getDefaultNoisCurve(lcurve); - getDefaultCCCurve(cccurve); + getDefaultNoisCurve (lcurve); + getDefaultCCCurve (cccurve); enabled = false; enhance = false; @@ -834,10 +833,10 @@ void DirPyrDenoiseParams::setDefaults() gamma = 1.7; } -void DirPyrDenoiseParams::getCurves(NoiseCurve &lCurve, NoiseCurve &cCurve) const +void DirPyrDenoiseParams::getCurves (NoiseCurve &lCurve, NoiseCurve &cCurve) const { - lCurve.Set(this->lcurve); - cCurve.Set(this->cccurve); + lCurve.Set (this->lcurve); + cCurve.Set (this->cccurve); } void ToneCurveParams::setDefaults() @@ -853,9 +852,9 @@ void ToneCurveParams::setDefaults() hlcomprthresh = 33; shcompr = 50; curve.clear (); - curve.push_back(DCT_Linear); + curve.push_back (DCT_Linear); curve2.clear (); - curve2.push_back(DCT_Linear); + curve2.push_back (DCT_Linear); curveMode = ToneCurveParams::TC_MODE_STD; curveMode2 = ToneCurveParams::TC_MODE_STD; hrenabled = false; @@ -876,6 +875,173 @@ void CoarseTransformParams::setDefaults() vflip = false; } +void LocallabParams::setDefaults() +{ + enabled = false; + degree = 0; + locY = 250; + locX = 250; + locYT = 250; + locXL = 250; + centerX = 0; + centerY = 0; + circrad = 18; + qualityMethod = "std"; + proxi = 1; + thres = 60; + lightness = 0; + contrast = 0; + chroma = 0; + noiselumf = 0; + noiselumc = 0; + noisechrof = 0; + noisechroc = 0; + sharradius = 40; + sharamount = 75; + shardamping = 75; + shariter = 30; + sensi = 19; + sensih = 19; + retrab = 500; + sensicb = 19; + sensibn = 60; + sensitm = 40; + sensisha = 19; + transit = 60; + chrrt = 0; + avoid = false; + Smethod = "IND"; + retinexMethod = "high"; + invers = false; + curvactiv = false; + activlum = false; + radius = 0; + inversrad = false; + inversret = false; + inverssha = false; + strength = 0; + stren = 0; + gamma = 100; + estop = 140; + scaltm = 3; + rewei = 0; + hueref = INFINITY; + chromaref = INFINITY; + lumaref = INFINITY; + str = 0; + neigh = 50; + vart = 200; + nbspot = 1; + anbspot = 0; + llcurve.clear (); + llcurve.push_back (DCT_Linear); + expcolor = true; + expblur = true; + exptonemap = true; + expreti = true; + expsharp = true; + expcbdl = true; + expdenoi = true; + + for (int i = 0; i < 5; i ++) { + mult[i] = 100; + } + + threshold = 20; + + getDefaultLocalgainCurveT (localTgaincurve); + getDefaultLocalgainCurveTrab (localTgaincurverab); + getDefaultLLCurve (llcurve); + getDefaultLHCurve (LHcurve); + +} + +void LocallabParams::getDefaultLocalgainCurveT (std::vector &curve) +{ + + + double v[12] = { 0.00, 0.12, 0.35, 0.35, + 0.70, 0.50, 0.35, 0.35, + 1.00, 0.12, 0.35, 0.35, + }; + + + curve.resize (13); + curve.at (0 ) = double (FCT_MinMaxCPoints); + + for (size_t i = 1; i < curve.size(); ++i) { + curve.at (i) = v[i - 1]; + } + +} + +void LocallabParams::getDefaultLHCurve (std::vector &curve) +{ + + /* + double v[12] = { 0.00, 0.12, 0.35, 0.35, + 0.70, 0.50, 0.35, 0.35, + 1.00, 0.12, 0.35, 0.35, + }; + */ + double v[24] = { 0.00, 0.50, 0.35, 0.35, + 0.166, 0.50, 0.35, 0.35, + 0.333, 0.50, 0.35, 0.35, + 0.50, 0.50, 0.35, 0.35, + 0.666, 0.50, 0.35, 0.35, + 0.833, 0.50, 0.35, 0.35, + }; + + curve.resize (25); + curve.at (0 ) = double (FCT_MinMaxCPoints); + + for (size_t i = 1; i < curve.size(); ++i) { + curve.at (i) = v[i - 1]; + } + +} + +void LocallabParams::getDefaultLocalgainCurveTrab (std::vector &curve) +{ + + double v[12] = { 0.00, 0.12, 0.35, 0.35, + 0.70, 0.50, 0.35, 0.35, + 1.00, 0.12, 0.35, 0.35, + }; + + + curve.resize (13); + curve.at (0 ) = double (FCT_MinMaxCPoints); + + for (size_t i = 1; i < curve.size(); ++i) { + curve.at (i) = v[i - 1]; + } + +} + +void LocallabParams::getDefaultLLCurve (std::vector &curve) +{ + double v[4] = { 0.00, 0.00, + // 0.499, 0.501, + 1.00, 1.00 + }; + + curve.resize (5); + curve.at (0) = double (DCT_NURBS); + + for (size_t i = 1; i < curve.size(); ++i) { + curve.at (i) = v[i - 1]; + } +} + + +void LocallabParams::getCurves (LocretigainCurve &cTgainCurve, LocretigainCurverab &cTgainCurverab, LocLHCurve &lhCurve) const +{ + cTgainCurve.Set (this->localTgaincurve); + cTgainCurverab.Set (this->localTgaincurverab); + lhCurve.Set (this->LHcurve); +} + void RAWParams::setDefaults() { bayersensor.method = RAWParams::BayerSensor::methodstring[RAWParams::BayerSensor::amaze]; @@ -976,32 +1142,32 @@ void ProcParams::setDefaults () labCurve.lcredsk = true; labCurve.rstprotection = 0; labCurve.lcurve.clear (); - labCurve.lcurve.push_back(DCT_Linear); + labCurve.lcurve.push_back (DCT_Linear); labCurve.acurve.clear (); - labCurve.acurve.push_back(DCT_Linear); + labCurve.acurve.push_back (DCT_Linear); labCurve.bcurve.clear (); - labCurve.bcurve.push_back(DCT_Linear); + labCurve.bcurve.push_back (DCT_Linear); labCurve.cccurve.clear (); - labCurve.cccurve.push_back(DCT_Linear); + labCurve.cccurve.push_back (DCT_Linear); labCurve.chcurve.clear (); - labCurve.chcurve.push_back(FCT_Linear); + labCurve.chcurve.push_back (FCT_Linear); labCurve.lhcurve.clear (); - labCurve.lhcurve.push_back(FCT_Linear); + labCurve.lhcurve.push_back (FCT_Linear); labCurve.hhcurve.clear (); - labCurve.hhcurve.push_back(FCT_Linear); + labCurve.hhcurve.push_back (FCT_Linear); labCurve.lccurve.clear (); - labCurve.lccurve.push_back(DCT_Linear); + labCurve.lccurve.push_back (DCT_Linear); labCurve.clcurve.clear (); - labCurve.clcurve.push_back(DCT_Linear); + labCurve.clcurve.push_back (DCT_Linear); rgbCurves.lumamode = false; rgbCurves.rcurve.clear (); - rgbCurves.rcurve.push_back(DCT_Linear); + rgbCurves.rcurve.push_back (DCT_Linear); rgbCurves.gcurve.clear (); - rgbCurves.gcurve.push_back(DCT_Linear); + rgbCurves.gcurve.push_back (DCT_Linear); rgbCurves.bcurve.clear (); - rgbCurves.bcurve.push_back(DCT_Linear); + rgbCurves.bcurve.push_back (DCT_Linear); colorToning.setDefaults(); @@ -1018,7 +1184,7 @@ void ProcParams::setDefaults () sharpening.enabled = false; sharpening.radius = 0.5; sharpening.amount = 200; - sharpening.threshold.setValues(20, 80, 2000, 1200); + sharpening.threshold.setValues (20, 80, 2000, 1200); sharpening.edgesonly = false; sharpening.edges_radius = 1.9; sharpening.edges_tolerance = 1800; @@ -1033,7 +1199,7 @@ void ProcParams::setDefaults () prsharpening.enabled = false; prsharpening.radius = 0.5; prsharpening.amount = 200; - prsharpening.threshold.setValues(20, 80, 2000, 1200); + prsharpening.threshold.setValues (20, 80, 2000, 1200); prsharpening.edgesonly = false; prsharpening.edges_radius = 1.9; prsharpening.edges_tolerance = 1800; @@ -1048,12 +1214,12 @@ void ProcParams::setDefaults () vibrance.enabled = false; vibrance.pastels = 0; vibrance.saturated = 0; - vibrance.psthreshold.setValues(0, 75); + vibrance.psthreshold.setValues (0, 75); vibrance.protectskins = false; vibrance.avoidcolorshift = true; vibrance.pastsattog = true; vibrance.skintonescurve.clear (); - vibrance.skintonescurve.push_back(DCT_Linear); + vibrance.skintonescurve.push_back (DCT_Linear); wb.method = "Camera"; wb.temperature = 6504; @@ -1085,13 +1251,13 @@ void ProcParams::setDefaults () colorappearance.tonecie = false; // colorappearance.sharpcie = false; colorappearance.curve.clear (); - colorappearance.curve.push_back(DCT_Linear); + colorappearance.curve.push_back (DCT_Linear); colorappearance.curve2.clear (); - colorappearance.curve2.push_back(DCT_Linear); + colorappearance.curve2.push_back (DCT_Linear); colorappearance.curveMode = ColorAppearanceParams::TC_MODE_LIGHT; colorappearance.curveMode2 = ColorAppearanceParams::TC_MODE_LIGHT; colorappearance.curve3.clear (); - colorappearance.curve3.push_back(DCT_Linear); + colorappearance.curve3.push_back (DCT_Linear); colorappearance.curveMode3 = ColorAppearanceParams::TC_MODE_CHROMA; impulseDenoise.enabled = false; @@ -1101,31 +1267,31 @@ void ProcParams::setDefaults () defringe.radius = 2.0; defringe.threshold = 13; defringe.huecurve.resize (25); - defringe.huecurve.at(0) = FCT_MinMaxCPoints; - defringe.huecurve.at(1) = 0.166666667; - defringe.huecurve.at(2) = 0.; - defringe.huecurve.at(3) = 0.35; - defringe.huecurve.at(4) = 0.35; - defringe.huecurve.at(5) = 0.347; - defringe.huecurve.at(6) = 0.; - defringe.huecurve.at(7) = 0.35; - defringe.huecurve.at(8) = 0.35; - defringe.huecurve.at(9) = 0.513667426; - defringe.huecurve.at(10) = 0; - defringe.huecurve.at(11) = 0.35; - defringe.huecurve.at(12) = 0.35; - defringe.huecurve.at(13) = 0.668944571; - defringe.huecurve.at(14) = 0.; - defringe.huecurve.at(15) = 0.35; - defringe.huecurve.at(16) = 0.35; - defringe.huecurve.at(17) = 0.8287775246; - defringe.huecurve.at(18) = 0.97835991; - defringe.huecurve.at(19) = 0.35; - defringe.huecurve.at(20) = 0.35; - defringe.huecurve.at(21) = 0.9908883827; - defringe.huecurve.at(22) = 0.; - defringe.huecurve.at(23) = 0.35; - defringe.huecurve.at(24) = 0.35; + defringe.huecurve.at (0) = FCT_MinMaxCPoints; + defringe.huecurve.at (1) = 0.166666667; + defringe.huecurve.at (2) = 0.; + defringe.huecurve.at (3) = 0.35; + defringe.huecurve.at (4) = 0.35; + defringe.huecurve.at (5) = 0.347; + defringe.huecurve.at (6) = 0.; + defringe.huecurve.at (7) = 0.35; + defringe.huecurve.at (8) = 0.35; + defringe.huecurve.at (9) = 0.513667426; + defringe.huecurve.at (10) = 0; + defringe.huecurve.at (11) = 0.35; + defringe.huecurve.at (12) = 0.35; + defringe.huecurve.at (13) = 0.668944571; + defringe.huecurve.at (14) = 0.; + defringe.huecurve.at (15) = 0.35; + defringe.huecurve.at (16) = 0.35; + defringe.huecurve.at (17) = 0.8287775246; + defringe.huecurve.at (18) = 0.97835991; + defringe.huecurve.at (19) = 0.35; + defringe.huecurve.at (20) = 0.35; + defringe.huecurve.at (21) = 0.9908883827; + defringe.huecurve.at (22) = 0.; + defringe.huecurve.at (23) = 0.35; + defringe.huecurve.at (24) = 0.35; dirpyrDenoise.setDefaults(); @@ -1220,10 +1386,10 @@ void ProcParams::setDefaults () blackwhite.filter = "None"; blackwhite.setting = "NormalContrast"; blackwhite.beforeCurve.clear (); - blackwhite.beforeCurve.push_back(DCT_Linear); + blackwhite.beforeCurve.push_back (DCT_Linear); blackwhite.beforeCurveMode = BlackWhiteParams::TC_MODE_STD_BW; blackwhite.afterCurve.clear (); - blackwhite.afterCurve.push_back(DCT_Linear); + blackwhite.afterCurve.push_back (DCT_Linear); blackwhite.afterCurveMode = BlackWhiteParams::TC_MODE_STD_BW; blackwhite.algo = "SP"; @@ -1242,13 +1408,13 @@ void ProcParams::setDefaults () dirpyrequalizer.cbdlMethod = "bef"; - for(int i = 0; i < 6; i ++) { + for (int i = 0; i < 6; i ++) { dirpyrequalizer.mult[i] = 1.0; } dirpyrequalizer.threshold = 0.2; dirpyrequalizer.skinprotect = 0.; - dirpyrequalizer.hueskin.setValues(-5, 25, 170, 120); //default (b_l 0, t_l 30, b_r 170, t_r 120); + dirpyrequalizer.hueskin.setValues (-5, 25, 170, 120); //default (b_l 0, t_l 30, b_r 170, t_r 120); // dirpyrequalizer.algo = "FI"; hsvequalizer.hcurve.clear (); @@ -1268,58 +1434,58 @@ void ProcParams::setDefaults () rank = 0; colorlabel = 0; inTrash = false; - + prot = 1; ppVersion = PPVERSION; } -static Glib::ustring expandRelativePath(const Glib::ustring &procparams_fname, const Glib::ustring &prefix, Glib::ustring embedded_fname) +static Glib::ustring expandRelativePath (const Glib::ustring &procparams_fname, const Glib::ustring &prefix, Glib::ustring embedded_fname) { - if (embedded_fname == "" || !Glib::path_is_absolute(procparams_fname)) { + if (embedded_fname == "" || !Glib::path_is_absolute (procparams_fname)) { return embedded_fname; } if (prefix != "") { - if (embedded_fname.length() < prefix.length() || embedded_fname.substr(0, prefix.length()) != prefix) { + if (embedded_fname.length() < prefix.length() || embedded_fname.substr (0, prefix.length()) != prefix) { return embedded_fname; } - embedded_fname = embedded_fname.substr(prefix.length()); + embedded_fname = embedded_fname.substr (prefix.length()); } - if (Glib::path_is_absolute(embedded_fname)) { + if (Glib::path_is_absolute (embedded_fname)) { return prefix + embedded_fname; } - Glib::ustring absPath = prefix + Glib::path_get_dirname(procparams_fname) + G_DIR_SEPARATOR_S + embedded_fname; + Glib::ustring absPath = prefix + Glib::path_get_dirname (procparams_fname) + G_DIR_SEPARATOR_S + embedded_fname; return absPath; } -static Glib::ustring relativePathIfInside(const Glib::ustring &procparams_fname, bool fnameAbsolute, Glib::ustring embedded_fname) +static Glib::ustring relativePathIfInside (const Glib::ustring &procparams_fname, bool fnameAbsolute, Glib::ustring embedded_fname) { - if (fnameAbsolute || embedded_fname == "" || !Glib::path_is_absolute(procparams_fname)) { + if (fnameAbsolute || embedded_fname == "" || !Glib::path_is_absolute (procparams_fname)) { return embedded_fname; } Glib::ustring prefix = ""; - if (embedded_fname.length() > 5 && embedded_fname.substr(0, 5) == "file:") { - embedded_fname = embedded_fname.substr(5); + if (embedded_fname.length() > 5 && embedded_fname.substr (0, 5) == "file:") { + embedded_fname = embedded_fname.substr (5); prefix = "file:"; } - if (!Glib::path_is_absolute(embedded_fname)) { + if (!Glib::path_is_absolute (embedded_fname)) { return prefix + embedded_fname; } - Glib::ustring dir1 = Glib::path_get_dirname(procparams_fname) + G_DIR_SEPARATOR_S; - Glib::ustring dir2 = Glib::path_get_dirname(embedded_fname) + G_DIR_SEPARATOR_S; + Glib::ustring dir1 = Glib::path_get_dirname (procparams_fname) + G_DIR_SEPARATOR_S; + Glib::ustring dir2 = Glib::path_get_dirname (embedded_fname) + G_DIR_SEPARATOR_S; - if (dir2.substr(0, dir1.length()) != dir1) { + if (dir2.substr (0, dir1.length()) != dir1) { // it's in a different directory, ie not inside return prefix + embedded_fname; } - return prefix + embedded_fname.substr(dir1.length()); + return prefix + embedded_fname.substr (dir1.length()); } int ProcParams::save (const Glib::ustring &fname, const Glib::ustring &fname2, bool fnameAbsolute, ParamsEdited* pedited) @@ -1404,29 +1570,29 @@ int ProcParams::save (const Glib::ustring &fname, const Glib::ustring &fname2, b Glib::ustring method; switch (toneCurve.curveMode) { - case (ToneCurveParams::TC_MODE_STD): - method = "Standard"; - break; + case (ToneCurveParams::TC_MODE_STD): + method = "Standard"; + break; - case (ToneCurveParams::TC_MODE_FILMLIKE): - method = "FilmLike"; - break; + case (ToneCurveParams::TC_MODE_FILMLIKE): + method = "FilmLike"; + break; - case (ToneCurveParams::TC_MODE_SATANDVALBLENDING): - method = "SatAndValueBlending"; - break; + case (ToneCurveParams::TC_MODE_SATANDVALBLENDING): + method = "SatAndValueBlending"; + break; - case (ToneCurveParams::TC_MODE_WEIGHTEDSTD): - method = "WeightedStd"; - break; + case (ToneCurveParams::TC_MODE_WEIGHTEDSTD): + method = "WeightedStd"; + break; - case (ToneCurveParams::TC_MODE_LUMINANCE): - method = "Luminance"; - break; + case (ToneCurveParams::TC_MODE_LUMINANCE): + method = "Luminance"; + break; - case (ToneCurveParams::TC_MODE_PERCEPTUAL): - method = "Perceptual"; - break; + case (ToneCurveParams::TC_MODE_PERCEPTUAL): + method = "Perceptual"; + break; } keyFile.set_string ("Exposure", "CurveMode", method); @@ -1436,29 +1602,29 @@ int ProcParams::save (const Glib::ustring &fname, const Glib::ustring &fname2, b Glib::ustring method; switch (toneCurve.curveMode2) { - case (ToneCurveParams::TC_MODE_STD): - method = "Standard"; - break; + case (ToneCurveParams::TC_MODE_STD): + method = "Standard"; + break; - case (ToneCurveParams::TC_MODE_FILMLIKE): - method = "FilmLike"; - break; + case (ToneCurveParams::TC_MODE_FILMLIKE): + method = "FilmLike"; + break; - case (ToneCurveParams::TC_MODE_SATANDVALBLENDING): - method = "SatAndValueBlending"; - break; + case (ToneCurveParams::TC_MODE_SATANDVALBLENDING): + method = "SatAndValueBlending"; + break; - case (ToneCurveParams::TC_MODE_WEIGHTEDSTD): - method = "WeightedStd"; - break; + case (ToneCurveParams::TC_MODE_WEIGHTEDSTD): + method = "WeightedStd"; + break; - case (ToneCurveParams::TC_MODE_LUMINANCE): - method = "Luminance"; - break; + case (ToneCurveParams::TC_MODE_LUMINANCE): + method = "Luminance"; + break; - case (ToneCurveParams::TC_MODE_PERCEPTUAL): - method = "Perceptual"; - break; + case (ToneCurveParams::TC_MODE_PERCEPTUAL): + method = "Perceptual"; + break; } keyFile.set_string ("Exposure", "CurveMode2", method); @@ -1466,12 +1632,12 @@ int ProcParams::save (const Glib::ustring &fname, const Glib::ustring &fname2, b if (!pedited || pedited->toneCurve.curve) { Glib::ArrayHandle tcurve = toneCurve.curve; - keyFile.set_double_list("Exposure", "Curve", tcurve); + keyFile.set_double_list ("Exposure", "Curve", tcurve); } if (!pedited || pedited->toneCurve.curve2) { Glib::ArrayHandle tcurve = toneCurve.curve2; - keyFile.set_double_list("Exposure", "Curve2", tcurve); + keyFile.set_double_list ("Exposure", "Curve2", tcurve); } //save retinex @@ -1568,22 +1734,22 @@ int ProcParams::save (const Glib::ustring &fname, const Glib::ustring &fname2, b if (!pedited || pedited->retinex.cdcurve) { Glib::ArrayHandle cdcurve = retinex.cdcurve; - keyFile.set_double_list("Retinex", "CDCurve", cdcurve); + keyFile.set_double_list ("Retinex", "CDCurve", cdcurve); } if (!pedited || pedited->retinex.mapcurve) { Glib::ArrayHandle mapcurve = retinex.mapcurve; - keyFile.set_double_list("Retinex", "MAPCurve", mapcurve); + keyFile.set_double_list ("Retinex", "MAPCurve", mapcurve); } if (!pedited || pedited->retinex.cdHcurve) { Glib::ArrayHandle cdHcurve = retinex.cdHcurve; - keyFile.set_double_list("Retinex", "CDHCurve", cdHcurve); + keyFile.set_double_list ("Retinex", "CDHCurve", cdHcurve); } if (!pedited || pedited->retinex.lhcurve) { Glib::ArrayHandle lhcurve = retinex.lhcurve; - keyFile.set_double_list("Retinex", "LHCurve", lhcurve); + keyFile.set_double_list ("Retinex", "LHCurve", lhcurve); } if (!pedited || pedited->retinex.highlights) { @@ -1608,28 +1774,28 @@ int ProcParams::save (const Glib::ustring &fname, const Glib::ustring &fname2, b if (!pedited || pedited->retinex.transmissionCurve) { Glib::ArrayHandle transmissionCurve = retinex.transmissionCurve; - keyFile.set_double_list("Retinex", "TransmissionCurve", transmissionCurve); + keyFile.set_double_list ("Retinex", "TransmissionCurve", transmissionCurve); } if (!pedited || pedited->retinex.gaintransmissionCurve) { Glib::ArrayHandle gaintransmissionCurve = retinex.gaintransmissionCurve; - keyFile.set_double_list("Retinex", "GainTransmissionCurve", gaintransmissionCurve); + keyFile.set_double_list ("Retinex", "GainTransmissionCurve", gaintransmissionCurve); } // save channel mixer if (!pedited || pedited->chmixer.red[0] || pedited->chmixer.red[1] || pedited->chmixer.red[2]) { Glib::ArrayHandle rmix (chmixer.red, 3, Glib::OWNERSHIP_NONE); - keyFile.set_integer_list("Channel Mixer", "Red", rmix); + keyFile.set_integer_list ("Channel Mixer", "Red", rmix); } if (!pedited || pedited->chmixer.green[0] || pedited->chmixer.green[1] || pedited->chmixer.green[2]) { Glib::ArrayHandle gmix (chmixer.green, 3, Glib::OWNERSHIP_NONE); - keyFile.set_integer_list("Channel Mixer", "Green", gmix); + keyFile.set_integer_list ("Channel Mixer", "Green", gmix); } if (!pedited || pedited->chmixer.blue[0] || pedited->chmixer.blue[1] || pedited->chmixer.blue[2]) { Glib::ArrayHandle bmix (chmixer.blue, 3, Glib::OWNERSHIP_NONE); - keyFile.set_integer_list("Channel Mixer", "Blue", bmix); + keyFile.set_integer_list ("Channel Mixer", "Blue", bmix); } //save Black & White @@ -1707,28 +1873,28 @@ int ProcParams::save (const Glib::ustring &fname, const Glib::ustring &fname2, b if (!pedited || pedited->blackwhite.luminanceCurve) { Glib::ArrayHandle luminanceCurve = blackwhite.luminanceCurve; - keyFile.set_double_list("Black & White", "LuminanceCurve", luminanceCurve); + keyFile.set_double_list ("Black & White", "LuminanceCurve", luminanceCurve); } if (!pedited || pedited->blackwhite.beforeCurveMode) { Glib::ustring mode; switch (blackwhite.beforeCurveMode) { - case (BlackWhiteParams::TC_MODE_STD_BW): - mode = "Standard"; - break; + case (BlackWhiteParams::TC_MODE_STD_BW): + mode = "Standard"; + break; - case (BlackWhiteParams::TC_MODE_FILMLIKE_BW): - mode = "FilmLike"; - break; + case (BlackWhiteParams::TC_MODE_FILMLIKE_BW): + mode = "FilmLike"; + break; - case (BlackWhiteParams::TC_MODE_SATANDVALBLENDING_BW): - mode = "SatAndValueBlending"; - break; + case (BlackWhiteParams::TC_MODE_SATANDVALBLENDING_BW): + mode = "SatAndValueBlending"; + break; - case (BlackWhiteParams::TC_MODE_WEIGHTEDSTD_BW): - mode = "WeightedStd"; - break; + case (BlackWhiteParams::TC_MODE_WEIGHTEDSTD_BW): + mode = "WeightedStd"; + break; } keyFile.set_string ("Black & White", "BeforeCurveMode", mode); @@ -1738,16 +1904,16 @@ int ProcParams::save (const Glib::ustring &fname, const Glib::ustring &fname2, b Glib::ustring mode; switch (blackwhite.afterCurveMode) { - case (BlackWhiteParams::TC_MODE_STD_BW): - mode = "Standard"; - break; + case (BlackWhiteParams::TC_MODE_STD_BW): + mode = "Standard"; + break; - case (BlackWhiteParams::TC_MODE_WEIGHTEDSTD_BW): - mode = "WeightedStd"; - break; + case (BlackWhiteParams::TC_MODE_WEIGHTEDSTD_BW): + mode = "WeightedStd"; + break; - default: - break; + default: + break; } keyFile.set_string ("Black & White", "AfterCurveMode", mode); @@ -1755,12 +1921,12 @@ int ProcParams::save (const Glib::ustring &fname, const Glib::ustring &fname2, b if (!pedited || pedited->blackwhite.beforeCurve) { Glib::ArrayHandle tcurvebw = blackwhite.beforeCurve; - keyFile.set_double_list("Black & White", "BeforeCurve", tcurvebw); + keyFile.set_double_list ("Black & White", "BeforeCurve", tcurvebw); } if (!pedited || pedited->blackwhite.afterCurve) { Glib::ArrayHandle tcurvebw = blackwhite.afterCurve; - keyFile.set_double_list("Black & White", "AfterCurve", tcurvebw); + keyFile.set_double_list ("Black & White", "AfterCurve", tcurvebw); } // save luma curve @@ -1790,47 +1956,47 @@ int ProcParams::save (const Glib::ustring &fname, const Glib::ustring &fname2, b if (!pedited || pedited->labCurve.lcurve) { Glib::ArrayHandle lcurve = labCurve.lcurve; - keyFile.set_double_list("Luminance Curve", "LCurve", lcurve); + keyFile.set_double_list ("Luminance Curve", "LCurve", lcurve); } if (!pedited || pedited->labCurve.acurve) { Glib::ArrayHandle acurve = labCurve.acurve; - keyFile.set_double_list("Luminance Curve", "aCurve", acurve); + keyFile.set_double_list ("Luminance Curve", "aCurve", acurve); } if (!pedited || pedited->labCurve.bcurve) { Glib::ArrayHandle bcurve = labCurve.bcurve; - keyFile.set_double_list("Luminance Curve", "bCurve", bcurve); + keyFile.set_double_list ("Luminance Curve", "bCurve", bcurve); } if (!pedited || pedited->labCurve.cccurve) { Glib::ArrayHandle cccurve = labCurve.cccurve; - keyFile.set_double_list("Luminance Curve", "ccCurve", cccurve); + keyFile.set_double_list ("Luminance Curve", "ccCurve", cccurve); } if (!pedited || pedited->labCurve.chcurve) { Glib::ArrayHandle chcurve = labCurve.chcurve; - keyFile.set_double_list("Luminance Curve", "chCurve", chcurve); + keyFile.set_double_list ("Luminance Curve", "chCurve", chcurve); } if (!pedited || pedited->labCurve.lhcurve) { Glib::ArrayHandle lhcurve = labCurve.lhcurve; - keyFile.set_double_list("Luminance Curve", "lhCurve", lhcurve); + keyFile.set_double_list ("Luminance Curve", "lhCurve", lhcurve); } if (!pedited || pedited->labCurve.hhcurve) { Glib::ArrayHandle hhcurve = labCurve.hhcurve; - keyFile.set_double_list("Luminance Curve", "hhCurve", hhcurve); + keyFile.set_double_list ("Luminance Curve", "hhCurve", hhcurve); } if (!pedited || pedited->labCurve.lccurve) { Glib::ArrayHandle lccurve = labCurve.lccurve; - keyFile.set_double_list("Luminance Curve", "LcCurve", lccurve); + keyFile.set_double_list ("Luminance Curve", "LcCurve", lccurve); } if (!pedited || pedited->labCurve.clcurve) { Glib::ArrayHandle clcurve = labCurve.clcurve; - keyFile.set_double_list("Luminance Curve", "ClCurve", clcurve); + keyFile.set_double_list ("Luminance Curve", "ClCurve", clcurve); } // save sharpening @@ -1852,7 +2018,7 @@ int ProcParams::save (const Glib::ustring &fname, const Glib::ustring &fname2, b if (!pedited || pedited->sharpening.threshold) { Glib::ArrayHandle thresh (sharpening.threshold.value, 4, Glib::OWNERSHIP_NONE); - keyFile.set_integer_list("Sharpening", "Threshold", thresh); + keyFile.set_integer_list ("Sharpening", "Threshold", thresh); } if (!pedited || pedited->sharpening.edgesonly) { @@ -1906,7 +2072,7 @@ int ProcParams::save (const Glib::ustring &fname, const Glib::ustring &fname2, b if (!pedited || pedited->vibrance.psthreshold) { Glib::ArrayHandle thresh (vibrance.psthreshold.value, 2, Glib::OWNERSHIP_NONE); - keyFile.set_integer_list("Vibrance", "PSThreshold", thresh); + keyFile.set_integer_list ("Vibrance", "PSThreshold", thresh); } if (!pedited || pedited->vibrance.protectskins) { @@ -1923,7 +2089,7 @@ int ProcParams::save (const Glib::ustring &fname, const Glib::ustring &fname2, b if (!pedited || pedited->vibrance.skintonescurve) { Glib::ArrayHandle skintonescurve = vibrance.skintonescurve; - keyFile.set_double_list("Vibrance", "SkinTonesCurve", skintonescurve); + keyFile.set_double_list ("Vibrance", "SkinTonesCurve", skintonescurve); } //save edge sharpening @@ -2090,13 +2256,13 @@ int ProcParams::save (const Glib::ustring &fname, const Glib::ustring &fname2, b Glib::ustring method; switch (colorappearance.curveMode) { - case (ColorAppearanceParams::TC_MODE_LIGHT): - method = "Lightness"; - break; + case (ColorAppearanceParams::TC_MODE_LIGHT): + method = "Lightness"; + break; - case (ColorAppearanceParams::TC_MODE_BRIGHT): - method = "Brightness"; - break; + case (ColorAppearanceParams::TC_MODE_BRIGHT): + method = "Brightness"; + break; } keyFile.set_string ("Color appearance", "CurveMode", method); @@ -2106,13 +2272,13 @@ int ProcParams::save (const Glib::ustring &fname, const Glib::ustring &fname2, b Glib::ustring method; switch (colorappearance.curveMode2) { - case (ColorAppearanceParams::TC_MODE_LIGHT): - method = "Lightness"; - break; + case (ColorAppearanceParams::TC_MODE_LIGHT): + method = "Lightness"; + break; - case (ColorAppearanceParams::TC_MODE_BRIGHT): - method = "Brightness"; - break; + case (ColorAppearanceParams::TC_MODE_BRIGHT): + method = "Brightness"; + break; } keyFile.set_string ("Color appearance", "CurveMode2", method); @@ -2122,17 +2288,17 @@ int ProcParams::save (const Glib::ustring &fname, const Glib::ustring &fname2, b Glib::ustring method; switch (colorappearance.curveMode3) { - case (ColorAppearanceParams::TC_MODE_CHROMA): - method = "Chroma"; - break; + case (ColorAppearanceParams::TC_MODE_CHROMA): + method = "Chroma"; + break; - case (ColorAppearanceParams::TC_MODE_SATUR): - method = "Saturation"; - break; + case (ColorAppearanceParams::TC_MODE_SATUR): + method = "Saturation"; + break; - case (ColorAppearanceParams::TC_MODE_COLORF): - method = "Colorfullness"; - break; + case (ColorAppearanceParams::TC_MODE_COLORF): + method = "Colorfullness"; + break; } @@ -2141,17 +2307,17 @@ int ProcParams::save (const Glib::ustring &fname, const Glib::ustring &fname2, b if (!pedited || pedited->colorappearance.curve) { Glib::ArrayHandle tcurve = colorappearance.curve; - keyFile.set_double_list("Color appearance", "Curve", tcurve); + keyFile.set_double_list ("Color appearance", "Curve", tcurve); } if (!pedited || pedited->colorappearance.curve2) { Glib::ArrayHandle tcurve = colorappearance.curve2; - keyFile.set_double_list("Color appearance", "Curve2", tcurve); + keyFile.set_double_list ("Color appearance", "Curve2", tcurve); } if (!pedited || pedited->colorappearance.curve3) { Glib::ArrayHandle tcurve = colorappearance.curve3; - keyFile.set_double_list("Color appearance", "Curve3", tcurve); + keyFile.set_double_list ("Color appearance", "Curve3", tcurve); } @@ -2180,7 +2346,7 @@ int ProcParams::save (const Glib::ustring &fname, const Glib::ustring &fname2, b if (!pedited || pedited->defringe.huecurve) { Glib::ArrayHandle huecurve = defringe.huecurve; - keyFile.set_double_list("Defringing", "HueCurve", huecurve); + keyFile.set_double_list ("Defringing", "HueCurve", huecurve); } // save dirpyrDenoise @@ -2223,7 +2389,7 @@ int ProcParams::save (const Glib::ustring &fname, const Glib::ustring &fname2, b // never save 'auto chroma preview mode' to pp3 if (!pedited || pedited->dirpyrDenoise.Cmethod) { - if(dirpyrDenoise.Cmethod == "PRE") { + if (dirpyrDenoise.Cmethod == "PRE") { dirpyrDenoise.Cmethod = "MAN"; } @@ -2231,7 +2397,7 @@ int ProcParams::save (const Glib::ustring &fname, const Glib::ustring &fname2, b } if (!pedited || pedited->dirpyrDenoise.C2method) { - if(dirpyrDenoise.C2method == "PREV") { + if (dirpyrDenoise.C2method == "PREV") { dirpyrDenoise.C2method = "MANU"; } @@ -2272,12 +2438,12 @@ int ProcParams::save (const Glib::ustring &fname, const Glib::ustring &fname2, b if (!pedited || pedited->dirpyrDenoise.lcurve) { Glib::ArrayHandle lcurve = dirpyrDenoise.lcurve; - keyFile.set_double_list("Directional Pyramid Denoising", "LCurve", lcurve); + keyFile.set_double_list ("Directional Pyramid Denoising", "LCurve", lcurve); } if (!pedited || pedited->dirpyrDenoise.cccurve) { Glib::ArrayHandle cccurve = dirpyrDenoise.cccurve; - keyFile.set_double_list("Directional Pyramid Denoising", "CCCurve", cccurve); + keyFile.set_double_list ("Directional Pyramid Denoising", "CCCurve", cccurve); } //Save epd. @@ -2418,7 +2584,7 @@ int ProcParams::save (const Glib::ustring &fname, const Glib::ustring &fname2, b // lens profile if (!pedited || pedited->lensProf.lcpFile) { - keyFile.set_string ("LensProfile", "LCPFile", relativePathIfInside(fname, fnameAbsolute, lensProf.lcpFile)); + keyFile.set_string ("LensProfile", "LCPFile", relativePathIfInside (fname, fnameAbsolute, lensProf.lcpFile)); } if (!pedited || pedited->lensProf.useDist) { @@ -2467,6 +2633,282 @@ int ProcParams::save (const Glib::ustring &fname, const Glib::ustring &fname2, b keyFile.set_integer ("Gradient", "CenterY", gradient.centerY); } + // save Local lab + if (!pedited || pedited->locallab.enabled) { + keyFile.set_boolean ("Locallab", "Enabled", locallab.enabled); + } + + if (!pedited || pedited->locallab.expcolor) { + keyFile.set_boolean ("Locallab", "Expcolor", locallab.expcolor); + } + + if (!pedited || pedited->locallab.expblur) { + keyFile.set_boolean ("Locallab", "Expblur", locallab.expblur); + } + + if (!pedited || pedited->locallab.exptonemap) { + keyFile.set_boolean ("Locallab", "Exptonemap", locallab.exptonemap); + } + + if (!pedited || pedited->locallab.expreti) { + keyFile.set_boolean ("Locallab", "Expreti", locallab.expreti); + } + + if (!pedited || pedited->locallab.expsharp) { + keyFile.set_boolean ("Locallab", "Expsharp", locallab.expsharp); + } + + if (!pedited || pedited->locallab.expcbdl) { + keyFile.set_boolean ("Locallab", "Expcbdl", locallab.expcbdl); + } + + if (!pedited || pedited->locallab.expdenoi) { + keyFile.set_boolean ("Locallab", "Expdenoi", locallab.expdenoi); + } + + if (!pedited || pedited->locallab.localTgaincurve) { + Glib::ArrayHandle localTgaincurve = locallab.localTgaincurve; + keyFile.set_double_list ("Locallab", "TgainCurve", localTgaincurve); + } + + if (!pedited || pedited->locallab.llcurve) { + Glib::ArrayHandle llcurve = locallab.llcurve; + keyFile.set_double_list ("Locallab", "LLCurve", llcurve); + } + + if (!pedited || pedited->locallab.LHcurve) { + Glib::ArrayHandle LHcurve = locallab.LHcurve; + keyFile.set_double_list ("Locallab", "LHCurve", LHcurve); + } + + if (!pedited || pedited->locallab.localTgaincurverab) { + Glib::ArrayHandle localTgaincurverab = locallab.localTgaincurverab; + keyFile.set_double_list ("Locallab", "TgainCurverab", localTgaincurverab); + } + + if (!pedited || pedited->locallab.avoid) { + keyFile.set_boolean ("Locallab", "Avoid", locallab.avoid); + } + + if (!pedited || pedited->locallab.invers) { + keyFile.set_boolean ("Locallab", "Invers", locallab.invers); + } + + if (!pedited || pedited->locallab.curvactiv) { + keyFile.set_boolean ("Locallab", "Curvactiv", locallab.curvactiv); + } + + if (!pedited || pedited->locallab.activlum) { + keyFile.set_boolean ("Locallab", "activlum", locallab.activlum); + } + + if (!pedited || pedited->locallab.inversrad) { + keyFile.set_boolean ("Locallab", "Inversrad", locallab.inversrad); + } + + if (!pedited || pedited->locallab.inverssha) { + keyFile.set_boolean ("Locallab", "Inverssha", locallab.inverssha); + } + + if (!pedited || pedited->locallab.inversret) { + keyFile.set_boolean ("Locallab", "Inversret", locallab.inversret); + } + + if (!pedited || pedited->locallab.degree) { + keyFile.set_double ("Locallab", "Degree", locallab.degree); + } + + if (!pedited || pedited->locallab.Smethod) { + keyFile.set_string ("Locallab", "Smethod", locallab.Smethod); + } + + if (!pedited || pedited->locallab.retinexMethod) { + keyFile.set_string ("Locallab", "retinexMethod", locallab.retinexMethod); + } + + if (!pedited || pedited->locallab.qualityMethod) { + keyFile.set_string ("Locallab", "qualityMethod", locallab.qualityMethod); + } + + if (!pedited || pedited->locallab.locY) { + keyFile.set_integer ("Locallab", "LocY", locallab.locY); + } + + if (!pedited || pedited->locallab.locX) { + keyFile.set_integer ("Locallab", "LocX", locallab.locX); + } + + if (!pedited || pedited->locallab.locYT) { + keyFile.set_integer ("Locallab", "LocYT", locallab.locYT); + } + + if (!pedited || pedited->locallab.locXL) { + keyFile.set_integer ("Locallab", "LocXL", locallab.locXL); + } + + if (!pedited || pedited->locallab.centerX) { + keyFile.set_integer ("Locallab", "CenterX", locallab.centerX); + } + + if (!pedited || pedited->locallab.centerY) { + keyFile.set_integer ("Locallab", "CenterY", locallab.centerY); + } + + if (!pedited || pedited->locallab.circrad) { + keyFile.set_integer ("Locallab", "Circrad", locallab.circrad); + } + + if (!pedited || pedited->locallab.thres) { + keyFile.set_integer ("Locallab", "Thres", locallab.thres); + } + + if (!pedited || pedited->locallab.proxi) { + keyFile.set_integer ("Locallab", "Proxi", locallab.proxi); + } + + if (!pedited || pedited->locallab.lightness) { + keyFile.set_integer ("Locallab", "Lightness", locallab.lightness); + } + + if (!pedited || pedited->locallab.contrast) { + keyFile.set_integer ("Locallab", "Contrast", locallab.contrast); + } + + if (!pedited || pedited->locallab.chroma) { + keyFile.set_integer ("Locallab", "Chroma", locallab.chroma); + } + + if (!pedited || pedited->locallab.noiselumf) { + keyFile.set_integer ("Locallab", "noiselumf", locallab.noiselumf); + } + + if (!pedited || pedited->locallab.noiselumc) { + keyFile.set_integer ("Locallab", "noiselumc", locallab.noiselumc); + } + + if (!pedited || pedited->locallab.noisechrof) { + keyFile.set_integer ("Locallab", "noisechrof", locallab.noisechrof); + } + + if (!pedited || pedited->locallab.noisechroc) { + keyFile.set_integer ("Locallab", "noisechroc", locallab.noisechroc); + } + + if (!pedited || pedited->locallab.sharradius) { + keyFile.set_integer ("Locallab", "Sharradius", locallab.sharradius); + } + + if (!pedited || pedited->locallab.sharamount) { + keyFile.set_integer ("Locallab", "Sharamount", locallab.sharamount); + } + + if (!pedited || pedited->locallab.shardamping) { + keyFile.set_integer ("Locallab", "Shardamping", locallab.shardamping); + } + + if (!pedited || pedited->locallab.shariter) { + keyFile.set_integer ("Locallab", "Shariter", locallab.shariter); + } + + if (!pedited || pedited->locallab.sensi) { + keyFile.set_integer ("Locallab", "Sensi", locallab.sensi); + } + + if (!pedited || pedited->locallab.sensitm) { + keyFile.set_integer ("Locallab", "Sensitm", locallab.sensitm); + } + + if (!pedited || pedited->locallab.sensisha) { + keyFile.set_integer ("Locallab", "Sensisha", locallab.sensisha); + } + + if (!pedited || pedited->locallab.sensih) { + keyFile.set_integer ("Locallab", "Sensih", locallab.sensih); + } + + if (!pedited || pedited->locallab.retrab) { + keyFile.set_integer ("Locallab", "Retrab", locallab.retrab); + } + + + if (!pedited || pedited->locallab.sensicb) { + keyFile.set_integer ("Locallab", "Sensicb", locallab.sensicb); + } + + if (!pedited || pedited->locallab.sensibn) { + keyFile.set_integer ("Locallab", "Sensibn", locallab.sensibn); + } + + if (!pedited || pedited->locallab.transit) { + keyFile.set_integer ("Locallab", "Transit", locallab.transit); + } + + if (!pedited || pedited->locallab.chrrt) { + keyFile.set_integer ("Locallab", "Chrrt", locallab.chrrt); + } + + if (!pedited || pedited->locallab.str) { + keyFile.set_integer ("Locallab", "Str", locallab.str); + } + + if (!pedited || pedited->locallab.neigh) { + keyFile.set_integer ("Locallab", "Neigh", locallab.neigh); + } + + if (!pedited || pedited->locallab.nbspot) { + keyFile.set_integer ("Locallab", "Nbspot", locallab.nbspot); + } + + if (!pedited || pedited->locallab.anbspot) { + keyFile.set_integer ("Locallab", "ANbspot", locallab.anbspot); + } + + if (!pedited || pedited->locallab.vart) { + keyFile.set_integer ("Locallab", "Vart", locallab.vart); + } + + if (!pedited || pedited->locallab.radius) { + keyFile.set_integer ("Locallab", "Radius", locallab.radius); + } + + if (!pedited || pedited->locallab.strength) { + keyFile.set_integer ("Locallab", "Strength", locallab.strength); + } + + for (int i = 0; i < 5; i++) { + std::stringstream ss; + ss << "Mult" << i; + + if (!pedited || pedited->locallab.mult[i]) { + keyFile.set_integer ("Locallab", ss.str(), locallab.mult[i]); + } + } + + if (!pedited || pedited->locallab.threshold) { + keyFile.set_integer ("Locallab", "Threshold", locallab.threshold); + } + + if (!pedited || pedited->locallab.stren) { + keyFile.set_integer ("Locallab", "Stren", locallab.stren); + } + + if (!pedited || pedited->locallab.gamma) { + keyFile.set_integer ("Locallab", "Gamma", locallab.gamma); + } + + if (!pedited || pedited->locallab.estop) { + keyFile.set_integer ("Locallab", "Estop", locallab.estop); + } + + if (!pedited || pedited->locallab.scaltm) { + keyFile.set_integer ("Locallab", "Scaltm", locallab.scaltm); + } + + if (!pedited || pedited->locallab.rewei) { + keyFile.set_integer ("Locallab", "Rewei", locallab.rewei); + } + + // save post-crop vignette if (!pedited || pedited->pcvignette.enabled) { keyFile.set_boolean ("PCVignette", "Enabled", pcvignette.enabled); @@ -2561,7 +3003,7 @@ int ProcParams::save (const Glib::ustring &fname, const Glib::ustring &fname2, b if (!pedited || pedited->prsharpening.threshold) { Glib::ArrayHandle thresh (prsharpening.threshold.value, 4, Glib::OWNERSHIP_NONE); - keyFile.set_integer_list("PostResizeSharpening", "Threshold", thresh); + keyFile.set_integer_list ("PostResizeSharpening", "Threshold", thresh); } if (!pedited || pedited->prsharpening.edgesonly) { @@ -2603,7 +3045,7 @@ int ProcParams::save (const Glib::ustring &fname, const Glib::ustring &fname2, b // save color management settings if (!pedited || pedited->icm.input) { - keyFile.set_string ("Color Management", "InputProfile", relativePathIfInside(fname, fnameAbsolute, icm.input)); + keyFile.set_string ("Color Management", "InputProfile", relativePathIfInside (fname, fnameAbsolute, icm.input)); } if (!pedited || pedited->icm.toneCurve) { @@ -2642,22 +3084,22 @@ int ProcParams::save (const Glib::ustring &fname, const Glib::ustring &fname2, b Glib::ustring intent; switch (icm.outputIntent) { - default: - case RI_PERCEPTUAL: - intent = "Perceptual"; - break; + default: + case RI_PERCEPTUAL: + intent = "Perceptual"; + break; - case RI_RELATIVE: - intent = "Relative"; - break; + case RI_RELATIVE: + intent = "Relative"; + break; - case RI_SATURATION: - intent = "Saturation"; - break; + case RI_SATURATION: + intent = "Saturation"; + break; - case RI_ABSOLUTE: - intent = "Absolute"; - break; + case RI_ABSOLUTE: + intent = "Absolute"; + break; } keyFile.set_string ("Color Management", "OutputProfileIntent", intent); @@ -2782,21 +3224,21 @@ int ProcParams::save (const Glib::ustring &fname, const Glib::ustring &fname2, b keyFile.set_boolean ("Wavelet", "Expnoise", wavelet.expnoise); } - for(int i = 0; i < 9; i++) { + for (int i = 0; i < 9; i++) { std::stringstream ss; ss << "Contrast" << (i + 1); if (!pedited || pedited->wavelet.c[i]) { - keyFile.set_integer("Wavelet", ss.str(), wavelet.c[i]); + keyFile.set_integer ("Wavelet", ss.str(), wavelet.c[i]); } } - for(int i = 0; i < 9; i++) { + for (int i = 0; i < 9; i++) { std::stringstream ss; ss << "Chroma" << (i + 1); if (!pedited || pedited->wavelet.ch[i]) { - keyFile.set_integer("Wavelet", ss.str(), wavelet.ch[i]); + keyFile.set_integer ("Wavelet", ss.str(), wavelet.ch[i]); } } @@ -2810,37 +3252,37 @@ int ProcParams::save (const Glib::ustring &fname, const Glib::ustring &fname2, b if (!pedited || pedited->wavelet.hllev) { Glib::ArrayHandle thresh (wavelet.hllev.value, 4, Glib::OWNERSHIP_NONE); - keyFile.set_integer_list("Wavelet", "HLRange", thresh); + keyFile.set_integer_list ("Wavelet", "HLRange", thresh); } if (!pedited || pedited->wavelet.bllev) { Glib::ArrayHandle thresh (wavelet.bllev.value, 4, Glib::OWNERSHIP_NONE); - keyFile.set_integer_list("Wavelet", "SHRange", thresh); + keyFile.set_integer_list ("Wavelet", "SHRange", thresh); } if (!pedited || pedited->wavelet.edgcont) { Glib::ArrayHandle thresh (wavelet.edgcont.value, 4, Glib::OWNERSHIP_NONE); - keyFile.set_integer_list("Wavelet", "Edgcont", thresh); + keyFile.set_integer_list ("Wavelet", "Edgcont", thresh); } if (!pedited || pedited->wavelet.level0noise) { Glib::ArrayHandle thresh (wavelet.level0noise.value, 2, Glib::OWNERSHIP_NONE); - keyFile.set_double_list("Wavelet", "Level0noise", thresh); + keyFile.set_double_list ("Wavelet", "Level0noise", thresh); } if (!pedited || pedited->wavelet.level1noise) { Glib::ArrayHandle thresh (wavelet.level1noise.value, 2, Glib::OWNERSHIP_NONE); - keyFile.set_double_list("Wavelet", "Level1noise", thresh); + keyFile.set_double_list ("Wavelet", "Level1noise", thresh); } if (!pedited || pedited->wavelet.level2noise) { Glib::ArrayHandle thresh (wavelet.level2noise.value, 2, Glib::OWNERSHIP_NONE); - keyFile.set_double_list("Wavelet", "Level2noise", thresh); + keyFile.set_double_list ("Wavelet", "Level2noise", thresh); } if (!pedited || pedited->wavelet.level3noise) { Glib::ArrayHandle thresh (wavelet.level3noise.value, 2, Glib::OWNERSHIP_NONE); - keyFile.set_double_list("Wavelet", "Level3noise", thresh); + keyFile.set_double_list ("Wavelet", "Level3noise", thresh); } @@ -2910,52 +3352,52 @@ int ProcParams::save (const Glib::ustring &fname, const Glib::ustring &fname2, b if (!pedited || pedited->wavelet.ccwcurve) { Glib::ArrayHandle ccwcurve = wavelet.ccwcurve; - keyFile.set_double_list("Wavelet", "ContrastCurve", ccwcurve); + keyFile.set_double_list ("Wavelet", "ContrastCurve", ccwcurve); } if (!pedited || pedited->wavelet.pastlev) { Glib::ArrayHandle thresh (wavelet.pastlev.value, 4, Glib::OWNERSHIP_NONE); - keyFile.set_integer_list("Wavelet", "Pastlev", thresh); + keyFile.set_integer_list ("Wavelet", "Pastlev", thresh); } if (!pedited || pedited->wavelet.satlev) { Glib::ArrayHandle thresh (wavelet.satlev.value, 4, Glib::OWNERSHIP_NONE); - keyFile.set_integer_list("Wavelet", "Satlev", thresh); + keyFile.set_integer_list ("Wavelet", "Satlev", thresh); } if (!pedited || pedited->wavelet.opacityCurveRG) { Glib::ArrayHandle curve = wavelet.opacityCurveRG; - keyFile.set_double_list("Wavelet", "OpacityCurveRG", curve); + keyFile.set_double_list ("Wavelet", "OpacityCurveRG", curve); } if (!pedited || pedited->wavelet.opacityCurveBY) { Glib::ArrayHandle curve = wavelet.opacityCurveBY; - keyFile.set_double_list("Wavelet", "OpacityCurveBY", curve); + keyFile.set_double_list ("Wavelet", "OpacityCurveBY", curve); } if (!pedited || pedited->wavelet.opacityCurveW) { Glib::ArrayHandle curve = wavelet.opacityCurveW; - keyFile.set_double_list("Wavelet", "OpacityCurveW", curve); + keyFile.set_double_list ("Wavelet", "OpacityCurveW", curve); } if (!pedited || pedited->wavelet.opacityCurveWL) { Glib::ArrayHandle curve = wavelet.opacityCurveWL; - keyFile.set_double_list("Wavelet", "OpacityCurveWL", curve); + keyFile.set_double_list ("Wavelet", "OpacityCurveWL", curve); } if (!pedited || pedited->wavelet.hhcurve) { Glib::ArrayHandle curve = wavelet.hhcurve; - keyFile.set_double_list("Wavelet", "HHcurve", curve); + keyFile.set_double_list ("Wavelet", "HHcurve", curve); } if (!pedited || pedited->wavelet.Chcurve) { Glib::ArrayHandle curve = wavelet.Chcurve; - keyFile.set_double_list("Wavelet", "CHcurve", curve); + keyFile.set_double_list ("Wavelet", "CHcurve", curve); } if (!pedited || pedited->wavelet.wavclCurve) { Glib::ArrayHandle wavclCurve = wavelet.wavclCurve; - keyFile.set_double_list("Wavelet", "WavclCurve", wavclCurve); + keyFile.set_double_list ("Wavelet", "WavclCurve", wavclCurve); } @@ -2986,7 +3428,7 @@ int ProcParams::save (const Glib::ustring &fname, const Glib::ustring &fname2, b if (!pedited || pedited->wavelet.hueskin) { Glib::ArrayHandle thresh (wavelet.hueskin.value, 4, Glib::OWNERSHIP_NONE); - keyFile.set_integer_list("Wavelet", "Hueskin", thresh); + keyFile.set_integer_list ("Wavelet", "Hueskin", thresh); } if (!pedited || pedited->wavelet.edgrad) { @@ -3046,7 +3488,7 @@ int ProcParams::save (const Glib::ustring &fname, const Glib::ustring &fname2, b if (!pedited || pedited->wavelet.hueskin2) { Glib::ArrayHandle thresh (wavelet.hueskin2.value, 4, Glib::OWNERSHIP_NONE); - keyFile.set_integer_list("Wavelet", "HueRange", thresh); + keyFile.set_integer_list ("Wavelet", "HueRange", thresh); } if (!pedited || pedited->wavelet.contrast) { @@ -3067,12 +3509,12 @@ int ProcParams::save (const Glib::ustring &fname, const Glib::ustring &fname2, b keyFile.set_string ("Directional Pyramid Equalizer", "cbdlMethod", dirpyrequalizer.cbdlMethod); } - for(int i = 0; i < 6; i++) { + for (int i = 0; i < 6; i++) { std::stringstream ss; ss << "Mult" << i; if (!pedited || pedited->dirpyrequalizer.mult[i]) { - keyFile.set_double("Directional Pyramid Equalizer", ss.str(), dirpyrequalizer.mult[i]); + keyFile.set_double ("Directional Pyramid Equalizer", ss.str(), dirpyrequalizer.mult[i]); } } @@ -3087,28 +3529,28 @@ int ProcParams::save (const Glib::ustring &fname, const Glib::ustring &fname2, b // if (!pedited || pedited->dirpyrequalizer.algo) keyFile.set_string ("Directional Pyramid Equalizer", "Algorithm", dirpyrequalizer.algo); if (!pedited || pedited->dirpyrequalizer.hueskin) { Glib::ArrayHandle thresh (dirpyrequalizer.hueskin.value, 4, Glib::OWNERSHIP_NONE); - keyFile.set_integer_list("Directional Pyramid Equalizer", "Hueskin", thresh); + keyFile.set_integer_list ("Directional Pyramid Equalizer", "Hueskin", thresh); } // save hsv wavelet parameters if (!pedited || pedited->hsvequalizer.hcurve) { Glib::ArrayHandle hcurve = hsvequalizer.hcurve; - keyFile.set_double_list("HSV Equalizer", "HCurve", hcurve); + keyFile.set_double_list ("HSV Equalizer", "HCurve", hcurve); } if (!pedited || pedited->hsvequalizer.scurve) { Glib::ArrayHandle scurve = hsvequalizer.scurve; - keyFile.set_double_list("HSV Equalizer", "SCurve", scurve); + keyFile.set_double_list ("HSV Equalizer", "SCurve", scurve); } if (!pedited || pedited->hsvequalizer.vcurve) { Glib::ArrayHandle vcurve = hsvequalizer.vcurve; - keyFile.set_double_list("HSV Equalizer", "VCurve", vcurve); + keyFile.set_double_list ("HSV Equalizer", "VCurve", vcurve); } //save film simulation parameters if ( !pedited || pedited->filmSimulation.enabled ) { - keyFile.set_boolean( "Film Simulation", "Enabled", filmSimulation.enabled ); + keyFile.set_boolean ( "Film Simulation", "Enabled", filmSimulation.enabled ); } if ( !pedited || pedited->filmSimulation.clutFilename ) { @@ -3116,7 +3558,7 @@ int ProcParams::save (const Glib::ustring &fname, const Glib::ustring &fname2, b } if ( !pedited || pedited->filmSimulation.strength ) { - keyFile.set_integer( "Film Simulation", "Strength", filmSimulation.strength ); + keyFile.set_integer ( "Film Simulation", "Strength", filmSimulation.strength ); } @@ -3126,17 +3568,17 @@ int ProcParams::save (const Glib::ustring &fname, const Glib::ustring &fname2, b if (!pedited || pedited->rgbCurves.rcurve) { Glib::ArrayHandle RGBrcurve = rgbCurves.rcurve; - keyFile.set_double_list("RGB Curves", "rCurve", RGBrcurve); + keyFile.set_double_list ("RGB Curves", "rCurve", RGBrcurve); } if (!pedited || pedited->rgbCurves.gcurve) { Glib::ArrayHandle RGBgcurve = rgbCurves.gcurve; - keyFile.set_double_list("RGB Curves", "gCurve", RGBgcurve); + keyFile.set_double_list ("RGB Curves", "gCurve", RGBgcurve); } if (!pedited || pedited->rgbCurves.bcurve) { Glib::ArrayHandle RGBbcurve = rgbCurves.bcurve; - keyFile.set_double_list("RGB Curves", "bCurve", RGBbcurve); + keyFile.set_double_list ("RGB Curves", "bCurve", RGBbcurve); } // save Color Toning @@ -3210,12 +3652,12 @@ int ProcParams::save (const Glib::ustring &fname, const Glib::ustring &fname2, b if (!pedited || pedited->colorToning.opacityCurve) { Glib::ArrayHandle curve = colorToning.opacityCurve; - keyFile.set_double_list("ColorToning", "OpacityCurve", curve); + keyFile.set_double_list ("ColorToning", "OpacityCurve", curve); } if (!pedited || pedited->colorToning.colorCurve) { Glib::ArrayHandle curve = colorToning.colorCurve; - keyFile.set_double_list("ColorToning", "ColorCurve", curve); + keyFile.set_double_list ("ColorToning", "ColorCurve", curve); } if (!pedited || pedited->colorToning.satprotectionthreshold) { @@ -3232,27 +3674,27 @@ int ProcParams::save (const Glib::ustring &fname, const Glib::ustring &fname2, b if (!pedited || pedited->colorToning.hlColSat) { Glib::ArrayHandle thresh (colorToning.hlColSat.value, 2, Glib::OWNERSHIP_NONE); - keyFile.set_integer_list("ColorToning", "HighlightsColorSaturation", thresh); + keyFile.set_integer_list ("ColorToning", "HighlightsColorSaturation", thresh); } if (!pedited || pedited->colorToning.shadowsColSat) { Glib::ArrayHandle thresh (colorToning.shadowsColSat.value, 2, Glib::OWNERSHIP_NONE); - keyFile.set_integer_list("ColorToning", "ShadowsColorSaturation", thresh); + keyFile.set_integer_list ("ColorToning", "ShadowsColorSaturation", thresh); } if (!pedited || pedited->colorToning.clcurve) { Glib::ArrayHandle clcurve = colorToning.clcurve; - keyFile.set_double_list("ColorToning", "ClCurve", clcurve); + keyFile.set_double_list ("ColorToning", "ClCurve", clcurve); } if (!pedited || pedited->colorToning.cl2curve) { Glib::ArrayHandle cl2curve = colorToning.cl2curve; - keyFile.set_double_list("ColorToning", "Cl2Curve", cl2curve); + keyFile.set_double_list ("ColorToning", "Cl2Curve", cl2curve); } // save raw parameters if (!pedited || pedited->raw.darkFrame) { - keyFile.set_string ("RAW", "DarkFrame", relativePathIfInside(fname, fnameAbsolute, raw.dark_frame) ); + keyFile.set_string ("RAW", "DarkFrame", relativePathIfInside (fname, fnameAbsolute, raw.dark_frame) ); } if (!pedited || pedited->raw.dfAuto) { @@ -3260,7 +3702,7 @@ int ProcParams::save (const Glib::ustring &fname, const Glib::ustring &fname2, b } if (!pedited || pedited->raw.ff_file) { - keyFile.set_string ("RAW", "FlatFieldFile", relativePathIfInside(fname, fnameAbsolute, raw.ff_file) ); + keyFile.set_string ("RAW", "FlatFieldFile", relativePathIfInside (fname, fnameAbsolute, raw.ff_file) ); } if (!pedited || pedited->raw.ff_AutoSelect) { @@ -3408,7 +3850,7 @@ int ProcParams::save (const Glib::ustring &fname, const Glib::ustring &fname2, b sPParams = keyFile.to_data(); - } catch(Glib::KeyFileError&) {} + } catch (Glib::KeyFileError&) {} if (sPParams.empty ()) { return 1; @@ -3449,7 +3891,7 @@ int ProcParams::write (const Glib::ustring &fname, const Glib::ustring &content) int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) { - setlocale(LC_NUMERIC, "C"); // to set decimal point to "." + setlocale (LC_NUMERIC, "C"); // to set decimal point to "." if (fname.empty()) { return 1; @@ -3460,7 +3902,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) try { if (pedited) { - pedited->set(false); + pedited->set (false); } FILE* f = g_fopen (fname.c_str (), "rt"); @@ -3676,6 +4118,10 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) } } + + + + if (keyFile.has_group ("HLRecovery")) { if (keyFile.has_key ("HLRecovery", "Enabled")) { toneCurve.hrenabled = keyFile.get_boolean ("HLRecovery", "Enabled"); @@ -3694,6 +4140,549 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) } } + + // load Local Lab + if (keyFile.has_group ("Locallab")) { + if (keyFile.has_key ("Locallab", "Enabled")) { + locallab.enabled = keyFile.get_boolean ("Locallab", "Enabled"); + + if (pedited) { + pedited->locallab.enabled = true; + } + } + + if (keyFile.has_key ("Locallab", "Expcolor")) { + locallab.expcolor = keyFile.get_boolean ("Locallab", "Expcolor"); + + if (pedited) { + pedited->locallab.expcolor = true; + } + } + + if (keyFile.has_key ("Locallab", "Expblur")) { + locallab.expblur = keyFile.get_boolean ("Locallab", "Expblur"); + + if (pedited) { + pedited->locallab.expblur = true; + } + } + + if (keyFile.has_key ("Locallab", "Exptonemap")) { + locallab.exptonemap = keyFile.get_boolean ("Locallab", "Exptonemap"); + + if (pedited) { + pedited->locallab.exptonemap = true; + } + } + + if (keyFile.has_key ("Locallab", "Expreti")) { + locallab.expreti = keyFile.get_boolean ("Locallab", "Expreti"); + + if (pedited) { + pedited->locallab.expreti = true; + } + } + + if (keyFile.has_key ("Locallab", "Expsharp")) { + locallab.expsharp = keyFile.get_boolean ("Locallab", "Expsharp"); + + if (pedited) { + pedited->locallab.expsharp = true; + } + } + + if (keyFile.has_key ("Locallab", "Expdenoi")) { + locallab.expdenoi = keyFile.get_boolean ("Locallab", "Expdenoi"); + + if (pedited) { + pedited->locallab.expdenoi = true; + } + } + + if (keyFile.has_key ("Locallab", "Avoid")) { + locallab.avoid = keyFile.get_boolean ("Locallab", "Avoid"); + + if (pedited) { + pedited->locallab.avoid = true; + } + } + + if (keyFile.has_key ("Locallab", "TgainCurve")) { + locallab.localTgaincurve = keyFile.get_double_list ("Locallab", "TgainCurve"); + + if (pedited) { + pedited->locallab.localTgaincurve = true; + } + } + + if (keyFile.has_key ("Locallab", "LLCurve")) { + locallab.llcurve = keyFile.get_double_list ("Locallab", "LLCurve"); + + if (pedited) { + pedited->locallab.llcurve = true; + } + } + + if (keyFile.has_key ("Locallab", "LHCurve")) { + locallab.LHcurve = keyFile.get_double_list ("Locallab", "LHCurve"); + + if (pedited) { + pedited->locallab.LHcurve = true; + } + } + + if (keyFile.has_key ("Locallab", "TgainCurverab")) { + locallab.localTgaincurverab = keyFile.get_double_list ("Locallab", "TgainCurverab"); + + if (pedited) { + pedited->locallab.localTgaincurverab = true; + } + } + + if (keyFile.has_key ("Locallab", "Invers")) { + locallab.invers = keyFile.get_boolean ("Locallab", "Invers"); + + if (pedited) { + pedited->locallab.invers = true; + } + } + + if (keyFile.has_key ("Locallab", "Curvactiv")) { + locallab.curvactiv = keyFile.get_boolean ("Locallab", "Curvactiv"); + + if (pedited) { + pedited->locallab.curvactiv = true; + } + } + + if (keyFile.has_key ("Locallab", "activlum")) { + locallab.activlum = keyFile.get_boolean ("Locallab", "activlum"); + + if (pedited) { + pedited->locallab.activlum = true; + } + } + + if (keyFile.has_key ("Locallab", "Inversrad")) { + locallab.inversrad = keyFile.get_boolean ("Locallab", "Inversrad"); + + if (pedited) { + pedited->locallab.inversrad = true; + } + } + + if (keyFile.has_key ("Locallab", "Inverssha")) { + locallab.inverssha = keyFile.get_boolean ("Locallab", "Inverssha"); + + if (pedited) { + pedited->locallab.inverssha = true; + } + } + + if (keyFile.has_key ("Locallab", "Inversret")) { + locallab.inversret = keyFile.get_boolean ("Locallab", "Inversret"); + + if (pedited) { + pedited->locallab.inversret = true; + } + } + + + if (keyFile.has_key ("Locallab", "Degree")) { + locallab.degree = keyFile.get_double ("Locallab", "Degree"); + + if (pedited) { + pedited->locallab.degree = true; + } + } + + if (keyFile.has_key ("Locallab", "Smethod")) { + locallab.Smethod = keyFile.get_string ("Locallab", "Smethod"); + + if (pedited) { + pedited->locallab.Smethod = true; + } + } + + if (keyFile.has_key ("Locallab", "retinexMethod")) { + locallab.retinexMethod = keyFile.get_string ("Locallab", "retinexMethod"); + + if (pedited) { + pedited->locallab.retinexMethod = true; + } + } + + if (keyFile.has_key ("Locallab", "qualityMethod")) { + locallab.qualityMethod = keyFile.get_string ("Locallab", "qualityMethod"); + + if (pedited) { + pedited->locallab.qualityMethod = true; + } + } + + if (keyFile.has_key ("Locallab", "LocY")) { + locallab.locY = keyFile.get_integer ("Locallab", "LocY"); + + if (pedited) { + pedited->locallab.locY = true; + } + } + + if (keyFile.has_key ("Locallab", "LocX")) { + locallab.locX = keyFile.get_integer ("Locallab", "LocX"); + + if (pedited) { + pedited->locallab.locX = true; + } + } + + if (keyFile.has_key ("Locallab", "LocYT")) { + locallab.locYT = keyFile.get_integer ("Locallab", "LocYT"); + + if (pedited) { + pedited->locallab.locYT = true; + } + } + + if (keyFile.has_key ("Locallab", "LocXL")) { + locallab.locXL = keyFile.get_integer ("Locallab", "LocXL"); + + if (pedited) { + pedited->locallab.locXL = true; + } + } + + if (keyFile.has_key ("Locallab", "CenterX")) { + locallab.centerX = keyFile.get_integer ("Locallab", "CenterX"); + + if (pedited) { + pedited->locallab.centerX = true; + } + } + + if (keyFile.has_key ("Locallab", "CenterY")) { + locallab.centerY = keyFile.get_integer ("Locallab", "CenterY"); + + if (pedited) { + pedited->locallab.centerY = true; + } + } + + if (keyFile.has_key ("Locallab", "Circrad")) { + locallab.circrad = keyFile.get_integer ("Locallab", "Circrad"); + + if (pedited) { + pedited->locallab.circrad = true; + } + } + + if (keyFile.has_key ("Locallab", "Thres")) { + locallab.thres = keyFile.get_integer ("Locallab", "Thres"); + + if (pedited) { + pedited->locallab.thres = true; + } + } + + + if (keyFile.has_key ("Locallab", "Proxi")) { + locallab.proxi = keyFile.get_integer ("Locallab", "Proxi"); + + if (pedited) { + pedited->locallab.proxi = true; + } + } + + if (keyFile.has_key ("Locallab", "Chroma")) { + locallab.chroma = keyFile.get_integer ("Locallab", "Chroma"); + + if (pedited) { + pedited->locallab.chroma = true; + } + } + + if (keyFile.has_key ("Locallab", "noiselumf")) { + locallab.noiselumf = keyFile.get_integer ("Locallab", "noiselumf"); + + if (pedited) { + pedited->locallab.noiselumf = true; + } + } + + if (keyFile.has_key ("Locallab", "noiselumc")) { + locallab.noiselumc = keyFile.get_integer ("Locallab", "noiselumc"); + + if (pedited) { + pedited->locallab.noiselumc = true; + } + } + + if (keyFile.has_key ("Locallab", "noisechrof")) { + locallab.noisechrof = keyFile.get_integer ("Locallab", "noisechrof"); + + if (pedited) { + pedited->locallab.noisechrof = true; + } + } + + if (keyFile.has_key ("Locallab", "noisechroc")) { + locallab.noisechroc = keyFile.get_integer ("Locallab", "noisechroc"); + + if (pedited) { + pedited->locallab.noisechroc = true; + } + } + + if (keyFile.has_key ("Locallab", "Sharradius")) { + locallab.sharradius = keyFile.get_integer ("Locallab", "Sharradius"); + + if (pedited) { + pedited->locallab.sharradius = true; + } + } + + if (keyFile.has_key ("Locallab", "Sharamount")) { + locallab.sharamount = keyFile.get_integer ("Locallab", "Sharamount"); + + if (pedited) { + pedited->locallab.sharamount = true; + } + } + + if (keyFile.has_key ("Locallab", "Shardamping")) { + locallab.shardamping = keyFile.get_integer ("Locallab", "Shardamping"); + + if (pedited) { + pedited->locallab.shardamping = true; + } + } + + if (keyFile.has_key ("Locallab", "Shariter")) { + locallab.shariter = keyFile.get_integer ("Locallab", "Shariter"); + + if (pedited) { + pedited->locallab.shariter = true; + } + } + + if (keyFile.has_key ("Locallab", "Sensi")) { + locallab.sensi = keyFile.get_integer ("Locallab", "Sensi"); + + if (pedited) { + pedited->locallab.sensi = true; + } + } + + if (keyFile.has_key ("Locallab", "Sensitm")) { + locallab.sensitm = keyFile.get_integer ("Locallab", "Sensitm"); + + if (pedited) { + pedited->locallab.sensitm = true; + } + } + + if (keyFile.has_key ("Locallab", "Sensisha")) { + locallab.sensisha = keyFile.get_integer ("Locallab", "Sensisha"); + + if (pedited) { + pedited->locallab.sensisha = true; + } + } + + if (keyFile.has_key ("Locallab", "Sensih")) { + locallab.sensih = keyFile.get_integer ("Locallab", "Sensih"); + + if (pedited) { + pedited->locallab.sensih = true; + } + } + + if (keyFile.has_key ("Locallab", "Retrab")) { + locallab.retrab = keyFile.get_integer ("Locallab", "Retrab"); + + if (pedited) { + pedited->locallab.retrab = true; + } + } + + + //RAS + + + if (keyFile.has_key ("Locallab", "Sensicb")) { + locallab.sensicb = keyFile.get_integer ("Locallab", "Sensicb"); + + if (pedited) { + pedited->locallab.sensicb = true; + } + } + + if (keyFile.has_key ("Locallab", "Sensibn")) { + locallab.sensibn = keyFile.get_integer ("Locallab", "Sensibn"); + + if (pedited) { + pedited->locallab.sensibn = true; + } + } + + + if (keyFile.has_key ("Locallab", "Transit")) { + locallab.transit = keyFile.get_integer ("Locallab", "Transit"); + + if (pedited) { + pedited->locallab.transit = true; + } + } + + + if (keyFile.has_key ("Locallab", "Chrrt")) { + locallab.chrrt = keyFile.get_integer ("Locallab", "Chrrt"); + + if (pedited) { + pedited->locallab.chrrt = true; + } + } + + if (keyFile.has_key ("Locallab", "Str")) { + locallab.str = keyFile.get_integer ("Locallab", "Str"); + + if (pedited) { + pedited->locallab.str = true; + } + } + + +//AFT + if (keyFile.has_key ("Locallab", "Neigh")) { + locallab.neigh = keyFile.get_integer ("Locallab", "Neigh"); + + if (pedited) { + pedited->locallab.neigh = true; + } + } + + if (keyFile.has_key ("Locallab", "Nbspot")) { + locallab.nbspot = keyFile.get_integer ("Locallab", "Nbspot"); + + if (pedited) { + pedited->locallab.nbspot = true; + } + } + + +//AFT + if (keyFile.has_key ("Locallab", "ANbspot")) { + locallab.anbspot = keyFile.get_integer ("Locallab", "ANbspot"); + + if (pedited) { + pedited->locallab.anbspot = true; + } + } + + if (keyFile.has_key ("Locallab", "Vart")) { + locallab.vart = keyFile.get_integer ("Locallab", "Vart"); + + if (pedited) { + pedited->locallab.vart = true; + } + } + + if (keyFile.has_key ("Locallab", "Lightness")) { + locallab.lightness = keyFile.get_integer ("Locallab", "Lightness"); + + if (pedited) { + pedited->locallab.lightness = true; + } + } + + if (keyFile.has_key ("Locallab", "Contrast")) { + locallab.contrast = keyFile.get_integer ("Locallab", "Contrast"); + + if (pedited) { + pedited->locallab.contrast = true; + } + } + +//IND + if (keyFile.has_key ("Locallab", "Radius")) { + locallab.radius = keyFile.get_integer ("Locallab", "Radius"); + + if (pedited) { + pedited->locallab.radius = true; + } + } + + if (keyFile.has_key ("Locallab", "Strength")) { + locallab.strength = keyFile.get_integer ("Locallab", "Strength"); + + if (pedited) { + pedited->locallab.strength = true; + } + } + + if (keyFile.has_key ("Locallab", "Stren")) { + locallab.stren = keyFile.get_integer ("Locallab", "Stren"); + + if (pedited) { + pedited->locallab.stren = true; + } + } + + if (keyFile.has_key ("Locallab", "Gamma")) { + locallab.gamma = keyFile.get_integer ("Locallab", "Gamma"); + + if (pedited) { + pedited->locallab.gamma = true; + } + } + + if (keyFile.has_key ("Locallab", "Estop")) { + locallab.estop = keyFile.get_integer ("Locallab", "Estop"); + + if (pedited) { + pedited->locallab.estop = true; + } + } + + if (keyFile.has_key ("Locallab", "Scaltm")) { + locallab.scaltm = keyFile.get_integer ("Locallab", "Scaltm"); + + if (pedited) { + pedited->locallab.scaltm = true; + } + } + + if (keyFile.has_key ("Locallab", "Rewei")) { + locallab.rewei = keyFile.get_integer ("Locallab", "Rewei"); + + if (pedited) { + pedited->locallab.rewei = true; + } + } + + for (int i = 0; i < 5; i ++) { + std::stringstream ss; + ss << "Mult" << i; + + if (keyFile.has_key ("Locallab", ss.str())) { + locallab.mult[i] = keyFile.get_integer ("Locallab", ss.str()); + + if (pedited) { + pedited->locallab.mult[i] = true; + } + } + } + + if (keyFile.has_key ("Locallab", "Threshold")) { + locallab.threshold = keyFile.get_integer ("Locallab", "Threshold"); + + if (pedited) { + pedited->locallab.threshold = true; + } + } + + } + // load channel mixer curve if (keyFile.has_group ("Channel Mixer")) { if (keyFile.has_key ("Channel Mixer", "Red") && keyFile.has_key ("Channel Mixer", "Green") && keyFile.has_key ("Channel Mixer", "Blue")) { @@ -3706,9 +4695,9 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) Glib::ArrayHandle rmix = keyFile.get_integer_list ("Channel Mixer", "Red"); Glib::ArrayHandle gmix = keyFile.get_integer_list ("Channel Mixer", "Green"); Glib::ArrayHandle bmix = keyFile.get_integer_list ("Channel Mixer", "Blue"); - memcpy (chmixer.red, rmix.data(), 3 * sizeof(int)); - memcpy (chmixer.green, gmix.data(), 3 * sizeof(int)); - memcpy (chmixer.blue, bmix.data(), 3 * sizeof(int)); + memcpy (chmixer.red, rmix.data(), 3 * sizeof (int)); + memcpy (chmixer.green, gmix.data(), 3 * sizeof (int)); + memcpy (chmixer.blue, bmix.data(), 3 * sizeof (int)); } } @@ -4380,11 +5369,11 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) if (keyFile.has_key ("Sharpening", "Threshold")) { if (ppVersion < 302) { - int thresh = min(keyFile.get_integer ("Sharpening", "Threshold"), 2000); - sharpening.threshold.setValues(thresh, thresh, 2000, 2000); // TODO: 2000 is the maximum value and is taken of rtgui/sharpening.cc ; should be changed by the tool modularization + int thresh = min (keyFile.get_integer ("Sharpening", "Threshold"), 2000); + sharpening.threshold.setValues (thresh, thresh, 2000, 2000); // TODO: 2000 is the maximum value and is taken of rtgui/sharpening.cc ; should be changed by the tool modularization } else { Glib::ArrayHandle thresh = keyFile.get_integer_list ("Sharpening", "Threshold"); - sharpening.threshold.setValues(thresh.data()[0], thresh.data()[1], min(thresh.data()[2], 2000), min(thresh.data()[3], 2000)); + sharpening.threshold.setValues (thresh.data()[0], thresh.data()[1], min (thresh.data()[2], 2000), min (thresh.data()[3], 2000)); } if (pedited) { @@ -4572,10 +5561,10 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) if (keyFile.has_key ("Vibrance", "PSThreshold")) { if (ppVersion < 302) { int thresh = keyFile.get_integer ("Vibrance", "PSThreshold"); - vibrance.psthreshold.setValues(thresh, thresh); + vibrance.psthreshold.setValues (thresh, thresh); } else { Glib::ArrayHandle thresh = keyFile.get_integer_list ("Vibrance", "PSThreshold"); - vibrance.psthreshold.setValues(thresh.data()[0], thresh.data()[1]); + vibrance.psthreshold.setValues (thresh.data()[0], thresh.data()[1]); } if (pedited) { @@ -4699,7 +5688,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) } if (ppVersion < 310) { - defringe.threshold = sqrt(defringe.threshold * 33.f / 5.f); + defringe.threshold = sqrt (defringe.threshold * 33.f / 5.f); } if (keyFile.has_key ("Defringing", "HueCurve")) { @@ -5075,7 +6064,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) } // never load 'auto chroma preview mode' from pp3 - if(dirpyrDenoise.Cmethod == "PRE") { + if (dirpyrDenoise.Cmethod == "PRE") { dirpyrDenoise.Cmethod = "MAN"; } @@ -5087,7 +6076,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) } } - if(dirpyrDenoise.C2method == "PREV") { + if (dirpyrDenoise.C2method == "PREV") { dirpyrDenoise.C2method = "MANU"; } @@ -5174,7 +6163,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) //Load EPD. if (keyFile.has_group ("EPD")) { - if(keyFile.has_key("EPD", "Enabled")) { + if (keyFile.has_key ("EPD", "Enabled")) { epd.enabled = keyFile.get_boolean ("EPD", "Enabled"); if (pedited) { @@ -5182,7 +6171,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) } } - if(keyFile.has_key("EPD", "Strength")) { + if (keyFile.has_key ("EPD", "Strength")) { epd.strength = keyFile.get_double ("EPD", "Strength"); if (pedited) { @@ -5190,7 +6179,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) } } - if(keyFile.has_key("EPD", "Gamma")) { + if (keyFile.has_key ("EPD", "Gamma")) { epd.gamma = keyFile.get_double ("EPD", "Gamma"); if (pedited) { @@ -5198,7 +6187,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) } } - if(keyFile.has_key("EPD", "EdgeStopping")) { + if (keyFile.has_key ("EPD", "EdgeStopping")) { epd.edgeStopping = keyFile.get_double ("EPD", "EdgeStopping"); if (pedited) { @@ -5206,7 +6195,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) } } - if(keyFile.has_key("EPD", "Scale")) { + if (keyFile.has_key ("EPD", "Scale")) { epd.scale = keyFile.get_double ("EPD", "Scale"); if (pedited) { @@ -5214,7 +6203,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) } } - if(keyFile.has_key("EPD", "ReweightingIterates")) { + if (keyFile.has_key ("EPD", "ReweightingIterates")) { epd.reweightingIterates = keyFile.get_integer ("EPD", "ReweightingIterates"); if (pedited) { @@ -5456,7 +6445,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) // lens profile if (keyFile.has_group ("LensProfile")) { if (keyFile.has_key ("LensProfile", "LCPFile")) { - lensProf.lcpFile = expandRelativePath(fname, "", keyFile.get_string ("LensProfile", "LCPFile")); + lensProf.lcpFile = expandRelativePath (fname, "", keyFile.get_string ("LensProfile", "LCPFile")); if (pedited) { pedited->lensProf.lcpFile = true; @@ -5741,11 +6730,11 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) if (keyFile.has_key ("PostResizeSharpening", "Threshold")) { if (ppVersion < 302) { - int thresh = min(keyFile.get_integer ("PostResizeSharpening", "Threshold"), 2000); - prsharpening.threshold.setValues(thresh, thresh, 2000, 2000); // TODO: 2000 is the maximum value and is taken of rtgui/sharpening.cc ; should be changed by the tool modularization + int thresh = min (keyFile.get_integer ("PostResizeSharpening", "Threshold"), 2000); + prsharpening.threshold.setValues (thresh, thresh, 2000, 2000); // TODO: 2000 is the maximum value and is taken of rtgui/sharpening.cc ; should be changed by the tool modularization } else { Glib::ArrayHandle thresh = keyFile.get_integer_list ("PostResizeSharpening", "Threshold"); - prsharpening.threshold.setValues(thresh.data()[0], thresh.data()[1], min(thresh.data()[2], 2000), min(thresh.data()[3], 2000)); + prsharpening.threshold.setValues (thresh.data()[0], thresh.data()[1], min (thresh.data()[2], 2000), min (thresh.data()[3], 2000)); } if (pedited) { @@ -5836,8 +6825,9 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) // load color management settings if (keyFile.has_group ("Color Management")) { + if (keyFile.has_key ("Color Management", "InputProfile")) { - icm.input = expandRelativePath(fname, "file:", keyFile.get_string ("Color Management", "InputProfile")); + icm.input = expandRelativePath (fname, "file:", keyFile.get_string ("Color Management", "InputProfile")); if (pedited) { pedited->icm.input = true; @@ -6469,7 +7459,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) if (keyFile.has_key ("Wavelet", "Hueskin")) { Glib::ArrayHandle thresh = keyFile.get_integer_list ("Wavelet", "Hueskin"); - wavelet.hueskin.setValues(thresh.data()[0], thresh.data()[1], min(thresh.data()[2], 300), min(thresh.data()[3], 300)); + wavelet.hueskin.setValues (thresh.data()[0], thresh.data()[1], min (thresh.data()[2], 300), min (thresh.data()[3], 300)); if (pedited) { pedited->wavelet.hueskin = true; @@ -6478,7 +7468,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) if (keyFile.has_key ("Wavelet", "HueRange")) { Glib::ArrayHandle thresh = keyFile.get_integer_list ("Wavelet", "HueRange"); - wavelet.hueskin2.setValues(thresh.data()[0], thresh.data()[1], min(thresh.data()[2], 300), min(thresh.data()[3], 300)); + wavelet.hueskin2.setValues (thresh.data()[0], thresh.data()[1], min (thresh.data()[2], 300), min (thresh.data()[3], 300)); if (pedited) { pedited->wavelet.hueskin2 = true; @@ -6487,7 +7477,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) if (keyFile.has_key ("Wavelet", "HLRange")) { Glib::ArrayHandle thresh = keyFile.get_integer_list ("Wavelet", "HLRange"); - wavelet.hllev.setValues(thresh.data()[0], thresh.data()[1], min(thresh.data()[2], 300), min(thresh.data()[3], 300)); + wavelet.hllev.setValues (thresh.data()[0], thresh.data()[1], min (thresh.data()[2], 300), min (thresh.data()[3], 300)); if (pedited) { pedited->wavelet.hllev = true; @@ -6496,7 +7486,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) if (keyFile.has_key ("Wavelet", "SHRange")) { Glib::ArrayHandle thresh = keyFile.get_integer_list ("Wavelet", "SHRange"); - wavelet.bllev.setValues(thresh.data()[0], thresh.data()[1], min(thresh.data()[2], 300), min(thresh.data()[3], 300)); + wavelet.bllev.setValues (thresh.data()[0], thresh.data()[1], min (thresh.data()[2], 300), min (thresh.data()[3], 300)); if (pedited) { pedited->wavelet.bllev = true; @@ -6505,7 +7495,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) if (keyFile.has_key ("Wavelet", "Edgcont")) { Glib::ArrayHandle thresh = keyFile.get_integer_list ("Wavelet", "Edgcont"); - wavelet.edgcont.setValues(thresh.data()[0], thresh.data()[1], min(thresh.data()[2], 300), min(thresh.data()[3], 300)); + wavelet.edgcont.setValues (thresh.data()[0], thresh.data()[1], min (thresh.data()[2], 300), min (thresh.data()[3], 300)); if (pedited) { pedited->wavelet.edgcont = true; @@ -6514,7 +7504,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) if (keyFile.has_key ("Wavelet", "Level0noise")) { Glib::ArrayHandle thresh = keyFile.get_double_list ("Wavelet", "Level0noise"); - wavelet.level0noise.setValues(thresh.data()[0], thresh.data()[1]); + wavelet.level0noise.setValues (thresh.data()[0], thresh.data()[1]); if (pedited) { pedited->wavelet.level0noise = true; @@ -6523,7 +7513,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) if (keyFile.has_key ("Wavelet", "Level1noise")) { Glib::ArrayHandle thresh = keyFile.get_double_list ("Wavelet", "Level1noise"); - wavelet.level1noise.setValues(thresh.data()[0], thresh.data()[1]); + wavelet.level1noise.setValues (thresh.data()[0], thresh.data()[1]); if (pedited) { pedited->wavelet.level1noise = true; @@ -6532,7 +7522,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) if (keyFile.has_key ("Wavelet", "Level2noise")) { Glib::ArrayHandle thresh = keyFile.get_double_list ("Wavelet", "Level2noise"); - wavelet.level2noise.setValues(thresh.data()[0], thresh.data()[1]); + wavelet.level2noise.setValues (thresh.data()[0], thresh.data()[1]); if (pedited) { pedited->wavelet.level2noise = true; @@ -6541,7 +7531,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) if (keyFile.has_key ("Wavelet", "Level3noise")) { Glib::ArrayHandle thresh = keyFile.get_double_list ("Wavelet", "Level3noise"); - wavelet.level3noise.setValues(thresh.data()[0], thresh.data()[1]); + wavelet.level3noise.setValues (thresh.data()[0], thresh.data()[1]); if (pedited) { pedited->wavelet.level3noise = true; @@ -6551,7 +7541,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) if (keyFile.has_key ("Wavelet", "Pastlev")) { Glib::ArrayHandle thresh = keyFile.get_integer_list ("Wavelet", "Pastlev"); - wavelet.pastlev.setValues(thresh.data()[0], thresh.data()[1], min(thresh.data()[2], 300), min(thresh.data()[3], 300)); + wavelet.pastlev.setValues (thresh.data()[0], thresh.data()[1], min (thresh.data()[2], 300), min (thresh.data()[3], 300)); if (pedited) { pedited->wavelet.pastlev = true; @@ -6560,7 +7550,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) if (keyFile.has_key ("Wavelet", "Satlev")) { Glib::ArrayHandle thresh = keyFile.get_integer_list ("Wavelet", "Satlev"); - wavelet.satlev.setValues(thresh.data()[0], thresh.data()[1], min(thresh.data()[2], 300), min(thresh.data()[3], 300)); + wavelet.satlev.setValues (thresh.data()[0], thresh.data()[1], min (thresh.data()[2], 300), min (thresh.data()[3], 300)); if (pedited) { pedited->wavelet.satlev = true; @@ -6568,7 +7558,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) } - if(keyFile.has_key ("Wavelet", "Skinprotect")) { + if (keyFile.has_key ("Wavelet", "Skinprotect")) { wavelet.skinprotect = keyFile.get_double ("Wavelet", "Skinprotect"); if (pedited) { @@ -6592,11 +7582,11 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) } } - for(int i = 0; i < 9; i ++) { + for (int i = 0; i < 9; i ++) { std::stringstream ss; ss << "Contrast" << (i + 1); - if(keyFile.has_key ("Wavelet", ss.str())) { + if (keyFile.has_key ("Wavelet", ss.str())) { wavelet.c[i] = keyFile.get_integer ("Wavelet", ss.str()); if (pedited) { @@ -6605,11 +7595,11 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) } } - for(int i = 0; i < 9; i ++) { + for (int i = 0; i < 9; i ++) { std::stringstream ss; ss << "Chroma" << (i + 1); - if(keyFile.has_key ("Wavelet", ss.str())) { + if (keyFile.has_key ("Wavelet", ss.str())) { wavelet.ch[i] = keyFile.get_integer ("Wavelet", ss.str()); if (pedited) { @@ -6692,7 +7682,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) // if (keyFile.has_key ("Directional Pyramid Equalizer", "Algorithm")) { dirpyrequalizer.algo = keyFile.get_string ("Directional Pyramid Equalizer", "Algorithm"); if (pedited) pedited->dirpyrequalizer.algo = true; } if (keyFile.has_key ("Directional Pyramid Equalizer", "Hueskin")) { Glib::ArrayHandle thresh = keyFile.get_integer_list ("Directional Pyramid Equalizer", "Hueskin"); - dirpyrequalizer.hueskin.setValues(thresh.data()[0], thresh.data()[1], min(thresh.data()[2], 300), min(thresh.data()[3], 300)); + dirpyrequalizer.hueskin.setValues (thresh.data()[0], thresh.data()[1], min (thresh.data()[2], 300), min (thresh.data()[3], 300)); if (pedited) { pedited->dirpyrequalizer.hueskin = true; @@ -6700,12 +7690,12 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) } if (ppVersion < 316) { - for(int i = 0; i < 5; i ++) { + for (int i = 0; i < 5; i ++) { std::stringstream ss; ss << "Mult" << i; - if(keyFile.has_key ("Directional Pyramid Equalizer", ss.str())) { - if(i == 4) { + if (keyFile.has_key ("Directional Pyramid Equalizer", ss.str())) { + if (i == 4) { dirpyrequalizer.threshold = keyFile.get_double ("Directional Pyramid Equalizer", ss.str()); if (pedited) { @@ -6724,11 +7714,11 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) dirpyrequalizer.mult[4] = 1.0; } else { // 5 level wavelet + dedicated threshold parameter - for(int i = 0; i < 6; i ++) { + for (int i = 0; i < 6; i ++) { std::stringstream ss; ss << "Mult" << i; - if(keyFile.has_key ("Directional Pyramid Equalizer", ss.str())) { + if (keyFile.has_key ("Directional Pyramid Equalizer", ss.str())) { dirpyrequalizer.mult[i] = keyFile.get_double ("Directional Pyramid Equalizer", ss.str()); if (pedited) { @@ -6737,7 +7727,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) } } - if(keyFile.has_key ("Directional Pyramid Equalizer", "Threshold")) { + if (keyFile.has_key ("Directional Pyramid Equalizer", "Threshold")) { dirpyrequalizer.threshold = keyFile.get_double ("Directional Pyramid Equalizer", "Threshold"); if (pedited) { @@ -6745,7 +7735,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) } } - if(keyFile.has_key ("Directional Pyramid Equalizer", "Skinprotect")) { + if (keyFile.has_key ("Directional Pyramid Equalizer", "Skinprotect")) { dirpyrequalizer.skinprotect = keyFile.get_double ("Directional Pyramid Equalizer", "Skinprotect"); if (pedited) { @@ -6756,28 +7746,28 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) } // load CLUT parameters - if ( keyFile.has_group( "Film Simulation" ) ) { - if ( keyFile.has_key( "Film Simulation", "Enabled" ) ) { - filmSimulation.enabled = keyFile.get_boolean( "Film Simulation", "Enabled" ); + if ( keyFile.has_group ( "Film Simulation" ) ) { + if ( keyFile.has_key ( "Film Simulation", "Enabled" ) ) { + filmSimulation.enabled = keyFile.get_boolean ( "Film Simulation", "Enabled" ); if ( pedited ) { pedited->filmSimulation.enabled = true; } } - if ( keyFile.has_key( "Film Simulation", "ClutFilename" ) ) { - filmSimulation.clutFilename = keyFile.get_string( "Film Simulation", "ClutFilename" ); + if ( keyFile.has_key ( "Film Simulation", "ClutFilename" ) ) { + filmSimulation.clutFilename = keyFile.get_string ( "Film Simulation", "ClutFilename" ); if ( pedited ) { pedited->filmSimulation.clutFilename = true; } } - if ( keyFile.has_key( "Film Simulation", "Strength" ) ) { + if ( keyFile.has_key ( "Film Simulation", "Strength" ) ) { if (ppVersion < 321) { - filmSimulation.strength = int(keyFile.get_double( "Film Simulation", "Strength" ) * 100 + 0.1); + filmSimulation.strength = int (keyFile.get_double ( "Film Simulation", "Strength" ) * 100 + 0.1); } else { - filmSimulation.strength = keyFile.get_integer( "Film Simulation", "Strength" ); + filmSimulation.strength = keyFile.get_integer ( "Film Simulation", "Strength" ); } if ( pedited ) { @@ -6934,7 +7924,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) if (keyFile.has_key ("ColorToning", "HighlightsColorSaturation")) { Glib::ArrayHandle thresh = keyFile.get_integer_list ("ColorToning", "HighlightsColorSaturation"); - colorToning.hlColSat.setValues(thresh.data()[0], thresh.data()[1]); + colorToning.hlColSat.setValues (thresh.data()[0], thresh.data()[1]); if (pedited) { pedited->colorToning.hlColSat = true; @@ -6943,7 +7933,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) if (keyFile.has_key ("ColorToning", "ShadowsColorSaturation")) { Glib::ArrayHandle thresh = keyFile.get_integer_list ("ColorToning", "ShadowsColorSaturation"); - colorToning.shadowsColSat.setValues(thresh.data()[0], thresh.data()[1]); + colorToning.shadowsColSat.setValues (thresh.data()[0], thresh.data()[1]); if (pedited) { pedited->colorToning.shadowsColSat = true; @@ -7066,7 +8056,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) // load raw settings if (keyFile.has_group ("RAW")) { if (keyFile.has_key ("RAW", "DarkFrame")) { - raw.dark_frame = expandRelativePath(fname, "", keyFile.get_string ("RAW", "DarkFrame" )); + raw.dark_frame = expandRelativePath (fname, "", keyFile.get_string ("RAW", "DarkFrame" )); if (pedited) { pedited->raw.darkFrame = true; @@ -7082,7 +8072,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) } if (keyFile.has_key ("RAW", "FlatFieldFile")) { - raw.ff_file = expandRelativePath(fname, "", keyFile.get_string ("RAW", "FlatFieldFile" )); + raw.ff_file = expandRelativePath (fname, "", keyFile.get_string ("RAW", "FlatFieldFile" )); if (pedited) { pedited->raw.ff_file = true; @@ -7195,7 +8185,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) } if (keyFile.has_key ("RAW", "PreExposure")) { - raw.expos = keyFile.get_double("RAW", "PreExposure"); + raw.expos = keyFile.get_double ("RAW", "PreExposure"); if (pedited) { pedited->raw.exPos = true; @@ -7203,7 +8193,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) } if (keyFile.has_key ("RAW", "PrePreserv")) { - raw.preser = keyFile.get_double("RAW", "PrePreserv"); + raw.preser = keyFile.get_double ("RAW", "PrePreserv"); if (pedited) { pedited->raw.exPreser = true; @@ -7244,7 +8234,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) } if (keyFile.has_key ("RAW", "DCBIterations")) { - raw.bayersensor.dcb_iterations = keyFile.get_integer("RAW", "DCBIterations"); + raw.bayersensor.dcb_iterations = keyFile.get_integer ("RAW", "DCBIterations"); if (pedited) { pedited->raw.bayersensor.dcbIterations = true; @@ -7252,7 +8242,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) } if (keyFile.has_key ("RAW", "DCBEnhance")) { - raw.bayersensor.dcb_enhance = keyFile.get_boolean("RAW", "DCBEnhance"); + raw.bayersensor.dcb_enhance = keyFile.get_boolean ("RAW", "DCBEnhance"); if (pedited) { pedited->raw.bayersensor.dcbEnhance = true; @@ -7260,7 +8250,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) } if (keyFile.has_key ("RAW", "LMMSEIterations")) { - raw.bayersensor.lmmse_iterations = keyFile.get_integer("RAW", "LMMSEIterations"); + raw.bayersensor.lmmse_iterations = keyFile.get_integer ("RAW", "LMMSEIterations"); if (pedited) { pedited->raw.bayersensor.lmmseIterations = true; @@ -7268,7 +8258,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) } if (keyFile.has_key ("RAW", "PreBlackzero")) { - raw.bayersensor.black0 = keyFile.get_double("RAW", "PreBlackzero"); + raw.bayersensor.black0 = keyFile.get_double ("RAW", "PreBlackzero"); if (pedited) { pedited->raw.bayersensor.exBlack0 = true; @@ -7276,7 +8266,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) } if (keyFile.has_key ("RAW", "PreBlackone")) { - raw.bayersensor.black1 = keyFile.get_double("RAW", "PreBlackone"); + raw.bayersensor.black1 = keyFile.get_double ("RAW", "PreBlackone"); if (pedited) { pedited->raw.bayersensor.exBlack1 = true; @@ -7284,7 +8274,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) } if (keyFile.has_key ("RAW", "PreBlacktwo")) { - raw.bayersensor.black2 = keyFile.get_double("RAW", "PreBlacktwo"); + raw.bayersensor.black2 = keyFile.get_double ("RAW", "PreBlacktwo"); if (pedited) { pedited->raw.bayersensor.exBlack2 = true; @@ -7292,7 +8282,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) } if (keyFile.has_key ("RAW", "PreBlackthree")) { - raw.bayersensor.black3 = keyFile.get_double("RAW", "PreBlackthree"); + raw.bayersensor.black3 = keyFile.get_double ("RAW", "PreBlackthree"); if (pedited) { pedited->raw.bayersensor.exBlack3 = true; @@ -7300,7 +8290,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) } if (keyFile.has_key ("RAW", "PreTwoGreen")) { - raw.bayersensor.twogreen = keyFile.get_boolean("RAW", "PreTwoGreen"); + raw.bayersensor.twogreen = keyFile.get_boolean ("RAW", "PreTwoGreen"); if (pedited) { pedited->raw.bayersensor.exTwoGreen = true; @@ -7330,7 +8320,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) } if (keyFile.has_key ("RAW Bayer", "PreBlack0")) { - raw.bayersensor.black0 = keyFile.get_double("RAW Bayer", "PreBlack0"); + raw.bayersensor.black0 = keyFile.get_double ("RAW Bayer", "PreBlack0"); if (pedited) { pedited->raw.bayersensor.exBlack0 = true; @@ -7338,7 +8328,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) } if (keyFile.has_key ("RAW Bayer", "PreBlack1")) { - raw.bayersensor.black1 = keyFile.get_double("RAW Bayer", "PreBlack1"); + raw.bayersensor.black1 = keyFile.get_double ("RAW Bayer", "PreBlack1"); if (pedited) { pedited->raw.bayersensor.exBlack1 = true; @@ -7346,7 +8336,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) } if (keyFile.has_key ("RAW Bayer", "PreBlack2")) { - raw.bayersensor.black2 = keyFile.get_double("RAW Bayer", "PreBlack2"); + raw.bayersensor.black2 = keyFile.get_double ("RAW Bayer", "PreBlack2"); if (pedited) { pedited->raw.bayersensor.exBlack2 = true; @@ -7354,7 +8344,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) } if (keyFile.has_key ("RAW Bayer", "PreBlack3")) { - raw.bayersensor.black3 = keyFile.get_double("RAW Bayer", "PreBlack3"); + raw.bayersensor.black3 = keyFile.get_double ("RAW Bayer", "PreBlack3"); if (pedited) { pedited->raw.bayersensor.exBlack3 = true; @@ -7362,7 +8352,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) } if (keyFile.has_key ("RAW Bayer", "PreTwoGreen")) { - raw.bayersensor.twogreen = keyFile.get_boolean("RAW Bayer", "PreTwoGreen"); + raw.bayersensor.twogreen = keyFile.get_boolean ("RAW Bayer", "PreTwoGreen"); if (pedited) { pedited->raw.bayersensor.exTwoGreen = true; @@ -7386,7 +8376,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) } if (keyFile.has_key ("RAW Bayer", "DCBIterations")) { - raw.bayersensor.dcb_iterations = keyFile.get_integer("RAW Bayer", "DCBIterations"); + raw.bayersensor.dcb_iterations = keyFile.get_integer ("RAW Bayer", "DCBIterations"); if (pedited) { pedited->raw.bayersensor.dcbIterations = true; @@ -7394,7 +8384,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) } if (keyFile.has_key ("RAW Bayer", "DCBEnhance")) { - raw.bayersensor.dcb_enhance = keyFile.get_boolean("RAW Bayer", "DCBEnhance"); + raw.bayersensor.dcb_enhance = keyFile.get_boolean ("RAW Bayer", "DCBEnhance"); if (pedited) { pedited->raw.bayersensor.dcbEnhance = true; @@ -7402,7 +8392,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) } if (keyFile.has_key ("RAW Bayer", "LMMSEIterations")) { - raw.bayersensor.lmmse_iterations = keyFile.get_integer("RAW Bayer", "LMMSEIterations"); + raw.bayersensor.lmmse_iterations = keyFile.get_integer ("RAW Bayer", "LMMSEIterations"); if (pedited) { pedited->raw.bayersensor.lmmseIterations = true; @@ -7431,7 +8421,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) } if (keyFile.has_key ("RAW X-Trans", "PreBlackRed")) { - raw.xtranssensor.blackred = keyFile.get_double("RAW X-Trans", "PreBlackRed"); + raw.xtranssensor.blackred = keyFile.get_double ("RAW X-Trans", "PreBlackRed"); if (pedited) { pedited->raw.xtranssensor.exBlackRed = true; @@ -7439,7 +8429,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) } if (keyFile.has_key ("RAW X-Trans", "PreBlackGreen")) { - raw.xtranssensor.blackgreen = keyFile.get_double("RAW X-Trans", "PreBlackGreen"); + raw.xtranssensor.blackgreen = keyFile.get_double ("RAW X-Trans", "PreBlackGreen"); if (pedited) { pedited->raw.xtranssensor.exBlackGreen = true; @@ -7447,7 +8437,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) } if (keyFile.has_key ("RAW X-Trans", "PreBlackBlue")) { - raw.xtranssensor.blackblue = keyFile.get_double("RAW X-Trans", "PreBlackBlue"); + raw.xtranssensor.blackblue = keyFile.get_double ("RAW X-Trans", "PreBlackBlue"); if (pedited) { pedited->raw.xtranssensor.exBlackBlue = true; @@ -7487,7 +8477,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) for (unsigned int i = 0; i < keys.size(); i++) { // does this key already exist? - element = iptc.find(keys[i]); + element = iptc.find (keys[i]); if (element != iptc.end()) { // it already exist so we cleanup the values @@ -7501,7 +8491,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) std::vector::iterator currLoadedTagValue = currIptc.begin(); currLoadedTagValue != currIptc.end(); ++currLoadedTagValue) { - iptc[keys[i]].push_back(currLoadedTagValue->data()); + iptc[keys[i]].push_back (currLoadedTagValue->data()); } if (pedited) { @@ -7525,22 +8515,22 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) return 0; } -const Glib::ustring ColorManagementParams::NoICMString = Glib::ustring("No ICM: sRGB output"); +const Glib::ustring ColorManagementParams::NoICMString = Glib::ustring ("No ICM: sRGB output"); -bool operator==(const WaveletParams & a, const WaveletParams & b) +bool operator== (const WaveletParams & a, const WaveletParams & b) { - if(a.enabled != b.enabled) { + if (a.enabled != b.enabled) { return false; } - for(int i = 0; i < 9; i++) { - if(a.c[i] != b.c[i]) { + for (int i = 0; i < 9; i++) { + if (a.c[i] != b.c[i]) { return false; } } - for(int i = 0; i < 9; i++) { - if(a.ch[i] != b.ch[i]) { + for (int i = 0; i < 9; i++) { + if (a.ch[i] != b.ch[i]) { return false; } } @@ -7550,14 +8540,14 @@ bool operator==(const WaveletParams & a, const WaveletParams & b) -bool operator==(const DirPyrEqualizerParams & a, const DirPyrEqualizerParams & b) +bool operator== (const DirPyrEqualizerParams & a, const DirPyrEqualizerParams & b) { - if(a.enabled != b.enabled) { + if (a.enabled != b.enabled) { return false; } - for(int i = 0; i < 6; i++) { - if(a.mult[i] != b.mult[i]) { + for (int i = 0; i < 6; i++) { + if (a.mult[i] != b.mult[i]) { return false; } } @@ -7565,6 +8555,23 @@ bool operator==(const DirPyrEqualizerParams & a, const DirPyrEqualizerParams & b return a.threshold == b.threshold; } + +bool operator== (const LocallabParams & a, const LocallabParams & b) +{ + if (a.enabled != b.enabled) { + return false; + } + + for (int i = 0; i < 5; i++) { + if (a.mult[i] != b.mult[i]) { + return false; + } + } + + return a.threshold == b.threshold; +} + + /*bool operator==(const ExifPairs& a, const ExifPairs& b) { return a.field == b.field && a.value == b.value; @@ -7795,6 +8802,71 @@ bool ProcParams::operator== (const ProcParams& other) && gradient.strength == other.gradient.strength && gradient.centerX == other.gradient.centerX && gradient.centerY == other.gradient.centerY + && locallab.enabled == other.locallab.enabled + && locallab.avoid == other.locallab.avoid + && locallab.invers == other.locallab.invers + && locallab.curvactiv == other.locallab.curvactiv + && locallab.activlum == other.locallab.activlum + && locallab.inversrad == other.locallab.inversrad + && locallab.inversret == other.locallab.inversret + && locallab.inverssha == other.locallab.inverssha + && locallab.degree == other.locallab.degree + && locallab.Smethod == other.locallab.Smethod + && locallab.retinexMethod == other.locallab.retinexMethod + && locallab.qualityMethod == other.locallab.qualityMethod + && locallab.locY == other.locallab.locY + && locallab.locX == other.locallab.locX + && locallab.locYT == other.locallab.locYT + && locallab.locXL == other.locallab.locXL + && locallab.centerX == other.locallab.centerX + && locallab.centerY == other.locallab.centerY + && locallab.circrad == other.locallab.circrad + && locallab.thres == other.locallab.thres + && locallab.proxi == other.locallab.proxi + && locallab.lightness == other.locallab.lightness + && locallab.contrast == other.locallab.contrast + && locallab.chroma == other.locallab.chroma + && locallab.noiselumf == other.locallab.noiselumf + && locallab.noiselumc == other.locallab.noiselumc + && locallab.noisechrof == other.locallab.noisechrof + && locallab.noisechroc == other.locallab.noisechroc + && locallab.sharradius == other.locallab.sharradius + && locallab.sharamount == other.locallab.sharamount + && locallab.shardamping == other.locallab.shardamping + && locallab.shariter == other.locallab.shariter + && locallab.sensi == other.locallab.sensi + && locallab.sensitm == other.locallab.sensitm + && locallab.sensih == other.locallab.sensih + && locallab.retrab == other.locallab.retrab + && locallab.sensicb == other.locallab.sensicb + && locallab.sensibn == other.locallab.sensibn + && locallab.sensisha == other.locallab.sensisha + && locallab.radius == other.locallab.radius + && locallab.strength == other.locallab.strength + && locallab.stren == other.locallab.stren + && locallab.gamma == other.locallab.gamma + && locallab.estop == other.locallab.estop + && locallab.scaltm == other.locallab.scaltm + && locallab.rewei == other.locallab.rewei + && locallab.transit == other.locallab.transit + && locallab.chrrt == other.locallab.chrrt + && locallab.str == other.locallab.str + && locallab.neigh == other.locallab.neigh + && locallab.nbspot == other.locallab.nbspot + && locallab.anbspot == other.locallab.anbspot + && locallab.vart == other.locallab.vart + && locallab.threshold == other.locallab.threshold + && locallab.expcolor == other.locallab.expcolor + && locallab.expblur == other.locallab.expblur + && locallab.exptonemap == other.locallab.exptonemap + && locallab.expreti == other.locallab.expreti + && locallab.expsharp == other.locallab.expsharp + && locallab.expcbdl == other.locallab.expcbdl + && locallab.expdenoi == other.locallab.expdenoi + && locallab.localTgaincurve == other.locallab.localTgaincurve + && locallab.localTgaincurverab == other.locallab.localTgaincurverab + && locallab.llcurve == other.locallab.llcurve + && locallab.LHcurve == other.locallab.LHcurve && pcvignette.enabled == other.pcvignette.enabled && pcvignette.strength == other.pcvignette.strength && pcvignette.feather == other.pcvignette.feather @@ -7806,9 +8878,9 @@ bool ProcParams::operator== (const ProcParams& other) && vignetting.strength == other.vignetting.strength && vignetting.centerX == other.vignetting.centerX && vignetting.centerY == other.vignetting.centerY - && !memcmp (&chmixer.red, &other.chmixer.red, 3 * sizeof(int)) - && !memcmp (&chmixer.green, &other.chmixer.green, 3 * sizeof(int)) - && !memcmp (&chmixer.blue, &other.chmixer.blue, 3 * sizeof(int)) + && !memcmp (&chmixer.red, &other.chmixer.red, 3 * sizeof (int)) + && !memcmp (&chmixer.green, &other.chmixer.green, 3 * sizeof (int)) + && !memcmp (&chmixer.blue, &other.chmixer.blue, 3 * sizeof (int)) && blackwhite.mixerRed == other.blackwhite.mixerRed && blackwhite.mixerOrange == other.blackwhite.mixerOrange && blackwhite.mixerYellow == other.blackwhite.mixerYellow @@ -8010,45 +9082,45 @@ bool ProcParams::operator== (const ProcParams& other) bool ProcParams::operator!= (const ProcParams& other) { - return !(*this == other); + return ! (*this == other); } -PartialProfile::PartialProfile(bool createInstance, bool paramsEditedValue) +PartialProfile::PartialProfile (bool createInstance, bool paramsEditedValue) { if (createInstance) { pparams = new ProcParams(); - pedited = new ParamsEdited(paramsEditedValue); + pedited = new ParamsEdited (paramsEditedValue); } else { pparams = nullptr; pedited = nullptr; } } -PartialProfile::PartialProfile(ProcParams* pp, ParamsEdited* pe, bool fullCopy) +PartialProfile::PartialProfile (ProcParams* pp, ParamsEdited* pe, bool fullCopy) { if (fullCopy && pp) { - pparams = new ProcParams(*pp); + pparams = new ProcParams (*pp); } else { pparams = pp; } if (fullCopy && pe) { - pedited = new ParamsEdited(*pe); + pedited = new ParamsEdited (*pe); } else { pedited = pe; } } -PartialProfile::PartialProfile(const ProcParams* pp, const ParamsEdited* pe) +PartialProfile::PartialProfile (const ProcParams* pp, const ParamsEdited* pe) { if (pp) { - pparams = new ProcParams(*pp); + pparams = new ProcParams (*pp); } else { pparams = nullptr; } if (pe) { - pedited = new ParamsEdited(*pe); + pedited = new ParamsEdited (*pe); } else { pedited = nullptr; } @@ -8067,7 +9139,7 @@ int PartialProfile::load (const Glib::ustring &fName) if (fName == DEFPROFILE_INTERNAL) { return 0; } else { - return pparams->load(fName, pedited); + return pparams->load (fName, pedited); } } @@ -8097,17 +9169,17 @@ void PartialProfile::clearGeneral () } } -const void PartialProfile::applyTo(ProcParams *destParams) const +const void PartialProfile::applyTo (ProcParams *destParams) const { if (destParams && pparams && pedited) { - pedited->combine(*destParams, *pparams, true); + pedited->combine (*destParams, *pparams, true); } } -void PartialProfile::set(bool v) +void PartialProfile::set (bool v) { if (pedited) { - pedited->set(v); + pedited->set (v); } } diff --git a/rtengine/procparams.h b/rtengine/procparams.h index 7c2d71aaa..66c679733 100644 --- a/rtengine/procparams.h +++ b/rtengine/procparams.h @@ -45,6 +45,10 @@ class WavOpacityCurveW; class WavOpacityCurveWL; class RetinextransmissionCurve; class RetinexgaintransmissionCurve; +class LocretigainCurve; +class LocretigainCurverab; +class LocLHCurve; + enum RenderingIntent { RI_PERCEPTUAL = INTENT_PERCEPTUAL, @@ -73,8 +77,8 @@ public: initEq1 = startAtOne; value[0] = bottom; value[1] = top; - value[2] = T(0); - value[3] = T(0); + value[2] = T (0); + value[3] = T (0); _isDouble = false; } @@ -89,14 +93,14 @@ public: } // for convenience, since 'values' is public - void setValues(T bottom, T top) + void setValues (T bottom, T top) { value[0] = bottom; value[1] = top; } // for convenience, since 'values' is public - void setValues(T bottomLeft, T topLeft, T bottomRight, T topRight) + void setValues (T bottomLeft, T topLeft, T bottomRight, T topRight) { value[0] = bottomLeft; value[1] = topLeft; @@ -113,64 +117,64 @@ public: // RV: Type of the value on the X axis // RV2: Type of the maximum value on the Y axis template - RT multiply(RV x, RV2 yMax) const + RT multiply (RV x, RV2 yMax) const { - double val = double(x); + double val = double (x); if (initEq1) { if (_isDouble) { - if (val == double(value[2]) && double(value[2]) == double(value[3])) + if (val == double (value[2]) && double (value[2]) == double (value[3])) // this handle the special case where the 2 right values are the same, then bottom one is sent back, // useful if one wants to keep the bottom value even beyond the x max bound { - return RT(0.); + return RT (0.); } - if (val >= double(value[3])) { - return RT(yMax); + if (val >= double (value[3])) { + return RT (yMax); } - if (val > double(value[2])) { - return RT(double(yMax) * (val - double(value[2])) / (double(value[3]) - double(value[2]))); + if (val > double (value[2])) { + return RT (double (yMax) * (val - double (value[2])) / (double (value[3]) - double (value[2]))); } } - if (val >= double(value[0])) { - return RT(0); + if (val >= double (value[0])) { + return RT (0); } - if (val > double(value[1])) { - return RT(double(yMax) * (1. - (val - double(value[0])) / (double(value[1]) - double(value[0])))); + if (val > double (value[1])) { + return RT (double (yMax) * (1. - (val - double (value[0])) / (double (value[1]) - double (value[0])))); } - return RT(yMax); + return RT (yMax); } else { if (_isDouble) { - if (val == double(value[2]) && double(value[2]) == double(value[3])) + if (val == double (value[2]) && double (value[2]) == double (value[3])) // this handle the special case where the 2 right values are the same, then top one is sent back, // useful if one wants to keep the top value even beyond the x max bound { - return RT(yMax); + return RT (yMax); } - if (val >= double(value[2])) { - return RT(0); + if (val >= double (value[2])) { + return RT (0); } - if (val > double(value[3])) { - return RT(double(yMax) * (1. - (val - double(value[3])) / (double(value[2]) - double(value[3])))); + if (val > double (value[3])) { + return RT (double (yMax) * (1. - (val - double (value[3])) / (double (value[2]) - double (value[3])))); } } - if (val >= double(value[1])) { - return RT(yMax); + if (val >= double (value[1])) { + return RT (yMax); } - if (val > double(value[0])) { - return RT(double(yMax) * (val - double(value[0])) / (double(value[1]) - double(value[0]))); + if (val > double (value[0])) { + return RT (double (yMax) * (val - double (value[0])) / (double (value[1]) - double (value[0]))); } - return RT(0); + return RT (0); } } @@ -207,7 +211,7 @@ public: } }*/ - Threshold& operator =(const Threshold &rhs) + Threshold& operator = (const Threshold &rhs) { value[0] = rhs.value[0]; value[1] = rhs.value[1]; @@ -219,21 +223,21 @@ public: } template - typename std::enable_if::value, bool>::type operator ==(const Threshold &rhs) const + typename std::enable_if::value, bool>::type operator == (const Threshold &rhs) const { if (_isDouble) { - return std::fabs(value[0] - rhs.value[0]) < 1e-10 - && std::fabs(value[1] - rhs.value[1]) < 1e-10 - && std::fabs(value[2] - rhs.value[2]) < 1e-10 - && std::fabs(value[3] - rhs.value[3]) < 1e-10; + return std::fabs (value[0] - rhs.value[0]) < 1e-10 + && std::fabs (value[1] - rhs.value[1]) < 1e-10 + && std::fabs (value[2] - rhs.value[2]) < 1e-10 + && std::fabs (value[3] - rhs.value[3]) < 1e-10; } else { - return std::fabs(value[0] - rhs.value[0]) < 1e-10 - && std::fabs(value[1] - rhs.value[1]) < 1e-10; + return std::fabs (value[0] - rhs.value[0]) < 1e-10 + && std::fabs (value[1] - rhs.value[1]) < 1e-10; } } template - typename std::enable_if::value, bool>::type operator ==(const Threshold &rhs) const + typename std::enable_if::value, bool>::type operator == (const Threshold &rhs) const { if (_isDouble) { return @@ -288,7 +292,7 @@ public: setDefaults(); } void setDefaults(); - static bool HLReconstructionNecessary(LUTu &histRedRaw, LUTu &histGreenRaw, LUTu &histBlueRaw); + static bool HLReconstructionNecessary (LUTu &histRedRaw, LUTu &histGreenRaw, LUTu &histBlueRaw); }; /** * Parameters of Retinex @@ -333,11 +337,11 @@ public: bool medianmap; RetinexParams (); void setDefaults(); - void getCurves(RetinextransmissionCurve &transmissionCurveLUT, RetinexgaintransmissionCurve &gaintransmissionCurveLUT) const; + void getCurves (RetinextransmissionCurve &transmissionCurveLUT, RetinexgaintransmissionCurve &gaintransmissionCurveLUT) const; - static void getDefaultgaintransmissionCurve(std::vector &curve); + static void getDefaultgaintransmissionCurve (std::vector &curve); - static void getDefaulttransmissionCurve(std::vector &curve); + static void getDefaulttransmissionCurve (std::vector &curve); }; @@ -433,16 +437,16 @@ public: ColorToningParams (); void setDefaults(); // SHOULD BE GENERALIZED TO ALL CLASSES! /// @brief Transform the mixer values to their curve equivalences - void mixerToCurve(std::vector &colorCurve, std::vector &opacityCurve) const; + void mixerToCurve (std::vector &colorCurve, std::vector &opacityCurve) const; /// @brief Specifically transform the sliders values to their curve equivalences - void slidersToCurve(std::vector &colorCurve, std::vector &opacityCurve) const; + void slidersToCurve (std::vector &colorCurve, std::vector &opacityCurve) const; /// @brief Fill the ColorGradientCurve and OpacityCurve LUTf from the control points curve or sliders value - void getCurves(ColorGradientCurve &colorCurveLUT, OpacityCurve &opacityCurveLUT, const double xyz_rgb[3][3], const double rgb_xyz[3][3], bool &opautili) const; + void getCurves (ColorGradientCurve &colorCurveLUT, OpacityCurve &opacityCurveLUT, const double xyz_rgb[3][3], const double rgb_xyz[3][3], bool &opautili) const; - static void getDefaultColorCurve(std::vector &curve); - static void getDefaultOpacityCurve(std::vector &curve); - static void getDefaultCLCurve(std::vector &curve); - static void getDefaultCL2Curve(std::vector &curve); + static void getDefaultColorCurve (std::vector &curve); + static void getDefaultOpacityCurve (std::vector &curve); + static void getDefaultCLCurve (std::vector &curve); + static void getDefaultCL2Curve (std::vector &curve); }; /** @@ -467,7 +471,7 @@ public: int deconviter; int deconvdamping; - SharpeningParams() : threshold(20, 80, 2000, 1200, false) {}; + SharpeningParams() : threshold (20, 80, 2000, 1200, false) {}; }; class SharpenEdgeParams { @@ -502,7 +506,7 @@ public: bool pastsattog; std::vector skintonescurve; - VibranceParams() : psthreshold(0, 75, false) {}; + VibranceParams() : psthreshold (0, 75, false) {}; }; /** @@ -547,7 +551,7 @@ public: double green; double equal; - WBEntry(const Glib::ustring &p, enum WBTypes t, const Glib::ustring &l, int temp, double green, double equal) : ppLabel(p), type(t), GUILabel(l), temperature(temp), green(green), equal(equal) {}; + WBEntry (const Glib::ustring &p, enum WBTypes t, const Glib::ustring &l, int temp, double green, double equal) : ppLabel (p), type (t), GUILabel (l), temperature (temp), green (green), equal (equal) {}; }; class WBParams @@ -709,10 +713,10 @@ public: DirPyrDenoiseParams (); void setDefaults(); // SHOULD BE GENERALIZED TO ALL CLASSES! - void getCurves(NoiseCurve &lCurve, NoiseCurve &cCurve) const; + void getCurves (NoiseCurve &lCurve, NoiseCurve &cCurve) const; - static void getDefaultNoisCurve(std::vector &curve); - static void getDefaultCCCurve(std::vector &curve); + static void getDefaultNoisCurve (std::vector &curve); + static void getDefaultCCCurve (std::vector &curve); }; @@ -762,8 +766,8 @@ public: Glib::ustring orientation; Glib::ustring guide; - CropParams() : enabled(false), x(0), y(0), w(0), h(0), fixratio(false) {}; - void mapToResized(int resizedWidth, int resizedHeight, int scale, int &x1, int &x2, int &y1, int &y2) const; + CropParams() : enabled (false), x (0), y (0), w (0), h (0), fixratio (false) {}; + void mapToResized (int resizedWidth, int resizedHeight, int scale, int &x1, int &x2, int &y1, int &y2) const; }; /** @@ -854,6 +858,101 @@ public: int centerX; int centerY; }; +/** + * Parameters of the Local Lab + */ +class LocallabParams +{ + +public: + bool enabled; + double degree; + int locY; + int locX; + int locYT; + int locXL; + int centerX; + int centerY; + int circrad; + int thres; + int proxi; + Glib::ustring qualityMethod; + bool expcolor; + bool expblur; + bool exptonemap; + bool expreti; + bool expsharp; + bool expcbdl; + bool expdenoi; + + int lightness; + int contrast; + int chroma; + int sharradius; + int sharamount; + int shardamping; + int shariter; + int noiselumf; + int noiselumc; + int noisechrof; + int noisechroc; + + int sensi; + int sensih; + int retrab; + int sensicb; + int sensibn; + int sensisha; + int sensitm; + int radius; + int strength; + int stren; + int gamma; + int estop; + int scaltm; + int rewei; + int transit; + bool avoid; + Glib::ustring Smethod; + Glib::ustring retinexMethod; + bool invers; + bool curvactiv; + bool activlum; + bool inversrad; + bool inversret; + bool inverssha; + double hueref; + double chromaref; + double lumaref; + int str; + int neigh; + int nbspot; + int anbspot; + int vart; + int chrrt; + std::vector localTgaincurve; + std::vector localTgaincurverab; + std::vector llcurve; + std::vector LHcurve; + + double mult[5]; + double threshold; + + LocallabParams () + { + setDefaults(); + } + void setDefaults(); + void getCurves (LocretigainCurve &cTgainCurve, LocretigainCurverab &cTgainCurverab, LocLHCurve & lhCurve) const; + static void getDefaultLocalgainCurveT (std::vector &curve); + static void getDefaultLocalgainCurveTrab (std::vector &curve); + static void getDefaultLLCurve (std::vector &curve); + static void getDefaultLHCurve (std::vector &curve); + +}; + + + /** * Parameters of the post-crop vignette filter @@ -1106,12 +1205,12 @@ public: WaveletParams (); void setDefaults(); - void getCurves(WavCurve &cCurve, WavOpacityCurveRG &opacityCurveLUTRG , WavOpacityCurveBY &opacityCurveLUTBY, WavOpacityCurveW &opacityCurveLUTW, WavOpacityCurveWL &opacityCurveLUTWL) const; - static void getDefaultCCWCurve(std::vector &curve); - static void getDefaultOpacityCurveRG(std::vector &curve); - static void getDefaultOpacityCurveBY(std::vector &curve); - static void getDefaultOpacityCurveW(std::vector &curve); - static void getDefaultOpacityCurveWL(std::vector &curve); + void getCurves (WavCurve &cCurve, WavOpacityCurveRG &opacityCurveLUTRG , WavOpacityCurveBY &opacityCurveLUTBY, WavOpacityCurveW &opacityCurveLUTW, WavOpacityCurveWL &opacityCurveLUTWL) const; + static void getDefaultCCWCurve (std::vector &curve); + static void getDefaultOpacityCurveRG (std::vector &curve); + static void getDefaultOpacityCurveBY (std::vector &curve); + static void getDefaultOpacityCurveW (std::vector &curve); + static void getDefaultOpacityCurveWL (std::vector &curve); }; @@ -1131,7 +1230,7 @@ public: Threshold hueskin; //Glib::ustring algo; Glib::ustring cbdlMethod; - DirPyrEqualizerParams() : hueskin(20, 80, 2000, 1200, false) {}; + DirPyrEqualizerParams() : hueskin (20, 80, 2000, 1200, false) {}; }; /** @@ -1297,6 +1396,7 @@ public: LensProfParams lensProf; ///< Lens correction profile parameters PerspectiveParams perspective; ///< Perspective correction parameters GradientParams gradient; ///< Gradient filter parameters + LocallabParams locallab; ///< Local lab parameters PCVignetteParams pcvignette; ///< Post-crop vignette filter parameters CACorrParams cacorrection; ///< Lens c/a correction parameters VignettingParams vignetting; ///< Lens vignetting correction parameters @@ -1314,7 +1414,7 @@ public: bool inTrash; ///< Marks deleted image Glib::ustring appVersion; ///< Version of the application that generated the parameters int ppVersion; ///< Version of the PP file from which the parameters have been read - + int prot; ExifPairs exif; ///< List of modifications appplied on the exif tags of the input image IPTCPairs iptc; ///< The IPTC tags and values to be saved to the output image @@ -1383,7 +1483,7 @@ class PartialProfile public: rtengine::procparams::ProcParams* pparams; ParamsEdited* pedited; - PartialProfile& operator =(const PartialProfile& rhs) + PartialProfile& operator = (const PartialProfile& rhs) { pparams = rhs.pparams; pedited = rhs.pedited; @@ -1408,7 +1508,7 @@ public: class AutoPartialProfile : public PartialProfile { public: - AutoPartialProfile() : PartialProfile(true) {} + AutoPartialProfile() : PartialProfile (true) {} ~AutoPartialProfile() { deleteInstance(); diff --git a/rtengine/rawimagesource.cc b/rtengine/rawimagesource.cc index 049c509f5..3f713c6ad 100644 --- a/rtengine/rawimagesource.cc +++ b/rtengine/rawimagesource.cc @@ -1635,7 +1635,8 @@ int RawImageSource::load (const Glib::ustring &fname, bool batch) rml.ciffBase = ri->get_ciffBase(); rml.ciffLength = ri->get_ciffLen(); idata = new ImageData (fname, &rml); - + Glib::ustring nana = ri->get_filename(); + printf("nana=%s \n", nana.c_str()); green(W, H); red(W, H); blue(W, H); diff --git a/rtengine/refreshmap.cc b/rtengine/refreshmap.cc index 025265e0a..bbaa17522 100644 --- a/rtengine/refreshmap.cc +++ b/rtengine/refreshmap.cc @@ -468,8 +468,75 @@ int refreshmap[rtengine::NUMOFEVENTS] = { DEMOSAIC, // EvviewMethod ALLNORAW, // EvcbdlMethod RETINEX, // EvRetinexgaintransmission - RETINEX, // EvLskal - OUTPUTPROFILE // EvOBPCompens + RETINEX, //EvLskal + OUTPUTPROFILE, // EvOBPCompens + LUMINANCECURVE, //EvlocallabEnabled + LUMINANCECURVE, //EvlocallablocY + LUMINANCECURVE, //EvlocallablocX + LUMINANCECURVE,// EvlocallabCenter + LUMINANCECURVE, //EvlocallabDegree + LUMINANCECURVE, //Evlocallablightness + LUMINANCECURVE, //Evlocallabcontrast + LUMINANCECURVE, //Evlocallabchroma + LUMINANCECURVE, //Evlocallabtransit + LUMINANCECURVE, //Evlocallabavoid + LUMINANCECURVE, //EvlocallablocYT + LUMINANCECURVE, //EvlocallablocXL + LUMINANCECURVE, //EvlocallabSmet + LUMINANCECURVE, //Evlocallabinvers + LUMINANCECURVE, //Evlocallabradius + LUMINANCECURVE, //Evlocallabinversrad + LUMINANCECURVE, //Evlocallabstrength + LUMINANCECURVE, //Evlocallabsensi + LUMINANCECURVE, //EvlocallabretinexMethod + LUMINANCECURVE, //Evlocallabstr + LUMINANCECURVE, //Evlocallabneigh + LUMINANCECURVE, //Evlocallabvart + LUMINANCECURVE, //EvlocallabCTgainCurve + LUMINANCECURVE, //Evlocallabchrrt + LUMINANCECURVE, //Evlocallabinversret + LUMINANCECURVE, //Evlocallabsensih + LUMINANCECURVE, //Evlocallabnbspot + LUMINANCECURVE, //Evlocallabactivlum + LUMINANCECURVE, //Evlocallabanbspot + LUMINANCECURVE, //Evlocallabsharradius + LUMINANCECURVE, //Evlocallabsharamount + LUMINANCECURVE, //Evlocallabshardamping + LUMINANCECURVE, //Evlocallabshariter + LUMINANCECURVE, //Evlocallabsensis + LUMINANCECURVE, //Evlocallabinverssha + LUMINANCECURVE, //Evlocallabcircrad + LUMINANCECURVE, //Evlocallabthres + LUMINANCECURVE, //Evlocallabproxi + LUMINANCECURVE, //EvlocallabqualityMethod + LUMINANCECURVE, //Evlocallabnoiselumf + LUMINANCECURVE, //Evlocallabnoiselumc + LUMINANCECURVE, //Evlocallabnoisechrof + LUMINANCECURVE, //Evlocallabnoisechroc + LUMINANCECURVE, //EvlocallabThresho + LUMINANCECURVE, //EvlocallabEqualizer + LUMINANCECURVE, //Evlocallabsensicb + LUMINANCECURVE, //Evlocallabsensibn + LUMINANCECURVE, //Evlocallabstren + LUMINANCECURVE, //Evlocallabgamma + LUMINANCECURVE, //Evlocallabestop + LUMINANCECURVE, //Evlocallabscaltm + LUMINANCECURVE, //Evlocallabrewei + LUMINANCECURVE, //Evlocallabsensitm + LUMINANCECURVE, //EvlocallabCTgainCurverab + LUMINANCECURVE, //Evlocallabretrab + LUMINANCECURVE, //Evlocallabllshape + LUMINANCECURVE, //Evlocenacolor + LUMINANCECURVE, //Evlocenablur + LUMINANCECURVE, //Evlocenatonemap + LUMINANCECURVE, //Evlocenareti + LUMINANCECURVE, //Evlocenasharp + LUMINANCECURVE, //Evlocenacbdl + LUMINANCECURVE, //Evlocenadenoi + LUMINANCECURVE, //EvlocallabLHshape + LUMINANCECURVE //Evlocallabcurvactiv + + }; diff --git a/rtengine/rtengine.h b/rtengine/rtengine.h index 61c779fb7..d7efdd898 100644 --- a/rtengine/rtengine.h +++ b/rtengine/rtengine.h @@ -33,6 +33,7 @@ #include "../rtgui/threadutils.h" #include "settings.h" #include "LUT.h" + /** * @file * This file contains the main functionality of the RawTherapee engine. @@ -310,6 +311,16 @@ public : }; +class localListener +{ +public : + virtual ~localListener() {} + virtual void localChanged (int **datasp, std::string datastr, std::string ll_str, std::string lh_str, int sp, int maxdat) {} + virtual void localretChanged (int **datasp, std::string datastr, std::string ll_str, std::string lh_str, int sp, int maxdat) {} + +}; + + class WaveletListener { public : @@ -411,6 +422,7 @@ public: virtual void setPreviewImageListener (PreviewImageListener* l) = 0; virtual void setAutoCamListener (AutoCamListener* l) = 0; virtual void setAutoBWListener (AutoBWListener* l) = 0; + virtual void setlocalListener (localListener* l) = 0; virtual void setAutoColorTonListener (AutoColorTonListener* l) = 0; virtual void setAutoChromaListener (AutoChromaListener* l) = 0; virtual void setRetinexListener (RetinexListener* l) = 0; diff --git a/rtengine/rtthumbnail.cc b/rtengine/rtthumbnail.cc index 257a3eeb3..82d1b29c6 100644 --- a/rtengine/rtthumbnail.cc +++ b/rtengine/rtthumbnail.cc @@ -1133,7 +1133,8 @@ IImage8* Thumbnail::processImage (const procparams::ProcParams& params, int rhei CurveFactory::complexsgnCurve (autili, butili, ccutili, cclutili, params.labCurve.acurve, params.labCurve.bcurve, params.labCurve.cccurve, params.labCurve.lccurve, curve1, curve2, satcurve, lhskcurve, 16); - ipf.chromiLuminanceCurve (nullptr, 1, labView, labView, curve1, curve2, satcurve, lhskcurve, clcurve, lumacurve, utili, autili, butili, ccutili, cclutili, clcutili, dummy, dummy); + + ipf.chromiLuminanceCurve (nullptr, 1, labView, labView, curve1, curve2, satcurve, lhskcurve, clcurve, lumacurve, utili, autili, butili, ccutili, cclutili, clcutili, dummy, dummy); ipf.vibrance(labView); diff --git a/rtengine/settings.h b/rtengine/settings.h index ada63400a..663354453 100644 --- a/rtengine/settings.h +++ b/rtengine/settings.h @@ -92,6 +92,14 @@ public: double ed_low; double ed_lipinfl; double ed_lipampl; + + int nspot; + bool locdelay; + int cropsleep; + double reduchigh; + double reduclow; + + /** Creates a new instance of Settings. * @return a pointer to the new Settings instance. */ static Settings* create (); diff --git a/rtengine/shmap.h b/rtengine/shmap.h index 9bb496b54..0705887f8 100644 --- a/rtengine/shmap.h +++ b/rtengine/shmap.h @@ -36,6 +36,7 @@ public: SHMap (int w, int h, bool multiThread); ~SHMap (); + void updateLab (LabImage* img, double radius, bool hq, int skip); void update (Imagefloat* img, double radius, double lumi[3], bool hq, int skip); void updateL (float** L, double radius, bool hq, int skip); @@ -44,6 +45,7 @@ public: private: int W, H; bool multiThread; + void fillLuminanceLab( LabImage * img, float **luminance); void fillLuminance( Imagefloat * img, float **luminance, double lumi[3] ); void fillLuminanceL( float ** L, float **luminance ); diff --git a/rtengine/simpleprocess.cc b/rtengine/simpleprocess.cc index 4fb193c2b..f2a6b4e8a 100644 --- a/rtengine/simpleprocess.cc +++ b/rtengine/simpleprocess.cc @@ -29,6 +29,10 @@ #include "rawimagesource.h" #include "../rtgui/multilangmgr.h" #include "mytime.h" +#include +#include +#include + #undef THREAD_PRIORITY_NORMAL namespace rtengine @@ -40,7 +44,7 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p errorCode = 0; - ProcessingJobImpl* job = static_cast(pjob); + ProcessingJobImpl* job = static_cast (pjob); if (pl) { pl->setProgressStr ("PROGRESSBAR_PROCESSING"); @@ -63,7 +67,7 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p // acquire image from imagesource ImageSource* imgsrc = ii->getImageSource (); - int tr = getCoarseBitMask(params.coarse); + int tr = getCoarseBitMask (params.coarse); int fw, fh; imgsrc->getFullSize (fw, fh, tr); @@ -102,13 +106,13 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p ImProcFunctions ipf (¶ms, true); PreviewProps pp (0, 0, fw, fh, 1); - imgsrc->preprocess( params.raw, params.lensProf, params.coarse, params.dirpyrDenoise.enabled); + imgsrc->preprocess ( params.raw, params.lensProf, params.coarse, params.dirpyrDenoise.enabled); if (params.toneCurve.autoexp) {// this enabled HLRecovery - LUTu histRedRaw(256), histGreenRaw(256), histBlueRaw(256); - imgsrc->getRAWHistogram(histRedRaw, histGreenRaw, histBlueRaw); + LUTu histRedRaw (256), histGreenRaw (256), histBlueRaw (256); + imgsrc->getRAWHistogram (histRedRaw, histGreenRaw, histBlueRaw); - if (ToneCurveParams::HLReconstructionNecessary(histRedRaw, histGreenRaw, histBlueRaw) && !params.toneCurve.hrenabled) { + if (ToneCurveParams::HLReconstructionNecessary (histRedRaw, histGreenRaw, histBlueRaw) && !params.toneCurve.hrenabled) { params.toneCurve.hrenabled = true; // WARNING: Highlight Reconstruction is being forced 'on', should we force a method here too? } @@ -118,13 +122,13 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p pl->setProgress (0.20); } - imgsrc->demosaic( params.raw); + imgsrc->demosaic ( params.raw); if (pl) { pl->setProgress (0.30); } - if(params.retinex.enabled) { //enabled Retinex + if (params.retinex.enabled) { //enabled Retinex LUTf cdcurve (65536, 0); LUTf mapcurve (65536, 0); LUTu dummy; @@ -134,18 +138,18 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p bool mapcontlutili = false; bool useHsl = false; // multi_array2D conversionBuffer(1, 1); - multi_array2D conversionBuffer(1, 1); - imgsrc->retinexPrepareBuffers(params.icm, params.retinex, conversionBuffer, dummy); - imgsrc->retinexPrepareCurves(params.retinex, cdcurve, mapcurve, dehatransmissionCurve, dehagaintransmissionCurve, dehacontlutili, mapcontlutili, useHsl, dummy, dummy ); + multi_array2D conversionBuffer (1, 1); + imgsrc->retinexPrepareBuffers (params.icm, params.retinex, conversionBuffer, dummy); + imgsrc->retinexPrepareCurves (params.retinex, cdcurve, mapcurve, dehatransmissionCurve, dehagaintransmissionCurve, dehacontlutili, mapcontlutili, useHsl, dummy, dummy ); float minCD, maxCD, mini, maxi, Tmean, Tsigma, Tmin, Tmax; - imgsrc->retinex( params.icm, params.retinex, params.toneCurve, cdcurve, mapcurve, dehatransmissionCurve, dehagaintransmissionCurve, conversionBuffer, dehacontlutili, mapcontlutili, useHsl, minCD, maxCD, mini, maxi, Tmean, Tsigma, Tmin, Tmax, dummy); + imgsrc->retinex ( params.icm, params.retinex, params.toneCurve, cdcurve, mapcurve, dehatransmissionCurve, dehagaintransmissionCurve, conversionBuffer, dehacontlutili, mapcontlutili, useHsl, minCD, maxCD, mini, maxi, Tmean, Tsigma, Tmin, Tmax, dummy); } if (pl) { pl->setProgress (0.40); } - imgsrc->HLRecovery_Global( params.toneCurve ); + imgsrc->HLRecovery_Global ( params.toneCurve ); if (pl) { @@ -159,25 +163,25 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p currWB = imgsrc->getWB (); } else if (params.wb.method == "Auto") { double rm, gm, bm; - imgsrc->getAutoWBMultipliers(rm, gm, bm); - currWB.update(rm, gm, bm, params.wb.equal); + imgsrc->getAutoWBMultipliers (rm, gm, bm); + currWB.update (rm, gm, bm, params.wb.equal); } NoiseCurve noiseLCurve; NoiseCurve noiseCCurve; Imagefloat *calclum = nullptr ; - params.dirpyrDenoise.getCurves(noiseLCurve, noiseCCurve); + params.dirpyrDenoise.getCurves (noiseLCurve, noiseCCurve); float autoNR = (float) settings->nrauto;// float autoNRmax = (float) settings->nrautomax;// int tilesize; int overlap; - if(settings->leveldnti == 0) { + if (settings->leveldnti == 0) { tilesize = 1024; overlap = 128; } - if(settings->leveldnti == 1) { + if (settings->leveldnti == 1) { tilesize = 768; overlap = 96; } @@ -188,7 +192,7 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p ipf.Tile_calc (tilesize, overlap, 2, fw, fh, numtiles_W, numtiles_H, tilewidth, tileheight, tileWskip, tileHskip); int nbtl = numtiles_W * numtiles_H; - if((settings->leveldnautsimpl == 1 && params.dirpyrDenoise.Cmethod == "AUT") || (settings->leveldnautsimpl == 0 && params.dirpyrDenoise.C2method == "AUTO")) { + if ((settings->leveldnautsimpl == 1 && params.dirpyrDenoise.Cmethod == "AUT") || (settings->leveldnautsimpl == 0 && params.dirpyrDenoise.C2method == "AUTO")) { nbtl = 9; } @@ -204,28 +208,28 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p float *pcsk = new float [nbtl]; // printf("expert=%d\n",settings->leveldnautsimpl); - if(settings->leveldnautsimpl == 1 && params.dirpyrDenoise.Cmethod == "PON") { + if (settings->leveldnautsimpl == 1 && params.dirpyrDenoise.Cmethod == "PON") { MyTime t1pone, t2pone; t1pone.set(); int crW, crH; - if(settings->leveldnv == 0) { + if (settings->leveldnv == 0) { crW = 100; crH = 100; } - if(settings->leveldnv == 1) { + if (settings->leveldnv == 1) { crW = 250; crH = 250; } - if(settings->leveldnv == 2) { - crW = int(tileWskip / 2); - crH = int(tileHskip / 2); + if (settings->leveldnv == 2) { + crW = int (tileWskip / 2); + crH = int (tileHskip / 2); } // if(settings->leveldnv ==2) {crW=int(tileWskip/2);crH=int(1.15f*(tileWskip/2));}//adapted to scale of preview - if(settings->leveldnv == 3) { + if (settings->leveldnv == 3) { crW = tileWskip - 10; crH = tileHskip - 10; } @@ -233,7 +237,7 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p float lowdenoise = 1.f; int levaut = settings->leveldnaut; - if(levaut == 1) { //Standard + if (levaut == 1) { //Standard lowdenoise = 0.7f; } @@ -242,9 +246,9 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p // Imagefloat *origCropPart;//init auto noise // origCropPart = new Imagefloat (crW, crH);//allocate memory if (params.dirpyrDenoise.enabled) {//evaluate Noise - LUTf gamcurve(65536, 0); + LUTf gamcurve (65536, 0); float gam, gamthresh, gamslope; - ipf.RGB_denoise_infoGamCurve(params.dirpyrDenoise, imgsrc->isRAW(), gamcurve, gam, gamthresh, gamslope); + ipf.RGB_denoise_infoGamCurve (params.dirpyrDenoise, imgsrc->isRAW(), gamcurve, gam, gamthresh, gamslope); #pragma omp parallel { Imagefloat *origCropPart;//init auto noise @@ -253,23 +257,23 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p int skipP = 1; #pragma omp for schedule(dynamic) collapse(2) nowait - for(int wcr = 0; wcr < numtiles_W; wcr++) { - for(int hcr = 0; hcr < numtiles_H; hcr++) { + for (int wcr = 0; wcr < numtiles_W; wcr++) { + for (int hcr = 0; hcr < numtiles_H; hcr++) { int beg_tileW = wcr * tileWskip + tileWskip / 2.f - crW / 2.f; int beg_tileH = hcr * tileHskip + tileHskip / 2.f - crH / 2.f; PreviewProps ppP (beg_tileW , beg_tileH, crW, crH, skipP); imgsrc->getImage (currWB, tr, origCropPart, ppP, params.toneCurve, params.icm, params.raw ); // we only need image reduced to 1/4 here - for(int ii = 0; ii < crH; ii += 2) { - for(int jj = 0; jj < crW; jj += 2) { - provicalc->r(ii >> 1, jj >> 1) = origCropPart->r(ii, jj); - provicalc->g(ii >> 1, jj >> 1) = origCropPart->g(ii, jj); - provicalc->b(ii >> 1, jj >> 1) = origCropPart->b(ii, jj); + for (int ii = 0; ii < crH; ii += 2) { + for (int jj = 0; jj < crW; jj += 2) { + provicalc->r (ii >> 1, jj >> 1) = origCropPart->r (ii, jj); + provicalc->g (ii >> 1, jj >> 1) = origCropPart->g (ii, jj); + provicalc->b (ii >> 1, jj >> 1) = origCropPart->b (ii, jj); } } - imgsrc->convertColorSpace(provicalc, params.icm, currWB);//for denoise luminance curve + imgsrc->convertColorSpace (provicalc, params.icm, currWB); //for denoise luminance curve float maxr = 0.f; float maxb = 0.f; float pondcorrec = 1.0f; @@ -282,7 +286,7 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p maxblueaut = 0.f; chromina = 0.f; sigma = 0.f; - ipf.RGB_denoise_info(origCropPart, provicalc, imgsrc->isRAW(), gamcurve, gam, gamthresh, gamslope, params.dirpyrDenoise, imgsrc->getDirPyrDenoiseExpComp(), chaut, Nb, redaut, blueaut, maxredaut, maxblueaut, minredaut, minblueaut, chromina, sigma, lumema, sigma_L, redyel, skinc, nsknc); + ipf.RGB_denoise_info (origCropPart, provicalc, imgsrc->isRAW(), gamcurve, gam, gamthresh, gamslope, params.dirpyrDenoise, imgsrc->getDirPyrDenoiseExpComp(), chaut, Nb, redaut, blueaut, maxredaut, maxblueaut, minredaut, minblueaut, chromina, sigma, lumema, sigma_L, redyel, skinc, nsknc); float multip = 1.f; float adjustr = 1.f; @@ -304,27 +308,27 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p adjustr = 1.f / 1.2f; } - if(!imgsrc->isRAW()) { + if (!imgsrc->isRAW()) { multip = 2.f; //take into account gamma for TIF / JPG approximate value...not good fot gamma=1 } - float maxmax = max(maxredaut, maxblueaut); + float maxmax = max (maxredaut, maxblueaut); float delta; int mode = 2; int lissage = settings->leveldnliss; ipf.calcautodn_info (chaut, delta, Nb, levaut, maxmax, lumema, chromina, mode, lissage, redyel, skinc, nsknc); // printf("PROCESS cha=%f red=%f bl=%f redM=%f bluM=%f chrom=%f sigm=%f lum=%f sigL=%f\n",chaut,redaut,blueaut, maxredaut, maxblueaut, chromina, sigma, lumema, sigma_L); - if(maxredaut > maxblueaut) { + if (maxredaut > maxblueaut) { maxr = (delta) / ((autoNRmax * multip * adjustr * lowdenoise) / 2.f); - if(minblueaut <= minredaut && minblueaut < chaut) { + if (minblueaut <= minredaut && minblueaut < chaut) { maxb = (-chaut + minblueaut) / (autoNRmax * multip * adjustr * lowdenoise); } } else { maxb = (delta) / ((autoNRmax * multip * adjustr * lowdenoise) / 2.f); - if(minredaut <= minblueaut && minredaut < chaut) { + if (minredaut <= minblueaut && minredaut < chaut) { maxr = (-chaut + minredaut) / (autoNRmax * multip * adjustr * lowdenoise); } }//maxb mxr - empirical evaluation red / blue @@ -347,45 +351,45 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p int liss = settings->leveldnliss; //smooth result around mean - if(liss == 2 || liss == 3) { + if (liss == 2 || liss == 3) { // I smooth only mean and not delta (max) float nchm = 0.f; float koef = 0.4f; //between 0.1 to 0.9 - if(liss == 3) { + if (liss == 3) { koef = 0.0f; //quasi auto for mean Ch } - for(int wcr = 0; wcr < numtiles_W; wcr++) { - for(int hcr = 0; hcr < numtiles_H; hcr++) { + for (int wcr = 0; wcr < numtiles_W; wcr++) { + for (int hcr = 0; hcr < numtiles_H; hcr++) { nchm += ch_M[hcr * numtiles_W + wcr]; } } nchm /= (numtiles_H * numtiles_W); - for(int wcr = 0; wcr < numtiles_W; wcr++) { - for(int hcr = 0; hcr < numtiles_H; hcr++) { + for (int wcr = 0; wcr < numtiles_W; wcr++) { + for (int hcr = 0; hcr < numtiles_H; hcr++) { ch_M[hcr * numtiles_W + wcr] = nchm + (ch_M[hcr * numtiles_W + wcr] - nchm) * koef; } } } - if(liss == 3) { //same as auto but with much cells + if (liss == 3) { //same as auto but with much cells float MaxR = 0.f; float MaxB = 0.f; float MaxRMoy = 0.f; float MaxBMoy = 0.f; - for(int k = 0; k < nbtl; k++) { + for (int k = 0; k < nbtl; k++) { MaxBMoy += max_b[k]; MaxRMoy += max_r[k]; - if(max_r[k] > MaxR) { + if (max_r[k] > MaxR) { MaxR = max_r[k]; } - if(max_b[k] > MaxB) { + if (max_b[k] > MaxB) { MaxB = max_b[k]; } @@ -394,8 +398,8 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p MaxBMoy /= nbtl; MaxRMoy /= nbtl; - for(int k = 0; k < nbtl; k++) { - if(MaxR > MaxB) { + for (int k = 0; k < nbtl; k++) { + if (MaxR > MaxB) { max_r[k] = MaxRMoy + (MaxR - MaxRMoy) * 0.66f; //#std Dev //max_b[k]=MinB; max_b[k] = MaxBMoy + (MaxB - MaxBMoy) * 0.66f; @@ -411,35 +415,35 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p if (settings->verbose) { t2pone.set(); - printf("Info denoise ponderated performed in %d usec:\n", t2pone.etime(t1pone)); + printf ("Info denoise ponderated performed in %d usec:\n", t2pone.etime (t1pone)); } } } - if((settings->leveldnautsimpl == 1 && params.dirpyrDenoise.Cmethod == "AUT") || (settings->leveldnautsimpl == 0 && params.dirpyrDenoise.C2method == "AUTO")) { + if ((settings->leveldnautsimpl == 1 && params.dirpyrDenoise.Cmethod == "AUT") || (settings->leveldnautsimpl == 0 && params.dirpyrDenoise.C2method == "AUTO")) { MyTime t1aue, t2aue; t1aue.set(); int crW, crH; - if(settings->leveldnv == 0) { + if (settings->leveldnv == 0) { crW = 100; crH = 100; } - if(settings->leveldnv == 1) { + if (settings->leveldnv == 1) { crW = 250; crH = 250; } - if(settings->leveldnv == 2) { - crW = int(tileWskip / 2); - crH = int(tileHskip / 2); + if (settings->leveldnv == 2) { + crW = int (tileWskip / 2); + crH = int (tileHskip / 2); } // if(settings->leveldnv ==2) {crW=int(tileWskip/2);crH=int(1.15f*(tileWskip/2));}//adapted to scale of preview - if(settings->leveldnv == 3) { + if (settings->leveldnv == 3) { crW = tileWskip - 10; crH = tileHskip - 10; } @@ -447,14 +451,14 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p float lowdenoise = 1.f; int levaut = settings->leveldnaut; - if(levaut == 1) { //Standard + if (levaut == 1) { //Standard lowdenoise = 0.7f; } if (params.dirpyrDenoise.enabled) {//evaluate Noise - LUTf gamcurve(65536, 0); + LUTf gamcurve (65536, 0); float gam, gamthresh, gamslope; - ipf.RGB_denoise_infoGamCurve(params.dirpyrDenoise, imgsrc->isRAW(), gamcurve, gam, gamthresh, gamslope); + ipf.RGB_denoise_infoGamCurve (params.dirpyrDenoise, imgsrc->isRAW(), gamcurve, gam, gamthresh, gamslope); int Nb[9]; int coordW[3];//coordonate of part of image to mesure noise int coordH[3]; @@ -474,24 +478,24 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p #pragma omp for schedule(dynamic) collapse(2) nowait - for(int wcr = 0; wcr <= 2; wcr++) { - for(int hcr = 0; hcr <= 2; hcr++) { + for (int wcr = 0; wcr <= 2; wcr++) { + for (int hcr = 0; hcr <= 2; hcr++) { PreviewProps ppP (coordW[wcr] , coordH[hcr], crW, crH, 1); imgsrc->getImage (currWB, tr, origCropPart, ppP, params.toneCurve, params.icm, params.raw); // we only need image reduced to 1/4 here - for(int ii = 0; ii < crH; ii += 2) { - for(int jj = 0; jj < crW; jj += 2) { - provicalc->r(ii >> 1, jj >> 1) = origCropPart->r(ii, jj); - provicalc->g(ii >> 1, jj >> 1) = origCropPart->g(ii, jj); - provicalc->b(ii >> 1, jj >> 1) = origCropPart->b(ii, jj); + for (int ii = 0; ii < crH; ii += 2) { + for (int jj = 0; jj < crW; jj += 2) { + provicalc->r (ii >> 1, jj >> 1) = origCropPart->r (ii, jj); + provicalc->g (ii >> 1, jj >> 1) = origCropPart->g (ii, jj); + provicalc->b (ii >> 1, jj >> 1) = origCropPart->b (ii, jj); } } - imgsrc->convertColorSpace(provicalc, params.icm, currWB);//for denoise luminance curve + imgsrc->convertColorSpace (provicalc, params.icm, currWB); //for denoise luminance curve int nb = 0; float chaut = 0.f, redaut = 0.f, blueaut = 0.f, maxredaut = 0.f, maxblueaut = 0.f, minredaut = 0.f, minblueaut = 0.f, chromina = 0.f, sigma = 0.f, lumema = 0.f, sigma_L = 0.f, redyel = 0.f, skinc = 0.f, nsknc = 0.f; - ipf.RGB_denoise_info(origCropPart, provicalc, imgsrc->isRAW(), gamcurve, gam, gamthresh, gamslope, params.dirpyrDenoise, imgsrc->getDirPyrDenoiseExpComp(), chaut, nb, redaut, blueaut, maxredaut, maxblueaut, minredaut, minblueaut, chromina, sigma, lumema, sigma_L, redyel, skinc, nsknc); + ipf.RGB_denoise_info (origCropPart, provicalc, imgsrc->isRAW(), gamcurve, gam, gamthresh, gamslope, params.dirpyrDenoise, imgsrc->getDirPyrDenoiseExpComp(), chaut, nb, redaut, blueaut, maxredaut, maxblueaut, minredaut, minblueaut, chromina, sigma, lumema, sigma_L, redyel, skinc, nsknc); Nb[hcr * 3 + wcr] = nb; ch_M[hcr * 3 + wcr] = chaut; max_r[hcr * 3 + wcr] = maxredaut; @@ -545,7 +549,7 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p adjustr = 1.f / 1.2f; } - if(!imgsrc->isRAW()) { + if (!imgsrc->isRAW()) { multip = 2.f; //take into account gamma for TIF / JPG approximate value...not good fot gamma=1 } @@ -553,17 +557,17 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p int mode = 1; int lissage = settings->leveldnliss; - for(int k = 0; k < 9; k++) { - float maxmax = max(max_r[k], max_b[k]); + for (int k = 0; k < 9; k++) { + float maxmax = max (max_r[k], max_b[k]); ipf.calcautodn_info (ch_M[k], delta[k], Nb[k], levaut, maxmax, lumL[k], chromC[k], mode, lissage, ry[k], sk[k], pcsk[k] ); // printf("ch_M=%f delta=%f\n",ch_M[k], delta[k]); } - for(int k = 0; k < 9; k++) { - if(max_r[k] > max_b[k]) { + for (int k = 0; k < 9; k++) { + if (max_r[k] > max_b[k]) { //printf("R delta=%f koef=%f\n",delta[k],autoNRmax*multip*adjustr*lowdenoise); Max_R[k] = (delta[k]) / ((autoNRmax * multip * adjustr * lowdenoise) / 2.f); - Min_B[k] = -(ch_M[k] - min_b[k]) / (autoNRmax * multip * adjustr * lowdenoise); + Min_B[k] = - (ch_M[k] - min_b[k]) / (autoNRmax * multip * adjustr * lowdenoise); Max_B[k] = 0.f; Min_R[k] = 0.f; } else { @@ -575,7 +579,7 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p } } - for(int k = 0; k < 9; k++) { + for (int k = 0; k < 9; k++) { // printf("ch_M= %f Max_R=%f Max_B=%f min_r=%f min_b=%f\n",ch_M[k],Max_R[k], Max_B[k],Min_R[k], Min_B[k]); chM += ch_M[k]; MaxBMoy += Max_B[k]; @@ -583,19 +587,19 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p MinRMoy += Min_R[k]; MinBMoy += Min_B[k]; - if(Max_R[k] > MaxR) { + if (Max_R[k] > MaxR) { MaxR = Max_R[k]; } - if(Max_B[k] > MaxB) { + if (Max_B[k] > MaxB) { MaxB = Max_B[k]; } - if(Min_R[k] < MinR) { + if (Min_R[k] < MinR) { MinR = Min_R[k]; } - if(Min_B[k] < MinB) { + if (Min_B[k] < MinB) { MinB = Min_B[k]; } @@ -607,7 +611,7 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p MinBMoy /= 9; MinRMoy /= 9; - if(MaxR > MaxB) { + if (MaxR > MaxB) { maxr = MaxRMoy + (MaxR - MaxRMoy) * 0.66f; //#std Dev // maxb=MinB; maxb = MinBMoy + (MinB - MinBMoy) * 0.66f; @@ -628,7 +632,7 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p if (settings->verbose) { t2aue.set(); - printf("Info denoise auto performed in %d usec:\n", t2aue.etime(t1aue)); + printf ("Info denoise auto performed in %d usec:\n", t2aue.etime (t1aue)); } //end evaluate noise @@ -664,7 +668,7 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p // at this stage, we can flush the raw data to free up quite an important amount of memory // commented out because it makes the application crash when batch processing... // TODO: find a better place to flush rawData and rawRGB - if(flush) { + if (flush) { imgsrc->flushRawData(); imgsrc->flushRGB(); } @@ -679,13 +683,13 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p DirPyrDenoiseParams denoiseParams = params.dirpyrDenoise; // make a copy because we cheat here - if(denoiseParams.Lmethod == "CUR") { - if(noiseLCurve) { + if (denoiseParams.Lmethod == "CUR") { + if (noiseLCurve) { denoiseParams.luma = 0.5f; } else { denoiseParams.luma = 0.0f; } - } else if(denoiseParams.Lmethod == "SLI") { + } else if (denoiseParams.Lmethod == "SLI") { noiseLCurve.Reset(); } @@ -694,15 +698,15 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p calclum = new Imagefloat ((fw + 1) / 2, (fh + 1) / 2); //for luminance denoise curve #pragma omp parallel for - for(int ii = 0; ii < fh; ii += 2) { - for(int jj = 0; jj < fw; jj += 2) { - calclum->r(ii >> 1, jj >> 1) = baseImg->r(ii, jj); - calclum->g(ii >> 1, jj >> 1) = baseImg->g(ii, jj); - calclum->b(ii >> 1, jj >> 1) = baseImg->b(ii, jj); + for (int ii = 0; ii < fh; ii += 2) { + for (int jj = 0; jj < fw; jj += 2) { + calclum->r (ii >> 1, jj >> 1) = baseImg->r (ii, jj); + calclum->g (ii >> 1, jj >> 1) = baseImg->g (ii, jj); + calclum->b (ii >> 1, jj >> 1) = baseImg->b (ii, jj); } } - imgsrc->convertColorSpace(calclum, params.icm, currWB); + imgsrc->convertColorSpace (calclum, params.icm, currWB); } if (denoiseParams.enabled) { @@ -711,7 +715,7 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p // ipf.RGB_denoise(baseImg, baseImg, calclum, imgsrc->isRAW(), denoiseParams, params.defringe, imgsrc->getDirPyrDenoiseExpComp(), noiseLCurve, lldenoiseutili); float chaut, redaut, blueaut, maxredaut, maxblueaut, nresi, highresi; int kall = 2; - ipf.RGB_denoise(kall, baseImg, baseImg, calclum, ch_M, max_r, max_b, imgsrc->isRAW(), denoiseParams, imgsrc->getDirPyrDenoiseExpComp(), noiseLCurve, noiseCCurve, chaut, redaut, blueaut, maxredaut, maxblueaut, nresi, highresi); + ipf.RGB_denoise (kall, baseImg, baseImg, calclum, ch_M, max_r, max_b, imgsrc->isRAW(), denoiseParams, imgsrc->getDirPyrDenoiseExpComp(), noiseLCurve, noiseCCurve, chaut, redaut, blueaut, maxredaut, maxblueaut, nresi, highresi); } @@ -727,7 +731,7 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p delete [] sk; delete [] pcsk; - imgsrc->convertColorSpace(baseImg, params.icm, currWB); + imgsrc->convertColorSpace (baseImg, params.icm, currWB); // perform first analysis LUTu hist16 (65536); @@ -747,10 +751,10 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p if (params.dirpyrequalizer.cbdlMethod == "bef" && params.dirpyrequalizer.enabled && !params.colorappearance.enabled) { const int W = baseImg->getWidth(); const int H = baseImg->getHeight(); - LabImage labcbdl(W, H); - ipf.rgb2lab(*baseImg, labcbdl, params.icm.working); + LabImage labcbdl (W, H); + ipf.rgb2lab (*baseImg, labcbdl, params.icm.working); ipf.dirpyrequalizer (&labcbdl, 1); - ipf.lab2rgb(labcbdl, *baseImg, params.icm.working); + ipf.lab2rgb (labcbdl, *baseImg, params.icm.working); } // update blurmap @@ -758,7 +762,7 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p if (params.sh.enabled) { shmap = new SHMap (fw, fh, true); - double radius = sqrt (double(fw * fw + fh * fh)) / 2.0; + double radius = sqrt (double (fw * fw + fh * fh)) / 2.0; double shradius = params.sh.radius; if (!params.sh.hq) { @@ -775,7 +779,7 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p LUTf curve (65536, 0); LUTf satcurve (65536, 0); LUTf lhskcurve (65536, 0); - LUTf lumacurve(32770, 0); // lumacurve[32768] and lumacurve[32769] will be set to 32768 and 32769 later to allow linear interpolation + LUTf lumacurve (32770, 0); // lumacurve[32768] and lumacurve[32769] will be set to 32768 and 32769 later to allow linear interpolation LUTf clcurve (65536, 0); LUTf clToningcurve; LUTf cl2Toningcurve; @@ -804,7 +808,7 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p bool opautili = false; - if(params.colorToning.enabled) { + if (params.colorToning.enabled) { TMatrix wprof = iccStore->workingSpaceMatrix (params.icm.working); double wp[3][3] = { {wprof[0][0], wprof[0][1], wprof[0][2]}, @@ -817,35 +821,35 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p {wiprof[1][0], wiprof[1][1], wiprof[1][2]}, {wiprof[2][0], wiprof[2][1], wiprof[2][2]} }; - params.colorToning.getCurves(ctColorCurve, ctOpacityCurve, wp, wip, opautili); + params.colorToning.getCurves (ctColorCurve, ctOpacityCurve, wp, wip, opautili); clToningcurve (65536, 0); - CurveFactory::curveToning(params.colorToning.clcurve, clToningcurve, 1); + CurveFactory::curveToning (params.colorToning.clcurve, clToningcurve, 1); cl2Toningcurve (65536, 0); - CurveFactory::curveToning(params.colorToning.cl2curve, cl2Toningcurve, 1); + CurveFactory::curveToning (params.colorToning.cl2curve, cl2Toningcurve, 1); } LabImage* labView = new LabImage (fw, fh); - if(params.blackwhite.enabled) { + if (params.blackwhite.enabled) { CurveFactory::curveBW (params.blackwhite.beforeCurve, params.blackwhite.afterCurve, hist16, dummy, customToneCurvebw1, customToneCurvebw2, 1); } double rrm, ggm, bbm; float autor, autog, autob; - float satLimit = float(params.colorToning.satProtectionThreshold) / 100.f * 0.7f + 0.3f; - float satLimitOpacity = 1.f - (float(params.colorToning.saturatedOpacity) / 100.f); + float satLimit = float (params.colorToning.satProtectionThreshold) / 100.f * 0.7f + 0.3f; + float satLimitOpacity = 1.f - (float (params.colorToning.saturatedOpacity) / 100.f); - if(params.colorToning.enabled && params.colorToning.autosat) { //for colortoning evaluation of saturation settings + if (params.colorToning.enabled && params.colorToning.autosat) { //for colortoning evaluation of saturation settings float moyS = 0.f; float eqty = 0.f; ipf.moyeqt (baseImg, moyS, eqty);//return image : mean saturation and standard dev of saturation float satp = ((moyS + 1.5f * eqty) - 0.3f) / 0.7f; //1.5 sigma ==> 93% pixels with high saturation -0.3 / 0.7 convert to Hombre scale - if(satp >= 0.92f) { + if (satp >= 0.92f) { satp = 0.92f; //avoid values too high (out of gamut) } - if(satp <= 0.15f) { + if (satp <= 0.15f) { satp = 0.15f; //avoid too low values } @@ -856,14 +860,14 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p autor = -9000.f; // This will ask to compute the "auto" values for the B&W tool (have to be inferior to -5000) DCPProfile::ApplyState as; - DCPProfile *dcpProf = imgsrc->getDCP(params.icm, currWB, as); + DCPProfile *dcpProf = imgsrc->getDCP (params.icm, currWB, as); LUTu histToneCurve; ipf.rgbProc (baseImg, labView, nullptr, curve1, curve2, curve, shmap, params.toneCurve.saturation, rCurve, gCurve, bCurve, satLimit , satLimitOpacity, ctColorCurve, ctOpacityCurve, opautili, clToningcurve, cl2Toningcurve, customToneCurve1, customToneCurve2, customToneCurvebw1, customToneCurvebw2, rrm, ggm, bbm, autor, autog, autob, expcomp, hlcompr, hlcomprthresh, dcpProf, as, histToneCurve); if (settings->verbose) { - printf("Output image / Auto B&W coefs: R=%.2f G=%.2f B=%.2f\n", autor, autog, autob); + printf ("Output image / Auto B&W coefs: R=%.2f G=%.2f B=%.2f\n", autor, autog, autob); } // if clut was used and size of clut cache == 1 we free the memory used by the clutstore (default clut cache size = 1 for 32 bit OS) @@ -900,7 +904,7 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p // start tile processing...??? - if(params.labCurve.contrast != 0) { //only use hist16 for contrast + if (params.labCurve.contrast != 0) { //only use hist16 for contrast hist16.clear(); #ifdef _OPENMP @@ -915,7 +919,7 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p for (int i = 0; i < fh; i++) for (int j = 0; j < fw; j++) { - hist16thr[(int)((labView->L[i][j]))]++; + hist16thr[ (int) ((labView->L[i][j]))]++; } #pragma omp critical @@ -929,42 +933,656 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p CurveFactory::complexLCurve (params.labCurve.brightness, params.labCurve.contrast, params.labCurve.lcurve, hist16, lumacurve, dummy, 1, utili); bool clcutili; - CurveFactory::curveCL(clcutili, params.labCurve.clcurve, clcurve, 1); + CurveFactory::curveCL (clcutili, params.labCurve.clcurve, clcurve, 1); bool autili, butili, ccutili, cclutili; CurveFactory::complexsgnCurve (autili, butili, ccutili, cclutili, params.labCurve.acurve, params.labCurve.bcurve, params.labCurve.cccurve, params.labCurve.lccurve, curve1, curve2, satcurve, lhskcurve, 1); + bool locutili = false; + bool locallutili = false; + + if (params.locallab.enabled) { + MyTime t1, t2; + t1.set(); + + //Glib::ustring datalab = imgsrc->getFileName() + ".mip"; + + Glib::ustring pop = options.getUserProfilePath() + "/"; + Glib::ustring datalab; + + if (options.mip == MI_opt) { + datalab = pop + Glib::path_get_basename (imgsrc->getFileName () + ".mip"); + } + + if (options.mip == MI_prev) { + datalab = imgsrc->getFileName() + ".mip"; + } + + + LocretigainCurve locRETgainCurve; + LocLHCurve loclhCurve; + + LocretigainCurverab locRETgainCurverab; + LUTf lllocalcurve (65536, 0); + + int realspot = params.locallab.nbspot; + int maxspot = settings->nspot + 1; + ifstream fic0 (datalab, ios::in); + float** shbuffer; + int versionmip = 0; + std::string delim[69] = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", + "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", + "&", "#", "{", "[", "]", "}", "$", "*", "?", ">", "!", ";", "<"",(", ")", "+", "-" + }; + + if (params.locallab.inverssha) { + shbuffer = new float*[fh]; + + for (int i = 0; i < fh; i++) { + shbuffer[i] = new float[fw]; + } + } + + if (fic0) {//normally we don't use here but ?? + //find the version mip + string line; + string spotline; + int cont = 0; + + while (getline (fic0, line)) { + spotline = line; + std::size_t pos = spotline.find ("="); + std::size_t posend = spotline.find ("@"); //in case of for futur use + + if (spotline.substr (0, pos) == "Mipversion") { + string strversion = spotline.substr (pos + 1, (posend - pos)); + versionmip = std::stoi (strversion.c_str()); + } + + if (spotline.substr (0, pos) == "Spot") { + cont = 0; + } + + + } + + fic0.close(); + } + + ifstream fich (datalab, ios::in); + + if (fich && versionmip != 0) { + std::string inser; + + int **dataspots; + dataspots = new int*[60]; + + for (int i = 0; i < 60; i++) { + dataspots[i] = new int[maxspot]; + } + + + std::string *retistrs; + retistrs = new std::string[maxspot]; + std::string *llstrs; + + llstrs = new std::string[maxspot]; + std::string *lhstrs; + + lhstrs = new std::string[maxspot]; + + { + dataspots[2][0] = params.locallab.circrad; + dataspots[3][0] = params.locallab.locX; + dataspots[4][0] = params.locallab.locY; + dataspots[5][0] = params.locallab.locYT; + dataspots[6][0] = params.locallab.locXL; + dataspots[7][0] = params.locallab.centerX; + dataspots[8][0] = params.locallab.centerY; + dataspots[9][0] = params.locallab.lightness; + dataspots[10][0] = params.locallab.contrast; + dataspots[11][0] = params.locallab.chroma; + dataspots[12][0] = params.locallab.sensi; + dataspots[13][0] = params.locallab.transit; + + if (!params.locallab.invers) { + dataspots[14][0] = 0; + } else { + dataspots[14][0] = 1; + } + + if (params.locallab.Smethod == "IND") { + dataspots[15][0] = 0; + } else if (params.locallab.Smethod == "SYM") { + dataspots[15][0] = 1; + } else if (params.locallab.Smethod == "INDSL") { + dataspots[15][0] = 2; + } else if (params.locallab.Smethod == "SYMSL") { + dataspots[15][0] = 3; + } + + dataspots[17][0] = params.locallab.radius; + dataspots[18][0] = params.locallab.strength; + dataspots[19][0] = params.locallab.sensibn; + + if (!params.locallab.inversrad) { + dataspots[20][0] = 0; + } else { + dataspots[20][0] = 1; + } + + dataspots[21][0] = params.locallab.str; + dataspots[22][0] = params.locallab.chrrt; + dataspots[23][0] = params.locallab.neigh; + dataspots[24][0] = params.locallab.vart; + dataspots[25][0] = params.locallab.sensih; + + if (!params.locallab.inversret) { + dataspots[26][0] = 0; + } else { + dataspots[26][0] = 1; + } + + if (params.locallab.retinexMethod == "low") { + dataspots[27][0] = 0; + } else if (params.locallab.retinexMethod == "uni") { + dataspots[27][0] = 1; + } else if (params.locallab.retinexMethod == "high") { + dataspots[27][0] = 2; + } + + + dataspots[28][0] = params.locallab.sharradius; + dataspots[29][0] = params.locallab.sharamount; + dataspots[30][0] = params.locallab.shardamping; + dataspots[31][0] = params.locallab.shariter; + dataspots[32][0] = params.locallab.sensisha; + + if (!params.locallab.inverssha) { + dataspots[33][0] = 0; + } else { + dataspots[33][0] = 1; + } + + if (params.locallab.qualityMethod == "std") { + dataspots[34][0] = 0; + } else if (params.locallab.qualityMethod == "enh") { + dataspots[34][0] = 1; + } else if (params.locallab.qualityMethod == "enhden") { + dataspots[34][0] = 2; + } + + dataspots[35][0] = params.locallab.thres; + dataspots[36][0] = params.locallab.proxi; + + dataspots[37][0] = params.locallab.noiselumf; + dataspots[38][0] = params.locallab.noiselumc; + dataspots[39][0] = params.locallab.noisechrof; + dataspots[40][0] = params.locallab.noisechroc; + + dataspots[41][0] = params.locallab.mult[0]; + dataspots[42][0] = params.locallab.mult[1]; + dataspots[43][0] = params.locallab.mult[2]; + dataspots[44][0] = params.locallab.mult[3]; + dataspots[45][0] = params.locallab.mult[4]; + dataspots[46][0] = params.locallab.threshold; + dataspots[47][0] = params.locallab.sensicb; + + if (!params.locallab.activlum) { + dataspots[48][0] = 0; + } else { + dataspots[48][0] = 1; + } + + dataspots[49][0] = params.locallab.stren; + dataspots[50][0] = params.locallab.gamma; + dataspots[51][0] = params.locallab.estop; + dataspots[52][0] = params.locallab.scaltm; + dataspots[53][0] = params.locallab.rewei; + dataspots[54][0] = params.locallab.sensitm; + dataspots[55][0] = params.locallab.retrab; + + if (!params.locallab.curvactiv) { + dataspots[56][0] = 0; + } else { + dataspots[56][0] = 1; + } + + dataspots[57][0] = 100.f * params.locallab.hueref; + dataspots[58][0] = params.locallab.chromaref; + dataspots[59][0] = params.locallab.lumaref; + + //curve Reti local + int siz = params.locallab.localTgaincurve.size(); + + if (siz > 69) { + siz = 69;//avoid crash + } + + int s_cur[siz + 1]; + int s_datcur[siz + 1]; + + for (int j = 0; j < siz; j++) { + s_datcur[j] = (int) (1000. * params.locallab.localTgaincurve[j]); + } + + std::string cur_str = ""; + + for (int j = 0; j < siz; j++) { + cur_str = cur_str + std::to_string (s_datcur[j]) + delim[j]; + } + + inser = retistrs[0] = cur_str + "@"; + + int sizl = params.locallab.llcurve.size(); + + if (sizl > 69) { + sizl = 69; + } + + int s_curl[sizl + 1]; + int s_datcurl[sizl + 1]; + + for (int j = 0; j < sizl; j++) { + s_datcurl[j] = (int) (1000. * params.locallab.llcurve[j]); + } + + std::string ll_str = ""; + + for (int j = 0; j < sizl; j++) { + ll_str = ll_str + std::to_string (s_datcurl[j]) + delim[j]; + } + + llstrs[0] = ll_str + "@"; + + + int sizh = params.locallab.LHcurve.size(); + + if (sizh > 69) { + sizh = 69; + } + + int s_curh[sizh + 1]; + int s_datcurh[sizh + 1]; + + for (int j = 0; j < sizh; j++) { + s_datcurh[j] = (int) (1000. * params.locallab.LHcurve[j]); + } + + std::string lh_str = ""; + + for (int j = 0; j < sizl; j++) { + lh_str = lh_str + std::to_string (s_datcurh[j]) + delim[j]; + } + + lhstrs[0] = lh_str + "@"; + + + } + locallutili = false; + + + int ns; + int realsp = params.locallab.nbspot; + + if (fich) { + + std::string line; + std::string spotline; + int cont = 0; + int sizecu; + int sizell; + int sizelh; + + while (getline (fich, line)) { + spotline = line; + std::size_t pos = spotline.find ("="); + std::size_t posend = spotline.find ("@"); //in case of for futur use + + if (spotline.substr (0, pos) == "Mipversion") { + std::string strversion = spotline.substr (pos + 1, (posend - pos)); + versionmip = std::stoi (strversion.c_str()); + } + + if (spotline.substr (0, pos) == "Spot") { + cont = 0; + } + + cont++; + std::string str3 = spotline.substr (pos + 1, (posend - pos)); + + if (cont == 1) { + ns = std::stoi (str3.c_str()); + } + + if (cont >= 2 && cont < 16) { + dataspots[cont][ns] = std::stoi (str3.c_str()); + + } + + if (spotline.substr (0, pos) == "Currentspot") { + dataspots[16][0] = std::stoi (str3.c_str()); + } + + if (cont > 16 && cont < 60) { + dataspots[cont][ns] = std::stoi (str3.c_str()); + + } + + if (spotline.substr (0, pos) == "curveReti") { + std::string curstr; + int longecur; + std::string strend = spotline.substr (posend - 1, 1); + std::size_t posz = spotline.find (strend); + int longe; + + for (int sl = 0; sl < 69; sl++) { + if (delim[sl] == strend) { + longe = sl + 1; + } + } + + retistrs[ns] = str3; + sizecu = longe; + // printf("lec simpl str=%s ns=%i si=%i\n", retistrs[ns].c_str(), ns, sizecu); + } + + if (spotline.substr (0, pos) == "curveLL") { + std::string curstrl; + int longecurl; + std::string strendl = spotline.substr (posend - 1, 1); + std::size_t poszl = spotline.find (strendl); + int longel; + + for (int sl = 0; sl < 69; sl++) { + if (delim[sl] == strendl) { + longel = sl + 1; + } + } + + llstrs[ns] = str3; + sizell = longel; + // printf("lecture strLL=%s ns=%i si=%i\n", llstr[ns].c_str(), ns, sizell); + + } + + if (spotline.substr (0, pos) == "curveLH") { + std::string curstrh; + int longecurh; + std::string strendh = spotline.substr (posend - 1, 1); + std::size_t poszh = spotline.find (strendh); + int longeh; + + for (int sh = 0; sh < 69; sh++) { + if (delim[sh] == strendh) { + longeh = sh + 1; + } + } + + lhstrs[ns] = str3; + sizelh = longeh; + //printf("lecture strLH=%s ns=%i si=%i\n", lhstr[ns].c_str(), ns, sizelh); + } + + } + + fich.close(); + } + + + for (int sp = 1; sp < maxspot; sp++) { //spots default + params.locallab.hueref = INFINITY; + params.locallab.chromaref = INFINITY; + params.locallab.lumaref = INFINITY; + + params.locallab.circrad = dataspots[2][sp]; + params.locallab.locX = dataspots[3][sp]; + params.locallab.locY = dataspots[4][sp]; + params.locallab.locYT = dataspots[5][sp]; + params.locallab.locXL = dataspots[6][sp]; + params.locallab.centerX = dataspots[7][sp]; + params.locallab.centerY = dataspots[8][sp]; + params.locallab.lightness = dataspots[9][sp]; + params.locallab.contrast = dataspots[10][sp]; + params.locallab.chroma = dataspots[11][sp]; + params.locallab.sensi = dataspots[12][sp]; + params.locallab.transit = dataspots[13][sp]; + + if (dataspots[14][sp] == 0) { + params.locallab.invers = false; + } else { + params.locallab.invers = true; + } + + if (dataspots[15][sp] == 0) { + params.locallab.Smethod = "IND" ; + } else if (dataspots[15][sp] == 1) { + params.locallab.Smethod = "SYM" ; + } else if (dataspots[15][sp] == 2) { + params.locallab.Smethod = "INDSL"; + } else if (dataspots[15][sp] == 3) { + params.locallab.Smethod = "SYMSL"; + } + + params.locallab.radius = dataspots[17][sp]; + params.locallab.strength = dataspots[18][sp]; + params.locallab.sensibn = dataspots[19][sp]; + + if (dataspots[20][sp] == 0) { + params.locallab.inversrad = false; + } else { + params.locallab.inversrad = true; + } + + params.locallab.str = dataspots[21][sp]; + params.locallab.chrrt = dataspots[22][sp]; + params.locallab.neigh = dataspots[23][sp]; + params.locallab.vart = dataspots[24][sp]; + params.locallab.sensih = dataspots[25][sp]; + + if (dataspots[26][sp] == 0) { + params.locallab.inversret = false; + } else { + params.locallab.inversret = true; + } + + if (dataspots[27][sp] == 0) { + params.locallab.retinexMethod = "low" ; + } else if (dataspots[27][sp] == 1) { + params.locallab.retinexMethod = "uni" ; + } else if (dataspots[27][sp] == 2) { + params.locallab.retinexMethod = "high"; + } + + params.locallab.sharradius = dataspots[28][sp]; + params.locallab.sharamount = dataspots[29][sp]; + params.locallab.shardamping = dataspots[30][sp]; + params.locallab.shariter = dataspots[31][sp]; + params.locallab.sensisha = dataspots[32][sp]; + + if (dataspots[33][sp] == 0) { + params.locallab.inverssha = false; + } else { + params.locallab.inverssha = true; + } + + if (dataspots[34][sp] == 0) { + params.locallab.qualityMethod = "std" ; + } else if (dataspots[34][sp] == 1) { + params.locallab.qualityMethod = "enh" ; + } else if (dataspots[34][sp] == 2) { + params.locallab.qualityMethod = "enhden" ; + } + + params.locallab.thres = dataspots[35][sp]; + params.locallab.proxi = dataspots[36][sp]; + + params.locallab.noiselumf = dataspots[37][sp]; + params.locallab.noiselumc = dataspots[38][sp]; + params.locallab.noisechrof = dataspots[39][sp]; + params.locallab.noisechroc = dataspots[40][sp]; + + params.locallab.mult[0] = dataspots[41][sp]; + params.locallab.mult[1] = dataspots[42][sp]; + params.locallab.mult[2] = dataspots[43][sp]; + params.locallab.mult[3] = dataspots[44][sp]; + params.locallab.mult[4] = dataspots[45][sp]; + params.locallab.threshold = dataspots[46][sp]; + params.locallab.sensicb = dataspots[47][sp]; + + if (dataspots[48][sp] == 0) { + params.locallab.activlum = false; + } else { + params.locallab.activlum = true; + } + + params.locallab.stren = dataspots[49][sp]; + params.locallab.gamma = dataspots[50][sp]; + params.locallab.estop = dataspots[51][sp]; + params.locallab.scaltm = dataspots[52][sp]; + params.locallab.rewei = dataspots[53][sp]; + params.locallab.sensitm = dataspots[54][sp]; + params.locallab.retrab = dataspots[55][sp]; + + if (dataspots[56][sp] == 0) { + params.locallab.curvactiv = false; + } else { + params.locallab.curvactiv = true; + } + + params.locallab.hueref = ((float) dataspots[57][sp]) / 100.f; + params.locallab.chromaref = dataspots[58][sp]; + params.locallab.lumaref = dataspots[59][sp]; + + + int *s_datc; + s_datc = new int[70]; + int siz; + + ipf.strcurv_data (retistrs[sp], s_datc, siz); + std::vector cretiend; + + for (int j = 0; j < siz; j++) { + cretiend.push_back ((double) (s_datc[j]) / 1000.); + } + + delete [] s_datc; + + int *s_datcl; + s_datcl = new int[70]; + int sizl; + + ipf.strcurv_data (llstrs[sp], s_datcl, sizl); + + + std::vector cllend; + + for (int j = 0; j < sizl; j++) { + cllend.push_back ((double) (s_datcl[j]) / 1000.); + } + + delete [] s_datcl; + + + int *s_datch; + s_datch = new int[70]; + int sizh; + + ipf.strcurv_data (lhstrs[sp], s_datch, sizh); + + + std::vector clhend; + + for (int j = 0; j < sizh; j++) { + clhend.push_back ((double) (s_datch[j]) / 1000.); + } + + + params.locallab.localTgaincurve.clear(); + params.locallab.llcurve.clear(); + params.locallab.LHcurve.clear(); + + params.locallab.localTgaincurve = cretiend; + params.locallab.llcurve = cllend; + params.locallab.LHcurve = clhend; + + + + params.locallab.getCurves (locRETgainCurve, locRETgainCurverab, loclhCurve); + bool locallutili = false; + CurveFactory::curveLocal (locallutili, params.locallab.llcurve, lllocalcurve, 1); + + ipf.Lab_Local (2, sp, (float**)shbuffer, labView, labView, 0, 0, 0, 0, fw, fh, fw, fh, locutili, 1, locRETgainCurve, locallutili, lllocalcurve, loclhCurve, params.locallab.hueref, params.locallab.chromaref, params.locallab.lumaref); + lllocalcurve.clear(); + } + + + + for (int i = 0; i < 60; i++) { + delete [] dataspots[i]; + } + + delete [] dataspots; + + + + + delete [] retistrs; + delete [] llstrs; + delete [] lhstrs; + + if (params.locallab.inverssha) { + + for (int i = 0; i < fh; i++) { + delete [] shbuffer[i]; + } + + delete [] shbuffer; + } + + + } + + t2.set(); + + if ( settings->verbose ) { + printf ("Total local:- %d usec\n", t2.etime (t1)); + } + + } + ipf.chromiLuminanceCurve (nullptr, 1, labView, labView, curve1, curve2, satcurve, lhskcurve, clcurve, lumacurve, utili, autili, butili, ccutili, cclutili, clcutili, dummy, dummy); - if((params.colorappearance.enabled && !params.colorappearance.tonecie) || (!params.colorappearance.enabled)) { - ipf.EPDToneMap(labView, 5, 1); + + if ((params.colorappearance.enabled && !params.colorappearance.tonecie) || (!params.colorappearance.enabled)) { + ipf.EPDToneMap (labView, 5, 1); } - ipf.vibrance(labView); + ipf.vibrance (labView); - if((params.colorappearance.enabled && !settings->autocielab) || (!params.colorappearance.enabled)) { + if ((params.colorappearance.enabled && !settings->autocielab) || (!params.colorappearance.enabled)) { ipf.impulsedenoise (labView); } // for all treatments Defringe, Sharpening, Contrast detail ,Microcontrast they are activated if "CIECAM" function are disabled - if((params.colorappearance.enabled && !settings->autocielab) || (!params.colorappearance.enabled)) { + if ((params.colorappearance.enabled && !settings->autocielab) || (!params.colorappearance.enabled)) { ipf.defringe (labView); } if (params.sharpenEdge.enabled) { - ipf.MLsharpen(labView); + ipf.MLsharpen (labView); } if (params.sharpenMicro.enabled) { - if((params.colorappearance.enabled && !settings->autocielab) || (!params.colorappearance.enabled)) { + if ((params.colorappearance.enabled && !settings->autocielab) || (!params.colorappearance.enabled)) { ipf.MLmicrocontrast (labView); //!params.colorappearance.sharpcie } } - if(((params.colorappearance.enabled && !settings->autocielab) || (!params.colorappearance.enabled)) && params.sharpening.enabled) { + if (((params.colorappearance.enabled && !settings->autocielab) || (!params.colorappearance.enabled)) && params.sharpening.enabled) { float **buffer = new float*[fh]; @@ -988,22 +1606,22 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p WavOpacityCurveW waOpacityCurveW; WavOpacityCurveWL waOpacityCurveWL; - params.wavelet.getCurves(wavCLVCurve, waOpacityCurveRG, waOpacityCurveBY, waOpacityCurveW, waOpacityCurveWL ); + params.wavelet.getCurves (wavCLVCurve, waOpacityCurveRG, waOpacityCurveBY, waOpacityCurveW, waOpacityCurveWL ); // directional pyramid wavelet - if(params.dirpyrequalizer.cbdlMethod == "aft") { - if((params.colorappearance.enabled && !settings->autocielab) || !params.colorappearance.enabled) { + if (params.dirpyrequalizer.cbdlMethod == "aft") { + if ((params.colorappearance.enabled && !settings->autocielab) || !params.colorappearance.enabled) { ipf.dirpyrequalizer (labView, 1); //TODO: this is the luminance tonecurve, not the RGB one } } bool wavcontlutili = false; - CurveFactory::curveWavContL(wavcontlutili, params.wavelet.wavclCurve, wavclCurve,/* hist16C, dummy,*/ 1); + CurveFactory::curveWavContL (wavcontlutili, params.wavelet.wavclCurve, wavclCurve,/* hist16C, dummy,*/ 1); - if(params.wavelet.enabled) { - ipf.ip_wavelet(labView, labView, 2, WaveParams, wavCLVCurve, waOpacityCurveRG, waOpacityCurveBY, waOpacityCurveW, waOpacityCurveWL, wavclCurve, wavcontlutili, 1); + if (params.wavelet.enabled) { + ipf.ip_wavelet (labView, labView, 2, WaveParams, wavCLVCurve, waOpacityCurveRG, waOpacityCurveBY, waOpacityCurveW, waOpacityCurveWL, wavclCurve, wavcontlutili, 1); } wavCLVCurve.Reset(); @@ -1013,7 +1631,7 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p int f_w = 1, f_h = 1; int begh = 0, endh = fh; - if(params.colorappearance.tonecie || params.colorappearance.enabled) { + if (params.colorappearance.tonecie || params.colorappearance.enabled) { f_w = fw; f_h = fh; } @@ -1032,21 +1650,21 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p customColCurve3, 1); - if(params.colorappearance.enabled) { + if (params.colorappearance.enabled) { double adap; float fnum = imgsrc->getMetaData()->getFNumber ();// F number float fiso = imgsrc->getMetaData()->getISOSpeed () ;// ISO float fspeed = imgsrc->getMetaData()->getShutterSpeed () ;//speed float fcomp = imgsrc->getMetaData()->getExpComp ();//compensation + - - if(fnum < 0.3f || fiso < 5.f || fspeed < 0.00001f) { + if (fnum < 0.3f || fiso < 5.f || fspeed < 0.00001f) { adap = 2000.; }//if no exif data or wrong else { float E_V = fcomp + log2 ((fnum * fnum) / fspeed / (fiso / 100.f)); E_V += params.toneCurve.expcomp;// exposure compensation in tonecurve ==> direct EV - E_V += log2(params.raw.expos);// exposure raw white point ; log2 ==> linear to EV - adap = powf(2.f, E_V - 3.f); //cd / m2 + E_V += log2 (params.raw.expos); // exposure raw white point ; log2 ==> linear to EV + adap = powf (2.f, E_V - 3.f); //cd / m2 } LUTf CAMBrightCurveJ; @@ -1054,17 +1672,17 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p float CAMMean = NAN; if (params.sharpening.enabled) { - if(settings->ciecamfloat) { + if (settings->ciecamfloat) { float d; - ipf.ciecam_02float (cieView, float(adap), begh, endh, 1, 2, labView, ¶ms, customColCurve1, customColCurve2, customColCurve3, dummy, dummy, CAMBrightCurveJ, CAMBrightCurveQ, CAMMean, 5, 1, true, d, 1, 1); + ipf.ciecam_02float (cieView, float (adap), begh, endh, 1, 2, labView, ¶ms, customColCurve1, customColCurve2, customColCurve3, dummy, dummy, CAMBrightCurveJ, CAMBrightCurveQ, CAMMean, 5, 1, true, d, 1, 1); } else { double dd; ipf.ciecam_02 (cieView, adap, begh, endh, 1, 2, labView, ¶ms, customColCurve1, customColCurve2, customColCurve3, dummy, dummy, CAMBrightCurveJ, CAMBrightCurveQ, CAMMean, 5, 1, true, dd, 1, 1); } } else { - if(settings->ciecamfloat) { + if (settings->ciecamfloat) { float d; - ipf.ciecam_02float (cieView, float(adap), begh, endh, 1, 2, labView, ¶ms, customColCurve1, customColCurve2, customColCurve3, dummy, dummy, CAMBrightCurveJ, CAMBrightCurveQ, CAMMean, 5, 1, true, d, 1, 1); + ipf.ciecam_02float (cieView, float (adap), begh, endh, 1, 2, labView, ¶ms, customColCurve1, customColCurve2, customColCurve3, dummy, dummy, CAMBrightCurveJ, CAMBrightCurveQ, CAMMean, 5, 1, true, d, 1, 1); } else { double dd; ipf.ciecam_02 (cieView, adap, begh, endh, 1, 2, labView, ¶ms, customColCurve1, customColCurve2, customColCurve3, dummy, dummy, CAMBrightCurveJ, CAMBrightCurveQ, CAMMean, 5, 1, true, dd, 1, 1); @@ -1087,7 +1705,7 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p } int imw, imh; - double tmpScale = ipf.resizeScale(¶ms, fw, fh, imw, imh); + double tmpScale = ipf.resizeScale (¶ms, fw, fh, imw, imh); bool labResize = params.resize.enabled && params.resize.method != "Nearest" && tmpScale != 1.0; LabImage *tmplab; @@ -1100,11 +1718,11 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p cw = params.crop.w; ch = params.crop.h; - if(labResize) { // crop lab data - tmplab = new LabImage(cw, ch); + if (labResize) { // crop lab data + tmplab = new LabImage (cw, ch); - for(int row = 0; row < ch; row++) { - for(int col = 0; col < cw; col++) { + for (int row = 0; row < ch; row++) { + for (int col = 0; col < cw; col++) { tmplab->L[row][col] = labView->L[row + cy][col + cx]; tmplab->a[row][col] = labView->a[row + cy][col + cx]; tmplab->b[row][col] = labView->b[row + cy][col + cx]; @@ -1120,16 +1738,16 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p if (labResize) { // resize lab data // resize image - tmplab = new LabImage(imw, imh); + tmplab = new LabImage (imw, imh); ipf.Lanczos (labView, tmplab, tmpScale); delete labView; labView = tmplab; cw = labView->W; ch = labView->H; - if(params.prsharpening.enabled) { - for(int i = 0; i < ch; i++) - for(int j = 0; j < cw; j++) { + if (params.prsharpening.enabled) { + for (int i = 0; i < ch; i++) + for (int j = 0; j < cw; j++) { labView->L[i][j] = labView->L[i][j] < 0.f ? 0.f : labView->L[i][j]; } @@ -1155,7 +1773,7 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p bool useLCMS = false; bool bwonly = params.blackwhite.enabled && !params.colorToning.enabled && !autili && !butili ; - if(params.icm.gamma != "default" || params.icm.freegamma) { // if select gamma output between BT709, sRGB, linear, low, high, 2.2 , 1.8 + if (params.icm.gamma != "default" || params.icm.freegamma) { // if select gamma output between BT709, sRGB, linear, low, high, 2.2 , 1.8 GammaValues ga; // if(params.blackwhite.enabled) params.toneCurve.hrenabled=false; @@ -1176,7 +1794,7 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p readyImg = ipf.lab2rgb16 (labView, cx, cy, cw, ch, params.icm, bwonly); if (settings->verbose) { - printf("Output profile_: \"%s\"\n", params.icm.output.c_str()); + printf ("Output profile_: \"%s\"\n", params.icm.output.c_str()); } } @@ -1185,15 +1803,15 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p - if(bwonly) { //force BW r=g=b + if (bwonly) { //force BW r=g=b if (settings->verbose) { - printf("Force BW\n"); + printf ("Force BW\n"); } for (int ccw = 0; ccw < cw; ccw++) { for (int cch = 0; cch < ch; cch++) { - readyImg->r(cch, ccw) = readyImg->g(cch, ccw); - readyImg->b(cch, ccw) = readyImg->g(cch, ccw); + readyImg->r (cch, ccw) = readyImg->g (cch, ccw); + readyImg->b (cch, ccw) = readyImg->g (cch, ccw); } } } @@ -1220,7 +1838,7 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p if (customGamma) { if (!useLCMS) { // use corrected sRGB profile in order to apply a good TRC if present, otherwise use LCMS2 profile generated by lab2rgb16 w/ gamma - ProfileContent pc(jprof); + ProfileContent pc (jprof); readyImg->setOutputProfile (pc.data, pc.length); } } else { @@ -1229,15 +1847,15 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p if (params.icm.output != "" && params.icm.output != ColorManagementParams::NoICMString) { // if iccStore->getProfile send back an object, then iccStore->getContent will do too - cmsHPROFILE jprof = iccStore->getProfile(params.icm.output); //get outProfile + cmsHPROFILE jprof = iccStore->getProfile (params.icm.output); //get outProfile if (jprof == nullptr) { if (settings->verbose) { - printf("\"%s\" ICC output profile not found!\n - use LCMS2 substitution\n", params.icm.output.c_str()); + printf ("\"%s\" ICC output profile not found!\n - use LCMS2 substitution\n", params.icm.output.c_str()); } } else { if (settings->verbose) { - printf("Using \"%s\" output profile\n", params.icm.output.c_str()); + printf ("Using \"%s\" output profile\n", params.icm.output.c_str()); } ProfileContent pc = iccStore->getContent (params.icm.output); @@ -1287,7 +1905,7 @@ void batchProcessingThread (ProcessingJob* job, BatchProcessingListener* bpl, bo IImage16* img = processImage (currentJob, errorCode, bpl, tunnelMetaData, true); if (errorCode) { - bpl->error (M("MAIN_MSG_CANNOTLOAD")); + bpl->error (M ("MAIN_MSG_CANNOTLOAD")); currentJob = nullptr; } else { try { @@ -1306,10 +1924,10 @@ void startBatchProcessing (ProcessingJob* job, BatchProcessingListener* bpl, boo if (bpl) #if __GNUC__ == 4 && __GNUC_MINOR__ == 8 && defined( WIN32 ) && defined(__x86_64__) // See Issue 2384 "Very bad response time on win7/64 using gcc 4.8 when queue is running" - Glib::Thread::create(sigc::bind(sigc::ptr_fun(batchProcessingThread), job, bpl, tunnelMetaData), 0, true, true, Glib::THREAD_PRIORITY_NORMAL); + Glib::Thread::create (sigc::bind (sigc::ptr_fun (batchProcessingThread), job, bpl, tunnelMetaData), 0, true, true, Glib::THREAD_PRIORITY_NORMAL); #else - Glib::Thread::create(sigc::bind(sigc::ptr_fun(batchProcessingThread), job, bpl, tunnelMetaData), 0, true, true, Glib::THREAD_PRIORITY_LOW); + Glib::Thread::create (sigc::bind (sigc::ptr_fun (batchProcessingThread), job, bpl, tunnelMetaData), 0, true, true, Glib::THREAD_PRIORITY_LOW); #endif } diff --git a/rtgui/CMakeLists.txt b/rtgui/CMakeLists.txt index ad896041f..ad524ae2d 100644 --- a/rtgui/CMakeLists.txt +++ b/rtgui/CMakeLists.txt @@ -29,7 +29,7 @@ set (BASESOURCEFILES sensorbayer.cc sensorxtrans.cc preprocess.cc bayerpreprocess.cc bayerprocess.cc bayerrawexposure.cc xtransprocess.cc xtransrawexposure.cc darkframe.cc flatfield.cc rawcacorrection.cc rawexposure.cc wavelet.cc dirpyrequalizer.cc hsvequalizer.cc defringe.cc - popupcommon.cc popupbutton.cc popuptogglebutton.cc sharpenedge.cc sharpenmicro.cc colorappearance.cc + popupcommon.cc popupbutton.cc popuptogglebutton.cc sharpenedge.cc sharpenmicro.cc colorappearance.cc locallab.cc filmsimulation.cc prsharpening.cc) include_directories (BEFORE "${CMAKE_CURRENT_BINARY_DIR}") diff --git a/rtgui/addsetids.h b/rtgui/addsetids.h index 580874e5a..633b795b1 100644 --- a/rtgui/addsetids.h +++ b/rtgui/addsetids.h @@ -115,7 +115,19 @@ enum { ADDSET_RETI_VART, ADDSET_RETI_GAM, ADDSET_RETI_SLO, - + ADDSET_LOCALLAB_DEGREE, + ADDSET_LOCALLAB_LOCY, + ADDSET_LOCALLAB_LOCX, + ADDSET_LOCALLAB_LOCYT, + ADDSET_LOCALLAB_LOCXL, + ADDSET_LOCALLAB_CENTER, + ADDSET_LOCALLAB_LIGHTNESS, + ADDSET_LOCALLAB_CONTRAST, + ADDSET_LOCALLAB_CHROMA, + ADDSET_LOCALLAB_RADIUS, + ADDSET_LOCALLAB_TRANSIT, + ADDSET_LOCALLAB_STRENGTH, + ADDSET_LOCALLAB_SENSI, ADDSET_PARAM_NUM // THIS IS USED AS A DELIMITER!! }; diff --git a/rtgui/batchtoolpanelcoord.cc b/rtgui/batchtoolpanelcoord.cc index 2caa61187..38645ad6a 100644 --- a/rtgui/batchtoolpanelcoord.cc +++ b/rtgui/batchtoolpanelcoord.cc @@ -160,6 +160,7 @@ void BatchToolPanelCoordinator::initSession () distortion->setAdjusterBehavior (false); perspective->setAdjusterBehavior (false); gradient->setAdjusterBehavior (false, false, false, false); + locallab->setAdjusterBehavior (false, false, false, false, false, false, false, false, false, false, false, false, false); pcvignette->setAdjusterBehavior (false, false, false); cacorrection->setAdjusterBehavior (false); sharpening->setAdjusterBehavior (false); @@ -199,6 +200,7 @@ void BatchToolPanelCoordinator::initSession () distortion->setAdjusterBehavior (options.baBehav[ADDSET_DIST_AMOUNT]); perspective->setAdjusterBehavior (options.baBehav[ADDSET_PERSPECTIVE]); gradient->setAdjusterBehavior (options.baBehav[ADDSET_GRADIENT_DEGREE], options.baBehav[ADDSET_GRADIENT_FEATHER], options.baBehav[ADDSET_GRADIENT_STRENGTH], options.baBehav[ADDSET_GRADIENT_CENTER]); + locallab->setAdjusterBehavior (options.baBehav[ADDSET_LOCALLAB_DEGREE], options.baBehav[ADDSET_LOCALLAB_LOCY], options.baBehav[ADDSET_LOCALLAB_LOCX], options.baBehav[ADDSET_LOCALLAB_LOCYT], options.baBehav[ADDSET_LOCALLAB_LOCXL], options.baBehav[ADDSET_LOCALLAB_CENTER], options.baBehav[ADDSET_LOCALLAB_LIGHTNESS], options.baBehav[ADDSET_LOCALLAB_CONTRAST], options.baBehav[ADDSET_LOCALLAB_CHROMA], options.baBehav[ADDSET_LOCALLAB_SENSI], options.baBehav[ADDSET_LOCALLAB_RADIUS], options.baBehav[ADDSET_LOCALLAB_STRENGTH], options.baBehav[ADDSET_LOCALLAB_TRANSIT]); pcvignette->setAdjusterBehavior (options.baBehav[ADDSET_PCVIGNETTE_STRENGTH], options.baBehav[ADDSET_PCVIGNETTE_FEATHER], options.baBehav[ADDSET_PCVIGNETTE_ROUNDNESS]); cacorrection->setAdjusterBehavior (options.baBehav[ADDSET_CA]); sharpening->setAdjusterBehavior (options.baBehav[ADDSET_SHARP_AMOUNT]); @@ -454,6 +456,62 @@ void BatchToolPanelCoordinator::initSession () pparams.gradient.centerY = 0; } + if (options.baBehav[ADDSET_LOCALLAB_DEGREE]) { + pparams.locallab.degree = 0; + } + + if (options.baBehav[ADDSET_LOCALLAB_LOCY]) { + pparams.locallab.locY = 0; + } + + if (options.baBehav[ADDSET_LOCALLAB_LOCX]) { + pparams.locallab.locX = 0; + } + + if (options.baBehav[ADDSET_LOCALLAB_LOCYT]) { + pparams.locallab.locYT = 0; + } + + if (options.baBehav[ADDSET_LOCALLAB_LOCXL]) { + pparams.locallab.locXL = 0; + } + + if (options.baBehav[ADDSET_LOCALLAB_CENTER]) { + pparams.locallab.centerX = 0; + } + + if (options.baBehav[ADDSET_LOCALLAB_CENTER]) { + pparams.locallab.centerY = 0; + } + + if (options.baBehav[ADDSET_LOCALLAB_LIGHTNESS]) { + pparams.locallab.lightness = 0; + } + + if (options.baBehav[ADDSET_LOCALLAB_CONTRAST]) { + pparams.locallab.contrast = 0; + } + + if (options.baBehav[ADDSET_LOCALLAB_CHROMA]) { + pparams.locallab.chroma = 0; + } + + if (options.baBehav[ADDSET_LOCALLAB_SENSI]) { + pparams.locallab.sensi = 0; + } + + if (options.baBehav[ADDSET_LOCALLAB_RADIUS]) { + pparams.locallab.radius = 0; + } + + if (options.baBehav[ADDSET_LOCALLAB_STRENGTH]) { + pparams.locallab.strength = 0; + } + + if (options.baBehav[ADDSET_LOCALLAB_TRANSIT]) { + pparams.locallab.transit = 0; + } + if (options.baBehav[ADDSET_PCVIGNETTE_STRENGTH]) { pparams.pcvignette.strength = 0; } diff --git a/rtgui/gradient.cc b/rtgui/gradient.cc index 50625251e..14f3328af 100644 --- a/rtgui/gradient.cc +++ b/rtgui/gradient.cc @@ -146,6 +146,8 @@ void Gradient::updateGeometry(const int centerX, const int centerY, const double int imW=0; int imH=0; + + if (fullWidth != -1 && fullHeight != -1) { imW = fullWidth; imH = fullHeight; diff --git a/rtgui/locallab.cc b/rtgui/locallab.cc new file mode 100644 index 000000000..32da9a0bf --- /dev/null +++ b/rtgui/locallab.cc @@ -0,0 +1,3456 @@ +/* + * 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 . + * 2017 Jacques Desmis + */ + + +#include "locallab.h" +#include "rtimage.h" +#include +#include "../rtengine/rt_math.h" +#include "options.h" +#include +#include "edit.h" +#include "guiutils.h" +#include +#include +#include "../rtengine/improcfun.h" + +using namespace rtengine; +using namespace rtengine::procparams; +extern Options options; + + +Locallab::Locallab (): FoldableToolPanel (this, "locallab", M ("TP_LOCALLAB_LABEL"), false, true), EditSubscriber (ET_OBJECTS), lastObject (-1), draggedPointOldAngle (-1000.), + expcolor (new MyExpander (true, M ("TP_LOCALLAB_COFR"))), + expblur (new MyExpander (true, M ("TP_LOCALLAB_BLUFR"))), + exptonemap (new MyExpander (true, M ("TP_LOCALLAB_TM"))), + expreti (new MyExpander (true, M ("TP_LOCALLAB_RETI"))), + expsharp (new MyExpander (true, M ("TP_LOCALLAB_SHARP"))), + expcbdl (new MyExpander (true, M ("TP_LOCALLAB_CBDL"))), + expdenoi (new MyExpander (true, M ("TP_LOCALLAB_DENOIS"))) + +{ + CurveListener::setMulti (true); + ProcParams params; + editHBox = Gtk::manage (new Gtk::HBox()); + edit = Gtk::manage (new Gtk::ToggleButton()); + edit->add (*Gtk::manage (new RTImage ("editmodehand.png"))); + edit->set_tooltip_text (M ("EDIT_OBJECT_TOOLTIP")); + editConn = edit->signal_toggled().connect ( sigc::mem_fun (*this, &Locallab::editToggled) ); + editHBox->pack_start (*edit, Gtk::PACK_SHRINK, 0); + pack_start (*editHBox, Gtk::PACK_SHRINK, 0); + int realnbspot; + + + realnbspot = options.rtSettings.nspot; + + nbspot = Gtk::manage (new Adjuster (M ("TP_LOCALLAB_NBSPOT"), 1, realnbspot, 1, 1)); + + if (options.rtSettings.locdelay) { + + if (nbspot->delay < 200) { + nbspot->delay = 200; + } + } + + + nbspot->setAdjusterListener (this); + nbspot->set_tooltip_text (M ("TP_LOCALLAB_NBSPOT_TOOLTIP")); + + + anbspot = Gtk::manage (new Adjuster (M ("TP_LOCALLAB_ANBSPOT"), 0, 1, 1, 0)); + anbspot->setAdjusterListener (this); + anbspot->set_tooltip_text (M ("TP_LOCALLAB_ANBSPOT_TOOLTIP")); + + + Gtk::Frame* shapeFrame = Gtk::manage (new Gtk::Frame (M ("TP_LOCALLAB_SHFR")) ); + shapeFrame->set_border_width (0); + shapeFrame->set_label_align (0.025, 0.5); + + expcolor->signal_button_release_event().connect_notify ( sigc::bind ( sigc::mem_fun (this, &Locallab::foldAllButMe), expcolor) ); + enablecolorConn = expcolor->signal_enabled_toggled().connect ( sigc::bind ( sigc::mem_fun (this, &Locallab::enableToggled), expcolor) ); + + expblur->signal_button_release_event().connect_notify ( sigc::bind ( sigc::mem_fun (this, &Locallab::foldAllButMe), expblur) ); + enableblurConn = expblur->signal_enabled_toggled().connect ( sigc::bind ( sigc::mem_fun (this, &Locallab::enableToggled), expblur) ); + + exptonemap->signal_button_release_event().connect_notify ( sigc::bind ( sigc::mem_fun (this, &Locallab::foldAllButMe), exptonemap) ); + enabletonemapConn = exptonemap->signal_enabled_toggled().connect ( sigc::bind ( sigc::mem_fun (this, &Locallab::enableToggled), exptonemap) ); + + expreti->signal_button_release_event().connect_notify ( sigc::bind ( sigc::mem_fun (this, &Locallab::foldAllButMe), expreti) ); + enableretiConn = expreti->signal_enabled_toggled().connect ( sigc::bind ( sigc::mem_fun (this, &Locallab::enableToggled), expreti) ); + + expsharp->signal_button_release_event().connect_notify ( sigc::bind ( sigc::mem_fun (this, &Locallab::foldAllButMe), expsharp) ); + enablesharpConn = expsharp->signal_enabled_toggled().connect ( sigc::bind ( sigc::mem_fun (this, &Locallab::enableToggled), expsharp) ); + + expcbdl->signal_button_release_event().connect_notify ( sigc::bind ( sigc::mem_fun (this, &Locallab::foldAllButMe), expcbdl) ); + enablecbdlConn = expcbdl->signal_enabled_toggled().connect ( sigc::bind ( sigc::mem_fun (this, &Locallab::enableToggled), expcbdl) ); + + expdenoi->signal_button_release_event().connect_notify ( sigc::bind ( sigc::mem_fun (this, &Locallab::foldAllButMe), expdenoi) ); + enabledenoiConn = expdenoi->signal_enabled_toggled().connect ( sigc::bind ( sigc::mem_fun (this, &Locallab::enableToggled), expdenoi) ); + + Gtk::VBox *shapeVBox = Gtk::manage ( new Gtk::VBox()); + shapeVBox->set_spacing (2); + shapeVBox->set_border_width (4); + + ctboxS = Gtk::manage (new Gtk::HBox ()); + Gtk::Label* labmS = Gtk::manage (new Gtk::Label (M ("TP_LOCALLAB_STYPE") + ":")); + ctboxS->pack_start (*labmS, Gtk::PACK_SHRINK, 4); + ctboxS->set_tooltip_markup (M ("TP_LOCALLAB_STYPE_TOOLTIP")); + + Smethod = Gtk::manage (new MyComboBoxText ()); + Smethod->append (M ("TP_LOCALLAB_IND")); + Smethod->append (M ("TP_LOCALLAB_SYM")); + Smethod->append (M ("TP_LOCALLAB_INDSL")); + Smethod->append (M ("TP_LOCALLAB_SYMSL")); + Smethod->set_active (0); + Smethodconn = Smethod->signal_changed().connect ( sigc::mem_fun (*this, &Locallab::SmethodChanged) ); + + locX = Gtk::manage (new Adjuster (M ("TP_LOCAL_WIDTH"), 0, 1500, 1, 250)); + //locX->set_tooltip_text (M("TP_LOCAL_WIDTH_TOOLTIP")); + locX->setAdjusterListener (this); + + locXL = Gtk::manage (new Adjuster (M ("TP_LOCAL_WIDTH_L"), 0, 1500, 1, 250)); + //locX->set_tooltip_text (M("TP_LOCAL_WIDTH_TOOLTIP")); + locXL->setAdjusterListener (this); + + degree = Gtk::manage (new Adjuster (M ("TP_LOCAL_DEGREE"), -180, 180, 1, 0)); + //degree->set_tooltip_text (M("TP_LOCAL_DEGREE_TOOLTIP")); + degree->setAdjusterListener (this); + + locY = Gtk::manage (new Adjuster (M ("TP_LOCAL_HEIGHT"), 0, 1500, 1, 250)); + //locY->set_tooltip_text (M("TP_LOCAL_HEIGHT_TOOLTIP")); + locY->setAdjusterListener (this); + + locYT = Gtk::manage (new Adjuster (M ("TP_LOCAL_HEIGHT_T"), 0, 1500, 1, 250)); + //locY->set_tooltip_text (M("TP_LOCAL_HEIGHT_TOOLTIP")); + locYT->setAdjusterListener (this); + + centerX = Gtk::manage (new Adjuster (M ("TP_LOCALLAB_CENTER_X"), -1000, 1000, 1, 0)); + //centerX->set_tooltip_text (M("TP_LOCALLAB_CENTER_X_TOOLTIP")); + centerX->setAdjusterListener (this); + + centerY = Gtk::manage (new Adjuster (M ("TP_LOCALLAB_CENTER_Y"), -1000, 1000, 1, 0)); + //centerY->set_tooltip_text (M("TP_LOCALLAB_CENTER_Y_TOOLTIP")); + centerY->setAdjusterListener (this); + + circrad = Gtk::manage (new Adjuster (M ("TP_LOCALLAB_CIRCRADIUS"), 4, 100, 1, 18)); + circrad->setAdjusterListener (this); + + + qualityMethod = Gtk::manage (new MyComboBoxText ()); + qualityMethod->append (M ("TP_LOCALLAB_STD")); + qualityMethod->append (M ("TP_LOCALLAB_ENH")); + qualityMethod->append (M ("TP_LOCALLAB_ENHDEN")); + qualityMethod->set_active (0); + qualityMethodConn = qualityMethod->signal_changed().connect ( sigc::mem_fun (*this, &Locallab::qualityMethodChanged) ); + qualityMethod->set_tooltip_markup (M ("TP_LOCALLAB_METHOD_TOOLTIP")); + + thres = Gtk::manage (new Adjuster (M ("TP_LOCALLAB_THRES"), 1, 315, 1, 60)); + thres->setAdjusterListener (this); + + proxi = Gtk::manage (new Adjuster (M ("TP_LOCALLAB_PROXI"), 1, 8, 1, 1)); + proxi->setAdjusterListener (this); + std::vector milestones; + std::vector defaultCurve; + std::vector defaultCurve2; + std::vector defaultCurve2rab; + std::vector defaultCurve3; + + irg = Gtk::manage (new RTImage ("Chanmixer-RG.png")); + + llCurveEditorG = new CurveEditorGroup (options.lastlocalCurvesDir, M ("TP_LOCALLAB_LUM")); + llCurveEditorG->setCurveListener (this); + + rtengine::LocallabParams::getDefaultLLCurve (defaultCurve); + llshape = static_cast (llCurveEditorG->addCurve (CT_Diagonal, "L(L)")); + llshape->setResetCurve (DiagonalCurveType (defaultCurve.at (0)), defaultCurve); + llshape->setTooltip (M ("TP_LOCALLAB_CURVEEDITOR_LL_TOOLTIP")); + milestones.push_back ( GradientMilestone (0., 0., 0., 0.) ); + milestones.push_back ( GradientMilestone (1., 1., 1., 1.) ); + llshape->setBottomBarBgGradient (milestones); + llshape->setLeftBarBgGradient (milestones); + + + rtengine::LocallabParams::getDefaultLHCurve (defaultCurve3); + + LHshape = static_cast (llCurveEditorG->addCurve (CT_Flat, "L(H)", nullptr, false, true)); + + LHshape->setIdentityValue (0.); + LHshape->setResetCurve (FlatCurveType (defaultCurve3.at (0)), defaultCurve3); + LHshape->setTooltip (M ("TP_LOCALLAB_CURVEEDITOR_LL_TOOLTIP")); + LHshape->setCurveColorProvider (this, 1); + milestones.clear(); + + for (int i = 0; i < 7; i++) { + float R, G, B; + float x = float (i) * (1.0f / 6.0); + Color::hsv2rgb01 (x, 0.5f, 0.5f, R, G, B); + milestones.push_back ( GradientMilestone (double (x), double (R), double (G), double (B)) ); + } + + LHshape->setBottomBarBgGradient (milestones); + + + llCurveEditorG->curveListComplete(); + + + + lightness = Gtk::manage (new Adjuster (M ("TP_LOCALLAB_LIGHTNESS"), -100, 100, 1, 0)); + //lightness->set_tooltip_text (M("TP_LOCALLAB_LIGHTNESS_TOOLTIP")); + lightness->setAdjusterListener (this); + + contrast = Gtk::manage (new Adjuster (M ("TP_LOCALLAB_CONTRAST"), -100, 100, 1, 0)); + //contrast->set_tooltip_text (M("TP_LOCALLAB_CONTRAST_TOOLTIP")); + contrast->setAdjusterListener (this); + + chroma = Gtk::manage (new Adjuster (M ("TP_LOCALLAB_CHROMA"), -100, 150, 1, 0)); + //chroma->set_tooltip_text (M("TP_LOCALLAB_CHROMA_TOOLTIP")); + chroma->setAdjusterListener (this); + + sensi = Gtk::manage (new Adjuster (M ("TP_LOCALLAB_SENSI"), 0, 100, 1, 19)); + sensi->set_tooltip_text (M ("TP_LOCALLAB_SENSI_TOOLTIP")); + sensi->setAdjusterListener (this); + + radius = Gtk::manage ( new Adjuster (M ("TP_LOCALLAB_RADIUS"), 0, 100, 1, 0) ); + //radius->set_tooltip_text (M("TP_LOCALLAB_RADIUS_TOOLTIP")); + radius->setAdjusterListener (this); + strength = Gtk::manage ( new Adjuster (M ("TP_LOCALLAB_STRENGTH"), 0, 100, 1, 0) ); + //radius->set_tooltip_text (M("TP_LOCALLAB_RADIUS_TOOLTIP")); + strength->setAdjusterListener (this); + + + sensibn = Gtk::manage (new Adjuster (M ("TP_LOCALLAB_SENSIBN"), 0, 100, 1, 60)); + sensibn->set_tooltip_text (M ("TP_LOCALLAB_SENSIH_TOOLTIP")); + sensibn->setAdjusterListener (this); + + activlum = Gtk::manage (new Gtk::CheckButton (M ("TP_LOCALLAB_ACTIV"))); + activlum->set_active (false); + activlumConn = activlum->signal_toggled().connect ( sigc::mem_fun (*this, &Locallab::activlumChanged) ); + + transit = Gtk::manage (new Adjuster (M ("TP_LOCALLAB_TRANSIT"), 5, 95, 1, 60)); + transit->set_tooltip_text (M ("TP_LOCALLAB_TRANSIT_TOOLTIP")); + transit->setAdjusterListener (this); + + invers = Gtk::manage (new Gtk::CheckButton (M ("TP_LOCALLAB_INVERS"))); + invers->set_active (false); + inversConn = invers->signal_toggled().connect ( sigc::mem_fun (*this, &Locallab::inversChanged) ); + + curvactiv = Gtk::manage (new Gtk::CheckButton (M ("TP_LOCALLAB_CURV"))); + curvactiv->set_active (false); + curvactivConn = curvactiv->signal_toggled().connect ( sigc::mem_fun (*this, &Locallab::curvactivChanged) ); + + inversrad = Gtk::manage (new Gtk::CheckButton (M ("TP_LOCALLAB_INVERS"))); + inversrad->set_active (false); + inversradConn = inversrad->signal_toggled().connect ( sigc::mem_fun (*this, &Locallab::inversradChanged) ); + + inversret = Gtk::manage (new Gtk::CheckButton (M ("TP_LOCALLAB_INVERS"))); + inversret->set_active (false); + inversretConn = inversret->signal_toggled().connect ( sigc::mem_fun (*this, &Locallab::inversretChanged) ); + +//tone mapping local + Gtk::VBox * tmBox = Gtk::manage (new Gtk::VBox()); + tmBox->set_border_width (4); + tmBox->set_spacing (2); + + stren = Gtk::manage (new Adjuster (M ("TP_LOCALLAB_STREN"), -100, 200, 1, 0)); + stren->setAdjusterListener (this); + + gamma = Gtk::manage (new Adjuster (M ("TP_LOCALLAB_GAM"), 80, 150, 1, 100)); + gamma->setAdjusterListener (this); + + estop = Gtk::manage (new Adjuster (M ("TP_LOCALLAB_ESTOP"), 10, 400, 1, 140)); + estop->setAdjusterListener (this); + + scaltm = Gtk::manage (new Adjuster (M ("TP_LOCALLAB_SCALTM"), 1, 100, 1, 3)); + scaltm->setAdjusterListener (this); + + rewei = Gtk::manage (new Adjuster (M ("TP_LOCALLAB_REWEI"), 0, 9, 1, 0)); + rewei->setAdjusterListener (this); + + sensitm = Gtk::manage (new Adjuster (M ("TP_LOCALLAB_SENSI"), 0, 100, 1, 40)); + sensitm->set_tooltip_text (M ("TP_LOCALLAB_SENSI_TOOLTIP")); + sensitm->setAdjusterListener (this); + +//end TM + + +//retinex local + Gtk::VBox * retiBox = Gtk::manage (new Gtk::VBox()); + retiBox->set_border_width (4); + retiBox->set_spacing (2); + + dhbox = Gtk::manage (new Gtk::HBox ()); + labmdh = Gtk::manage (new Gtk::Label (M ("TP_LOCRETI_METHOD") + ":")); + dhbox->pack_start (*labmdh, Gtk::PACK_SHRINK, 1); + + retinexMethod = Gtk::manage (new MyComboBoxText ()); +// retinexMethod->append (M("TP_WAVE_NONE")); + retinexMethod->append (M ("TP_RETINEX_LOW")); + retinexMethod->append (M ("TP_RETINEX_UNIFORM")); + retinexMethod->append (M ("TP_RETINEX_HIGH")); + retinexMethod->set_active (0); + retinexMethodConn = retinexMethod->signal_changed().connect ( sigc::mem_fun (*this, &Locallab::retinexMethodChanged) ); + retinexMethod->set_tooltip_markup (M ("TP_LOCRETI_METHOD_TOOLTIP")); + + str = Gtk::manage (new Adjuster (M ("TP_LOCALLAB_STR"), 0, 100, 1, 0)); + str->setAdjusterListener (this); + neigh = Gtk::manage (new Adjuster (M ("TP_LOCALLAB_NEIGH"), 14, 150, 1, 50)); + neigh->setAdjusterListener (this); + vart = Gtk::manage (new Adjuster (M ("TP_LOCALLAB_VART"), 50, 500, 1, 200)); + vart->setAdjusterListener (this); + chrrt = Gtk::manage (new Adjuster (M ("TP_LOCALLAB_CHRRT"), 0, 100, 1, 0)); + chrrt->setAdjusterListener (this); + sensih = Gtk::manage (new Adjuster (M ("TP_LOCALLAB_SENSIH"), 0, 100, 1, 19)); + sensih->set_tooltip_text (M ("TP_LOCALLAB_SENSIH_TOOLTIP")); + sensih->setAdjusterListener (this); + retrab = Gtk::manage (new Adjuster (M ("TP_LOCALLAB_RETRAB"), 0, 10000, 1, 500)); + retrab->setAdjusterListener (this); + +// std::vector defaultCurve; + + LocalcurveEditorgainT = new CurveEditorGroup (options.lastlocalCurvesDir, M ("TP_LOCALLAB_TRANSMISSIONGAIN")); + LocalcurveEditorgainT->setCurveListener (this); + rtengine::LocallabParams::getDefaultLocalgainCurveT (defaultCurve2); + + + cTgainshape = static_cast (LocalcurveEditorgainT->addCurve (CT_Flat, "", nullptr, false, false)); + + cTgainshape->setIdentityValue (0.); + cTgainshape->setResetCurve (FlatCurveType (defaultCurve2.at (0)), defaultCurve2); + cTgainshape->setTooltip (M ("TP_RETINEX_GAINTRANSMISSION_TOOLTIP")); + /* + cTgainshape->setCurveColorProvider(this, 1); + milestones.clear(); + + for (int i = 0; i < 7; i++) { + float R, G, B; + float x = float(i) * (1.0f / 6.0); + Color::hsv2rgb01(x, 0.5f, 0.5f, R, G, B); + milestones.push_back( GradientMilestone(double(x), double(R), double(G), double(B)) ); + } + + cTgainshape->setBottomBarBgGradient(milestones); + */ + + LocalcurveEditorgainTrab = new CurveEditorGroup (options.lastlocalCurvesDir, M ("TP_LOCALLAB_TRANSMISSIONGAINRAB")); + LocalcurveEditorgainTrab->setCurveListener (this); + + rtengine::LocallabParams::getDefaultLocalgainCurveTrab (defaultCurve2rab); + + + cTgainshaperab = static_cast (LocalcurveEditorgainTrab->addCurve (CT_Flat, "", nullptr, false, false)); + + + cTgainshaperab->setIdentityValue (0.); + cTgainshaperab->setResetCurve (FlatCurveType (defaultCurve2rab.at (0)), defaultCurve2rab); + cTgainshaperab->setTooltip (M ("TP_RETINEX_GAINTRANSMISSIONRAB_TOOLTIP")); + + LocalcurveEditorgainT->curveListComplete(); + LocalcurveEditorgainT->show(); + LocalcurveEditorgainTrab->curveListComplete(); + LocalcurveEditorgainTrab->show(); + +// retiFrame->add(*retiBox); +// pack_start (*retiFrame); + +// end reti + + avoid = Gtk::manage (new Gtk::CheckButton (M ("TP_LOCALLAB_AVOID"))); + avoid->set_active (false); + avoidConn = avoid->signal_toggled().connect ( sigc::mem_fun (*this, &Locallab::avoidChanged) ); + pack_start (*nbspot); + pack_start (*anbspot); + anbspot->hide();//keep anbspot - i used it to test diffrent algo... + ctboxS->pack_start (*Smethod); + shapeVBox->pack_start (*ctboxS); + + shapeVBox->pack_start (*locX); + shapeVBox->pack_start (*locXL); + //pack_start (*degree); + shapeVBox->pack_start (*locY); + shapeVBox->pack_start (*locYT); + shapeVBox->pack_start (*centerX); + shapeVBox->pack_start (*centerY); + shapeVBox->pack_start (*circrad); + //shapeVBox->pack_start (*activlum); + shapeVBox->pack_start (*qualityMethod); + // shapeVBox->pack_start (*thres); + // shapeVBox->pack_start (*proxi); + + shapeFrame->add (*shapeVBox); + pack_start (*shapeFrame); + + Gtk::VBox *colorVBox = Gtk::manage ( new Gtk::VBox()); + colorVBox->set_spacing (2); + colorVBox->set_border_width (4); + + Gtk::VBox *blurrVBox = Gtk::manage ( new Gtk::VBox()); + blurrVBox->set_spacing (2); + blurrVBox->set_border_width (4); + + Gtk::VBox *sharpVBox = Gtk::manage ( new Gtk::VBox()); + sharpVBox->set_spacing (2); + sharpVBox->set_border_width (4); + + Gtk::VBox *cbdlVBox = Gtk::manage ( new Gtk::VBox()); + cbdlVBox->set_spacing (2); + cbdlVBox->set_border_width (4); + + + Gtk::HBox * buttonBox1 = Gtk::manage (new Gtk::HBox (true, 10)); + + Gtk::Button * lumacontrastMinusButton = Gtk::manage (new Gtk::Button (M ("TP_DIRPYREQUALIZER_LUMACONTRAST_MINUS"))); + buttonBox1->pack_start (*lumacontrastMinusButton); + lumacontrastMinusPressedConn = lumacontrastMinusButton->signal_pressed().connect ( sigc::mem_fun (*this, &Locallab::lumacontrastMinusPressed)); + + Gtk::Button * lumaneutralButton = Gtk::manage (new Gtk::Button (M ("TP_DIRPYREQUALIZER_LUMANEUTRAL"))); + buttonBox1->pack_start (*lumaneutralButton); + lumaneutralPressedConn = lumaneutralButton->signal_pressed().connect ( sigc::mem_fun (*this, &Locallab::lumaneutralPressed)); + + Gtk::Button * lumacontrastPlusButton = Gtk::manage (new Gtk::Button (M ("TP_DIRPYREQUALIZER_LUMACONTRAST_PLUS"))); + buttonBox1->pack_start (*lumacontrastPlusButton); + lumacontrastPlusPressedConn = lumacontrastPlusButton->signal_pressed().connect ( sigc::mem_fun (*this, &Locallab::lumacontrastPlusPressed)); + + cbdlVBox->pack_start (*buttonBox1); + + for (int i = 0; i < 5; i++) { + Glib::ustring ss; + ss = Glib::ustring::format (i); + + if (i == 0) { + ss += Glib::ustring::compose (" (%1)", M ("TP_DIRPYREQUALIZER_LUMAFINEST")); + } else if (i == 4) { + ss += Glib::ustring::compose (" (%1)", M ("TP_DIRPYREQUALIZER_LUMACOARSEST")); + } + + multiplier[i] = Gtk::manage ( new Adjuster (ss, 0, 400, 1, 100) ); + multiplier[i]->setAdjusterListener (this); + cbdlVBox->pack_start (*multiplier[i]); + } + + Gtk::HSeparator *separator3 = Gtk::manage (new Gtk::HSeparator()); + cbdlVBox->pack_start (*separator3, Gtk::PACK_SHRINK, 2); + + threshold = Gtk::manage ( new Adjuster (M ("TP_DIRPYREQUALIZER_THRESHOLD"), 0, 100, 1, 20) ); + threshold->setAdjusterListener (this); + cbdlVBox->pack_start (*threshold); + + sensicb = Gtk::manage (new Adjuster (M ("TP_LOCALLAB_SENSICB"), 0, 100, 1, 19)); + sensicb->set_tooltip_text (M ("TP_LOCALLAB_SENSIH_TOOLTIP")); + sensicb->setAdjusterListener (this); + cbdlVBox->pack_start (*sensicb); + + sharradius = Gtk::manage (new Adjuster (M ("TP_LOCALLAB_SHARRADIUS"), 42, 250, 1, 4)); + sharradius->setAdjusterListener (this); + + sharamount = Gtk::manage (new Adjuster (M ("TP_LOCALLAB_SHARAMOUNT"), 0, 100, 1, 75)); + sharamount->setAdjusterListener (this); + + shardamping = Gtk::manage (new Adjuster (M ("TP_LOCALLAB_SHARDAMPING"), 0, 100, 1, 75)); + shardamping->setAdjusterListener (this); + + shariter = Gtk::manage (new Adjuster (M ("TP_LOCALLAB_SHARITER"), 5, 100, 1, 30)); + shariter->setAdjusterListener (this); + + + sensisha = Gtk::manage (new Adjuster (M ("TP_LOCALLAB_SENSIS"), 0, 100, 1, 19)); + sensisha->set_tooltip_text (M ("TP_LOCALLAB_SENSIS_TOOLTIP")); + sensisha->setAdjusterListener (this); + + inverssha = Gtk::manage (new Gtk::CheckButton (M ("TP_LOCALLAB_INVERS"))); + inverssha->set_active (false); + inversshaConn = inverssha->signal_toggled().connect ( sigc::mem_fun (*this, &Locallab::inversshaChanged) ); + + sharpVBox->pack_start (*sharradius); + sharpVBox->pack_start (*sharamount); + sharpVBox->pack_start (*shardamping); + sharpVBox->pack_start (*shariter); + sharpVBox->pack_start (*sensisha); + sharpVBox->pack_start (*inverssha); + + Gtk::VBox *denoisVBox = Gtk::manage ( new Gtk::VBox()); + denoisVBox->set_spacing (2); + denoisVBox->set_border_width (4); + + noiselumf = Gtk::manage (new Adjuster (M ("TP_LOCALLAB_NOISELUMFINE"), 0, 100, 1, 0)); + noiselumf->setAdjusterListener (this); + + noiselumc = Gtk::manage (new Adjuster (M ("TP_LOCALLAB_NOISELUMCOARSE"), 0, 100, 1, 0)); + noiselumc->setAdjusterListener (this); + + noisechrof = Gtk::manage (new Adjuster (M ("TP_LOCALLAB_NOISECHROFINE"), 0, 100, 1, 0)); + noisechrof->setAdjusterListener (this); + + noisechroc = Gtk::manage (new Adjuster (M ("TP_LOCALLAB_NOISECHROCOARSE"), 0, 100, 1, 0)); + noisechroc->setAdjusterListener (this); + + denoisVBox->pack_start (*noiselumf); + denoisVBox->pack_start (*noiselumc); + denoisVBox->pack_start (*noisechrof); + denoisVBox->pack_start (*noisechroc); + + neutrHBox1 = Gtk::manage (new Gtk::HBox ()); + neutrHBox1->set_border_width (2); + + neutral1 = Gtk::manage (new Gtk::Button (M ("TP_LOCALLAB_NEUTRAL"))); + RTImage *resetImg1 = Gtk::manage (new RTImage ("gtk-undo-ltr-small.png", "gtk-undo-rtl-small.png")); + neutral1->set_image (*resetImg1); + neutral1->set_tooltip_text (M ("TP_LOCALLAB_NEUTRAL_TIP")); + neutralconn1 = neutral1->signal_pressed().connect ( sigc::mem_fun (*this, &Locallab::neutral_pressed) ); + neutral1->show(); + neutrHBox1->pack_start (*neutral1); + pack_start (*neutrHBox1); + + + + colorVBox->pack_start (*lightness); + colorVBox->pack_start (*contrast); + colorVBox->pack_start (*chroma); + colorVBox->pack_start (*sensi); + colorVBox->pack_start (*curvactiv); + + colorVBox->pack_start (*llCurveEditorG, Gtk::PACK_SHRINK, 2); + // colorVBox->pack_start(*llCurveEditorG2, Gtk::PACK_SHRINK, 2); + + colorVBox->pack_start (*invers); + +// colorFrame->add(*colorVBox); +// pack_start (*colorFrame); + expcolor->add (*colorVBox); + pack_start (*expcolor); + + blurrVBox->pack_start (*radius); + blurrVBox->pack_start (*strength); + blurrVBox->pack_start (*sensibn); + blurrVBox->pack_start (*activlum); + + blurrVBox->pack_start (*inversrad); + expblur->add (*blurrVBox); + pack_start (*expblur); + + tmBox->pack_start (*stren); + tmBox->pack_start (*gamma); + tmBox->pack_start (*estop); + tmBox->pack_start (*scaltm); + tmBox->pack_start (*rewei); + tmBox->pack_start (*sensitm); + + exptonemap->add (*tmBox); + pack_start (*exptonemap); + + + retiBox->pack_start (*retinexMethod); + retiBox->pack_start (*str); + retiBox->pack_start (*chrrt); + retiBox->pack_start (*neigh); + retiBox->pack_start (*vart); + retiBox->pack_start (*sensih); + retiBox->pack_start (*retrab); + + retiBox->pack_start (*LocalcurveEditorgainTrab, Gtk::PACK_SHRINK, 4); + + retiBox->pack_start (*LocalcurveEditorgainT, Gtk::PACK_SHRINK, 4); + retiBox->pack_start (*inversret); + + expreti->add (*retiBox); + pack_start (*expreti); + + + expsharp->add (*sharpVBox); + pack_start (*expsharp); + + expcbdl->add (*cbdlVBox); + pack_start (*expcbdl); + + expdenoi->add (*denoisVBox); + pack_start (*expdenoi); + + + pack_start (*transit); + pack_start (*avoid);//keep avoid clor shift in case of + + neutrHBox = Gtk::manage (new Gtk::HBox ()); + neutrHBox->set_border_width (2); + + neutral = Gtk::manage (new Gtk::Button (M ("TP_LOCALLAB_NEUTRAL"))); + RTImage *resetImg = Gtk::manage (new RTImage ("gtk-undo-ltr-small.png", "gtk-undo-rtl-small.png")); + neutral->set_image (*resetImg); + neutral->set_tooltip_text (M ("TP_LOCALLAB_NEUTRAL_TIP")); + neutralconn = neutral->signal_pressed().connect ( sigc::mem_fun (*this, &Locallab::neutral_pressed) ); + neutral->show(); + neutrHBox->pack_start (*neutral); + pack_start (*neutrHBox); + + + // Instantiating the Editing geometry; positions will be initialized later + Line *hLine, *vLine, *locYLine[2], *locXLine[2]; + Circle *centerCircle; + + // Visible geometry + locXLine[0] = new Line(); + locXLine[0]->innerLineWidth = 2; + locXLine[1] = new Line(); + locXLine[1]->innerLineWidth = 2; + locXLine[0]->datum = locXLine[1]->datum = Geometry::IMAGE; + + locYLine[0] = new Line(); + locYLine[0]->innerLineWidth = 2; + locYLine[1] = new Line(); + locYLine[1]->innerLineWidth = 2; + locYLine[0]->datum = locYLine[1]->datum = Geometry::IMAGE; + + centerCircle = new Circle(); + centerCircle->datum = Geometry::IMAGE; + centerCircle->radiusInImageSpace = true; + centerCircle->radius = circrad->getValue(); //19; + centerCircle->filled = false; + + EditSubscriber::visibleGeometry.push_back ( locXLine[0] ); + EditSubscriber::visibleGeometry.push_back ( locXLine[1] ); + EditSubscriber::visibleGeometry.push_back ( locYLine[0] ); + EditSubscriber::visibleGeometry.push_back ( locYLine[1] ); + EditSubscriber::visibleGeometry.push_back ( centerCircle ); + + // MouseOver geometry + locXLine[0] = new Line(); + locXLine[0]->innerLineWidth = 2; + locXLine[1] = new Line(); + locXLine[1]->innerLineWidth = 2; + locXLine[0]->datum = locXLine[1]->datum = Geometry::IMAGE; + + locYLine[0] = new Line(); + locYLine[0]->innerLineWidth = 2; + locYLine[1] = new Line(); + locYLine[1]->innerLineWidth = 2; + locYLine[0]->datum = locYLine[1]->datum = Geometry::IMAGE; + + centerCircle = new Circle(); + centerCircle->datum = Geometry::IMAGE; + centerCircle->radiusInImageSpace = true; + centerCircle->radius = circrad->getValue();//19; + centerCircle->filled = true; + + EditSubscriber::mouseOverGeometry.push_back ( locXLine[0] ); + EditSubscriber::mouseOverGeometry.push_back ( locXLine[1] ); + + EditSubscriber::mouseOverGeometry.push_back ( locYLine[0] ); + EditSubscriber::mouseOverGeometry.push_back ( locYLine[1] ); + + EditSubscriber::mouseOverGeometry.push_back ( centerCircle ); + + show_all(); +} + +Locallab::~Locallab() +{ + for (std::vector::const_iterator i = visibleGeometry.begin(); i != visibleGeometry.end(); ++i) { + delete *i; + } + + for (std::vector::const_iterator i = mouseOverGeometry.begin(); i != mouseOverGeometry.end(); ++i) { + delete *i; + } + + delete LocalcurveEditorgainT; + delete LocalcurveEditorgainTrab; + delete llCurveEditorG; +// delete llCurveEditorG2; + +} +void Locallab::foldAllButMe (GdkEventButton* event, MyExpander *expander) +{ + if (event->button == 2) { + expcolor->set_expanded (expcolor == expander); + expblur->set_expanded (expblur == expander); + exptonemap->set_expanded (exptonemap == expander); + expreti->set_expanded (expreti == expander); + expsharp->set_expanded (expsharp == expander); + expcbdl->set_expanded (expcbdl == expander); + expdenoi->set_expanded (expdenoi == expander); + + } +} + +void Locallab::enableToggled (MyExpander *expander) +{ + if (listener) { + rtengine::ProcEvent event = NUMOFEVENTS; + + if (expander == expcolor) { + event = EvLocenacolor; + } else if (expander == expblur) { + event = EvLocenablur; + } else if (expander == exptonemap) { + event = EvLocenatonemap; + } else if (expander == expreti) { + event = EvLocenareti; + } else if (expander == expsharp) { + event = EvLocenasharp; + } else if (expander == expcbdl) { + event = EvLocenacbdl; + } else if (expander == expdenoi) { + event = EvLocenadenoi; + } else { + return; + } + + if (expander->get_inconsistent()) { + listener->panelChanged (event, M ("GENERAL_UNCHANGED")); + } else if (expander->getEnabled()) { + listener->panelChanged (event, M ("GENERAL_ENABLED")); + } else { + listener->panelChanged (event, M ("GENERAL_DISABLED")); + } + + } +} + +void Locallab::writeOptions (std::vector &tpOpen) +{ + tpOpen.push_back (expcolor->get_expanded ()); + tpOpen.push_back (expblur->get_expanded ()); + tpOpen.push_back (exptonemap->get_expanded ()); + tpOpen.push_back (expreti->get_expanded ()); + tpOpen.push_back (expsharp->get_expanded ()); + tpOpen.push_back (expcbdl->get_expanded ()); + tpOpen.push_back (expdenoi->get_expanded ()); + +} + +void Locallab::updateToolState (std::vector &tpOpen) +{ + if (tpOpen.size() == 7) { + expcolor->set_expanded (tpOpen.at (0)); + expblur->set_expanded (tpOpen.at (1)); + exptonemap->set_expanded (tpOpen.at (2)); + expreti->set_expanded (tpOpen.at (3)); + expsharp->set_expanded (tpOpen.at (4)); + expcbdl->set_expanded (tpOpen.at (5)); + expdenoi->set_expanded (tpOpen.at (6)); + + + } +} + + + +void Locallab::neutral_pressed () +{ + Smethod->set_active (0); + locX->resetValue (false); + locXL->resetValue (false); + locY->resetValue (false); + locYT->resetValue (false); + centerX->resetValue (false); + centerY->resetValue (false); + circrad->resetValue (false); + qualityMethod->set_active (0); + thres->resetValue (false); + proxi->resetValue (false); + lightness->resetValue (false); + chroma->resetValue (false); + contrast->resetValue (false); + sensi->resetValue (false); + radius->resetValue (false); + strength->resetValue (false); + transit->resetValue (false); + sensibn->resetValue (false); + invers->set_active (false); + curvactiv->set_active (false); + inversrad->set_active (false); + inversret->set_active (false); + stren->resetValue (false); + gamma->resetValue (false); + estop->resetValue (false); + scaltm->resetValue (false); + rewei->resetValue (false); + sensitm->resetValue (false); + retinexMethod->set_active (2); + str->resetValue (false); + neigh->resetValue (false); + vart->resetValue (false); + chrrt->resetValue (false); + sensih->resetValue (false); + retrab->resetValue (false); +// cTgainshape->reset(); +// cTgainshape->setCurve (creti); + avoid->set_active (false); + + for (int i = 0; i < 5; i++) { + multiplier[i]->resetValue (false); + } + + threshold->resetValue (false); + sensicb->resetValue (false); + sharradius->resetValue (false); + sharamount->resetValue (false); + shardamping->resetValue (false); + shariter->resetValue (false); + sensisha->resetValue (false); + inverssha->set_active (false); + noiselumf->resetValue (false); + noiselumc->resetValue (false); + noisechrof->resetValue (false); + noisechroc->resetValue (false); + + +} + + +void Locallab::lumaneutralPressed () +{ + + for (int i = 0; i < 5; i++) { + multiplier[i]->setValue (100); + adjusterChanged (multiplier[i], 100); + } +} + + +void Locallab::lumacontrastPlusPressed () +{ + + for (int i = 0; i < 5; i++) { + float inc = (5 - i); + multiplier[i]->setValue (multiplier[i]->getValue() + inc); + adjusterChanged (multiplier[i], multiplier[i]->getValue()); + } +} + + +void Locallab::lumacontrastMinusPressed () +{ + + for (int i = 0; i < 5; i++) { + float inc = - (5 - i); + multiplier[i]->setValue (multiplier[i]->getValue() + inc); + adjusterChanged (multiplier[i], multiplier[i]->getValue()); + } +} + + + +void Locallab::autoOpenCurve () +{ + cTgainshape->openIfNonlinear(); + // llshape->openIfNonlinear(); + // LHshape->openIfNonlinear(); + +} + + +int localChangedUI (void* data) +{ + + GThreadLock lock; + (static_cast (data))->localComputed_ (); + + return 0; +} + +int localretChangedUI (void* data) +{ + + GThreadLock lock; + (static_cast (data))->localretComputed_ (); + + return 0; +} + +bool Locallab::localretComputed_ () +{ + disableListener (); + + //Reticurv +//update GUI and MIP specially for curve + + int *s_datc; + s_datc = new int[70]; + int siz; + //printf("nexts=%s\n", nextstr2.c_str()); + ImProcFunctions::strcurv_data (nextstr2, s_datc, siz); + std::vector creti; + + for (int j = 0; j < siz; j++) { + creti.push_back ((double) (s_datc[j]) / 1000.); + } + + delete [] s_datc; + + cTgainshape->setCurve (creti); + + int *s_datcl; + s_datcl = new int[70]; + int sizl; + ImProcFunctions::strcurv_data (nextll_str2, s_datcl, sizl); + std::vector cll; + + for (int j = 0; j < sizl; j++) { + cll.push_back ((double) (s_datcl[j]) / 1000.); + } + + delete [] s_datcl; + + llshape->setCurve (cll); + + int *s_datch; + s_datch = new int[70]; + int sizh; + ImProcFunctions::strcurv_data (nextlh_str2, s_datch, sizh); + std::vector clh; + + for (int j = 0; j < sizh; j++) { + clh.push_back ((double) (s_datch[j]) / 1000.); + } + + delete [] s_datch; + + LHshape->setCurve (clh); + + + enableListener (); + + //update all sliders by this strange process! + if (anbspot->getValue() == 0) { + anbspot->setValue (1); + + if (options.rtSettings.locdelay) { + if (anbspot->delay < 100) { + anbspot->delay = 100; + } + } + + adjusterChanged (anbspot, 1); + + } else if (anbspot->getValue() == 1) { + anbspot->setValue (0); + + if (options.rtSettings.locdelay) { + if (anbspot->delay < 100) { + anbspot->delay = 100; + } + } + + adjusterChanged (anbspot, 0); + + } + + //update all curves + std::vector cretirab; + cretirab = cTgainshaperab->getCurve (); + + if (cretirab.at (5) == 0.70) { + cretirab.at (5) = 0.9; + cTgainshaperab->setCurve (cretirab); + + curveChanged (cTgainshaperab); + } else if (cretirab.at (5) == 0.90) { + cretirab.at (5) = 0.7; + cTgainshaperab->setCurve (cretirab); + curveChanged (cTgainshaperab); + + } + + +// printf("G2 anbspot=%i\n", anbspot->getValue()); + + if (listener) { //for all sliders + listener->panelChanged (Evlocallabanbspot, anbspot->getTextValue()); + } + + if (listener) {//for curve + listener->panelChanged (EvlocallabCTgainCurverab, M ("HISTORY_CUSTOMCURVE")); + } + + if (listener) {//for curve + listener->panelChanged (EvlocallabCTgainCurve, M ("HISTORY_CUSTOMCURVE")); + } + + if (listener) {//for curve + listener->panelChanged (Evlocallabllshape, M ("HISTORY_CUSTOMCURVE")); + } + + if (listener) {//for curve + listener->panelChanged (EvlocallabLHshape, M ("HISTORY_CUSTOMCURVE")); + } + + +} + +bool Locallab::localComputed_ () +{ +//update GUI and MIP + disableListener (); + + //size spot + circrad->setValue (nextdatasp[2]); + //center and cursor + locX->setValue (nextdatasp[3]); + locY->setValue (nextdatasp[4]); + locYT->setValue (nextdatasp[5]); + locXL->setValue (nextdatasp[6]); + centerX->setValue (nextdatasp[7]); + centerY->setValue (nextdatasp[8]); + + //sliders + lightness->setValue (nextdatasp[9]); + contrast->setValue (nextdatasp[10]); + chroma->setValue (nextdatasp[11]); + sensi->setValue (nextdatasp[12]); + transit->setValue (nextdatasp[13]); + + //inverse + if (nextdatasp[14] == 0) { + invers->set_active (false); + } else { + invers->set_active (true); + } + + //method cursor + if (nextdatasp[15] == 0) { + Smethod->set_active (0); + } else if (nextdatasp[15] == 1) { + Smethod->set_active (1); + } else if (nextdatasp[15] == 2) { + Smethod->set_active (2); + } else if (nextdatasp[15] == 3) { + Smethod->set_active (3); + } + + //sliders blurr + radius->setValue (nextdatasp[17]); + strength->setValue (nextdatasp[18]); + sensibn->setValue (nextdatasp[19]); + + //inverse + if (nextdatasp[20] == 0) { + inversrad->set_active (false); + } else { + inversrad->set_active (true); + } + + //sliders retinex + str->setValue (nextdatasp[21]); + chrrt->setValue (nextdatasp[22]); + neigh->setValue (nextdatasp[23]); + vart->setValue (nextdatasp[24]); + sensih->setValue (nextdatasp[25]); + + //inverse + if (nextdatasp[26] == 0) { + inversret->set_active (false); + } else { + inversret->set_active (true); + } + + //method retinex + if (nextdatasp[27] == 0) { + retinexMethod->set_active (0); + } else if (nextdatasp[27] == 1) { + retinexMethod->set_active (1); + } else if (nextdatasp[27] == 2) { + retinexMethod->set_active (2); + } + + //sharpening + sharradius->setValue (nextdatasp[28]); + sharamount->setValue (nextdatasp[29]); + shardamping->setValue (nextdatasp[30]); + shariter->setValue (nextdatasp[31]); + sensisha->setValue (nextdatasp[32]); + + if (nextdatasp[33] == 0) { + inverssha->set_active (false); + } else { + inverssha->set_active (true); + } + + if (nextdatasp[34] == 0) { + qualityMethod->set_active (0); + } else if (nextdatasp[34] == 1) { + qualityMethod->set_active (1); + } else if (nextdatasp[34] == 2) { + qualityMethod->set_active (2); + } + + thres->setValue (nextdatasp[35]); + proxi->setValue (nextdatasp[36]); + + //denoise + noiselumf->setValue (nextdatasp[37]); + noiselumc->setValue (nextdatasp[38]); + noisechrof->setValue (nextdatasp[39]); + noisechroc->setValue (nextdatasp[40]); + + //cbdl + multiplier[0]->setValue (nextdatasp[41]); + multiplier[1]->setValue (nextdatasp[42]); + multiplier[2]->setValue (nextdatasp[43]); + multiplier[3]->setValue (nextdatasp[44]); + multiplier[4]->setValue (nextdatasp[45]); + threshold->setValue (nextdatasp[46]); + sensicb->setValue (nextdatasp[47]); + + //blur luma + if (nextdatasp[48] == 0) { + activlum->set_active (false); + } else { + activlum->set_active (true); + } + +//TM + stren->setValue (nextdatasp[49]); + gamma->setValue (nextdatasp[50]); + estop->setValue (nextdatasp[51]); + scaltm->setValue (nextdatasp[52]); + rewei->setValue (nextdatasp[53]); + sensitm->setValue (nextdatasp[54]); + // usleep(10000); + + //Reticurv + retrab->setValue (nextdatasp[55]); + + //curvactiv + if (nextdatasp[56] == 0) { + curvactiv->set_active (false); + } else { + curvactiv->set_active (true); + } + + int *s_datc; + s_datc = new int[70]; + int siz; + ImProcFunctions::strcurv_data (nextstr, s_datc, siz); + + + std::vector creti; + + for (int j = 0; j < siz; j++) { + creti.push_back ((double) (s_datc[j]) / 1000.); + } + + delete [] s_datc; + + cTgainshape->setCurve (creti); + + //LLcurv + int *s_datcl; + s_datcl = new int[70]; + int sizl; + ImProcFunctions::strcurv_data (nextll_str, s_datcl, sizl); + + + std::vector cll; + + for (int j = 0; j < sizl; j++) { + cll.push_back ((double) (s_datcl[j]) / 1000.); + } + + delete [] s_datcl; + llshape->setCurve (cll); + + + //LHcurv + int *s_datch; + s_datch = new int[70]; + int sizh; + ImProcFunctions::strcurv_data (nextlh_str, s_datch, sizh); + + + std::vector clh; + + for (int j = 0; j < sizh; j++) { + clh.push_back ((double) (s_datch[j]) / 1000.); + } + + delete [] s_datch; + LHshape->setCurve (clh); + + + // usleep(10000); + + + enableListener (); + + //update all sliders by this strange process! + if (anbspot->getValue() == 0) { + anbspot->setValue (1); + + if (options.rtSettings.locdelay) { + if (anbspot->delay < 100) { + anbspot->delay = 100; + } + } + + adjusterChanged (anbspot, 1); + + } else if (anbspot->getValue() == 1) { + anbspot->setValue (0); + + if (options.rtSettings.locdelay) { + if (anbspot->delay < 100) { + anbspot->delay = 100; + } + } + + adjusterChanged (anbspot, 0); + + } + + + //update all curves + std::vector cretirab; + cretirab = cTgainshaperab->getCurve (); + + if (cretirab.at (5) == 0.70) { + cretirab.at (5) = 0.9; + cTgainshaperab->setCurve (cretirab); + + curveChanged (cTgainshaperab); + } else if (cretirab.at (5) == 0.90) { + cretirab.at (5) = 0.7; + cTgainshaperab->setCurve (cretirab); + curveChanged (cTgainshaperab); + + } + + // + +// printf("G1 maj anbspot=%i cretirab=%f\n", anbspot->getValue(), cretirab.at(5)); + + + //add events for each cases + if (listener) { //for all sliders + listener->panelChanged (Evlocallabanbspot, anbspot->getTextValue()); + } + + if (listener) {//for curve + listener->panelChanged (EvlocallabCTgainCurverab, M ("HISTORY_CUSTOMCURVE")); + } + + if (listener) {//for inverse color + listener->panelChanged (Evlocallabinvers, M ("GENERAL_ENABLED")); + } + + if (listener) {//for curvactiv + listener->panelChanged (Evlocallabcurvactiv, M ("GENERAL_ENABLED")); + } + + if (listener) {//for inverse blurr + listener->panelChanged (Evlocallabinversrad, M ("GENERAL_ENABLED")); + } + + if (listener) {//for quality method + listener->panelChanged (EvlocallabqualityMethod, qualityMethod->get_active_text ()); + + } + + if (listener) {//for inverse retinex + listener->panelChanged (Evlocallabinversret, M ("GENERAL_ENABLED")); + } + + if (listener) {//for inverse sharpen + listener->panelChanged (Evlocallabinverssha, M ("GENERAL_ENABLED")); + } + + if (listener) {//for Smethod : position of mouse cursor + listener->panelChanged (EvlocallabSmet, Smethod->get_active_text ()); + } + + if (listener) {//for retinex method + listener->panelChanged (EvlocallabretinexMethod, retinexMethod->get_active_text ()); + } + + if (listener) {//for curve reti + listener->panelChanged (EvlocallabCTgainCurve, M ("HISTORY_CUSTOMCURVE")); + } + + if (listener) {//for curve LL + listener->panelChanged (Evlocallabllshape, M ("HISTORY_CUSTOMCURVE")); + } + + if (listener) {//for curve LH + listener->panelChanged (EvlocallabLHshape, M ("HISTORY_CUSTOMCURVE")); + } + + return false; +} + +void Locallab::localChanged (int **datasp, std::string datastr, std::string ll_str, std::string lh_str, int sp, int maxdat) +{ + for (int i = 2; i < 60; i++) { //58 + nextdatasp[i] = datasp[i][sp]; + } + + nextstr = datastr; + nextll_str = ll_str; + nextlh_str = lh_str; + + nextlength = maxdat; + g_idle_add (localChangedUI, this); +} + +void Locallab::localretChanged (int **datasp, std::string datastr, std::string ll_str, std::string lh_str, int sp, int maxdat) +{ + nextlength = maxdat; + nextstr2 = datastr; + nextll_str2 = ll_str; + nextlh_str2 = lh_str; + + g_idle_add (localretChangedUI, this); +} + + +void Locallab::read (const ProcParams* pp, const ParamsEdited* pedited) +{ + disableListener (); + enablecolorConn.block (true); + enableblurConn.block (true); + enabletonemapConn.block (true); + enableretiConn.block (true); + enablesharpConn.block (true); + enablecbdlConn.block (true); + enabledenoiConn.block (true); + + + if (pedited) { + degree->setEditedState (pedited->locallab.degree ? Edited : UnEdited); + locY->setEditedState (pedited->locallab.locY ? Edited : UnEdited); + locX->setEditedState (pedited->locallab.locX ? Edited : UnEdited); + locYT->setEditedState (pedited->locallab.locYT ? Edited : UnEdited); + locXL->setEditedState (pedited->locallab.locXL ? Edited : UnEdited); + centerX->setEditedState (pedited->locallab.centerX ? Edited : UnEdited); + centerY->setEditedState (pedited->locallab.centerY ? Edited : UnEdited); + circrad->setEditedState (pedited->locallab.circrad ? Edited : UnEdited); + thres->setEditedState (pedited->locallab.thres ? Edited : UnEdited); + proxi->setEditedState (pedited->locallab.proxi ? Edited : UnEdited); + lightness->setEditedState (pedited->locallab.lightness ? Edited : UnEdited); + contrast->setEditedState (pedited->locallab.contrast ? Edited : UnEdited); + chroma->setEditedState (pedited->locallab.chroma ? Edited : UnEdited); + sharradius->setEditedState (pedited->locallab.sharradius ? Edited : UnEdited); + sharamount->setEditedState (pedited->locallab.sharamount ? Edited : UnEdited); + shardamping->setEditedState (pedited->locallab.shardamping ? Edited : UnEdited); + shariter->setEditedState (pedited->locallab.shariter ? Edited : UnEdited); + sensisha->setEditedState (pedited->locallab.sensisha ? Edited : UnEdited); + noiselumf->setEditedState (pedited->locallab.noiselumf ? Edited : UnEdited); + noiselumc->setEditedState (pedited->locallab.noiselumc ? Edited : UnEdited); + noisechrof->setEditedState (pedited->locallab.noisechrof ? Edited : UnEdited); + noisechroc->setEditedState (pedited->locallab.noisechroc ? Edited : UnEdited); + + for (int i = 0; i < 5; i++) { + multiplier[i]->setEditedState (pedited->locallab.mult[i] ? Edited : UnEdited); + } + + threshold->setEditedState (pedited->locallab.threshold ? Edited : UnEdited); + + sensi->setEditedState (pedited->locallab.sensi ? Edited : UnEdited); + sensih->setEditedState (pedited->locallab.sensih ? Edited : UnEdited); + retrab->setEditedState (pedited->locallab.retrab ? Edited : UnEdited); + sensicb->setEditedState (pedited->locallab.sensicb ? Edited : UnEdited); + sensibn->setEditedState (pedited->locallab.sensibn ? Edited : UnEdited); + sensitm->setEditedState (pedited->locallab.sensitm ? Edited : UnEdited); + radius->setEditedState (pedited->locallab.radius ? Edited : UnEdited); + strength->setEditedState (pedited->locallab.strength ? Edited : UnEdited); + stren->setEditedState (pedited->locallab.stren ? Edited : UnEdited); + gamma->setEditedState (pedited->locallab.gamma ? Edited : UnEdited); + estop->setEditedState (pedited->locallab.estop ? Edited : UnEdited); + scaltm->setEditedState (pedited->locallab.scaltm ? Edited : UnEdited); + rewei->setEditedState (pedited->locallab.rewei ? Edited : UnEdited); + + nbspot->setEditedState (pedited->locallab.nbspot ? Edited : UnEdited); + anbspot->setEditedState (pedited->locallab.anbspot ? Edited : UnEdited); + transit->setEditedState (pedited->locallab.transit ? Edited : UnEdited); + str->setEditedState (pedited->locallab.str ? Edited : UnEdited); + neigh->setEditedState (pedited->locallab.neigh ? Edited : UnEdited); + vart->setEditedState (pedited->locallab.vart ? Edited : UnEdited); + chrrt->setEditedState (pedited->locallab.chrrt ? Edited : UnEdited); + set_inconsistent (multiImage && !pedited->locallab.enabled); + avoid->set_inconsistent (multiImage && !pedited->locallab.avoid); + activlum->set_inconsistent (multiImage && !pedited->locallab.activlum); + invers->set_inconsistent (multiImage && !pedited->locallab.invers); + curvactiv->set_inconsistent (multiImage && !pedited->locallab.curvactiv); + inversrad->set_inconsistent (multiImage && !pedited->locallab.inversrad); + inverssha->set_inconsistent (multiImage && !pedited->locallab.inverssha); + cTgainshape->setUnChanged (!pedited->locallab.localTgaincurve); + llshape->setUnChanged (!pedited->locallab.llcurve); + LHshape->setUnChanged (!pedited->locallab.LHcurve); + inversret->set_inconsistent (multiImage && !pedited->locallab.inversret); + cTgainshaperab->setUnChanged (!pedited->locallab.localTgaincurverab); + expcolor->set_inconsistent (!pedited->locallab.expcolor); + expblur->set_inconsistent (!pedited->locallab.expblur); + exptonemap->set_inconsistent (!pedited->locallab.exptonemap); + expreti->set_inconsistent (!pedited->locallab.expreti); + expsharp->set_inconsistent (!pedited->locallab.expsharp); + expcbdl->set_inconsistent (!pedited->locallab.expcbdl); + expdenoi->set_inconsistent (!pedited->locallab.expdenoi); + + if (!pedited->locallab.Smethod) { + Smethod->set_active_text (M ("GENERAL_UNCHANGED")); + } + + if (!pedited->locallab.retinexMethod) { + retinexMethod->set_active_text (M ("GENERAL_UNCHANGED")); + } + + if (!pedited->locallab.qualityMethod) { + qualityMethod->set_active_text (M ("GENERAL_UNCHANGED")); + } + + } + + setEnabled (pp->locallab.enabled); + + Smethodconn.block (true); + retinexMethodConn.block (true); + qualityMethodConn.block (true); + + avoidConn.block (true); + avoid->set_active (pp->locallab.avoid); + avoidConn.block (false); + activlumConn.block (true); + activlum->set_active (pp->locallab.activlum); + activlumConn.block (false); + inversConn.block (true); + invers->set_active (pp->locallab.invers); + inversConn.block (false); + curvactivConn.block (true); + curvactiv->set_active (pp->locallab.curvactiv); + curvactivConn.block (false); + inversradConn.block (true); + inversrad->set_active (pp->locallab.inversrad); + inversradConn.block (false); + inversretConn.block (true); + inversret->set_active (pp->locallab.inversret); + inversretConn.block (false); + inversshaConn.block (true); + inverssha->set_active (pp->locallab.inverssha); + inversshaConn.block (false); + + degree->setValue (pp->locallab.degree); + locY->setValue (pp->locallab.locY); + locX->setValue (pp->locallab.locX); + locYT->setValue (pp->locallab.locYT); + locXL->setValue (pp->locallab.locXL); + centerX->setValue (pp->locallab.centerX); + centerY->setValue (pp->locallab.centerY); + circrad->setValue (pp->locallab.circrad); + thres->setValue (pp->locallab.thres); + proxi->setValue (pp->locallab.proxi); + lightness->setValue (pp->locallab.lightness); + contrast->setValue (pp->locallab.contrast); + chroma->setValue (pp->locallab.chroma); + sharradius->setValue (pp->locallab.sharradius); + sharamount->setValue (pp->locallab.sharamount); + shardamping->setValue (pp->locallab.shardamping); + shariter->setValue (pp->locallab.shariter); + sensisha->setValue (pp->locallab.sensisha); + sensi->setValue (pp->locallab.sensi); + sensih->setValue (pp->locallab.sensih); + retrab->setValue (pp->locallab.retrab); + sensicb->setValue (pp->locallab.sensicb); + sensibn->setValue (pp->locallab.sensibn); + sensitm->setValue (pp->locallab.sensitm); + transit->setValue (pp->locallab.transit); + radius->setValue (pp->locallab.radius); + strength->setValue (pp->locallab.strength); + stren->setValue (pp->locallab.stren); + gamma->setValue (pp->locallab.gamma); + estop->setValue (pp->locallab.estop); + scaltm->setValue (pp->locallab.scaltm); + rewei->setValue (pp->locallab.rewei); + str->setValue (pp->locallab.str); + neigh->setValue (pp->locallab.neigh); + nbspot->setValue (pp->locallab.nbspot); + anbspot->setValue (pp->locallab.anbspot); + vart->setValue (pp->locallab.vart); + chrrt->setValue (pp->locallab.chrrt); + cTgainshape->setCurve (pp->locallab.localTgaincurve); + cTgainshaperab->setCurve (pp->locallab.localTgaincurverab); + llshape->setCurve (pp->locallab.llcurve); + LHshape->setCurve (pp->locallab.LHcurve); + lastactivlum = pp->locallab.activlum; + lastanbspot = pp->locallab.anbspot; + noiselumf->setValue (pp->locallab.noiselumf); + noiselumc->setValue (pp->locallab.noiselumc); + noisechrof->setValue (pp->locallab.noisechrof); + noisechroc->setValue (pp->locallab.noisechroc); + expcolor->setEnabled (pp->locallab.expcolor); + expblur->setEnabled (pp->locallab.expblur); + exptonemap->setEnabled (pp->locallab.exptonemap); + expreti->setEnabled (pp->locallab.expreti); + expsharp->setEnabled (pp->locallab.expsharp); + expcbdl->setEnabled (pp->locallab.expcbdl); + expdenoi->setEnabled (pp->locallab.expdenoi); + + for (int i = 0; i < 5; i++) { + multiplier[i]->setValue (pp->locallab.mult[i]); + } + + threshold->setValue (pp->locallab.threshold); + + lastavoid = pp->locallab.avoid; + lastinvers = pp->locallab.invers; + lastcurvactiv = pp->locallab.curvactiv; + lastinversrad = pp->locallab.inversrad; + lastinversret = pp->locallab.inversret; + lastinverssha = pp->locallab.inverssha; + activlumChanged(); + inversChanged(); + curvactivChanged(); + inversradChanged(); + inversretChanged(); + inversshaChanged(); + + updateGeometry (pp->locallab.centerX, pp->locallab.centerY, pp->locallab.circrad, pp->locallab.locY, pp->locallab.degree, pp->locallab.locX, pp->locallab.locYT, pp->locallab.locXL); + + if (pp->locallab.Smethod == "IND") { + Smethod->set_active (0); + } else if (pp->locallab.Smethod == "SYM") { + Smethod->set_active (1); + } else if (pp->locallab.Smethod == "INDSL") { + Smethod->set_active (2); + } else if (pp->locallab.Smethod == "SYMSL") { + Smethod->set_active (3); + } + + SmethodChanged(); + Smethodconn.block (false); + + if (pp->locallab.retinexMethod == "low") { + retinexMethod->set_active (0); + } else if (pp->locallab.retinexMethod == "uni") { + retinexMethod->set_active (1); + } else if (pp->locallab.retinexMethod == "high") { + retinexMethod->set_active (2); + } + + retinexMethodChanged (); + retinexMethodConn.block (false); + + if (pp->locallab.qualityMethod == "std") { + qualityMethod->set_active (0); + } else if (pp->locallab.qualityMethod == "enh") { + qualityMethod->set_active (1); + } else if (pp->locallab.qualityMethod == "enhden") { + qualityMethod->set_active (2); + } + + qualityMethodChanged (); + qualityMethodConn.block (false); + + + anbspot->hide(); + + if (pp->locallab.Smethod == "SYM" || pp->locallab.Smethod == "SYMSL") { + locXL->setValue (locX->getValue()); + locYT->setValue (locY->getValue()); + } else if (pp->locallab.Smethod == "LOC") { + locXL->setValue (locX->getValue()); + locYT->setValue (locX->getValue()); + locY->setValue (locX->getValue()); + } else if (pp->locallab.Smethod == "INDSL" || pp->locallab.Smethod == "IND") { + locX->setValue (pp->locallab.locX); + locY->setValue (pp->locallab.locY); + locXL->setValue (pp->locallab.locXL); + locYT->setValue (pp->locallab.locYT); + + } + + enablecolorConn.block (false); + enableblurConn.block (false); + enabletonemapConn.block (false); + enableretiConn.block (false); + enablesharpConn.block (false); + enablecbdlConn.block (false); + enabledenoiConn.block (false); + + enableListener (); +} + +void Locallab::updateGeometry (const int centerX_, const int centerY_, const int circrad_, const int locY_, const double degree_, const int locX_, const int locYT_, const int locXL_, const int fullWidth, const int fullHeight) +{ + EditDataProvider* dataProvider = getEditProvider(); + + + if (!dataProvider) { + return; + } + + int imW = 0; + int imH = 0; + + if (fullWidth != -1 && fullHeight != -1) { + imW = fullWidth; + imH = fullHeight; + } else { + dataProvider->getImageSize (imW, imH); + + if (!imW || !imH) { + return; + } + } + + PolarCoord polCoord1, polCoord2, polCoord0; + // dataProvider->getImageSize(imW, imH); + double decayY = (locY_) * double (imH) / 2000.; + double decayYT = (locYT_) * double (imH) / 2000.; + double decayX = (locX_) * (double (imW)) / 2000.; + double decayXL = (locXL_) * (double (imW)) / 2000.; + rtengine::Coord origin (imW / 2 + centerX_ * imW / 2000.f, imH / 2 + centerY_ * imH / 2000.f); +// printf("deX=%f dexL=%f deY=%f deyT=%f\n", decayX, decayXL, decayY, decayYT); + + if (Smethod->get_active_row_number() == 1 || Smethod->get_active_row_number() == 3) { + decayYT = decayY; + decayXL = decayX; + } + + Line *currLine; + Circle *currCircle; + double decay; + const auto updateLine = [&] (Geometry * geometry, const float radius, const float begin, const float end) { + const auto line = static_cast (geometry); + line->begin = PolarCoord (radius, -degree_ + begin); + line->begin += origin; + line->end = PolarCoord (radius, -degree_ + end); + line->end += origin; + }; + + const auto updateLineWithDecay = [&] (Geometry * geometry, const float radius, const float decal, const float offSetAngle) { + const auto line = static_cast (geometry); //180 + line->begin = PolarCoord (radius, -degree_ + decal) + PolarCoord (decay, -degree_ + offSetAngle); + line->begin += origin;//0 + line->end = PolarCoord (radius, -degree_ + (decal - 180)) + PolarCoord (decay, -degree_ + offSetAngle); + line->end += origin; + }; + + const auto updateCircle = [&] (Geometry * geometry) { + const auto circle = static_cast (geometry); + circle->center = origin; + circle->radius = circrad_; + + }; + + decay = decayX; + updateLineWithDecay (visibleGeometry.at (0), 100., 90., 0.); + updateLineWithDecay (mouseOverGeometry.at (0), 100., 90., 0.); + + decay = decayXL; + + updateLineWithDecay (visibleGeometry.at (1), 100., 90., 180.); + updateLineWithDecay (mouseOverGeometry.at (1), 100., 90., 180.); + + decay = decayYT; + updateLineWithDecay (visibleGeometry.at (2), 100., 180., 270.); + updateLineWithDecay (mouseOverGeometry.at (2), 100., 180., 270.); + + decay = decayY; + + updateLineWithDecay (visibleGeometry.at (3), 100., 180, 90.); + updateLineWithDecay (mouseOverGeometry.at (3), 100., 180., 90.); + + + updateCircle (visibleGeometry.at (4)); + updateCircle (mouseOverGeometry.at (4)); + + +} + +void Locallab::write (ProcParams* pp, ParamsEdited* pedited) +{ + pp->locallab.degree = degree->getValue (); + pp->locallab.locY = locY->getIntValue (); + pp->locallab.locX = locX->getValue (); + pp->locallab.locYT = locYT->getIntValue (); + pp->locallab.locXL = locXL->getValue (); + pp->locallab.centerX = centerX->getIntValue (); + pp->locallab.centerY = centerY->getIntValue (); + pp->locallab.circrad = circrad->getIntValue (); + pp->locallab.proxi = proxi->getIntValue (); + pp->locallab.thres = thres->getIntValue (); + pp->locallab.lightness = lightness->getIntValue (); + pp->locallab.contrast = contrast->getIntValue (); + pp->locallab.chroma = chroma->getIntValue (); + pp->locallab.noiselumc = noiselumc->getIntValue (); + pp->locallab.noiselumf = noiselumf->getIntValue (); + pp->locallab.noisechrof = noisechrof->getIntValue (); + pp->locallab.noisechroc = noisechroc->getIntValue (); + pp->locallab.sharradius = sharradius->getIntValue (); + pp->locallab.sharamount = sharamount->getIntValue (); + pp->locallab.shardamping = shardamping->getIntValue (); + pp->locallab.shariter = shariter->getIntValue (); + pp->locallab.sensisha = sensisha->getIntValue (); + pp->locallab.sensi = sensi->getIntValue (); + pp->locallab.sensih = sensih->getIntValue (); + pp->locallab.retrab = retrab->getIntValue (); + pp->locallab.sensicb = sensicb->getIntValue (); + pp->locallab.sensibn = sensibn->getIntValue (); + pp->locallab.sensitm = sensitm->getIntValue (); + pp->locallab.radius = radius->getIntValue (); + pp->locallab.strength = strength->getIntValue (); + pp->locallab.stren = stren->getIntValue (); + pp->locallab.gamma = gamma->getIntValue (); + pp->locallab.estop = estop->getIntValue (); + pp->locallab.scaltm = scaltm->getIntValue (); + pp->locallab.rewei = rewei->getIntValue (); + pp->locallab.enabled = getEnabled(); + pp->locallab.transit = transit->getIntValue (); + pp->locallab.avoid = avoid->get_active(); + pp->locallab.activlum = activlum->get_active(); + pp->locallab.invers = invers->get_active(); + pp->locallab.curvactiv = curvactiv->get_active(); + pp->locallab.inversrad = inversrad->get_active(); + pp->locallab.inversret = inversret->get_active(); + pp->locallab.inverssha = inverssha->get_active(); + pp->locallab.str = str->getIntValue (); + pp->locallab.neigh = neigh->getIntValue (); + pp->locallab.nbspot = nbspot->getIntValue (); + pp->locallab.anbspot = anbspot->getIntValue (); + pp->locallab.vart = vart->getIntValue (); + pp->locallab.chrrt = chrrt->getIntValue (); + pp->locallab.localTgaincurve = cTgainshape->getCurve (); + pp->locallab.localTgaincurverab = cTgainshaperab->getCurve (); + pp->locallab.llcurve = llshape->getCurve (); + pp->locallab.LHcurve = LHshape->getCurve (); + pp->locallab.expcolor = expcolor->getEnabled(); + pp->locallab.expblur = expblur->getEnabled(); + pp->locallab.exptonemap = exptonemap->getEnabled(); + pp->locallab.expreti = expreti->getEnabled(); + pp->locallab.expsharp = expsharp->getEnabled(); + pp->locallab.expcbdl = expcbdl->getEnabled(); + pp->locallab.expdenoi = expdenoi->getEnabled(); + + for (int i = 0; i < 5; i++) { + pp->locallab.mult[i] = multiplier[i]->getIntValue(); + } + + pp->locallab.threshold = threshold->getIntValue(); + + if (pedited) { + pedited->locallab.degree = degree->getEditedState (); + pedited->locallab.Smethod = Smethod->get_active_text() != M ("GENERAL_UNCHANGED"); + pedited->locallab.retinexMethod = retinexMethod->get_active_text() != M ("GENERAL_UNCHANGED"); + pedited->locallab.qualityMethod = qualityMethod->get_active_text() != M ("GENERAL_UNCHANGED"); + pedited->locallab.locY = locY->getEditedState (); + pedited->locallab.locX = locX->getEditedState (); + pedited->locallab.locYT = locYT->getEditedState (); + pedited->locallab.locXL = locXL->getEditedState (); + pedited->locallab.centerX = centerX->getEditedState (); + pedited->locallab.centerY = centerY->getEditedState (); + pedited->locallab.circrad = circrad->getEditedState (); + pedited->locallab.proxi = proxi->getEditedState (); + pedited->locallab.thres = thres->getEditedState (); + pedited->locallab.lightness = lightness->getEditedState (); + pedited->locallab.contrast = contrast->getEditedState (); + pedited->locallab.chroma = chroma->getEditedState (); + pedited->locallab.noiselumf = noiselumf->getEditedState (); + pedited->locallab.noiselumc = noiselumc->getEditedState (); + pedited->locallab.noisechrof = noisechrof->getEditedState (); + pedited->locallab.noisechroc = noisechroc->getEditedState (); + pedited->locallab.sharradius = sharradius->getEditedState (); + pedited->locallab.sharamount = sharamount->getEditedState (); + pedited->locallab.shardamping = shardamping->getEditedState (); + pedited->locallab.shariter = shariter->getEditedState (); + pedited->locallab.sensisha = sensisha->getEditedState (); + pedited->locallab.sensi = sensi->getEditedState (); + pedited->locallab.sensih = sensih->getEditedState (); + pedited->locallab.retrab = retrab->getEditedState (); + pedited->locallab.sensicb = sensicb->getEditedState (); + pedited->locallab.sensibn = sensibn->getEditedState (); + pedited->locallab.sensitm = sensitm->getEditedState (); + pedited->locallab.radius = radius->getEditedState (); + pedited->locallab.strength = strength->getEditedState (); + pedited->locallab.stren = stren->getEditedState (); + pedited->locallab.gamma = gamma->getEditedState (); + pedited->locallab.estop = estop->getEditedState (); + pedited->locallab.scaltm = scaltm->getEditedState (); + pedited->locallab.rewei = rewei->getEditedState (); + pedited->locallab.transit = transit->getEditedState (); + pedited->locallab.enabled = !get_inconsistent(); + pedited->locallab.avoid = !avoid->get_inconsistent(); + pedited->locallab.invers = !invers->get_inconsistent(); + pedited->locallab.curvactiv = !curvactiv->get_inconsistent(); + pedited->locallab.activlum = !activlum->get_inconsistent(); + pedited->locallab.inversret = !inversret->get_inconsistent(); + pedited->locallab.inversrad = !inversrad->get_inconsistent(); + pedited->locallab.inverssha = !inverssha->get_inconsistent(); + pedited->locallab.str = str->getEditedState (); + pedited->locallab.neigh = neigh->getEditedState (); + pedited->locallab.nbspot = nbspot->getEditedState (); + pedited->locallab.anbspot = anbspot->getEditedState (); + pedited->locallab.vart = vart->getEditedState (); + pedited->locallab.chrrt = chrrt->getEditedState (); + pedited->locallab.localTgaincurve = !cTgainshape->isUnChanged (); + pedited->locallab.localTgaincurverab = !cTgainshaperab->isUnChanged (); + pedited->locallab.llcurve = !llshape->isUnChanged (); + pedited->locallab.LHcurve = !LHshape->isUnChanged (); + pedited->locallab.expcolor = !expcolor->get_inconsistent(); + pedited->locallab.expblur = !expblur->get_inconsistent(); + pedited->locallab.exptonemap = !exptonemap->get_inconsistent(); + pedited->locallab.expreti = !expreti->get_inconsistent(); + pedited->locallab.expsharp = !expsharp->get_inconsistent(); + pedited->locallab.expcbdl = !expcbdl->get_inconsistent(); + pedited->locallab.expdenoi = !expdenoi->get_inconsistent(); + + for (int i = 0; i < 5; i++) { + pedited->locallab.mult[i] = multiplier[i]->getEditedState(); + } + + pedited->locallab.threshold = threshold->getEditedState(); + + } + + if (retinexMethod->get_active_row_number() == 0) { + pp->locallab.retinexMethod = "low"; + } else if (retinexMethod->get_active_row_number() == 1) { + pp->locallab.retinexMethod = "uni"; + } else if (retinexMethod->get_active_row_number() == 2) { + pp->locallab.retinexMethod = "high"; + } + + if (qualityMethod->get_active_row_number() == 0) { + pp->locallab.qualityMethod = "std"; + } else if (qualityMethod->get_active_row_number() == 1) { + pp->locallab.qualityMethod = "enh"; + } else if (qualityMethod->get_active_row_number() == 2) { + pp->locallab.qualityMethod = "enhden"; + } + + + if (Smethod->get_active_row_number() == 0) { + pp->locallab.Smethod = "IND"; + } else if (Smethod->get_active_row_number() == 1) { + pp->locallab.Smethod = "SYM"; + } else if (Smethod->get_active_row_number() == 2) { + pp->locallab.Smethod = "INDSL"; + } else if (Smethod->get_active_row_number() == 3) { + pp->locallab.Smethod = "SYMSL"; + } + + if (Smethod->get_active_row_number() == 1 || Smethod->get_active_row_number() == 3) { +// if(Smethod->get_active_row_number() == 0 || Smethod->get_active_row_number() == 1) { + pp->locallab.locX = locX->getValue(); + pp->locallab.locY = locY->getValue(); + + pp->locallab.locXL = pp->locallab.locX; + pp->locallab.locYT = pp->locallab.locY; + } + /* else if(Smethod->get_active_row_number()==2){ + pp->locallab.locXL=pp->locallab.locX; + pp->locallab.locYT=pp->locallab.locX; + pp->locallab.locY=pp->locallab.locX; + } + */ + else { + pp->locallab.locXL = locXL->getValue(); + pp->locallab.locX = locX->getValue(); + pp->locallab.locY = locY->getValue(); + pp->locallab.locYT = locYT->getValue(); + } +} + +void Locallab::curveChanged (CurveEditor* ce) +{ + + if (listener && getEnabled()) { + if (ce == cTgainshape) { + listener->panelChanged (EvlocallabCTgainCurve, M ("HISTORY_CUSTOMCURVE")); + int strval = retrab->getValue(); + //update MIP + retrab->setValue (strval + 1); + adjusterChanged (retrab, strval + 1); + usleep (10000); //to test + retrab->setValue (strval); + + adjusterChanged (retrab, strval); + } + + else if (ce == cTgainshaperab) { + listener->panelChanged (EvlocallabCTgainCurverab, M ("HISTORY_CUSTOMCURVE")); + } else if (ce == LHshape) { + listener->panelChanged (EvlocallabLHshape, M ("HISTORY_CUSTOMCURVE")); + int strval = retrab->getValue(); + //update MIP + retrab->setValue (strval + 1); + adjusterChanged (retrab, strval + 1); + usleep (10000); //to test + retrab->setValue (strval); + + adjusterChanged (retrab, strval); + + + } else if (ce == llshape) { + listener->panelChanged (Evlocallabllshape, M ("HISTORY_CUSTOMCURVE")); + int strval = retrab->getValue(); + //update MIP + retrab->setValue (strval + 1); + adjusterChanged (retrab, strval + 1); + usleep (10000); //to test + retrab->setValue (strval); + + adjusterChanged (retrab, strval); + + } + + } +} + +void Locallab::retinexMethodChanged() +{ + retrab->hide(); + LocalcurveEditorgainTrab->hide(); + // llCurveEditorG2->hide(); + + if (listener) { + listener->panelChanged (EvlocallabretinexMethod, retinexMethod->get_active_text ()); + } +} + +void Locallab::qualityMethodChanged() +{ + if (!batchMode) { + if (qualityMethod->get_active_row_number() == 0) { //STD + proxi->hide(); + thres->hide(); + } else {//enh + proxi->show(); + thres->show(); + } + } + + if (listener) { + listener->panelChanged (EvlocallabqualityMethod, qualityMethod->get_active_text ()); + } +} + +void Locallab::SmethodChanged () +{ + if (!batchMode) { + if (Smethod->get_active_row_number() == 0) { //IND 0 + locX->hide(); + locXL->hide(); + locY->hide(); + locYT->hide(); + centerX->hide(); + centerY->hide(); + } else if (Smethod->get_active_row_number() == 1) { // 1 SYM + locX->hide(); + locXL->hide(); + locY->hide(); + locYT->hide(); + centerX->hide(); + centerY->hide(); + + } else if (Smethod->get_active_row_number() == 2) { //2 SYM + locX->show(); + locXL->show(); + locY->show(); + locYT->show(); + centerX->show(); + centerY->show(); + + } else if (Smethod->get_active_row_number() == 3) { // 3 SYM + locX->show(); + locXL->hide(); + locY->show(); + locYT->hide(); + centerX->show(); + centerY->show(); + + } + + /* else if(Smethod->get_active_row_number()==2) { // LOC + locX->show(); + locXL->hide(); + locY->hide(); + locYT->hide(); + } */ + } + + if (listener && getEnabled()) { + if (Smethod->get_active_row_number() == 1 || Smethod->get_active_row_number() == 3) { + listener->panelChanged (EvlocallabSmet, Smethod->get_active_text ()); + locXL->setValue (locX->getValue()); + locYT->setValue (locY->getValue()); + } + // else if(Smethod->get_active_row_number()==2) { + // listener->panelChanged (EvlocallabSmet, Smethod->get_active_text ()); + // locXL->setValue (locX->getValue()); + // locYT->setValue (locX->getValue()); + // locY->setValue (locX->getValue()); + // } + else + + { + listener->panelChanged (EvlocallabSmet, Smethod->get_active_text ()); + + } + } +} +void Locallab::inversChanged () +{ + + if (batchMode) { + if (invers->get_inconsistent()) { + invers->set_inconsistent (false); + inversConn.block (true); + invers->set_active (false); + inversConn.block (false); + } else if (lastinvers) { + invers->set_inconsistent (true); + } + + lastinvers = invers->get_active (); + } + + if (invers->get_active ()) { + sensi->hide(); + llCurveEditorG->hide(); + } else { + sensi->show(); + llCurveEditorG->show(); + } + + if (listener) { + if (getEnabled()) { + listener->panelChanged (Evlocallabinvers, M ("GENERAL_ENABLED")); + } else { + listener->panelChanged (Evlocallabinvers, M ("GENERAL_DISABLED")); + } + } +} + +void Locallab::curvactivChanged () +{ + + if (batchMode) { + if (curvactiv->get_inconsistent()) { + curvactiv->set_inconsistent (false); + curvactivConn.block (true); + curvactiv->set_active (false); + curvactivConn.block (false); + } else if (lastcurvactiv) { + curvactiv->set_inconsistent (true); + } + + lastcurvactiv = curvactiv->get_active (); + } + + + if (listener) { + if (getEnabled()) { + listener->panelChanged (Evlocallabcurvactiv, M ("GENERAL_ENABLED")); + } else { + listener->panelChanged (Evlocallabcurvactiv, M ("GENERAL_DISABLED")); + } + } +} + +void Locallab::activlumChanged () +{ + + if (batchMode) { + if (activlum->get_inconsistent()) { + activlum->set_inconsistent (false); + activlumConn.block (true); + activlum->set_active (false); + activlumConn.block (false); + } else if (lastactivlum) { + activlum->set_inconsistent (true); + } + + lastactivlum = activlum->get_active (); + } + + + if (listener) { + + if (getEnabled()) { + listener->panelChanged (Evlocallabactivlum, M ("GENERAL_ENABLED")); + } else { + listener->panelChanged (Evlocallabactivlum, M ("GENERAL_DISABLED")); + } + } +} + +void Locallab::inversradChanged () +{ + + if (batchMode) { + if (inversrad->get_inconsistent()) { + inversrad->set_inconsistent (false); + inversradConn.block (true); + inversrad->set_active (false); + inversradConn.block (false); + } else if (lastinversrad) { + inversrad->set_inconsistent (true); + } + + lastinversrad = inversrad->get_active (); + } + + if (inversrad->get_active ()) { + sensibn->hide(); + } else { + sensibn->show(); + } + + + if (listener) { + if (getEnabled()) { + listener->panelChanged (Evlocallabinversrad, M ("GENERAL_ENABLED")); + } else { + listener->panelChanged (Evlocallabinversrad, M ("GENERAL_DISABLED")); + } + } +} + +void Locallab::inversshaChanged () +{ + + if (batchMode) { + if (inverssha->get_inconsistent()) { + inverssha->set_inconsistent (false); + inversshaConn.block (true); + inverssha->set_active (false); + inversshaConn.block (false); + } else if (lastinverssha) { + inverssha->set_inconsistent (true); + } + + lastinverssha = inverssha->get_active (); + } + + /* + if(inverssha->get_active ()) { + sensisha->hide(); + } else { + sensisha->show(); + } + */ + if (listener) { + if (getEnabled()) { + listener->panelChanged (Evlocallabinverssha, M ("GENERAL_ENABLED")); + } else { + listener->panelChanged (Evlocallabinverssha, M ("GENERAL_DISABLED")); + } + } +} + +void Locallab::inversretChanged () +{ + + if (batchMode) { + if (inversret->get_inconsistent()) { + inversret->set_inconsistent (false); + inversretConn.block (true); + inversret->set_active (false); + inversretConn.block (false); + } else if (lastinversret) { + inversret->set_inconsistent (true); + } + + lastinversret = inversret->get_active (); + } + + if (inversret->get_active ()) { + sensih->hide(); + } else { + sensih->show(); + } + + + if (listener) { + if (getEnabled()) { + listener->panelChanged (Evlocallabinversret, M ("GENERAL_ENABLED")); + } else { + listener->panelChanged (Evlocallabinversret, M ("GENERAL_DISABLED")); + } + } +} + + +void Locallab::setDefaults (const ProcParams * defParams, const ParamsEdited * pedited) +{ + degree->setDefault (defParams->locallab.degree); + locY->setDefault (defParams->locallab.locY); + locX->setDefault (defParams->locallab.locX); + locYT->setDefault (defParams->locallab.locYT); + locXL->setDefault (defParams->locallab.locXL); + centerX->setDefault (defParams->locallab.centerX); + centerY->setDefault (defParams->locallab.centerY); + circrad->setDefault (defParams->locallab.circrad); + thres->setDefault (defParams->locallab.thres); + proxi->setDefault (defParams->locallab.proxi); + lightness->setDefault (defParams->locallab.lightness); + contrast->setDefault (defParams->locallab.contrast); + chroma->setDefault (defParams->locallab.chroma); + noiselumf->setDefault (defParams->locallab.noiselumf); + noiselumc->setDefault (defParams->locallab.noiselumc); + noisechrof->setDefault (defParams->locallab.noisechrof); + noisechroc->setDefault (defParams->locallab.noisechroc); + sharradius->setDefault (defParams->locallab.sharradius); + sharamount->setDefault (defParams->locallab.sharamount); + shardamping->setDefault (defParams->locallab.shardamping); + shariter->setDefault (defParams->locallab.shariter); + sensisha->setDefault (defParams->locallab.sensisha); + sensi->setDefault (defParams->locallab.sensi); + sensih->setDefault (defParams->locallab.sensih); + retrab->setDefault (defParams->locallab.retrab); + sensicb->setDefault (defParams->locallab.sensicb); + sensibn->setDefault (defParams->locallab.sensibn); + sensitm->setDefault (defParams->locallab.sensitm); + transit->setDefault (defParams->locallab.transit); + radius->setDefault (defParams->locallab.radius); + strength->setDefault (defParams->locallab.strength); + stren->setDefault (defParams->locallab.stren); + gamma->setDefault (defParams->locallab.gamma); + estop->setDefault (defParams->locallab.estop); + gamma->setDefault (defParams->locallab.gamma); + scaltm->setDefault (defParams->locallab.scaltm); + rewei->setDefault (defParams->locallab.rewei); + neigh->setDefault (defParams->locallab.neigh); + nbspot->setDefault (defParams->locallab.nbspot); + anbspot->setDefault (defParams->locallab.anbspot); + vart->setDefault (defParams->locallab.vart); + chrrt->setDefault (defParams->locallab.chrrt); + + for (int i = 0; i < 5; i++) { + multiplier[i]->setDefault (defParams->locallab.mult[i]); + } + + threshold->setDefault (defParams->locallab.threshold); + + + if (pedited) { + degree->setDefaultEditedState (pedited->locallab.degree ? Edited : UnEdited); + locY->setDefaultEditedState (pedited->locallab.locY ? Edited : UnEdited); + locX->setDefaultEditedState (pedited->locallab.locX ? Edited : UnEdited); + locYT->setDefaultEditedState (pedited->locallab.locYT ? Edited : UnEdited); + locXL->setDefaultEditedState (pedited->locallab.locXL ? Edited : UnEdited); + centerX->setDefaultEditedState (pedited->locallab.centerX ? Edited : UnEdited); + centerY->setDefaultEditedState (pedited->locallab.centerY ? Edited : UnEdited); + circrad->setDefaultEditedState (pedited->locallab.circrad ? Edited : UnEdited); + thres->setDefaultEditedState (pedited->locallab.thres ? Edited : UnEdited); + proxi->setDefaultEditedState (pedited->locallab.proxi ? Edited : UnEdited); + lightness->setDefaultEditedState (pedited->locallab.lightness ? Edited : UnEdited); + contrast->setDefaultEditedState (pedited->locallab.contrast ? Edited : UnEdited); + chroma->setDefaultEditedState (pedited->locallab.chroma ? Edited : UnEdited); + noiselumf->setDefaultEditedState (pedited->locallab.noiselumf ? Edited : UnEdited); + noiselumc->setDefaultEditedState (pedited->locallab.noiselumc ? Edited : UnEdited); + noisechrof->setDefaultEditedState (pedited->locallab.noisechrof ? Edited : UnEdited); + noisechroc->setDefaultEditedState (pedited->locallab.noisechroc ? Edited : UnEdited); + sharradius->setDefaultEditedState (pedited->locallab.sharradius ? Edited : UnEdited); + sharamount->setDefaultEditedState (pedited->locallab.sharamount ? Edited : UnEdited); + shardamping->setDefaultEditedState (pedited->locallab.shardamping ? Edited : UnEdited); + shariter->setDefaultEditedState (pedited->locallab.shariter ? Edited : UnEdited); + sensisha->setDefaultEditedState (pedited->locallab.sensisha ? Edited : UnEdited); + sensi->setDefaultEditedState (pedited->locallab.sensi ? Edited : UnEdited); + sensih->setDefaultEditedState (pedited->locallab.sensih ? Edited : UnEdited); + retrab->setDefaultEditedState (pedited->locallab.retrab ? Edited : UnEdited); + sensicb->setDefaultEditedState (pedited->locallab.sensicb ? Edited : UnEdited); + sensibn->setDefaultEditedState (pedited->locallab.sensibn ? Edited : UnEdited); + sensitm->setDefaultEditedState (pedited->locallab.sensitm ? Edited : UnEdited); + radius->setDefaultEditedState (pedited->locallab.radius ? Edited : UnEdited); + strength->setDefaultEditedState (pedited->locallab.strength ? Edited : UnEdited); + stren->setDefaultEditedState (pedited->locallab.stren ? Edited : UnEdited); + gamma->setDefaultEditedState (pedited->locallab.gamma ? Edited : UnEdited); + estop->setDefaultEditedState (pedited->locallab.estop ? Edited : UnEdited); + scaltm->setDefaultEditedState (pedited->locallab.scaltm ? Edited : UnEdited); + rewei->setDefaultEditedState (pedited->locallab.rewei ? Edited : UnEdited); + transit->setDefaultEditedState (pedited->locallab.transit ? Edited : UnEdited); + str->setDefaultEditedState (pedited->locallab.str ? Edited : UnEdited); + neigh->setDefaultEditedState (pedited->locallab.neigh ? Edited : UnEdited); + nbspot->setDefaultEditedState (pedited->locallab.nbspot ? Edited : UnEdited); + anbspot->setDefaultEditedState (pedited->locallab.anbspot ? Edited : UnEdited); + vart->setDefaultEditedState (pedited->locallab.vart ? Edited : UnEdited); + chrrt->setDefaultEditedState (pedited->locallab.chrrt ? Edited : UnEdited); + + for (int i = 0; i < 5; i++) { + multiplier[i]->setDefaultEditedState (pedited->locallab.mult[i] ? Edited : UnEdited); + } + + threshold->setDefaultEditedState (pedited->locallab.threshold ? Edited : UnEdited); + + } else { + degree->setDefaultEditedState (Irrelevant); + locY->setDefaultEditedState (Irrelevant); + locX->setDefaultEditedState (Irrelevant); + locYT->setDefaultEditedState (Irrelevant); + locXL->setDefaultEditedState (Irrelevant); + centerX->setDefaultEditedState (Irrelevant); + centerY->setDefaultEditedState (Irrelevant); + circrad->setDefaultEditedState (Irrelevant); + thres->setDefaultEditedState (Irrelevant); + proxi->setDefaultEditedState (Irrelevant); + lightness->setDefaultEditedState (Irrelevant); + contrast->setDefaultEditedState (Irrelevant); + chroma->setDefaultEditedState (Irrelevant); + noiselumf->setDefaultEditedState (Irrelevant); + noiselumc->setDefaultEditedState (Irrelevant); + noisechrof->setDefaultEditedState (Irrelevant); + noisechroc->setDefaultEditedState (Irrelevant); + sharradius->setDefaultEditedState (Irrelevant); + sharamount->setDefaultEditedState (Irrelevant); + shardamping->setDefaultEditedState (Irrelevant); + shariter->setDefaultEditedState (Irrelevant); + sensisha->setDefaultEditedState (Irrelevant); + sensi->setDefaultEditedState (Irrelevant); + sensih->setDefaultEditedState (Irrelevant); + retrab->setDefaultEditedState (Irrelevant); + sensicb->setDefaultEditedState (Irrelevant); + sensibn->setDefaultEditedState (Irrelevant); + sensitm->setDefaultEditedState (Irrelevant); + radius->setDefaultEditedState (Irrelevant); + strength->setDefaultEditedState (Irrelevant); + stren->setDefaultEditedState (Irrelevant); + gamma->setDefaultEditedState (Irrelevant); + estop->setDefaultEditedState (Irrelevant); + scaltm->setDefaultEditedState (Irrelevant); + rewei->setDefaultEditedState (Irrelevant); + transit->setDefaultEditedState (Irrelevant); + str->setDefaultEditedState (Irrelevant); + neigh->setDefaultEditedState (Irrelevant); + nbspot->setDefaultEditedState (Irrelevant); + anbspot->setDefaultEditedState (Irrelevant); + vart->setDefaultEditedState (Irrelevant); + chrrt->setDefaultEditedState (Irrelevant); + + for (int i = 0; i < 5; i++) { + multiplier[i]->setDefaultEditedState (Irrelevant); + } + + threshold->setDefaultEditedState (Irrelevant); + + + } +} + +void Locallab::adjusterChanged (Adjuster * a, double newval) +{ + + updateGeometry (int (centerX->getValue()), int (centerY->getValue()), int (circrad->getValue()), (int)locY->getValue(), degree->getValue(), (int)locX->getValue(), (int)locYT->getValue(), (int)locXL->getValue()); + anbspot->hide(); + + if (listener && getEnabled()) { + if (a == degree) { + listener->panelChanged (EvlocallabDegree, degree->getTextValue()); + } else if (a == locY) { + if (Smethod->get_active_row_number() == 0 || Smethod->get_active_row_number() == 2) { // 0 2 + listener->panelChanged (EvlocallablocY, locY->getTextValue()); + } + /* else if(Smethod->get_active_row_number()==2) { + listener->panelChanged (EvlocallablocY, locY->getTextValue()); + locXL->setValue (locX->getValue()); + locY->setValue (locX->getValue()); + locYT->setValue (locX->getValue()); + }*/ + else if (Smethod->get_active_row_number() == 1 || Smethod->get_active_row_number() == 3) { + listener->panelChanged (EvlocallablocY, locY->getTextValue()); + locYT->setValue (locY->getValue()); + } + } else if (a == locX) { + //listener->panelChanged (EvlocallablocX, locX->getTextValue()); + if (Smethod->get_active_row_number() == 0 || Smethod->get_active_row_number() == 2) { + listener->panelChanged (EvlocallablocX, locX->getTextValue()); + } + /* else if(Smethod->get_active_row_number()==2) { + listener->panelChanged (EvlocallablocX, locX->getTextValue()); + locXL->setValue (locX->getValue()); + locY->setValue (locX->getValue()); + locYT->setValue (locX->getValue()); + }*/ + else if (Smethod->get_active_row_number() == 1 || Smethod->get_active_row_number() == 3) { + listener->panelChanged (EvlocallablocX, locX->getTextValue()); + locXL->setValue (locX->getValue()); + } + } else if (a == locYT) { + if (Smethod->get_active_row_number() == 0 || Smethod->get_active_row_number() == 2) { + listener->panelChanged (EvlocallablocYT, locYT->getTextValue()); + } + /* else if(Smethod->get_active_row_number()==2) { + listener->panelChanged (EvlocallablocYT, locYT->getTextValue()); + locXL->setValue (locX->getValue()); + locY->setValue (locX->getValue()); + locYT->setValue (locX->getValue()); + }*/ + else if (Smethod->get_active_row_number() == 1 || Smethod->get_active_row_number() == 3) { + listener->panelChanged (EvlocallablocYT, locYT->getTextValue()); + locYT->setValue (locY->getValue()); + } + } else if (a == locXL) { + if (Smethod->get_active_row_number() == 0 || Smethod->get_active_row_number() == 2) { + listener->panelChanged (EvlocallablocXL, locXL->getTextValue()); + listener->panelChanged (EvlocallablocXL, locXL->getTextValue()); + } + /* else if(Smethod->get_active_row_number()==2) { + listener->panelChanged (EvlocallablocXL, locXL->getTextValue()); + locXL->setValue (locX->getValue()); + locY->setValue (locX->getValue()); + locYT->setValue (locX->getValue()); + }*/ + else if (Smethod->get_active_row_number() == 1 || Smethod->get_active_row_number() == 3) { + listener->panelChanged (EvlocallablocXL, locXL->getTextValue()); + locXL->setValue (locX->getValue()); + } + } else if (a == lightness) { + listener->panelChanged (Evlocallablightness, lightness->getTextValue()); + } else if (a == contrast) { + listener->panelChanged (Evlocallabcontrast, contrast->getTextValue()); + } else if (a == chroma) { + listener->panelChanged (Evlocallabchroma, chroma->getTextValue()); + } else if (a == noiselumf) { + listener->panelChanged (Evlocallabnoiselumf, noiselumf->getTextValue()); + } else if (a == noiselumc) { + listener->panelChanged (Evlocallabnoiselumc, noiselumc->getTextValue()); + } else if (a == noisechrof) { + listener->panelChanged (Evlocallabnoisechrof, noisechrof->getTextValue()); + } else if (a == noisechroc) { + listener->panelChanged (Evlocallabnoisechroc, noisechroc->getTextValue()); + } else if (a == sharradius) { + listener->panelChanged (Evlocallabsharradius, sharradius->getTextValue()); + } else if (a == sharamount) { + listener->panelChanged (Evlocallabsharamount, sharamount->getTextValue()); + } else if (a == shardamping) { + listener->panelChanged (Evlocallabshardamping, shardamping->getTextValue()); + } else if (a == shariter) { + listener->panelChanged (Evlocallabshariter, shariter->getTextValue()); + } else if (a == sensisha) { + listener->panelChanged (Evlocallabsensis, sensisha->getTextValue()); + } else if (a == sensi) { + listener->panelChanged (Evlocallabsensi, sensi->getTextValue()); + } else if (a == sensih) { + listener->panelChanged (Evlocallabsensih, sensih->getTextValue()); + } else if (a == retrab) { + listener->panelChanged (Evlocallabretrab, retrab->getTextValue()); + } else if (a == radius) { + listener->panelChanged (Evlocallabradius, radius->getTextValue()); + } else if (a == strength) { + listener->panelChanged (Evlocallabstrength, strength->getTextValue()); + } else if (a == stren) { + listener->panelChanged (Evlocallabstren, stren->getTextValue()); + } else if (a == gamma) { + listener->panelChanged (Evlocallabgamma, gamma->getTextValue()); + } else if (a == estop) { + listener->panelChanged (Evlocallabestop, estop->getTextValue()); + } else if (a == scaltm) { + listener->panelChanged (Evlocallabscaltm, scaltm->getTextValue()); + } else if (a == rewei) { + listener->panelChanged (Evlocallabrewei, rewei->getTextValue()); + } else if (a == sensitm) { + listener->panelChanged (Evlocallabsensitm, sensitm->getTextValue()); + } else if (a == transit) { + listener->panelChanged (Evlocallabtransit, transit->getTextValue()); + } else if (a == str) { + listener->panelChanged (Evlocallabstr, str->getTextValue()); + } else if (a == neigh) { + listener->panelChanged (Evlocallabneigh, neigh->getTextValue()); + } else if (a == nbspot) { + listener->panelChanged (Evlocallabnbspot, nbspot->getTextValue()); + } else if (a == anbspot) { + listener->panelChanged (Evlocallabanbspot, anbspot->getTextValue()); + } else if (a == vart) { + listener->panelChanged (Evlocallabvart, vart->getTextValue()); + } else if (a == chrrt) { + listener->panelChanged (Evlocallabchrrt, chrrt->getTextValue()); + } else if (a == circrad) { + listener->panelChanged (Evlocallabcircrad, circrad->getTextValue()); + } else if (a == thres) { + listener->panelChanged (Evlocallabthres, thres->getTextValue()); + } else if (a == threshold) { + listener->panelChanged (EvlocallabThresho, threshold->getTextValue()); + } else if (a == sensicb) { + listener->panelChanged (Evlocallabsensicb, sensicb->getTextValue()); + } else if (a == sensibn) { + listener->panelChanged (Evlocallabsensibn, sensibn->getTextValue()); + } else if (a == proxi) { + listener->panelChanged (Evlocallabproxi, proxi->getTextValue()); + } else if (a == centerX || a == centerY) { + listener->panelChanged (EvlocallabCenter, Glib::ustring::compose ("X=%1\nY=%2", centerX->getTextValue(), centerY->getTextValue())); + } else { + listener->panelChanged (EvlocallabEqualizer, + Glib::ustring::compose ("%1, %2, %3, %4, %5", + Glib::ustring::format (std::fixed, std::setprecision (0), multiplier[0]->getValue()), + Glib::ustring::format (std::fixed, std::setprecision (0), multiplier[1]->getValue()), + Glib::ustring::format (std::fixed, std::setprecision (0), multiplier[2]->getValue()), + Glib::ustring::format (std::fixed, std::setprecision (0), multiplier[3]->getValue()), + Glib::ustring::format (std::fixed, std::setprecision (0), multiplier[4]->getValue())) + ); + + } + } +} + +void Locallab::enabledChanged () +{ + + if (listener) { + if (get_inconsistent()) { + listener->panelChanged (EvlocallabEnabled, M ("GENERAL_UNCHANGED")); + } else if (getEnabled()) { + listener->panelChanged (EvlocallabEnabled, M ("GENERAL_ENABLED")); + } else { + listener->panelChanged (EvlocallabEnabled, M ("GENERAL_DISABLED")); + } + } +} + +void Locallab::avoidChanged () +{ + + if (batchMode) { + if (avoid->get_inconsistent()) { + avoid->set_inconsistent (false); + avoidConn.block (true); + avoid->set_active (false); + avoidConn.block (false); + } else if (lastavoid) { + avoid->set_inconsistent (true); + } + + lastavoid = avoid->get_active (); + } + + if (listener) { + if (getEnabled()) { + listener->panelChanged (Evlocallabavoid, M ("GENERAL_ENABLED")); + } else { + listener->panelChanged (Evlocallabavoid, M ("GENERAL_DISABLED")); + } + } +} + +void Locallab::setAdjusterBehavior (bool degreeadd, bool locYadd, bool locXadd, bool locYTadd, bool locXLadd, bool centeradd, bool lightnessadd, bool contrastadd, bool chromaadd, bool sensiadd, bool transitadd, bool radiusadd, bool strengthadd) +{ + degree->setAddMode (degreeadd); + locY->setAddMode (locYadd); + locX->setAddMode (locXadd); + locYT->setAddMode (locYTadd); + locXL->setAddMode (locXLadd); + centerX->setAddMode (centeradd); + centerY->setAddMode (centeradd); + lightness->setAddMode (lightnessadd); + contrast->setAddMode (contrastadd); + chroma->setAddMode (chromaadd); + sensi->setAddMode (sensiadd); + transit->setAddMode (transitadd); + radius->setAddMode (radiusadd); + strength->setAddMode (strengthadd); + +} + +void Locallab::trimValues (rtengine::procparams::ProcParams * pp) +{ + degree->trimValue (pp->locallab.degree); + locY->trimValue (pp->locallab.locY); + locX->trimValue (pp->locallab.locX); + locYT->trimValue (pp->locallab.locYT); + locXL->trimValue (pp->locallab.locXL); + centerX->trimValue (pp->locallab.centerX); + centerY->trimValue (pp->locallab.centerY); + circrad->trimValue (pp->locallab.circrad); + thres->trimValue (pp->locallab.thres); + proxi->trimValue (pp->locallab.proxi); + lightness->trimValue (pp->locallab.lightness); + contrast->trimValue (pp->locallab.contrast); + chroma->trimValue (pp->locallab.chroma); + noiselumf->trimValue (pp->locallab.noiselumf); + noiselumc->trimValue (pp->locallab.noiselumc); + noisechrof->trimValue (pp->locallab.noisechrof); + noisechroc->trimValue (pp->locallab.noisechroc); + sharradius->trimValue (pp->locallab.sharradius); + sharamount->trimValue (pp->locallab.sharamount); + shardamping->trimValue (pp->locallab.shardamping); + shariter->trimValue (pp->locallab.shariter); + sensisha->trimValue (pp->locallab.sensisha); + sensi->trimValue (pp->locallab.sensi); + sensih->trimValue (pp->locallab.sensih); + retrab->trimValue (pp->locallab.retrab); + sensicb->trimValue (pp->locallab.sensicb); + sensibn->trimValue (pp->locallab.sensibn); + sensitm->trimValue (pp->locallab.sensitm); + radius->trimValue (pp->locallab.radius); + strength->trimValue (pp->locallab.strength); + stren->trimValue (pp->locallab.stren); + gamma->trimValue (pp->locallab.gamma); + estop->trimValue (pp->locallab.estop); + scaltm->trimValue (pp->locallab.scaltm); + rewei->trimValue (pp->locallab.rewei); + transit->trimValue (pp->locallab.transit); + str->trimValue (pp->locallab.str); + neigh->trimValue (pp->locallab.neigh); + nbspot->trimValue (pp->locallab.nbspot); + anbspot->trimValue (pp->locallab.anbspot); + vart->trimValue (pp->locallab.vart); + chrrt->trimValue (pp->locallab.chrrt); + + for (int i = 0; i < 5; i++) { + multiplier[i]->trimValue (pp->locallab.mult[i]); + } + + threshold->trimValue (pp->locallab.threshold); + +} + +void Locallab::setBatchMode (bool batchMode) +{ + removeIfThere (this, edit, false); + ToolPanel::setBatchMode (batchMode); + degree->showEditedCB (); + locY->showEditedCB (); + locX->showEditedCB (); + locYT->showEditedCB (); + locXL->showEditedCB (); + centerX->showEditedCB (); + centerY->showEditedCB (); + circrad->showEditedCB (); + thres->showEditedCB (); + proxi->showEditedCB (); + lightness->showEditedCB (); + contrast->showEditedCB (); + chroma->showEditedCB (); + noiselumf->showEditedCB (); + noiselumc->showEditedCB (); + noisechroc->showEditedCB (); + noiselumf->showEditedCB (); + sharradius->showEditedCB (); + sharamount->showEditedCB (); + shardamping->showEditedCB (); + shariter->showEditedCB (); + sensisha->showEditedCB (); + sensi->showEditedCB (); + sensih->showEditedCB (); + retrab->showEditedCB (); + sensicb->showEditedCB (); + sensibn->showEditedCB (); + sensitm->showEditedCB (); + radius->showEditedCB (); + strength->showEditedCB (); + stren->showEditedCB (); + gamma->showEditedCB (); + estop->showEditedCB (); + scaltm->showEditedCB (); + rewei->showEditedCB (); + transit->showEditedCB (); + Smethod->append (M ("GENERAL_UNCHANGED")); + str->showEditedCB (); + neigh->showEditedCB (); + nbspot->showEditedCB (); + anbspot->showEditedCB (); + vart->showEditedCB (); + LocalcurveEditorgainT->setBatchMode (batchMode); + LocalcurveEditorgainTrab->setBatchMode (batchMode); + llCurveEditorG->setBatchMode (batchMode); +// llCurveEditorG2->setBatchMode (batchMode); + chrrt->showEditedCB (); + + for (int i = 0; i < 5; i++) { + multiplier[i]->showEditedCB(); + } + + threshold->showEditedCB(); + +} + +void Locallab::setEditProvider (EditDataProvider * provider) +{ + EditSubscriber::setEditProvider (provider); + cTgainshape->setEditProvider (provider); + cTgainshaperab->setEditProvider (provider); + +} + +void Locallab::editToggled () +{ + if (edit->get_active()) { + subscribe(); + } else { + unsubscribe(); + } +} + +void Locallab::colorForValue (double valX, double valY, enum ColorCaller::ElemType elemType, int callerId, ColorCaller *caller) +{ + + float R, G, B; + + if (elemType == ColorCaller::CCET_VERTICAL_BAR) { + valY = 0.5; + } + + if (callerId == 1) { // ch - main curve + + Color::hsv2rgb01 (float (valX), float (valY), 0.5f, R, G, B); + } else if (callerId == 2) { // cc - bottom bar + + float value = (1.f - 0.7f) * float (valX) + 0.7f; + // whole hue range + // Y axis / from 0.15 up to 0.75 (arbitrary values; was 0.45 before) + Color::hsv2rgb01 (float (valY), float (valX), value, R, G, B); + } else if (callerId == 3) { // lc - bottom bar + + float value = (1.f - 0.7f) * float (valX) + 0.7f; + // Y axis / from 0.15 up to 0.75 (arbitrary values; was 0.45 before) + Color::hsv2rgb01 (float (valY), float (valX), value, R, G, B); + } else if (callerId == 4) { // LH - bottom bar + Color::hsv2rgb01 (float (valX), 0.5f, float (valY), R, G, B); + } else if (callerId == 5) { // HH - bottom bar + float h = float ((valY - 0.5) * 0.3 + valX); + + if (h > 1.0f) { + h -= 1.0f; + } else if (h < 0.0f) { + h += 1.0f; + } + + Color::hsv2rgb01 (h, 0.5f, 0.5f, R, G, B); + } + + caller->ccRed = double (R); + caller->ccGreen = double (G); + caller->ccBlue = double (B); +} + + + +CursorShape Locallab::getCursor (int objectID) +{ + switch (objectID) { + case (2): { + int angle = degree->getIntValue(); + + if (angle < -135 || (angle >= -45 && angle <= 45) || angle > 135) { + return CSMove1DV; + } + + return CSMove1DH; + } + + case (3): { + int angle = degree->getIntValue(); + + if (angle < -135 || (angle >= -45 && angle <= 45) || angle > 135) { + return CSMove1DV; + } + + return CSMove1DH; + } + + case (0): { + int angle = degree->getIntValue(); + + if (angle < -135 || (angle >= -45 && angle <= 45) || angle > 135) { + return CSMove1DH; + } + + return CSMove1DV; + } + + case (1): { + int angle = degree->getIntValue(); + + if (angle < -135 || (angle >= -45 && angle <= 45) || angle > 135) { + return CSMove1DH; + } + + return CSMove1DV; + } + + case (4): + return CSMove2D; + + default: + return CSOpenHand; + } +} + +bool Locallab::mouseOver (int modifierKey) +{ + EditDataProvider* editProvider = getEditProvider(); + + if (editProvider && editProvider->object != lastObject) { + if (lastObject > -1) { + if (lastObject == 2 || lastObject == 3) { + EditSubscriber::visibleGeometry.at (2)->state = Geometry::NORMAL; + EditSubscriber::visibleGeometry.at (3)->state = Geometry::NORMAL; + } else if (lastObject == 0 || lastObject == 1) { + EditSubscriber::visibleGeometry.at (0)->state = Geometry::NORMAL; + EditSubscriber::visibleGeometry.at (1)->state = Geometry::NORMAL; + } + + else { + EditSubscriber::visibleGeometry.at (lastObject)->state = Geometry::NORMAL; + } + } + + if (editProvider->object > -1) { + if (editProvider->object == 2 || editProvider->object == 3) { + EditSubscriber::visibleGeometry.at (2)->state = Geometry::PRELIGHT; + EditSubscriber::visibleGeometry.at (3)->state = Geometry::PRELIGHT; + } else if (editProvider->object == 0 || editProvider->object == 1) { + EditSubscriber::visibleGeometry.at (0)->state = Geometry::PRELIGHT; + EditSubscriber::visibleGeometry.at (1)->state = Geometry::PRELIGHT; + } + + else { + EditSubscriber::visibleGeometry.at (editProvider->object)->state = Geometry::PRELIGHT; + } + } + + lastObject = editProvider->object; + return true; + } + + return false; +} + +bool Locallab::button1Pressed (int modifierKey) +{ + if (lastObject < 0) { + return false; + } + + EditDataProvider *provider = getEditProvider(); + + if (! (modifierKey & GDK_CONTROL_MASK)) { + // button press is valid (no modifier key) + PolarCoord pCoord; + // EditDataProvider *provider = getEditProvider(); + int imW, imH; + provider->getImageSize (imW, imH); + double halfSizeW = imW / 2.; + double halfSizeH = imH / 2.; + draggedCenter.set (int (halfSizeW + halfSizeW * (centerX->getValue() / 1000.)), int (halfSizeH + halfSizeH * (centerY->getValue() / 1000.))); + + // trick to get the correct angle (clockwise/counter-clockwise) + rtengine::Coord p1 = draggedCenter; + rtengine::Coord p2 = provider->posImage; + int p = p1.y; + p1.y = p2.y; + p2.y = p; + pCoord = p2 - p1; + draggedPointOldAngle = pCoord.angle; + draggedPointAdjusterAngle = degree->getValue(); + + if (Smethod->get_active_row_number() == 0 || Smethod->get_active_row_number() == 2) { + if (lastObject == 2) { + PolarCoord draggedPoint; + rtengine::Coord currPos; + currPos = provider->posImage; + rtengine::Coord centerPos = draggedCenter; + double verti = double (imH); + int p = centerPos.y; + centerPos.y = currPos.y; + currPos.y = p; + draggedPoint = currPos - centerPos; + // compute the projected value of the dragged point + draggedlocYOffset = draggedPoint.radius * sin ((draggedPoint.angle - degree->getValue()) / 180.*M_PI); + + if (lastObject == 2) { + //draggedlocYOffset = -draggedlocYOffset; + draggedlocYOffset -= (locYT->getValue() / 2000. * verti); + } + } else if (lastObject == 3) { + // Dragging a line to change the angle + PolarCoord draggedPoint; + rtengine::Coord currPos; + currPos = provider->posImage; + rtengine::Coord centerPos = draggedCenter; + + double verti = double (imH); + + // trick to get the correct angle (clockwise/counter-clockwise) + int p = centerPos.y; + centerPos.y = currPos.y; + currPos.y = p; + draggedPoint = currPos - centerPos; + + // draggedPoint.setFromCartesian(centerPos, currPos); + // compute the projected value of the dragged point + draggedlocYOffset = draggedPoint.radius * sin ((draggedPoint.angle - degree->getValue()) / 180.*M_PI); + + if (lastObject == 3) { + draggedlocYOffset = -draggedlocYOffset; + draggedlocYOffset -= (locY->getValue() / 2000. * verti); + } + + } + + } else if (Smethod->get_active_row_number() == 1 || Smethod->get_active_row_number() == 3) { + if (lastObject == 2 || lastObject == 3) { + // Dragging a line to change the angle + PolarCoord draggedPoint; + rtengine::Coord currPos; + currPos = provider->posImage; + rtengine::Coord centerPos = draggedCenter; + double verti = double (imH); + // trick to get the correct angle (clockwise/counter-clockwise) + int p = centerPos.y; + centerPos.y = currPos.y; + currPos.y = p; + draggedPoint = currPos - centerPos; + + // draggedPoint.setFromCartesian(centerPos, currPos); + // compute the projected value of the dragged point + draggedlocYOffset = draggedPoint.radius * sin ((draggedPoint.angle - degree->getValue()) / 180.*M_PI); + + if (lastObject == 3) { + draggedlocYOffset = -draggedlocYOffset; + } + + draggedlocYOffset -= (locY->getValue() / 2000. * verti); + } + } + + if (Smethod->get_active_row_number() == 0 || Smethod->get_active_row_number() == 2) { + if (lastObject == 0) { + // Dragging a line to change the angle + PolarCoord draggedPoint; + rtengine::Coord currPos; + currPos = provider->posImage; + rtengine::Coord centerPos = draggedCenter; + + double horiz = double (imW); + + // trick to get the correct angle (clockwise/counter-clockwise) + int p = centerPos.y; + centerPos.y = currPos.y; + currPos.y = p; + draggedPoint = currPos - centerPos; + + // draggedPoint.setFromCartesian(centerPos, currPos); + // compute the projected value of the dragged point + printf ("rad=%f ang=%f\n", draggedPoint.radius, draggedPoint.angle - degree->getValue()); + draggedlocXOffset = draggedPoint.radius * sin ((draggedPoint.angle - degree->getValue() + 90.) / 180.*M_PI); + // if (lastObject==1) + // draggedlocXOffset = -draggedlocXOffset;//- + draggedlocXOffset -= (locX->getValue() / 2000. * horiz); + } else if (lastObject == 1) { + // Dragging a line to change the angle + PolarCoord draggedPoint; + rtengine::Coord currPos; + currPos = provider->posImage; + rtengine::Coord centerPos = draggedCenter; + double horiz = double (imW); + int p = centerPos.y; + centerPos.y = currPos.y; + currPos.y = p; + draggedPoint = currPos - centerPos; + + // draggedPoint.setFromCartesian(centerPos, currPos); + printf ("rad=%f ang=%f\n", draggedPoint.radius, draggedPoint.angle - degree->getValue()); + draggedlocXOffset = draggedPoint.radius * sin ((draggedPoint.angle - degree->getValue() + 90.) / 180.*M_PI); + + if (lastObject == 1) { + draggedlocXOffset = -draggedlocXOffset; //- + } + + draggedlocXOffset -= (locXL->getValue() / 2000. * horiz); + } + + } else if (Smethod->get_active_row_number() == 1 || Smethod->get_active_row_number() == 3) { + + if (lastObject == 0 || lastObject == 1) { + PolarCoord draggedPoint; + rtengine::Coord currPos; + currPos = provider->posImage; + rtengine::Coord centerPos = draggedCenter; + double horiz = double (imW); + int p = centerPos.y; + centerPos.y = currPos.y; + currPos.y = p; + draggedPoint = currPos - centerPos; + + // draggedPoint.setFromCartesian(centerPos, currPos); + printf ("rad=%f ang=%f\n", draggedPoint.radius, draggedPoint.angle - degree->getValue()); + draggedlocXOffset = draggedPoint.radius * sin ((draggedPoint.angle - degree->getValue() + 90.) / 180.*M_PI); + + if (lastObject == 1) { + draggedlocXOffset = -draggedlocXOffset; //- + } + + draggedlocXOffset -= (locX->getValue() / 2000. * horiz); + } + } + + /* else if(Smethod->get_active_row_number()==2) { + if (lastObject==0 || lastObject==1 || lastObject==2 || lastObject==3) { + if (lastObject==2 || lastObject==3) { + // Dragging a line to change the angle + PolarCoord draggedPoint; + Coord currPos; + currPos = provider->posImage; + Coord centerPos = draggedCenter; + double verti = double(imH); + // trick to get the correct angle (clockwise/counter-clockwise) + int p = centerPos.y; + centerPos.y = currPos.y; + currPos.y = p; + + draggedPoint.setFromCartesian(centerPos, currPos); + // compute the projected value of the dragged point + draggedlocYOffset = draggedPoint.radius * sin((draggedPoint.angle-degree->getValue())/180.*M_PI); + if (lastObject==3) + draggedlocYOffset = -draggedlocYOffset; + draggedlocYOffset -= (locY->getValue() / 200. * verti); + } + + + if (lastObject==0 || lastObject==1) { + PolarCoord draggedPoint; + Coord currPos; + currPos = provider->posImage; + Coord centerPos = draggedCenter; + double horiz = double(imW); + int p = centerPos.y; + centerPos.y = currPos.y; + currPos.y = p; + draggedPoint.setFromCartesian(centerPos, currPos); + printf("rad=%f ang=%f\n",draggedPoint.radius,draggedPoint.angle-degree->getValue()); + draggedlocXOffset = draggedPoint.radius * sin((draggedPoint.angle-degree->getValue()+90.)/180.*M_PI); + if (lastObject==1) + draggedlocXOffset = -draggedlocXOffset;//- + draggedlocXOffset -= (locX->getValue() / 200. * horiz); + } + + } + } + */ + // EditSubscriber::dragging = true; + EditSubscriber::action = ES_ACTION_DRAGGING; + return false; + } else { + // this will let this class ignore further drag events + if (lastObject > -1) { // should theoretically always be true + if (lastObject == 2 || lastObject == 3) { + EditSubscriber::visibleGeometry.at (2)->state = Geometry::NORMAL; + EditSubscriber::visibleGeometry.at (3)->state = Geometry::NORMAL; + } + + if (lastObject == 0 || lastObject == 1) { + EditSubscriber::visibleGeometry.at (0)->state = Geometry::NORMAL; + EditSubscriber::visibleGeometry.at (1)->state = Geometry::NORMAL; + } else { + EditSubscriber::visibleGeometry.at (lastObject)->state = Geometry::NORMAL; + } + } + + lastObject = -1; + return true; + } +} + +bool Locallab::button1Released() +{ + draggedPointOldAngle = -1000.; + EditSubscriber::action = ES_ACTION_NONE; + + return true; +} + +bool Locallab::drag1 (int modifierKey) +{ + // compute the polar coordinate of the mouse position + EditDataProvider *provider = getEditProvider(); + int imW, imH; + provider->getImageSize (imW, imH); + double halfSizeW = imW / 2.; + double halfSizeH = imH / 2.; + + if (Smethod->get_active_row_number() == 0 || Smethod->get_active_row_number() == 2) { + if (lastObject == 2) { + // Dragging the upper or lower locY bar + PolarCoord draggedPoint; + rtengine::Coord currPos; + currPos = provider->posImage + provider->deltaImage; + rtengine::Coord centerPos = draggedCenter; + double verti = double (imH); + int p = centerPos.y; + centerPos.y = currPos.y; + currPos.y = p; + draggedPoint = currPos - centerPos; + + // draggedPoint.setFromCartesian(centerPos, currPos); + double currDraggedlocYOffset = draggedPoint.radius * sin ((draggedPoint.angle - degree->getValue()) / 180.*M_PI); + + if (lastObject == 2) { + currDraggedlocYOffset -= draggedlocYOffset; + } + + //else if (lastObject==3) + // Dragging the lower locY bar + // currDraggedlocYOffset = -currDraggedlocYOffset + draggedlocYOffset; + currDraggedlocYOffset = currDraggedlocYOffset * 2000. / verti; + + if (int (currDraggedlocYOffset) != locYT->getIntValue()) { + locYT->setValue ((int (currDraggedlocYOffset))); + double centX, centY; + centX = centerX->getValue(); + centY = centerY->getValue(); + updateGeometry (centX, centY, circrad->getValue(), locY->getValue(), degree->getValue(), locX->getValue(), locYT->getValue(), locXL->getValue() ); + + if (listener) { + listener->panelChanged (EvlocallablocY, locYT->getTextValue()); + } + + return true; + } + } else if (lastObject == 3) { + // Dragging the upper or lower locY bar + PolarCoord draggedPoint; + rtengine::Coord currPos; + currPos = provider->posImage + provider->deltaImage; + rtengine::Coord centerPos = draggedCenter; + double verti = double (imH); + // trick to get the correct angle (clockwise/counter-clockwise) + int p = centerPos.y; + centerPos.y = currPos.y; + currPos.y = p; + draggedPoint = currPos - centerPos; + + // draggedPoint.setFromCartesian(centerPos, currPos); + double currDraggedlocYOffset = draggedPoint.radius * sin ((draggedPoint.angle - degree->getValue()) / 180.*M_PI); + + // if (lastObject==2) + // Dragging the upper locY bar + // currDraggedlocYOffset -= draggedlocYOffset; + // else + if (lastObject == 3) + // Dragging the lower locY bar + { + currDraggedlocYOffset = -currDraggedlocYOffset + draggedlocYOffset; + } + + currDraggedlocYOffset = currDraggedlocYOffset * 2000. / verti; + + if (int (currDraggedlocYOffset) != locY->getIntValue()) { + + locY->setValue ((int (currDraggedlocYOffset))); + double centX, centY; + centX = centerX->getValue(); + centY = centerY->getValue(); + + updateGeometry (centX, centY, circrad->getValue(), locY->getValue(), degree->getValue(), locX->getValue(), locYT->getValue(), locXL->getValue()); + + if (listener) { + listener->panelChanged (EvlocallablocY, locY->getTextValue()); + } + + return true; + } + } + + } else if (Smethod->get_active_row_number() == 1 || Smethod->get_active_row_number() == 3) { + if (lastObject == 2 || lastObject == 3) { + // Dragging the upper or lower locY bar + PolarCoord draggedPoint; + rtengine::Coord currPos; + currPos = provider->posImage + provider->deltaImage; + rtengine::Coord centerPos = draggedCenter; + double verti = double (imH); + // trick to get the correct angle (clockwise/counter-clockwise) + int p = centerPos.y; + centerPos.y = currPos.y; + currPos.y = p; + draggedPoint = currPos - centerPos; + + // draggedPoint.setFromCartesian(centerPos, currPos); + double currDraggedlocYOffset = draggedPoint.radius * sin ((draggedPoint.angle - degree->getValue()) / 180.*M_PI); + + if (lastObject == 2) + // Dragging the upper locY bar + { + currDraggedlocYOffset -= draggedlocYOffset; + } else if (lastObject == 3) + // Dragging the lower locY bar + { + currDraggedlocYOffset = -currDraggedlocYOffset + draggedlocYOffset; + } + + currDraggedlocYOffset = currDraggedlocYOffset * 2000. / verti; + + if (int (currDraggedlocYOffset) != locY->getIntValue()) { + locY->setValue ((int (currDraggedlocYOffset))); + //Smethod->get_active_row_number()==2 + double centX, centY; + centX = centerX->getValue(); + centY = centerY->getValue(); + + updateGeometry (centX, centY, circrad->getValue(), locY->getValue(), degree->getValue(), locX->getValue(), locYT->getValue(), locXL->getValue()); + + if (listener) { + if (Smethod->get_active_row_number() == 1 || Smethod->get_active_row_number() == 3) { + listener->panelChanged (EvlocallablocY, locY->getTextValue()); + } + + // else listener->panelChanged (EvlocallablocY, locX->getTextValue()); + + } + + return true; + } + } + + } + + if (Smethod->get_active_row_number() == 0 || Smethod->get_active_row_number() == 2) { + //else if (lastObject==0) { + if (lastObject == 0) { + // Dragging the upper or lower locY bar + PolarCoord draggedPoint; + rtengine::Coord currPos; + currPos = provider->posImage + provider->deltaImage; + rtengine::Coord centerPos = draggedCenter; + double horiz = double (imW); + // trick to get the correct angle (clockwise/counter-clockwise) + int p = centerPos.y; + centerPos.y = currPos.y; + currPos.y = p; + draggedPoint = currPos - centerPos; + + // draggedPoint.setFromCartesian(centerPos, currPos); + double currDraggedStrOffset = draggedPoint.radius * sin ((draggedPoint.angle - degree->getValue() + 90.) / 180.*M_PI); + + if (lastObject == 0) + // Dragging the upper locY bar + { + currDraggedStrOffset -= draggedlocXOffset; + } else if (lastObject == 1) + // Dragging the lower locY bar + { + currDraggedStrOffset = - currDraggedStrOffset - draggedlocXOffset; //- + } + + currDraggedStrOffset = currDraggedStrOffset * 2000. / horiz; + + if (int (currDraggedStrOffset) != locX->getIntValue()) { + locX->setValue ((int (currDraggedStrOffset))); + double centX, centY; + centX = centerX->getValue(); + centY = centerY->getValue(); + updateGeometry (centX, centY, circrad->getValue(), locY->getValue(), degree->getValue(), locX->getValue(), locYT->getValue(), locXL->getValue()); + + if (listener) { + listener->panelChanged (EvlocallablocX, locX->getTextValue()); + } + + return true; + } + } else if (lastObject == 1) { + // Dragging the upper or lower locY bar + PolarCoord draggedPoint; + rtengine::Coord currPos; + currPos = provider->posImage + provider->deltaImage; + rtengine::Coord centerPos = draggedCenter; + double horiz = double (imW); + int p = centerPos.y; + centerPos.y = currPos.y; + currPos.y = p; + draggedPoint = currPos - centerPos; + + //draggedPoint.setFromCartesian(centerPos, currPos); + double currDraggedStrOffset = draggedPoint.radius * sin ((draggedPoint.angle - degree->getValue() + 90.) / 180.*M_PI); + + if (lastObject == 0) + // Dragging the upper locY bar + { + currDraggedStrOffset -= draggedlocXOffset; + } else if (lastObject == 1) + // Dragging the lower locY bar + { + currDraggedStrOffset = - currDraggedStrOffset - draggedlocXOffset; //- + } + + currDraggedStrOffset = currDraggedStrOffset * 2000. / horiz; + + if (int (currDraggedStrOffset) != locXL->getIntValue()) { + locXL->setValue ((int (currDraggedStrOffset))); + double centX, centY; + centX = centerX->getValue(); + centY = centerY->getValue(); + updateGeometry (centX, centY, circrad->getValue(), locY->getValue(), degree->getValue(), locX->getValue(), locYT->getValue(), locXL->getValue()); + + if (listener) { + listener->panelChanged (EvlocallablocX, locX->getTextValue()); + } + + return true; + } + } + + } else if (Smethod->get_active_row_number() == 1 || Smethod->get_active_row_number() == 3) { + if (lastObject == 0 || lastObject == 1) { + // Dragging the upper or lower locY bar + PolarCoord draggedPoint; + rtengine::Coord currPos; + currPos = provider->posImage + provider->deltaImage; + rtengine::Coord centerPos = draggedCenter; + double horiz = double (imW); + // trick to get the correct angle (clockwise/counter-clockwise) + int p = centerPos.y; + centerPos.y = currPos.y; + currPos.y = p; + draggedPoint = currPos - centerPos; + + // draggedPoint.setFromCartesian(centerPos, currPos); + double currDraggedStrOffset = draggedPoint.radius * sin ((draggedPoint.angle - degree->getValue() + 90.) / 180.*M_PI); + + if (lastObject == 0) + // Dragging the upper locY bar + { + currDraggedStrOffset -= draggedlocXOffset; + } else if (lastObject == 1) + // Dragging the lower locY bar + { + currDraggedStrOffset = - currDraggedStrOffset - draggedlocXOffset; //- + } + + currDraggedStrOffset = currDraggedStrOffset * 2000. / horiz; + + if (int (currDraggedStrOffset) != locX->getIntValue()) { + locX->setValue ((int (currDraggedStrOffset))); + double centX, centY; + centX = centerX->getValue(); + centY = centerY->getValue(); + updateGeometry (centX, centY, circrad->getValue(), locY->getValue(), degree->getValue(), locX->getValue(), locYT->getValue(), locXL->getValue()); + + if (listener) { + listener->panelChanged (EvlocallablocX, locX->getTextValue()); + } + + return true; + } + } + } + + /* else if(Smethod->get_active_row_number()==2) { + if (lastObject==0 || lastObject==1 || lastObject==2 || lastObject==3) { + if (lastObject==2 || lastObject==3) { + // Dragging the upper or lower locY bar + PolarCoord draggedPoint; + Coord currPos; + currPos = provider->posImage+provider->deltaImage; + Coord centerPos = draggedCenter; + double verti = double(imH); + // trick to get the correct angle (clockwise/counter-clockwise) + int p = centerPos.y; + centerPos.y = currPos.y; + currPos.y = p; + draggedPoint.setFromCartesian(centerPos, currPos); + double currDraggedlocYOffset = draggedPoint.radius * sin((draggedPoint.angle-degree->getValue())/180.*M_PI); + double currDraggedStrOffset = draggedPoint.radius * sin((draggedPoint.angle-degree->getValue() +90.)/180.*M_PI); + + if (lastObject==2) + currDraggedlocYOffset -= draggedlocYOffset; + else if (lastObject==3) + currDraggedlocYOffset = -currDraggedlocYOffset + draggedlocYOffset; + currDraggedlocYOffset = currDraggedlocYOffset * 200. / verti; + // if (int(currDraggedlocYOffset) != locY->getIntValue()) { + // locY->setValue((int(currDraggedlocYOffset))); + if (int(currDraggedlocYOffset) != locX->getIntValue()) {//locX + // if (int(currDraggedStrOffset) != locX->getIntValue()) {//locX + locX->setValue((int(currDraggedlocYOffset))); + double centX,centY; + centX=centerX->getValue(); + centY=centerY->getValue(); + + // updateGeometry (centX, centY, locY->getValue(), degree->getValue(), locX->getValue(), locYT->getValue(), locXL->getValue()); + updateGeometry (centX, centY, locX->getValue(), degree->getValue(), locX->getValue(), locX->getValue(), locX->getValue()); + if (listener) { + if(Smethod->get_active_row_number()==1) listener->panelChanged (EvlocallablocY, locY->getTextValue()); + + } + return true; + } + } + if (lastObject==0 || lastObject==1) { + // Dragging the upper or lower locY bar + PolarCoord draggedPoint; + Coord currPos; + currPos = provider->posImage+provider->deltaImage; + Coord centerPos = draggedCenter; + double horiz = double(imW); + int p = centerPos.y; + centerPos.y = currPos.y; + currPos.y = p; + draggedPoint.setFromCartesian(centerPos, currPos); + double currDraggedStrOffset = draggedPoint.radius * sin((draggedPoint.angle-degree->getValue() +90.)/180.*M_PI); + if (lastObject==0) + currDraggedStrOffset -= draggedlocXOffset; + else if (lastObject==1) + currDraggedStrOffset = - currDraggedStrOffset - draggedlocXOffset;//- + currDraggedStrOffset = currDraggedStrOffset * 200. / horiz; + + if (int(currDraggedStrOffset) != locX->getIntValue()) { + locX->setValue((int(currDraggedStrOffset))); + double centX,centY; + centX=centerX->getValue(); + centY=centerY->getValue(); + updateGeometry (centX, centY, locY->getValue(), degree->getValue(), locX->getValue(), locYT->getValue(),locXL->getValue()); + if (listener) + listener->panelChanged (EvlocallablocX, locX->getTextValue()); + return true; + } + } + + + } + } + */ + //else if (lastObject==4) { + if (lastObject == 4) { + + // Dragging the circle to change the center + rtengine::Coord currPos; + draggedCenter += provider->deltaPrevImage; + currPos = draggedCenter; + currPos.clip (imW, imH); + int newCenterX = int ((double (currPos.x) - halfSizeW) / halfSizeW * 1000.); + int newCenterY = int ((double (currPos.y) - halfSizeH) / halfSizeH * 1000.); + + if (newCenterX != centerX->getIntValue() || newCenterY != centerY->getIntValue()) { + centerX->setValue (newCenterX); + centerY->setValue (newCenterY); + updateGeometry (newCenterX, newCenterY, circrad->getValue(), locY->getValue(), degree->getValue(), locX->getValue(), locYT->getValue(), locXL->getValue()); + + if (listener) { + listener->panelChanged (EvlocallabCenter, Glib::ustring::compose ("X=%1\nY=%2", centerX->getTextValue(), centerY->getTextValue())); + } + + return true; + } + } + + return false; +} + +void Locallab::switchOffEditMode () +{ + if (edit->get_active()) { + // switching off the toggle button + bool wasBlocked = editConn.block (true); + edit->set_active (false); + + if (!wasBlocked) { + editConn.block (false); + } + } + + EditSubscriber::switchOffEditMode(); // disconnect +} + diff --git a/rtgui/locallab.h b/rtgui/locallab.h new file mode 100644 index 000000000..c4202bff1 --- /dev/null +++ b/rtgui/locallab.h @@ -0,0 +1,199 @@ +/* + * This file is part of RawTherapee. + */ +#ifndef _LOCALLAB_H_ +#define _LOCALLAB_H_ + +#include +#include "adjuster.h" +#include "toolpanel.h" +#include "edit.h" +#include "guiutils.h" +#include "curveeditor.h" +#include "curveeditorgroup.h" +#include "toolpanel.h" +#include "../rtengine/imagedata.h" +#include +#include "options.h" +#include +#include "../rtengine/improcfun.h" + + +class Locallab : public ToolParamBlock, public AdjusterListener, public FoldableToolPanel, public rtengine::localListener, public CurveListener, public EditSubscriber, public ColorProvider +{ +private: + int lastObject; + void foldAllButMe (GdkEventButton* event, MyExpander *expander); + void enableToggled (MyExpander *expander); + +protected: +// Gtk::CheckButton* enabled; + Gtk::HBox *editHBox; + Gtk::ToggleButton* edit; + Adjuster* degree; + Adjuster* locX; + Adjuster* locY; + Adjuster* locXL; + Adjuster* locYT; + Adjuster* centerX; + Adjuster* centerY; + Adjuster* circrad; + Adjuster* lightness; + Adjuster* contrast; + Adjuster* chroma; + Adjuster* sensi; + Adjuster* sensih; + Adjuster* radius; + Adjuster* strength; + Adjuster* transit; + Adjuster* str; + Adjuster* neigh; + Adjuster* vart; + Adjuster* chrrt; + Adjuster* nbspot; + Adjuster* anbspot; + Adjuster* maxn; + Adjuster* sharradius; + Adjuster* sharamount; + Adjuster* shardamping; + Adjuster* shariter; + Adjuster* sensisha; + Adjuster* thres; + Adjuster* proxi; + Adjuster* noiselumf; + Adjuster* noiselumc; + Adjuster* noisechrof; + Adjuster* noisechroc; + Adjuster* multiplier[5]; + Adjuster* threshold; + Adjuster* sensicb; + Adjuster* sensibn; + Adjuster* stren; + Adjuster* gamma; + Adjuster* estop; + Adjuster* scaltm; + Adjuster* rewei; + Adjuster* sensitm; + Adjuster* retrab; + + MyExpander* const expcolor; + MyExpander* const expblur; + MyExpander* const exptonemap; + MyExpander* const expreti; + MyExpander* const expsharp; + MyExpander* const expcbdl; + MyExpander* const expdenoi; + + + sigc::connection lumaneutralPressedConn; + sigc::connection lumacontrastPlusPressedConn; + sigc::connection lumacontrastMinusPressedConn; + sigc::connection enablecolorConn, enableblurConn, enabletonemapConn; + sigc::connection enableretiConn, enablesharpConn, enablecbdlConn; + sigc::connection enabledenoiConn; + + Gtk::CheckButton* avoid; + MyComboBoxText* Smethod; + sigc::connection Smethodconn; + Gtk::HBox* ctboxS; + Gtk::CheckButton* invers; + Gtk::CheckButton* curvactiv; + Gtk::CheckButton* inversrad; + Gtk::CheckButton* inversret; + Gtk::CheckButton* activlum; + Gtk::CheckButton* inverssha; + + Gtk::Button* neutral; + Gtk::HBox* neutrHBox; + + Gtk::Button* neutral1; + Gtk::HBox* neutrHBox1; + + MyComboBoxText* retinexMethod; + MyComboBoxText* qualityMethod; + Gtk::Label* labmdh; + Gtk::HBox* dhbox; + CurveEditorGroup* LocalcurveEditorgainT; + FlatCurveEditor* cTgainshape; + CurveEditorGroup* LocalcurveEditorgainTrab; + FlatCurveEditor* cTgainshaperab; + CurveEditorGroup* llCurveEditorG; + DiagonalCurveEditor* llshape; + Gtk::Image* irg; + FlatCurveEditor* LHshape; + + int nextdatasp[60]; + int nextlength; + std::string nextstr; + std::string nextstr2; + std::string nextll_str; + std::string nextll_str2; + std::string nextlh_str; + std::string nextlh_str2; + + double draggedPointOldAngle; + double draggedPointAdjusterAngle; + double draggedFeatherOffset; + double draggedlocYOffset; + double draggedlocXOffset; + double draggedlocYTOffset; + double draggedlocXLOffset; + rtengine::Coord draggedCenter; + bool lastavoid, lastinvers, lastinversrad, lastinversret, lastactivlum, lastinverssha, lastcurvactiv; + int lastanbspot; + sigc::connection editConn, avoidConn, inversConn, curvactivConn, activlumConn, inversradConn, inversretConn, inversshaConn, retinexMethodConn, qualityMethodConn, neutralconn, neutralconn1; + + void editToggled (); + +public: + + Locallab (); + ~Locallab (); + + void read (const rtengine::procparams::ProcParams* pp, const ParamsEdited* pedited = nullptr); + void write (rtengine::procparams::ProcParams* pp, ParamsEdited* pedited = nullptr); + void setDefaults (const rtengine::procparams::ProcParams* defParams, const ParamsEdited* pedited = nullptr); + + void setBatchMode (bool batchMode); + + void updateGeometry (const int centerX_, const int centerY_, const int circrad_, const int locY_, const double degree_, const int locX_, const int locYT_, const int locXL_, const int fullWidth = -1, const int fullHeight = -1); + void SmethodChanged (); + void writeOptions (std::vector &tpOpen); + void updateToolState (std::vector &tpOpen); + + void adjusterChanged (Adjuster* a, double newval); + void enabledChanged (); + void setAdjusterBehavior (bool degreeadd, bool locYadd, bool locXadd, bool locYTadd, bool locXLadd, bool centeradd, bool lightnessadd, bool contrastadd, bool chromaadd, bool sensiadd, bool transitadd, bool radiusadd, bool strengthadd); + void trimValues (rtengine::procparams::ProcParams* pp); + void avoidChanged (); + void activlumChanged (); + void inversChanged (); + void curvactivChanged (); + void inversradChanged (); + void inversretChanged (); + void inversshaChanged (); + void curveChanged (CurveEditor* ce); + void autoOpenCurve (); + void localChanged (int **datasp, std::string datastr, std::string ll_str, std::string lh_str, int sp, int maxdat); + void localretChanged (int **datasp, std::string datastr, std::string ll_str, std::string lh_str, int sp, int maxdat); + bool localComputed_ (); + bool localretComputed_ (); + void setEditProvider (EditDataProvider* provider); + void retinexMethodChanged(); + void qualityMethodChanged(); + void lumaneutralPressed (); + void lumacontrastPlusPressed (); + void lumacontrastMinusPressed (); + void neutral_pressed (); + virtual void colorForValue (double valX, double valY, enum ColorCaller::ElemType elemType, int callerId, ColorCaller* caller); + + // EditSubscriber interface + CursorShape getCursor (int objectID); + bool mouseOver (int modifierKey); + bool button1Pressed (int modifierKey); + bool button1Released(); + bool drag1 (int modifierKey); + void switchOffEditMode (); +}; + +#endif diff --git a/rtgui/main.cc b/rtgui/main.cc index f27a0f32f..399e705d3 100644 --- a/rtgui/main.cc +++ b/rtgui/main.cc @@ -115,16 +115,16 @@ static void myGdkLockLeave() * -1 if there is an error in parameters * -2 if an error occurred during processing * -3 if at least one required procparam file was not found */ -int processLineParams( int argc, char **argv ); +int processLineParams ( int argc, char **argv ); -int main(int argc, char **argv) +int main (int argc, char **argv) { - setlocale(LC_ALL, ""); - setlocale(LC_NUMERIC, "C"); // to set decimal point to "." + setlocale (LC_ALL, ""); + setlocale (LC_NUMERIC, "C"); // to set decimal point to "." gtk_init (&argc, &argv); // use the "--g-fatal-warnings" command line flag to make warnings fatal Glib::init(); // called by Gtk::Main, but this may be important for thread handling, so we call it ourselves now - gdk_threads_set_lock_functions(G_CALLBACK(myGdkLockEnter), (G_CALLBACK(myGdkLockLeave))); + gdk_threads_set_lock_functions (G_CALLBACK (myGdkLockEnter), (G_CALLBACK (myGdkLockLeave))); gdk_threads_init(); Gio::init (); @@ -137,33 +137,33 @@ int main(int argc, char **argv) #ifdef WIN32 WCHAR exnameU[512] = {0}; GetModuleFileNameW (NULL, exnameU, 512); - WideCharToMultiByte(CP_UTF8, 0, exnameU, -1, exname, 512, 0, 0 ); + WideCharToMultiByte (CP_UTF8, 0, exnameU, -1, exname, 512, 0, 0 ); #else - if (readlink("/proc/self/exe", exname, 512) < 0) { - strncpy(exname, argv[0], 512); + if (readlink ("/proc/self/exe", exname, 512) < 0) { + strncpy (exname, argv[0], 512); } #endif - exePath = Glib::path_get_dirname(exname); + exePath = Glib::path_get_dirname (exname); // set paths - if (Glib::path_is_absolute(DATA_SEARCH_PATH)) { + if (Glib::path_is_absolute (DATA_SEARCH_PATH)) { argv0 = DATA_SEARCH_PATH; } else { - argv0 = Glib::build_filename(exePath, DATA_SEARCH_PATH); + argv0 = Glib::build_filename (exePath, DATA_SEARCH_PATH); } - if (Glib::path_is_absolute(CREDITS_SEARCH_PATH)) { + if (Glib::path_is_absolute (CREDITS_SEARCH_PATH)) { creditsPath = CREDITS_SEARCH_PATH; } else { - creditsPath = Glib::build_filename(exePath, CREDITS_SEARCH_PATH); + creditsPath = Glib::build_filename (exePath, CREDITS_SEARCH_PATH); } - if (Glib::path_is_absolute(LICENCE_SEARCH_PATH)) { + if (Glib::path_is_absolute (LICENCE_SEARCH_PATH)) { licensePath = LICENCE_SEARCH_PATH; } else { - licensePath = Glib::build_filename(exePath, LICENCE_SEARCH_PATH); + licensePath = Glib::build_filename (exePath, LICENCE_SEARCH_PATH); } #else @@ -173,7 +173,7 @@ int main(int argc, char **argv) #endif if (!Options::load ()) { - Gtk::Main m(&argc, &argv); + Gtk::Main m (&argc, &argv); Gtk::MessageDialog msgd ("Fatal error!\nThe RT_SETTINGS and/or RT_PATH environment variables are set, but use a relative path. The path must be absolute!", true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true); msgd.run (); return -2; @@ -187,50 +187,50 @@ int main(int argc, char **argv) if (argc > 1 || options.rtSettings.verbose) { if (options.rtSettings.verbose || ( !Glib::file_test (fname_to_utf8 (argv[1]), Glib::FILE_TEST_EXISTS ) && !Glib::file_test (fname_to_utf8 (argv[1]), Glib::FILE_TEST_IS_DIR))) { - bool stdoutRedirectedtoFile = (GetFileType(GetStdHandle(STD_OUTPUT_HANDLE)) == 0x0001); - bool stderrRedirectedtoFile = (GetFileType(GetStdHandle(STD_ERROR_HANDLE)) == 0x0001); + bool stdoutRedirectedtoFile = (GetFileType (GetStdHandle (STD_OUTPUT_HANDLE)) == 0x0001); + bool stderrRedirectedtoFile = (GetFileType (GetStdHandle (STD_ERROR_HANDLE)) == 0x0001); // no console, if stdout and stderr both are redirected to file - if( !(stdoutRedirectedtoFile && stderrRedirectedtoFile)) { + if ( ! (stdoutRedirectedtoFile && stderrRedirectedtoFile)) { // check if parameter -w was passed. // We have to do that in this step, because it controls whether to open a console to show the output of following steps bool Console = true; - for(int i = 1; i < argc; i++) - if(!strcmp(argv[i], "-w")) { + for (int i = 1; i < argc; i++) + if (!strcmp (argv[i], "-w")) { Console = false; break; } - if(Console) { + if (Console) { AllocConsole(); - AttachConsole( GetCurrentProcessId() ) ; + AttachConsole ( GetCurrentProcessId() ) ; // Don't allow CTRL-C in console to terminate RT - SetConsoleCtrlHandler( NULL, true ); + SetConsoleCtrlHandler ( NULL, true ); // Set title of console char consoletitle[128]; - sprintf(consoletitle, "RawTherapee %s Console", VERSION); - SetConsoleTitle(consoletitle); + sprintf (consoletitle, "RawTherapee %s Console", VERSION); + SetConsoleTitle (consoletitle); // increase size of screen buffer COORD c; c.X = 200; c.Y = 1000; - SetConsoleScreenBufferSize( GetStdHandle( STD_OUTPUT_HANDLE ), c ); + SetConsoleScreenBufferSize ( GetStdHandle ( STD_OUTPUT_HANDLE ), c ); // Disable console-Cursor CONSOLE_CURSOR_INFO cursorInfo; cursorInfo.dwSize = 100; cursorInfo.bVisible = false; - SetConsoleCursorInfo( GetStdHandle( STD_OUTPUT_HANDLE ), &cursorInfo ); + SetConsoleCursorInfo ( GetStdHandle ( STD_OUTPUT_HANDLE ), &cursorInfo ); - if(!stdoutRedirectedtoFile) { - freopen( "CON", "w", stdout ) ; + if (!stdoutRedirectedtoFile) { + freopen ( "CON", "w", stdout ) ; } - if(!stderrRedirectedtoFile) { - freopen( "CON", "w", stderr ) ; + if (!stderrRedirectedtoFile) { + freopen ( "CON", "w", stderr ) ; } - freopen( "CON", "r", stdin ) ; + freopen ( "CON", "r", stdin ) ; consoleOpened = true; @@ -241,12 +241,12 @@ int main(int argc, char **argv) } } - int ret = processLineParams( argc, argv); + int ret = processLineParams ( argc, argv); - if( ret <= 0 ) { - if(consoleOpened) { - printf("Press any key to exit RawTherapee\n"); - FlushConsoleInputBuffer(GetStdHandle(STD_INPUT_HANDLE)); + if ( ret <= 0 ) { + if (consoleOpened) { + printf ("Press any key to exit RawTherapee\n"); + FlushConsoleInputBuffer (GetStdHandle (STD_INPUT_HANDLE)); getch(); } @@ -264,9 +264,9 @@ int main(int argc, char **argv) #endif if (argc > 1) { - int ret = processLineParams( argc, argv); + int ret = processLineParams ( argc, argv); - if( ret <= 0 ) { + if ( ret <= 0 ) { return ret; } } @@ -274,33 +274,34 @@ int main(int argc, char **argv) #endif - if( !options.rtSettings.verbose ) { - TIFFSetWarningHandler(nullptr); // avoid annoying message boxes + if ( !options.rtSettings.verbose ) { + TIFFSetWarningHandler (nullptr); // avoid annoying message boxes } #ifndef WIN32 // Move the old path to the new one if the new does not exist - if (Glib::file_test(Glib::build_filename(options.rtdir, "cache"), Glib::FILE_TEST_IS_DIR) && !Glib::file_test(options.cacheBaseDir, Glib::FILE_TEST_IS_DIR)) { - g_rename(Glib::build_filename (options.rtdir, "cache").c_str (), options.cacheBaseDir.c_str ()); + if (Glib::file_test (Glib::build_filename (options.rtdir, "cache"), Glib::FILE_TEST_IS_DIR) && !Glib::file_test (options.cacheBaseDir, Glib::FILE_TEST_IS_DIR)) { + g_rename (Glib::build_filename (options.rtdir, "cache").c_str (), options.cacheBaseDir.c_str ()); } #endif simpleEditor = false; - if( !argv1.empty() ) - if( Glib::file_test(argv1, Glib::FILE_TEST_EXISTS) && !Glib::file_test(argv1, Glib::FILE_TEST_IS_DIR)) { + if ( !argv1.empty() ) + if ( Glib::file_test (argv1, Glib::FILE_TEST_EXISTS) && !Glib::file_test (argv1, Glib::FILE_TEST_IS_DIR)) { simpleEditor = true; } - Gtk::Main m(&argc, &argv); + Gtk::Main m (&argc, &argv); - Glib::ustring icon_path = Glib::build_filename(argv0, "images"); + + Glib::ustring icon_path = Glib::build_filename (argv0, "images"); Glib::RefPtr defaultIconTheme = Gtk::IconTheme::get_default(); - defaultIconTheme->append_search_path(icon_path); + defaultIconTheme->append_search_path (icon_path); - RTImage::setPaths(options); + RTImage::setPaths (options); MyExpander::init(); // has to stay AFTER RTImage::setPaths // ------- loading theme files @@ -308,30 +309,34 @@ int main(int argc, char **argv) Glib::RefPtr screen = Gdk::Screen::get_default(); if (screen) { - Gtk::Settings::get_for_screen(screen)->property_gtk_theme_name() = "Adwaita"; - Gtk::Settings::get_for_screen(screen)->property_gtk_application_prefer_dark_theme() = true; + Gtk::Settings::get_for_screen (screen)->property_gtk_theme_name() = "Adwaita"; + Gtk::Settings::get_for_screen (screen)->property_gtk_application_prefer_dark_theme() = true; - Glib::RefPtr regex = Glib::Regex::create(THEMEREGEXSTR, Glib::RegexCompileFlags::REGEX_CASELESS); - Glib::ustring filename = Glib::build_filename(argv0, "themes", options.theme + ".css"); - if (!regex->match(options.theme + ".css") || !Glib::file_test(filename, Glib::FILE_TEST_EXISTS)) { + Glib::RefPtr regex = Glib::Regex::create (THEMEREGEXSTR, Glib::RegexCompileFlags::REGEX_CASELESS); + Glib::ustring filename = Glib::build_filename (argv0, "themes", options.theme + ".css"); + + if (!regex->match (options.theme + ".css") || !Glib::file_test (filename, Glib::FILE_TEST_EXISTS)) { options.theme = "RawTherapee-GTK"; + // We're not testing GTK_MAJOR_VERSION == 3 here, since this branch requires Gtk3 only if (GTK_MINOR_VERSION < 20) { options.theme = options.theme + "3-_19"; } else { options.theme = options.theme + "3-20_"; } - filename = Glib::build_filename(argv0, "themes", options.theme + ".css"); + + filename = Glib::build_filename (argv0, "themes", options.theme + ".css"); } + cssRT = Gtk::CssProvider::create(); try { cssRT->load_from_path (filename); - Gtk::StyleContext::add_provider_for_screen(screen, cssRT, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); + Gtk::StyleContext::add_provider_for_screen (screen, cssRT, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); } catch (Glib::Error &err) { - printf("Error: Can't load css file \"%s\"\nMessage: %s\n", filename.c_str(), err.what().c_str()); + printf ("Error: Can't load css file \"%s\"\nMessage: %s\n", filename.c_str(), err.what().c_str()); } catch (...) { - printf("Error: Can't load css file \"%s\"\n", filename.c_str()); + printf ("Error: Can't load css file \"%s\"\n", filename.c_str()); } // Set the font face and size @@ -339,24 +344,24 @@ int main(int argc, char **argv) try { cssForced = Gtk::CssProvider::create(); //GTK318 - #if GTK_MAJOR_VERSION == 3 && GTK_MINOR_VERSION < 20 - cssForced->load_from_data (Glib::ustring::compose("* { font-family: %1; font-size: %2px }", options.fontFamily, options.fontSize)); - #else - cssForced->load_from_data (Glib::ustring::compose("* { font-family: %1; font-size: %2pt }", options.fontFamily, options.fontSize)); - #endif +#if GTK_MAJOR_VERSION == 3 && GTK_MINOR_VERSION < 20 + cssForced->load_from_data (Glib::ustring::compose ("* { font-family: %1; font-size: %2px }", options.fontFamily, options.fontSize)); +#else + cssForced->load_from_data (Glib::ustring::compose ("* { font-family: %1; font-size: %2pt }", options.fontFamily, options.fontSize)); +#endif //GTK318 - Gtk::StyleContext::add_provider_for_screen(screen, cssForced, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); + Gtk::StyleContext::add_provider_for_screen (screen, cssForced, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); } catch (Glib::Error &err) { - printf("Error: \"%s\"\n", err.what().c_str()); + printf ("Error: \"%s\"\n", err.what().c_str()); } catch (...) { - printf("Error: Can't find the font named \"%s\"\n", options.fontFamily.c_str()); + printf ("Error: Can't find the font named \"%s\"\n", options.fontFamily.c_str()); } } } #ifndef NDEBUG else if (!screen) { - printf("ERROR: Can't get default screen!\n"); + printf ("ERROR: Can't get default screen!\n"); } #endif @@ -368,17 +373,17 @@ int main(int argc, char **argv) // alerting users if the default raw and image profiles are missing if (options.is_defProfRawMissing()) { - Gtk::MessageDialog msgd (Glib::ustring::compose(M("OPTIONS_DEFRAW_MISSING"), options.defProfRaw), true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true); + Gtk::MessageDialog msgd (Glib::ustring::compose (M ("OPTIONS_DEFRAW_MISSING"), options.defProfRaw), true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true); msgd.run (); } if (options.is_defProfImgMissing()) { - Gtk::MessageDialog msgd (Glib::ustring::compose(M("OPTIONS_DEFIMG_MISSING"), options.defProfImg), true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true); + Gtk::MessageDialog msgd (Glib::ustring::compose (M ("OPTIONS_DEFIMG_MISSING"), options.defProfImg), true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true); msgd.run (); } // opening the main window - m.run(*rtWindow); + m.run (*rtWindow); gdk_threads_leave (); delete rtWindow; @@ -387,8 +392,8 @@ int main(int argc, char **argv) #ifdef WIN32 if (consoleOpened) { - printf("Press any key to exit RawTherapee\n"); - FlushConsoleInputBuffer(GetStdHandle(STD_INPUT_HANDLE)); + printf ("Press any key to exit RawTherapee\n"); + FlushConsoleInputBuffer (GetStdHandle (STD_INPUT_HANDLE)); getch(); } @@ -397,7 +402,7 @@ int main(int argc, char **argv) return 0; } -void deleteProcParams(std::vector &pparams) +void deleteProcParams (std::vector &pparams) { for (unsigned int i = 0; i < pparams.size(); i++) { pparams[i]->deleteInstance(); @@ -408,7 +413,7 @@ void deleteProcParams(std::vector &pparam return; } -int processLineParams( int argc, char **argv ) +int processLineParams ( int argc, char **argv ) { rtengine::procparams::PartialProfile *rawParams = nullptr, *imgParams = nullptr; std::vector inputFiles; @@ -427,252 +432,254 @@ int processLineParams( int argc, char **argv ) std::string outputType = ""; unsigned errors = 0; - for( int iArg = 1; iArg < argc; iArg++) { - if( argv[iArg][0] == '-' ) { - switch( argv[iArg][1] ) { - case 'O': - copyParamsFile = true; + for ( int iArg = 1; iArg < argc; iArg++) { + if ( argv[iArg][0] == '-' ) { + switch ( argv[iArg][1] ) { + case 'O': + copyParamsFile = true; - case 'o': // outputfile or dir - if( iArg + 1 < argc ) { - iArg++; - outputPath = fname_to_utf8 (argv[iArg]); + case 'o': // outputfile or dir + if ( iArg + 1 < argc ) { + iArg++; + outputPath = fname_to_utf8 (argv[iArg]); - if( Glib::file_test (outputPath, Glib::FILE_TEST_IS_DIR)) { - outputDirectory = true; - } - } - - break; - - case 'p': // processing parameters for all inputs; all set procparams are required, so - - // RT stop if any of them can't be loaded for any reason. - if( iArg + 1 < argc ) { - iArg++; - Glib::ustring fname = fname_to_utf8 (argv[iArg]); - - if (fname.at(0) == '-') { - std::cerr << "Error: filename missing next to the -p switch" << std::endl; - deleteProcParams(processingParams); - return -3; + if ( Glib::file_test (outputPath, Glib::FILE_TEST_IS_DIR)) { + outputDirectory = true; + } } - rtengine::procparams::PartialProfile* currentParams = new rtengine::procparams::PartialProfile(true); + break; - if (!(currentParams->load ( fname ))) { - processingParams.push_back(currentParams); + case 'p': // processing parameters for all inputs; all set procparams are required, so + + // RT stop if any of them can't be loaded for any reason. + if ( iArg + 1 < argc ) { + iArg++; + Glib::ustring fname = fname_to_utf8 (argv[iArg]); + + if (fname.at (0) == '-') { + std::cerr << "Error: filename missing next to the -p switch" << std::endl; + deleteProcParams (processingParams); + return -3; + } + + rtengine::procparams::PartialProfile* currentParams = new rtengine::procparams::PartialProfile (true); + + if (! (currentParams->load ( fname ))) { + processingParams.push_back (currentParams); + } else { + std::cerr << "Error: \"" << fname << "\" not found" << std::endl; + deleteProcParams (processingParams); + return -3; + } + } + + break; + + case 'S': + skipIfNoSidecar = true; + + case 's': // Processing params next to file (file extension appended) + sideProcParams = true; + sideCarFilePos = processingParams.size(); + break; + + case 'd': + useDefault = true; + break; + + case 'Y': + overwriteFiles = true; + break; + + case 'j': + if (strlen (argv[iArg]) > 2 && argv[iArg][2] == 's') { + if (strlen (argv[iArg]) == 3) { + std::cerr << "Error: the -js switch requires a mandatory value!" << std::endl; + deleteProcParams (processingParams); + return -3; + } + + // looking for the subsampling parameter + sscanf (&argv[iArg][3], "%d", &subsampling); + + if (subsampling < 1 || subsampling > 3) { + std::cerr << "Error: the value accompanying the -js switch has to be in the [1-3] range!" << std::endl; + deleteProcParams (processingParams); + return -3; + } } else { - std::cerr << "Error: \"" << fname << "\" not found" << std::endl; - deleteProcParams(processingParams); - return -3; + outputType = "jpg"; + sscanf (&argv[iArg][2], "%d", &compression); + + if (compression < 0 || compression > 100) { + std::cerr << "Error: the value accompanying the -j switch has to be in the [0-100] range!" << std::endl; + deleteProcParams (processingParams); + return -3; + } } - } - break; + break; - case 'S': - skipIfNoSidecar = true; + case 'b': + sscanf (&argv[iArg][2], "%d", &bits); - case 's': // Processing params next to file (file extension appended) - sideProcParams = true; - sideCarFilePos = processingParams.size(); - break; - - case 'd': - useDefault = true; - break; - - case 'Y': - overwriteFiles = true; - break; - - case 'j': - if (strlen(argv[iArg]) > 2 && argv[iArg][2] == 's') { - if (strlen(argv[iArg]) == 3) { - std::cerr << "Error: the -js switch requires a mandatory value!" << std::endl; - deleteProcParams(processingParams); + if (bits != 8 && bits != 16) { + std::cerr << "Error: specify -b8 for 8-bit or -b16 for 16-bit output." << std::endl; + deleteProcParams (processingParams); return -3; } - // looking for the subsampling parameter - sscanf(&argv[iArg][3], "%d", &subsampling); + break; - if (subsampling < 1 || subsampling > 3) { - std::cerr << "Error: the value accompanying the -js switch has to be in the [1-3] range!" << std::endl; - deleteProcParams(processingParams); - return -3; - } - } else { - outputType = "jpg"; - sscanf(&argv[iArg][2], "%d", &compression); + case 't': + outputType = "tif"; + compression = ((argv[iArg][2] != 'z') ? 0 : 1); + break; - if (compression < 0 || compression > 100) { - std::cerr << "Error: the value accompanying the -j switch has to be in the [0-100] range!" << std::endl; - deleteProcParams(processingParams); - return -3; - } - } + case 'n': + outputType = "png"; + compression = -1; + break; - break; + case 'c': // MUST be last option + while (iArg + 1 < argc) { + iArg++; - case 'b': - sscanf(&argv[iArg][2], "%d", &bits); + const auto argument = fname_to_utf8 (argv[iArg]); - if (bits != 8 && bits != 16) { - std::cerr << "Error: specify -b8 for 8-bit or -b16 for 16-bit output." << std::endl; - deleteProcParams(processingParams); - return -3; - } - - break; - - case 't': - outputType = "tif"; - compression = ((argv[iArg][2] != 'z') ? 0 : 1); - break; - - case 'n': - outputType = "png"; - compression = -1; - break; - - case 'c': // MUST be last option - while (iArg + 1 < argc) { - iArg++; - - const auto argument = fname_to_utf8 (argv[iArg]); - - if (Glib::file_test (argument, Glib::FILE_TEST_IS_REGULAR)) { - inputFiles.emplace_back (argument); - continue; - } - - if (Glib::file_test (argument, Glib::FILE_TEST_IS_DIR)) { - - auto dir = Gio::File::create_for_path (argument); - if (!dir || !dir->query_exists()) { + if (Glib::file_test (argument, Glib::FILE_TEST_IS_REGULAR)) { + inputFiles.emplace_back (argument); continue; } - try { + if (Glib::file_test (argument, Glib::FILE_TEST_IS_DIR)) { - auto enumerator = dir->enumerate_children (); + auto dir = Gio::File::create_for_path (argument); - while (auto file = enumerator->next_file ()) { - - const auto fileName = Glib::build_filename (argument, file->get_name ()); - - if (Glib::file_test (fileName, Glib::FILE_TEST_IS_DIR)) { - continue; - } - - // skip files without extension and sidecar files - auto lastdot = fileName.find_last_of('.'); - if (lastdot == Glib::ustring::npos) { - continue; - } - - if (fileName.substr (lastdot).compare (paramFileExtension) == 0) { - continue; - } - - inputFiles.emplace_back (fileName); + if (!dir || !dir->query_exists()) { + continue; } - } catch (Glib::Exception&) {} + try { - continue; + auto enumerator = dir->enumerate_children (); + + while (auto file = enumerator->next_file ()) { + + const auto fileName = Glib::build_filename (argument, file->get_name ()); + + if (Glib::file_test (fileName, Glib::FILE_TEST_IS_DIR)) { + continue; + } + + // skip files without extension and sidecar files + auto lastdot = fileName.find_last_of ('.'); + + if (lastdot == Glib::ustring::npos) { + continue; + } + + if (fileName.substr (lastdot).compare (paramFileExtension) == 0) { + continue; + } + + inputFiles.emplace_back (fileName); + } + + } catch (Glib::Exception&) {} + + continue; + } + + std::cerr << "\"" << argument << "\" is neither a regular file nor a directory." << std::endl; } - std::cerr << "\"" << argument << "\" is neither a regular file nor a directory." << std::endl; + break; +#ifdef WIN32 + + case 'w': // This case is handled outside this function + break; +#endif + + case 'h': + case '?': + default: { + Glib::ustring pparamsExt = paramFileExtension.substr (1); + std::cout << " An advanced, cross-platform program for developing raw photos." << std::endl; + std::cout << std::endl; + std::cout << " Website: http://www.rawtherapee.com/" << std::endl; + std::cout << " Documentation: http://rawpedia.rawtherapee.com/" << std::endl; + std::cout << " Forum: https://discuss.pixls.us/c/software/rawtherapee" << std::endl; + std::cout << " Code and bug reports: https://github.com/Beep6581/RawTherapee" << std::endl; + std::cout << std::endl; + std::cout << "Symbols:" << std::endl; + std::cout << " indicate parameters you can change." << std::endl; + std::cout << " [Square brackets] mean the parameter is optional." << std::endl; + std::cout << " The pipe symbol | indicates a choice of one or the other." << std::endl; + std::cout << " The dash symbol - denotes a range of possible values from one to the other." << std::endl; + std::cout << std::endl; + std::cout << "Usage:" << std::endl; + std::cout << " " << Glib::path_get_basename (argv[0]) << " Start File Browser inside folder." << std::endl; + std::cout << " " << Glib::path_get_basename (argv[0]) << " Start Image Editor with file." << std::endl; + std::cout << " " << Glib::path_get_basename (argv[0]) << " -c | Convert files in batch with default parameters." << std::endl; + std::cout << " " << Glib::path_get_basename (argv[0]) << " -c | Convert files in batch with your own settings." << std::endl; + std::cout << std::endl; +#ifdef WIN32 + std::cout << " -w Do not open the Windows console" << std::endl; + std::cout << std::endl; +#endif + std::cout << "Options:" << std::endl; + std::cout << " " << Glib::path_get_basename (argv[0]) << " [-o |-O ] [-s|-S] [-p [-p ...] ] [-d] [ -j[1-100] [-js<1-3>] | [-b<8|16>] [-t[z] | [-n]] ] [-Y] -c " << std::endl; + std::cout << std::endl; + std::cout << " -c Specify one or more input files." << std::endl; + std::cout << " -c must be the last option." << std::endl; + std::cout << " -o | Set output file or folder." << std::endl; + std::cout << " Saves output file alongside input file if -o is not specified." << std::endl; + std::cout << " -O | Set output file or folder and copy " << pparamsExt << " file into it." << std::endl; + std::cout << " Saves output file alongside input file if -O is not specified." << std::endl; + std::cout << " -s Use the existing sidecar file to build the processing parameters," << std::endl; + std::cout << " e.g. for photo.raw there should be a photo.raw." << pparamsExt << " file in the same folder." << std::endl; + std::cout << " If the sidecar file does not exist, neutral values will be used." << std::endl; + std::cout << " -S Like -s but skip if the sidecar file does not exist." << std::endl; + std::cout << " -p Specify processing profile to be used for all conversions." << std::endl; + std::cout << " You can specify as many sets of \"-p \" options as you like," << std::endl; + std::cout << " each will be built on top of the previous one, as explained below." << std::endl; + std::cout << " -d Use the default raw or non-raw processing profile as set in" << std::endl; + std::cout << " Preferences > Image Processing > Default Processing Profile" << std::endl; + std::cout << " -j[1-100] Specify output to be JPEG (default, if -t and -n are not set)." << std::endl; + std::cout << " Optionally, specify compression 1-100 (default value: 92)." << std::endl; + std::cout << " -js<1-3> Specify the JPEG chroma subsampling parameter, where:" << std::endl; + std::cout << " 1 = Best compression: 2x2, 1x1, 1x1 (4:2:0)" << std::endl; + std::cout << " Chroma halved vertically and horizontally." << std::endl; + std::cout << " 2 = Balanced (default): 2x1, 1x1, 1x1 (4:2:2)" << std::endl; + std::cout << " Chroma halved horizontally." << std::endl; + std::cout << " 3 = Best quality: 1x1, 1x1, 1x1 (4:4:4)" << std::endl; + std::cout << " No chroma subsampling." << std::endl; + std::cout << " -b<8|16> Specify bit depth per channel (default value: 16 for TIFF, 8 for PNG)." << std::endl; + std::cout << " Only applies to TIFF and PNG output, JPEG is always 8." << std::endl; + std::cout << " -t[z] Specify output to be TIFF." << std::endl; + std::cout << " Uncompressed by default, or deflate compression with 'z'." << std::endl; + std::cout << " -n Specify output to be compressed PNG." << std::endl; + std::cout << " Compression is hard-coded to 6." << std::endl; + std::cout << " -Y Overwrite output if present." << std::endl; + std::cout << std::endl; + std::cout << "Your " << pparamsExt << " files can be incomplete, RawTherapee will build the final values as follows:" << std::endl; + std::cout << " 1- A new processing profile is created using neutral values," << std::endl; + std::cout << " 2- If the \"-d\" option is set, the values are overridden by those found in" << std::endl; + std::cout << " the default raw or non-raw processing profile." << std::endl; + std::cout << " 3- If one or more \"-p\" options are set, the values are overridden by those" << std::endl; + std::cout << " found in these processing profiles." << std::endl; + std::cout << " 4- If the \"-s\" or \"-S\" options are set, the values are finally overridden by those" << std::endl; + std::cout << " found in the sidecar files." << std::endl; + std::cout << " The processing profiles are processed in the order specified on the command line." << std::endl; + return -1; } - - break; -#ifdef WIN32 - - case 'w': // This case is handled outside this function - break; -#endif - - case 'h': - case '?': - default: { - Glib::ustring pparamsExt = paramFileExtension.substr(1); - std::cout << " An advanced, cross-platform program for developing raw photos." << std::endl; - std::cout << std::endl; - std::cout << " Website: http://www.rawtherapee.com/" << std::endl; - std::cout << " Documentation: http://rawpedia.rawtherapee.com/" << std::endl; - std::cout << " Forum: https://discuss.pixls.us/c/software/rawtherapee" << std::endl; - std::cout << " Code and bug reports: https://github.com/Beep6581/RawTherapee" << std::endl; - std::cout << std::endl; - std::cout << "Symbols:" << std::endl; - std::cout << " indicate parameters you can change." << std::endl; - std::cout << " [Square brackets] mean the parameter is optional." << std::endl; - std::cout << " The pipe symbol | indicates a choice of one or the other." << std::endl; - std::cout << " The dash symbol - denotes a range of possible values from one to the other." << std::endl; - std::cout << std::endl; - std::cout << "Usage:" << std::endl; - std::cout << " " << Glib::path_get_basename(argv[0]) << " Start File Browser inside folder." << std::endl; - std::cout << " " << Glib::path_get_basename(argv[0]) << " Start Image Editor with file." << std::endl; - std::cout << " " << Glib::path_get_basename(argv[0]) << " -c | Convert files in batch with default parameters." << std::endl; - std::cout << " " << Glib::path_get_basename(argv[0]) << " -c | Convert files in batch with your own settings." << std::endl; - std::cout << std::endl; -#ifdef WIN32 - std::cout << " -w Do not open the Windows console" << std::endl; - std::cout << std::endl; -#endif - std::cout << "Options:" << std::endl; - std::cout << " " << Glib::path_get_basename(argv[0]) << " [-o |-O ] [-s|-S] [-p [-p ...] ] [-d] [ -j[1-100] [-js<1-3>] | [-b<8|16>] [-t[z] | [-n]] ] [-Y] -c " << std::endl; - std::cout << std::endl; - std::cout << " -c Specify one or more input files." << std::endl; - std::cout << " -c must be the last option." << std::endl; - std::cout << " -o | Set output file or folder." << std::endl; - std::cout << " Saves output file alongside input file if -o is not specified." << std::endl; - std::cout << " -O | Set output file or folder and copy " << pparamsExt << " file into it." << std::endl; - std::cout << " Saves output file alongside input file if -O is not specified." << std::endl; - std::cout << " -s Use the existing sidecar file to build the processing parameters," << std::endl; - std::cout << " e.g. for photo.raw there should be a photo.raw." << pparamsExt << " file in the same folder." << std::endl; - std::cout << " If the sidecar file does not exist, neutral values will be used." << std::endl; - std::cout << " -S Like -s but skip if the sidecar file does not exist." << std::endl; - std::cout << " -p Specify processing profile to be used for all conversions." << std::endl; - std::cout << " You can specify as many sets of \"-p \" options as you like," << std::endl; - std::cout << " each will be built on top of the previous one, as explained below." << std::endl; - std::cout << " -d Use the default raw or non-raw processing profile as set in" << std::endl; - std::cout << " Preferences > Image Processing > Default Processing Profile" << std::endl; - std::cout << " -j[1-100] Specify output to be JPEG (default, if -t and -n are not set)." << std::endl; - std::cout << " Optionally, specify compression 1-100 (default value: 92)." << std::endl; - std::cout << " -js<1-3> Specify the JPEG chroma subsampling parameter, where:" << std::endl; - std::cout << " 1 = Best compression: 2x2, 1x1, 1x1 (4:2:0)" << std::endl; - std::cout << " Chroma halved vertically and horizontally." << std::endl; - std::cout << " 2 = Balanced (default): 2x1, 1x1, 1x1 (4:2:2)" << std::endl; - std::cout << " Chroma halved horizontally." << std::endl; - std::cout << " 3 = Best quality: 1x1, 1x1, 1x1 (4:4:4)" << std::endl; - std::cout << " No chroma subsampling." << std::endl; - std::cout << " -b<8|16> Specify bit depth per channel (default value: 16 for TIFF, 8 for PNG)." << std::endl; - std::cout << " Only applies to TIFF and PNG output, JPEG is always 8." << std::endl; - std::cout << " -t[z] Specify output to be TIFF." << std::endl; - std::cout << " Uncompressed by default, or deflate compression with 'z'." << std::endl; - std::cout << " -n Specify output to be compressed PNG." << std::endl; - std::cout << " Compression is hard-coded to 6." << std::endl; - std::cout << " -Y Overwrite output if present." << std::endl; - std::cout << std::endl; - std::cout << "Your " << pparamsExt << " files can be incomplete, RawTherapee will build the final values as follows:" << std::endl; - std::cout << " 1- A new processing profile is created using neutral values," << std::endl; - std::cout << " 2- If the \"-d\" option is set, the values are overridden by those found in" << std::endl; - std::cout << " the default raw or non-raw processing profile." << std::endl; - std::cout << " 3- If one or more \"-p\" options are set, the values are overridden by those" << std::endl; - std::cout << " found in these processing profiles." << std::endl; - std::cout << " 4- If the \"-s\" or \"-S\" options are set, the values are finally overridden by those" << std::endl; - std::cout << " found in the sidecar files." << std::endl; - std::cout << " The processing profiles are processed in the order specified on the command line." << std::endl; - return -1; - } } } else { argv1 = fname_to_utf8 (argv[iArg]); - if( outputDirectory ) { + if ( outputDirectory ) { options.savePathFolder = outputPath; options.saveUsePathTemplate = false; } else { @@ -699,41 +706,41 @@ int processLineParams( int argc, char **argv ) } } - if( !argv1.empty() ) { + if ( !argv1.empty() ) { return 1; } - if( inputFiles.empty() ) { + if ( inputFiles.empty() ) { return 2; } if (useDefault) { - rawParams = new rtengine::procparams::PartialProfile(true, true); - Glib::ustring profPath = options.findProfilePath(options.defProfRaw); + rawParams = new rtengine::procparams::PartialProfile (true, true); + Glib::ustring profPath = options.findProfilePath (options.defProfRaw); - if (options.is_defProfRawMissing() || profPath.empty() || rawParams->load(profPath == DEFPROFILE_INTERNAL ? DEFPROFILE_INTERNAL : Glib::build_filename(profPath, options.defProfRaw.substr(5) + paramFileExtension))) { + if (options.is_defProfRawMissing() || profPath.empty() || rawParams->load (profPath == DEFPROFILE_INTERNAL ? DEFPROFILE_INTERNAL : Glib::build_filename (profPath, options.defProfRaw.substr (5) + paramFileExtension))) { std::cerr << "Error: default raw processing profile not found" << std::endl; rawParams->deleteInstance(); delete rawParams; - deleteProcParams(processingParams); + deleteProcParams (processingParams); return -3; } - imgParams = new rtengine::procparams::PartialProfile(true); - profPath = options.findProfilePath(options.defProfImg); + imgParams = new rtengine::procparams::PartialProfile (true); + profPath = options.findProfilePath (options.defProfImg); - if (options.is_defProfImgMissing() || profPath.empty() || imgParams->load(profPath == DEFPROFILE_INTERNAL ? DEFPROFILE_INTERNAL : Glib::build_filename(profPath, options.defProfImg.substr(5) + paramFileExtension))) { + if (options.is_defProfImgMissing() || profPath.empty() || imgParams->load (profPath == DEFPROFILE_INTERNAL ? DEFPROFILE_INTERNAL : Glib::build_filename (profPath, options.defProfImg.substr (5) + paramFileExtension))) { std::cerr << "Error: default non-raw processing profile not found" << std::endl; imgParams->deleteInstance(); delete imgParams; rawParams->deleteInstance(); delete rawParams; - deleteProcParams(processingParams); + deleteProcParams (processingParams); return -3; } } - for( size_t iFile = 0; iFile < inputFiles.size(); iFile++) { + for ( size_t iFile = 0; iFile < inputFiles.size(); iFile++) { // Has to be reinstanciated at each profile to have a ProcParams object with default values rtengine::procparams::ProcParams currentParams; @@ -748,30 +755,30 @@ int processLineParams( int argc, char **argv ) Glib::ustring outputFile; - if( outputType.empty() ) { + if ( outputType.empty() ) { outputType = "jpg"; } - if( outputPath.empty() ) { + if ( outputPath.empty() ) { Glib::ustring s = inputFile; - Glib::ustring::size_type ext = s.find_last_of('.'); - outputFile = s.substr(0, ext) + "." + outputType; - } else if( outputDirectory ) { - Glib::ustring s = Glib::path_get_basename( inputFile ); - Glib::ustring::size_type ext = s.find_last_of('.'); - outputFile = outputPath + "/" + s.substr(0, ext) + "." + outputType; + Glib::ustring::size_type ext = s.find_last_of ('.'); + outputFile = s.substr (0, ext) + "." + outputType; + } else if ( outputDirectory ) { + Glib::ustring s = Glib::path_get_basename ( inputFile ); + Glib::ustring::size_type ext = s.find_last_of ('.'); + outputFile = outputPath + "/" + s.substr (0, ext) + "." + outputType; } else { Glib::ustring s = outputPath; - Glib::ustring::size_type ext = s.find_last_of('.'); - outputFile = s.substr(0, ext) + "." + outputType; + Glib::ustring::size_type ext = s.find_last_of ('.'); + outputFile = s.substr (0, ext) + "." + outputType; } - if( inputFile == outputFile) { + if ( inputFile == outputFile) { std::cerr << "Cannot overwrite: " << inputFile << std::endl; continue; } - if( !overwriteFiles && Glib::file_test( outputFile , Glib::FILE_TEST_EXISTS ) ) { + if ( !overwriteFiles && Glib::file_test ( outputFile , Glib::FILE_TEST_EXISTS ) ) { std::cerr << outputFile << " already exists: use -Y option to overwrite. This image has been skipped." << std::endl; continue; } @@ -795,10 +802,10 @@ int processLineParams( int argc, char **argv ) if (useDefault) { if (isRaw) { std::cout << " Merging default raw processing profile" << std::endl; - rawParams->applyTo(¤tParams); + rawParams->applyTo (¤tParams); } else { std::cout << " Merging default non-raw processing profile" << std::endl; - imgParams->applyTo(¤tParams); + imgParams->applyTo (¤tParams); } } @@ -812,7 +819,7 @@ int processLineParams( int argc, char **argv ) Glib::ustring sideProcessingParams = inputFile + paramFileExtension; // the "load" method don't reset the procparams values anymore, so values found in the procparam file override the one of currentParams - if( !Glib::file_test( sideProcessingParams, Glib::FILE_TEST_EXISTS ) || currentParams.load ( sideProcessingParams )) { + if ( !Glib::file_test ( sideProcessingParams, Glib::FILE_TEST_EXISTS ) || currentParams.load ( sideProcessingParams )) { std::cerr << "Warning: sidecar file requested but not found for: " << sideProcessingParams << std::endl; } else { sideCarFound = true; @@ -820,15 +827,15 @@ int processLineParams( int argc, char **argv ) } } - if( processingParams.size() > i ) { + if ( processingParams.size() > i ) { std::cout << " Merging procparams #" << i << std::endl; - processingParams[i]->applyTo(¤tParams); + processingParams[i]->applyTo (¤tParams); } i++; } while (i < processingParams.size() + (sideProcParams ? 1 : 0)); - if( sideProcParams && !sideCarFound && skipIfNoSidecar ) { + if ( sideProcParams && !sideCarFound && skipIfNoSidecar ) { delete ii; errors++; std::cerr << "Error: no sidecar procparams found for: " << inputFile << std::endl; @@ -837,7 +844,7 @@ int processLineParams( int argc, char **argv ) job = rtengine::ProcessingJob::create (ii, currentParams); - if( !job ) { + if ( !job ) { errors++; std::cerr << "Error creating processing for: " << inputFile << std::endl; ii->decreaseRef(); @@ -847,31 +854,31 @@ int processLineParams( int argc, char **argv ) // Process image rtengine::IImage16* resultImage = rtengine::processImage (job, errorCode, nullptr, options.tunnelMetaData); - if( !resultImage ) { + if ( !resultImage ) { errors++; std::cerr << "Error processing: " << inputFile << std::endl; - rtengine::ProcessingJob::destroy( job ); + rtengine::ProcessingJob::destroy ( job ); continue; } // save image to disk - if( outputType == "jpg" ) { - errorCode = resultImage->saveAsJPEG( outputFile, compression, subsampling ); - } else if( outputType == "tif" ) { - errorCode = resultImage->saveAsTIFF( outputFile, bits, compression == 0 ); - } else if( outputType == "png" ) { - errorCode = resultImage->saveAsPNG( outputFile, compression, bits ); + if ( outputType == "jpg" ) { + errorCode = resultImage->saveAsJPEG ( outputFile, compression, subsampling ); + } else if ( outputType == "tif" ) { + errorCode = resultImage->saveAsTIFF ( outputFile, bits, compression == 0 ); + } else if ( outputType == "png" ) { + errorCode = resultImage->saveAsPNG ( outputFile, compression, bits ); } else { errorCode = resultImage->saveToFile (outputFile); } - if(errorCode) { + if (errorCode) { errors++; std::cerr << "Error saving to: " << outputFile << std::endl; } else { - if( copyParamsFile ) { + if ( copyParamsFile ) { Glib::ustring outputProcessingParams = outputFile + paramFileExtension; - currentParams.save( outputProcessingParams ); + currentParams.save ( outputProcessingParams ); } } @@ -889,7 +896,7 @@ int processLineParams( int argc, char **argv ) delete rawParams; } - deleteProcParams(processingParams); + deleteProcParams (processingParams); return errors > 0 ? -2 : 0; } diff --git a/rtgui/options.cc b/rtgui/options.cc index 2b8203728..50e74e9ad 100644 --- a/rtgui/options.cc +++ b/rtgui/options.cc @@ -184,6 +184,10 @@ void Options::updatePaths() lastWaveletCurvesDir = preferredPath; } + if (lastlocalCurvesDir.empty() || !Glib::file_test (lastlocalCurvesDir, Glib::FILE_TEST_EXISTS) || !Glib::file_test (lastlocalCurvesDir, Glib::FILE_TEST_IS_DIR)) { + lastlocalCurvesDir = preferredPath; + } + if (lastPFCurvesDir.empty() || !Glib::file_test (lastPFCurvesDir, Glib::FILE_TEST_EXISTS) || !Glib::file_test (lastPFCurvesDir, Glib::FILE_TEST_IS_DIR)) { lastPFCurvesDir = preferredPath; } @@ -421,6 +425,8 @@ void Options::setDefaults () histogramFullMode = false; curvebboxpos = 1; prevdemo = PD_Sidecar; + mip = MI_opt; + rgbDenoiseThreadLimit = 0; #if defined( _OPENMP ) && defined( __x86_64__ ) clutCacheSize = omp_get_num_procs(); @@ -605,6 +611,20 @@ void Options::setDefaults () 0, // ADDSET_RETI_VART 0, // ADDSET_RETI_GAM 0, // ADDSET_RETI_SLO + 0, // ADDSET_LOCALLAB_DEGREE + 0, // ADDSET_LOCALLAB_LOCY + 0, // ADDSET_LOCALLAB_LOCX + 0, // ADDSET_LOCALLAB_LOCYY + 0, // ADDSET_LOCALLAB_LOCXL + 0, // ADDSET_LOCALLAB_CENTER + 0, // ADDSET_LOCALLAB_LIGHTNESS + 0, // ADDSET_LOCALLAB_CONTRAST + 0, // ADDSET_LOCALLAB_CHROMA + 0, // ADDSET_LOCALLAB_RADIUS + 0, // ADDSET_LOCALLAB_TRANSIT + 0, // ADDSET_LOCALLAB_STRENGTH + 0, // ADDSET_LOCALLAB_SENSI + }; rtSettings.darkFramesPath = ""; @@ -666,6 +686,14 @@ void Options::setDefaults () rtSettings.ed_lipinfl = 0.8; //between 0.5 to 0.9 rtSettings.ed_lipampl = 1.1; //between 1 and 2 +//locallab + rtSettings.nspot = 8;//between 1 and ?? + rtSettings.locdelay = false;//true enabled delay 200 for selection spot + rtSettings.cropsleep = 50;//generate a pause of 50 µs for dcrop (100%)to avoid crash when moving window, between 0 to ?? + rtSettings.reduchigh = 0.85;//transition for luminance in scope + rtSettings.reduclow = 0.85;//transition for luminance out scope + +// end locallab rtSettings.ciecamfloat = true; rtSettings.protectred = 60; @@ -700,6 +728,7 @@ void Options::setDefaults () lastRetinexDir = ""; lastDenoiseCurvesDir = ""; lastWaveletCurvesDir = ""; + lastlocalCurvesDir = ""; lastPFCurvesDir = ""; lastHsvCurvesDir = ""; lastToneCurvesDir = ""; @@ -825,6 +854,27 @@ int Options::readFromFile (Glib::ustring fname) rtSettings.bot_right = keyFile.get_double ("General", "BotRight"); } + if (keyFile.has_key ("General", "Nspot")) { + rtSettings.nspot = keyFile.get_integer ("General", "Nspot"); + } + + if (keyFile.has_key ("General", "Cropsleep")) { + rtSettings.cropsleep = keyFile.get_integer ("General", "Cropsleep"); + } + + if (keyFile.has_key ("General", "Reduchigh")) { + rtSettings.reduchigh = keyFile.get_double ("General", "Reduchigh"); + } + + if (keyFile.has_key ("General", "Reduclow")) { + rtSettings.reduclow = keyFile.get_double ("General", "Reduclow"); + } + + + if (keyFile.has_key ("General", "Locdelay")) { + rtSettings.locdelay = keyFile.get_boolean ("General", "Locdelay"); + } + if (keyFile.has_key ("General", "EDdetec")) { rtSettings.ed_detec = keyFile.get_double ("General", "EDdetec"); } @@ -1222,6 +1272,10 @@ int Options::readFromFile (Glib::ustring fname) prevdemo = (prevdemo_t)keyFile.get_integer ("Performance", "PreviewDemosaicFromSidecar"); } + if (keyFile.has_key ("Profiles", "Mipfiles")) { + mip = (mip_t)keyFile.get_integer ("Profiles", "Mipfiles"); + } + if (keyFile.has_key ("Performance", "Daubechies")) { rtSettings.daubech = keyFile.get_boolean ("Performance", "Daubechies"); } @@ -1454,11 +1508,11 @@ int Options::readFromFile (Glib::ustring fname) } if (keyFile.has_key ("Color Management", "PrinterIntent")) { - rtSettings.printerIntent = static_cast(keyFile.get_integer("Color Management", "PrinterIntent")); + rtSettings.printerIntent = static_cast (keyFile.get_integer ("Color Management", "PrinterIntent")); } if (keyFile.has_key ("Color Management", "PrinterBPC")) { - rtSettings.printerBPC = keyFile.get_boolean("Color Management", "PrinterBPC"); + rtSettings.printerBPC = keyFile.get_boolean ("Color Management", "PrinterBPC"); } if (keyFile.has_key ("Color Management", "PrinterProfile")) { @@ -1486,7 +1540,7 @@ int Options::readFromFile (Glib::ustring fname) } if (keyFile.has_key ("Color Management", "MonitorBPC")) { - rtSettings.monitorBPC = keyFile.get_boolean("Color Management", "MonitorBPC"); + rtSettings.monitorBPC = keyFile.get_boolean ("Color Management", "MonitorBPC"); } if (keyFile.has_key ("Color Management", "CRI")) { @@ -1791,6 +1845,8 @@ int Options::readFromFile (Glib::ustring fname) safeDirGet (keyFile, "Dialogs", "LastRetinexDir", lastRetinexDir); safeDirGet (keyFile, "Dialogs", "LastDenoiseCurvesDir", lastDenoiseCurvesDir); safeDirGet (keyFile, "Dialogs", "LastWaveletCurvesDir", lastWaveletCurvesDir); + safeDirGet (keyFile, "Dialogs", "LastlocalCurvesDir", lastlocalCurvesDir); + safeDirGet (keyFile, "Dialogs", "LastPFCurvesDir", lastPFCurvesDir); safeDirGet (keyFile, "Dialogs", "LastHsvCurvesDir", lastHsvCurvesDir); safeDirGet (keyFile, "Dialogs", "LastBWCurvesDir", lastBWCurvesDir); @@ -1825,7 +1881,7 @@ bool Options::safeDirGet (const Glib::KeyFile& keyFile, const Glib::ustring& sec const Glib::ustring& entryName, Glib::ustring& destination) { try { - + if (keyFile.has_key (section, entryName) && !keyFile.get_string (section, entryName).empty ()) { destination = keyFile.get_string (section, entryName); return true; @@ -1880,6 +1936,12 @@ int Options::saveToFile (Glib::ustring fname) keyFile.set_double ("General", "EDLipinfl", rtSettings.ed_lipinfl); keyFile.set_double ("General", "EDLipampl", rtSettings.ed_lipampl); + keyFile.set_integer ("General", "Nspot", rtSettings.nspot); + keyFile.set_boolean ("General", "Locdelay", rtSettings.locdelay); + keyFile.set_integer ("General", "Cropsleep", rtSettings.cropsleep); + keyFile.set_double ("General", "Reduchigh", rtSettings.reduchigh); + keyFile.set_double ("General", "Reduclow", rtSettings.reduclow); + keyFile.set_integer ("External Editor", "EditorKind", editorToSendTo); keyFile.set_string ("External Editor", "GimpDir", gimpDir); @@ -1990,6 +2052,7 @@ int Options::saveToFile (Glib::ustring fname) keyFile.set_integer ("Profiles", "LoadParamsFromLocation", paramsLoadLocation); keyFile.set_string ("Profiles", "CustomProfileBuilderPath", CPBPath); keyFile.set_integer ("Profiles", "CustomProfileBuilderKeys", CPBKeys); + keyFile.set_integer ("Profiles", "Mipfiles", mip); keyFile.set_integer ("GUI", "WindowWidth", windowWidth); keyFile.set_integer ("GUI", "WindowHeight", windowHeight); @@ -2147,6 +2210,7 @@ int Options::saveToFile (Glib::ustring fname) keyFile.set_string ("Dialogs", "LastRetinexDir", lastRetinexDir); keyFile.set_string ("Dialogs", "LastDenoiseCurvesDir", lastDenoiseCurvesDir); keyFile.set_string ("Dialogs", "LastWaveletCurvesDir", lastWaveletCurvesDir); + keyFile.set_string ("Dialogs", "LastlocalCurvesDir", lastlocalCurvesDir); keyFile.set_string ("Dialogs", "LastPFCurvesDir", lastPFCurvesDir); keyFile.set_string ("Dialogs", "LastHsvCurvesDir", lastHsvCurvesDir); keyFile.set_string ("Dialogs", "LastBWCurvesDir", lastBWCurvesDir); diff --git a/rtgui/options.h b/rtgui/options.h index 446e8d2cc..49f1865ef 100644 --- a/rtgui/options.h +++ b/rtgui/options.h @@ -52,13 +52,14 @@ public: int tiffBits; bool tiffUncompressed; bool saveParams; - SaveFormat () : format("jpg"), pngBits(8), pngCompression(6), jpegQuality(90), jpegSubSamp(2), tiffBits(8), tiffUncompressed(true), saveParams(true) {}; + SaveFormat () : format ("jpg"), pngBits (8), pngCompression (6), jpegQuality (90), jpegSubSamp (2), tiffBits (8), tiffUncompressed (true), saveParams (true) {}; }; enum ThFileType {FT_Invalid = -1, FT_None = 0, FT_Raw = 1, FT_Jpeg = 2, FT_Tiff = 3, FT_Png = 4, FT_Custom = 5, FT_Tiff16 = 6, FT_Png16 = 7, FT_Custom16 = 8}; enum PPLoadLocation {PLL_Cache = 0, PLL_Input = 1}; enum CPBKeyType {CPBKT_TID = 0, CPBKT_NAME = 1, CPBKT_TID_NAME = 2}; enum prevdemo_t {PD_Sidecar = 1, PD_Fast = 0}; +enum mip_t {MI_prev = 0, MI_opt = 1}; class Options { @@ -68,8 +69,8 @@ private: bool defProfImgMissing; Glib::ustring userProfilePath; Glib::ustring globalProfilePath; - bool checkProfilePath(Glib::ustring &path); - bool checkDirPath(Glib::ustring &path, Glib::ustring errString); + bool checkProfilePath (Glib::ustring &path); + bool checkDirPath (Glib::ustring &path, Glib::ustring errString); void updatePaths(); int getString (const char* src, char* dst); void error (int line); @@ -84,8 +85,8 @@ private: * @param destination destination variable to store to * @return @c true if @p destination was changed */ - bool safeDirGet(const Glib::KeyFile& keyFile, const Glib::ustring& section, - const Glib::ustring& entryName, Glib::ustring& destination); + bool safeDirGet (const Glib::KeyFile& keyFile, const Glib::ustring& section, + const Glib::ustring& entryName, Glib::ustring& destination); public: @@ -234,6 +235,7 @@ public: bool filledProfile; // Used as reminder for the ProfilePanel "mode" prevdemo_t prevdemo; // Demosaicing method used for the <100% preview bool serializeTiffRead; + mip_t mip; // MIP bool menuGroupRank; bool menuGroupLabel; @@ -287,6 +289,7 @@ public: Glib::ustring lastRetinexDir; Glib::ustring lastDenoiseCurvesDir; Glib::ustring lastWaveletCurvesDir; + Glib::ustring lastlocalCurvesDir; Glib::ustring lastPFCurvesDir; Glib::ustring lastHsvCurvesDir; Glib::ustring lastToneCurvesDir; @@ -319,9 +322,9 @@ public: { return globalProfilePath; } - Glib::ustring findProfilePath(Glib::ustring &profName); + Glib::ustring findProfilePath (Glib::ustring &profName); bool has_retained_extention (Glib::ustring fname); - bool is_extention_enabled(Glib::ustring ext); + bool is_extention_enabled (Glib::ustring ext); bool is_defProfRawMissing() { return defProfRawMissing; @@ -330,11 +333,11 @@ public: { return defProfImgMissing; } - void setDefProfRawMissing(bool value) + void setDefProfRawMissing (bool value) { defProfRawMissing = value; } - void setDefProfImgMissing(bool value) + void setDefProfImgMissing (bool value) { defProfImgMissing = value; } diff --git a/rtgui/paramsedited.cc b/rtgui/paramsedited.cc index ff3e4c0b1..e4b5c12e0 100644 --- a/rtgui/paramsedited.cc +++ b/rtgui/paramsedited.cc @@ -291,6 +291,77 @@ void ParamsEdited::set (bool v) gradient.strength = v; gradient.centerX = v; gradient.centerY = v; + locallab.enabled = v; + locallab.expcolor = v; + locallab.expblur = v; + locallab.exptonemap = v; + locallab.expreti = v; + locallab.expsharp = v; + locallab.expcbdl = v; + locallab.expdenoi = v; + locallab.degree = v; + locallab.locY = v; + locallab.locX = v; + locallab.locYT = v; + locallab.locXL = v; + locallab.centerX = v; + locallab.centerY = v; + locallab.circrad = v; + locallab.thres = v; + locallab.proxi = v; + locallab.qualityMethod = v; + locallab.lightness = v; + locallab.contrast = v; + locallab.chroma = v; + locallab.noiselumf = v; + locallab.noiselumc = v; + locallab.noisechrof = v; + locallab.noisechroc = v; + locallab.sharradius = v; + locallab.sharamount = v; + locallab.shardamping = v; + locallab.shariter = v; + locallab.sensi = v; + locallab.sensih = v; + locallab.retrab = v; + locallab.sensicb = v; + locallab.sensibn = v; + locallab.sensitm = v; + locallab.sensisha = v; + locallab.radius = v; + locallab.strength = v; + locallab.stren = v; + locallab.gamma = v; + locallab.estop = v; + locallab.scaltm = v; + locallab.rewei = v; + locallab.transit = v; + locallab.chrrt = v; + locallab.avoid = v; + locallab.Smethod = v; + locallab.retinexMethod = v; + locallab.invers = v; + locallab.curvactiv = v; + locallab.activlum = v; + locallab.inversrad = v; + locallab.inversret = v; + locallab.inverssha = v; + locallab.str = v; + locallab.neigh = v; + locallab.nbspot = v; + locallab.anbspot = v; + locallab.vart = v; + locallab.localTgaincurve = v; + locallab.localTgaincurverab = v; + locallab.llcurve = v; + locallab.LHcurve = v; + + for (int i = 0; i < 5; i++) { + locallab.mult[i] = v; + } + + locallab.threshold = v; + pcvignette.enabled = v; pcvignette.strength = v; pcvignette.feather = v; @@ -480,11 +551,11 @@ void ParamsEdited::set (bool v) wavelet.exptoning = v; wavelet.expnoise = v; - for(int i = 0; i < 9; i++) { + for (int i = 0; i < 9; i++) { wavelet.c[i] = v; } - for(int i = 0; i < 9; i++) { + for (int i = 0; i < 9; i++) { wavelet.ch[i] = v; } @@ -493,7 +564,7 @@ void ParamsEdited::set (bool v) dirpyrequalizer.cbdlMethod = v; - for(int i = 0; i < 6; i++) { + for (int i = 0; i < 6; i++) { dirpyrequalizer.mult[i] = v; } @@ -788,6 +859,76 @@ void ParamsEdited::initFrom (const std::vector gradient.strength = gradient.strength && p.gradient.strength == other.gradient.strength; gradient.centerX = gradient.centerX && p.gradient.centerX == other.gradient.centerX; gradient.centerY = gradient.centerY && p.gradient.centerY == other.gradient.centerY; + locallab.enabled = locallab.enabled && p.locallab.enabled == other.locallab.enabled; + locallab.avoid = locallab.avoid && p.locallab.avoid == other.locallab.avoid; + locallab.invers = locallab.invers && p.locallab.invers == other.locallab.invers; + locallab.curvactiv = locallab.curvactiv && p.locallab.curvactiv == other.locallab.curvactiv; + locallab.activlum = locallab.activlum && p.locallab.activlum == other.locallab.activlum; + locallab.inversrad = locallab.inversrad && p.locallab.inversrad == other.locallab.inversrad; + locallab.inversret = locallab.inversret && p.locallab.inversret == other.locallab.inversret; + locallab.inverssha = locallab.inverssha && p.locallab.inverssha == other.locallab.inverssha; + locallab.degree = locallab.degree && p.locallab.degree == other.locallab.degree; + locallab.locY = locallab.locY && p.locallab.locY == other.locallab.locY; + locallab.locX = locallab.locX && p.locallab.locX == other.locallab.locX; + locallab.locYT = locallab.locYT && p.locallab.locYT == other.locallab.locYT; + locallab.locXL = locallab.locXL && p.locallab.locXL == other.locallab.locXL; + locallab.Smethod = locallab.Smethod && p.locallab.Smethod == other.locallab.Smethod; + locallab.retinexMethod = locallab.retinexMethod && p.locallab.retinexMethod == other.locallab.retinexMethod; + locallab.centerX = locallab.centerX && p.locallab.centerX == other.locallab.centerX; + locallab.centerY = locallab.centerY && p.locallab.centerY == other.locallab.centerY; + locallab.circrad = locallab.circrad && p.locallab.circrad == other.locallab.circrad; + locallab.thres = locallab.thres && p.locallab.thres == other.locallab.thres; + locallab.proxi = locallab.proxi && p.locallab.proxi == other.locallab.proxi; + locallab.qualityMethod = locallab.qualityMethod && p.locallab.qualityMethod == other.locallab.qualityMethod; + locallab.lightness = locallab.lightness && p.locallab.lightness == other.locallab.lightness; + locallab.contrast = locallab.contrast && p.locallab.contrast == other.locallab.contrast; + locallab.chroma = locallab.chroma && p.locallab.chroma == other.locallab.chroma; + locallab.noiselumf = locallab.noiselumf && p.locallab.noiselumf == other.locallab.noiselumf; + locallab.noiselumc = locallab.noiselumc && p.locallab.noiselumc == other.locallab.noiselumc; + locallab.noisechrof = locallab.noisechrof && p.locallab.noisechrof == other.locallab.noisechrof; + locallab.noisechroc = locallab.noisechroc && p.locallab.noisechroc == other.locallab.noisechroc; + locallab.sharradius = locallab.sharradius && p.locallab.sharradius == other.locallab.sharradius; + locallab.sharamount = locallab.sharamount && p.locallab.sharamount == other.locallab.sharamount; + locallab.shariter = locallab.shariter && p.locallab.shariter == other.locallab.shariter; + locallab.sensi = locallab.sensi && p.locallab.sensi == other.locallab.sensi; + locallab.sensih = locallab.sensih && p.locallab.sensih == other.locallab.sensih; + locallab.retrab = locallab.retrab && p.locallab.retrab == other.locallab.retrab; + locallab.sensicb = locallab.sensicb && p.locallab.sensicb == other.locallab.sensicb; + locallab.sensibn = locallab.sensibn && p.locallab.sensibn == other.locallab.sensibn; + locallab.sensitm = locallab.sensitm && p.locallab.sensitm == other.locallab.sensitm; + locallab.sensisha = locallab.sensisha && p.locallab.sensisha == other.locallab.sensisha; + locallab.radius = locallab.radius && p.locallab.radius == other.locallab.radius; + locallab.strength = locallab.strength && p.locallab.strength == other.locallab.strength; + locallab.stren = locallab.stren && p.locallab.stren == other.locallab.stren; + locallab.gamma = locallab.gamma && p.locallab.gamma == other.locallab.gamma; + locallab.estop = locallab.estop && p.locallab.estop == other.locallab.estop; + locallab.scaltm = locallab.scaltm && p.locallab.scaltm == other.locallab.scaltm; + locallab.rewei = locallab.rewei && p.locallab.rewei == other.locallab.rewei; + locallab.transit = locallab.transit && p.locallab.transit == other.locallab.transit; + locallab.chrrt = locallab.chrrt && p.locallab.chrrt == other.locallab.chrrt; + locallab.str = locallab.str && p.locallab.str == other.locallab.str; + locallab.neigh = locallab.neigh && p.locallab.neigh == other.locallab.neigh; + locallab.nbspot = locallab.nbspot && p.locallab.nbspot == other.locallab.nbspot; + locallab.anbspot = locallab.anbspot && p.locallab.anbspot == other.locallab.anbspot; + locallab.vart = locallab.vart && p.locallab.vart == other.locallab.vart; + locallab.localTgaincurve = locallab.localTgaincurve && p.locallab.localTgaincurve == other.locallab.localTgaincurve; + locallab.localTgaincurverab = locallab.localTgaincurverab && p.locallab.localTgaincurverab == other.locallab.localTgaincurverab; + locallab.llcurve = locallab.llcurve && p.locallab.llcurve == other.locallab.llcurve; + locallab.LHcurve = locallab.LHcurve && p.locallab.LHcurve == other.locallab.LHcurve; + locallab.expcolor = locallab.expcolor && p.locallab.expcolor == other.locallab.expcolor; + locallab.expblur = locallab.expblur && p.locallab.expblur == other.locallab.expblur; + locallab.exptonemap = locallab.exptonemap && p.locallab.exptonemap == other.locallab.exptonemap; + locallab.expreti = locallab.expreti && p.locallab.expreti == other.locallab.expreti; + locallab.expsharp = locallab.expsharp && p.locallab.expsharp == other.locallab.expsharp; + locallab.expcbdl = locallab.expcbdl && p.locallab.expcbdl == other.locallab.expcbdl; + locallab.expdenoi = locallab.expdenoi && p.locallab.expdenoi == other.locallab.expdenoi; + + for (int i = 0; i < 5; i++) { + locallab.mult[i] = locallab.mult[i] && p.locallab.mult[i] == other.locallab.mult[i]; + } + + locallab.threshold = locallab.threshold && p.locallab.threshold == other.locallab.threshold; + pcvignette.enabled = pcvignette.enabled && p.pcvignette.enabled == other.pcvignette.enabled; pcvignette.strength = pcvignette.strength && p.pcvignette.strength == other.pcvignette.strength; pcvignette.feather = pcvignette.feather && p.pcvignette.feather == other.pcvignette.feather; @@ -971,11 +1112,11 @@ void ParamsEdited::initFrom (const std::vector wavelet.exptoning = wavelet.exptoning && p.wavelet.exptoning == other.wavelet.exptoning; wavelet.expnoise = wavelet.expnoise && p.wavelet.expnoise == other.wavelet.expnoise; - for(int i = 0; i < 9; i++) { + for (int i = 0; i < 9; i++) { wavelet.c[i] = wavelet.c[i] && p.wavelet.c[i] == other.wavelet.c[i]; } - for(int i = 0; i < 9; i++) { + for (int i = 0; i < 9; i++) { wavelet.ch[i] = wavelet.ch[i] && p.wavelet.ch[i] == other.wavelet.ch[i]; } @@ -983,7 +1124,7 @@ void ParamsEdited::initFrom (const std::vector dirpyrequalizer.gamutlab = dirpyrequalizer.gamutlab && p.dirpyrequalizer.gamutlab == other.dirpyrequalizer.gamutlab; dirpyrequalizer.cbdlMethod = dirpyrequalizer.cbdlMethod && p.dirpyrequalizer.cbdlMethod == other.dirpyrequalizer.cbdlMethod; - for(int i = 0; i < 6; i++) { + for (int i = 0; i < 6; i++) { dirpyrequalizer.mult[i] = dirpyrequalizer.mult[i] && p.dirpyrequalizer.mult[i] == other.dirpyrequalizer.mult[i]; } @@ -1994,6 +2135,273 @@ void ParamsEdited::combine (rtengine::procparams::ProcParams& toEdit, const rten toEdit.gradient.centerY = mods.gradient.centerY; } + if (locallab.enabled) { + toEdit.locallab.enabled = mods.locallab.enabled; + } + + if (locallab.expcolor) { + toEdit.locallab.expcolor = mods.locallab.expcolor; + } + + if (locallab.expblur) { + toEdit.locallab.expblur = mods.locallab.expblur; + } + + if (locallab.exptonemap) { + toEdit.locallab.exptonemap = mods.locallab.exptonemap; + } + + if (locallab.expreti) { + toEdit.locallab.expreti = mods.locallab.expreti; + } + + if (locallab.expsharp) { + toEdit.locallab.expsharp = mods.locallab.expsharp; + } + + if (locallab.expcbdl) { + toEdit.locallab.expcbdl = mods.locallab.expcbdl; + } + + if (locallab.expdenoi) { + toEdit.locallab.expdenoi = mods.locallab.expdenoi; + } + + if (locallab.avoid) { + toEdit.locallab.avoid = mods.locallab.avoid; + } + + if (locallab.invers) { + toEdit.locallab.invers = mods.locallab.invers; + } + + if (locallab.curvactiv) { + toEdit.locallab.curvactiv = mods.locallab.curvactiv; + } + + if (locallab.activlum) { + toEdit.locallab.activlum = mods.locallab.activlum; + } + + if (locallab.inversrad) { + toEdit.locallab.inversrad = mods.locallab.inversrad; + } + + if (locallab.inverssha) { + toEdit.locallab.inverssha = mods.locallab.inverssha; + } + + if (locallab.inversret) { + toEdit.locallab.inversret = mods.locallab.inversret; + } + + if (locallab.degree) { + toEdit.locallab.degree = dontforceSet && options.baBehav[ADDSET_LOCALLAB_DEGREE] ? toEdit.locallab.degree + mods.locallab.degree : mods.locallab.degree; + } + + if (locallab.locY) { + toEdit.locallab.locY = mods.locallab.locY; + } + + if (locallab.locX) { + toEdit.locallab.locX = mods.locallab.locX; + } + + if (locallab.locYT) { + toEdit.locallab.locYT = mods.locallab.locYT; + } + + if (locallab.locXL) { + toEdit.locallab.locXL = mods.locallab.locXL; + } + + if (locallab.Smethod) { + toEdit.locallab.Smethod = mods.locallab.Smethod; + } + + if (locallab.retinexMethod) { + toEdit.locallab.retinexMethod = mods.locallab.retinexMethod; + } + + if (locallab.qualityMethod) { + toEdit.locallab.qualityMethod = mods.locallab.qualityMethod; + } + + if (locallab.centerX) { + toEdit.locallab.centerX = mods.locallab.centerX; + } + + if (locallab.centerY) { + toEdit.locallab.centerY = mods.locallab.centerY; + } + + if (locallab.circrad) { + toEdit.locallab.circrad = mods.locallab.circrad; + } + + if (locallab.thres) { + toEdit.locallab.thres = mods.locallab.thres; + } + + if (locallab.proxi) { + toEdit.locallab.proxi = mods.locallab.proxi; + } + + if (locallab.lightness) { + toEdit.locallab.lightness = mods.locallab.lightness; + } + + if (locallab.contrast) { + toEdit.locallab.contrast = mods.locallab.contrast; + } + + if (locallab.chroma) { + toEdit.locallab.chroma = mods.locallab.chroma; + } + + if (locallab.noiselumf) { + toEdit.locallab.noiselumf = mods.locallab.noiselumf; + } + + if (locallab.noiselumc) { + toEdit.locallab.noiselumc = mods.locallab.noiselumc; + } + + if (locallab.noisechrof) { + toEdit.locallab.noisechrof = mods.locallab.noisechrof; + } + + if (locallab.noisechroc) { + toEdit.locallab.noisechroc = mods.locallab.noisechroc; + } + + if (locallab.sharradius) { + toEdit.locallab.sharradius = mods.locallab.sharradius; + } + + if (locallab.sharamount) { + toEdit.locallab.sharamount = mods.locallab.sharamount; + } + + if (locallab.shardamping) { + toEdit.locallab.shardamping = mods.locallab.shardamping; + } + + if (locallab.shariter) { + toEdit.locallab.shariter = mods.locallab.shariter; + } + + if (locallab.sensi) { + toEdit.locallab.sensi = mods.locallab.sensi; + } + + if (locallab.sensitm) { + toEdit.locallab.sensitm = mods.locallab.sensitm; + } + + if (locallab.sensih) { + toEdit.locallab.sensih = mods.locallab.sensih; + } + + if (locallab.retrab) { + toEdit.locallab.retrab = mods.locallab.retrab; + } + + + if (locallab.sensicb) { + toEdit.locallab.sensicb = mods.locallab.sensicb; + } + + if (locallab.sensibn) { + toEdit.locallab.sensibn = mods.locallab.sensibn; + } + + if (locallab.sensisha) { + toEdit.locallab.sensisha = mods.locallab.sensisha; + } + + if (locallab.radius) { + toEdit.locallab.radius = mods.locallab.radius; + } + + if (locallab.strength) { + toEdit.locallab.strength = mods.locallab.strength; + } + + if (locallab.stren) { + toEdit.locallab.stren = mods.locallab.stren; + } + + if (locallab.gamma) { + toEdit.locallab.gamma = mods.locallab.gamma; + } + + if (locallab.estop) { + toEdit.locallab.estop = mods.locallab.estop; + } + + if (locallab.scaltm) { + toEdit.locallab.scaltm = mods.locallab.scaltm; + } + + if (locallab.rewei) { + toEdit.locallab.rewei = mods.locallab.rewei; + } + + if (locallab.transit) { + toEdit.locallab.transit = mods.locallab.transit; + } + + if (locallab.chrrt) { + toEdit.locallab.chrrt = mods.locallab.chrrt; + } + + if (locallab.str) { + toEdit.locallab.str = mods.locallab.str; + } + + if (locallab.neigh) { + toEdit.locallab.neigh = mods.locallab.neigh; + } + + if (locallab.nbspot) { + toEdit.locallab.nbspot = mods.locallab.nbspot; + } + + if (locallab.anbspot) { + toEdit.locallab.anbspot = mods.locallab.anbspot; + } + + if (locallab.vart) { + toEdit.locallab.vart = mods.locallab.vart; + } + + if (locallab.localTgaincurve) { + toEdit.locallab.localTgaincurve = mods.locallab.localTgaincurve; + } + + if (locallab.llcurve) { + toEdit.locallab.llcurve = mods.locallab.llcurve; + } + + if (locallab.LHcurve) { + toEdit.locallab.LHcurve = mods.locallab.LHcurve; + } + + if (locallab.localTgaincurverab) { + toEdit.locallab.localTgaincurverab = mods.locallab.localTgaincurverab; + } + + for (int i = 0; i < 5; i++) { + if (locallab.mult[i]) { + toEdit.locallab.mult[i] = mods.locallab.mult[i]; + } + } + + if (locallab.threshold) { + toEdit.locallab.threshold = mods.locallab.threshold; + } + if (pcvignette.enabled) { toEdit.pcvignette.enabled = mods.pcvignette.enabled; } @@ -2610,14 +3018,14 @@ void ParamsEdited::combine (rtengine::procparams::ProcParams& toEdit, const rten toEdit.wavelet.expnoise = mods.wavelet.expnoise; } - for(int i = 0; i < 9; i++) { - if(wavelet.c[i]) { + for (int i = 0; i < 9; i++) { + if (wavelet.c[i]) { toEdit.wavelet.c[i] = dontforceSet && options.baBehav[ADDSET_WA] ? toEdit.wavelet.c[i] + mods.wavelet.c[i] : mods.wavelet.c[i]; } } - for(int i = 0; i < 9; i++) { - if(wavelet.ch[i]) { + for (int i = 0; i < 9; i++) { + if (wavelet.ch[i]) { toEdit.wavelet.ch[i] = dontforceSet && options.baBehav[ADDSET_WA] ? toEdit.wavelet.ch[i] + mods.wavelet.ch[i] : mods.wavelet.ch[i]; } } @@ -2723,8 +3131,8 @@ void ParamsEdited::combine (rtengine::procparams::ProcParams& toEdit, const rten toEdit.dirpyrequalizer.cbdlMethod = mods.dirpyrequalizer.cbdlMethod; } - for(int i = 0; i < 6; i++) { - if(dirpyrequalizer.mult[i]) { + for (int i = 0; i < 6; i++) { + if (dirpyrequalizer.mult[i]) { toEdit.dirpyrequalizer.mult[i] = dontforceSet && options.baBehav[ADDSET_DIRPYREQ] ? toEdit.dirpyrequalizer.mult[i] + mods.dirpyrequalizer.mult[i] : mods.dirpyrequalizer.mult[i]; } } diff --git a/rtgui/paramsedited.h b/rtgui/paramsedited.h index 38f26658a..5f2fb2931 100644 --- a/rtgui/paramsedited.h +++ b/rtgui/paramsedited.h @@ -413,6 +413,78 @@ class DistortionParamsEdited public: bool amount; }; +class LocallabParamsEdited +{ + +public: + bool enabled; + bool degree; + bool locY; + bool locX; + bool locYT; + bool locXL; + bool centerX; + bool centerY; + bool circrad; + bool thres; + bool proxi; + bool qualityMethod; + bool lightness; + bool contrast; + bool chroma; + bool noiselumf; + bool noiselumc; + bool noisechrof; + bool noisechroc; + bool sharradius; + bool sharamount; + bool shardamping; + bool shariter; + bool sensi; + bool sensih; + bool retrab; + bool sensicb; + bool sensibn; + bool sensitm; + bool sensisha; + bool radius; + bool strength; + bool stren; + bool gamma; + bool estop; + bool scaltm; + bool rewei; + bool transit; + bool avoid; + bool Smethod; + bool retinexMethod; + bool str; + bool neigh; + bool nbspot; + bool anbspot; + bool vart; + bool activlum; + bool invers; + bool curvactiv; + bool inversrad; + bool inversret; + bool inverssha; + bool localTgaincurve; + bool localTgaincurverab; + bool llcurve; + bool LHcurve; + bool chrrt; + bool mult[5]; + bool threshold; + bool expcolor; + bool expblur; + bool exptonemap; + bool expreti; + bool expsharp; + bool expcbdl; + bool expdenoi; + +}; class LensProfParamsEdited { @@ -768,6 +840,7 @@ public: LensProfParamsEdited lensProf; PerspectiveParamsEdited perspective; GradientParamsEdited gradient; + LocallabParamsEdited locallab; PCVignetteParamsEdited pcvignette; CACorrParamsEdited cacorrection; VignettingParamsEdited vignetting; diff --git a/rtgui/partialpastedlg.cc b/rtgui/partialpastedlg.cc index c0cc2c87c..2263ed980 100644 --- a/rtgui/partialpastedlg.cc +++ b/rtgui/partialpastedlg.cc @@ -24,115 +24,116 @@ PartialPasteDlg::PartialPasteDlg (const Glib::ustring &title, Gtk::Window* parent) : Gtk::Dialog (title, *parent, true) { - set_default_size(700, 600); + set_default_size (700, 600); - everything = Gtk::manage (new Gtk::CheckButton (M("PARTIALPASTE_EVERYTHING"))); - everything ->set_name("PartialPasteHeader"); + everything = Gtk::manage (new Gtk::CheckButton (M ("PARTIALPASTE_EVERYTHING"))); + everything ->set_name ("PartialPasteHeader"); - basic = Gtk::manage (new Gtk::CheckButton (M("PARTIALPASTE_BASICGROUP"))); - basic ->set_name("PartialPasteHeader"); - detail = Gtk::manage (new Gtk::CheckButton (M("PARTIALPASTE_DETAILGROUP"))); - detail ->set_name("PartialPasteHeader"); - color = Gtk::manage (new Gtk::CheckButton (M("PARTIALPASTE_COLORGROUP"))); - color ->set_name("PartialPasteHeader"); - lens = Gtk::manage (new Gtk::CheckButton (M("PARTIALPASTE_LENSGROUP"))); - lens ->set_name("PartialPasteHeader"); - composition = Gtk::manage (new Gtk::CheckButton (M("PARTIALPASTE_COMPOSITIONGROUP"))); - composition ->set_name("PartialPasteHeader"); - meta = Gtk::manage (new Gtk::CheckButton (M("PARTIALPASTE_METAGROUP"))); - meta ->set_name("PartialPasteHeader"); - raw = Gtk::manage (new Gtk::CheckButton (M("PARTIALPASTE_RAWGROUP"))); - raw ->set_name("PartialPasteHeader"); - wav = Gtk::manage (new Gtk::CheckButton (M("PARTIALPASTE_WAVELETGROUP"))); - wav ->set_name("PartialPasteHeader"); + basic = Gtk::manage (new Gtk::CheckButton (M ("PARTIALPASTE_BASICGROUP"))); + basic ->set_name ("PartialPasteHeader"); + detail = Gtk::manage (new Gtk::CheckButton (M ("PARTIALPASTE_DETAILGROUP"))); + detail ->set_name ("PartialPasteHeader"); + color = Gtk::manage (new Gtk::CheckButton (M ("PARTIALPASTE_COLORGROUP"))); + color ->set_name ("PartialPasteHeader"); + lens = Gtk::manage (new Gtk::CheckButton (M ("PARTIALPASTE_LENSGROUP"))); + lens ->set_name ("PartialPasteHeader"); + composition = Gtk::manage (new Gtk::CheckButton (M ("PARTIALPASTE_COMPOSITIONGROUP"))); + composition ->set_name ("PartialPasteHeader"); + meta = Gtk::manage (new Gtk::CheckButton (M ("PARTIALPASTE_METAGROUP"))); + meta ->set_name ("PartialPasteHeader"); + raw = Gtk::manage (new Gtk::CheckButton (M ("PARTIALPASTE_RAWGROUP"))); + raw ->set_name ("PartialPasteHeader"); + wav = Gtk::manage (new Gtk::CheckButton (M ("PARTIALPASTE_WAVELETGROUP"))); + wav ->set_name ("PartialPasteHeader"); // options in basic: - wb = Gtk::manage (new Gtk::CheckButton (M("PARTIALPASTE_WHITEBALANCE"))); - exposure = Gtk::manage (new Gtk::CheckButton (M("PARTIALPASTE_EXPOSURE"))); - sh = Gtk::manage (new Gtk::CheckButton (M("PARTIALPASTE_SHADOWSHIGHLIGHTS"))); - epd = Gtk::manage (new Gtk::CheckButton (M("PARTIALPASTE_EPD"))); - retinex = Gtk::manage (new Gtk::CheckButton (M("PARTIALPASTE_RETINEX"))); - pcvignette = Gtk::manage (new Gtk::CheckButton (M("PARTIALPASTE_PCVIGNETTE"))); - gradient = Gtk::manage (new Gtk::CheckButton (M("PARTIALPASTE_GRADIENT"))); - labcurve = Gtk::manage (new Gtk::CheckButton (M("PARTIALPASTE_LABCURVE"))); - colorappearance = Gtk::manage (new Gtk::CheckButton (M("PARTIALPASTE_COLORAPP"))); + wb = Gtk::manage (new Gtk::CheckButton (M ("PARTIALPASTE_WHITEBALANCE"))); + exposure = Gtk::manage (new Gtk::CheckButton (M ("PARTIALPASTE_EXPOSURE"))); + sh = Gtk::manage (new Gtk::CheckButton (M ("PARTIALPASTE_SHADOWSHIGHLIGHTS"))); + epd = Gtk::manage (new Gtk::CheckButton (M ("PARTIALPASTE_EPD"))); + retinex = Gtk::manage (new Gtk::CheckButton (M ("PARTIALPASTE_RETINEX"))); + pcvignette = Gtk::manage (new Gtk::CheckButton (M ("PARTIALPASTE_PCVIGNETTE"))); + gradient = Gtk::manage (new Gtk::CheckButton (M ("PARTIALPASTE_GRADIENT"))); + labcurve = Gtk::manage (new Gtk::CheckButton (M ("PARTIALPASTE_LABCURVE"))); + locallab = Gtk::manage (new Gtk::CheckButton (M ("PARTIALPASTE_LOCALLAB"))); + colorappearance = Gtk::manage (new Gtk::CheckButton (M ("PARTIALPASTE_COLORAPP"))); // options in detail: - sharpen = Gtk::manage (new Gtk::CheckButton (M("PARTIALPASTE_SHARPENING"))); - sharpenedge = Gtk::manage (new Gtk::CheckButton (M("PARTIALPASTE_SHARPENEDGE"))); - sharpenmicro = Gtk::manage (new Gtk::CheckButton (M("PARTIALPASTE_SHARPENMICRO"))); - impden = Gtk::manage (new Gtk::CheckButton (M("PARTIALPASTE_IMPULSEDENOISE"))); - dirpyreq = Gtk::manage (new Gtk::CheckButton (M("PARTIALPASTE_DIRPYREQUALIZER"))); - defringe = Gtk::manage (new Gtk::CheckButton (M("PARTIALPASTE_DEFRINGE"))); + sharpen = Gtk::manage (new Gtk::CheckButton (M ("PARTIALPASTE_SHARPENING"))); + sharpenedge = Gtk::manage (new Gtk::CheckButton (M ("PARTIALPASTE_SHARPENEDGE"))); + sharpenmicro = Gtk::manage (new Gtk::CheckButton (M ("PARTIALPASTE_SHARPENMICRO"))); + impden = Gtk::manage (new Gtk::CheckButton (M ("PARTIALPASTE_IMPULSEDENOISE"))); + dirpyreq = Gtk::manage (new Gtk::CheckButton (M ("PARTIALPASTE_DIRPYREQUALIZER"))); + defringe = Gtk::manage (new Gtk::CheckButton (M ("PARTIALPASTE_DEFRINGE"))); // options in wavelet: - wavelet = Gtk::manage (new Gtk::CheckButton (M("PARTIALPASTE_EQUALIZER"))); //TODO - rename to wavelet + wavelet = Gtk::manage (new Gtk::CheckButton (M ("PARTIALPASTE_EQUALIZER"))); //TODO - rename to wavelet // options in color: - icm = Gtk::manage (new Gtk::CheckButton (M("PARTIALPASTE_ICMSETTINGS"))); + icm = Gtk::manage (new Gtk::CheckButton (M ("PARTIALPASTE_ICMSETTINGS"))); //gam = Gtk::manage (new Gtk::CheckButton (M("PARTIALPASTE_ICMGAMMA"))); - vibrance = Gtk::manage (new Gtk::CheckButton (M("PARTIALPASTE_VIBRANCE"))); - chmixer = Gtk::manage (new Gtk::CheckButton (M("PARTIALPASTE_CHANNELMIXER"))); - blackwhite = Gtk::manage (new Gtk::CheckButton (M("PARTIALPASTE_CHANNELMIXERBW"))); - dirpyrden = Gtk::manage (new Gtk::CheckButton (M("PARTIALPASTE_DIRPYRDENOISE"))); - hsveq = Gtk::manage (new Gtk::CheckButton (M("PARTIALPASTE_HSVEQUALIZER"))); - filmSimulation = Gtk::manage (new Gtk::CheckButton (M("PARTIALPASTE_FILMSIMULATION")) ); - rgbcurves = Gtk::manage (new Gtk::CheckButton (M("PARTIALPASTE_RGBCURVES"))); - colortoning = Gtk::manage (new Gtk::CheckButton (M("PARTIALPASTE_COLORTONING"))); + vibrance = Gtk::manage (new Gtk::CheckButton (M ("PARTIALPASTE_VIBRANCE"))); + chmixer = Gtk::manage (new Gtk::CheckButton (M ("PARTIALPASTE_CHANNELMIXER"))); + blackwhite = Gtk::manage (new Gtk::CheckButton (M ("PARTIALPASTE_CHANNELMIXERBW"))); + dirpyrden = Gtk::manage (new Gtk::CheckButton (M ("PARTIALPASTE_DIRPYRDENOISE"))); + hsveq = Gtk::manage (new Gtk::CheckButton (M ("PARTIALPASTE_HSVEQUALIZER"))); + filmSimulation = Gtk::manage (new Gtk::CheckButton (M ("PARTIALPASTE_FILMSIMULATION")) ); + rgbcurves = Gtk::manage (new Gtk::CheckButton (M ("PARTIALPASTE_RGBCURVES"))); + colortoning = Gtk::manage (new Gtk::CheckButton (M ("PARTIALPASTE_COLORTONING"))); // options in lens: - distortion = Gtk::manage (new Gtk::CheckButton (M("PARTIALPASTE_DISTORTION"))); - cacorr = Gtk::manage (new Gtk::CheckButton (M("PARTIALPASTE_CACORRECTION"))); - vignetting = Gtk::manage (new Gtk::CheckButton (M("PARTIALPASTE_VIGNETTING"))); - lcp = Gtk::manage (new Gtk::CheckButton (M("PARTIALPASTE_LENSPROFILE"))); + distortion = Gtk::manage (new Gtk::CheckButton (M ("PARTIALPASTE_DISTORTION"))); + cacorr = Gtk::manage (new Gtk::CheckButton (M ("PARTIALPASTE_CACORRECTION"))); + vignetting = Gtk::manage (new Gtk::CheckButton (M ("PARTIALPASTE_VIGNETTING"))); + lcp = Gtk::manage (new Gtk::CheckButton (M ("PARTIALPASTE_LENSPROFILE"))); // options in composition: - coarserot = Gtk::manage (new Gtk::CheckButton (M("PARTIALPASTE_COARSETRANS"))); - finerot = Gtk::manage (new Gtk::CheckButton (M("PARTIALPASTE_ROTATION"))); - crop = Gtk::manage (new Gtk::CheckButton (M("PARTIALPASTE_CROP"))); - resize = Gtk::manage (new Gtk::CheckButton (M("PARTIALPASTE_RESIZE"))); - prsharpening = Gtk::manage (new Gtk::CheckButton (M("PARTIALPASTE_PRSHARPENING"))); - perspective = Gtk::manage (new Gtk::CheckButton (M("PARTIALPASTE_PERSPECTIVE"))); - commonTrans = Gtk::manage (new Gtk::CheckButton (M("PARTIALPASTE_COMMONTRANSFORMPARAMS"))); + coarserot = Gtk::manage (new Gtk::CheckButton (M ("PARTIALPASTE_COARSETRANS"))); + finerot = Gtk::manage (new Gtk::CheckButton (M ("PARTIALPASTE_ROTATION"))); + crop = Gtk::manage (new Gtk::CheckButton (M ("PARTIALPASTE_CROP"))); + resize = Gtk::manage (new Gtk::CheckButton (M ("PARTIALPASTE_RESIZE"))); + prsharpening = Gtk::manage (new Gtk::CheckButton (M ("PARTIALPASTE_PRSHARPENING"))); + perspective = Gtk::manage (new Gtk::CheckButton (M ("PARTIALPASTE_PERSPECTIVE"))); + commonTrans = Gtk::manage (new Gtk::CheckButton (M ("PARTIALPASTE_COMMONTRANSFORMPARAMS"))); // options in meta: - exifch = Gtk::manage (new Gtk::CheckButton (M("PARTIALPASTE_EXIFCHANGES"))); - iptc = Gtk::manage (new Gtk::CheckButton (M("PARTIALPASTE_IPTCINFO"))); + exifch = Gtk::manage (new Gtk::CheckButton (M ("PARTIALPASTE_EXIFCHANGES"))); + iptc = Gtk::manage (new Gtk::CheckButton (M ("PARTIALPASTE_IPTCINFO"))); // options in raw: - raw_expos = Gtk::manage (new Gtk::CheckButton (M("PARTIALPASTE_RAWEXPOS_LINEAR"))); - raw_preser = Gtk::manage (new Gtk::CheckButton (M("PARTIALPASTE_RAWEXPOS_PRESER"))); - raw_black = Gtk::manage (new Gtk::CheckButton (M("PARTIALPASTE_RAWEXPOS_BLACK"))); - raw_ca_autocorrect = Gtk::manage (new Gtk::CheckButton (M("PARTIALPASTE_RAWCACORR_AUTO"))); - raw_cared = Gtk::manage (new Gtk::CheckButton (M("PARTIALPASTE_RAWCACORR_CARED"))); - raw_cablue = Gtk::manage (new Gtk::CheckButton (M("PARTIALPASTE_RAWCACORR_CABLUE"))); - raw_hotpix_filt = Gtk::manage (new Gtk::CheckButton (M("PARTIALPASTE_PREPROCESS_HOTPIXFILT"))); - raw_deadpix_filt = Gtk::manage (new Gtk::CheckButton (M("PARTIALPASTE_PREPROCESS_DEADPIXFILT"))); - raw_linenoise = Gtk::manage (new Gtk::CheckButton (M("PARTIALPASTE_PREPROCESS_LINEDENOISE"))); - raw_greenthresh = Gtk::manage (new Gtk::CheckButton (M("PARTIALPASTE_PREPROCESS_GREENEQUIL"))); - raw_method = Gtk::manage (new Gtk::CheckButton (M("PARTIALPASTE_RAW_DMETHOD"))); - raw_ccSteps = Gtk::manage (new Gtk::CheckButton (M("PARTIALPASTE_RAW_FALSECOLOR"))); - raw_dcb_iterations = Gtk::manage (new Gtk::CheckButton (M("PARTIALPASTE_RAW_DCBITERATIONS"))); - raw_dcb_enhance = Gtk::manage (new Gtk::CheckButton (M("PARTIALPASTE_RAW_DCBENHANCE"))); + raw_expos = Gtk::manage (new Gtk::CheckButton (M ("PARTIALPASTE_RAWEXPOS_LINEAR"))); + raw_preser = Gtk::manage (new Gtk::CheckButton (M ("PARTIALPASTE_RAWEXPOS_PRESER"))); + raw_black = Gtk::manage (new Gtk::CheckButton (M ("PARTIALPASTE_RAWEXPOS_BLACK"))); + raw_ca_autocorrect = Gtk::manage (new Gtk::CheckButton (M ("PARTIALPASTE_RAWCACORR_AUTO"))); + raw_cared = Gtk::manage (new Gtk::CheckButton (M ("PARTIALPASTE_RAWCACORR_CARED"))); + raw_cablue = Gtk::manage (new Gtk::CheckButton (M ("PARTIALPASTE_RAWCACORR_CABLUE"))); + raw_hotpix_filt = Gtk::manage (new Gtk::CheckButton (M ("PARTIALPASTE_PREPROCESS_HOTPIXFILT"))); + raw_deadpix_filt = Gtk::manage (new Gtk::CheckButton (M ("PARTIALPASTE_PREPROCESS_DEADPIXFILT"))); + raw_linenoise = Gtk::manage (new Gtk::CheckButton (M ("PARTIALPASTE_PREPROCESS_LINEDENOISE"))); + raw_greenthresh = Gtk::manage (new Gtk::CheckButton (M ("PARTIALPASTE_PREPROCESS_GREENEQUIL"))); + raw_method = Gtk::manage (new Gtk::CheckButton (M ("PARTIALPASTE_RAW_DMETHOD"))); + raw_ccSteps = Gtk::manage (new Gtk::CheckButton (M ("PARTIALPASTE_RAW_FALSECOLOR"))); + raw_dcb_iterations = Gtk::manage (new Gtk::CheckButton (M ("PARTIALPASTE_RAW_DCBITERATIONS"))); + raw_dcb_enhance = Gtk::manage (new Gtk::CheckButton (M ("PARTIALPASTE_RAW_DCBENHANCE"))); //raw_all_enhance = Gtk::manage (new Gtk::CheckButton (M("PARTIALPASTE_RAW_ALLENHANCE"))); - raw_lmmse_iterations = Gtk::manage (new Gtk::CheckButton (M("PARTIALPASTE_RAW_LMMSEITERATIONS"))); + raw_lmmse_iterations = Gtk::manage (new Gtk::CheckButton (M ("PARTIALPASTE_RAW_LMMSEITERATIONS"))); - df_file = Gtk::manage (new Gtk::CheckButton (M("PARTIALPASTE_DARKFRAMEFILE"))); - df_AutoSelect = Gtk::manage (new Gtk::CheckButton (M("PARTIALPASTE_DARKFRAMEAUTOSELECT"))); - ff_file = Gtk::manage (new Gtk::CheckButton (M("PARTIALPASTE_FLATFIELDFILE"))); - ff_AutoSelect = Gtk::manage (new Gtk::CheckButton (M("PARTIALPASTE_FLATFIELDAUTOSELECT"))); - ff_BlurRadius = Gtk::manage (new Gtk::CheckButton (M("PARTIALPASTE_FLATFIELDBLURRADIUS"))); - ff_BlurType = Gtk::manage (new Gtk::CheckButton (M("PARTIALPASTE_FLATFIELDBLURTYPE"))); - ff_ClipControl = Gtk::manage (new Gtk::CheckButton (M("PARTIALPASTE_FLATFIELDCLIPCONTROL"))); + df_file = Gtk::manage (new Gtk::CheckButton (M ("PARTIALPASTE_DARKFRAMEFILE"))); + df_AutoSelect = Gtk::manage (new Gtk::CheckButton (M ("PARTIALPASTE_DARKFRAMEAUTOSELECT"))); + ff_file = Gtk::manage (new Gtk::CheckButton (M ("PARTIALPASTE_FLATFIELDFILE"))); + ff_AutoSelect = Gtk::manage (new Gtk::CheckButton (M ("PARTIALPASTE_FLATFIELDAUTOSELECT"))); + ff_BlurRadius = Gtk::manage (new Gtk::CheckButton (M ("PARTIALPASTE_FLATFIELDBLURRADIUS"))); + ff_BlurType = Gtk::manage (new Gtk::CheckButton (M ("PARTIALPASTE_FLATFIELDBLURTYPE"))); + ff_ClipControl = Gtk::manage (new Gtk::CheckButton (M ("PARTIALPASTE_FLATFIELDCLIPCONTROL"))); Gtk::VBox* vboxes[8]; Gtk::HSeparator* hseps[8]; for (int i = 0; i < 8; i++) { vboxes[i] = Gtk::manage (new Gtk::VBox ()); - vboxes[i]->set_name("PartialPasteGroupContainer"); + vboxes[i]->set_name ("PartialPasteGroupContainer"); hseps[i] = Gtk::manage (new Gtk::HSeparator ()); - hseps[i]->set_name("PartialPasteHeaderSep"); + hseps[i]->set_name ("PartialPasteHeaderSep"); } //BASIC @@ -146,6 +147,7 @@ PartialPasteDlg::PartialPasteDlg (const Glib::ustring &title, Gtk::Window* paren vboxes[0]->pack_start (*pcvignette, Gtk::PACK_SHRINK, 2); vboxes[0]->pack_start (*gradient, Gtk::PACK_SHRINK, 2); vboxes[0]->pack_start (*labcurve, Gtk::PACK_SHRINK, 2); + vboxes[0]->pack_start (*locallab, Gtk::PACK_SHRINK, 2); vboxes[0]->pack_start (*colorappearance, Gtk::PACK_SHRINK, 2); //DETAIL @@ -258,22 +260,22 @@ PartialPasteDlg::PartialPasteDlg (const Glib::ustring &title, Gtk::Window* paren Gtk::HBox* hbmain = Gtk::manage (new Gtk::HBox ()); hbmain->pack_start (*vbCol1); Gtk::VSeparator *vsep1 = Gtk::manage (new Gtk::VSeparator ()); - setExpandAlignProperties(vsep1, false, true, Gtk::ALIGN_CENTER, Gtk::ALIGN_FILL); + setExpandAlignProperties (vsep1, false, true, Gtk::ALIGN_CENTER, Gtk::ALIGN_FILL); hbmain->pack_start (*vsep1); hbmain->pack_start (*vbCol2); Gtk::VSeparator *vsep2 = Gtk::manage (new Gtk::VSeparator ()); - setExpandAlignProperties(vsep2, false, true, Gtk::ALIGN_CENTER, Gtk::ALIGN_FILL); + setExpandAlignProperties (vsep2, false, true, Gtk::ALIGN_CENTER, Gtk::ALIGN_FILL); hbmain->pack_start (*vsep2); hbmain->pack_start (*vbCol3); scrolledwindow = Gtk::manage ( new Gtk::ScrolledWindow() ); - scrolledwindow->set_name("PartialPaste"); - scrolledwindow->set_can_focus(true); - scrolledwindow->set_shadow_type(Gtk::SHADOW_NONE); - scrolledwindow->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); - scrolledwindow->property_window_placement().set_value(Gtk::CORNER_TOP_LEFT); + scrolledwindow->set_name ("PartialPaste"); + scrolledwindow->set_can_focus (true); + scrolledwindow->set_shadow_type (Gtk::SHADOW_NONE); + scrolledwindow->set_policy (Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); + scrolledwindow->property_window_placement().set_value (Gtk::CORNER_TOP_LEFT); - scrolledwindow->add(*hbmain); + scrolledwindow->add (*hbmain); Gtk::Dialog::get_content_area()->pack_start (*scrolledwindow, Gtk::PACK_EXPAND_WIDGET, 2);// TODO replace with get_content_area() with GTK upgrade @@ -282,89 +284,90 @@ PartialPasteDlg::PartialPasteDlg (const Glib::ustring &title, Gtk::Window* paren // This can be improved // there is currently no binding of subsettings to CheckButton 'everything' for its inconsistent status - everythingConn = everything->signal_toggled().connect (sigc::mem_fun(*this, &PartialPasteDlg::everythingToggled)); - basicConn = basic->signal_toggled().connect (sigc::mem_fun(*this, &PartialPasteDlg::basicToggled)); - detailConn = detail->signal_toggled().connect (sigc::mem_fun(*this, &PartialPasteDlg::detailToggled)); - colorConn = color->signal_toggled().connect (sigc::mem_fun(*this, &PartialPasteDlg::colorToggled)); - lensConn = lens->signal_toggled().connect (sigc::mem_fun(*this, &PartialPasteDlg::lensToggled)); - compositionConn = composition->signal_toggled().connect (sigc::mem_fun(*this, &PartialPasteDlg::compositionToggled)); - metaConn = meta->signal_toggled().connect (sigc::mem_fun(*this, &PartialPasteDlg::metaToggled)); - rawConn = raw->signal_toggled().connect (sigc::mem_fun(*this, &PartialPasteDlg::rawToggled)); - wavConn = wav->signal_toggled().connect (sigc::mem_fun(*this, &PartialPasteDlg::wavToggled)); + everythingConn = everything->signal_toggled().connect (sigc::mem_fun (*this, &PartialPasteDlg::everythingToggled)); + basicConn = basic->signal_toggled().connect (sigc::mem_fun (*this, &PartialPasteDlg::basicToggled)); + detailConn = detail->signal_toggled().connect (sigc::mem_fun (*this, &PartialPasteDlg::detailToggled)); + colorConn = color->signal_toggled().connect (sigc::mem_fun (*this, &PartialPasteDlg::colorToggled)); + lensConn = lens->signal_toggled().connect (sigc::mem_fun (*this, &PartialPasteDlg::lensToggled)); + compositionConn = composition->signal_toggled().connect (sigc::mem_fun (*this, &PartialPasteDlg::compositionToggled)); + metaConn = meta->signal_toggled().connect (sigc::mem_fun (*this, &PartialPasteDlg::metaToggled)); + rawConn = raw->signal_toggled().connect (sigc::mem_fun (*this, &PartialPasteDlg::rawToggled)); + wavConn = wav->signal_toggled().connect (sigc::mem_fun (*this, &PartialPasteDlg::wavToggled)); - wbConn = wb->signal_toggled().connect (sigc::bind (sigc::mem_fun(*basic, &Gtk::CheckButton::set_inconsistent), true)); - exposureConn = exposure->signal_toggled().connect (sigc::bind (sigc::mem_fun(*basic, &Gtk::CheckButton::set_inconsistent), true)); - shConn = sh->signal_toggled().connect (sigc::bind (sigc::mem_fun(*basic, &Gtk::CheckButton::set_inconsistent), true)); - epdConn = epd->signal_toggled().connect (sigc::bind (sigc::mem_fun(*basic, &Gtk::CheckButton::set_inconsistent), true)); - retinexConn = retinex->signal_toggled().connect (sigc::bind (sigc::mem_fun(*basic, &Gtk::CheckButton::set_inconsistent), true)); - pcvignetteConn = pcvignette->signal_toggled().connect (sigc::bind (sigc::mem_fun(*basic, &Gtk::CheckButton::set_inconsistent), true)); - gradientConn = gradient->signal_toggled().connect (sigc::bind (sigc::mem_fun(*basic, &Gtk::CheckButton::set_inconsistent), true)); - labcurveConn = labcurve->signal_toggled().connect (sigc::bind (sigc::mem_fun(*basic, &Gtk::CheckButton::set_inconsistent), true)); - colorappearanceConn = colorappearance->signal_toggled().connect (sigc::bind (sigc::mem_fun(*basic, &Gtk::CheckButton::set_inconsistent), true)); + wbConn = wb->signal_toggled().connect (sigc::bind (sigc::mem_fun (*basic, &Gtk::CheckButton::set_inconsistent), true)); + exposureConn = exposure->signal_toggled().connect (sigc::bind (sigc::mem_fun (*basic, &Gtk::CheckButton::set_inconsistent), true)); + shConn = sh->signal_toggled().connect (sigc::bind (sigc::mem_fun (*basic, &Gtk::CheckButton::set_inconsistent), true)); + epdConn = epd->signal_toggled().connect (sigc::bind (sigc::mem_fun (*basic, &Gtk::CheckButton::set_inconsistent), true)); + retinexConn = retinex->signal_toggled().connect (sigc::bind (sigc::mem_fun (*basic, &Gtk::CheckButton::set_inconsistent), true)); + pcvignetteConn = pcvignette->signal_toggled().connect (sigc::bind (sigc::mem_fun (*basic, &Gtk::CheckButton::set_inconsistent), true)); + gradientConn = gradient->signal_toggled().connect (sigc::bind (sigc::mem_fun (*basic, &Gtk::CheckButton::set_inconsistent), true)); + labcurveConn = labcurve->signal_toggled().connect (sigc::bind (sigc::mem_fun (*basic, &Gtk::CheckButton::set_inconsistent), true)); + locallabConn = locallab->signal_toggled().connect (sigc::bind (sigc::mem_fun (*basic, &Gtk::CheckButton::set_inconsistent), true)); + colorappearanceConn = colorappearance->signal_toggled().connect (sigc::bind (sigc::mem_fun (*basic, &Gtk::CheckButton::set_inconsistent), true)); - sharpenConn = sharpen->signal_toggled().connect (sigc::bind (sigc::mem_fun(*detail, &Gtk::CheckButton::set_inconsistent), true)); - gradsharpenConn = sharpenedge->signal_toggled().connect (sigc::bind (sigc::mem_fun(*detail, &Gtk::CheckButton::set_inconsistent), true)); - microcontrastConn = sharpenmicro->signal_toggled().connect (sigc::bind (sigc::mem_fun(*detail, &Gtk::CheckButton::set_inconsistent), true)); - impdenConn = impden->signal_toggled().connect (sigc::bind (sigc::mem_fun(*detail, &Gtk::CheckButton::set_inconsistent), true)); - dirpyrdenConn = dirpyrden->signal_toggled().connect (sigc::bind (sigc::mem_fun(*detail, &Gtk::CheckButton::set_inconsistent), true)); - dirpyreqConn = dirpyreq->signal_toggled().connect (sigc::bind (sigc::mem_fun(*detail, &Gtk::CheckButton::set_inconsistent), true)); - defringeConn = defringe->signal_toggled().connect (sigc::bind (sigc::mem_fun(*detail, &Gtk::CheckButton::set_inconsistent), true)); + sharpenConn = sharpen->signal_toggled().connect (sigc::bind (sigc::mem_fun (*detail, &Gtk::CheckButton::set_inconsistent), true)); + gradsharpenConn = sharpenedge->signal_toggled().connect (sigc::bind (sigc::mem_fun (*detail, &Gtk::CheckButton::set_inconsistent), true)); + microcontrastConn = sharpenmicro->signal_toggled().connect (sigc::bind (sigc::mem_fun (*detail, &Gtk::CheckButton::set_inconsistent), true)); + impdenConn = impden->signal_toggled().connect (sigc::bind (sigc::mem_fun (*detail, &Gtk::CheckButton::set_inconsistent), true)); + dirpyrdenConn = dirpyrden->signal_toggled().connect (sigc::bind (sigc::mem_fun (*detail, &Gtk::CheckButton::set_inconsistent), true)); + dirpyreqConn = dirpyreq->signal_toggled().connect (sigc::bind (sigc::mem_fun (*detail, &Gtk::CheckButton::set_inconsistent), true)); + defringeConn = defringe->signal_toggled().connect (sigc::bind (sigc::mem_fun (*detail, &Gtk::CheckButton::set_inconsistent), true)); - waveletConn = wavelet->signal_toggled().connect (sigc::bind (sigc::mem_fun(*wav, &Gtk::CheckButton::set_inconsistent), true)); + waveletConn = wavelet->signal_toggled().connect (sigc::bind (sigc::mem_fun (*wav, &Gtk::CheckButton::set_inconsistent), true)); - icmConn = icm->signal_toggled().connect (sigc::bind (sigc::mem_fun(*color, &Gtk::CheckButton::set_inconsistent), true)); + icmConn = icm->signal_toggled().connect (sigc::bind (sigc::mem_fun (*color, &Gtk::CheckButton::set_inconsistent), true)); //gamcsconn = gam->signal_toggled().connect (sigc::bind (sigc::mem_fun(*color, &Gtk::CheckButton::set_inconsistent), true)); - vibranceConn = vibrance->signal_toggled().connect (sigc::bind (sigc::mem_fun(*color, &Gtk::CheckButton::set_inconsistent), true)); - chmixerConn = chmixer->signal_toggled().connect (sigc::bind (sigc::mem_fun(*color, &Gtk::CheckButton::set_inconsistent), true)); - chmixerbwConn = blackwhite->signal_toggled().connect (sigc::bind (sigc::mem_fun(*color, &Gtk::CheckButton::set_inconsistent), true)); - hsveqConn = hsveq->signal_toggled().connect (sigc::bind (sigc::mem_fun(*color, &Gtk::CheckButton::set_inconsistent), true)); - filmSimulationConn = filmSimulation->signal_toggled().connect (sigc::bind (sigc::mem_fun(*color, &Gtk::CheckButton::set_inconsistent), true)); - rgbcurvesConn = rgbcurves->signal_toggled().connect (sigc::bind (sigc::mem_fun(*color, &Gtk::CheckButton::set_inconsistent), true)); - colortoningConn = colortoning->signal_toggled().connect (sigc::bind (sigc::mem_fun(*color, &Gtk::CheckButton::set_inconsistent), true)); + vibranceConn = vibrance->signal_toggled().connect (sigc::bind (sigc::mem_fun (*color, &Gtk::CheckButton::set_inconsistent), true)); + chmixerConn = chmixer->signal_toggled().connect (sigc::bind (sigc::mem_fun (*color, &Gtk::CheckButton::set_inconsistent), true)); + chmixerbwConn = blackwhite->signal_toggled().connect (sigc::bind (sigc::mem_fun (*color, &Gtk::CheckButton::set_inconsistent), true)); + hsveqConn = hsveq->signal_toggled().connect (sigc::bind (sigc::mem_fun (*color, &Gtk::CheckButton::set_inconsistent), true)); + filmSimulationConn = filmSimulation->signal_toggled().connect (sigc::bind (sigc::mem_fun (*color, &Gtk::CheckButton::set_inconsistent), true)); + rgbcurvesConn = rgbcurves->signal_toggled().connect (sigc::bind (sigc::mem_fun (*color, &Gtk::CheckButton::set_inconsistent), true)); + colortoningConn = colortoning->signal_toggled().connect (sigc::bind (sigc::mem_fun (*color, &Gtk::CheckButton::set_inconsistent), true)); - distortionConn = distortion->signal_toggled().connect (sigc::bind (sigc::mem_fun(*lens, &Gtk::CheckButton::set_inconsistent), true)); - cacorrConn = cacorr->signal_toggled().connect (sigc::bind (sigc::mem_fun(*lens, &Gtk::CheckButton::set_inconsistent), true)); - vignettingConn = vignetting->signal_toggled().connect (sigc::bind (sigc::mem_fun(*lens, &Gtk::CheckButton::set_inconsistent), true)); - lcpConn = lcp->signal_toggled().connect (sigc::bind (sigc::mem_fun(*lens, &Gtk::CheckButton::set_inconsistent), true)); + distortionConn = distortion->signal_toggled().connect (sigc::bind (sigc::mem_fun (*lens, &Gtk::CheckButton::set_inconsistent), true)); + cacorrConn = cacorr->signal_toggled().connect (sigc::bind (sigc::mem_fun (*lens, &Gtk::CheckButton::set_inconsistent), true)); + vignettingConn = vignetting->signal_toggled().connect (sigc::bind (sigc::mem_fun (*lens, &Gtk::CheckButton::set_inconsistent), true)); + lcpConn = lcp->signal_toggled().connect (sigc::bind (sigc::mem_fun (*lens, &Gtk::CheckButton::set_inconsistent), true)); - coarserotConn = coarserot->signal_toggled().connect (sigc::bind (sigc::mem_fun(*composition, &Gtk::CheckButton::set_inconsistent), true)); - finerotConn = finerot->signal_toggled().connect (sigc::bind (sigc::mem_fun(*composition, &Gtk::CheckButton::set_inconsistent), true)); - cropConn = crop->signal_toggled().connect (sigc::bind (sigc::mem_fun(*composition, &Gtk::CheckButton::set_inconsistent), true)); - resizeConn = resize->signal_toggled().connect (sigc::bind (sigc::mem_fun(*composition, &Gtk::CheckButton::set_inconsistent), true)); - prsharpeningConn = prsharpening->signal_toggled().connect (sigc::bind (sigc::mem_fun(*composition, &Gtk::CheckButton::set_inconsistent), true)); - perspectiveConn = perspective->signal_toggled().connect (sigc::bind (sigc::mem_fun(*composition, &Gtk::CheckButton::set_inconsistent), true)); - commonTransConn = commonTrans->signal_toggled().connect (sigc::bind (sigc::mem_fun(*composition, &Gtk::CheckButton::set_inconsistent), true)); + coarserotConn = coarserot->signal_toggled().connect (sigc::bind (sigc::mem_fun (*composition, &Gtk::CheckButton::set_inconsistent), true)); + finerotConn = finerot->signal_toggled().connect (sigc::bind (sigc::mem_fun (*composition, &Gtk::CheckButton::set_inconsistent), true)); + cropConn = crop->signal_toggled().connect (sigc::bind (sigc::mem_fun (*composition, &Gtk::CheckButton::set_inconsistent), true)); + resizeConn = resize->signal_toggled().connect (sigc::bind (sigc::mem_fun (*composition, &Gtk::CheckButton::set_inconsistent), true)); + prsharpeningConn = prsharpening->signal_toggled().connect (sigc::bind (sigc::mem_fun (*composition, &Gtk::CheckButton::set_inconsistent), true)); + perspectiveConn = perspective->signal_toggled().connect (sigc::bind (sigc::mem_fun (*composition, &Gtk::CheckButton::set_inconsistent), true)); + commonTransConn = commonTrans->signal_toggled().connect (sigc::bind (sigc::mem_fun (*composition, &Gtk::CheckButton::set_inconsistent), true)); - exifchConn = exifch->signal_toggled().connect (sigc::bind (sigc::mem_fun(*meta, &Gtk::CheckButton::set_inconsistent), true)); - iptcConn = iptc->signal_toggled().connect (sigc::bind (sigc::mem_fun(*meta, &Gtk::CheckButton::set_inconsistent), true)); + exifchConn = exifch->signal_toggled().connect (sigc::bind (sigc::mem_fun (*meta, &Gtk::CheckButton::set_inconsistent), true)); + iptcConn = iptc->signal_toggled().connect (sigc::bind (sigc::mem_fun (*meta, &Gtk::CheckButton::set_inconsistent), true)); - raw_methodConn = raw_method->signal_toggled().connect (sigc::bind (sigc::mem_fun(*raw, &Gtk::CheckButton::set_inconsistent), true)); - raw_ccStepsConn = raw_ccSteps->signal_toggled().connect (sigc::bind (sigc::mem_fun(*raw, &Gtk::CheckButton::set_inconsistent), true)); - raw_dcb_iterationsConn = raw_dcb_iterations->signal_toggled().connect (sigc::bind (sigc::mem_fun(*raw, &Gtk::CheckButton::set_inconsistent), true)); - raw_dcb_enhanceConn = raw_dcb_enhance->signal_toggled().connect (sigc::bind (sigc::mem_fun(*raw, &Gtk::CheckButton::set_inconsistent), true)); + raw_methodConn = raw_method->signal_toggled().connect (sigc::bind (sigc::mem_fun (*raw, &Gtk::CheckButton::set_inconsistent), true)); + raw_ccStepsConn = raw_ccSteps->signal_toggled().connect (sigc::bind (sigc::mem_fun (*raw, &Gtk::CheckButton::set_inconsistent), true)); + raw_dcb_iterationsConn = raw_dcb_iterations->signal_toggled().connect (sigc::bind (sigc::mem_fun (*raw, &Gtk::CheckButton::set_inconsistent), true)); + raw_dcb_enhanceConn = raw_dcb_enhance->signal_toggled().connect (sigc::bind (sigc::mem_fun (*raw, &Gtk::CheckButton::set_inconsistent), true)); //raw_all_enhanceConn = raw_all_enhance->signal_toggled().connect (sigc::bind (sigc::mem_fun(*raw, &Gtk::CheckButton::set_inconsistent), true)); - raw_lmmse_iterationsConn = raw_lmmse_iterations->signal_toggled().connect (sigc::bind (sigc::mem_fun(*raw, &Gtk::CheckButton::set_inconsistent), true)); + raw_lmmse_iterationsConn = raw_lmmse_iterations->signal_toggled().connect (sigc::bind (sigc::mem_fun (*raw, &Gtk::CheckButton::set_inconsistent), true)); - raw_exposConn = raw_expos->signal_toggled().connect (sigc::bind (sigc::mem_fun(*raw, &Gtk::CheckButton::set_inconsistent), true)); - raw_preserConn = raw_preser->signal_toggled().connect (sigc::bind (sigc::mem_fun(*raw, &Gtk::CheckButton::set_inconsistent), true)); - raw_blackConn = raw_black->signal_toggled().connect (sigc::bind (sigc::mem_fun(*raw, &Gtk::CheckButton::set_inconsistent), true)); - raw_ca_autocorrectConn = raw_ca_autocorrect->signal_toggled().connect (sigc::bind (sigc::mem_fun(*raw, &Gtk::CheckButton::set_inconsistent), true)); - raw_caredConn = raw_cared->signal_toggled().connect (sigc::bind (sigc::mem_fun(*raw, &Gtk::CheckButton::set_inconsistent), true)); - raw_cablueConn = raw_cablue->signal_toggled().connect (sigc::bind (sigc::mem_fun(*raw, &Gtk::CheckButton::set_inconsistent), true)); - raw_hotpix_filtConn = raw_hotpix_filt->signal_toggled().connect (sigc::bind (sigc::mem_fun(*raw, &Gtk::CheckButton::set_inconsistent), true)); - raw_deadpix_filtConn = raw_deadpix_filt->signal_toggled().connect (sigc::bind (sigc::mem_fun(*raw, &Gtk::CheckButton::set_inconsistent), true)); - raw_linenoiseConn = raw_linenoise->signal_toggled().connect (sigc::bind (sigc::mem_fun(*raw, &Gtk::CheckButton::set_inconsistent), true)); - raw_greenthreshConn = raw_greenthresh->signal_toggled().connect (sigc::bind (sigc::mem_fun(*raw, &Gtk::CheckButton::set_inconsistent), true)); - df_fileConn = df_file->signal_toggled().connect (sigc::bind (sigc::mem_fun(*raw, &Gtk::CheckButton::set_inconsistent), true)); - df_AutoSelectConn = df_AutoSelect->signal_toggled().connect (sigc::bind (sigc::mem_fun(*raw, &Gtk::CheckButton::set_inconsistent), true)); - ff_fileConn = ff_file->signal_toggled().connect (sigc::bind (sigc::mem_fun(*raw, &Gtk::CheckButton::set_inconsistent), true)); - ff_AutoSelectConn = ff_AutoSelect->signal_toggled().connect (sigc::bind (sigc::mem_fun(*raw, &Gtk::CheckButton::set_inconsistent), true)); - ff_BlurRadiusConn = ff_BlurRadius->signal_toggled().connect (sigc::bind (sigc::mem_fun(*raw, &Gtk::CheckButton::set_inconsistent), true)); - ff_BlurTypeConn = ff_BlurType->signal_toggled().connect (sigc::bind (sigc::mem_fun(*raw, &Gtk::CheckButton::set_inconsistent), true)); - ff_ClipControlConn = ff_ClipControl->signal_toggled().connect (sigc::bind (sigc::mem_fun(*raw, &Gtk::CheckButton::set_inconsistent), true)); + raw_exposConn = raw_expos->signal_toggled().connect (sigc::bind (sigc::mem_fun (*raw, &Gtk::CheckButton::set_inconsistent), true)); + raw_preserConn = raw_preser->signal_toggled().connect (sigc::bind (sigc::mem_fun (*raw, &Gtk::CheckButton::set_inconsistent), true)); + raw_blackConn = raw_black->signal_toggled().connect (sigc::bind (sigc::mem_fun (*raw, &Gtk::CheckButton::set_inconsistent), true)); + raw_ca_autocorrectConn = raw_ca_autocorrect->signal_toggled().connect (sigc::bind (sigc::mem_fun (*raw, &Gtk::CheckButton::set_inconsistent), true)); + raw_caredConn = raw_cared->signal_toggled().connect (sigc::bind (sigc::mem_fun (*raw, &Gtk::CheckButton::set_inconsistent), true)); + raw_cablueConn = raw_cablue->signal_toggled().connect (sigc::bind (sigc::mem_fun (*raw, &Gtk::CheckButton::set_inconsistent), true)); + raw_hotpix_filtConn = raw_hotpix_filt->signal_toggled().connect (sigc::bind (sigc::mem_fun (*raw, &Gtk::CheckButton::set_inconsistent), true)); + raw_deadpix_filtConn = raw_deadpix_filt->signal_toggled().connect (sigc::bind (sigc::mem_fun (*raw, &Gtk::CheckButton::set_inconsistent), true)); + raw_linenoiseConn = raw_linenoise->signal_toggled().connect (sigc::bind (sigc::mem_fun (*raw, &Gtk::CheckButton::set_inconsistent), true)); + raw_greenthreshConn = raw_greenthresh->signal_toggled().connect (sigc::bind (sigc::mem_fun (*raw, &Gtk::CheckButton::set_inconsistent), true)); + df_fileConn = df_file->signal_toggled().connect (sigc::bind (sigc::mem_fun (*raw, &Gtk::CheckButton::set_inconsistent), true)); + df_AutoSelectConn = df_AutoSelect->signal_toggled().connect (sigc::bind (sigc::mem_fun (*raw, &Gtk::CheckButton::set_inconsistent), true)); + ff_fileConn = ff_file->signal_toggled().connect (sigc::bind (sigc::mem_fun (*raw, &Gtk::CheckButton::set_inconsistent), true)); + ff_AutoSelectConn = ff_AutoSelect->signal_toggled().connect (sigc::bind (sigc::mem_fun (*raw, &Gtk::CheckButton::set_inconsistent), true)); + ff_BlurRadiusConn = ff_BlurRadius->signal_toggled().connect (sigc::bind (sigc::mem_fun (*raw, &Gtk::CheckButton::set_inconsistent), true)); + ff_BlurTypeConn = ff_BlurType->signal_toggled().connect (sigc::bind (sigc::mem_fun (*raw, &Gtk::CheckButton::set_inconsistent), true)); + ff_ClipControlConn = ff_ClipControl->signal_toggled().connect (sigc::bind (sigc::mem_fun (*raw, &Gtk::CheckButton::set_inconsistent), true)); - add_button (M("GENERAL_OK"), Gtk::RESPONSE_OK); - add_button (M("GENERAL_CANCEL"), Gtk::RESPONSE_CANCEL); + add_button (M ("GENERAL_OK"), Gtk::RESPONSE_OK); + add_button (M ("GENERAL_CANCEL"), Gtk::RESPONSE_CANCEL); set_response_sensitive (Gtk::RESPONSE_OK); set_default_response (Gtk::RESPONSE_OK); show_all_children (); @@ -385,14 +388,14 @@ void PartialPasteDlg::everythingToggled () everything->set_inconsistent (false); //toggle group headings - basic->set_active(everything->get_active()); - detail->set_active(everything->get_active()); - color->set_active(everything->get_active()); - lens->set_active(everything->get_active()); - composition->set_active(everything->get_active()); - meta->set_active(everything->get_active()); - raw->set_active(everything->get_active()); - wav->set_active(everything->get_active()); + basic->set_active (everything->get_active()); + detail->set_active (everything->get_active()); + color->set_active (everything->get_active()); + lens->set_active (everything->get_active()); + composition->set_active (everything->get_active()); + meta->set_active (everything->get_active()); + raw->set_active (everything->get_active()); + wav->set_active (everything->get_active()); //toggle group children PartialPasteDlg::basicToggled (); @@ -498,11 +501,12 @@ void PartialPasteDlg::basicToggled () wbConn.block (true); exposureConn.block (true); shConn.block (true); - epdConn.block(true); + epdConn.block (true); pcvignetteConn.block (true); gradientConn.block (true); labcurveConn.block (true); colorappearanceConn.block (true); + locallabConn.block (true); retinexConn.block (true); basic->set_inconsistent (false); @@ -516,6 +520,7 @@ void PartialPasteDlg::basicToggled () retinex->set_active (basic->get_active ()); labcurve->set_active (basic->get_active ()); colorappearance->set_active (basic->get_active ()); + locallab->set_active (basic->get_active ()); wbConn.block (false); exposureConn.block (false); @@ -524,8 +529,9 @@ void PartialPasteDlg::basicToggled () pcvignetteConn.block (false); gradientConn.block (false); retinexConn.block (false); - + labcurveConn.block (false); + locallabConn.block (false); colorappearanceConn.block (false); } @@ -533,8 +539,8 @@ void PartialPasteDlg::detailToggled () { sharpenConn.block (true); - gradsharpenConn.block(true); - microcontrastConn.block(true); + gradsharpenConn.block (true); + microcontrastConn.block (true); impdenConn.block (true); dirpyrdenConn.block (true); defringeConn.block (true); @@ -551,8 +557,8 @@ void PartialPasteDlg::detailToggled () dirpyreq->set_active (detail->get_active ()); sharpenConn.block (false); - gradsharpenConn.block(false); - microcontrastConn.block(false); + gradsharpenConn.block (false); + microcontrastConn.block (false); impdenConn.block (false); dirpyrdenConn.block (false); defringeConn.block (false); @@ -592,7 +598,7 @@ void PartialPasteDlg::colorToggled () hsveq->set_active (color->get_active ()); filmSimulation->set_active (color->get_active ()); rgbcurves->set_active (color->get_active ()); - colortoning->set_active(color->get_active ()); + colortoning->set_active (color->get_active ()); icmConn.block (false); //gamcsconn.block (false); @@ -679,7 +685,7 @@ void PartialPasteDlg::applyPaste (rtengine::procparams::ProcParams* dstPP, Param { ParamsEdited falsePE; // falsePE is a workaround to set a group of ParamsEdited to false - ParamsEdited filterPE(true); // Contains the initial information about the loaded values + ParamsEdited filterPE (true); // Contains the initial information about the loaded values if (srcPE) { filterPE = *srcPE; @@ -718,6 +724,10 @@ void PartialPasteDlg::applyPaste (rtengine::procparams::ProcParams* dstPP, Param filterPE.gradient = falsePE.gradient; } + if (!locallab->get_active ()) { + filterPE.locallab = falsePE.locallab; + } + if (!labcurve->get_active ()) { filterPE.labCurve = falsePE.labCurve; } @@ -950,6 +960,6 @@ void PartialPasteDlg::applyPaste (rtengine::procparams::ProcParams* dstPP, Param } // Apply the filter! - filterPE.combine(*dstPP, *srcPP, true); + filterPE.combine (*dstPP, *srcPP, true); } diff --git a/rtgui/partialpastedlg.h b/rtgui/partialpastedlg.h index 99249eefd..ad18e3645 100644 --- a/rtgui/partialpastedlg.h +++ b/rtgui/partialpastedlg.h @@ -51,6 +51,7 @@ public: Gtk::CheckButton* gradient; Gtk::CheckButton* labcurve; Gtk::CheckButton* colorappearance; + Gtk::CheckButton* locallab; // options in detail: Gtk::CheckButton* sharpen; @@ -122,7 +123,7 @@ public: sigc::connection everythingConn, basicConn, detailConn, colorConn, lensConn, compositionConn, metaConn, rawConn, wavConn; - sigc::connection wbConn, exposureConn, shConn, pcvignetteConn, gradientConn, labcurveConn, colorappearanceConn; + sigc::connection wbConn, exposureConn, shConn, pcvignetteConn, gradientConn, labcurveConn, colorappearanceConn, locallabConn; sigc::connection sharpenConn, gradsharpenConn, microcontrastConn, impdenConn, dirpyrdenConn, defringeConn, epdConn, dirpyreqConn, waveletConn, retinexConn; sigc::connection vibranceConn, chmixerConn, hsveqConn, rgbcurvesConn, chmixerbwConn, colortoningConn, filmSimulationConn; sigc::connection distortionConn, cacorrConn, vignettingConn, lcpConn; diff --git a/rtgui/preferences.cc b/rtgui/preferences.cc index 15c6e60c8..0e5b22d74 100644 --- a/rtgui/preferences.cc +++ b/rtgui/preferences.cc @@ -36,13 +36,13 @@ Glib::RefPtr themecss; Glib::RefPtr fontcss; Preferences::Preferences (RTWindow *rtwindow) - : Gtk::Dialog (M("MAIN_BUTTON_PREFERENCES"), *rtwindow, true) + : Gtk::Dialog (M ("MAIN_BUTTON_PREFERENCES"), *rtwindow, true) , splash (nullptr) , rprofiles (nullptr) , iprofiles (nullptr) , parent (rtwindow) { - regex = Glib::Regex::create(THEMEREGEXSTR, Glib::RegexCompileFlags::REGEX_CASELESS); + regex = Glib::Regex::create (THEMEREGEXSTR, Glib::RegexCompileFlags::REGEX_CASELESS); moptions.copyFrom (&options); @@ -59,7 +59,7 @@ Preferences::Preferences (RTWindow *rtwindow) Gtk::Box* mainBox = get_content_area (); //GTK318 #if GTK_MAJOR_VERSION == 3 && GTK_MINOR_VERSION < 20 - mainBox->set_spacing(8); + mainBox->set_spacing (8); #endif //GTK318 //set_has_separator (false); @@ -68,31 +68,31 @@ Preferences::Preferences (RTWindow *rtwindow) nb->set_name ("PrefNotebook"); mainBox->pack_start (*nb); - Gtk::Button* about = Gtk::manage (new Gtk::Button (M("GENERAL_ABOUT"))); - Gtk::Button* ok = Gtk::manage (new Gtk::Button (M("GENERAL_OK"))); - Gtk::Button* cancel = Gtk::manage (new Gtk::Button (M("GENERAL_CANCEL"))); + Gtk::Button* about = Gtk::manage (new Gtk::Button (M ("GENERAL_ABOUT"))); + Gtk::Button* ok = Gtk::manage (new Gtk::Button (M ("GENERAL_OK"))); + Gtk::Button* cancel = Gtk::manage (new Gtk::Button (M ("GENERAL_CANCEL"))); - about->signal_clicked().connect( sigc::mem_fun(*this, &Preferences::aboutPressed) ); - ok->signal_clicked().connect( sigc::mem_fun(*this, &Preferences::okPressed) ); - cancel->signal_clicked().connect( sigc::mem_fun(*this, &Preferences::cancelPressed) ); + about->signal_clicked().connect ( sigc::mem_fun (*this, &Preferences::aboutPressed) ); + ok->signal_clicked().connect ( sigc::mem_fun (*this, &Preferences::okPressed) ); + cancel->signal_clicked().connect ( sigc::mem_fun (*this, &Preferences::cancelPressed) ); get_action_area()->pack_start (*about); get_action_area()->pack_end (*ok); get_action_area()->pack_end (*cancel); - nb->append_page (*getGeneralPanel(), M("PREFERENCES_TAB_GENERAL")); - nb->append_page (*getProcParamsPanel(), M("PREFERENCES_TAB_IMPROC")); - nb->append_page (*getFileBrowserPanel(), M("PREFERENCES_TAB_BROWSER")); - nb->append_page (*getColorManagementPanel(), M("PREFERENCES_TAB_COLORMGR")); - nb->append_page (*getBatchProcPanel(), M("PREFERENCES_BATCH_PROCESSING")); - nb->append_page (*getPerformancePanel(), M("PREFERENCES_TAB_PERFORMANCE")); + nb->append_page (*getGeneralPanel(), M ("PREFERENCES_TAB_GENERAL")); + nb->append_page (*getProcParamsPanel(), M ("PREFERENCES_TAB_IMPROC")); + nb->append_page (*getFileBrowserPanel(), M ("PREFERENCES_TAB_BROWSER")); + nb->append_page (*getColorManagementPanel(), M ("PREFERENCES_TAB_COLORMGR")); + nb->append_page (*getBatchProcPanel(), M ("PREFERENCES_BATCH_PROCESSING")); + nb->append_page (*getPerformancePanel(), M ("PREFERENCES_TAB_PERFORMANCE")); // Sounds only on Windows and Linux #if defined(WIN32) || defined(__linux__) - nb->append_page (*getSoundPanel(), M("PREFERENCES_TAB_SOUND")); + nb->append_page (*getSoundPanel(), M ("PREFERENCES_TAB_SOUND")); #endif nb->set_current_page (0); - profileStore.addListener(this); + profileStore.addListener (this); fillPreferences (); @@ -103,20 +103,21 @@ Preferences::Preferences (RTWindow *rtwindow) Preferences::~Preferences () { - profileStore.removeListener(this); - get_size(options.preferencesWidth, options.preferencesHeight); + profileStore.removeListener (this); + get_size (options.preferencesWidth, options.preferencesHeight); } -int Preferences::getThemeRowNumber(Glib::ustring& longThemeFName) +int Preferences::getThemeRowNumber (Glib::ustring& longThemeFName) { - if (regex->match(longThemeFName + ".css", matchInfo)) { - for (size_t i=0 ; imatch (longThemeFName + ".css", matchInfo)) { + for (size_t i = 0 ; i < themeFNames.size(); ++i) { + if (themeFNames.at (i).longFName == longThemeFName) { return (int)i; } } } + return -1; } @@ -127,10 +128,10 @@ Gtk::Widget* Preferences::getBatchProcPanel () Gtk::ScrolledWindow* behscrollw = Gtk::manage (new Gtk::ScrolledWindow ()); behscrollw->set_policy (Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); - behscrollw->set_size_request(-1, 60); - Gtk::VBox* vbbeh = Gtk::manage( new Gtk::VBox () ); + behscrollw->set_size_request (-1, 60); + Gtk::VBox* vbbeh = Gtk::manage ( new Gtk::VBox () ); vbbeh->pack_start (*behscrollw, Gtk::PACK_EXPAND_WIDGET); - Gtk::Frame* behFrame = Gtk::manage (new Gtk::Frame (M("PREFERENCES_BEHAVIOR"))); + Gtk::Frame* behFrame = Gtk::manage (new Gtk::Frame (M ("PREFERENCES_BEHAVIOR"))); behFrame->add (*vbbeh); //mvbpp->pack_start (*behFrame); mvbpp->pack_start (*behFrame, Gtk::PACK_EXPAND_WIDGET, 4); @@ -140,25 +141,25 @@ Gtk::Widget* Preferences::getBatchProcPanel () behModel = Gtk::TreeStore::create (behavColumns); behTreeView->set_model (behModel); - behTreeView->append_column (M("PREFERENCES_PROPERTY"), behavColumns.label); - behTreeView->append_column_editable (M("PREFERENCES_ADD"), behavColumns.badd); - behTreeView->append_column_editable (M("PREFERENCES_SET"), behavColumns.bset); + behTreeView->append_column (M ("PREFERENCES_PROPERTY"), behavColumns.label); + behTreeView->append_column_editable (M ("PREFERENCES_ADD"), behavColumns.badd); + behTreeView->append_column_editable (M ("PREFERENCES_SET"), behavColumns.bset); Gtk::CellRendererToggle* cr_add = static_cast (behTreeView->get_column (1)->get_first_cell()); Gtk::CellRendererToggle* cr_set = static_cast (behTreeView->get_column (2)->get_first_cell()); cr_add->set_radio (true); - cr_add->set_property("xalign", 0.0f); + cr_add->set_property ("xalign", 0.0f); sigc::connection addc = cr_add->signal_toggled().connect (sigc::mem_fun (*this, &Preferences::behAddRadioToggled)); cr_set->set_radio (true); - cr_set->set_property("xalign", 0.0f); + cr_set->set_property ("xalign", 0.0f); sigc::connection setc = cr_set->signal_toggled().connect (sigc::mem_fun (*this, &Preferences::behSetRadioToggled)); behTreeView->get_column (1)->add_attribute (*cr_add, "visible", behavColumns.visible); - behTreeView->get_column (1)->set_sizing(Gtk::TREE_VIEW_COLUMN_FIXED); + behTreeView->get_column (1)->set_sizing (Gtk::TREE_VIEW_COLUMN_FIXED); behTreeView->get_column (1)->set_fixed_width (50); behTreeView->get_column (2)->add_attribute (*cr_set, "visible", behavColumns.visible); - behTreeView->get_column (2)->set_sizing(Gtk::TREE_VIEW_COLUMN_FIXED); + behTreeView->get_column (2)->set_sizing (Gtk::TREE_VIEW_COLUMN_FIXED); behTreeView->get_column (2)->set_fixed_width (50); // fill model @@ -168,215 +169,234 @@ Gtk::Widget* Preferences::getBatchProcPanel () * The TRUE/FALSE values of appendBehavList are replaced by the one defined in options.cc, */ mi = behModel->append (); - mi->set_value (behavColumns.label, M("TP_EXPOSURE_LABEL")); - appendBehavList (mi, M("TP_EXPOSURE_EXPCOMP"), ADDSET_TC_EXPCOMP, false); - appendBehavList (mi, M("TP_EXPOSURE_COMPRHIGHLIGHTS"), ADDSET_TC_HLCOMPAMOUNT, false); - appendBehavList (mi, M("TP_EXPOSURE_COMPRHIGHLIGHTSTHRESHOLD"), ADDSET_TC_HLCOMPTHRESH, false); - appendBehavList (mi, M("TP_EXPOSURE_BLACKLEVEL"), ADDSET_TC_BLACKLEVEL, false); - appendBehavList (mi, M("TP_EXPOSURE_COMPRSHADOWS"), ADDSET_TC_SHCOMP, false); - appendBehavList (mi, M("TP_EXPOSURE_BRIGHTNESS"), ADDSET_TC_BRIGHTNESS, false); - appendBehavList (mi, M("TP_EXPOSURE_CONTRAST"), ADDSET_TC_CONTRAST, false); - appendBehavList (mi, M("TP_EXPOSURE_SATURATION"), ADDSET_TC_SATURATION, false); + mi->set_value (behavColumns.label, M ("TP_EXPOSURE_LABEL")); + appendBehavList (mi, M ("TP_EXPOSURE_EXPCOMP"), ADDSET_TC_EXPCOMP, false); + appendBehavList (mi, M ("TP_EXPOSURE_COMPRHIGHLIGHTS"), ADDSET_TC_HLCOMPAMOUNT, false); + appendBehavList (mi, M ("TP_EXPOSURE_COMPRHIGHLIGHTSTHRESHOLD"), ADDSET_TC_HLCOMPTHRESH, false); + appendBehavList (mi, M ("TP_EXPOSURE_BLACKLEVEL"), ADDSET_TC_BLACKLEVEL, false); + appendBehavList (mi, M ("TP_EXPOSURE_COMPRSHADOWS"), ADDSET_TC_SHCOMP, false); + appendBehavList (mi, M ("TP_EXPOSURE_BRIGHTNESS"), ADDSET_TC_BRIGHTNESS, false); + appendBehavList (mi, M ("TP_EXPOSURE_CONTRAST"), ADDSET_TC_CONTRAST, false); + appendBehavList (mi, M ("TP_EXPOSURE_SATURATION"), ADDSET_TC_SATURATION, false); mi = behModel->append (); - mi->set_value (behavColumns.label, M("TP_RETINEX_LABEL")); - appendBehavList (mi, M("TP_RETINEX_STRENGTH"), ADDSET_RETI_STR, false); - appendBehavList (mi, M("TP_RETINEX_NEIGHBOR"), ADDSET_RETI_NEIGH, false); - appendBehavList (mi, M("TP_RETINEX_VARIANCE"), ADDSET_RETI_VART, false); - appendBehavList (mi, M("TP_RETINEX_GAMMA"), ADDSET_RETI_GAM, false); - appendBehavList (mi, M("TP_RETINEX_SLOPE"), ADDSET_RETI_SLO, false); - appendBehavList (mi, M("TP_RETINEX_GAIN"), ADDSET_RETI_GAIN, false); - appendBehavList (mi, M("TP_RETINEX_OFFSET"), ADDSET_RETI_OFFS, false); - appendBehavList (mi, M("TP_RETINEX_THRESHOLD"), ADDSET_RETI_LIMD, false); + mi->set_value (behavColumns.label, M ("TP_RETINEX_LABEL")); + appendBehavList (mi, M ("TP_RETINEX_STRENGTH"), ADDSET_RETI_STR, false); + appendBehavList (mi, M ("TP_RETINEX_NEIGHBOR"), ADDSET_RETI_NEIGH, false); + appendBehavList (mi, M ("TP_RETINEX_VARIANCE"), ADDSET_RETI_VART, false); + appendBehavList (mi, M ("TP_RETINEX_GAMMA"), ADDSET_RETI_GAM, false); + appendBehavList (mi, M ("TP_RETINEX_SLOPE"), ADDSET_RETI_SLO, false); + appendBehavList (mi, M ("TP_RETINEX_GAIN"), ADDSET_RETI_GAIN, false); + appendBehavList (mi, M ("TP_RETINEX_OFFSET"), ADDSET_RETI_OFFS, false); + appendBehavList (mi, M ("TP_RETINEX_THRESHOLD"), ADDSET_RETI_LIMD, false); mi = behModel->append (); - mi->set_value (behavColumns.label, M("TP_SHADOWSHLIGHTS_LABEL")); - appendBehavList (mi, M("TP_SHADOWSHLIGHTS_HIGHLIGHTS"), ADDSET_SH_HIGHLIGHTS, false); - appendBehavList (mi, M("TP_SHADOWSHLIGHTS_SHADOWS"), ADDSET_SH_SHADOWS, false); - appendBehavList (mi, M("TP_SHADOWSHLIGHTS_LOCALCONTR"), ADDSET_SH_LOCALCONTRAST, false); + mi->set_value (behavColumns.label, M ("TP_SHADOWSHLIGHTS_LABEL")); + appendBehavList (mi, M ("TP_SHADOWSHLIGHTS_HIGHLIGHTS"), ADDSET_SH_HIGHLIGHTS, false); + appendBehavList (mi, M ("TP_SHADOWSHLIGHTS_SHADOWS"), ADDSET_SH_SHADOWS, false); + appendBehavList (mi, M ("TP_SHADOWSHLIGHTS_LOCALCONTR"), ADDSET_SH_LOCALCONTRAST, false); mi = behModel->append (); - mi->set_value (behavColumns.label, M("TP_LABCURVE_LABEL")); - appendBehavList (mi, M("TP_LABCURVE_BRIGHTNESS"), ADDSET_LC_BRIGHTNESS, false); - appendBehavList (mi, M("TP_LABCURVE_CONTRAST"), ADDSET_LC_CONTRAST, false); - appendBehavList (mi, M("TP_LABCURVE_CHROMATICITY"), ADDSET_LC_CHROMATICITY, false); + mi->set_value (behavColumns.label, M ("TP_LABCURVE_LABEL")); + appendBehavList (mi, M ("TP_LABCURVE_BRIGHTNESS"), ADDSET_LC_BRIGHTNESS, false); + appendBehavList (mi, M ("TP_LABCURVE_CONTRAST"), ADDSET_LC_CONTRAST, false); + appendBehavList (mi, M ("TP_LABCURVE_CHROMATICITY"), ADDSET_LC_CHROMATICITY, false); mi = behModel->append (); - mi->set_value (behavColumns.label, M("TP_SHARPENING_LABEL")); - appendBehavList (mi, M("TP_SHARPENING_AMOUNT"), ADDSET_SHARP_AMOUNT, false); + mi->set_value (behavColumns.label, M ("TP_SHARPENING_LABEL")); + appendBehavList (mi, M ("TP_SHARPENING_AMOUNT"), ADDSET_SHARP_AMOUNT, false); mi = behModel->append (); - mi->set_value (behavColumns.label, M("TP_SHARPENEDGE_LABEL")); - appendBehavList (mi, M("TP_SHARPENEDGE_PASSES"), ADDSET_SHARPENEDGE_PASS, false); - appendBehavList (mi, M("TP_SHARPENEDGE_AMOUNT"), ADDSET_SHARPENEDGE_AMOUNT, false); + + mi->set_value (behavColumns.label, M ("TP_LOCALLAB_LABEL")); + // appendBehavList (mi, M("TP_LOCALLAB_DEGREE"), ADDSET_LOCALLAB_DEGREE, false); + appendBehavList (mi, M ("TP_LOCAL_HEIGHT"), ADDSET_LOCALLAB_LOCY, false); + appendBehavList (mi, M ("TP_LOCAL_WIDTH"), ADDSET_LOCALLAB_LOCX, false); + appendBehavList (mi, M ("TP_LOCAL_HEIGHT_T"), ADDSET_LOCALLAB_LOCYT, false); + appendBehavList (mi, M ("TP_LOCAL_WIDTH_L"), ADDSET_LOCALLAB_LOCXL, false); + appendBehavList (mi, M ("TP_LOCALLAB_CENTER_X") + ", " + M ("TP_LOCALLAB_CENTER_Y"), ADDSET_LOCALLAB_CENTER, false); + appendBehavList (mi, M ("TP_LOCALLAB_LIGHTNESS"), ADDSET_LOCALLAB_LIGHTNESS, false); + appendBehavList (mi, M ("TP_LOCALLAB_CONTRAST"), ADDSET_LOCALLAB_CONTRAST, false); + appendBehavList (mi, M ("TP_LOCALLAB_CHROMA"), ADDSET_LOCALLAB_CHROMA, false); + appendBehavList (mi, M ("TP_LOCALLAB_SENSI"), ADDSET_LOCALLAB_SENSI, false); + appendBehavList (mi, M ("TP_LOCALLAB_RADIUS"), ADDSET_LOCALLAB_RADIUS, false); + appendBehavList (mi, M ("TP_LOCALLAB_STRENGTH"), ADDSET_LOCALLAB_STRENGTH, false); + appendBehavList (mi, M ("TP_LOCALLAB_TRANSIT"), ADDSET_LOCALLAB_TRANSIT, false); + + mi = behModel->append (); - mi->set_value (behavColumns.label, M("TP_SHARPENMICRO_LABEL")); - appendBehavList (mi, M("TP_SHARPENMICRO_AMOUNT"), ADDSET_SHARPENMICRO_AMOUNT, false); - appendBehavList (mi, M("TP_SHARPENMICRO_UNIFORMITY"), ADDSET_SHARPENMICRO_UNIFORMITY, false); + mi->set_value (behavColumns.label, M ("TP_SHARPENEDGE_LABEL")); + appendBehavList (mi, M ("TP_SHARPENEDGE_PASSES"), ADDSET_SHARPENEDGE_PASS, false); + appendBehavList (mi, M ("TP_SHARPENEDGE_AMOUNT"), ADDSET_SHARPENEDGE_AMOUNT, false); mi = behModel->append (); - mi->set_value (behavColumns.label, M("TP_DIRPYRDENOISE_LABEL")); + mi->set_value (behavColumns.label, M ("TP_SHARPENMICRO_LABEL")); + appendBehavList (mi, M ("TP_SHARPENMICRO_AMOUNT"), ADDSET_SHARPENMICRO_AMOUNT, false); + appendBehavList (mi, M ("TP_SHARPENMICRO_UNIFORMITY"), ADDSET_SHARPENMICRO_UNIFORMITY, false); + + mi = behModel->append (); + mi->set_value (behavColumns.label, M ("TP_DIRPYRDENOISE_LABEL")); // appendBehavList (mi, M("TP_DIRPYRDENOISE_LUMA")+", "+M("TP_DIRPYRDENOISE_CHROMA"), ADDSET_DIRPYRDN_CHLUM, true); - appendBehavList (mi, M("TP_DIRPYRDENOISE_LUMA"), ADDSET_DIRPYRDN_LUMA, true); - appendBehavList (mi, M("TP_DIRPYRDENOISE_LDETAIL"), ADDSET_DIRPYRDN_LUMDET, true); - appendBehavList (mi, M("TP_DIRPYRDENOISE_CHROMA"), ADDSET_DIRPYRDN_CHROMA, true); - appendBehavList (mi, M("TP_DIRPYRDENOISE_RED"), ADDSET_DIRPYRDN_CHROMARED, true); - appendBehavList (mi, M("TP_DIRPYRDENOISE_BLUE"), ADDSET_DIRPYRDN_CHROMABLUE, true); - appendBehavList (mi, M("TP_DIRPYRDENOISE_GAMMA"), ADDSET_DIRPYRDN_GAMMA, true); - appendBehavList (mi, M("TP_DIRPYRDENOISE_PASSES"), ADDSET_DIRPYRDN_PASSES, true); + appendBehavList (mi, M ("TP_DIRPYRDENOISE_LUMA"), ADDSET_DIRPYRDN_LUMA, true); + appendBehavList (mi, M ("TP_DIRPYRDENOISE_LDETAIL"), ADDSET_DIRPYRDN_LUMDET, true); + appendBehavList (mi, M ("TP_DIRPYRDENOISE_CHROMA"), ADDSET_DIRPYRDN_CHROMA, true); + appendBehavList (mi, M ("TP_DIRPYRDENOISE_RED"), ADDSET_DIRPYRDN_CHROMARED, true); + appendBehavList (mi, M ("TP_DIRPYRDENOISE_BLUE"), ADDSET_DIRPYRDN_CHROMABLUE, true); + appendBehavList (mi, M ("TP_DIRPYRDENOISE_GAMMA"), ADDSET_DIRPYRDN_GAMMA, true); + appendBehavList (mi, M ("TP_DIRPYRDENOISE_PASSES"), ADDSET_DIRPYRDN_PASSES, true); mi = behModel->append (); - mi->set_value (behavColumns.label, M("TP_WBALANCE_LABEL")); - appendBehavList (mi, M("TP_WBALANCE_TEMPERATURE"), ADDSET_WB_TEMPERATURE, true); - appendBehavList (mi, M("TP_WBALANCE_GREEN"), ADDSET_WB_GREEN, true); - appendBehavList (mi, M("TP_WBALANCE_EQBLUERED"), ADDSET_WB_EQUAL, true); + mi->set_value (behavColumns.label, M ("TP_WBALANCE_LABEL")); + appendBehavList (mi, M ("TP_WBALANCE_TEMPERATURE"), ADDSET_WB_TEMPERATURE, true); + appendBehavList (mi, M ("TP_WBALANCE_GREEN"), ADDSET_WB_GREEN, true); + appendBehavList (mi, M ("TP_WBALANCE_EQBLUERED"), ADDSET_WB_EQUAL, true); mi = behModel->append (); - mi->set_value (behavColumns.label, M("TP_COLORAPP_LABEL")); - appendBehavList (mi, M("TP_COLORAPP_CIECAT_DEGREE"), ADDSET_CAT_DEGREE, true); - appendBehavList (mi, M("TP_COLORAPP_ADAPTSCENE"), ADDSET_CAT_ADAPTSCENE, true); - appendBehavList (mi, M("TP_COLORAPP_LIGHT"), ADDSET_CAT_LIGHT, true); - appendBehavList (mi, M("TP_COLORAPP_BRIGHT"), ADDSET_CAT_BRIGHT, true); - appendBehavList (mi, M("TP_COLORAPP_CHROMA"), ADDSET_CAT_CHROMA, true); - appendBehavList (mi, M("TP_COLORAPP_RSTPRO"), ADDSET_CAT_RSTPRO, true); - appendBehavList (mi, M("TP_COLORAPP_CONTRAST"), ADDSET_CAT_CONTRAST, true); - appendBehavList (mi, M("TP_COLORAPP_CONTRAST_Q"), ADDSET_CAT_CONTRAST_Q, true); - appendBehavList (mi, M("TP_COLORAPP_CHROMA_S"), ADDSET_CAT_CHROMA_S, true); - appendBehavList (mi, M("TP_COLORAPP_CHROMA_M"), ADDSET_CAT_CHROMA_M, true); - appendBehavList (mi, M("TP_COLORAPP_HUE"), ADDSET_CAT_HUE, true); - appendBehavList (mi, M("TP_COLORAPP_ADAPTVIEWING"), ADDSET_CAT_ADAPTVIEWING, true); - appendBehavList (mi, M("TP_COLORAPP_BADPIXSL"), ADDSET_CAT_BADPIX, true); + mi->set_value (behavColumns.label, M ("TP_COLORAPP_LABEL")); + appendBehavList (mi, M ("TP_COLORAPP_CIECAT_DEGREE"), ADDSET_CAT_DEGREE, true); + appendBehavList (mi, M ("TP_COLORAPP_ADAPTSCENE"), ADDSET_CAT_ADAPTSCENE, true); + appendBehavList (mi, M ("TP_COLORAPP_LIGHT"), ADDSET_CAT_LIGHT, true); + appendBehavList (mi, M ("TP_COLORAPP_BRIGHT"), ADDSET_CAT_BRIGHT, true); + appendBehavList (mi, M ("TP_COLORAPP_CHROMA"), ADDSET_CAT_CHROMA, true); + appendBehavList (mi, M ("TP_COLORAPP_RSTPRO"), ADDSET_CAT_RSTPRO, true); + appendBehavList (mi, M ("TP_COLORAPP_CONTRAST"), ADDSET_CAT_CONTRAST, true); + appendBehavList (mi, M ("TP_COLORAPP_CONTRAST_Q"), ADDSET_CAT_CONTRAST_Q, true); + appendBehavList (mi, M ("TP_COLORAPP_CHROMA_S"), ADDSET_CAT_CHROMA_S, true); + appendBehavList (mi, M ("TP_COLORAPP_CHROMA_M"), ADDSET_CAT_CHROMA_M, true); + appendBehavList (mi, M ("TP_COLORAPP_HUE"), ADDSET_CAT_HUE, true); + appendBehavList (mi, M ("TP_COLORAPP_ADAPTVIEWING"), ADDSET_CAT_ADAPTVIEWING, true); + appendBehavList (mi, M ("TP_COLORAPP_BADPIXSL"), ADDSET_CAT_BADPIX, true); mi = behModel->append (); - mi->set_value (behavColumns.label, M("TP_VIBRANCE_LABEL")); - appendBehavList (mi, M("TP_VIBRANCE_PASTELS"), ADDSET_VIBRANCE_PASTELS, false); - appendBehavList (mi, M("TP_VIBRANCE_SATURATED"), ADDSET_VIBRANCE_SATURATED, false); + mi->set_value (behavColumns.label, M ("TP_VIBRANCE_LABEL")); + appendBehavList (mi, M ("TP_VIBRANCE_PASTELS"), ADDSET_VIBRANCE_PASTELS, false); + appendBehavList (mi, M ("TP_VIBRANCE_SATURATED"), ADDSET_VIBRANCE_SATURATED, false); mi = behModel->append (); - mi->set_value (behavColumns.label, M("TP_GAMMA_OUTPUT")); - appendBehavList (mi, M("TP_GAMMA_CURV"), ADDSET_FREE_OUPUT_GAMMA, false); - appendBehavList (mi, M("TP_GAMMA_SLOP"), ADDSET_FREE_OUTPUT_SLOPE, false); + mi->set_value (behavColumns.label, M ("TP_GAMMA_OUTPUT")); + appendBehavList (mi, M ("TP_GAMMA_CURV"), ADDSET_FREE_OUPUT_GAMMA, false); + appendBehavList (mi, M ("TP_GAMMA_SLOP"), ADDSET_FREE_OUTPUT_SLOPE, false); mi = behModel->append (); - mi->set_value (behavColumns.label, M("TP_CHMIXER_LABEL")); - appendBehavList (mi, M("TP_CHMIXER_RED") + ", " + M("TP_CHMIXER_GREEN") + ", " + M("TP_CHMIXER_BLUE"), ADDSET_CHMIXER, false); + mi->set_value (behavColumns.label, M ("TP_CHMIXER_LABEL")); + appendBehavList (mi, M ("TP_CHMIXER_RED") + ", " + M ("TP_CHMIXER_GREEN") + ", " + M ("TP_CHMIXER_BLUE"), ADDSET_CHMIXER, false); mi = behModel->append (); - mi->set_value (behavColumns.label, M("TP_BWMIX_LABEL")); - appendBehavList (mi, M("TP_BWMIX_MIXC"), ADDSET_BLACKWHITE_HUES, false); - appendBehavList (mi, M("TP_BWMIX_GAMMA"), ADDSET_BLACKWHITE_GAMMA, false); + mi->set_value (behavColumns.label, M ("TP_BWMIX_LABEL")); + appendBehavList (mi, M ("TP_BWMIX_MIXC"), ADDSET_BLACKWHITE_HUES, false); + appendBehavList (mi, M ("TP_BWMIX_GAMMA"), ADDSET_BLACKWHITE_GAMMA, false); mi = behModel->append (); - mi->set_value( behavColumns.label, M("TP_FILMSIMULATION_LABEL") ); - appendBehavList( mi, M( "TP_FILMSIMULATION_STRENGTH" ), ADDSET_FILMSIMULATION_STRENGTH, true ); + mi->set_value ( behavColumns.label, M ("TP_FILMSIMULATION_LABEL") ); + appendBehavList ( mi, M ( "TP_FILMSIMULATION_STRENGTH" ), ADDSET_FILMSIMULATION_STRENGTH, true ); mi = behModel->append (); - mi->set_value (behavColumns.label, M("TP_COLORTONING_LABEL")); - appendBehavList (mi, M("TP_COLORTONING_SPLITCOCO"), ADDSET_COLORTONING_SPLIT , true); - appendBehavList (mi, M("TP_COLORTONING_SATURATIONTHRESHOLD"), ADDSET_COLORTONING_SATTHRESHOLD , true); - appendBehavList (mi, M("TP_COLORTONING_SATURATEDOPACITY"), ADDSET_COLORTONING_SATOPACITY , true); - appendBehavList (mi, M("TP_COLORTONING_BALANCE"), ADDSET_COLORTONING_BALANCE , true); - appendBehavList (mi, M("TP_COLORTONING_STRENGTH"), ADDSET_COLORTONING_STRENGTH , true); + mi->set_value (behavColumns.label, M ("TP_COLORTONING_LABEL")); + appendBehavList (mi, M ("TP_COLORTONING_SPLITCOCO"), ADDSET_COLORTONING_SPLIT , true); + appendBehavList (mi, M ("TP_COLORTONING_SATURATIONTHRESHOLD"), ADDSET_COLORTONING_SATTHRESHOLD , true); + appendBehavList (mi, M ("TP_COLORTONING_SATURATEDOPACITY"), ADDSET_COLORTONING_SATOPACITY , true); + appendBehavList (mi, M ("TP_COLORTONING_BALANCE"), ADDSET_COLORTONING_BALANCE , true); + appendBehavList (mi, M ("TP_COLORTONING_STRENGTH"), ADDSET_COLORTONING_STRENGTH , true); mi = behModel->append (); - mi->set_value (behavColumns.label, M("TP_ROTATE_LABEL")); - appendBehavList (mi, M("TP_ROTATE_DEGREE"), ADDSET_ROTATE_DEGREE, false); + mi->set_value (behavColumns.label, M ("TP_ROTATE_LABEL")); + appendBehavList (mi, M ("TP_ROTATE_DEGREE"), ADDSET_ROTATE_DEGREE, false); mi = behModel->append (); - mi->set_value (behavColumns.label, M("TP_DISTORTION_LABEL")); - appendBehavList (mi, M("TP_DISTORTION_AMOUNT"), ADDSET_DIST_AMOUNT, false); + mi->set_value (behavColumns.label, M ("TP_DISTORTION_LABEL")); + appendBehavList (mi, M ("TP_DISTORTION_AMOUNT"), ADDSET_DIST_AMOUNT, false); mi = behModel->append (); - mi->set_value (behavColumns.label, M("TP_PERSPECTIVE_LABEL")); - appendBehavList (mi, M("TP_PERSPECTIVE_HORIZONTAL") + ", " + M("TP_PERSPECTIVE_VERTICAL"), ADDSET_PERSPECTIVE, false); + mi->set_value (behavColumns.label, M ("TP_PERSPECTIVE_LABEL")); + appendBehavList (mi, M ("TP_PERSPECTIVE_HORIZONTAL") + ", " + M ("TP_PERSPECTIVE_VERTICAL"), ADDSET_PERSPECTIVE, false); mi = behModel->append (); - mi->set_value (behavColumns.label, M("TP_GRADIENT_LABEL")); - appendBehavList (mi, M("TP_GRADIENT_DEGREE"), ADDSET_GRADIENT_DEGREE, false); - appendBehavList (mi, M("TP_GRADIENT_FEATHER"), ADDSET_GRADIENT_FEATHER, false); - appendBehavList (mi, M("TP_GRADIENT_STRENGTH"), ADDSET_GRADIENT_STRENGTH, false); - appendBehavList (mi, M("TP_GRADIENT_CENTER_X") + ", " + M("TP_GRADIENT_CENTER_Y"), ADDSET_GRADIENT_CENTER, false); + mi->set_value (behavColumns.label, M ("TP_GRADIENT_LABEL")); + appendBehavList (mi, M ("TP_GRADIENT_DEGREE"), ADDSET_GRADIENT_DEGREE, false); + appendBehavList (mi, M ("TP_GRADIENT_FEATHER"), ADDSET_GRADIENT_FEATHER, false); + appendBehavList (mi, M ("TP_GRADIENT_STRENGTH"), ADDSET_GRADIENT_STRENGTH, false); + appendBehavList (mi, M ("TP_GRADIENT_CENTER_X") + ", " + M ("TP_GRADIENT_CENTER_Y"), ADDSET_GRADIENT_CENTER, false); mi = behModel->append (); - mi->set_value (behavColumns.label, M("TP_PCVIGNETTE_LABEL")); - appendBehavList (mi, M("TP_PCVIGNETTE_STRENGTH"), ADDSET_PCVIGNETTE_STRENGTH, false); - appendBehavList (mi, M("TP_PCVIGNETTE_FEATHER"), ADDSET_PCVIGNETTE_FEATHER, false); - appendBehavList (mi, M("TP_PCVIGNETTE_ROUNDNESS"), ADDSET_PCVIGNETTE_ROUNDNESS, false); + mi->set_value (behavColumns.label, M ("TP_PCVIGNETTE_LABEL")); + appendBehavList (mi, M ("TP_PCVIGNETTE_STRENGTH"), ADDSET_PCVIGNETTE_STRENGTH, false); + appendBehavList (mi, M ("TP_PCVIGNETTE_FEATHER"), ADDSET_PCVIGNETTE_FEATHER, false); + appendBehavList (mi, M ("TP_PCVIGNETTE_ROUNDNESS"), ADDSET_PCVIGNETTE_ROUNDNESS, false); mi = behModel->append (); - mi->set_value (behavColumns.label, M("TP_CACORRECTION_LABEL")); - appendBehavList (mi, M("TP_CACORRECTION_BLUE") + ", " + M("TP_CACORRECTION_RED"), ADDSET_CA, true); + mi->set_value (behavColumns.label, M ("TP_CACORRECTION_LABEL")); + appendBehavList (mi, M ("TP_CACORRECTION_BLUE") + ", " + M ("TP_CACORRECTION_RED"), ADDSET_CA, true); mi = behModel->append (); - mi->set_value (behavColumns.label, M("TP_VIGNETTING_LABEL")); - appendBehavList (mi, M("TP_VIGNETTING_AMOUNT"), ADDSET_VIGN_AMOUNT, false); - appendBehavList (mi, M("TP_VIGNETTING_RADIUS"), ADDSET_VIGN_RADIUS, false); - appendBehavList (mi, M("TP_VIGNETTING_STRENGTH"), ADDSET_VIGN_STRENGTH, false); - appendBehavList (mi, M("TP_VIGNETTING_CENTER_X") + ", " + M("TP_VIGNETTING_CENTER_Y"), ADDSET_VIGN_CENTER, false); + mi->set_value (behavColumns.label, M ("TP_VIGNETTING_LABEL")); + appendBehavList (mi, M ("TP_VIGNETTING_AMOUNT"), ADDSET_VIGN_AMOUNT, false); + appendBehavList (mi, M ("TP_VIGNETTING_RADIUS"), ADDSET_VIGN_RADIUS, false); + appendBehavList (mi, M ("TP_VIGNETTING_STRENGTH"), ADDSET_VIGN_STRENGTH, false); + appendBehavList (mi, M ("TP_VIGNETTING_CENTER_X") + ", " + M ("TP_VIGNETTING_CENTER_Y"), ADDSET_VIGN_CENTER, false); mi = behModel->append (); - mi->set_value (behavColumns.label, M("TP_DIRPYREQUALIZER_LABEL")); - appendBehavList (mi, M("TP_EXPOSURE_CONTRAST"), ADDSET_DIRPYREQ, true); - appendBehavList (mi, M("TP_DIRPYREQUALIZER_THRESHOLD"), ADDSET_DIRPYREQ_THRESHOLD, true); - appendBehavList (mi, M("TP_DIRPYREQUALIZER_SKIN"), ADDSET_DIRPYREQ_SKINPROTECT, true); + mi->set_value (behavColumns.label, M ("TP_DIRPYREQUALIZER_LABEL")); + appendBehavList (mi, M ("TP_EXPOSURE_CONTRAST"), ADDSET_DIRPYREQ, true); + appendBehavList (mi, M ("TP_DIRPYREQUALIZER_THRESHOLD"), ADDSET_DIRPYREQ_THRESHOLD, true); + appendBehavList (mi, M ("TP_DIRPYREQUALIZER_SKIN"), ADDSET_DIRPYREQ_SKINPROTECT, true); mi = behModel->append (); - mi->set_value (behavColumns.label, M("TP_WAVELET_LABEL")); - appendBehavList (mi, M("TP_WAVELET_LEVELS"), ADDSET_WA_THRES, true); + mi->set_value (behavColumns.label, M ("TP_WAVELET_LABEL")); + appendBehavList (mi, M ("TP_WAVELET_LEVELS"), ADDSET_WA_THRES, true); // appendBehavList (mi, M("TP_WAVELET_CONTRAST"), ADDSET_WA, true); - appendBehavList (mi, M("TP_WAVELET_THRESHOLD"), ADDSET_WA_THRESHOLD, true); - appendBehavList (mi, M("TP_WAVELET_THRESHOLD2"), ADDSET_WA_THRESHOLD2, true); - appendBehavList (mi, M("TP_WAVELET_CHRO"), ADDSET_WA_CHRO, true); - appendBehavList (mi, M("TP_WAVELET_CHR"), ADDSET_WA_CHROMA, true); - appendBehavList (mi, M("TP_WAVELET_SKIN"), ADDSET_WA_SKINPROTECT, true); - appendBehavList (mi, M("TP_WAVELET_EDRAD"), ADDSET_WA_EDGRAD, true); - appendBehavList (mi, M("TP_WAVELET_EDVAL"), ADDSET_WA_EDGVAL, true); - appendBehavList (mi, M("TP_WAVELET_RESCON"), ADDSET_WA_RESCON, true); - appendBehavList (mi, M("TP_WAVELET_THR"), ADDSET_WA_THRR, true); - appendBehavList (mi, M("TP_WAVELET_RESCONH"), ADDSET_WA_RESCONH, true); - appendBehavList (mi, M("TP_WAVELET_THRH"), ADDSET_WA_THRRH, true); - appendBehavList (mi, M("TP_WAVELET_RESCHRO"), ADDSET_WA_RESCHRO, true); - appendBehavList (mi, M("TP_WAVELET_TMSTRENGTH"), ADDSET_WA_TMRS, true); - appendBehavList (mi, M("TP_WAVELET_SKY"), ADDSET_WA_SKYPROTECT, true); - appendBehavList (mi, M("TP_WAVELET_CONTRA"), ADDSET_WA_CONTRAST, true); - appendBehavList (mi, M("TP_WAVELET_STRENGTH"), ADDSET_WA_STRENGTH, true); - appendBehavList (mi, M("TP_WAVELET_COMPGAMMA"), ADDSET_WA_GAMMA, true); - appendBehavList (mi, M("TP_WAVELET_EDGEDETECT"), ADDSET_WA_EDGEDETECT, true); - appendBehavList (mi, M("TP_WAVELET_EDGEDETECTTHR"), ADDSET_WA_EDGEDETECTTHR, true); - appendBehavList (mi, M("TP_WAVELET_EDGEDETECTTHR2"), ADDSET_WA_EDGEDETECTTHR2, true); + appendBehavList (mi, M ("TP_WAVELET_THRESHOLD"), ADDSET_WA_THRESHOLD, true); + appendBehavList (mi, M ("TP_WAVELET_THRESHOLD2"), ADDSET_WA_THRESHOLD2, true); + appendBehavList (mi, M ("TP_WAVELET_CHRO"), ADDSET_WA_CHRO, true); + appendBehavList (mi, M ("TP_WAVELET_CHR"), ADDSET_WA_CHROMA, true); + appendBehavList (mi, M ("TP_WAVELET_SKIN"), ADDSET_WA_SKINPROTECT, true); + appendBehavList (mi, M ("TP_WAVELET_EDRAD"), ADDSET_WA_EDGRAD, true); + appendBehavList (mi, M ("TP_WAVELET_EDVAL"), ADDSET_WA_EDGVAL, true); + appendBehavList (mi, M ("TP_WAVELET_RESCON"), ADDSET_WA_RESCON, true); + appendBehavList (mi, M ("TP_WAVELET_THR"), ADDSET_WA_THRR, true); + appendBehavList (mi, M ("TP_WAVELET_RESCONH"), ADDSET_WA_RESCONH, true); + appendBehavList (mi, M ("TP_WAVELET_THRH"), ADDSET_WA_THRRH, true); + appendBehavList (mi, M ("TP_WAVELET_RESCHRO"), ADDSET_WA_RESCHRO, true); + appendBehavList (mi, M ("TP_WAVELET_TMSTRENGTH"), ADDSET_WA_TMRS, true); + appendBehavList (mi, M ("TP_WAVELET_SKY"), ADDSET_WA_SKYPROTECT, true); + appendBehavList (mi, M ("TP_WAVELET_CONTRA"), ADDSET_WA_CONTRAST, true); + appendBehavList (mi, M ("TP_WAVELET_STRENGTH"), ADDSET_WA_STRENGTH, true); + appendBehavList (mi, M ("TP_WAVELET_COMPGAMMA"), ADDSET_WA_GAMMA, true); + appendBehavList (mi, M ("TP_WAVELET_EDGEDETECT"), ADDSET_WA_EDGEDETECT, true); + appendBehavList (mi, M ("TP_WAVELET_EDGEDETECTTHR"), ADDSET_WA_EDGEDETECTTHR, true); + appendBehavList (mi, M ("TP_WAVELET_EDGEDETECTTHR2"), ADDSET_WA_EDGEDETECTTHR2, true); mi = behModel->append (); - mi->set_value (behavColumns.label, M("TP_PREPROCESS_LABEL")); - appendBehavList (mi, M("TP_PREPROCESS_GREENEQUIL"), ADDSET_PREPROCESS_GREENEQUIL, false); - appendBehavList (mi, M("TP_PREPROCESS_LINEDENOISE"), ADDSET_PREPROCESS_LINEDENOISE, true); + mi->set_value (behavColumns.label, M ("TP_PREPROCESS_LABEL")); + appendBehavList (mi, M ("TP_PREPROCESS_GREENEQUIL"), ADDSET_PREPROCESS_GREENEQUIL, false); + appendBehavList (mi, M ("TP_PREPROCESS_LINEDENOISE"), ADDSET_PREPROCESS_LINEDENOISE, true); mi = behModel->append (); - mi->set_value (behavColumns.label, M("TP_EXPOS_WHITEPOINT_LABEL")); - appendBehavList (mi, M("TP_RAWEXPOS_LINEAR"), ADDSET_RAWEXPOS_LINEAR, false); - appendBehavList (mi, M("TP_RAWEXPOS_PRESER"), ADDSET_RAWEXPOS_PRESER, false); + mi->set_value (behavColumns.label, M ("TP_EXPOS_WHITEPOINT_LABEL")); + appendBehavList (mi, M ("TP_RAWEXPOS_LINEAR"), ADDSET_RAWEXPOS_LINEAR, false); + appendBehavList (mi, M ("TP_RAWEXPOS_PRESER"), ADDSET_RAWEXPOS_PRESER, false); mi = behModel->append (); - mi->set_value (behavColumns.label, M("TP_RAWEXPOS_BLACKS")); - appendBehavList (mi, M("TP_RAWEXPOS_RGB"), ADDSET_RAWEXPOS_BLACKS, false); + mi->set_value (behavColumns.label, M ("TP_RAWEXPOS_BLACKS")); + appendBehavList (mi, M ("TP_RAWEXPOS_RGB"), ADDSET_RAWEXPOS_BLACKS, false); mi = behModel->append (); - mi->set_value (behavColumns.label, M("TP_FLATFIELD_LABEL")); - appendBehavList (mi, M("TP_FLATFIELD_CLIPCONTROL"), ADDSET_RAWFFCLIPCONTROL, true); + mi->set_value (behavColumns.label, M ("TP_FLATFIELD_LABEL")); + appendBehavList (mi, M ("TP_FLATFIELD_CLIPCONTROL"), ADDSET_RAWFFCLIPCONTROL, true); mi = behModel->append (); - mi->set_value (behavColumns.label, M("TP_CHROMATABERR_LABEL")); - appendBehavList (mi, M("TP_RAWCACORR_CARED") + ", " + M("TP_RAWCACORR_CABLUE"), ADDSET_RAWCACORR, true); + mi->set_value (behavColumns.label, M ("TP_CHROMATABERR_LABEL")); + appendBehavList (mi, M ("TP_RAWCACORR_CARED") + ", " + M ("TP_RAWCACORR_CABLUE"), ADDSET_RAWCACORR, true); behTreeView->expand_all (); - behAddAll = Gtk::manage( new Gtk::Button (M("PREFERENCES_BEHADDALL")) ); - behSetAll = Gtk::manage( new Gtk::Button (M("PREFERENCES_BEHSETALL")) ); - behAddAll->set_tooltip_markup (M("PREFERENCES_BEHADDALLHINT")); - behSetAll->set_tooltip_markup (M("PREFERENCES_BEHSETALLHINT")); + behAddAll = Gtk::manage ( new Gtk::Button (M ("PREFERENCES_BEHADDALL")) ); + behSetAll = Gtk::manage ( new Gtk::Button (M ("PREFERENCES_BEHSETALL")) ); + behAddAll->set_tooltip_markup (M ("PREFERENCES_BEHADDALLHINT")); + behSetAll->set_tooltip_markup (M ("PREFERENCES_BEHSETALLHINT")); - behAddAll->signal_clicked().connect( sigc::mem_fun(*this, &Preferences::behAddAllPressed) ); - behSetAll->signal_clicked().connect( sigc::mem_fun(*this, &Preferences::behSetAllPressed) ); + behAddAll->signal_clicked().connect ( sigc::mem_fun (*this, &Preferences::behAddAllPressed) ); + behSetAll->signal_clicked().connect ( sigc::mem_fun (*this, &Preferences::behSetAllPressed) ); Gtk::HBox* buttonpanel1 = Gtk::manage (new Gtk::HBox ()); //buttonpanel1->set_spacing(8); @@ -384,8 +404,8 @@ Gtk::Widget* Preferences::getBatchProcPanel () buttonpanel1->pack_end (*behAddAll, Gtk::PACK_SHRINK, 4); vbbeh->pack_start (*buttonpanel1, Gtk::PACK_SHRINK, 4); - chOverwriteOutputFile = Gtk::manage( new Gtk::CheckButton (M("PREFERENCES_OVERWRITEOUTPUTFILE")) ); - mvbpp->pack_start(*chOverwriteOutputFile, Gtk::PACK_SHRINK, 4); + chOverwriteOutputFile = Gtk::manage ( new Gtk::CheckButton (M ("PREFERENCES_OVERWRITEOUTPUTFILE")) ); + mvbpp->pack_start (*chOverwriteOutputFile, Gtk::PACK_SHRINK, 4); return mvbpp; } @@ -424,40 +444,40 @@ Gtk::Widget* Preferences::getProcParamsPanel () Gtk::VBox* mvbpp = Gtk::manage (new Gtk::VBox ()); - Gtk::Frame* fpp = Gtk::manage (new Gtk::Frame (M("PREFERENCES_IMPROCPARAMS"))); + Gtk::Frame* fpp = Gtk::manage (new Gtk::Frame (M ("PREFERENCES_IMPROCPARAMS"))); Gtk::VBox* vbpp = Gtk::manage (new Gtk::VBox ()); - Gtk::Label* drlab = Gtk::manage (new Gtk::Label (M("PREFERENCES_FORRAW") + ":", Gtk::ALIGN_START)); + Gtk::Label* drlab = Gtk::manage (new Gtk::Label (M ("PREFERENCES_FORRAW") + ":", Gtk::ALIGN_START)); rprofiles = Gtk::manage (new ProfileStoreComboBox ()); - setExpandAlignProperties(rprofiles, true, false, Gtk::ALIGN_FILL, Gtk::ALIGN_CENTER); - rprofiles->set_size_request(50, -1); - rpconn = rprofiles->signal_changed().connect( sigc::mem_fun(*this, &Preferences::forRAWComboChanged) ); - Gtk::Label* drimg = Gtk::manage (new Gtk::Label (M("PREFERENCES_FORIMAGE") + ":", Gtk::ALIGN_START)); + setExpandAlignProperties (rprofiles, true, false, Gtk::ALIGN_FILL, Gtk::ALIGN_CENTER); + rprofiles->set_size_request (50, -1); + rpconn = rprofiles->signal_changed().connect ( sigc::mem_fun (*this, &Preferences::forRAWComboChanged) ); + Gtk::Label* drimg = Gtk::manage (new Gtk::Label (M ("PREFERENCES_FORIMAGE") + ":", Gtk::ALIGN_START)); iprofiles = Gtk::manage (new ProfileStoreComboBox ()); - iprofiles->set_size_request(50, -1); - setExpandAlignProperties(iprofiles, true, false, Gtk::ALIGN_FILL, Gtk::ALIGN_FILL); - ipconn = iprofiles->signal_changed().connect( sigc::mem_fun(*this, &Preferences::forImageComboChanged) ); + iprofiles->set_size_request (50, -1); + setExpandAlignProperties (iprofiles, true, false, Gtk::ALIGN_FILL, Gtk::ALIGN_FILL); + ipconn = iprofiles->signal_changed().connect ( sigc::mem_fun (*this, &Preferences::forImageComboChanged) ); Gtk::Table* defpt = Gtk::manage (new Gtk::Table (2, 2)); defpt->attach (*drlab, 0, 1, 0, 1, Gtk::FILL, Gtk::SHRINK, 2, 2); defpt->attach (*rprofiles, 1, 2, 0, 1, Gtk::EXPAND | Gtk::FILL | Gtk::SHRINK, Gtk::SHRINK, 2, 2); defpt->attach (*drimg, 0, 1, 1, 2, Gtk::FILL, Gtk::SHRINK, 2, 2); defpt->attach (*iprofiles, 1, 2, 1, 2, Gtk::EXPAND | Gtk::FILL | Gtk::SHRINK, Gtk::SHRINK, 2, 2); vbpp->pack_start (*defpt, Gtk::PACK_SHRINK, 4); - useBundledProfiles = Gtk::manage (new Gtk::CheckButton (M("PREFERENCES_USEBUNDLEDPROFILES"))); - bpconn = useBundledProfiles->signal_clicked().connect ( sigc::mem_fun(*this, &Preferences::bundledProfilesChanged) ); + useBundledProfiles = Gtk::manage (new Gtk::CheckButton (M ("PREFERENCES_USEBUNDLEDPROFILES"))); + bpconn = useBundledProfiles->signal_clicked().connect ( sigc::mem_fun (*this, &Preferences::bundledProfilesChanged) ); vbpp->pack_start (*useBundledProfiles, Gtk::PACK_SHRINK, 4); fpp->add (*vbpp); mvbpp->pack_start (*fpp, Gtk::PACK_SHRINK, 4); // Custom profile builder box - Gtk::Frame* cpfrm = Gtk::manage( new Gtk::Frame (M("PREFERENCES_CUSTPROFBUILD")) ); - Gtk::Label* cplab = Gtk::manage( new Gtk::Label (M("PREFERENCES_CUSTPROFBUILDPATH") + ":", Gtk::ALIGN_START) ); - txtCustProfBuilderPath = Gtk::manage( new Gtk::Entry () ); - txtCustProfBuilderPath->set_tooltip_markup (M("PREFERENCES_CUSTPROFBUILDHINT")); - Gtk::Label* cpltypelab = Gtk::manage( new Gtk::Label (M("PREFERENCES_CUSTPROFBUILDKEYFORMAT") + ":", Gtk::ALIGN_START) ); + Gtk::Frame* cpfrm = Gtk::manage ( new Gtk::Frame (M ("PREFERENCES_CUSTPROFBUILD")) ); + Gtk::Label* cplab = Gtk::manage ( new Gtk::Label (M ("PREFERENCES_CUSTPROFBUILDPATH") + ":", Gtk::ALIGN_START) ); + txtCustProfBuilderPath = Gtk::manage ( new Gtk::Entry () ); + txtCustProfBuilderPath->set_tooltip_markup (M ("PREFERENCES_CUSTPROFBUILDHINT")); + Gtk::Label* cpltypelab = Gtk::manage ( new Gtk::Label (M ("PREFERENCES_CUSTPROFBUILDKEYFORMAT") + ":", Gtk::ALIGN_START) ); custProfBuilderLabelType = Gtk::manage (new Gtk::ComboBoxText ()); - custProfBuilderLabelType->append (M("PREFERENCES_CUSTPROFBUILDKEYFORMAT_TID")); - custProfBuilderLabelType->append (M("PREFERENCES_CUSTPROFBUILDKEYFORMAT_NAME")); - custProfBuilderLabelType->append (M("PREFERENCES_CUSTPROFBUILDKEYFORMAT_TID") + "_" + M("PREFERENCES_CUSTPROFBUILDKEYFORMAT_NAME")); + custProfBuilderLabelType->append (M ("PREFERENCES_CUSTPROFBUILDKEYFORMAT_TID")); + custProfBuilderLabelType->append (M ("PREFERENCES_CUSTPROFBUILDKEYFORMAT_NAME")); + custProfBuilderLabelType->append (M ("PREFERENCES_CUSTPROFBUILDKEYFORMAT_TID") + "_" + M ("PREFERENCES_CUSTPROFBUILDKEYFORMAT_NAME")); Gtk::Table* cpbt = Gtk::manage (new Gtk::Table (2, 2)); cpbt->attach (*cplab, 0, 1, 0, 1, Gtk::FILL, Gtk::SHRINK, 2, 2); cpbt->attach (*txtCustProfBuilderPath, 1, 2, 0, 1, Gtk::EXPAND | Gtk::FILL | Gtk::SHRINK, Gtk::SHRINK, 2, 2); @@ -466,112 +486,129 @@ Gtk::Widget* Preferences::getProcParamsPanel () cpfrm->add (*cpbt); mvbpp->pack_start (*cpfrm, Gtk::PACK_SHRINK, 4); - Gtk::Frame* fdp = Gtk::manage (new Gtk::Frame (M("PREFERENCES_PROFILEHANDLING"))); + Gtk::Frame* fdp = Gtk::manage (new Gtk::Frame (M ("PREFERENCES_PROFILEHANDLING"))); Gtk::VBox* vbdp = Gtk::manage (new Gtk::VBox ()); - saveParamsFile = Gtk::manage (new Gtk::CheckButton (M("PREFERENCES_PROFILESAVEINPUT"))); + saveParamsFile = Gtk::manage (new Gtk::CheckButton (M ("PREFERENCES_PROFILESAVEINPUT"))); vbdp->pack_start (*saveParamsFile, Gtk::PACK_SHRINK, 4); - saveParamsCache = Gtk::manage (new Gtk::CheckButton (M("PREFERENCES_PROFILESAVECACHE"))); + saveParamsCache = Gtk::manage (new Gtk::CheckButton (M ("PREFERENCES_PROFILESAVECACHE"))); vbdp->pack_start (*saveParamsCache, Gtk::PACK_SHRINK, 4); - Gtk::Label* lplab = Gtk::manage (new Gtk::Label (M("PREFERENCES_PROFILELOADPR") + ":")); + Gtk::Label* lplab = Gtk::manage (new Gtk::Label (M ("PREFERENCES_PROFILELOADPR") + ":")); loadParamsPreference = Gtk::manage (new Gtk::ComboBoxText ()); - loadParamsPreference->append (M("PREFERENCES_PROFILEPRCACHE")); - loadParamsPreference->append (M("PREFERENCES_PROFILEPRFILE")); + loadParamsPreference->append (M ("PREFERENCES_PROFILEPRCACHE")); + loadParamsPreference->append (M ("PREFERENCES_PROFILEPRFILE")); Gtk::HBox* hb41 = Gtk::manage (new Gtk::HBox ()); hb41->pack_start (*lplab, Gtk::PACK_SHRINK, 0); hb41->pack_start (*loadParamsPreference, Gtk::PACK_EXPAND_WIDGET, 0); - hb41->set_spacing(4); + hb41->set_spacing (4); vbdp->pack_start (*hb41, Gtk::PACK_EXPAND_WIDGET, 4); fdp->add (*vbdp); mvbpp->pack_start (*fdp, Gtk::PACK_SHRINK, 4); - Gtk::Frame* fdf = Gtk::manage (new Gtk::Frame (M("PREFERENCES_DARKFRAME")) ); + Gtk::Frame* fmip = Gtk::manage (new Gtk::Frame (M ("PREFERENCES_MIP"))); + Gtk::HBox* hbmip = Gtk::manage (new Gtk::HBox (false, 4)); + Gtk::Label* lmip = Gtk::manage (new Gtk::Label (M ("PREFERENCES_MIP_LABEL"))); + cmip = Gtk::manage (new Gtk::ComboBoxText ()); + cmip->append (M ("PREFERENCES_MIP_PREV")); + cmip->append (M ("PREFERENCES_MIP_OPT")); + cmip->set_active (1); + cmip->set_tooltip_text (M ("PREFERENCES_MIP_TOOLTIP")); + + hbmip->pack_start (*lmip, Gtk::PACK_SHRINK); + hbmip->pack_start (*cmip); + fmip->add (*hbmip); + hbmip->set_border_width (4); + mvbpp->pack_start (*fmip, Gtk::PACK_SHRINK, 4); + + Gtk::Frame* fdf = Gtk::manage (new Gtk::Frame (M ("PREFERENCES_DARKFRAME")) ); Gtk::HBox* hb42 = Gtk::manage (new Gtk::HBox ()); - darkFrameDir = Gtk::manage(new Gtk::FileChooserButton(M("PREFERENCES_DIRDARKFRAMES"), Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER)); - Gtk::Label *dfLab = Gtk::manage(new Gtk::Label(M("PREFERENCES_DIRDARKFRAMES") + ":")); - hb42->pack_start(*dfLab , Gtk::PACK_SHRINK, 4 ); - hb42->pack_start(*darkFrameDir, Gtk::PACK_EXPAND_WIDGET, 4); - dfLabel = Gtk::manage(new Gtk::Label("Found:")); + darkFrameDir = Gtk::manage (new Gtk::FileChooserButton (M ("PREFERENCES_DIRDARKFRAMES"), Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER)); + Gtk::Label *dfLab = Gtk::manage (new Gtk::Label (M ("PREFERENCES_DIRDARKFRAMES") + ":")); + hb42->pack_start (*dfLab , Gtk::PACK_SHRINK, 4 ); + hb42->pack_start (*darkFrameDir, Gtk::PACK_EXPAND_WIDGET, 4); + dfLabel = Gtk::manage (new Gtk::Label ("Found:")); Gtk::VBox* vbdf = Gtk::manage (new Gtk::VBox ()); - vbdf->pack_start( *hb42, Gtk::PACK_SHRINK, 4); - vbdf->pack_start( *dfLabel, Gtk::PACK_SHRINK, 4 ); - fdf->add( *vbdf ); + vbdf->pack_start ( *hb42, Gtk::PACK_SHRINK, 4); + vbdf->pack_start ( *dfLabel, Gtk::PACK_SHRINK, 4 ); + fdf->add ( *vbdf ); mvbpp->pack_start ( *fdf , Gtk::PACK_SHRINK, 4); //dfconn = darkFrameDir->signal_file_set().connect ( sigc::mem_fun(*this, &Preferences::darkFrameChanged), true); - dfconn = darkFrameDir->signal_current_folder_changed().connect ( sigc::mem_fun(*this, &Preferences::darkFrameChanged), true); + dfconn = darkFrameDir->signal_current_folder_changed().connect ( sigc::mem_fun (*this, &Preferences::darkFrameChanged), true); // FLATFIELD - Gtk::Frame* fff = Gtk::manage (new Gtk::Frame (M("PREFERENCES_FLATFIELD")) ); + Gtk::Frame* fff = Gtk::manage (new Gtk::Frame (M ("PREFERENCES_FLATFIELD")) ); Gtk::HBox* hb43 = Gtk::manage (new Gtk::HBox ()); - flatFieldDir = Gtk::manage(new Gtk::FileChooserButton(M("PREFERENCES_FLATFIELDSDIR"), Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER)); - Gtk::Label *ffLab = Gtk::manage(new Gtk::Label(M("PREFERENCES_FLATFIELDSDIR") + ":")); - hb43->pack_start(*ffLab , Gtk::PACK_SHRINK, 4 ); - hb43->pack_start(*flatFieldDir); - ffLabel = Gtk::manage(new Gtk::Label("Found:")); + flatFieldDir = Gtk::manage (new Gtk::FileChooserButton (M ("PREFERENCES_FLATFIELDSDIR"), Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER)); + Gtk::Label *ffLab = Gtk::manage (new Gtk::Label (M ("PREFERENCES_FLATFIELDSDIR") + ":")); + hb43->pack_start (*ffLab , Gtk::PACK_SHRINK, 4 ); + hb43->pack_start (*flatFieldDir); + ffLabel = Gtk::manage (new Gtk::Label ("Found:")); Gtk::VBox* vbff = Gtk::manage (new Gtk::VBox ()); - vbff->pack_start( *hb43, Gtk::PACK_SHRINK, 4); - vbff->pack_start( *ffLabel, Gtk::PACK_SHRINK, 4 ); - fff->add( *vbff ); + vbff->pack_start ( *hb43, Gtk::PACK_SHRINK, 4); + vbff->pack_start ( *ffLabel, Gtk::PACK_SHRINK, 4 ); + fff->add ( *vbff ); mvbpp->pack_start ( *fff , Gtk::PACK_SHRINK, 4); //ffconn = flatFieldDir->signal_file_set().connect ( sigc::mem_fun(*this, &Preferences::flatFieldChanged), true); - ffconn = flatFieldDir->signal_current_folder_changed().connect ( sigc::mem_fun(*this, &Preferences::flatFieldChanged), true); + ffconn = flatFieldDir->signal_current_folder_changed().connect ( sigc::mem_fun (*this, &Preferences::flatFieldChanged), true); //Cluts Dir - Gtk::Frame* clutsDirFrame = Gtk::manage (new Gtk::Frame (M("PREFERENCES_FILMSIMULATION")) ); + Gtk::Frame* clutsDirFrame = Gtk::manage (new Gtk::Frame (M ("PREFERENCES_FILMSIMULATION")) ); Gtk::HBox* clutsDirBox = Gtk::manage (new Gtk::HBox ()); - clutsDir = Gtk::manage(new Gtk::FileChooserButton(M("PREFERENCES_CLUTSDIR"), Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER)); - Gtk::Label *clutsDirLabel = Gtk::manage(new Gtk::Label(M("PREFERENCES_CLUTSDIR") + ":")); - Gtk::Label* clutsRestartNeeded = Gtk::manage( new Gtk::Label (Glib::ustring(" (") + M("PREFERENCES_APPLNEXTSTARTUP") + ")") ); - clutsDirBox->pack_start( *clutsDirLabel, Gtk::PACK_SHRINK, 4 ); - clutsDirBox->pack_start( *clutsDir ); - clutsDirBox->pack_start( *clutsRestartNeeded, Gtk::PACK_SHRINK, 4 ); - clutsDirFrame->add( *clutsDirBox ); - mvbpp->pack_start( *clutsDirFrame, Gtk::PACK_SHRINK, 4 ); + clutsDir = Gtk::manage (new Gtk::FileChooserButton (M ("PREFERENCES_CLUTSDIR"), Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER)); + Gtk::Label *clutsDirLabel = Gtk::manage (new Gtk::Label (M ("PREFERENCES_CLUTSDIR") + ":")); + Gtk::Label* clutsRestartNeeded = Gtk::manage ( new Gtk::Label (Glib::ustring (" (") + M ("PREFERENCES_APPLNEXTSTARTUP") + ")") ); + clutsDirBox->pack_start ( *clutsDirLabel, Gtk::PACK_SHRINK, 4 ); + clutsDirBox->pack_start ( *clutsDir ); + clutsDirBox->pack_start ( *clutsRestartNeeded, Gtk::PACK_SHRINK, 4 ); + clutsDirFrame->add ( *clutsDirBox ); + mvbpp->pack_start ( *clutsDirFrame, Gtk::PACK_SHRINK, 4 ); - Gtk::Frame* fmd = Gtk::manage (new Gtk::Frame (M("PREFERENCES_METADATA"))); + Gtk::Frame* fmd = Gtk::manage (new Gtk::Frame (M ("PREFERENCES_METADATA"))); Gtk::VBox* vbmd = Gtk::manage (new Gtk::VBox ()); - ckbTunnelMetaData = Gtk::manage (new Gtk::CheckButton (M("PREFERENCES_TUNNELMETADATA"))); + ckbTunnelMetaData = Gtk::manage (new Gtk::CheckButton (M ("PREFERENCES_TUNNELMETADATA"))); vbmd->pack_start (*ckbTunnelMetaData, Gtk::PACK_SHRINK, 4); fmd->add (*vbmd); mvbpp->pack_start (*fmd, Gtk::PACK_SHRINK, 4); + + return mvbpp; } Gtk::Widget* Preferences::getPerformancePanel () { - Gtk::VBox* mainContainer = Gtk::manage( new Gtk::VBox () ); - mainContainer->set_spacing(4); + Gtk::VBox* mainContainer = Gtk::manage ( new Gtk::VBox () ); + mainContainer->set_spacing (4); - Gtk::Frame* fprevdemo = Gtk::manage (new Gtk::Frame (M("PREFERENCES_PREVDEMO"))); + Gtk::Frame* fprevdemo = Gtk::manage (new Gtk::Frame (M ("PREFERENCES_PREVDEMO"))); Gtk::HBox* hbprevdemo = Gtk::manage (new Gtk::HBox (false, 4)); - Gtk::Label* lprevdemo = Gtk::manage (new Gtk::Label (M("PREFERENCES_PREVDEMO_LABEL"))); + Gtk::Label* lprevdemo = Gtk::manage (new Gtk::Label (M ("PREFERENCES_PREVDEMO_LABEL"))); cprevdemo = Gtk::manage (new Gtk::ComboBoxText ()); - cprevdemo->append (M("PREFERENCES_PREVDEMO_FAST")); - cprevdemo->append (M("PREFERENCES_PREVDEMO_SIDECAR")); + cprevdemo->append (M ("PREFERENCES_PREVDEMO_FAST")); + cprevdemo->append (M ("PREFERENCES_PREVDEMO_SIDECAR")); cprevdemo->set_active (1); hbprevdemo->pack_start (*lprevdemo, Gtk::PACK_SHRINK); hbprevdemo->pack_start (*cprevdemo); fprevdemo->add (*hbprevdemo); mainContainer->pack_start (*fprevdemo, Gtk::PACK_SHRINK, 4); - Gtk::Frame* ftiffserialize = Gtk::manage (new Gtk::Frame (M("PREFERENCES_SERIALIZE_TIFF_READ"))); + Gtk::Frame* ftiffserialize = Gtk::manage (new Gtk::Frame (M ("PREFERENCES_SERIALIZE_TIFF_READ"))); Gtk::HBox* htiffserialize = Gtk::manage (new Gtk::HBox (false, 4)); - ctiffserialize = Gtk::manage( new Gtk::CheckButton (M("PREFERENCES_SERIALIZE_TIFF_READ_LABEL")) ); - ctiffserialize->set_tooltip_text(M("PREFERENCES_SERIALIZE_TIFF_READ_TOOLTIP")); + ctiffserialize = Gtk::manage ( new Gtk::CheckButton (M ("PREFERENCES_SERIALIZE_TIFF_READ_LABEL")) ); + ctiffserialize->set_tooltip_text (M ("PREFERENCES_SERIALIZE_TIFF_READ_TOOLTIP")); htiffserialize->pack_start (*ctiffserialize); ftiffserialize->add (*htiffserialize); mainContainer->pack_start (*ftiffserialize, Gtk::PACK_SHRINK, 4); - Gtk::Frame* fclut = Gtk::manage( new Gtk::Frame (M("PREFERENCES_CLUTSCACHE")) ); - Gtk::HBox* clutCacheSizeHB = Gtk::manage( new Gtk::HBox () ); - clutCacheSizeHB->set_spacing(4); - Gtk::Label* CLUTLl = Gtk::manage( new Gtk::Label (M("PREFERENCES_CLUTSCACHE_LABEL") + ":", Gtk::ALIGN_START)); - clutCacheSizeSB = Gtk::manage( new Gtk::SpinButton () ); + Gtk::Frame* fclut = Gtk::manage ( new Gtk::Frame (M ("PREFERENCES_CLUTSCACHE")) ); + Gtk::HBox* clutCacheSizeHB = Gtk::manage ( new Gtk::HBox () ); + clutCacheSizeHB->set_spacing (4); + Gtk::Label* CLUTLl = Gtk::manage ( new Gtk::Label (M ("PREFERENCES_CLUTSCACHE_LABEL") + ":", Gtk::ALIGN_START)); + clutCacheSizeSB = Gtk::manage ( new Gtk::SpinButton () ); clutCacheSizeSB->set_digits (0); clutCacheSizeSB->set_increments (1, 5); - clutCacheSizeSB->set_max_length(2); // Will this be sufficient? :) + clutCacheSizeSB->set_max_length (2); // Will this be sufficient? :) #ifdef _OPENMP clutCacheSizeSB->set_range (1, 3 * omp_get_num_procs()); #else @@ -582,32 +619,32 @@ Gtk::Widget* Preferences::getPerformancePanel () fclut->add (*clutCacheSizeHB); mainContainer->pack_start (*fclut, Gtk::PACK_SHRINK, 4); - Gtk::Frame* finspect = Gtk::manage( new Gtk::Frame (M("PREFERENCES_INSPECT_LABEL")) ); - Gtk::HBox* maxIBuffersHB = Gtk::manage( new Gtk::HBox () ); - maxIBuffersHB->set_spacing(4); - maxIBuffersHB->set_tooltip_text(M("PREFERENCES_INSPECT_MAXBUFFERS_TOOLTIP")); - Gtk::Label* maxIBufferLbl = Gtk::manage( new Gtk::Label (M("PREFERENCES_INSPECT_MAXBUFFERS_LABEL") + ":", Gtk::ALIGN_START)); - maxInspectorBuffersSB = Gtk::manage( new Gtk::SpinButton () ); + Gtk::Frame* finspect = Gtk::manage ( new Gtk::Frame (M ("PREFERENCES_INSPECT_LABEL")) ); + Gtk::HBox* maxIBuffersHB = Gtk::manage ( new Gtk::HBox () ); + maxIBuffersHB->set_spacing (4); + maxIBuffersHB->set_tooltip_text (M ("PREFERENCES_INSPECT_MAXBUFFERS_TOOLTIP")); + Gtk::Label* maxIBufferLbl = Gtk::manage ( new Gtk::Label (M ("PREFERENCES_INSPECT_MAXBUFFERS_LABEL") + ":", Gtk::ALIGN_START)); + maxInspectorBuffersSB = Gtk::manage ( new Gtk::SpinButton () ); maxInspectorBuffersSB->set_digits (0); maxInspectorBuffersSB->set_increments (1, 5); - maxInspectorBuffersSB->set_max_length(2); + maxInspectorBuffersSB->set_max_length (2); maxInspectorBuffersSB->set_range (1, 12); // ... we have to set a limit, 12 seem to be enough even for systems with tons of RAM maxIBuffersHB->pack_start (*maxIBufferLbl, Gtk::PACK_SHRINK, 0); maxIBuffersHB->pack_end (*maxInspectorBuffersSB, Gtk::PACK_SHRINK, 0); - finspect->add(*maxIBuffersHB); - mainContainer->pack_start(*finspect, Gtk::PACK_SHRINK, 4); + finspect->add (*maxIBuffersHB); + mainContainer->pack_start (*finspect, Gtk::PACK_SHRINK, 4); - Gtk::Frame* fdenoise = Gtk::manage( new Gtk::Frame (M("PREFERENCES_NOISE")) ); - Gtk::VBox* vbdenoise = Gtk::manage( new Gtk::VBox (Gtk::PACK_SHRINK, 4) ); + Gtk::Frame* fdenoise = Gtk::manage ( new Gtk::Frame (M ("PREFERENCES_NOISE")) ); + Gtk::VBox* vbdenoise = Gtk::manage ( new Gtk::VBox (Gtk::PACK_SHRINK, 4) ); - Gtk::Label* lreloadneeded2 = Gtk::manage (new Gtk::Label (M("PREFERENCES_IMG_RELOAD_NEEDED"), Gtk::ALIGN_START)); + Gtk::Label* lreloadneeded2 = Gtk::manage (new Gtk::Label (M ("PREFERENCES_IMG_RELOAD_NEEDED"), Gtk::ALIGN_START)); Gtk::HBox* threadLimitHB = Gtk::manage (new Gtk::HBox (Gtk::PACK_SHRINK, 4)); - threadLimitHB->set_tooltip_text(M("PREFERENCES_RGBDTL_TOOLTIP")); - Gtk::Label* RGBDTLl = Gtk::manage( new Gtk::Label (M("PREFERENCES_RGBDTL_LABEL") + ":", Gtk::ALIGN_START)); - rgbDenoiseTreadLimitSB = Gtk::manage( new Gtk::SpinButton () ); + threadLimitHB->set_tooltip_text (M ("PREFERENCES_RGBDTL_TOOLTIP")); + Gtk::Label* RGBDTLl = Gtk::manage ( new Gtk::Label (M ("PREFERENCES_RGBDTL_LABEL") + ":", Gtk::ALIGN_START)); + rgbDenoiseTreadLimitSB = Gtk::manage ( new Gtk::SpinButton () ); rgbDenoiseTreadLimitSB->set_digits (0); rgbDenoiseTreadLimitSB->set_increments (1, 5); - rgbDenoiseTreadLimitSB->set_max_length(2); // Will this be sufficient? :) + rgbDenoiseTreadLimitSB->set_max_length (2); // Will this be sufficient? :) #ifdef _OPENMP int maxThreadNumber = omp_get_max_threads(); #else @@ -617,40 +654,40 @@ Gtk::Widget* Preferences::getPerformancePanel () threadLimitHB->pack_start (*RGBDTLl, Gtk::PACK_SHRINK, 2); threadLimitHB->pack_end (*rgbDenoiseTreadLimitSB, Gtk::PACK_SHRINK, 2); - Gtk::Label* dnlab = Gtk::manage (new Gtk::Label (M("PREFERENCES_LEVDN") + ":", Gtk::ALIGN_START)); - Gtk::Label* dnautlab = Gtk::manage (new Gtk::Label (M("PREFERENCES_LEVAUTDN") + ":", Gtk::ALIGN_START)); - Gtk::Label* dnautsimpllab = Gtk::manage (new Gtk::Label (M("PREFERENCES_SIMPLAUT") + ":", Gtk::ALIGN_START)); - Gtk::Label* dntilab = Gtk::manage (new Gtk::Label (M("PREFERENCES_TINB") + ":", Gtk::ALIGN_START)); - Gtk::Label* dnwavlab = Gtk::manage (new Gtk::Label (M("PREFERENCES_WAVLEV") + ":", Gtk::ALIGN_START)); - Gtk::Label* dnlisslab = Gtk::manage (new Gtk::Label (M("PREFERENCES_LISS") + ":", Gtk::ALIGN_START)); + Gtk::Label* dnlab = Gtk::manage (new Gtk::Label (M ("PREFERENCES_LEVDN") + ":", Gtk::ALIGN_START)); + Gtk::Label* dnautlab = Gtk::manage (new Gtk::Label (M ("PREFERENCES_LEVAUTDN") + ":", Gtk::ALIGN_START)); + Gtk::Label* dnautsimpllab = Gtk::manage (new Gtk::Label (M ("PREFERENCES_SIMPLAUT") + ":", Gtk::ALIGN_START)); + Gtk::Label* dntilab = Gtk::manage (new Gtk::Label (M ("PREFERENCES_TINB") + ":", Gtk::ALIGN_START)); + Gtk::Label* dnwavlab = Gtk::manage (new Gtk::Label (M ("PREFERENCES_WAVLEV") + ":", Gtk::ALIGN_START)); + Gtk::Label* dnlisslab = Gtk::manage (new Gtk::Label (M ("PREFERENCES_LISS") + ":", Gtk::ALIGN_START)); dnv = Gtk::manage (new Gtk::ComboBoxText ()); - dnv->append (M("PREFERENCES_MIN")); - dnv->append (M("PREFERENCES_SMA")); - dnv->append (M("PREFERENCES_MED")); - dnv->append (M("PREFERENCES_MAX")); + dnv->append (M ("PREFERENCES_MIN")); + dnv->append (M ("PREFERENCES_SMA")); + dnv->append (M ("PREFERENCES_MED")); + dnv->append (M ("PREFERENCES_MAX")); dnaut = Gtk::manage (new Gtk::ComboBoxText ()); - dnaut->append (M("PREFERENCES_AUTLOW")); - dnaut->append (M("PREFERENCES_AUTSTD")); + dnaut->append (M ("PREFERENCES_AUTLOW")); + dnaut->append (M ("PREFERENCES_AUTSTD")); dnautsimpl = Gtk::manage (new Gtk::ComboBoxText ()); - dnautsimpl->append (M("PREFERENCES_STDAUT")); - dnautsimpl->append (M("PREFERENCES_EXPAUT")); + dnautsimpl->append (M ("PREFERENCES_STDAUT")); + dnautsimpl->append (M ("PREFERENCES_EXPAUT")); dnliss = Gtk::manage (new Gtk::ComboBoxText ()); - dnliss->append (M("PREFERENCES_AUTLISVLOW"));//very low - dnliss->append (M("PREFERENCES_AUTLISLOW"));//low - dnliss->append (M("PREFERENCES_AUTLISSTD"));//med - dnliss->append (M("PREFERENCES_AUTLISMAX"));//max + dnliss->append (M ("PREFERENCES_AUTLISVLOW")); //very low + dnliss->append (M ("PREFERENCES_AUTLISLOW")); //low + dnliss->append (M ("PREFERENCES_AUTLISSTD")); //med + dnliss->append (M ("PREFERENCES_AUTLISMAX")); //max dnti = Gtk::manage (new Gtk::ComboBoxText ()); - dnti->append (M("PREFERENCES_TISTD")); - dnti->append (M("PREFERENCES_TIMAX")); + dnti->append (M ("PREFERENCES_TISTD")); + dnti->append (M ("PREFERENCES_TIMAX")); dnwavlev = Gtk::manage (new Gtk::ComboBoxText ()); - dnwavlev->append (M("PREFERENCES_WLZER")); - dnwavlev->append (M("PREFERENCES_WLONE")); - dnwavlev->append (M("PREFERENCES_WLTWO")); + dnwavlev->append (M ("PREFERENCES_WLZER")); + dnwavlev->append (M ("PREFERENCES_WLONE")); + dnwavlev->append (M ("PREFERENCES_WLTWO")); Gtk::Table* colon = Gtk::manage (new Gtk::Table (6, 2)); colon->attach (*dnlab, 0, 1, 0, 1, Gtk::FILL, Gtk::SHRINK, 2, 2); @@ -668,10 +705,10 @@ Gtk::Widget* Preferences::getPerformancePanel () vbdenoise->pack_start (*lreloadneeded2, Gtk::PACK_SHRINK); vbdenoise->pack_start (*colon, Gtk::PACK_SHRINK); - vbdenoise->pack_start(*threadLimitHB, Gtk::PACK_SHRINK); + vbdenoise->pack_start (*threadLimitHB, Gtk::PACK_SHRINK); // <--- To be hard-coded and removed once tested - cbdaubech = Gtk::manage (new Gtk::CheckButton (M("PREFERENCES_DAUB_LABEL"), Gtk::ALIGN_START)); - cbdaubech->set_tooltip_markup (M("PREFERENCES_DAUB_TOOLTIP")); + cbdaubech = Gtk::manage (new Gtk::CheckButton (M ("PREFERENCES_DAUB_LABEL"), Gtk::ALIGN_START)); + cbdaubech->set_tooltip_markup (M ("PREFERENCES_DAUB_TOOLTIP")); // vbdenoise->pack_start (*cbdaubech, Gtk::PACK_SHRINK); // ---> fdenoise->add (*vbdenoise); @@ -686,10 +723,10 @@ Gtk::Widget* Preferences::getColorManagementPanel () Gtk::VBox* mvbcm = Gtk::manage (new Gtk::VBox ()); mvbcm->set_spacing (4); - iccDir = Gtk::manage (new Gtk::FileChooserButton (M("PREFERENCES_ICCDIR"), Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER)); - setExpandAlignProperties(iccDir, true, false, Gtk::ALIGN_FILL, Gtk::ALIGN_CENTER); - Gtk::Label* pdlabel = Gtk::manage (new Gtk::Label (M("PREFERENCES_ICCDIR") + ":", Gtk::ALIGN_START)); - setExpandAlignProperties(pdlabel, false, false, Gtk::ALIGN_FILL, Gtk::ALIGN_CENTER); + iccDir = Gtk::manage (new Gtk::FileChooserButton (M ("PREFERENCES_ICCDIR"), Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER)); + setExpandAlignProperties (iccDir, true, false, Gtk::ALIGN_FILL, Gtk::ALIGN_CENTER); + Gtk::Label* pdlabel = Gtk::manage (new Gtk::Label (M ("PREFERENCES_ICCDIR") + ":", Gtk::ALIGN_START)); + setExpandAlignProperties (pdlabel, false, false, Gtk::ALIGN_FILL, Gtk::ALIGN_CENTER); Gtk::Grid* iccdgrid = Gtk::manage (new Gtk::Grid ()); setExpandAlignProperties (iccdgrid, true, false, Gtk::ALIGN_FILL, Gtk::ALIGN_FILL); @@ -700,54 +737,55 @@ Gtk::Widget* Preferences::getColorManagementPanel () iccDir->signal_selection_changed ().connect (sigc::mem_fun (this, &Preferences::iccDirChanged)); - mvbcm->pack_start(*iccdgrid, Gtk::PACK_SHRINK); + mvbcm->pack_start (*iccdgrid, Gtk::PACK_SHRINK); //------------------------- MONITOR ---------------------- - Gtk::Frame* fmonitor = Gtk::manage( new Gtk::Frame (M("PREFERENCES_MONITOR")) ); - Gtk::Grid* gmonitor = Gtk::manage( new Gtk::Grid () ); + Gtk::Frame* fmonitor = Gtk::manage ( new Gtk::Frame (M ("PREFERENCES_MONITOR")) ); + Gtk::Grid* gmonitor = Gtk::manage ( new Gtk::Grid () ); gmonitor->set_column_spacing (4); monProfile = Gtk::manage (new Gtk::ComboBoxText ()); - setExpandAlignProperties(monProfile, true, false, Gtk::ALIGN_FILL, Gtk::ALIGN_CENTER); - Gtk::Label* mplabel = Gtk::manage (new Gtk::Label (M("PREFERENCES_MONPROFILE") + ":", Gtk::ALIGN_START)); - setExpandAlignProperties(mplabel, false, false, Gtk::ALIGN_START, Gtk::ALIGN_CENTER); + setExpandAlignProperties (monProfile, true, false, Gtk::ALIGN_FILL, Gtk::ALIGN_CENTER); + Gtk::Label* mplabel = Gtk::manage (new Gtk::Label (M ("PREFERENCES_MONPROFILE") + ":", Gtk::ALIGN_START)); + setExpandAlignProperties (mplabel, false, false, Gtk::ALIGN_START, Gtk::ALIGN_CENTER); monIntent = Gtk::manage (new Gtk::ComboBoxText ()); - setExpandAlignProperties(monIntent, true, false, Gtk::ALIGN_FILL, Gtk::ALIGN_CENTER); - Gtk::Label* milabel = Gtk::manage (new Gtk::Label (M("PREFERENCES_MONINTENT")+":", Gtk::ALIGN_START)); - setExpandAlignProperties(milabel, false, false, Gtk::ALIGN_START, Gtk::ALIGN_CENTER); + setExpandAlignProperties (monIntent, true, false, Gtk::ALIGN_FILL, Gtk::ALIGN_CENTER); + Gtk::Label* milabel = Gtk::manage (new Gtk::Label (M ("PREFERENCES_MONINTENT") + ":", Gtk::ALIGN_START)); + setExpandAlignProperties (milabel, false, false, Gtk::ALIGN_START, Gtk::ALIGN_CENTER); - monProfile->append (M("PREFERENCES_PROFILE_NONE")); + monProfile->append (M ("PREFERENCES_PROFILE_NONE")); monProfile->set_active (0); const std::vector profiles = rtengine::ICCStore::getInstance ()->getProfiles (rtengine::ICCStore::ProfileType::MONITOR); + for (const auto profile : profiles) { monProfile->append (profile); } // same order as the enum - monIntent->append (M("PREFERENCES_INTENT_PERCEPTUAL")); - monIntent->append (M("PREFERENCES_INTENT_RELATIVE")); - monIntent->append (M("PREFERENCES_INTENT_ABSOLUTE")); + monIntent->append (M ("PREFERENCES_INTENT_PERCEPTUAL")); + monIntent->append (M ("PREFERENCES_INTENT_RELATIVE")); + monIntent->append (M ("PREFERENCES_INTENT_ABSOLUTE")); monIntent->set_active (1); - monIntent->set_size_request(120, -1); + monIntent->set_size_request (120, -1); - monBPC = Gtk::manage (new Gtk::CheckButton (M("PREFERENCES_CMMBPC"))); - setExpandAlignProperties(monBPC, false, false, Gtk::ALIGN_START, Gtk::ALIGN_CENTER); + monBPC = Gtk::manage (new Gtk::CheckButton (M ("PREFERENCES_CMMBPC"))); + setExpandAlignProperties (monBPC, false, false, Gtk::ALIGN_START, Gtk::ALIGN_CENTER); monBPC->set_active (true); #if defined(WIN32) // Auto-detection not implemented for Linux, see issue 851 - cbAutoMonProfile = Gtk::manage (new Gtk::CheckButton (M("PREFERENCES_AUTOMONPROFILE"))); - setExpandAlignProperties(cbAutoMonProfile, false, false, Gtk::ALIGN_START, Gtk::ALIGN_CENTER); - autoMonProfileConn = cbAutoMonProfile->signal_toggled().connect (sigc::mem_fun(*this, &Preferences::autoMonProfileToggled)); + cbAutoMonProfile = Gtk::manage (new Gtk::CheckButton (M ("PREFERENCES_AUTOMONPROFILE"))); + setExpandAlignProperties (cbAutoMonProfile, false, false, Gtk::ALIGN_START, Gtk::ALIGN_CENTER); + autoMonProfileConn = cbAutoMonProfile->signal_toggled().connect (sigc::mem_fun (*this, &Preferences::autoMonProfileToggled)); #endif int row = 0; gmonitor->attach (*mplabel, 0, row, 1, 1); #if defined(__APPLE__) // monitor profile not supported on apple - Gtk::Label *osxwarn = Gtk::manage (new Gtk::Label (M("PREFERENCES_MONPROFILE_WARNOSX"), Gtk::ALIGN_START)); - setExpandAlignProperties(osxwarn, false, false, Gtk::ALIGN_CENTER, Gtk::ALIGN_CENTER); + Gtk::Label *osxwarn = Gtk::manage (new Gtk::Label (M ("PREFERENCES_MONPROFILE_WARNOSX"), Gtk::ALIGN_START)); + setExpandAlignProperties (osxwarn, false, false, Gtk::ALIGN_CENTER, Gtk::ALIGN_CENTER); gmonitor->attach (*osxwarn, 1, row, 1, 1); #else gmonitor->attach (*monProfile, 1, row, 1, 1); @@ -766,40 +804,42 @@ Gtk::Widget* Preferences::getColorManagementPanel () autoMonProfileToggled(); #endif - fmonitor->add(*gmonitor); + fmonitor->add (*gmonitor); - mvbcm->pack_start(*fmonitor, Gtk::PACK_SHRINK); + mvbcm->pack_start (*fmonitor, Gtk::PACK_SHRINK); //------------------------- PRINTER ---------------------- - Gtk::Frame* fprinter = Gtk::manage( new Gtk::Frame (M("PREFERENCES_PRINTER")) ); - Gtk::Grid* gprinter = Gtk::manage( new Gtk::Grid () ); + Gtk::Frame* fprinter = Gtk::manage ( new Gtk::Frame (M ("PREFERENCES_PRINTER")) ); + Gtk::Grid* gprinter = Gtk::manage ( new Gtk::Grid () ); gprinter->set_column_spacing (4); prtProfile = Gtk::manage (new Gtk::ComboBoxText ()); - setExpandAlignProperties(prtProfile, true, false, Gtk::ALIGN_FILL, Gtk::ALIGN_CENTER); - Gtk::Label* pplabel = Gtk::manage (new Gtk::Label (M("PREFERENCES_PRTPROFILE") + ":")); - setExpandAlignProperties(pplabel, false, false, Gtk::ALIGN_START, Gtk::ALIGN_CENTER); + setExpandAlignProperties (prtProfile, true, false, Gtk::ALIGN_FILL, Gtk::ALIGN_CENTER); + Gtk::Label* pplabel = Gtk::manage (new Gtk::Label (M ("PREFERENCES_PRTPROFILE") + ":")); + setExpandAlignProperties (pplabel, false, false, Gtk::ALIGN_START, Gtk::ALIGN_CENTER); prtIntent = Gtk::manage (new Gtk::ComboBoxText ()); - setExpandAlignProperties(prtIntent, true, false, Gtk::ALIGN_FILL, Gtk::ALIGN_CENTER); - Gtk::Label* pilabel = Gtk::manage (new Gtk::Label (M("PREFERENCES_PRTINTENT")+":")); - setExpandAlignProperties(pilabel, false, false, Gtk::ALIGN_START, Gtk::ALIGN_CENTER); + setExpandAlignProperties (prtIntent, true, false, Gtk::ALIGN_FILL, Gtk::ALIGN_CENTER); + Gtk::Label* pilabel = Gtk::manage (new Gtk::Label (M ("PREFERENCES_PRTINTENT") + ":")); + setExpandAlignProperties (pilabel, false, false, Gtk::ALIGN_START, Gtk::ALIGN_CENTER); - prtProfile->append (M("PREFERENCES_PROFILE_NONE")); + prtProfile->append (M ("PREFERENCES_PROFILE_NONE")); prtProfile->set_active (0); const std::vector prtprofiles = rtengine::ICCStore::getInstance ()->getProfiles (rtengine::ICCStore::ProfileType::PRINTER); - for (const auto prtprofile : prtprofiles) + + for (const auto prtprofile : prtprofiles) { prtProfile->append (prtprofile); + } // same order as the enum - prtIntent->append (M("PREFERENCES_INTENT_PERCEPTUAL")); - prtIntent->append (M("PREFERENCES_INTENT_RELATIVE")); - prtIntent->append (M("PREFERENCES_INTENT_ABSOLUTE")); + prtIntent->append (M ("PREFERENCES_INTENT_PERCEPTUAL")); + prtIntent->append (M ("PREFERENCES_INTENT_RELATIVE")); + prtIntent->append (M ("PREFERENCES_INTENT_ABSOLUTE")); prtIntent->set_active (1); - prtBPC = Gtk::manage (new Gtk::CheckButton (M("PREFERENCES_CMMBPC"))); - setExpandAlignProperties(prtBPC, false, false, Gtk::ALIGN_START, Gtk::ALIGN_CENTER); + prtBPC = Gtk::manage (new Gtk::CheckButton (M ("PREFERENCES_CMMBPC"))); + setExpandAlignProperties (prtBPC, false, false, Gtk::ALIGN_START, Gtk::ALIGN_CENTER); prtBPC->set_active (true); row = 0; @@ -814,52 +854,52 @@ Gtk::Widget* Preferences::getColorManagementPanel () autoMonProfileToggled(); #endif - fprinter->add(*gprinter); + fprinter->add (*gprinter); - mvbcm->pack_start(*fprinter, Gtk::PACK_SHRINK); + mvbcm->pack_start (*fprinter, Gtk::PACK_SHRINK); //------------------------- CIECAM ---------------------- - Gtk::Label* viewlab = Gtk::manage (new Gtk::Label (M("PREFERENCES_VIEW") + ":", Gtk::ALIGN_START)); - setExpandAlignProperties(viewlab, false, false, Gtk::ALIGN_START, Gtk::ALIGN_CENTER); + Gtk::Label* viewlab = Gtk::manage (new Gtk::Label (M ("PREFERENCES_VIEW") + ":", Gtk::ALIGN_START)); + setExpandAlignProperties (viewlab, false, false, Gtk::ALIGN_START, Gtk::ALIGN_CENTER); view = Gtk::manage (new Gtk::ComboBoxText ()); - setExpandAlignProperties(view, true, false, Gtk::ALIGN_FILL, Gtk::ALIGN_CENTER); - view->append (M("PREFERENCES_D50")); - view->append (M("PREFERENCES_D55")); - view->append (M("PREFERENCES_D60")); - view->append (M("PREFERENCES_D65")); - view->append (M("PREFERENCES_BLACKBODY")); - view->append (M("PREFERENCES_FLUOF2")); - view->append (M("PREFERENCES_FLUOF7")); - view->append (M("PREFERENCES_FLUOF11")); + setExpandAlignProperties (view, true, false, Gtk::ALIGN_FILL, Gtk::ALIGN_CENTER); + view->append (M ("PREFERENCES_D50")); + view->append (M ("PREFERENCES_D55")); + view->append (M ("PREFERENCES_D60")); + view->append (M ("PREFERENCES_D65")); + view->append (M ("PREFERENCES_BLACKBODY")); + view->append (M ("PREFERENCES_FLUOF2")); + view->append (M ("PREFERENCES_FLUOF7")); + view->append (M ("PREFERENCES_FLUOF11")); - Gtk::Label* greylab = Gtk::manage (new Gtk::Label (M("PREFERENCES_GREY") + ":", Gtk::ALIGN_START)); - setExpandAlignProperties(greylab, false, false, Gtk::ALIGN_START, Gtk::ALIGN_CENTER); + Gtk::Label* greylab = Gtk::manage (new Gtk::Label (M ("PREFERENCES_GREY") + ":", Gtk::ALIGN_START)); + setExpandAlignProperties (greylab, false, false, Gtk::ALIGN_START, Gtk::ALIGN_CENTER); grey = Gtk::manage (new Gtk::ComboBoxText ()); - setExpandAlignProperties(grey, true, false, Gtk::ALIGN_FILL, Gtk::ALIGN_CENTER); - grey->append (M("PREFERENCES_GREY05")); - grey->append (M("PREFERENCES_GREY10")); - grey->append (M("PREFERENCES_GREY15")); - grey->append (M("PREFERENCES_GREY18")); - grey->append (M("PREFERENCES_GREY23")); - grey->append (M("PREFERENCES_GREY30")); - grey->append (M("PREFERENCES_GREY40")); + setExpandAlignProperties (grey, true, false, Gtk::ALIGN_FILL, Gtk::ALIGN_CENTER); + grey->append (M ("PREFERENCES_GREY05")); + grey->append (M ("PREFERENCES_GREY10")); + grey->append (M ("PREFERENCES_GREY15")); + grey->append (M ("PREFERENCES_GREY18")); + grey->append (M ("PREFERENCES_GREY23")); + grey->append (M ("PREFERENCES_GREY30")); + grey->append (M ("PREFERENCES_GREY40")); - Gtk::Label* greySclab = Gtk::manage (new Gtk::Label (M("PREFERENCES_GREYSC") + ":", Gtk::ALIGN_START)); - setExpandAlignProperties(greySclab, false, false, Gtk::ALIGN_START, Gtk::ALIGN_CENTER); + Gtk::Label* greySclab = Gtk::manage (new Gtk::Label (M ("PREFERENCES_GREYSC") + ":", Gtk::ALIGN_START)); + setExpandAlignProperties (greySclab, false, false, Gtk::ALIGN_START, Gtk::ALIGN_CENTER); greySc = Gtk::manage (new Gtk::ComboBoxText ()); - setExpandAlignProperties(greySc, true, false, Gtk::ALIGN_FILL, Gtk::ALIGN_CENTER); - greySc->append (M("PREFERENCES_GREYSCA")); - greySc->append (M("PREFERENCES_GREYSC18")); + setExpandAlignProperties (greySc, true, false, Gtk::ALIGN_FILL, Gtk::ALIGN_CENTER); + greySc->append (M ("PREFERENCES_GREYSCA")); + greySc->append (M ("PREFERENCES_GREYSC18")); - Gtk::Frame* fcielab = Gtk::manage( new Gtk::Frame (M("PREFERENCES_CIEART_FRAME")) ); - setExpandAlignProperties(fcielab, true, false, Gtk::ALIGN_FILL, Gtk::ALIGN_START); + Gtk::Frame* fcielab = Gtk::manage ( new Gtk::Frame (M ("PREFERENCES_CIEART_FRAME")) ); + setExpandAlignProperties (fcielab, true, false, Gtk::ALIGN_FILL, Gtk::ALIGN_START); Gtk::Grid* colo = Gtk::manage (new Gtk::Grid ()); - setExpandAlignProperties(colo, true, false, Gtk::ALIGN_FILL, Gtk::ALIGN_FILL); - Gtk::Label* lreloadneeded1 = Gtk::manage (new Gtk::Label (M("PREFERENCES_IMG_RELOAD_NEEDED"), Gtk::ALIGN_START)); - setExpandAlignProperties(lreloadneeded1, true, false, Gtk::ALIGN_START, Gtk::ALIGN_CENTER); + setExpandAlignProperties (colo, true, false, Gtk::ALIGN_FILL, Gtk::ALIGN_FILL); + Gtk::Label* lreloadneeded1 = Gtk::manage (new Gtk::Label (M ("PREFERENCES_IMG_RELOAD_NEEDED"), Gtk::ALIGN_START)); + setExpandAlignProperties (lreloadneeded1, true, false, Gtk::ALIGN_START, Gtk::ALIGN_CENTER); colo->attach (*lreloadneeded1, 0, 0, 2, 1); colo->attach (*viewlab, 0, 1, 1, 1); colo->attach (*view, 1, 1, 1, 1); @@ -867,10 +907,10 @@ Gtk::Widget* Preferences::getColorManagementPanel () colo->attach (*grey, 1, 2, 1, 1); colo->attach (*greySclab, 0, 3, 1, 1); colo->attach (*greySc, 1, 3, 1, 1); - cbciecamfloat = Gtk::manage (new Gtk::CheckButton (M("PREFERENCES_CIEART_LABEL"))); - setExpandAlignProperties(cbciecamfloat, false, false, Gtk::ALIGN_START, Gtk::ALIGN_CENTER); + cbciecamfloat = Gtk::manage (new Gtk::CheckButton (M ("PREFERENCES_CIEART_LABEL"))); + setExpandAlignProperties (cbciecamfloat, false, false, Gtk::ALIGN_START, Gtk::ALIGN_CENTER); colo->attach (*cbciecamfloat, 0, 4, 2, 1); - cbciecamfloat->set_tooltip_markup (M("PREFERENCES_CIEART_TOOLTIP")); + cbciecamfloat->set_tooltip_markup (M ("PREFERENCES_CIEART_TOOLTIP")); fcielab->add (*colo); mvbcm->pack_start (*fcielab, Gtk::PACK_SHRINK, 4); @@ -881,96 +921,96 @@ Gtk::Widget* Preferences::getColorManagementPanel () Gtk::Widget* Preferences::getGeneralPanel () { - Gtk::Grid* mvbsd = Gtk::manage( new Gtk::Grid () ); - mvbsd->set_column_spacing(4); - mvbsd->set_row_spacing(4); + Gtk::Grid* mvbsd = Gtk::manage ( new Gtk::Grid () ); + mvbsd->set_column_spacing (4); + mvbsd->set_row_spacing (4); - Gtk::Frame* fworklflow = Gtk::manage (new Gtk::Frame (M("PREFERENCES_WORKFLOW"))); - setExpandAlignProperties(fworklflow, true, false, Gtk::ALIGN_FILL, Gtk::ALIGN_START); + Gtk::Frame* fworklflow = Gtk::manage (new Gtk::Frame (M ("PREFERENCES_WORKFLOW"))); + setExpandAlignProperties (fworklflow, true, false, Gtk::ALIGN_FILL, Gtk::ALIGN_START); Gtk::Grid* workflowGrid = Gtk::manage (new Gtk::Grid()); - workflowGrid->set_column_spacing(4); - workflowGrid->set_row_spacing(4); - setExpandAlignProperties(workflowGrid, false, false, Gtk::ALIGN_FILL, Gtk::ALIGN_FILL); + workflowGrid->set_column_spacing (4); + workflowGrid->set_row_spacing (4); + setExpandAlignProperties (workflowGrid, false, false, Gtk::ALIGN_FILL, Gtk::ALIGN_FILL); - Gtk::Label* flayoutlab = Gtk::manage (new Gtk::Label (M("PREFERENCES_EDITORLAYOUT") + ":")); - setExpandAlignProperties(flayoutlab, false, false, Gtk::ALIGN_START, Gtk::ALIGN_BASELINE); + Gtk::Label* flayoutlab = Gtk::manage (new Gtk::Label (M ("PREFERENCES_EDITORLAYOUT") + ":")); + setExpandAlignProperties (flayoutlab, false, false, Gtk::ALIGN_START, Gtk::ALIGN_BASELINE); editorLayout = Gtk::manage (new Gtk::ComboBoxText ()); - setExpandAlignProperties(editorLayout, true, false, Gtk::ALIGN_FILL, Gtk::ALIGN_BASELINE); - editorLayout->append (M("PREFERENCES_SINGLETAB")); - editorLayout->append (M("PREFERENCES_SINGLETABVERTAB")); - editorLayout->append (M("PREFERENCES_MULTITAB")); - editorLayout->append (M("PREFERENCES_MULTITABDUALMON")); + setExpandAlignProperties (editorLayout, true, false, Gtk::ALIGN_FILL, Gtk::ALIGN_BASELINE); + editorLayout->append (M ("PREFERENCES_SINGLETAB")); + editorLayout->append (M ("PREFERENCES_SINGLETABVERTAB")); + editorLayout->append (M ("PREFERENCES_MULTITAB")); + editorLayout->append (M ("PREFERENCES_MULTITABDUALMON")); editorLayout->set_active (2); - Gtk::CellRendererText* cellRenderer = dynamic_cast(editorLayout->get_first_cell()); + Gtk::CellRendererText* cellRenderer = dynamic_cast (editorLayout->get_first_cell()); cellRenderer->property_ellipsize() = Pango::ELLIPSIZE_MIDDLE; cellRenderer->property_ellipsize_set() = true; - editorLayout->signal_changed().connect (sigc::mem_fun(*this, &Preferences::layoutComboChanged)); + editorLayout->signal_changed().connect (sigc::mem_fun (*this, &Preferences::layoutComboChanged)); layoutComboChanged(); // update the tooltip - Gtk::Label* lNextStart = Gtk::manage( new Gtk::Label (Glib::ustring("(") + M("PREFERENCES_APPLNEXTSTARTUP") + ")") ); - setExpandAlignProperties(lNextStart, false, false, Gtk::ALIGN_START, Gtk::ALIGN_BASELINE); - workflowGrid->attach_next_to(*flayoutlab, Gtk::POS_LEFT, 1, 1); - workflowGrid->attach_next_to(*editorLayout, *flayoutlab, Gtk::POS_RIGHT, 1, 1); - workflowGrid->attach_next_to(*lNextStart, *editorLayout, Gtk::POS_RIGHT, 1, 1); + Gtk::Label* lNextStart = Gtk::manage ( new Gtk::Label (Glib::ustring ("(") + M ("PREFERENCES_APPLNEXTSTARTUP") + ")") ); + setExpandAlignProperties (lNextStart, false, false, Gtk::ALIGN_START, Gtk::ALIGN_BASELINE); + workflowGrid->attach_next_to (*flayoutlab, Gtk::POS_LEFT, 1, 1); + workflowGrid->attach_next_to (*editorLayout, *flayoutlab, Gtk::POS_RIGHT, 1, 1); + workflowGrid->attach_next_to (*lNextStart, *editorLayout, Gtk::POS_RIGHT, 1, 1); - Gtk::Label* curveBBoxPosL = Gtk::manage (new Gtk::Label (M("PREFERENCES_CURVEBBOXPOS") + ":")); - setExpandAlignProperties(curveBBoxPosL, false, false, Gtk::ALIGN_START, Gtk::ALIGN_BASELINE); + Gtk::Label* curveBBoxPosL = Gtk::manage (new Gtk::Label (M ("PREFERENCES_CURVEBBOXPOS") + ":")); + setExpandAlignProperties (curveBBoxPosL, false, false, Gtk::ALIGN_START, Gtk::ALIGN_BASELINE); curveBBoxPosC = Gtk::manage (new Gtk::ComboBoxText ()); - setExpandAlignProperties(curveBBoxPosC, true, false, Gtk::ALIGN_FILL, Gtk::ALIGN_BASELINE); - curveBBoxPosC->append (M("PREFERENCES_CURVEBBOXPOS_ABOVE")); - curveBBoxPosC->append (M("PREFERENCES_CURVEBBOXPOS_RIGHT")); - curveBBoxPosC->append (M("PREFERENCES_CURVEBBOXPOS_BELOW")); - curveBBoxPosC->append (M("PREFERENCES_CURVEBBOXPOS_LEFT")); + setExpandAlignProperties (curveBBoxPosC, true, false, Gtk::ALIGN_FILL, Gtk::ALIGN_BASELINE); + curveBBoxPosC->append (M ("PREFERENCES_CURVEBBOXPOS_ABOVE")); + curveBBoxPosC->append (M ("PREFERENCES_CURVEBBOXPOS_RIGHT")); + curveBBoxPosC->append (M ("PREFERENCES_CURVEBBOXPOS_BELOW")); + curveBBoxPosC->append (M ("PREFERENCES_CURVEBBOXPOS_LEFT")); curveBBoxPosC->set_active (1); - Gtk::Label* curveBBoxPosRestartL = Gtk::manage (new Gtk::Label (Glib::ustring("(") + M("PREFERENCES_APPLNEXTSTARTUP") + ")")); - setExpandAlignProperties(curveBBoxPosRestartL, false, false, Gtk::ALIGN_START, Gtk::ALIGN_BASELINE); - workflowGrid->attach_next_to(*curveBBoxPosL, *flayoutlab, Gtk::POS_BOTTOM, 1, 1); - workflowGrid->attach_next_to(*curveBBoxPosC, *editorLayout, Gtk::POS_BOTTOM, 1, 1); - workflowGrid->attach_next_to(*curveBBoxPosRestartL, *lNextStart, Gtk::POS_BOTTOM, 1, 1); + Gtk::Label* curveBBoxPosRestartL = Gtk::manage (new Gtk::Label (Glib::ustring ("(") + M ("PREFERENCES_APPLNEXTSTARTUP") + ")")); + setExpandAlignProperties (curveBBoxPosRestartL, false, false, Gtk::ALIGN_START, Gtk::ALIGN_BASELINE); + workflowGrid->attach_next_to (*curveBBoxPosL, *flayoutlab, Gtk::POS_BOTTOM, 1, 1); + workflowGrid->attach_next_to (*curveBBoxPosC, *editorLayout, Gtk::POS_BOTTOM, 1, 1); + workflowGrid->attach_next_to (*curveBBoxPosRestartL, *lNextStart, Gtk::POS_BOTTOM, 1, 1); - ckbHistogramPositionLeft = Gtk::manage( new Gtk::CheckButton (M("PREFERENCES_HISTOGRAMPOSITIONLEFT")) ); - setExpandAlignProperties(ckbHistogramPositionLeft, false, false, Gtk::ALIGN_START, Gtk::ALIGN_BASELINE); - ckbHistogramWorking = Gtk::manage( new Gtk::CheckButton (M("PREFERENCES_HISTOGRAMWORKING")) ); - setExpandAlignProperties(ckbHistogramWorking, false, false, Gtk::ALIGN_START, Gtk::ALIGN_BASELINE); - ckbHistogramWorking->set_tooltip_markup (M("PREFERENCES_HISTOGRAM_TOOLTIP")); - workflowGrid->attach_next_to(*ckbHistogramPositionLeft, *curveBBoxPosL, Gtk::POS_BOTTOM, 1, 1); - workflowGrid->attach_next_to(*ckbHistogramWorking, *curveBBoxPosC, Gtk::POS_BOTTOM, 2, 1); + ckbHistogramPositionLeft = Gtk::manage ( new Gtk::CheckButton (M ("PREFERENCES_HISTOGRAMPOSITIONLEFT")) ); + setExpandAlignProperties (ckbHistogramPositionLeft, false, false, Gtk::ALIGN_START, Gtk::ALIGN_BASELINE); + ckbHistogramWorking = Gtk::manage ( new Gtk::CheckButton (M ("PREFERENCES_HISTOGRAMWORKING")) ); + setExpandAlignProperties (ckbHistogramWorking, false, false, Gtk::ALIGN_START, Gtk::ALIGN_BASELINE); + ckbHistogramWorking->set_tooltip_markup (M ("PREFERENCES_HISTOGRAM_TOOLTIP")); + workflowGrid->attach_next_to (*ckbHistogramPositionLeft, *curveBBoxPosL, Gtk::POS_BOTTOM, 1, 1); + workflowGrid->attach_next_to (*ckbHistogramWorking, *curveBBoxPosC, Gtk::POS_BOTTOM, 2, 1); - ckbFileBrowserToolbarSingleRow = Gtk::manage( new Gtk::CheckButton (M("PREFERENCES_FILEBROWSERTOOLBARSINGLEROW")) ); - setExpandAlignProperties(ckbFileBrowserToolbarSingleRow, false, false, Gtk::ALIGN_START, Gtk::ALIGN_START); - ckbShowFilmStripToolBar = Gtk::manage( new Gtk::CheckButton (M("PREFERENCES_SHOWFILMSTRIPTOOLBAR")) ); - setExpandAlignProperties(ckbShowFilmStripToolBar, false, false, Gtk::ALIGN_START, Gtk::ALIGN_START); - workflowGrid->attach_next_to(*ckbFileBrowserToolbarSingleRow, *ckbHistogramPositionLeft, Gtk::POS_BOTTOM, 1, 1); - workflowGrid->attach_next_to(*ckbShowFilmStripToolBar, *ckbHistogramWorking, Gtk::POS_BOTTOM, 2, 1); + ckbFileBrowserToolbarSingleRow = Gtk::manage ( new Gtk::CheckButton (M ("PREFERENCES_FILEBROWSERTOOLBARSINGLEROW")) ); + setExpandAlignProperties (ckbFileBrowserToolbarSingleRow, false, false, Gtk::ALIGN_START, Gtk::ALIGN_START); + ckbShowFilmStripToolBar = Gtk::manage ( new Gtk::CheckButton (M ("PREFERENCES_SHOWFILMSTRIPTOOLBAR")) ); + setExpandAlignProperties (ckbShowFilmStripToolBar, false, false, Gtk::ALIGN_START, Gtk::ALIGN_START); + workflowGrid->attach_next_to (*ckbFileBrowserToolbarSingleRow, *ckbHistogramPositionLeft, Gtk::POS_BOTTOM, 1, 1); + workflowGrid->attach_next_to (*ckbShowFilmStripToolBar, *ckbHistogramWorking, Gtk::POS_BOTTOM, 2, 1); - Gtk::Label* hb4label = Gtk::manage( new Gtk::Label (M("PREFERENCES_TP_LABEL")) ); - setExpandAlignProperties(hb4label, false, false, Gtk::ALIGN_START, Gtk::ALIGN_BASELINE); - ckbHideTPVScrollbar = Gtk::manage( new Gtk::CheckButton (M("PREFERENCES_TP_VSCROLLBAR")) ); - setExpandAlignProperties(ckbHideTPVScrollbar, false, false, Gtk::ALIGN_START, Gtk::ALIGN_BASELINE); - ckbUseIconNoText = Gtk::manage( new Gtk::CheckButton (M("PREFERENCES_TP_USEICONORTEXT")) ); - setExpandAlignProperties(ckbUseIconNoText, false, false, Gtk::ALIGN_START, Gtk::ALIGN_BASELINE); - workflowGrid->attach_next_to(*hb4label, *ckbFileBrowserToolbarSingleRow, Gtk::POS_BOTTOM, 1, 1); - workflowGrid->attach_next_to(*ckbHideTPVScrollbar, *hb4label, Gtk::POS_RIGHT, 1, 1); - workflowGrid->attach_next_to(*ckbUseIconNoText, *ckbHideTPVScrollbar, Gtk::POS_RIGHT, 1, 1); + Gtk::Label* hb4label = Gtk::manage ( new Gtk::Label (M ("PREFERENCES_TP_LABEL")) ); + setExpandAlignProperties (hb4label, false, false, Gtk::ALIGN_START, Gtk::ALIGN_BASELINE); + ckbHideTPVScrollbar = Gtk::manage ( new Gtk::CheckButton (M ("PREFERENCES_TP_VSCROLLBAR")) ); + setExpandAlignProperties (ckbHideTPVScrollbar, false, false, Gtk::ALIGN_START, Gtk::ALIGN_BASELINE); + ckbUseIconNoText = Gtk::manage ( new Gtk::CheckButton (M ("PREFERENCES_TP_USEICONORTEXT")) ); + setExpandAlignProperties (ckbUseIconNoText, false, false, Gtk::ALIGN_START, Gtk::ALIGN_BASELINE); + workflowGrid->attach_next_to (*hb4label, *ckbFileBrowserToolbarSingleRow, Gtk::POS_BOTTOM, 1, 1); + workflowGrid->attach_next_to (*ckbHideTPVScrollbar, *hb4label, Gtk::POS_RIGHT, 1, 1); + workflowGrid->attach_next_to (*ckbUseIconNoText, *ckbHideTPVScrollbar, Gtk::POS_RIGHT, 1, 1); fworklflow->add (*workflowGrid); - mvbsd->attach_next_to(*fworklflow, Gtk::POS_TOP, 2, 1); + mvbsd->attach_next_to (*fworklflow, Gtk::POS_TOP, 2, 1); // --------------------------------------------- - Gtk::Frame* flang = Gtk::manage( new Gtk::Frame (M("PREFERENCES_DEFAULTLANG")) ); - setExpandAlignProperties(flang, true, false, Gtk::ALIGN_FILL, Gtk::ALIGN_START); - Gtk::Grid* langGrid = Gtk::manage( new Gtk::Grid() ); - langGrid->set_column_spacing(4); - langGrid->set_row_spacing(4); - setExpandAlignProperties(langGrid, false, false, Gtk::ALIGN_FILL, Gtk::ALIGN_BASELINE); + Gtk::Frame* flang = Gtk::manage ( new Gtk::Frame (M ("PREFERENCES_DEFAULTLANG")) ); + setExpandAlignProperties (flang, true, false, Gtk::ALIGN_FILL, Gtk::ALIGN_START); + Gtk::Grid* langGrid = Gtk::manage ( new Gtk::Grid() ); + langGrid->set_column_spacing (4); + langGrid->set_row_spacing (4); + setExpandAlignProperties (langGrid, false, false, Gtk::ALIGN_FILL, Gtk::ALIGN_BASELINE); - ckbLangAutoDetect = Gtk::manage( new Gtk::CheckButton (M("PREFERENCES_LANGAUTODETECT")) ); - setExpandAlignProperties(ckbLangAutoDetect, false, false, Gtk::ALIGN_START, Gtk::ALIGN_BASELINE); + ckbLangAutoDetect = Gtk::manage ( new Gtk::CheckButton (M ("PREFERENCES_LANGAUTODETECT")) ); + setExpandAlignProperties (ckbLangAutoDetect, false, false, Gtk::ALIGN_START, Gtk::ALIGN_BASELINE); - Gtk::Label* langlab = Gtk::manage( new Gtk::Label (M("PREFERENCES_SELECTLANG") + ":") ); - setExpandAlignProperties(langlab, false, false, Gtk::ALIGN_START, Gtk::ALIGN_BASELINE); - languages = Gtk::manage( new Gtk::ComboBoxText () ); - setExpandAlignProperties(languages, false, false, Gtk::ALIGN_START, Gtk::ALIGN_BASELINE); + Gtk::Label* langlab = Gtk::manage ( new Gtk::Label (M ("PREFERENCES_SELECTLANG") + ":") ); + setExpandAlignProperties (langlab, false, false, Gtk::ALIGN_START, Gtk::ALIGN_BASELINE); + languages = Gtk::manage ( new Gtk::ComboBoxText () ); + setExpandAlignProperties (languages, false, false, Gtk::ALIGN_START, Gtk::ALIGN_BASELINE); std::vector langs; parseDir (argv0 + "/languages", langs, ""); @@ -981,205 +1021,205 @@ Gtk::Widget* Preferences::getGeneralPanel () } } - Gtk::Label* langw = Gtk::manage( new Gtk::Label (Glib::ustring(" (") + M("PREFERENCES_APPLNEXTSTARTUP") + ")") ); - setExpandAlignProperties(langw, false, false, Gtk::ALIGN_START, Gtk::ALIGN_BASELINE); - langGrid->attach_next_to(*ckbLangAutoDetect, Gtk::POS_LEFT, 3, 1); - langGrid->attach_next_to(*langlab, *ckbLangAutoDetect, Gtk::POS_BOTTOM, 1, 1); - langGrid->attach_next_to(*languages, *langlab, Gtk::POS_RIGHT, 1, 1); - langGrid->attach_next_to(*langw, *languages, Gtk::POS_RIGHT, 1, 1); + Gtk::Label* langw = Gtk::manage ( new Gtk::Label (Glib::ustring (" (") + M ("PREFERENCES_APPLNEXTSTARTUP") + ")") ); + setExpandAlignProperties (langw, false, false, Gtk::ALIGN_START, Gtk::ALIGN_BASELINE); + langGrid->attach_next_to (*ckbLangAutoDetect, Gtk::POS_LEFT, 3, 1); + langGrid->attach_next_to (*langlab, *ckbLangAutoDetect, Gtk::POS_BOTTOM, 1, 1); + langGrid->attach_next_to (*languages, *langlab, Gtk::POS_RIGHT, 1, 1); + langGrid->attach_next_to (*langw, *languages, Gtk::POS_RIGHT, 1, 1); flang->add (*langGrid); - mvbsd->attach_next_to(*flang, *fworklflow, Gtk::POS_BOTTOM, 2, 1); + mvbsd->attach_next_to (*flang, *fworklflow, Gtk::POS_BOTTOM, 2, 1); // --------------------------------------------- - Gtk::Frame* ftheme = Gtk::manage( new Gtk::Frame (M("PREFERENCES_DEFAULTTHEME")) ); - setExpandAlignProperties(ftheme, true, false, Gtk::ALIGN_FILL, Gtk::ALIGN_START); - Gtk::Grid* themeGrid = Gtk::manage( new Gtk::Grid() ); - themeGrid->set_column_spacing(4); - themeGrid->set_row_spacing(4); - setExpandAlignProperties(themeGrid, false, false, Gtk::ALIGN_FILL, Gtk::ALIGN_FILL); + Gtk::Frame* ftheme = Gtk::manage ( new Gtk::Frame (M ("PREFERENCES_DEFAULTTHEME")) ); + setExpandAlignProperties (ftheme, true, false, Gtk::ALIGN_FILL, Gtk::ALIGN_START); + Gtk::Grid* themeGrid = Gtk::manage ( new Gtk::Grid() ); + themeGrid->set_column_spacing (4); + themeGrid->set_row_spacing (4); + setExpandAlignProperties (themeGrid, false, false, Gtk::ALIGN_FILL, Gtk::ALIGN_FILL); - Gtk::Label* themelab = Gtk::manage( new Gtk::Label (M("PREFERENCES_SELECTTHEME") + ":") ); - setExpandAlignProperties(themelab, false, false, Gtk::ALIGN_START, Gtk::ALIGN_BASELINE); - theme = Gtk::manage( new Gtk::ComboBoxText () ); - setExpandAlignProperties(theme, false, false, Gtk::ALIGN_START, Gtk::ALIGN_BASELINE); + Gtk::Label* themelab = Gtk::manage ( new Gtk::Label (M ("PREFERENCES_SELECTTHEME") + ":") ); + setExpandAlignProperties (themelab, false, false, Gtk::ALIGN_START, Gtk::ALIGN_BASELINE); + theme = Gtk::manage ( new Gtk::ComboBoxText () ); + setExpandAlignProperties (theme, false, false, Gtk::ALIGN_START, Gtk::ALIGN_BASELINE); theme->set_active (0); - parseThemeDir (Glib::build_filename(argv0, "themes")); + parseThemeDir (Glib::build_filename (argv0, "themes")); for (size_t i = 0; i < themeFNames.size(); i++) { - theme->append (themeFNames.at(i).shortFName); + theme->append (themeFNames.at (i).shortFName); } - themeGrid->attach_next_to(*themelab, Gtk::POS_LEFT, 1, 1); - themeGrid->attach_next_to(*theme, *themelab, Gtk::POS_RIGHT, 1, 1); + themeGrid->attach_next_to (*themelab, Gtk::POS_LEFT, 1, 1); + themeGrid->attach_next_to (*theme, *themelab, Gtk::POS_RIGHT, 1, 1); - Gtk::Label* fontlab = Gtk::manage( new Gtk::Label (M("PREFERENCES_SELECTFONT")) ); - setExpandAlignProperties(fontlab, false, false, Gtk::ALIGN_FILL, Gtk::ALIGN_BASELINE); - fontButton = Gtk::manage( new Gtk::FontButton ()); - setExpandAlignProperties(fontButton, false, false, Gtk::ALIGN_FILL, Gtk::ALIGN_BASELINE); - fontButton->set_use_size(true); - fontButton->set_font_name(Glib::ustring::compose("%1 %2", options.fontFamily == "default" ? "sans" : options.fontFamily, options.fontSize)); + Gtk::Label* fontlab = Gtk::manage ( new Gtk::Label (M ("PREFERENCES_SELECTFONT")) ); + setExpandAlignProperties (fontlab, false, false, Gtk::ALIGN_FILL, Gtk::ALIGN_BASELINE); + fontButton = Gtk::manage ( new Gtk::FontButton ()); + setExpandAlignProperties (fontButton, false, false, Gtk::ALIGN_FILL, Gtk::ALIGN_BASELINE); + fontButton->set_use_size (true); + fontButton->set_font_name (Glib::ustring::compose ("%1 %2", options.fontFamily == "default" ? "sans" : options.fontFamily, options.fontSize)); - themeGrid->attach_next_to(*fontlab, *theme, Gtk::POS_RIGHT, 1, 1); - themeGrid->attach_next_to(*fontButton, *fontlab, Gtk::POS_RIGHT, 1, 1); + themeGrid->attach_next_to (*fontlab, *theme, Gtk::POS_RIGHT, 1, 1); + themeGrid->attach_next_to (*fontButton, *fontlab, Gtk::POS_RIGHT, 1, 1); - Gtk::Label* cpfontlab = Gtk::manage( new Gtk::Label (M("PREFERENCES_SELECTFONT_COLPICKER") + ":") ); - setExpandAlignProperties(cpfontlab, false, false, Gtk::ALIGN_FILL, Gtk::ALIGN_BASELINE); - colorPickerFontButton = Gtk::manage( new Gtk::FontButton ()); - setExpandAlignProperties(fontButton, false, false, Gtk::ALIGN_FILL, Gtk::ALIGN_BASELINE); - colorPickerFontButton->set_use_size(true); - colorPickerFontButton->set_font_name(Glib::ustring::compose("%1 %2", options.CPFontFamily == "default" ? "sans" : options.CPFontFamily, options.CPFontSize)); + Gtk::Label* cpfontlab = Gtk::manage ( new Gtk::Label (M ("PREFERENCES_SELECTFONT_COLPICKER") + ":") ); + setExpandAlignProperties (cpfontlab, false, false, Gtk::ALIGN_FILL, Gtk::ALIGN_BASELINE); + colorPickerFontButton = Gtk::manage ( new Gtk::FontButton ()); + setExpandAlignProperties (fontButton, false, false, Gtk::ALIGN_FILL, Gtk::ALIGN_BASELINE); + colorPickerFontButton->set_use_size (true); + colorPickerFontButton->set_font_name (Glib::ustring::compose ("%1 %2", options.CPFontFamily == "default" ? "sans" : options.CPFontFamily, options.CPFontSize)); - themeGrid->attach_next_to(*cpfontlab, *fontButton, Gtk::POS_RIGHT, 1, 1); - themeGrid->attach_next_to(*colorPickerFontButton, *cpfontlab, Gtk::POS_RIGHT, 1, 1); + themeGrid->attach_next_to (*cpfontlab, *fontButton, Gtk::POS_RIGHT, 1, 1); + themeGrid->attach_next_to (*colorPickerFontButton, *cpfontlab, Gtk::POS_RIGHT, 1, 1); - Gtk::Label* cutOverlayLabel = Gtk::manage( new Gtk::Label (M("PREFERENCES_CUTOVERLAYBRUSH") + ":") ); - setExpandAlignProperties(cutOverlayLabel, false, false, Gtk::ALIGN_START, Gtk::ALIGN_BASELINE); - butCropCol = Gtk::manage( new Gtk::ColorButton() ); - setExpandAlignProperties(butCropCol, false, false, Gtk::ALIGN_START, Gtk::ALIGN_CENTER); - butCropCol->set_use_alpha(true); - themeGrid->attach_next_to(*cutOverlayLabel, *themelab, Gtk::POS_BOTTOM, 1, 1); - themeGrid->attach_next_to(*butCropCol, *cutOverlayLabel, Gtk::POS_RIGHT, 1, 1); + Gtk::Label* cutOverlayLabel = Gtk::manage ( new Gtk::Label (M ("PREFERENCES_CUTOVERLAYBRUSH") + ":") ); + setExpandAlignProperties (cutOverlayLabel, false, false, Gtk::ALIGN_START, Gtk::ALIGN_BASELINE); + butCropCol = Gtk::manage ( new Gtk::ColorButton() ); + setExpandAlignProperties (butCropCol, false, false, Gtk::ALIGN_START, Gtk::ALIGN_CENTER); + butCropCol->set_use_alpha (true); + themeGrid->attach_next_to (*cutOverlayLabel, *themelab, Gtk::POS_BOTTOM, 1, 1); + themeGrid->attach_next_to (*butCropCol, *cutOverlayLabel, Gtk::POS_RIGHT, 1, 1); - Gtk::Label* navGuideLabel = Gtk::manage( new Gtk::Label (M("PREFERENCES_NAVGUIDEBRUSH") + ":") ); - setExpandAlignProperties(navGuideLabel, false, false, Gtk::ALIGN_START, Gtk::ALIGN_BASELINE); - butNavGuideCol = Gtk::manage( new Gtk::ColorButton() ); - setExpandAlignProperties(butNavGuideCol, false, false, Gtk::ALIGN_START, Gtk::ALIGN_CENTER); - butNavGuideCol->set_use_alpha(true); - themeGrid->attach_next_to(*navGuideLabel, *butCropCol, Gtk::POS_RIGHT, 2, 1); - themeGrid->attach_next_to(*butNavGuideCol, *navGuideLabel, Gtk::POS_RIGHT, 1, 1); + Gtk::Label* navGuideLabel = Gtk::manage ( new Gtk::Label (M ("PREFERENCES_NAVGUIDEBRUSH") + ":") ); + setExpandAlignProperties (navGuideLabel, false, false, Gtk::ALIGN_START, Gtk::ALIGN_BASELINE); + butNavGuideCol = Gtk::manage ( new Gtk::ColorButton() ); + setExpandAlignProperties (butNavGuideCol, false, false, Gtk::ALIGN_START, Gtk::ALIGN_CENTER); + butNavGuideCol->set_use_alpha (true); + themeGrid->attach_next_to (*navGuideLabel, *butCropCol, Gtk::POS_RIGHT, 2, 1); + themeGrid->attach_next_to (*butNavGuideCol, *navGuideLabel, Gtk::POS_RIGHT, 1, 1); ftheme->add (*themeGrid); - mvbsd->attach_next_to(*ftheme, *flang, Gtk::POS_BOTTOM, 2, 1); + mvbsd->attach_next_to (*ftheme, *flang, Gtk::POS_BOTTOM, 2, 1); // --------------------------------------------- - Gtk::Frame* fclip = Gtk::manage( new Gtk::Frame (M("PREFERENCES_CLIPPINGIND"))); - setExpandAlignProperties(fclip, true, false, Gtk::ALIGN_FILL, Gtk::ALIGN_FILL); - Gtk::Grid* clipGrid = Gtk::manage( new Gtk::Grid() ); - clipGrid->set_column_spacing(4); - clipGrid->set_row_spacing(4); - setExpandAlignProperties(clipGrid, false, false, Gtk::ALIGN_FILL, Gtk::ALIGN_FILL); + Gtk::Frame* fclip = Gtk::manage ( new Gtk::Frame (M ("PREFERENCES_CLIPPINGIND"))); + setExpandAlignProperties (fclip, true, false, Gtk::ALIGN_FILL, Gtk::ALIGN_FILL); + Gtk::Grid* clipGrid = Gtk::manage ( new Gtk::Grid() ); + clipGrid->set_column_spacing (4); + clipGrid->set_row_spacing (4); + setExpandAlignProperties (clipGrid, false, false, Gtk::ALIGN_FILL, Gtk::ALIGN_FILL); - Gtk::Label* hll = Gtk::manage( new Gtk::Label (M("PREFERENCES_HLTHRESHOLD") + ": ")); - setExpandAlignProperties(hll, true, false, Gtk::ALIGN_START, Gtk::ALIGN_BASELINE); - hlThresh = Gtk::manage( new Gtk::SpinButton () ); - setExpandAlignProperties(hlThresh, false, false, Gtk::ALIGN_END, Gtk::ALIGN_BASELINE); + Gtk::Label* hll = Gtk::manage ( new Gtk::Label (M ("PREFERENCES_HLTHRESHOLD") + ": ")); + setExpandAlignProperties (hll, true, false, Gtk::ALIGN_START, Gtk::ALIGN_BASELINE); + hlThresh = Gtk::manage ( new Gtk::SpinButton () ); + setExpandAlignProperties (hlThresh, false, false, Gtk::ALIGN_END, Gtk::ALIGN_BASELINE); hlThresh->set_digits (0); hlThresh->set_increments (1, 10); hlThresh->set_range (0, 255); - clipGrid->attach_next_to(*hll, Gtk::POS_LEFT, 1, 1); - clipGrid->attach_next_to(*hlThresh, *hll, Gtk::POS_RIGHT, 1, 1); + clipGrid->attach_next_to (*hll, Gtk::POS_LEFT, 1, 1); + clipGrid->attach_next_to (*hlThresh, *hll, Gtk::POS_RIGHT, 1, 1); - Gtk::Label* shl = Gtk::manage( new Gtk::Label (M("PREFERENCES_SHTHRESHOLD") + ": ") ); - setExpandAlignProperties(shl, true, false, Gtk::ALIGN_START, Gtk::ALIGN_BASELINE); - shThresh = Gtk::manage( new Gtk::SpinButton () ); - setExpandAlignProperties(shThresh, false, false, Gtk::ALIGN_END, Gtk::ALIGN_BASELINE); + Gtk::Label* shl = Gtk::manage ( new Gtk::Label (M ("PREFERENCES_SHTHRESHOLD") + ": ") ); + setExpandAlignProperties (shl, true, false, Gtk::ALIGN_START, Gtk::ALIGN_BASELINE); + shThresh = Gtk::manage ( new Gtk::SpinButton () ); + setExpandAlignProperties (shThresh, false, false, Gtk::ALIGN_END, Gtk::ALIGN_BASELINE); shThresh->show (); shThresh->set_digits (0); shThresh->set_increments (1, 10); shThresh->set_range (0, 255); - clipGrid->attach_next_to(*shl, *hll, Gtk::POS_BOTTOM, 1, 1); - clipGrid->attach_next_to(*shThresh, *shl, Gtk::POS_RIGHT, 1, 1); + clipGrid->attach_next_to (*shl, *hll, Gtk::POS_BOTTOM, 1, 1); + clipGrid->attach_next_to (*shThresh, *shl, Gtk::POS_RIGHT, 1, 1); fclip->add (*clipGrid); - mvbsd->attach_next_to(*fclip, *ftheme, Gtk::POS_BOTTOM, 1, 1); + mvbsd->attach_next_to (*fclip, *ftheme, Gtk::POS_BOTTOM, 1, 1); // --------------------------------------------- - Gtk::Frame* fnav = Gtk::manage( new Gtk::Frame (M("PREFERENCES_NAVIGATIONFRAME")) ); - setExpandAlignProperties(fclip, true, false, Gtk::ALIGN_FILL, Gtk::ALIGN_FILL); - Gtk::Grid* navigationGrid = Gtk::manage( new Gtk::Grid() ); - navigationGrid->set_column_spacing(4); - navigationGrid->set_row_spacing(4); - setExpandAlignProperties(fclip, false, false, Gtk::ALIGN_START, Gtk::ALIGN_FILL); + Gtk::Frame* fnav = Gtk::manage ( new Gtk::Frame (M ("PREFERENCES_NAVIGATIONFRAME")) ); + setExpandAlignProperties (fclip, true, false, Gtk::ALIGN_FILL, Gtk::ALIGN_FILL); + Gtk::Grid* navigationGrid = Gtk::manage ( new Gtk::Grid() ); + navigationGrid->set_column_spacing (4); + navigationGrid->set_row_spacing (4); + setExpandAlignProperties (fclip, false, false, Gtk::ALIGN_START, Gtk::ALIGN_FILL); - Gtk::Label* panFactorLabel = Gtk::manage( new Gtk::Label (M("PREFERENCES_PANFACTORLABEL") + ":", Gtk::ALIGN_START)); - setExpandAlignProperties(panFactorLabel, false, false, Gtk::ALIGN_START, Gtk::ALIGN_BASELINE); - panFactor = Gtk::manage( new Gtk::SpinButton () ); - setExpandAlignProperties(panFactor, true, false, Gtk::ALIGN_START, Gtk::ALIGN_BASELINE); + Gtk::Label* panFactorLabel = Gtk::manage ( new Gtk::Label (M ("PREFERENCES_PANFACTORLABEL") + ":", Gtk::ALIGN_START)); + setExpandAlignProperties (panFactorLabel, false, false, Gtk::ALIGN_START, Gtk::ALIGN_BASELINE); + panFactor = Gtk::manage ( new Gtk::SpinButton () ); + setExpandAlignProperties (panFactor, true, false, Gtk::ALIGN_START, Gtk::ALIGN_BASELINE); panFactor->set_digits (0); panFactor->set_increments (1, 5); panFactor->set_range (1, 10); - navigationGrid->attach_next_to(*panFactorLabel, Gtk::POS_LEFT, 1, 1); - navigationGrid->attach_next_to(*panFactor, *panFactorLabel, Gtk::POS_RIGHT, 1, 1); + navigationGrid->attach_next_to (*panFactorLabel, Gtk::POS_LEFT, 1, 1); + navigationGrid->attach_next_to (*panFactor, *panFactorLabel, Gtk::POS_RIGHT, 1, 1); - rememberZoomPanCheckbutton = Gtk::manage( new Gtk::CheckButton (M("PREFERENCES_REMEMBERZOOMPAN")) ); - setExpandAlignProperties(rememberZoomPanCheckbutton, false, false, Gtk::ALIGN_START, Gtk::ALIGN_BASELINE); - rememberZoomPanCheckbutton->set_tooltip_text(M("PREFERENCES_REMEMBERZOOMPAN_TOOLTIP")); + rememberZoomPanCheckbutton = Gtk::manage ( new Gtk::CheckButton (M ("PREFERENCES_REMEMBERZOOMPAN")) ); + setExpandAlignProperties (rememberZoomPanCheckbutton, false, false, Gtk::ALIGN_START, Gtk::ALIGN_BASELINE); + rememberZoomPanCheckbutton->set_tooltip_text (M ("PREFERENCES_REMEMBERZOOMPAN_TOOLTIP")); - navigationGrid->attach_next_to(*rememberZoomPanCheckbutton, *panFactorLabel, Gtk::POS_BOTTOM, 2, 1); + navigationGrid->attach_next_to (*rememberZoomPanCheckbutton, *panFactorLabel, Gtk::POS_BOTTOM, 2, 1); fnav->add (*navigationGrid); - mvbsd->attach_next_to(*fnav, *fclip, Gtk::POS_RIGHT, 1, 1); + mvbsd->attach_next_to (*fnav, *fclip, Gtk::POS_RIGHT, 1, 1); // --------------------------------------------- - Gtk::Frame* fdg = Gtk::manage( new Gtk::Frame (M("PREFERENCES_EXTERNALEDITOR")) ); - setExpandAlignProperties(fdg, true, false, Gtk::ALIGN_FILL, Gtk::ALIGN_FILL); - Gtk::Grid* externaleditorGrid = Gtk::manage( new Gtk::Grid() ); - externaleditorGrid->set_column_spacing(4); - externaleditorGrid->set_row_spacing(4); - setExpandAlignProperties(externaleditorGrid, false, false, Gtk::ALIGN_FILL, Gtk::ALIGN_FILL); + Gtk::Frame* fdg = Gtk::manage ( new Gtk::Frame (M ("PREFERENCES_EXTERNALEDITOR")) ); + setExpandAlignProperties (fdg, true, false, Gtk::ALIGN_FILL, Gtk::ALIGN_FILL); + Gtk::Grid* externaleditorGrid = Gtk::manage ( new Gtk::Grid() ); + externaleditorGrid->set_column_spacing (4); + externaleditorGrid->set_row_spacing (4); + setExpandAlignProperties (externaleditorGrid, false, false, Gtk::ALIGN_FILL, Gtk::ALIGN_FILL); - edOther = Gtk::manage( new Gtk::RadioButton (M("PREFERENCES_EDITORCMDLINE") + ":")); - setExpandAlignProperties(edOther, false, false, Gtk::ALIGN_START, Gtk::ALIGN_CENTER); - editorToSendTo = Gtk::manage( new Gtk::Entry () ); - setExpandAlignProperties(editorToSendTo, true, false, Gtk::ALIGN_FILL, Gtk::ALIGN_BASELINE); + edOther = Gtk::manage ( new Gtk::RadioButton (M ("PREFERENCES_EDITORCMDLINE") + ":")); + setExpandAlignProperties (edOther, false, false, Gtk::ALIGN_START, Gtk::ALIGN_CENTER); + editorToSendTo = Gtk::manage ( new Gtk::Entry () ); + setExpandAlignProperties (editorToSendTo, true, false, Gtk::ALIGN_FILL, Gtk::ALIGN_BASELINE); Gtk::RadioButton::Group ge = edOther->get_group(); #ifdef __APPLE__ - edGimp = Gtk::manage( new Gtk::RadioButton ("GIMP") ); - setExpandAlignProperties(edGimp, false, false, Gtk::ALIGN_START, Gtk::ALIGN_CENTER); + edGimp = Gtk::manage ( new Gtk::RadioButton ("GIMP") ); + setExpandAlignProperties (edGimp, false, false, Gtk::ALIGN_START, Gtk::ALIGN_CENTER); edGimp->set_group (ge); - externaleditorGrid->attach_next_to(*edGimp, Gtk::POS_TOP, 2, 1); + externaleditorGrid->attach_next_to (*edGimp, Gtk::POS_TOP, 2, 1); - edPS = Gtk::manage( new Gtk::RadioButton (M("PREFERENCES_PSPATH") + ":")); - setExpandAlignProperties(edPS, false, false, Gtk::ALIGN_START, Gtk::ALIGN_CENTER); - psDir = Gtk::manage( new Gtk::FileChooserButton (M("PREFERENCES_PSPATH"), Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER) ); - setExpandAlignProperties(psDir, true, false, Gtk::ALIGN_FILL, Gtk::ALIGN_CENTER); - externaleditorGrid->attach_next_to(*edPS, *edGimp, Gtk::POS_BOTTOM, 1, 1); - externaleditorGrid->attach_next_to(*psDir, *edPS, Gtk::POS_RIGHT, 1, 1); + edPS = Gtk::manage ( new Gtk::RadioButton (M ("PREFERENCES_PSPATH") + ":")); + setExpandAlignProperties (edPS, false, false, Gtk::ALIGN_START, Gtk::ALIGN_CENTER); + psDir = Gtk::manage ( new Gtk::FileChooserButton (M ("PREFERENCES_PSPATH"), Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER) ); + setExpandAlignProperties (psDir, true, false, Gtk::ALIGN_FILL, Gtk::ALIGN_CENTER); + externaleditorGrid->attach_next_to (*edPS, *edGimp, Gtk::POS_BOTTOM, 1, 1); + externaleditorGrid->attach_next_to (*psDir, *edPS, Gtk::POS_RIGHT, 1, 1); edPS->set_group (ge); - externaleditorGrid->attach_next_to(*edOther, *edPS, Gtk::POS_BOTTOM, 1, 1); - externaleditorGrid->attach_next_to(*editorToSendTo, *edOther, Gtk::POS_RIGHT, 1, 1); + externaleditorGrid->attach_next_to (*edOther, *edPS, Gtk::POS_BOTTOM, 1, 1); + externaleditorGrid->attach_next_to (*editorToSendTo, *edOther, Gtk::POS_RIGHT, 1, 1); #elif defined WIN32 - edGimp = Gtk::manage( new Gtk::RadioButton (M("PREFERENCES_GIMPPATH") + ":") ); - setExpandAlignProperties(edGimp, false, false, Gtk::ALIGN_START, Gtk::ALIGN_CENTER); - gimpDir = Gtk::manage( new Gtk::FileChooserButton (M("PREFERENCES_GIMPPATH"), Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER) ); - setExpandAlignProperties(gimpDir, true, false, Gtk::ALIGN_FILL, Gtk::ALIGN_CENTER); - externaleditorGrid->attach_next_to(*edGimp, Gtk::POS_TOP, 1, 1); - externaleditorGrid->attach_next_to(*gimpDir, *edGimp, Gtk::POS_RIGHT, 1, 1); + edGimp = Gtk::manage ( new Gtk::RadioButton (M ("PREFERENCES_GIMPPATH") + ":") ); + setExpandAlignProperties (edGimp, false, false, Gtk::ALIGN_START, Gtk::ALIGN_CENTER); + gimpDir = Gtk::manage ( new Gtk::FileChooserButton (M ("PREFERENCES_GIMPPATH"), Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER) ); + setExpandAlignProperties (gimpDir, true, false, Gtk::ALIGN_FILL, Gtk::ALIGN_CENTER); + externaleditorGrid->attach_next_to (*edGimp, Gtk::POS_TOP, 1, 1); + externaleditorGrid->attach_next_to (*gimpDir, *edGimp, Gtk::POS_RIGHT, 1, 1); edGimp->set_group (ge); - edPS = Gtk::manage( new Gtk::RadioButton (M("PREFERENCES_PSPATH") + ":") ); - setExpandAlignProperties(edPS, false, false, Gtk::ALIGN_START, Gtk::ALIGN_CENTER); - psDir = Gtk::manage( new Gtk::FileChooserButton (M("PREFERENCES_PSPATH"), Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER) ); - setExpandAlignProperties(psDir, true, false, Gtk::ALIGN_FILL, Gtk::ALIGN_CENTER); - externaleditorGrid->attach_next_to(*edPS, *edGimp, Gtk::POS_BOTTOM, 1, 1); - externaleditorGrid->attach_next_to(*psDir, *edPS, Gtk::POS_RIGHT, 1, 1); + edPS = Gtk::manage ( new Gtk::RadioButton (M ("PREFERENCES_PSPATH") + ":") ); + setExpandAlignProperties (edPS, false, false, Gtk::ALIGN_START, Gtk::ALIGN_CENTER); + psDir = Gtk::manage ( new Gtk::FileChooserButton (M ("PREFERENCES_PSPATH"), Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER) ); + setExpandAlignProperties (psDir, true, false, Gtk::ALIGN_FILL, Gtk::ALIGN_CENTER); + externaleditorGrid->attach_next_to (*edPS, *edGimp, Gtk::POS_BOTTOM, 1, 1); + externaleditorGrid->attach_next_to (*psDir, *edPS, Gtk::POS_RIGHT, 1, 1); edPS->set_group (ge); - externaleditorGrid->attach_next_to(*edOther, *edPS, Gtk::POS_BOTTOM, 1, 1); - externaleditorGrid->attach_next_to(*editorToSendTo, *edOther, Gtk::POS_RIGHT, 1, 1); + externaleditorGrid->attach_next_to (*edOther, *edPS, Gtk::POS_BOTTOM, 1, 1); + externaleditorGrid->attach_next_to (*editorToSendTo, *edOther, Gtk::POS_RIGHT, 1, 1); #else - edGimp = Gtk::manage( new Gtk::RadioButton ("GIMP") ); - setExpandAlignProperties(edGimp, false, false, Gtk::ALIGN_START, Gtk::ALIGN_CENTER); - externaleditorGrid->attach_next_to(*edGimp, Gtk::POS_TOP, 2, 1); + edGimp = Gtk::manage ( new Gtk::RadioButton ("GIMP") ); + setExpandAlignProperties (edGimp, false, false, Gtk::ALIGN_START, Gtk::ALIGN_CENTER); + externaleditorGrid->attach_next_to (*edGimp, Gtk::POS_TOP, 2, 1); edGimp->set_group (ge); - externaleditorGrid->attach_next_to(*edOther, *edGimp, Gtk::POS_BOTTOM, 1, 1); - externaleditorGrid->attach_next_to(*editorToSendTo, *edOther, Gtk::POS_RIGHT, 1, 1); + externaleditorGrid->attach_next_to (*edOther, *edGimp, Gtk::POS_BOTTOM, 1, 1); + externaleditorGrid->attach_next_to (*editorToSendTo, *edOther, Gtk::POS_RIGHT, 1, 1); #endif fdg->add (*externaleditorGrid); - mvbsd->attach_next_to(*fdg, *fclip, Gtk::POS_BOTTOM, 2, 1); + mvbsd->attach_next_to (*fdg, *fclip, Gtk::POS_BOTTOM, 2, 1); - langAutoDetectConn = ckbLangAutoDetect->signal_toggled().connect (sigc::mem_fun(*this, &Preferences::langAutoDetectToggled)); - tconn = theme->signal_changed().connect( sigc::mem_fun(*this, &Preferences::themeChanged) ); - fconn = fontButton->signal_font_set().connect( sigc::mem_fun(*this, &Preferences::fontChanged) ); + langAutoDetectConn = ckbLangAutoDetect->signal_toggled().connect (sigc::mem_fun (*this, &Preferences::langAutoDetectToggled)); + tconn = theme->signal_changed().connect ( sigc::mem_fun (*this, &Preferences::themeChanged) ); + fconn = fontButton->signal_font_set().connect ( sigc::mem_fun (*this, &Preferences::fontChanged) ); return mvbsd; } @@ -1187,29 +1227,29 @@ Gtk::Widget* Preferences::getGeneralPanel () Gtk::Widget* Preferences::getFileBrowserPanel () { - Gtk::VBox* mvbfb = Gtk::manage( new Gtk::VBox () ); + Gtk::VBox* mvbfb = Gtk::manage ( new Gtk::VBox () ); - Gtk::Frame* fsd = Gtk::manage( new Gtk::Frame (M("PREFERENCES_STARTUPIMDIR")) ); + Gtk::Frame* fsd = Gtk::manage ( new Gtk::Frame (M ("PREFERENCES_STARTUPIMDIR")) ); - sdcurrent = Gtk::manage( new Gtk::RadioButton (M("PREFERENCES_DIRSOFTWARE")) ); - sdlast = Gtk::manage( new Gtk::RadioButton (M("PREFERENCES_DIRLAST")) ); - sdhome = Gtk::manage( new Gtk::RadioButton (M("PREFERENCES_DIRHOME")) ); - sdother = Gtk::manage( new Gtk::RadioButton (M("PREFERENCES_DIROTHER") + ": ") ); - startupdir = Gtk::manage( new Gtk::Entry () ); + sdcurrent = Gtk::manage ( new Gtk::RadioButton (M ("PREFERENCES_DIRSOFTWARE")) ); + sdlast = Gtk::manage ( new Gtk::RadioButton (M ("PREFERENCES_DIRLAST")) ); + sdhome = Gtk::manage ( new Gtk::RadioButton (M ("PREFERENCES_DIRHOME")) ); + sdother = Gtk::manage ( new Gtk::RadioButton (M ("PREFERENCES_DIROTHER") + ": ") ); + startupdir = Gtk::manage ( new Gtk::Entry () ); - Gtk::Button* sdselect = Gtk::manage( new Gtk::Button () ); - sdselect->set_image (*Gtk::manage(new RTImage ("gtk-open.png"))); + Gtk::Button* sdselect = Gtk::manage ( new Gtk::Button () ); + sdselect->set_image (*Gtk::manage (new RTImage ("gtk-open.png"))); Gtk::RadioButton::Group opts = sdcurrent->get_group(); sdlast->set_group (opts); sdhome->set_group (opts); sdother->set_group (opts); - Gtk::VBox* vbsd = Gtk::manage( new Gtk::VBox () ); + Gtk::VBox* vbsd = Gtk::manage ( new Gtk::VBox () ); vbsd->pack_start (*sdcurrent, Gtk::PACK_SHRINK, 0); vbsd->pack_start (*sdlast, Gtk::PACK_SHRINK, 0); vbsd->pack_start (*sdhome, Gtk::PACK_SHRINK, 0); - Gtk::HBox* otherbox = Gtk::manage( new Gtk::HBox () ); + Gtk::HBox* otherbox = Gtk::manage ( new Gtk::HBox () ); otherbox->pack_start (*sdother, Gtk::PACK_SHRINK); otherbox->pack_start (*startupdir); otherbox->pack_end (*sdselect, Gtk::PACK_SHRINK, 4); @@ -1218,29 +1258,29 @@ Gtk::Widget* Preferences::getFileBrowserPanel () fsd->add (*vbsd); mvbfb->pack_start (*fsd, Gtk::PACK_SHRINK, 4); - sdselect->signal_clicked().connect( sigc::mem_fun(*this, &Preferences::selectStartupDir) ); + sdselect->signal_clicked().connect ( sigc::mem_fun (*this, &Preferences::selectStartupDir) ); //--- - Gtk::Frame* fro = Gtk::manage( new Gtk::Frame (M("PREFERENCES_FBROWSEROPTS")) ); - showDateTime = Gtk::manage( new Gtk::CheckButton (M("PREFERENCES_SHOWDATETIME")) ); - showBasicExif = Gtk::manage( new Gtk::CheckButton (M("PREFERENCES_SHOWBASICEXIF")) ); - showExpComp = Gtk::manage( new Gtk::CheckButton (M("PREFERENCES_SHOWEXPOSURECOMPENSATION")) ); - Gtk::VBox* vbro = Gtk::manage( new Gtk::VBox () ); - Gtk::HBox* hbro1 = Gtk::manage( new Gtk::HBox () ); - Gtk::HBox* hbro0 = Gtk::manage( new Gtk::HBox () ); - overlayedFileNames = Gtk::manage( new Gtk::CheckButton (M("PREFERENCES_OVERLAY_FILENAMES")) ); - filmStripOverlayedFileNames = Gtk::manage( new Gtk::CheckButton (M("PREFERENCES_OVERLAY_FILENAMES_FILMSTRIP")) ); - sameThumbSize = Gtk::manage( new Gtk::CheckButton (M("PREFERENCES_FSTRIP_SAME_THUMB_HEIGHT")) ); - sameThumbSize->set_tooltip_text(M("PREFERENCES_FSTRIP_SAME_THUMB_HEIGHT_HINT")); - ckbInternalThumbIfUntouched = Gtk::manage( new Gtk::CheckButton (M("PREFERENCES_INTERNALTHUMBIFUNTOUCHED"))); + Gtk::Frame* fro = Gtk::manage ( new Gtk::Frame (M ("PREFERENCES_FBROWSEROPTS")) ); + showDateTime = Gtk::manage ( new Gtk::CheckButton (M ("PREFERENCES_SHOWDATETIME")) ); + showBasicExif = Gtk::manage ( new Gtk::CheckButton (M ("PREFERENCES_SHOWBASICEXIF")) ); + showExpComp = Gtk::manage ( new Gtk::CheckButton (M ("PREFERENCES_SHOWEXPOSURECOMPENSATION")) ); + Gtk::VBox* vbro = Gtk::manage ( new Gtk::VBox () ); + Gtk::HBox* hbro1 = Gtk::manage ( new Gtk::HBox () ); + Gtk::HBox* hbro0 = Gtk::manage ( new Gtk::HBox () ); + overlayedFileNames = Gtk::manage ( new Gtk::CheckButton (M ("PREFERENCES_OVERLAY_FILENAMES")) ); + filmStripOverlayedFileNames = Gtk::manage ( new Gtk::CheckButton (M ("PREFERENCES_OVERLAY_FILENAMES_FILMSTRIP")) ); + sameThumbSize = Gtk::manage ( new Gtk::CheckButton (M ("PREFERENCES_FSTRIP_SAME_THUMB_HEIGHT")) ); + sameThumbSize->set_tooltip_text (M ("PREFERENCES_FSTRIP_SAME_THUMB_HEIGHT_HINT")); + ckbInternalThumbIfUntouched = Gtk::manage ( new Gtk::CheckButton (M ("PREFERENCES_INTERNALTHUMBIFUNTOUCHED"))); vbro->pack_start (*showDateTime, Gtk::PACK_SHRINK, 0); - Gtk::Label* dflab = Gtk::manage( new Gtk::Label (M("PREFERENCES_DATEFORMAT") + ":", Gtk::ALIGN_START)); - dateformat = Gtk::manage( new Gtk::Entry () ); - dateformat->set_tooltip_markup (M("PREFERENCES_DATEFORMATHINT")); - dflab->set_tooltip_markup (M("PREFERENCES_DATEFORMATHINT")); + Gtk::Label* dflab = Gtk::manage ( new Gtk::Label (M ("PREFERENCES_DATEFORMAT") + ":", Gtk::ALIGN_START)); + dateformat = Gtk::manage ( new Gtk::Entry () ); + dateformat->set_tooltip_markup (M ("PREFERENCES_DATEFORMATHINT")); + dflab->set_tooltip_markup (M ("PREFERENCES_DATEFORMATHINT")); hbro0->pack_start (*dflab, Gtk::PACK_SHRINK, 4); hbro0->pack_start (*dateformat, Gtk::PACK_SHRINK, 0); @@ -1253,9 +1293,9 @@ Gtk::Widget* Preferences::getFileBrowserPanel () vbro->pack_start (*sameThumbSize, Gtk::PACK_SHRINK, 0); vbro->pack_start (*ckbInternalThumbIfUntouched, Gtk::PACK_SHRINK, 0); - Gtk::HBox* hbrecent = Gtk::manage( new Gtk::HBox () ); - Gtk::Label* labrecent = Gtk::manage( new Gtk::Label (M("PREFERENCES_MAXRECENTFOLDERS") + ":") ); - maxRecentFolders = Gtk::manage( new Gtk::SpinButton () ); + Gtk::HBox* hbrecent = Gtk::manage ( new Gtk::HBox () ); + Gtk::Label* labrecent = Gtk::manage ( new Gtk::Label (M ("PREFERENCES_MAXRECENTFOLDERS") + ":") ); + maxRecentFolders = Gtk::manage ( new Gtk::SpinButton () ); hbrecent->pack_start (*labrecent, Gtk::PACK_SHRINK, 4); hbrecent->pack_start (*maxRecentFolders, Gtk::PACK_SHRINK, 4); maxRecentFolders->set_digits (0); @@ -1266,13 +1306,13 @@ Gtk::Widget* Preferences::getFileBrowserPanel () fro->add (*vbro); - Gtk::Frame* frmnu = Gtk::manage( new Gtk::Frame (M("PREFERENCES_MENUOPTIONS")) ); - ckbmenuGroupRank = Gtk::manage( new Gtk::CheckButton (M("PREFERENCES_MENUGROUPRANK")) ); - ckbmenuGroupLabel = Gtk::manage( new Gtk::CheckButton (M("PREFERENCES_MENUGROUPLABEL")) ); - ckbmenuGroupFileOperations = Gtk::manage( new Gtk::CheckButton (M("PREFERENCES_MENUGROUPFILEOPERATIONS")) ); - ckbmenuGroupProfileOperations = Gtk::manage( new Gtk::CheckButton (M("PREFERENCES_MENUGROUPPROFILEOPERATIONS")) ); - ckbmenuGroupExtProg = Gtk::manage( new Gtk::CheckButton (M("PREFERENCES_MENUGROUPEXTPROGS")) ); - Gtk::VBox* vbmnu = Gtk::manage( new Gtk::VBox () ); + Gtk::Frame* frmnu = Gtk::manage ( new Gtk::Frame (M ("PREFERENCES_MENUOPTIONS")) ); + ckbmenuGroupRank = Gtk::manage ( new Gtk::CheckButton (M ("PREFERENCES_MENUGROUPRANK")) ); + ckbmenuGroupLabel = Gtk::manage ( new Gtk::CheckButton (M ("PREFERENCES_MENUGROUPLABEL")) ); + ckbmenuGroupFileOperations = Gtk::manage ( new Gtk::CheckButton (M ("PREFERENCES_MENUGROUPFILEOPERATIONS")) ); + ckbmenuGroupProfileOperations = Gtk::manage ( new Gtk::CheckButton (M ("PREFERENCES_MENUGROUPPROFILEOPERATIONS")) ); + ckbmenuGroupExtProg = Gtk::manage ( new Gtk::CheckButton (M ("PREFERENCES_MENUGROUPEXTPROGS")) ); + Gtk::VBox* vbmnu = Gtk::manage ( new Gtk::VBox () ); vbmnu->pack_start (*ckbmenuGroupRank, Gtk::PACK_SHRINK, 0); vbmnu->pack_start (*ckbmenuGroupLabel, Gtk::PACK_SHRINK, 0); @@ -1283,27 +1323,27 @@ Gtk::Widget* Preferences::getFileBrowserPanel () frmnu->add (*vbmnu); - Gtk::Frame* fre = Gtk::manage( new Gtk::Frame (M("PREFERENCES_PARSEDEXT")) ); - Gtk::VBox* vbre = Gtk::manage( new Gtk::VBox () ); - Gtk::HBox* hb0 = Gtk::manage( new Gtk::HBox () ); - Gtk::Label* elab = Gtk::manage( new Gtk::Label (M("PREFERENCES_PARSEDEXTADD") + ":") ); + Gtk::Frame* fre = Gtk::manage ( new Gtk::Frame (M ("PREFERENCES_PARSEDEXT")) ); + Gtk::VBox* vbre = Gtk::manage ( new Gtk::VBox () ); + Gtk::HBox* hb0 = Gtk::manage ( new Gtk::HBox () ); + Gtk::Label* elab = Gtk::manage ( new Gtk::Label (M ("PREFERENCES_PARSEDEXTADD") + ":") ); hb0->pack_start (*elab, Gtk::PACK_SHRINK, 4); - extension = Gtk::manage( new Gtk::Entry () ); - extension->set_width_chars(5); - extension->set_max_width_chars(5); + extension = Gtk::manage ( new Gtk::Entry () ); + extension->set_width_chars (5); + extension->set_max_width_chars (5); hb0->pack_start (*extension); - addExt = Gtk::manage( new Gtk::Button () ); - delExt = Gtk::manage( new Gtk::Button () ); - moveExtUp = Gtk::manage( new Gtk::Button () ); - moveExtDown = Gtk::manage( new Gtk::Button () ); - addExt->set_tooltip_text (M("PREFERENCES_PARSEDEXTADDHINT")); - delExt->set_tooltip_text (M("PREFERENCES_PARSEDEXTDELHINT")); - moveExtUp->set_tooltip_text (M("PREFERENCES_PARSEDEXTUPHINT")); - moveExtDown->set_tooltip_text (M("PREFERENCES_PARSEDEXTDOWNHINT")); - Gtk::Image* addExtImg = Gtk::manage( new RTImage ("list-add-small.png") ); - Gtk::Image* delExtImg = Gtk::manage( new RTImage ("list-remove-red-small.png") ); - Gtk::Image* moveExtUpImg = Gtk::manage( new RTImage ("arrow-up-small.png") ); - Gtk::Image* moveExtDownImg = Gtk::manage( new RTImage ("arrow-down-small.png") ); + addExt = Gtk::manage ( new Gtk::Button () ); + delExt = Gtk::manage ( new Gtk::Button () ); + moveExtUp = Gtk::manage ( new Gtk::Button () ); + moveExtDown = Gtk::manage ( new Gtk::Button () ); + addExt->set_tooltip_text (M ("PREFERENCES_PARSEDEXTADDHINT")); + delExt->set_tooltip_text (M ("PREFERENCES_PARSEDEXTDELHINT")); + moveExtUp->set_tooltip_text (M ("PREFERENCES_PARSEDEXTUPHINT")); + moveExtDown->set_tooltip_text (M ("PREFERENCES_PARSEDEXTDOWNHINT")); + Gtk::Image* addExtImg = Gtk::manage ( new RTImage ("list-add-small.png") ); + Gtk::Image* delExtImg = Gtk::manage ( new RTImage ("list-remove-red-small.png") ); + Gtk::Image* moveExtUpImg = Gtk::manage ( new RTImage ("arrow-up-small.png") ); + Gtk::Image* moveExtDownImg = Gtk::manage ( new RTImage ("arrow-down-small.png") ); addExt->add (*addExtImg); delExt->add (*delExtImg); moveExtUp->set_image (*moveExtUpImg); @@ -1312,27 +1352,27 @@ Gtk::Widget* Preferences::getFileBrowserPanel () hb0->pack_end (*moveExtUp, Gtk::PACK_SHRINK, 4); hb0->pack_end (*delExt, Gtk::PACK_SHRINK, 4); hb0->pack_end (*addExt, Gtk::PACK_SHRINK, 4); - extensions = Gtk::manage( new Gtk::TreeView () ); - Gtk::ScrolledWindow* hscrollw = Gtk::manage( new Gtk::ScrolledWindow () ); + extensions = Gtk::manage ( new Gtk::TreeView () ); + Gtk::ScrolledWindow* hscrollw = Gtk::manage ( new Gtk::ScrolledWindow () ); hscrollw->set_policy (Gtk::POLICY_AUTOMATIC, Gtk::POLICY_ALWAYS); hscrollw->add (*extensions); extensionModel = Gtk::ListStore::create (extensionColumns); extensions->set_model (extensionModel); - extensions->append_column_editable("Enabled", extensionColumns.enabled); - extensions->append_column("Extension", extensionColumns.ext); + extensions->append_column_editable ("Enabled", extensionColumns.enabled); + extensions->append_column ("Extension", extensionColumns.ext); extensions->set_headers_visible (false); vbre->pack_start (*hscrollw); vbre->pack_start (*hb0, Gtk::PACK_SHRINK, 4); fre->add (*vbre); - Gtk::Frame* frc = Gtk::manage( new Gtk::Frame (M("PREFERENCES_CACHEOPTS")) ); - Gtk::VBox* vbc = Gtk::manage( new Gtk::VBox () ); + Gtk::Frame* frc = Gtk::manage ( new Gtk::Frame (M ("PREFERENCES_CACHEOPTS")) ); + Gtk::VBox* vbc = Gtk::manage ( new Gtk::VBox () ); frc->add (*vbc); - Gtk::HBox* hb3 = Gtk::manage( new Gtk::HBox () ); - Gtk::Label* chlab = Gtk::manage( new Gtk::Label (M("PREFERENCES_CACHETHUMBHEIGHT") + ":") ); - maxThumbSize = Gtk::manage( new Gtk::SpinButton () ); + Gtk::HBox* hb3 = Gtk::manage ( new Gtk::HBox () ); + Gtk::Label* chlab = Gtk::manage ( new Gtk::Label (M ("PREFERENCES_CACHETHUMBHEIGHT") + ":") ); + maxThumbSize = Gtk::manage ( new Gtk::SpinButton () ); hb3->pack_start (*chlab, Gtk::PACK_SHRINK, 4); hb3->pack_start (*maxThumbSize, Gtk::PACK_SHRINK, 4); @@ -1341,9 +1381,9 @@ Gtk::Widget* Preferences::getFileBrowserPanel () maxThumbSize->set_range (40, 800); vbc->pack_start (*hb3, Gtk::PACK_SHRINK, 4); - Gtk::HBox* hb4 = Gtk::manage( new Gtk::HBox () ); - Gtk::Label* celab = Gtk::manage( new Gtk::Label (M("PREFERENCES_CACHEMAXENTRIES") + ":") ); - maxCacheEntries = Gtk::manage( new Gtk::SpinButton () ); + Gtk::HBox* hb4 = Gtk::manage ( new Gtk::HBox () ); + Gtk::Label* celab = Gtk::manage ( new Gtk::Label (M ("PREFERENCES_CACHEMAXENTRIES") + ":") ); + maxCacheEntries = Gtk::manage ( new Gtk::SpinButton () ); hb4->pack_start (*celab, Gtk::PACK_SHRINK, 4); hb4->pack_start (*maxCacheEntries, Gtk::PACK_SHRINK, 4); @@ -1352,24 +1392,24 @@ Gtk::Widget* Preferences::getFileBrowserPanel () maxCacheEntries->set_range (10, 100000); vbc->pack_start (*hb4, Gtk::PACK_SHRINK, 4); - Gtk::HBox* hb5 = Gtk::manage( new Gtk::HBox () ); - clearThumbnails = Gtk::manage( new Gtk::Button (M("PREFERENCES_CACHECLEARTHUMBS")) ); - clearProfiles = Gtk::manage( new Gtk::Button (M("PREFERENCES_CACHECLEARPROFILES")) ); - clearAll = Gtk::manage( new Gtk::Button (M("PREFERENCES_CACHECLEARALL")) ); + Gtk::HBox* hb5 = Gtk::manage ( new Gtk::HBox () ); + clearThumbnails = Gtk::manage ( new Gtk::Button (M ("PREFERENCES_CACHECLEARTHUMBS")) ); + clearProfiles = Gtk::manage ( new Gtk::Button (M ("PREFERENCES_CACHECLEARPROFILES")) ); + clearAll = Gtk::manage ( new Gtk::Button (M ("PREFERENCES_CACHECLEARALL")) ); hb5->pack_start (*clearThumbnails, Gtk::PACK_SHRINK, 4); hb5->pack_start (*clearProfiles, Gtk::PACK_SHRINK, 4); hb5->pack_start (*clearAll, Gtk::PACK_SHRINK, 4); vbc->pack_start (*hb5, Gtk::PACK_SHRINK, 4); - Gtk::HBox* hb6 = Gtk::manage( new Gtk::HBox () ); - Gtk::VBox* vb6 = Gtk::manage( new Gtk::VBox () ); + Gtk::HBox* hb6 = Gtk::manage ( new Gtk::HBox () ); + Gtk::VBox* vb6 = Gtk::manage ( new Gtk::VBox () ); vb6->pack_start (*fro); vb6->pack_start (*frmnu); vb6->pack_end (*frc); hb6->pack_start (*vb6); hb6->pack_start (*fre); - hb6->set_spacing(4); + hb6->set_spacing (4); mvbfb->pack_start (*hb6, Gtk::PACK_SHRINK, 4); @@ -1377,14 +1417,14 @@ Gtk::Widget* Preferences::getFileBrowserPanel () // mvbfb->pack_start (*fre); // mvbfb->pack_start (*frc, Gtk::PACK_SHRINK, 4); - addExt->signal_clicked().connect( sigc::mem_fun(*this, &Preferences::addExtPressed) ); - delExt->signal_clicked().connect( sigc::mem_fun(*this, &Preferences::delExtPressed) ); - moveExtUp->signal_clicked().connect( sigc::mem_fun(*this, &Preferences::moveExtUpPressed) ); - moveExtDown->signal_clicked().connect( sigc::mem_fun(*this, &Preferences::moveExtDownPressed) ); - extension->signal_activate().connect( sigc::mem_fun(*this, &Preferences::addExtPressed) ); - clearThumbnails->signal_clicked().connect( sigc::mem_fun(*this, &Preferences::clearThumbImagesPressed) ); - clearProfiles->signal_clicked().connect( sigc::mem_fun(*this, &Preferences::clearProfilesPressed) ); - clearAll->signal_clicked().connect( sigc::mem_fun(*this, &Preferences::clearAllPressed) ); + addExt->signal_clicked().connect ( sigc::mem_fun (*this, &Preferences::addExtPressed) ); + delExt->signal_clicked().connect ( sigc::mem_fun (*this, &Preferences::delExtPressed) ); + moveExtUp->signal_clicked().connect ( sigc::mem_fun (*this, &Preferences::moveExtUpPressed) ); + moveExtDown->signal_clicked().connect ( sigc::mem_fun (*this, &Preferences::moveExtDownPressed) ); + extension->signal_activate().connect ( sigc::mem_fun (*this, &Preferences::addExtPressed) ); + clearThumbnails->signal_clicked().connect ( sigc::mem_fun (*this, &Preferences::clearThumbImagesPressed) ); + clearProfiles->signal_clicked().connect ( sigc::mem_fun (*this, &Preferences::clearProfilesPressed) ); + clearAll->signal_clicked().connect ( sigc::mem_fun (*this, &Preferences::clearAllPressed) ); return mvbfb; } @@ -1393,20 +1433,20 @@ Gtk::Widget* Preferences::getSoundPanel () { Gtk::VBox* pSnd = new Gtk::VBox (); - ckbSndEnable = Gtk::manage( new Gtk::CheckButton (M("GENERAL_ENABLE"))); - sndEnableConn = ckbSndEnable->signal_toggled().connect (sigc::mem_fun(*this, &Preferences::sndEnableToggled)); + ckbSndEnable = Gtk::manage ( new Gtk::CheckButton (M ("GENERAL_ENABLE"))); + sndEnableConn = ckbSndEnable->signal_toggled().connect (sigc::mem_fun (*this, &Preferences::sndEnableToggled)); pSnd->pack_start (*ckbSndEnable, Gtk::PACK_SHRINK, 4); Gtk::HBox* hblSndHelp = Gtk::manage (new Gtk::HBox ()); - Gtk::Label* lSndHelp = Gtk::manage (new Gtk::Label (M("PREFERENCES_SND_HELP"))); + Gtk::Label* lSndHelp = Gtk::manage (new Gtk::Label (M ("PREFERENCES_SND_HELP"))); hblSndHelp->pack_start (*lSndHelp, Gtk::PACK_SHRINK, 4); pSnd->pack_start (*hblSndHelp, Gtk::PACK_SHRINK, 4); // BatchQueueDone - Gtk::HBox* pBatchQueueDone = Gtk::manage( new Gtk::HBox() ); + Gtk::HBox* pBatchQueueDone = Gtk::manage ( new Gtk::HBox() ); - Gtk::Label* lSndBatchQueueDone = Gtk::manage (new Gtk::Label (M("PREFERENCES_SND_BATCHQUEUEDONE") + Glib::ustring(":"))); + Gtk::Label* lSndBatchQueueDone = Gtk::manage (new Gtk::Label (M ("PREFERENCES_SND_BATCHQUEUEDONE") + Glib::ustring (":"))); pBatchQueueDone->pack_start (*lSndBatchQueueDone, Gtk::PACK_SHRINK, 4); txtSndBatchQueueDone = Gtk::manage (new Gtk::Entry()); @@ -1415,18 +1455,18 @@ Gtk::Widget* Preferences::getSoundPanel () pSnd->pack_start (*pBatchQueueDone, Gtk::PACK_SHRINK, 4); // LngEditProcDone - Gtk::HBox* pSndLngEditProcDone = Gtk::manage( new Gtk::HBox() ); + Gtk::HBox* pSndLngEditProcDone = Gtk::manage ( new Gtk::HBox() ); - Gtk::Label* lSndLngEditProcDone = Gtk::manage (new Gtk::Label (M("PREFERENCES_SND_LNGEDITPROCDONE") + Glib::ustring(":"))); + Gtk::Label* lSndLngEditProcDone = Gtk::manage (new Gtk::Label (M ("PREFERENCES_SND_LNGEDITPROCDONE") + Glib::ustring (":"))); pSndLngEditProcDone->pack_start (*lSndLngEditProcDone, Gtk::PACK_SHRINK, 4); txtSndLngEditProcDone = Gtk::manage (new Gtk::Entry()); pSndLngEditProcDone->pack_start (*txtSndLngEditProcDone, Gtk::PACK_EXPAND_WIDGET, 4); - Gtk::Label* lSndLngEditProcDoneSecs = Gtk::manage (new Gtk::Label (M("PREFERENCES_SND_TRESHOLDSECS") + Glib::ustring(":"))); + Gtk::Label* lSndLngEditProcDoneSecs = Gtk::manage (new Gtk::Label (M ("PREFERENCES_SND_TRESHOLDSECS") + Glib::ustring (":"))); pSndLngEditProcDone->pack_start (*lSndLngEditProcDoneSecs, Gtk::PACK_SHRINK, 12); - spbSndLngEditProcDoneSecs = Gtk::manage( new Gtk::SpinButton () ); + spbSndLngEditProcDoneSecs = Gtk::manage ( new Gtk::SpinButton () ); spbSndLngEditProcDoneSecs->set_digits (1); spbSndLngEditProcDoneSecs->set_increments (0.5, 1); spbSndLngEditProcDoneSecs->set_range (0, 10); @@ -1456,16 +1496,16 @@ void Preferences::parseDir (Glib::ustring dirname, std::vector& i } for (Glib::DirIterator i = dir->begin(); i != dir->end(); ++i) { - Glib::ustring fname = Glib::build_filename(dirname, *i); + Glib::ustring fname = Glib::build_filename (dirname, *i); Glib::ustring sname = *i; // ignore directories if (!Glib::file_test (fname, Glib::FILE_TEST_IS_DIR) && sname.size() >= ext.size() && sname.substr (sname.size() - ext.size(), ext.size()).casefold() == ext) { - items.push_back (sname.substr(0, sname.size() - ext.size())); + items.push_back (sname.substr (0, sname.size() - ext.size())); } } - std::sort(items.begin(), items.end()); + std::sort (items.begin(), items.end()); delete dir; } @@ -1486,38 +1526,42 @@ void Preferences::parseThemeDir (Glib::ustring dirname) } for (Glib::DirIterator i = dir->begin(); i != dir->end(); ++i) { - Glib::ustring fname = Glib::build_filename(dirname, *i); + Glib::ustring fname = Glib::build_filename (dirname, *i); Glib::ustring sname = *i; bool keepIt = false; // ignore directories and filter out unsupported theme - if (regex->match(sname, matchInfo) && !Glib::file_test (fname, Glib::FILE_TEST_IS_DIR) && sname.size() >= 4) { - Glib::ustring fname2 = matchInfo.fetch(1); - Glib::ustring minMinor = matchInfo.fetch(2); - Glib::ustring maxMinor = matchInfo.fetch(3); + if (regex->match (sname, matchInfo) && !Glib::file_test (fname, Glib::FILE_TEST_IS_DIR) && sname.size() >= 4) { + Glib::ustring fname2 = matchInfo.fetch (1); + Glib::ustring minMinor = matchInfo.fetch (2); + Glib::ustring maxMinor = matchInfo.fetch (3); if (!minMinor.empty()) { - guint64 minMinorVal = g_ascii_strtoll(minMinor.c_str(), 0, 0); + guint64 minMinorVal = g_ascii_strtoll (minMinor.c_str(), 0, 0); + if ((guint64)GTK_MINOR_VERSION >= minMinorVal) { keepIt = true; } } + if (!maxMinor.empty()) { - guint64 maxMinorVal = g_ascii_strtoll(maxMinor.c_str(), 0, 0); + guint64 maxMinorVal = g_ascii_strtoll (maxMinor.c_str(), 0, 0); + if ((guint64)GTK_MINOR_VERSION <= maxMinorVal) { keepIt = true; } } + if (keepIt) { - themeFNames.push_back(ThemeFilename(matchInfo.fetch(1), sname.substr(0, sname.size() - 4))); + themeFNames.push_back (ThemeFilename (matchInfo.fetch (1), sname.substr (0, sname.size() - 4))); } } } - std::sort(themeFNames.begin(), themeFNames.end(), [] (const ThemeFilename& firstDir, const ThemeFilename& secondDir) - { - return firstDir.longFName < secondDir.longFName; - }); + + std::sort (themeFNames.begin(), themeFNames.end(), [] (const ThemeFilename & firstDir, const ThemeFilename & secondDir) { + return firstDir.longFName < secondDir.longFName; + }); delete dir; } @@ -1554,7 +1598,7 @@ void Preferences::storePreferences () moptions.shadowThreshold = (int)shThresh->get_value (); moptions.language = languages->get_active_text (); moptions.languageAutoDetect = ckbLangAutoDetect->get_active (); - moptions.theme = themeFNames.at(theme->get_active_row_number ()).longFName; + moptions.theme = themeFNames.at (theme->get_active_row_number ()).longFName; Gdk::RGBA cropCol = butCropCol->get_rgba(); moptions.cutOverlayBrush[0] = cropCol.get_red(); @@ -1568,11 +1612,11 @@ void Preferences::storePreferences () moptions.navGuideBrush[2] = NavGuideCol.get_blue(); moptions.navGuideBrush[3] = butNavGuideCol->get_alpha() / 65535.0; - Pango::FontDescription fd(fontButton->get_font_name()); + Pango::FontDescription fd (fontButton->get_font_name()); moptions.fontFamily = fd.get_family(); moptions.fontSize = fd.get_size() / Pango::SCALE; - Pango::FontDescription cpfd(colorPickerFontButton->get_font_name()); + Pango::FontDescription cpfd (colorPickerFontButton->get_font_name()); moptions.CPFontFamily = cpfd.get_family(); moptions.CPFontSize = cpfd.get_size() / Pango::SCALE; @@ -1604,45 +1648,54 @@ void Preferences::storePreferences () } moptions.CPBPath = txtCustProfBuilderPath->get_text(); - moptions.CPBKeys = CPBKeyType(custProfBuilderLabelType->get_active_row_number()); + moptions.CPBKeys = CPBKeyType (custProfBuilderLabelType->get_active_row_number()); if (!prtProfile->get_active_row_number()) { moptions.rtSettings.printerProfile = ""; } else { moptions.rtSettings.printerProfile = prtProfile->get_active_text (); } + switch (prtIntent->get_active_row_number ()) { - default: - case 0: - moptions.rtSettings.printerIntent = rtengine::RI_PERCEPTUAL; - break; - case 1: - moptions.rtSettings.printerIntent = rtengine::RI_RELATIVE; - break; - case 2: - moptions.rtSettings.printerIntent = rtengine::RI_ABSOLUTE; - break; + default: + case 0: + moptions.rtSettings.printerIntent = rtengine::RI_PERCEPTUAL; + break; + + case 1: + moptions.rtSettings.printerIntent = rtengine::RI_RELATIVE; + break; + + case 2: + moptions.rtSettings.printerIntent = rtengine::RI_ABSOLUTE; + break; } + moptions.rtSettings.printerBPC = prtBPC->get_active (); #if !defined(__APPLE__) // monitor profile not supported on apple + if (!monProfile->get_active_row_number()) { moptions.rtSettings.monitorProfile = ""; } else { moptions.rtSettings.monitorProfile = monProfile->get_active_text (); } + switch (monIntent->get_active_row_number ()) { - default: - case 0: - moptions.rtSettings.monitorIntent = rtengine::RI_PERCEPTUAL; - break; - case 1: - moptions.rtSettings.monitorIntent = rtengine::RI_RELATIVE; - break; - case 2: - moptions.rtSettings.monitorIntent = rtengine::RI_ABSOLUTE; - break; + default: + case 0: + moptions.rtSettings.monitorIntent = rtengine::RI_PERCEPTUAL; + break; + + case 1: + moptions.rtSettings.monitorIntent = rtengine::RI_RELATIVE; + break; + + case 2: + moptions.rtSettings.monitorIntent = rtengine::RI_ABSOLUTE; + break; } + moptions.rtSettings.monitorBPC = monBPC->get_active (); #if defined(WIN32) moptions.rtSettings.autoMonitorProfile = cbAutoMonProfile->get_active (); @@ -1666,6 +1719,7 @@ void Preferences::storePreferences () moptions.prevdemo = (prevdemo_t)cprevdemo->get_active_row_number (); moptions.serializeTiffRead = ctiffserialize->get_active(); + moptions.mip = (mip_t)cmip->get_active_row_number (); if (sdcurrent->get_active ()) { moptions.startupDir = STARTUPDIR_CURRENT; @@ -1748,9 +1802,9 @@ void Preferences::fillPreferences () sconn.block (true); dfconn.block (true); ffconn.block (true); - rpconn.block(true); - ipconn.block(true); - bpconn.block(true); + rpconn.block (true); + ipconn.block (true); + bpconn.block (true); rprofiles->setActiveRowFromFullPath (moptions.defProfRaw); forRAWComboChanged(); // update the tooltip @@ -1759,40 +1813,48 @@ void Preferences::fillPreferences () dateformat->set_text (moptions.dateFormat); panFactor->set_value (moptions.panAccelFactor); rememberZoomPanCheckbutton->set_active (moptions.rememberZoomAndPan); - ctiffserialize->set_active(moptions.serializeTiffRead); + ctiffserialize->set_active (moptions.serializeTiffRead); setActiveTextOrIndex (*prtProfile, moptions.rtSettings.printerProfile, 0); + switch (moptions.rtSettings.printerIntent) { - default: - case rtengine::RI_PERCEPTUAL: - prtIntent->set_active (0); - break; - case rtengine::RI_RELATIVE: - prtIntent->set_active (1); - break; - case rtengine::RI_ABSOLUTE: - prtIntent->set_active (2); - break; + default: + case rtengine::RI_PERCEPTUAL: + prtIntent->set_active (0); + break; + + case rtengine::RI_RELATIVE: + prtIntent->set_active (1); + break; + + case rtengine::RI_ABSOLUTE: + prtIntent->set_active (2); + break; } + prtBPC->set_active (moptions.rtSettings.printerBPC); #if !defined(__APPLE__) // monitor profile not supported on apple setActiveTextOrIndex (*monProfile, moptions.rtSettings.monitorProfile, 0); + switch (moptions.rtSettings.monitorIntent) { - default: - case rtengine::RI_PERCEPTUAL: - monIntent->set_active (0); - break; - case rtengine::RI_RELATIVE: - monIntent->set_active (1); - break; - case rtengine::RI_ABSOLUTE: - monIntent->set_active (2); - break; + default: + case rtengine::RI_PERCEPTUAL: + monIntent->set_active (0); + break; + + case rtengine::RI_RELATIVE: + monIntent->set_active (1); + break; + + case rtengine::RI_ABSOLUTE: + monIntent->set_active (2); + break; } + monBPC->set_active (moptions.rtSettings.monitorBPC); #if defined(WIN32) - cbAutoMonProfile->set_active(moptions.rtSettings.autoMonitorProfile); + cbAutoMonProfile->set_active (moptions.rtSettings.autoMonitorProfile); #endif #endif @@ -1811,36 +1873,37 @@ void Preferences::fillPreferences () dnwavlev->set_active (moptions.rtSettings.nrwavlevel); cprevdemo->set_active (moptions.prevdemo); cbdaubech->set_active (moptions.rtSettings.daubech); + cmip->set_active (moptions.mip); // cbAutocielab->set_active (moptions.rtSettings.autocielab); cbciecamfloat->set_active (moptions.rtSettings.ciecamfloat); ckbHistogramWorking->set_active (moptions.rtSettings.HistogramWorking); languages->set_active_text (moptions.language); ckbLangAutoDetect->set_active (moptions.languageAutoDetect); - int themeNbr = getThemeRowNumber(moptions.theme); - theme->set_active (themeNbr==-1 ? 0 : themeNbr); + int themeNbr = getThemeRowNumber (moptions.theme); + theme->set_active (themeNbr == -1 ? 0 : themeNbr); Gdk::RGBA cropCol; - cropCol.set_rgba(moptions.cutOverlayBrush[0], moptions.cutOverlayBrush[1], moptions.cutOverlayBrush[2]); - butCropCol->set_rgba(cropCol); - butCropCol->set_alpha ( (unsigned short)(moptions.cutOverlayBrush[3] * 65535.0)); + cropCol.set_rgba (moptions.cutOverlayBrush[0], moptions.cutOverlayBrush[1], moptions.cutOverlayBrush[2]); + butCropCol->set_rgba (cropCol); + butCropCol->set_alpha ( (unsigned short) (moptions.cutOverlayBrush[3] * 65535.0)); Gdk::RGBA NavGuideCol; - NavGuideCol.set_rgba(moptions.navGuideBrush[0], moptions.navGuideBrush[1], moptions.navGuideBrush[2]); - butNavGuideCol->set_rgba(NavGuideCol); - butNavGuideCol->set_alpha ( (unsigned short)(moptions.navGuideBrush[3] * 65535.0)); + NavGuideCol.set_rgba (moptions.navGuideBrush[0], moptions.navGuideBrush[1], moptions.navGuideBrush[2]); + butNavGuideCol->set_rgba (NavGuideCol); + butNavGuideCol->set_alpha ( (unsigned short) (moptions.navGuideBrush[3] * 65535.0)); - fontButton->set_font_name(Glib::ustring::compose("%1 %2", options.fontFamily == "default" ? "sans" : options.fontFamily, options.fontSize)); - colorPickerFontButton->set_font_name(Glib::ustring::compose("%1 %2", options.CPFontFamily == "default" ? "sans" : options.CPFontFamily, options.CPFontSize)); + fontButton->set_font_name (Glib::ustring::compose ("%1 %2", options.fontFamily == "default" ? "sans" : options.fontFamily, options.fontSize)); + colorPickerFontButton->set_font_name (Glib::ustring::compose ("%1 %2", options.CPFontFamily == "default" ? "sans" : options.CPFontFamily, options.CPFontSize)); showDateTime->set_active (moptions.fbShowDateTime); showBasicExif->set_active (moptions.fbShowBasicExif); showExpComp->set_active (moptions.fbShowExpComp); - ckbmenuGroupRank->set_active(moptions.menuGroupRank); - ckbmenuGroupLabel->set_active(moptions.menuGroupLabel); - ckbmenuGroupFileOperations->set_active(moptions.menuGroupFileOperations); - ckbmenuGroupProfileOperations->set_active(moptions.menuGroupProfileOperations); - ckbmenuGroupExtProg->set_active(moptions.menuGroupExtProg); + ckbmenuGroupRank->set_active (moptions.menuGroupRank); + ckbmenuGroupLabel->set_active (moptions.menuGroupLabel); + ckbmenuGroupFileOperations->set_active (moptions.menuGroupFileOperations); + ckbmenuGroupProfileOperations->set_active (moptions.menuGroupProfileOperations); + ckbmenuGroupExtProg->set_active (moptions.menuGroupExtProg); hlThresh->set_value (moptions.highlightThreshold); shThresh->set_value (moptions.shadowThreshold); @@ -1868,8 +1931,8 @@ void Preferences::fillPreferences () #endif editorToSendTo->set_text (moptions.customEditorProg); - txtCustProfBuilderPath->set_text(moptions.CPBPath); - custProfBuilderLabelType->set_active(moptions.CPBKeys); + txtCustProfBuilderPath->set_text (moptions.CPBPath); + custProfBuilderLabelType->set_active (moptions.CPBKeys); if (moptions.startupDir == STARTUPDIR_CURRENT) { @@ -1886,18 +1949,18 @@ void Preferences::fillPreferences () extensionModel->clear (); for (size_t i = 0; i < moptions.parseExtensions.size(); i++) { - Gtk::TreeRow row = *(extensionModel->append()); + Gtk::TreeRow row = * (extensionModel->append()); row[extensionColumns.enabled] = moptions.parseExtensionsEnabled[i]; row[extensionColumns.ext] = moptions.parseExtensions[i]; } maxThumbSize->set_value (moptions.maxThumbnailHeight); - maxRecentFolders->set_value(moptions.maxRecentFolders); + maxRecentFolders->set_value (moptions.maxRecentFolders); maxCacheEntries->set_value (moptions.maxCacheEntries); overlayedFileNames->set_active (moptions.overlayedFileNames); - filmStripOverlayedFileNames->set_active(moptions.filmStripOverlayedFileNames); - sameThumbSize->set_active(moptions.sameThumbSize); - ckbInternalThumbIfUntouched->set_active(moptions.internalThumbIfUntouched); + filmStripOverlayedFileNames->set_active (moptions.filmStripOverlayedFileNames); + sameThumbSize->set_active (moptions.sameThumbSize); + ckbInternalThumbIfUntouched->set_active (moptions.internalThumbIfUntouched); saveParamsFile->set_active (moptions.saveParamsFile); saveParamsCache->set_active (moptions.saveParamsCache); @@ -1907,30 +1970,30 @@ void Preferences::fillPreferences () ckbTunnelMetaData->set_active (moptions.tunnelMetaData); if (!moptions.tabbedUI) { - editorLayout->set_active(moptions.mainNBVertical ? 1 : 0); + editorLayout->set_active (moptions.mainNBVertical ? 1 : 0); } else { - editorLayout->set_active(moptions.multiDisplayMode ? 3 : 2); + editorLayout->set_active (moptions.multiDisplayMode ? 3 : 2); } - curveBBoxPosC->set_active(moptions.curvebboxpos); - ckbHistogramPositionLeft->set_active(moptions.histogramPosition == 1); + curveBBoxPosC->set_active (moptions.curvebboxpos); + ckbHistogramPositionLeft->set_active (moptions.histogramPosition == 1); // ckbHistogramWorking->set_active(moptions.histogramWorking==1); - ckbFileBrowserToolbarSingleRow->set_active(moptions.FileBrowserToolbarSingleRow); - ckbShowFilmStripToolBar->set_active(moptions.showFilmStripToolBar); - ckbHideTPVScrollbar->set_active(moptions.hideTPVScrollbar); - ckbUseIconNoText->set_active(moptions.UseIconNoText); + ckbFileBrowserToolbarSingleRow->set_active (moptions.FileBrowserToolbarSingleRow); + ckbShowFilmStripToolBar->set_active (moptions.showFilmStripToolBar); + ckbHideTPVScrollbar->set_active (moptions.hideTPVScrollbar); + ckbUseIconNoText->set_active (moptions.UseIconNoText); - rgbDenoiseTreadLimitSB->set_value(moptions.rgbDenoiseThreadLimit); - clutCacheSizeSB->set_value(moptions.clutCacheSize); - maxInspectorBuffersSB->set_value(moptions.maxInspectorBuffers); + rgbDenoiseTreadLimitSB->set_value (moptions.rgbDenoiseThreadLimit); + clutCacheSizeSB->set_value (moptions.clutCacheSize); + maxInspectorBuffersSB->set_value (moptions.maxInspectorBuffers); - darkFrameDir->set_current_folder( moptions.rtSettings.darkFramesPath ); + darkFrameDir->set_current_folder ( moptions.rtSettings.darkFramesPath ); darkFrameChanged (); - flatFieldDir->set_current_folder( moptions.rtSettings.flatFieldsPath ); + flatFieldDir->set_current_folder ( moptions.rtSettings.flatFieldsPath ); flatFieldChanged (); - clutsDir->set_current_folder( moptions.clutsDir ); + clutsDir->set_current_folder ( moptions.clutsDir ); addc.block (true); setc.block (true); @@ -1953,9 +2016,9 @@ void Preferences::fillPreferences () sconn.block (false); dfconn.block (false); ffconn.block (false); - rpconn.block(true); - ipconn.block(true); - bpconn.block(false); + rpconn.block (true); + ipconn.block (true); + bpconn.block (false); chOverwriteOutputFile->set_active (moptions.overwriteOutputFile); @@ -1986,7 +2049,7 @@ void Preferences::savePressed () { #if defined(WIN32) void Preferences::autoMonProfileToggled () { - monProfile->set_sensitive(!cbAutoMonProfile->get_active()); + monProfile->set_sensitive (!cbAutoMonProfile->get_active()); } #endif /* @@ -1996,14 +2059,14 @@ void Preferences::autocielabToggled () { */ void Preferences::sndEnableToggled () { - txtSndBatchQueueDone->set_sensitive(ckbSndEnable->get_active()); - txtSndLngEditProcDone->set_sensitive(ckbSndEnable->get_active()); - spbSndLngEditProcDoneSecs->set_sensitive(ckbSndEnable->get_active()); + txtSndBatchQueueDone->set_sensitive (ckbSndEnable->get_active()); + txtSndLngEditProcDone->set_sensitive (ckbSndEnable->get_active()); + spbSndLngEditProcDoneSecs->set_sensitive (ckbSndEnable->get_active()); } void Preferences::langAutoDetectToggled () { - languages->set_sensitive(!ckbLangAutoDetect->get_active()); + languages->set_sensitive (!ckbLangAutoDetect->get_active()); } void Preferences::okPressed () @@ -2020,25 +2083,26 @@ void Preferences::okPressed () void Preferences::cancelPressed () { // set the initial theme back - if (themeFNames.at(theme->get_active_row_number ()).longFName != options.theme) { - RTImage::setPaths(options); + if (themeFNames.at (theme->get_active_row_number ()).longFName != options.theme) { + RTImage::setPaths (options); RTImage::updateImages(); - switchThemeTo(options.theme); + switchThemeTo (options.theme); } // set the initial font back - Pango::FontDescription fd(fontButton->get_font_name()); + Pango::FontDescription fd (fontButton->get_font_name()); + if (fd.get_family() != options.fontFamily && (fd.get_size() / Pango::SCALE) != options.fontSize) { - switchFontTo(options.fontFamily == "default" ? "sans" : options.fontFamily, options.fontSize); + switchFontTo (options.fontFamily == "default" ? "sans" : options.fontFamily, options.fontSize); } // update the profileStore if (useBundledProfiles->get_active () != options.useBundledProfiles) { // we have to rescan with the old value; - bpconn.block(true); + bpconn.block (true); useBundledProfiles->set_active (false); bundledProfilesChanged(); - bpconn.block(false); + bpconn.block (false); } hide (); @@ -2047,12 +2111,12 @@ void Preferences::cancelPressed () void Preferences::selectStartupDir () { - Gtk::FileChooserDialog dialog (getToplevelWindow (this), M("PREFERENCES_DIRSELECTDLG"), Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER); + Gtk::FileChooserDialog dialog (getToplevelWindow (this), M ("PREFERENCES_DIRSELECTDLG"), Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER); // dialog.set_transient_for(*this); //Add response buttons the the dialog: - dialog.add_button(M("GENERAL_CANCEL"), Gtk::RESPONSE_CANCEL); - dialog.add_button(M("GENERAL_OPEN"), Gtk::RESPONSE_OK); + dialog.add_button (M ("GENERAL_CANCEL"), Gtk::RESPONSE_CANCEL); + dialog.add_button (M ("GENERAL_OPEN"), Gtk::RESPONSE_OK); int result = dialog.run(); @@ -2066,17 +2130,17 @@ void Preferences::aboutPressed () splash = new Splash (*this); splash->set_transient_for (*this); - splash->signal_delete_event().connect( sigc::mem_fun(*this, &Preferences::splashClosed) ); + splash->signal_delete_event().connect ( sigc::mem_fun (*this, &Preferences::splashClosed) ); splash->show (); } void Preferences::themeChanged () { - moptions.theme = themeFNames.at(theme->get_active_row_number ()).longFName; - RTImage::setPaths(moptions); + moptions.theme = themeFNames.at (theme->get_active_row_number ()).longFName; + RTImage::setPaths (moptions); RTImage::updateImages(); - switchThemeTo(moptions.theme); + switchThemeTo (moptions.theme); } void Preferences::forRAWComboChanged () @@ -2092,14 +2156,14 @@ void Preferences::forRAWComboChanged () } if (selectedEntry->type == PSET_FOLDER) { - rpconn.block(true); - rprofiles->set_active(currRawRow); - rpconn.block(false); + rpconn.block (true); + rprofiles->set_active (currRawRow); + rpconn.block (false); } else { currRawRow = rprofiles->get_active(); } - rprofiles->set_tooltip_text(selectedEntry->label); + rprofiles->set_tooltip_text (selectedEntry->label); } void Preferences::forImageComboChanged () @@ -2115,19 +2179,19 @@ void Preferences::forImageComboChanged () } if (selectedEntry->type == PSET_FOLDER) { - ipconn.block(true); - iprofiles->set_active(currImgRow); - ipconn.block(false); + ipconn.block (true); + iprofiles->set_active (currImgRow); + ipconn.block (false); } else { currImgRow = rprofiles->get_active(); } - iprofiles->set_tooltip_text(iprofiles->getSelectedEntry()->label); + iprofiles->set_tooltip_text (iprofiles->getSelectedEntry()->label); } void Preferences::layoutComboChanged () { - editorLayout->set_tooltip_text(editorLayout->get_active_text()); + editorLayout->set_tooltip_text (editorLayout->get_active_text()); } void Preferences::bundledProfilesChanged () @@ -2156,12 +2220,13 @@ void Preferences::iccDirChanged () monProfile->remove_all(); - monProfile->append (M("PREFERENCES_PROFILE_NONE")); + monProfile->append (M ("PREFERENCES_PROFILE_NONE")); - for (const auto& profile : profiles) + for (const auto& profile : profiles) { monProfile->append (profile); + } - setActiveTextOrIndex(*monProfile, currentSelection, 0); + setActiveTextOrIndex (*monProfile, currentSelection, 0); } void Preferences::storeCurrentValue() @@ -2179,20 +2244,20 @@ void Preferences::updateProfileList() void Preferences::restoreValue() { - if (!rprofiles->setActiveRowFromFullPath(storedValueRaw)) { + if (!rprofiles->setActiveRowFromFullPath (storedValueRaw)) { moptions.defProfRaw = DEFPROFILE_INTERNAL; - rpconn.block(true); + rpconn.block (true); rprofiles->setInternalEntry(); - rpconn.block(false); + rpconn.block (false); } currRawRow = rprofiles->get_active(); - if (!iprofiles->setActiveRowFromFullPath(storedValueImg)) { + if (!iprofiles->setActiveRowFromFullPath (storedValueImg)) { moptions.defProfImg = DEFPROFILE_INTERNAL; - ipconn.block(true); + ipconn.block (true); iprofiles->setInternalEntry(); - ipconn.block(false); + ipconn.block (false); } currImgRow = iprofiles->get_active(); @@ -2201,55 +2266,55 @@ void Preferences::restoreValue() storedValueImg = ""; } -void Preferences::switchThemeTo(Glib::ustring newTheme) +void Preferences::switchThemeTo (Glib::ustring newTheme) { - Glib::ustring filename(Glib::build_filename(argv0, "themes", newTheme + ".css")); + Glib::ustring filename (Glib::build_filename (argv0, "themes", newTheme + ".css")); if (!themecss) { themecss = Gtk::CssProvider::create(); Glib::RefPtr screen = Gdk::Screen::get_default(); - Gtk::StyleContext::add_provider_for_screen(screen, themecss, GTK_STYLE_PROVIDER_PRIORITY_USER); + Gtk::StyleContext::add_provider_for_screen (screen, themecss, GTK_STYLE_PROVIDER_PRIORITY_USER); } try { themecss->load_from_path (filename); } catch (Glib::Error &err) { - printf("Error: Can't load css file \"%s\"\nMessage: %s\n", filename.c_str(), err.what().c_str()); + printf ("Error: Can't load css file \"%s\"\nMessage: %s\n", filename.c_str(), err.what().c_str()); } catch (...) { - printf("Error: Can't load css file \"%s\"\n", filename.c_str()); + printf ("Error: Can't load css file \"%s\"\n", filename.c_str()); } } void Preferences::fontChanged () { - Pango::FontDescription fd(fontButton->get_font_name()); - switchFontTo(fd.get_family(), fd.get_size() / Pango::SCALE); + Pango::FontDescription fd (fontButton->get_font_name()); + switchFontTo (fd.get_family(), fd.get_size() / Pango::SCALE); } -void Preferences::switchFontTo(const Glib::ustring &newFontFamily, const int newFontSize) +void Preferences::switchFontTo (const Glib::ustring &newFontFamily, const int newFontSize) { if (newFontFamily != "default") { if (!fontcss) { fontcss = Gtk::CssProvider::create(); Glib::RefPtr screen = Gdk::Screen::get_default(); - Gtk::StyleContext::add_provider_for_screen(screen, fontcss, GTK_STYLE_PROVIDER_PRIORITY_USER); + Gtk::StyleContext::add_provider_for_screen (screen, fontcss, GTK_STYLE_PROVIDER_PRIORITY_USER); } try { //GTK318 - #if GTK_MAJOR_VERSION == 3 && GTK_MINOR_VERSION < 20 - fontcss->load_from_data (Glib::ustring::compose("* { font-family: %1; font-size: %2px }", newFontFamily, newFontSize)); - #else - fontcss->load_from_data (Glib::ustring::compose("* { font-family: %1; font-size: %2pt }", newFontFamily, newFontSize)); - #endif +#if GTK_MAJOR_VERSION == 3 && GTK_MINOR_VERSION < 20 + fontcss->load_from_data (Glib::ustring::compose ("* { font-family: %1; font-size: %2px }", newFontFamily, newFontSize)); +#else + fontcss->load_from_data (Glib::ustring::compose ("* { font-family: %1; font-size: %2pt }", newFontFamily, newFontSize)); +#endif //GTK318 } catch (Glib::Error &err) { - printf("Error: \"%s\"\n", err.what().c_str()); + printf ("Error: \"%s\"\n", err.what().c_str()); } catch (...) { - printf("Error: Can't find the font named \"%s\"\n", newFontFamily.c_str()); + printf ("Error: Can't find the font named \"%s\"\n", newFontFamily.c_str()); } } } @@ -2257,51 +2322,50 @@ void Preferences::switchFontTo(const Glib::ustring &newFontFamily, const int new void Preferences::workflowUpdate () { - if(moptions.tabbedUI != options.tabbedUI) { + if (moptions.tabbedUI != options.tabbedUI) { parent->MoveFileBrowserToMain(); parent->CloseOpenEditors(); parent->SetMainCurrent(); - if(moptions.tabbedUI) { + if (moptions.tabbedUI) { parent->epanel->hide(); - parent->set_title_decorated(""); + parent->set_title_decorated (""); } else { parent->epanel->show_all(); - parent->set_title_decorated(parent->epanel->getFileName()); + parent->set_title_decorated (parent->epanel->getFileName()); } } - if(moptions.hideTPVScrollbar != options.hideTPVScrollbar) { + if (moptions.hideTPVScrollbar != options.hideTPVScrollbar) { // Update the tool panels parent->updateTPVScrollbar (moptions.hideTPVScrollbar); } - if(moptions.UseIconNoText != options.UseIconNoText) { + if (moptions.UseIconNoText != options.UseIconNoText) { // Update the tool's tab titles - parent->updateTabsUsesIcons(moptions.UseIconNoText); + parent->updateTabsUsesIcons (moptions.UseIconNoText); } - if(moptions.FileBrowserToolbarSingleRow != options.FileBrowserToolbarSingleRow) { + if (moptions.FileBrowserToolbarSingleRow != options.FileBrowserToolbarSingleRow) { // Update the position of the Query toolbar - parent->updateFBQueryTB(moptions.FileBrowserToolbarSingleRow); + parent->updateFBQueryTB (moptions.FileBrowserToolbarSingleRow); } - if(moptions.showFilmStripToolBar != options.showFilmStripToolBar) { + if (moptions.showFilmStripToolBar != options.showFilmStripToolBar) { // Update the visibility of FB toolbar - parent->updateFBToolBarVisibility(moptions.showFilmStripToolBar); + parent->updateFBToolBarVisibility (moptions.showFilmStripToolBar); } - if(moptions.histogramPosition != options.histogramPosition) { + if (moptions.histogramPosition != options.histogramPosition) { // Update the position of the Histogram - parent->updateHistogramPosition(options.histogramPosition, moptions.histogramPosition); + parent->updateHistogramPosition (options.histogramPosition, moptions.histogramPosition); } - if( moptions.rtSettings.printerProfile != options.rtSettings.printerProfile - ||moptions.rtSettings.printerBPC != options.rtSettings.printerBPC - ||moptions.rtSettings.printerIntent != options.rtSettings.printerIntent) - { + if ( moptions.rtSettings.printerProfile != options.rtSettings.printerProfile + || moptions.rtSettings.printerBPC != options.rtSettings.printerBPC + || moptions.rtSettings.printerIntent != options.rtSettings.printerIntent) { // Update the position of the Histogram - parent->updateProfiles(moptions.rtSettings.printerProfile, moptions.rtSettings.printerIntent, moptions.rtSettings.printerBPC); + parent->updateProfiles (moptions.rtSettings.printerProfile, moptions.rtSettings.printerIntent, moptions.rtSettings.printerBPC); } } @@ -2316,7 +2380,7 @@ void Preferences::addExtPressed () return; } - Gtk::TreeRow row = *(extensionModel->append()); + Gtk::TreeRow row = * (extensionModel->append()); row[extensionColumns.enabled] = true; row[extensionColumns.ext] = extension->get_text (); @@ -2331,12 +2395,16 @@ void Preferences::delExtPressed () void Preferences::moveExtUpPressed () { const Glib::RefPtr selection = extensions->get_selection (); - if (!selection) + + if (!selection) { return; + } const Gtk::TreeModel::iterator selected = selection->get_selected (); - if (!selected || selected == extensionModel->children ().begin ()) + + if (!selected || selected == extensionModel->children ().begin ()) { return; + } Gtk::TreeModel::iterator previous = selected; --previous; @@ -2346,16 +2414,22 @@ void Preferences::moveExtUpPressed () void Preferences::moveExtDownPressed () { const Glib::RefPtr selection = extensions->get_selection (); - if (!selection) + + if (!selection) { return; + } const Gtk::TreeModel::iterator selected = selection->get_selected (); - if (!selected) + + if (!selected) { return; + } Gtk::TreeModel::iterator next = selected; - if (++next) + + if (++next) { extensionModel->iter_swap (selected, next); + } } void Preferences::clearProfilesPressed () @@ -2379,9 +2453,9 @@ void Preferences::clearAllPressed () void Preferences::darkFrameChanged () { //Glib::ustring s(darkFrameDir->get_filename()); - Glib::ustring s(darkFrameDir->get_current_folder()); + Glib::ustring s (darkFrameDir->get_current_folder()); //if( s.compare( rtengine::dfm.getPathname()) !=0 ){ - rtengine::dfm.init( s ); + rtengine::dfm.init ( s ); updateDFinfos(); //} } @@ -2389,9 +2463,9 @@ void Preferences::darkFrameChanged () void Preferences::flatFieldChanged () { //Glib::ustring s(flatFieldDir->get_filename()); - Glib::ustring s(flatFieldDir->get_current_folder()); + Glib::ustring s (flatFieldDir->get_current_folder()); //if( s.compare( rtengine::ffm.getPathname()) !=0 ){ - rtengine::ffm.init( s ); + rtengine::ffm.init ( s ); updateFFinfos(); //} } @@ -2399,20 +2473,20 @@ void Preferences::flatFieldChanged () void Preferences::updateDFinfos() { int t1, t2; - rtengine::dfm.getStat(t1, t2); - Glib::ustring s = Glib::ustring::compose("%1: %2 %3, %4 %5", M("PREFERENCES_DARKFRAMEFOUND"), t1, M("PREFERENCES_DARKFRAMESHOTS"), t2, M("PREFERENCES_DARKFRAMETEMPLATES")); - dfLabel->set_text(s); + rtengine::dfm.getStat (t1, t2); + Glib::ustring s = Glib::ustring::compose ("%1: %2 %3, %4 %5", M ("PREFERENCES_DARKFRAMEFOUND"), t1, M ("PREFERENCES_DARKFRAMESHOTS"), t2, M ("PREFERENCES_DARKFRAMETEMPLATES")); + dfLabel->set_text (s); } void Preferences::updateFFinfos() { int t1, t2; - rtengine::ffm.getStat(t1, t2); - Glib::ustring s = Glib::ustring::compose("%1: %2 %3, %4 %5", M("PREFERENCES_FLATFIELDFOUND"), t1, M("PREFERENCES_FLATFIELDSHOTS"), t2, M("PREFERENCES_FLATFIELDTEMPLATES")); - ffLabel->set_text(s); + rtengine::ffm.getStat (t1, t2); + Glib::ustring s = Glib::ustring::compose ("%1: %2 %3, %4 %5", M ("PREFERENCES_FLATFIELDFOUND"), t1, M ("PREFERENCES_FLATFIELDSHOTS"), t2, M ("PREFERENCES_FLATFIELDTEMPLATES")); + ffLabel->set_text (s); } -bool Preferences::splashClosed(GdkEventAny* event) +bool Preferences::splashClosed (GdkEventAny* event) { delete splash; splash = nullptr; diff --git a/rtgui/preferences.h b/rtgui/preferences.h index 91951a2df..07a56b73b 100644 --- a/rtgui/preferences.h +++ b/rtgui/preferences.h @@ -35,8 +35,8 @@ class Preferences : public Gtk::Dialog, public ProfileStoreListener Gtk::TreeModelColumn ext; ExtensionColumns() { - add(enabled); - add(ext); + add (enabled); + add (ext); } }; ExtensionColumns extensionColumns; @@ -53,11 +53,11 @@ class Preferences : public Gtk::Dialog, public ProfileStoreListener Gtk::TreeModelColumn addsetid; BehavColumns() { - add(label); - add(badd); - add(bset); - add(visible); - add(addsetid); + add (label); + add (badd); + add (bset); + add (visible); + add (addsetid); } }; @@ -67,7 +67,7 @@ class Preferences : public Gtk::Dialog, public ProfileStoreListener Glib::ustring shortFName; Glib::ustring longFName; - ThemeFilename (Glib::ustring sfname, Glib::ustring lfname) : shortFName(sfname), longFName(lfname) {} + ThemeFilename (Glib::ustring sfname, Glib::ustring lfname) : shortFName (sfname), longFName (lfname) {} }; Glib::RefPtr behModel; @@ -139,6 +139,7 @@ class Preferences : public Gtk::Dialog, public ProfileStoreListener Gtk::ComboBoxText* cprevdemo; Gtk::CheckButton* ctiffserialize; Gtk::ComboBoxText* curveBBoxPosC; + Gtk::ComboBoxText* cmip; Gtk::ComboBoxText* theme; Gtk::FontButton* fontButton; @@ -226,9 +227,9 @@ class Preferences : public Gtk::Dialog, public ProfileStoreListener void iccDirChanged (); void switchThemeTo (Glib::ustring newTheme); void switchFontTo (const Glib::ustring &newFontFamily, const int newFontSize); - bool splashClosed(GdkEventAny* event); + bool splashClosed (GdkEventAny* event); - int getThemeRowNumber(Glib::ustring& longThemeFName); + int getThemeRowNumber (Glib::ustring& longThemeFName); void appendBehavList (Gtk::TreeModel::iterator& parent, Glib::ustring label, int id, bool set); diff --git a/rtgui/profilepanel.cc b/rtgui/profilepanel.cc index 939739805..2b7dcc3aa 100644 --- a/rtgui/profilepanel.cc +++ b/rtgui/profilepanel.cc @@ -458,7 +458,7 @@ void ProfilePanel::load_clicked (GdkEventButton* event) if (result == Gtk::RESPONSE_OK) { Glib::ustring fname = dialog.get_filename(); - + printf("fname=%s\n", fname.c_str()); if (event->state & Gdk::CONTROL_MASK) { // opening the partial paste dialog window partialProfileDlg->set_title(M("PROFILEPANEL_LOADPPASTE")); diff --git a/rtgui/toolpanelcoord.cc b/rtgui/toolpanelcoord.cc index 98dc311f8..8ab29d53f 100644 --- a/rtgui/toolpanelcoord.cc +++ b/rtgui/toolpanelcoord.cc @@ -28,7 +28,7 @@ using namespace rtengine::procparams; -ToolPanelCoordinator::ToolPanelCoordinator () : ipc(nullptr), editDataProvider(nullptr) +ToolPanelCoordinator::ToolPanelCoordinator () : ipc (nullptr), editDataProvider (nullptr) { exposurePanel = Gtk::manage (new ToolVBox ()); @@ -53,7 +53,7 @@ ToolPanelCoordinator::ToolPanelCoordinator () : ipc(nullptr), editDataProvider(n colortoning = Gtk::manage (new ColorToning ()); lensgeom = Gtk::manage (new LensGeometry ()); lensProf = Gtk::manage (new LensProfilePanel ()); - lensProf->setLensGeomRef(lensgeom); + lensProf->setLensGeomRef (lensgeom); distortion = Gtk::manage (new Distortion ()); rotate = Gtk::manage (new Rotate ()); vibrance = Gtk::manage (new Vibrance ()); @@ -62,6 +62,7 @@ ToolPanelCoordinator::ToolPanelCoordinator () : ipc(nullptr), editDataProvider(n vignetting = Gtk::manage (new Vignetting ()); retinex = Gtk::manage (new Retinex ()); gradient = Gtk::manage (new Gradient ()); + locallab = Gtk::manage (new Locallab ()); pcvignette = Gtk::manage (new PCVignette ()); perspective = Gtk::manage (new PerspCorrection ()); cacorrection = Gtk::manage (new CACorrection ()); @@ -135,6 +136,9 @@ ToolPanelCoordinator::ToolPanelCoordinator () : ipc(nullptr), editDataProvider(n toolPanels.push_back (gradient); addPanel (exposurePanel, lcurve); toolPanels.push_back (lcurve); // << TODO: Add "Enabled" ??? + addPanel (exposurePanel, locallab); + toolPanels.push_back (locallab); + addPanel (exposurePanel, colorappearance); toolPanels.push_back (colorappearance); addPanel (detailsPanel, impulsedenoise); @@ -203,8 +207,8 @@ ToolPanelCoordinator::ToolPanelCoordinator () : ipc(nullptr), editDataProvider(n toolPanelNotebook = new Gtk::Notebook (); toolPanelNotebook->set_name ("ToolPanelNotebook"); - metadataPanel->append_page (*exifpanel, M("MAIN_TAB_EXIF")); - metadataPanel->append_page (*iptcpanel, M("MAIN_TAB_IPTC")); + metadataPanel->append_page (*exifpanel, M ("MAIN_TAB_EXIF")); + metadataPanel->append_page (*iptcpanel, M ("MAIN_TAB_IPTC")); exposurePanelSW = Gtk::manage (new MyScrolledWindow ()); detailsPanelSW = Gtk::manage (new MyScrolledWindow ()); @@ -217,47 +221,47 @@ ToolPanelCoordinator::ToolPanelCoordinator () : ipc(nullptr), editDataProvider(n // load panel endings for (int i = 0; i < 6; i++) { vbPanelEnd[i] = Gtk::manage (new Gtk::VBox ()); - imgPanelEnd[i] = Gtk::manage (new RTImage("PanelEnding.png")); + imgPanelEnd[i] = Gtk::manage (new RTImage ("PanelEnding.png")); imgPanelEnd[i]->show (); vbPanelEnd[i]->pack_start (*imgPanelEnd[i], Gtk::PACK_SHRINK); vbPanelEnd[i]->show_all(); } exposurePanelSW->add (*exposurePanel); - exposurePanel->pack_start (*Gtk::manage(new Gtk::HSeparator), Gtk::PACK_SHRINK, 0); + exposurePanel->pack_start (*Gtk::manage (new Gtk::HSeparator), Gtk::PACK_SHRINK, 0); exposurePanel->pack_start (*vbPanelEnd[0], Gtk::PACK_SHRINK, 4); detailsPanelSW->add (*detailsPanel); - detailsPanel->pack_start (*Gtk::manage(new Gtk::HSeparator), Gtk::PACK_SHRINK, 0); + detailsPanel->pack_start (*Gtk::manage (new Gtk::HSeparator), Gtk::PACK_SHRINK, 0); detailsPanel->pack_start (*vbPanelEnd[1], Gtk::PACK_SHRINK, 4); colorPanelSW->add (*colorPanel); - colorPanel->pack_start (*Gtk::manage(new Gtk::HSeparator), Gtk::PACK_SHRINK, 0); + colorPanel->pack_start (*Gtk::manage (new Gtk::HSeparator), Gtk::PACK_SHRINK, 0); colorPanel->pack_start (*vbPanelEnd[2], Gtk::PACK_SHRINK, 4); waveletPanelSW->add (*waveletPanel); - waveletPanel->pack_start (*Gtk::manage(new Gtk::HSeparator), Gtk::PACK_SHRINK, 0); + waveletPanel->pack_start (*Gtk::manage (new Gtk::HSeparator), Gtk::PACK_SHRINK, 0); waveletPanel->pack_start (*vbPanelEnd[5], Gtk::PACK_SHRINK, 0); transformPanelSW->add (*transformPanel); - transformPanel->pack_start (*Gtk::manage(new Gtk::HSeparator), Gtk::PACK_SHRINK, 0); + transformPanel->pack_start (*Gtk::manage (new Gtk::HSeparator), Gtk::PACK_SHRINK, 0); transformPanel->pack_start (*vbPanelEnd[3], Gtk::PACK_SHRINK, 4); rawPanelSW->add (*rawPanel); - rawPanel->pack_start (*Gtk::manage(new Gtk::HSeparator), Gtk::PACK_SHRINK, 0); + rawPanel->pack_start (*Gtk::manage (new Gtk::HSeparator), Gtk::PACK_SHRINK, 0); rawPanel->pack_start (*vbPanelEnd[4], Gtk::PACK_SHRINK, 0); TOITypes type = options.UseIconNoText ? TOI_ICON : TOI_TEXT; - toiE = Gtk::manage (new TextOrIcon ("exposure.png" , M("MAIN_TAB_EXPOSURE") , M("MAIN_TAB_EXPOSURE_TOOLTIP") , type)); - toiD = Gtk::manage (new TextOrIcon ("detail.png" , M("MAIN_TAB_DETAIL") , M("MAIN_TAB_DETAIL_TOOLTIP") , type)); - toiC = Gtk::manage (new TextOrIcon ("colour.png" , M("MAIN_TAB_COLOR") , M("MAIN_TAB_COLOR_TOOLTIP") , type)); - toiW = Gtk::manage (new TextOrIcon ("wavelet.png" , M("MAIN_TAB_WAVELET") , M("MAIN_TAB_WAVELET_TOOLTIP") , type)); - toiT = Gtk::manage (new TextOrIcon ("transform.png", M("MAIN_TAB_TRANSFORM"), M("MAIN_TAB_TRANSFORM_TOOLTIP"), type)); - toiR = Gtk::manage (new TextOrIcon ("raw.png" , M("MAIN_TAB_RAW") , M("MAIN_TAB_RAW_TOOLTIP") , type)); - toiM = Gtk::manage (new TextOrIcon ("meta.png" , M("MAIN_TAB_METADATA") , M("MAIN_TAB_METADATA_TOOLTIP") , type)); + toiE = Gtk::manage (new TextOrIcon ("exposure.png" , M ("MAIN_TAB_EXPOSURE") , M ("MAIN_TAB_EXPOSURE_TOOLTIP") , type)); + toiD = Gtk::manage (new TextOrIcon ("detail.png" , M ("MAIN_TAB_DETAIL") , M ("MAIN_TAB_DETAIL_TOOLTIP") , type)); + toiC = Gtk::manage (new TextOrIcon ("colour.png" , M ("MAIN_TAB_COLOR") , M ("MAIN_TAB_COLOR_TOOLTIP") , type)); + toiW = Gtk::manage (new TextOrIcon ("wavelet.png" , M ("MAIN_TAB_WAVELET") , M ("MAIN_TAB_WAVELET_TOOLTIP") , type)); + toiT = Gtk::manage (new TextOrIcon ("transform.png", M ("MAIN_TAB_TRANSFORM"), M ("MAIN_TAB_TRANSFORM_TOOLTIP"), type)); + toiR = Gtk::manage (new TextOrIcon ("raw.png" , M ("MAIN_TAB_RAW") , M ("MAIN_TAB_RAW_TOOLTIP") , type)); + toiM = Gtk::manage (new TextOrIcon ("meta.png" , M ("MAIN_TAB_METADATA") , M ("MAIN_TAB_METADATA_TOOLTIP") , type)); toolPanelNotebook->append_page (*exposurePanelSW, *toiE); toolPanelNotebook->append_page (*detailsPanelSW, *toiD); @@ -287,17 +291,17 @@ ToolPanelCoordinator::ToolPanelCoordinator () : ipc(nullptr), editDataProvider(n icm->setICMPanelListener (this); toolBar = new ToolBar (); - toolBar->setToolBarListener(this); + toolBar->setToolBarListener (this); } void ToolPanelCoordinator::addPanel (Gtk::Box* where, FoldableToolPanel* panel, int level) { - panel->setParent(where); - panel->setLevel(level); + panel->setParent (where); + panel->setLevel (level); expList.push_back (panel->getExpander()); - where->pack_start(*panel->getExpander(), false, false); + where->pack_start (*panel->getExpander(), false, false); } ToolPanelCoordinator::~ToolPanelCoordinator () @@ -316,7 +320,7 @@ void ToolPanelCoordinator::panelChanged (rtengine::ProcEvent event, const Glib:: return; } - int changeFlags = refreshmap[(int)event]; + int changeFlags = refreshmap[ (int)event]; ProcParams* params = ipc->beginUpdateParams (); @@ -326,14 +330,15 @@ void ToolPanelCoordinator::panelChanged (rtengine::ProcEvent event, const Glib:: // Compensate rotation on flip if (event == rtengine::EvCTHFlip || event == rtengine::EvCTVFlip) { - if (fabs(params->rotate.degree) > 0.001) { + if (fabs (params->rotate.degree) > 0.001) { params->rotate.degree *= -1; - changeFlags |= refreshmap[(int)rtengine::EvROTDegree]; + changeFlags |= refreshmap[ (int)rtengine::EvROTDegree]; rotate->read (params); } } int tr = TR_NONE; + if (params->coarse.rotate == 90) { tr = TR_R90; } else if (params->coarse.rotate == 180) { @@ -348,6 +353,7 @@ void ToolPanelCoordinator::panelChanged (rtengine::ProcEvent event, const Glib:: int fw, fh; ipc->getInitialImage()->getImageSource()->getFullSize (fw, fh, tr); gradient->updateGeometry (params->gradient.centerX, params->gradient.centerY, params->gradient.feather, params->gradient.degree, fw, fh); + locallab->updateGeometry (params->locallab.centerX, params->locallab.centerY, params->locallab.circrad, params->locallab.locY, params->locallab.degree, params->locallab.locX, params->locallab.locYT, params->locallab.locXL, fw, fh); } // some transformations make the crop change for convenience @@ -398,14 +404,14 @@ void ToolPanelCoordinator::profileChange (const PartialProfile *nparams, rtengi } // And apply the partial profile nparams to mergedParams - nparams->applyTo(mergedParams); + nparams->applyTo (mergedParams); // Derive the effective changes, if it's a profile change, to prevent slow RAW rerendering if not necessary bool filterRawRefresh = false; if (event != rtengine::EvPhotoLoaded) { - ParamsEdited pe(true); - std::vector lParams(2); + ParamsEdited pe (true); + std::vector lParams (2); lParams[0] = *params; lParams[1] = *mergedParams; pe.initFrom (lParams); @@ -417,6 +423,7 @@ void ToolPanelCoordinator::profileChange (const PartialProfile *nparams, rtengi delete mergedParams; tr = TR_NONE; + if (params->coarse.rotate == 90) { tr = TR_R90; } else if (params->coarse.rotate == 180) { @@ -427,7 +434,7 @@ void ToolPanelCoordinator::profileChange (const PartialProfile *nparams, rtengi // trimming overflowing cropped area ipc->getInitialImage()->getImageSource()->getFullSize (fw, fh, tr); - crop->trim(params, fw, fh); + crop->trim (params, fw, fh); // updating the GUI with updated values for (auto toolPanel : toolPanels) { @@ -441,11 +448,13 @@ void ToolPanelCoordinator::profileChange (const PartialProfile *nparams, rtengi if (event == rtengine::EvPhotoLoaded || event == rtengine::EvProfileChanged || event == rtengine::EvHistoryBrowsed || event == rtengine::EvCTRotate) { // updating the "on preview" geometry gradient->updateGeometry (params->gradient.centerX, params->gradient.centerY, params->gradient.feather, params->gradient.degree, fw, fh); + locallab->updateGeometry (params->locallab.centerX, params->locallab.centerY, params->locallab.circrad, params->locallab.locY, params->locallab.degree, params->locallab.locX, params->locallab.locYT, params->locallab.locXL, fw, fh); + } // start the IPC processing if (filterRawRefresh) { - ipc->endUpdateParams ( refreshmap[(int)event] & ALLNORAW ); + ipc->endUpdateParams ( refreshmap[ (int)event] & ALLNORAW ); } else { ipc->endUpdateParams (event); } @@ -492,12 +501,13 @@ void ToolPanelCoordinator::initImage (rtengine::StagedImageProcessor* ipc_, bool ipc->setAutoChromaListener (dirpyrdenoise); ipc->setWaveletListener (wavelet); ipc->setRetinexListener (retinex); + ipc->setlocalListener (locallab); ipc->setSizeListener (crop); ipc->setSizeListener (resize); } - flatfield->setShortcutPath(Glib::path_get_dirname(ipc->getInitialImage()->getFileName())); + flatfield->setShortcutPath (Glib::path_get_dirname (ipc->getInitialImage()->getFileName())); icm->setRawMeta (raw, (const rtengine::ImageData*)pMetaData); lensProf->setRawMeta (raw, pMetaData); @@ -521,7 +531,7 @@ void ToolPanelCoordinator::closeAllTools() for (size_t i = 0; i < options.tpOpen.size(); i++) if (i < expList.size()) { - expList.at(i)->set_expanded (false); + expList.at (i)->set_expanded (false); } } @@ -530,7 +540,7 @@ void ToolPanelCoordinator::openAllTools() for (size_t i = 0; i < options.tpOpen.size(); i++) if (i < expList.size()) { - expList.at(i)->set_expanded (true); + expList.at (i)->set_expanded (true); } } @@ -539,19 +549,19 @@ void ToolPanelCoordinator::updateToolState() for (size_t i = 0; i < options.tpOpen.size(); i++) if (i < expList.size()) { - expList.at(i)->set_expanded (options.tpOpen.at(i)); + expList.at (i)->set_expanded (options.tpOpen.at (i)); } - if(options.tpOpen.size() > expList.size()) { + if (options.tpOpen.size() > expList.size()) { size_t sizeWavelet = options.tpOpen.size() - expList.size(); std::vector temp; for (size_t i = 0; i < sizeWavelet; i++) { - temp.push_back(options.tpOpen.at(i + expList.size())); + temp.push_back (options.tpOpen.at (i + expList.size())); } - wavelet->updateToolState(temp); - wavelet->setExpanded(true); + wavelet->updateToolState (temp); + wavelet->setExpanded (true); } } @@ -568,11 +578,11 @@ void ToolPanelCoordinator::writeOptions () options.tpOpen.clear (); for (size_t i = 0; i < expList.size(); i++) { - options.tpOpen.push_back (expList.at(i)->get_expanded ()); + options.tpOpen.push_back (expList.at (i)->get_expanded ()); } - wavelet->writeOptions(options.tpOpen); - retinex->writeOptions(options.tpOpen); + wavelet->writeOptions (options.tpOpen); + retinex->writeOptions (options.tpOpen); } @@ -647,14 +657,14 @@ rtengine::RawImage* ToolPanelCoordinator::getDF() const rtengine::ImageMetaData *imd = ipc->getInitialImage()->getMetaData(); - if(imd) { + if (imd) { int iso = imd->getISOSpeed(); double shutter = imd->getShutterSpeed(); - std::string maker( imd->getMake() ); - std::string model( imd->getModel() ); + std::string maker ( imd->getMake() ); + std::string model ( imd->getModel() ); time_t timestamp = imd->getDateTimeAsTS(); - return rtengine::dfm.searchDarkFrame( maker, model, iso, shutter, timestamp); + return rtengine::dfm.searchDarkFrame ( maker, model, iso, shutter, timestamp); } return nullptr; @@ -668,17 +678,17 @@ rtengine::RawImage* ToolPanelCoordinator::getFF() const rtengine::ImageMetaData *imd = ipc->getInitialImage()->getMetaData(); - if(imd) { + if (imd) { // int iso = imd->getISOSpeed(); temporarilly removed because unused // double shutter = imd->getShutterSpeed(); temporarilly removed because unused double aperture = imd->getFNumber(); double focallength = imd->getFocalLen(); - std::string maker( imd->getMake() ); - std::string model( imd->getModel() ); - std::string lens( imd->getLens() ); + std::string maker ( imd->getMake() ); + std::string model ( imd->getModel() ); + std::string lens ( imd->getLens() ); time_t timestamp = imd->getDateTimeAsTS(); - return rtengine::ffm.searchFlatField( maker, model, lens, focallength, aperture, timestamp); + return rtengine::ffm.searchFlatField ( maker, model, lens, focallength, aperture, timestamp); } return nullptr; @@ -751,8 +761,8 @@ void ToolPanelCoordinator::updateCurveBackgroundHistogram (LUTu & histToneCurve, colorappearance->updateCurveBackgroundHistogram (histToneCurve, histLCurve, histCCurve, /*histCLurve, histLLCurve,*/ histLCAM, histCCAM, histRed, histGreen, histBlue, histLuma, histLRETI); toneCurve->updateCurveBackgroundHistogram (histToneCurve, histLCurve, histCCurve,/* histCLurve, histLLCurve,*/ histLCAM, histCCAM, histRed, histGreen, histBlue, histLuma, histLRETI); lcurve->updateCurveBackgroundHistogram (histToneCurve, histLCurve, histCCurve, /*histCLurve, histLLCurve,*/ histLCAM, histCCAM, histRed, histGreen, histBlue, histLuma, histLRETI); - rgbcurves->updateCurveBackgroundHistogram(histToneCurve, histLCurve, histCCurve,/* histCLurve, histLLCurve, */histLCAM, histCCAM, histRed, histGreen, histBlue, histLuma, histLRETI); - retinex->updateCurveBackgroundHistogram(histToneCurve, histLCurve, histCCurve,/* histCLurve, histLLCurve, */histLCAM, histCCAM, histRed, histGreen, histBlue, histLuma, histLRETI); + rgbcurves->updateCurveBackgroundHistogram (histToneCurve, histLCurve, histCCurve,/* histCLurve, histLLCurve, */histLCAM, histCCAM, histRed, histGreen, histBlue, histLuma, histLRETI); + retinex->updateCurveBackgroundHistogram (histToneCurve, histLCurve, histCCurve,/* histCLurve, histLLCurve, */histLCAM, histCCAM, histRed, histGreen, histBlue, histLuma, histLRETI); } @@ -766,10 +776,10 @@ void ToolPanelCoordinator::foldAllButOne (Gtk::Box* parent, FoldableToolPanel* o if (currentTP->getParent() == parent) { // Section in the same tab, we unfold it if it's not the one that has been clicked if (currentTP != openedSection) { - currentTP->setExpanded(false); + currentTP->setExpanded (false); } else { if (!currentTP->getExpanded()) { - currentTP->setExpanded(true); + currentTP->setExpanded (true); } } } @@ -785,36 +795,36 @@ bool ToolPanelCoordinator::handleShortcutKey (GdkEventKey* event) bool alt = event->state & GDK_MOD1_MASK; if (alt) { - switch(event->keyval) { - case GDK_KEY_e: - toolPanelNotebook->set_current_page (toolPanelNotebook->page_num(*exposurePanelSW)); - return true; - - case GDK_KEY_d: - toolPanelNotebook->set_current_page (toolPanelNotebook->page_num(*detailsPanelSW)); - return true; - - case GDK_KEY_c: - toolPanelNotebook->set_current_page (toolPanelNotebook->page_num(*colorPanelSW)); - return true; - - case GDK_KEY_t: - toolPanelNotebook->set_current_page (toolPanelNotebook->page_num(*transformPanelSW)); - return true; - - case GDK_KEY_r: - toolPanelNotebook->set_current_page (toolPanelNotebook->page_num(*rawPanelSW)); - return true; - - case GDK_KEY_w: - toolPanelNotebook->set_current_page (toolPanelNotebook->page_num(*waveletPanelSW)); - return true; - - case GDK_KEY_m: - if (metadataPanel) { - toolPanelNotebook->set_current_page (toolPanelNotebook->page_num(*metadataPanel)); + switch (event->keyval) { + case GDK_KEY_e: + toolPanelNotebook->set_current_page (toolPanelNotebook->page_num (*exposurePanelSW)); return true; - } + + case GDK_KEY_d: + toolPanelNotebook->set_current_page (toolPanelNotebook->page_num (*detailsPanelSW)); + return true; + + case GDK_KEY_c: + toolPanelNotebook->set_current_page (toolPanelNotebook->page_num (*colorPanelSW)); + return true; + + case GDK_KEY_t: + toolPanelNotebook->set_current_page (toolPanelNotebook->page_num (*transformPanelSW)); + return true; + + case GDK_KEY_r: + toolPanelNotebook->set_current_page (toolPanelNotebook->page_num (*rawPanelSW)); + return true; + + case GDK_KEY_w: + toolPanelNotebook->set_current_page (toolPanelNotebook->page_num (*waveletPanelSW)); + return true; + + case GDK_KEY_m: + if (metadataPanel) { + toolPanelNotebook->set_current_page (toolPanelNotebook->page_num (*metadataPanel)); + return true; + } } } @@ -833,7 +843,7 @@ void ToolPanelCoordinator::updateVScrollbars (bool hide) waveletPanelSW->set_policy (Gtk::POLICY_AUTOMATIC, policy); for (auto currExp : expList) { - currExp->updateVScrollbars(hide); + currExp->updateVScrollbars (hide); } } @@ -842,14 +852,14 @@ void ToolPanelCoordinator::updateTabsHeader (bool useIcons) GThreadLock lock; // All GUI acces from idle_add callbacks or separate thread HAVE to be protected TOITypes type = useIcons ? TOI_ICON : TOI_TEXT; - toiE->switchTo(type); - toiD->switchTo(type); - toiC->switchTo(type); - toiT->switchTo(type); - toiR->switchTo(type); + toiE->switchTo (type); + toiD->switchTo (type); + toiC->switchTo (type); + toiT->switchTo (type); + toiR->switchTo (type); if (toiM) { - toiM->switchTo(type); + toiM->switchTo (type); } } @@ -868,24 +878,24 @@ void ToolPanelCoordinator::toolSelected (ToolMode tool) GThreadLock lock; // All GUI acces from idle_add callbacks or separate thread HAVE to be protected switch (tool) { - case TMCropSelect: - crop->setExpanded(true); - toolPanelNotebook->set_current_page(toolPanelNotebook->page_num(*transformPanelSW)); - break; + case TMCropSelect: + crop->setExpanded (true); + toolPanelNotebook->set_current_page (toolPanelNotebook->page_num (*transformPanelSW)); + break; - case TMSpotWB: - whitebalance->setExpanded(true); - toolPanelNotebook->set_current_page(toolPanelNotebook->page_num(*colorPanelSW)); - break; + case TMSpotWB: + whitebalance->setExpanded (true); + toolPanelNotebook->set_current_page (toolPanelNotebook->page_num (*colorPanelSW)); + break; - case TMStraighten: - lensgeom->setExpanded(true); - rotate->setExpanded(true); - toolPanelNotebook->set_current_page(toolPanelNotebook->page_num(*transformPanelSW)); - break; + case TMStraighten: + lensgeom->setExpanded (true); + rotate->setExpanded (true); + toolPanelNotebook->set_current_page (toolPanelNotebook->page_num (*transformPanelSW)); + break; - default: - break; + default: + break; } } @@ -899,14 +909,14 @@ void ToolPanelCoordinator::editModeSwitchedOff () void ToolPanelCoordinator::dirSelected (const Glib::ustring& dirname, const Glib::ustring& openfile) { - flatfield->setShortcutPath(dirname); + flatfield->setShortcutPath (dirname); } -void ToolPanelCoordinator::setEditProvider(EditDataProvider *provider) +void ToolPanelCoordinator::setEditProvider (EditDataProvider *provider) { editDataProvider = provider; for (size_t i = 0; i < toolPanels.size(); i++) { - toolPanels.at(i)->setEditProvider(provider); + toolPanels.at (i)->setEditProvider (provider); } } diff --git a/rtgui/toolpanelcoord.h b/rtgui/toolpanelcoord.h index c4d4d3ac2..04221ddef 100644 --- a/rtgui/toolpanelcoord.h +++ b/rtgui/toolpanelcoord.h @@ -53,6 +53,7 @@ #include "vignetting.h" #include "retinex.h" #include "gradient.h" +#include "locallab.h" #include "pcvignette.h" #include "toolbar.h" #include "lensgeom.h" @@ -100,6 +101,7 @@ protected: WhiteBalance* whitebalance; Vignetting* vignetting; Gradient* gradient; + Locallab* locallab; Retinex* retinex; PCVignette* pcvignette; LensGeometry* lensgeom; @@ -308,7 +310,7 @@ public: void toolSelected (ToolMode tool); void editModeSwitchedOff (); - void setEditProvider(EditDataProvider *provider); + void setEditProvider (EditDataProvider *provider); }; #endif