From f74e4b0dd20aafce52a208434570bece705687c1 Mon Sep 17 00:00:00 2001 From: Desmis Date: Fri, 13 Nov 2015 08:45:24 +0100 Subject: [PATCH] Fixed numerous bug and add Preview for mask and transmission --- rtdata/languages/default | 6 +++ rtengine/imagesource.h | 2 +- rtengine/improccoordinator.cc | 2 +- rtengine/ipretinex.cc | 33 ++++++++++--- rtengine/procevents.h | 2 + rtengine/procparams.cc | 15 ++++++ rtengine/procparams.h | 1 + rtengine/rawimagesource.cc | 4 +- rtengine/rawimagesource.h | 2 +- rtengine/refreshmap.cc | 7 +-- rtengine/shmap.cc | 17 ++++--- rtengine/simpleprocess.cc | 2 +- rtgui/paramsedited.cc | 6 +++ rtgui/paramsedited.h | 1 + rtgui/retinex.cc | 91 ++++++++++++++++++++++++++++++++--- rtgui/retinex.h | 6 ++- 16 files changed, 165 insertions(+), 32 deletions(-) diff --git a/rtdata/languages/default b/rtdata/languages/default index 97b327ef6..4ec24b42c 100644 --- a/rtdata/languages/default +++ b/rtdata/languages/default @@ -666,6 +666,7 @@ HISTORY_MSG_433;Retinex - Mask TW shadows HISTORY_MSG_434;Retinex - Mask radius HISTORY_MSG_435;Retinex - Mask method HISTORY_MSG_436;Retinex - Mask curve +HISTORY_MSG_437;Retinex - Preview HISTORY_NEWSNAPSHOT;Add HISTORY_NEWSNAPSHOT_TOOLTIP;Shortcut: Alt-s HISTORY_SNAPSHOTS;Snapshots @@ -1707,6 +1708,11 @@ TP_RETINEX_TRANSMISSION_TOOLTIP;Transmission according to transmission.\nAbsciss TP_RETINEX_UNIFORM;Uniform TP_RETINEX_VARIANCE;Variance TP_RETINEX_VARIANCE_TOOLTIP;Low variance increase local contrast and saturation, but can lead to artifacts. +TP_RETINEX_VIEW;Preview +TP_RETINEX_VIEW_NONE;Standard +TP_RETINEX_VIEW_MASK;Mask +TP_RETINEX_VIEW_TRAN;Transmission +TP_RETINEX_VIEW_METHOD_TOOLTIP;Standard - normal display\nMask - display mask\nTransmission - displays the file transmission-map , before any action on contrast and brightness\nAttention, this does not correspond to reality, but a shift to make it visible TP_RGBCURVES_BLUE;B TP_RGBCURVES_CHANNEL;Channel TP_RGBCURVES_GREEN;G diff --git a/rtengine/imagesource.h b/rtengine/imagesource.h index eaf9997fa..80fc53f23 100644 --- a/rtengine/imagesource.h +++ b/rtengine/imagesource.h @@ -69,7 +69,7 @@ public: virtual int load (Glib::ustring fname, bool batch = false) = 0; virtual void preprocess (const RAWParams &raw, const LensProfParams &lensProf, const CoarseTransformParams& coarse) {}; virtual void demosaic (const RAWParams &raw) {}; - virtual void retinex (ColorManagementParams cmp, RetinexParams deh, ToneCurveParams Tc, LUTf & cdcurve, const RetinextransmissionCurve & dehatransmissionCurve, multi_array2D &conversionBuffer, bool dehacontlutili, bool mapcontlutili, bool useHsl, float &minCD, float &maxCD, float &mini, float &maxi, float &Tmean, float &Tsigma, float &Tmin, float &Tmax, LUTu &histLRETI) {}; + virtual void retinex (ColorManagementParams cmp, RetinexParams deh, ToneCurveParams Tc, LUTf & cdcurve, LUTf & mapcurve, const RetinextransmissionCurve & dehatransmissionCurve, multi_array2D &conversionBuffer, bool dehacontlutili, bool mapcontlutili, bool useHsl, float &minCD, float &maxCD, float &mini, float &maxi, float &Tmean, float &Tsigma, float &Tmin, float &Tmax, LUTu &histLRETI) {}; virtual void retinexPrepareCurves (RetinexParams retinexParams, LUTf &cdcurve, LUTf &mapcurve, RetinextransmissionCurve &retinextransmissionCurve, bool &retinexcontlutili, bool &mapcontlutili, bool &useHsl, LUTu & lhist16RETI, LUTu & histLRETI) {}; virtual void retinexPrepareBuffers (ColorManagementParams cmp, RetinexParams retinexParams, multi_array2D &conversionBuffer, LUTu &lhist16RETI) {}; virtual void flushRawData () {}; diff --git a/rtengine/improccoordinator.cc b/rtengine/improccoordinator.cc index 479ec1282..dc135c4d5 100644 --- a/rtengine/improccoordinator.cc +++ b/rtengine/improccoordinator.cc @@ -251,7 +251,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) imgsrc->retinexPrepareCurves(params.retinex, cdcurve, mapcurve, dehatransmissionCurve, dehacontlutili, mapcontlutili, useHsl, lhist16RETI, histLRETI); float minCD, maxCD, mini, maxi, Tmean, Tsigma, Tmin, Tmax; - imgsrc->retinex( params.icm, params.retinex, params.toneCurve, mapcurve, dehatransmissionCurve, 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, 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); diff --git a/rtengine/ipretinex.cc b/rtengine/ipretinex.cc index d444380ce..839d8646e 100644 --- a/rtengine/ipretinex.cc +++ b/rtengine/ipretinex.cc @@ -405,7 +405,12 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e if(deh.mapMethod=="mapT") mapmet=3; if(deh.mapMethod=="curv") mapmet=1; if(deh.mapMethod=="gaus") mapmet=4; + double shradius = (double) deh.radius; + // printf("shrad=%f\n",shradius); + int viewmet=0; + if(deh.viewMethod=="mask") viewmet=1; + if(deh.viewMethod=="tran") viewmet=2; #ifdef _OPENMP #pragma omp parallel for @@ -424,6 +429,13 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e out[i] = &outBuffer[i * W_L]; } + float *tran[H_L] ALIGNED16; + float *tranBuffer = new float[H_L * W_L]; + + for (int i = 0; i < H_L; i++) { + tran[i] = &tranBuffer[i * W_L]; + } + const float logBetaGain = xlogf(16384.f); float pond = logBetaGain / (float) scal; @@ -451,8 +463,8 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e printf(".."); - double shradius = deh.radius; - if(mapmet==4) shradius /= 10.; + if(mapmet==4) shradius /= 1.; + else shradius = 40.; // if(shHighlights > 0 || shShadows > 0) { if(mapmet==3) if(it==1) shmap->updateL (out, shradius, true, 1);//wav Total @@ -488,7 +500,7 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e } // if(shHighlights > 0 || shShadows > 0) { - if((mapmet == 2 && scale >2) || mapmet==3 || mapmet==4) { + if(((mapmet == 2 && scale >2) || mapmet==3 || mapmet==4) && it==1) { #ifdef _OPENMP @@ -545,6 +557,7 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e } } } + printf(".\n"); if(mapmet > 1) { if(shmap) { delete shmap; @@ -553,7 +566,7 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e shmap = NULL; delete [] buffer; - delete [] outBuffer; +// delete [] outBuffer; delete [] srcBuffer; mean = 0.f; @@ -598,6 +611,7 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e } luminance[i][j] *= (-1.f + 4.f * dehatransmissionCurve[absciss]); //new transmission + tran[i][j]=luminance[i][j]; } } @@ -713,8 +727,10 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e } } - // if(exLuminance[i][j] > 65535.f*hig && higplus) str *= hig; - luminance[i][j] = clipretinex( cd, 0.f, 32768.f ) * str + (1.f - str) * originalLuminance[i][j]; + if(exLuminance[i][j] > 65535.f*hig && higplus) str *= hig; + if(viewmet==0) luminance[i][j]=clipretinex( cd, 0.f, 32768.f ) * str + (1.f - str) * originalLuminance[i][j]; + if(viewmet==1) luminance[i][j] = out[i][j]; + if(viewmet==2) luminance[i][j] = 1000.f+ tran[i][j]*700.f;//arbitrary values to help display log values which are between -20 to + 30 - usage values -4 + 5 } #ifdef _OPENMP @@ -726,6 +742,11 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e } } + delete [] outBuffer; + outBuffer = NULL; + delete [] tranBuffer; + tranBuffer = NULL; + // printf("cdmin=%f cdmax=%f\n",minCD, maxCD); Tmean = mean; Tsigma = stddv; diff --git a/rtengine/procevents.h b/rtengine/procevents.h index f23d68f2e..d02018d78 100644 --- a/rtengine/procevents.h +++ b/rtengine/procevents.h @@ -464,6 +464,8 @@ enum ProcEvent { EvLradius = 433, EvmapMethod = 434, EvRetinexmapcurve = 435, + EvviewMethod = 436, + NUMOFEVENTS }; } diff --git a/rtengine/procparams.cc b/rtengine/procparams.cc index 075067585..7a674e8c3 100644 --- a/rtengine/procparams.cc +++ b/rtengine/procparams.cc @@ -163,6 +163,7 @@ void RetinexParams::setDefaults() // grbl = 50; retinexMethod = "high"; mapMethod = "none"; + viewMethod = "none"; retinexcolorspace = "Lab"; gammaretinex = "none"; medianmap = false; @@ -1526,6 +1527,10 @@ int ProcParams::save (Glib::ustring fname, Glib::ustring fname2, bool fnameAbsol keyFile.set_string ("Retinex", "mapMethod", retinex.mapMethod); } + if (!pedited || pedited->retinex.viewMethod) { + keyFile.set_string ("Retinex", "viewMethod", retinex.viewMethod); + } + if (!pedited || pedited->retinex.retinexcolorspace) { keyFile.set_string ("Retinex", "Retinexcolorspace", retinex.retinexcolorspace); } @@ -3864,6 +3869,15 @@ int ProcParams::load (Glib::ustring fname, ParamsEdited* pedited) } } + if (keyFile.has_key ("Retinex", "viewMethod")) { + retinex.viewMethod = keyFile.get_string ("Retinex", "viewMethod"); + + if (pedited) { + pedited->retinex.viewMethod = true; + } + } + + if (keyFile.has_key ("Retinex", "Retinexcolorspace")) { retinex.retinexcolorspace = keyFile.get_string ("Retinex", "Retinexcolorspace"); @@ -7478,6 +7492,7 @@ bool ProcParams::operator== (const ProcParams& other) && retinex.offs == other.retinex.offs && retinex.retinexMethod == other.retinex.retinexMethod && retinex.mapMethod == other.retinex.mapMethod + && retinex.viewMethod == other.retinex.viewMethod && retinex.retinexcolorspace == other.retinex.retinexcolorspace && retinex.gammaretinex == other.retinex.gammaretinex && retinex.vart == other.retinex.vart diff --git a/rtengine/procparams.h b/rtengine/procparams.h index e2d2539ea..0aa31a9bd 100644 --- a/rtengine/procparams.h +++ b/rtengine/procparams.h @@ -294,6 +294,7 @@ public: Glib::ustring retinexcolorspace; Glib::ustring gammaretinex; Glib::ustring mapMethod; + Glib::ustring viewMethod; int vart; int limd; int highl; diff --git a/rtengine/rawimagesource.cc b/rtengine/rawimagesource.cc index 8a4fc3559..c552c64ac 100644 --- a/rtengine/rawimagesource.cc +++ b/rtengine/rawimagesource.cc @@ -2122,7 +2122,7 @@ void RawImageSource::retinexPrepareCurves(RetinexParams retinexParams, LUTf &cdc } //void RawImageSource::retinex(ColorManagementParams cmp, RetinexParams deh, ToneCurveParams Tc, LUTf & cdcurve, const RetinextransmissionCurve & dehatransmissionCurve, multi_array2D &conversionBuffer, bool dehacontlutili, bool useHsl, float &minCD, float &maxCD, float &mini, float &maxi, float &Tmean, float &Tsigma, float &Tmin, float &Tmax, LUTu &histLRETI) -void RawImageSource::retinex(ColorManagementParams cmp, RetinexParams deh, ToneCurveParams Tc, LUTf & cdcurve, const RetinextransmissionCurve & dehatransmissionCurve, multi_array2D &conversionBuffer, bool dehacontlutili, bool mapcontlutili, bool useHsl, float &minCD, float &maxCD, float &mini, float &maxi, float &Tmean, float &Tsigma, float &Tmin, float &Tmax, LUTu &histLRETI) +void RawImageSource::retinex(ColorManagementParams cmp, RetinexParams deh, ToneCurveParams Tc, LUTf & cdcurve, LUTf & mapcurve, const RetinextransmissionCurve & dehatransmissionCurve, multi_array2D &conversionBuffer, bool dehacontlutili, bool mapcontlutili, bool useHsl, float &minCD, float &maxCD, float &mini, float &maxi, float &Tmean, float &Tsigma, float &Tmin, float &Tmax, LUTu &histLRETI) { MyTime t4, t5; @@ -2274,7 +2274,7 @@ void RawImageSource::retinex(ColorManagementParams cmp, RetinexParams deh, ToneC } } - MSR(LBuffer, conversionBuffer[2], conversionBuffer[3], cdcurve, mapcontlutili, WNew, HNew, deh, dehatransmissionCurve, minCD, maxCD, mini, maxi, Tmean, Tsigma, Tmin, Tmax); + MSR(LBuffer, conversionBuffer[2], conversionBuffer[3], mapcurve, mapcontlutili, WNew, HNew, deh, dehatransmissionCurve, minCD, maxCD, mini, maxi, Tmean, Tsigma, Tmin, Tmax); if(useHsl) { if(chutili) { diff --git a/rtengine/rawimagesource.h b/rtengine/rawimagesource.h index f9e7e6cf1..10057d58a 100644 --- a/rtengine/rawimagesource.h +++ b/rtengine/rawimagesource.h @@ -152,7 +152,7 @@ public: void preprocess (const RAWParams &raw, const LensProfParams &lensProf, const CoarseTransformParams& coarse); void demosaic (const RAWParams &raw); // void retinex (RAWParams raw, ColorManagementParams cmp, RetinexParams lcur, LUTf & cdcurve, bool dehacontlutili); - void retinex (ColorManagementParams cmp, RetinexParams deh, ToneCurveParams Tc, LUTf & cdcurve, const RetinextransmissionCurve & dehatransmissionCurve, multi_array2D &conversionBuffer, bool dehacontlutili, bool mapcontlutili, bool useHsl, float &minCD, float &maxCD, float &mini, float &maxi, float &Tmean, float &Tsigma, float &Tmin, float &Tmax, LUTu &histLRETI); + void retinex (ColorManagementParams cmp, RetinexParams deh, ToneCurveParams Tc, LUTf & cdcurve, LUTf & mapcurve, const RetinextransmissionCurve & dehatransmissionCurve, multi_array2D &conversionBuffer, bool dehacontlutili, bool mapcontlutili, bool useHsl, float &minCD, float &maxCD, float &mini, float &maxi, float &Tmean, float &Tsigma, float &Tmin, float &Tmax, LUTu &histLRETI); void retinexPrepareCurves (RetinexParams retinexParams, LUTf &cdcurve, LUTf &mapcurve, RetinextransmissionCurve &retinextransmissionCurve, bool &retinexcontlutili, bool &mapcontlutili, bool &useHsl, LUTu & lhist16RETI, LUTu & histLRETI); void retinexPrepareBuffers (ColorManagementParams cmp, RetinexParams retinexParams, multi_array2D &conversionBuffer, LUTu &lhist16RETI); void flushRawData (); diff --git a/rtengine/refreshmap.cc b/rtengine/refreshmap.cc index 83cacfa1a..915ed615d 100644 --- a/rtengine/refreshmap.cc +++ b/rtengine/refreshmap.cc @@ -440,13 +440,13 @@ int refreshmap[rtengine::NUMOFEVENTS] = { RETINEX, // EvLstr RETINEX, // EvLscal RETINEX, // EvLvart - RETINEX, // EvLCDCurve + DEMOSAIC, // EvLCDCurve RETINEX, // EvRetinextransmission DEMOSAIC, // EvRetinexEnabled RETINEX, // EvRetinexmedianmap RETINEX, // EvLlimd DEMOSAIC, // Evretinexcolorspace - RETINEX, // EvLCDHCurve + DEMOSAIC, // EvLCDHCurve DEMOSAIC, // Evretinexgamma DEMOSAIC, // EvLgam DEMOSAIC, // EvLslope @@ -463,7 +463,8 @@ int refreshmap[rtengine::NUMOFEVENTS] = { RETINEX, //EvLs_tonalwidth RETINEX, //EvLradius RETINEX, //EvmapMethod - RETINEX //EvRetinexmapcurve + DEMOSAIC, //EvRetinexmapcurve + DEMOSAIC //EvviewMethod }; diff --git a/rtengine/shmap.cc b/rtengine/shmap.cc index f1539171d..2471b17a4 100644 --- a/rtengine/shmap.cc +++ b/rtengine/shmap.cc @@ -242,23 +242,23 @@ void SHMap::updateL (float** L, double radius, bool hq, int skip) { //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //experimental dirpyr shmap - float thresh = (100.f * radius); //1000; - + int levrad = 16; + levrad=2;//for retinex - otherwise levrad = 16 // set up range function // calculate size of Lookup table. That's possible because from a value k for all i>=k rangefn[i] will be exp(-10) // So we use this fact and the automatic clip of lut to reduce the size of lut and the number of calculations to fill the lut // In past this lut had only integer precision with rangefn[i] = 0 for all i>=k // We set the last element to a small epsilon 1e-15 instead of zero to avoid divisions by zero - const int lutSize = thresh * sqrtf(10.f) + 1; + const int lutSize = (int) thresh * sqrtf(10.f) + 1; thresh *= thresh; LUTf rangefn(lutSize); - for (int i = 0; i < lutSize - 1; i++) { rangefn[i] = xexpf(-min(10.f, (static_cast(i) * i) / thresh )); //*intfactor; } rangefn[lutSize - 1] = 1e-15f; + //printf("lut=%d rf5=%f rfm=%f\n thre=%f",lutSize, rangefn[5],rangefn[lutSize-10],thresh ); // We need one temporary buffer float ** buffer = allocArray (W, H); @@ -271,7 +271,7 @@ void SHMap::updateL (float** L, double radius, bool hq, int skip) int numLevels = 2; int scale = 2; - while (skip * scale < 16) { + while (skip * scale < levrad) { scale *= 2; numLevels++; } @@ -296,7 +296,7 @@ void SHMap::updateL (float** L, double radius, bool hq, int skip) level ++; indx = 1 - indx; - while (skip * scale < 16) { + while (skip * scale < levrad) { dirpyr_shmap(dirpyrlo[indx], dirpyrlo[1 - indx], W, H, rangefn, level, scale ); scale *= 2; level ++; @@ -398,7 +398,7 @@ SSEFUNCTION void SHMap::dirpyr_shmap(float ** data_fine, float ** data_coarse, i #endif { #if defined( __SSE2__ ) && defined( __x86_64__ ) - __m128 dirwtv, valv, normv, dftemp1v, dftemp2v; + __m128 dirwtv, valv, normv, dftemp1v, dftemp2v, fg; #endif // __SSE2__ int j; #ifdef _OPENMP @@ -414,6 +414,7 @@ SSEFUNCTION void SHMap::dirpyr_shmap(float ** data_fine, float ** data_coarse, i for(int inbr = max(i - scalewin, i % scale); inbr <= min(i + scalewin, height - 1); inbr += scale) { for (int jnbr = j % scale; jnbr <= j + scalewin; jnbr += scale) { + //printf("dat=%f ",abs(data_fine[inbr][jnbr] - data_fine[i][j])); dirwt = ( rangefn[abs(data_fine[inbr][jnbr] - data_fine[i][j])] ); val += dirwt * data_fine[inbr][jnbr]; norm += dirwt; @@ -504,7 +505,7 @@ SSEFUNCTION void SHMap::dirpyr_shmap(float ** data_fine, float ** data_coarse, i #endif { #if defined( __SSE2__ ) && defined( __x86_64__ ) - __m128 dirwtv, valv, normv, dftemp1v, dftemp2v; + __m128 dirwtv, valv, normv, dftemp1v, dftemp2v, fgg; float domkerv[5][5][4] __attribute__ ((aligned (16))) = {{{1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}}, {{1, 1, 1, 1}, {2, 2, 2, 2}, {2, 2, 2, 2}, {2, 2, 2, 2}, {1, 1, 1, 1}}, {{1, 1, 1, 1}, {2, 2, 2, 2}, {2, 2, 2, 2}, {2, 2, 2, 2}, {1, 1, 1, 1}}, {{1, 1, 1, 1}, {2, 2, 2, 2}, {2, 2, 2, 2}, {2, 2, 2, 2}, {1, 1, 1, 1}}, {{1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}}}; #endif // __SSE2__ diff --git a/rtengine/simpleprocess.cc b/rtengine/simpleprocess.cc index 1836c5446..3e667c129 100644 --- a/rtengine/simpleprocess.cc +++ b/rtengine/simpleprocess.cc @@ -129,7 +129,7 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p imgsrc->retinexPrepareBuffers(params.icm, params.retinex, conversionBuffer, dummy); imgsrc->retinexPrepareCurves(params.retinex, cdcurve, mapcurve, dehatransmissionCurve, dehacontlutili, mapcontlutili, useHsl, dummy, dummy ); float minCD, maxCD, mini, maxi, Tmean, Tsigma, Tmin, Tmax; - imgsrc->retinex( params.icm, params.retinex, params.toneCurve, mapcurve, dehatransmissionCurve, conversionBuffer, dehacontlutili, mapcontlutili, useHsl, minCD, maxCD, mini, maxi, Tmean, Tsigma, Tmin, Tmax, dummy); + imgsrc->retinex( params.icm, params.retinex, params.toneCurve, cdcurve, mapcurve, dehatransmissionCurve, conversionBuffer, dehacontlutili, mapcontlutili, useHsl, minCD, maxCD, mini, maxi, Tmean, Tsigma, Tmin, Tmax, dummy); } if (pl) { diff --git a/rtgui/paramsedited.cc b/rtgui/paramsedited.cc index 5178f3b8a..35f26c58c 100644 --- a/rtgui/paramsedited.cc +++ b/rtgui/paramsedited.cc @@ -55,6 +55,7 @@ void ParamsEdited::set (bool v) retinex.lhcurve = v; retinex.retinexMethod = v; retinex.mapMethod = v; + retinex.viewMethod = v; retinex.retinexcolorspace = v; retinex.gammaretinex = v; retinex.enabled = v; @@ -544,6 +545,7 @@ void ParamsEdited::initFrom (const std::vector retinex.transmissionCurve = retinex.transmissionCurve && p.retinex.transmissionCurve == other.retinex.transmissionCurve; retinex.retinexMethod = retinex.retinexMethod && p.retinex.retinexMethod == other.retinex.retinexMethod; retinex.mapMethod = retinex.mapMethod && p.retinex.mapMethod == other.retinex.mapMethod; + retinex.viewMethod = retinex.viewMethod && p.retinex.viewMethod == other.retinex.viewMethod; retinex.retinexcolorspace = retinex.retinexcolorspace && p.retinex.retinexcolorspace == other.retinex.retinexcolorspace; retinex.gammaretinex = retinex.gammaretinex && p.retinex.gammaretinex == other.retinex.gammaretinex; retinex.str = retinex.str && p.retinex.str == other.retinex.str; @@ -1092,6 +1094,10 @@ void ParamsEdited::combine (rtengine::procparams::ProcParams& toEdit, const rten toEdit.retinex.mapMethod = mods.retinex.mapMethod; } + if (retinex.viewMethod) { + toEdit.retinex.viewMethod = mods.retinex.viewMethod; + } + if (retinex.retinexcolorspace) { toEdit.retinex.retinexcolorspace = mods.retinex.retinexcolorspace; } diff --git a/rtgui/paramsedited.h b/rtgui/paramsedited.h index ba53ee5ea..60fbbdb81 100644 --- a/rtgui/paramsedited.h +++ b/rtgui/paramsedited.h @@ -71,6 +71,7 @@ public: bool offs; bool retinexMethod; bool mapMethod; + bool viewMethod; bool retinexcolorspace; bool gammaretinex; bool vart; diff --git a/rtgui/retinex.cc b/rtgui/retinex.cc index 2ede52af6..5e4a9f636 100644 --- a/rtgui/retinex.cc +++ b/rtgui/retinex.cc @@ -195,6 +195,17 @@ Retinex::Retinex () : FoldableToolPanel(this, "retinex", M("TP_RETINEX_LABEL"), s_tonalwidth = Gtk::manage (new Adjuster (M("TP_SHADOWSHLIGHTS_SHTONALW"), 10, 100, 1, 80)); radius = Gtk::manage (new Adjuster (M("TP_SHADOWSHLIGHTS_RADIUS"), 5, 100, 1, 40)); + viewbox = Gtk::manage (new Gtk::HBox ()); + labview = Gtk::manage (new Gtk::Label (M("TP_RETINEX_VIEW") + ":")); + viewbox->pack_start (*labview, Gtk::PACK_SHRINK, 1); + + viewMethod = Gtk::manage (new MyComboBoxText ()); + viewMethod->append_text (M("TP_RETINEX_VIEW_NONE")); + viewMethod->append_text (M("TP_RETINEX_VIEW_MASK")); + viewMethod->append_text (M("TP_RETINEX_VIEW_TRAN")); + viewMethod->set_active(0); + viewMethodConn = viewMethod->signal_changed().connect ( sigc::mem_fun(*this, &Retinex::viewMethodChanged) ); + viewMethod->set_tooltip_markup (M("TP_RETINEX_VIEW_METHOD_TOOLTIP")); curveEditorGH = new CurveEditorGroup (options.lastRetinexDir, M("TP_RETINEX_CONTEDIT_LH")); curveEditorGH->setCurveListener (this); @@ -292,6 +303,12 @@ Retinex::Retinex () : FoldableToolPanel(this, "retinex", M("TP_RETINEX_LABEL"), s_tonalwidth->show(); settingsVBox->pack_start (*radius); radius->show(); + + viewbox->pack_start(*viewMethod); + settingsVBox->pack_start(*viewbox); + + //settingsVBox->pack_start (*viewMethod); + // settingsVBox->pack_start (*highl); // highl->show (); @@ -481,6 +498,7 @@ void Retinex::neutral_pressed () s_tonalwidth->resetValue(false); radius->resetValue(false); mapMethod->set_active(0); + viewMethod->set_active(0); retinexMethod->set_active(2); retinexcolorspace->set_active(0); gammaretinex->set_active(0); @@ -599,6 +617,7 @@ void Retinex::read (const ProcParams* pp, const ParamsEdited* pedited) retinexColorSpaceConn.block(true); gammaretinexConn.block(true); mapMethodConn.block(true); + viewMethodConn.block(true); if (pedited) { @@ -633,6 +652,10 @@ void Retinex::read (const ProcParams* pp, const ParamsEdited* pedited) mapMethod->set_active_text(M("GENERAL_UNCHANGED")); } + if (!pedited->retinex.viewMethod) { + viewMethod->set_active_text(M("GENERAL_UNCHANGED")); + } + if (!pedited->retinex.retinexcolorspace) { retinexcolorspace->set_active_text(M("GENERAL_UNCHANGED")); } @@ -712,6 +735,13 @@ void Retinex::read (const ProcParams* pp, const ParamsEdited* pedited) mapMethod->set_active (4); } + if (pp->retinex.viewMethod == "none") { + viewMethod->set_active (0); + } else if (pp->retinex.viewMethod == "mask") { + viewMethod->set_active (1); + } else if (pp->retinex.viewMethod == "tran") { + viewMethod->set_active (2); + } if (pp->retinex.retinexcolorspace == "Lab") { retinexcolorspace->set_active (0); @@ -737,6 +767,7 @@ void Retinex::read (const ProcParams* pp, const ParamsEdited* pedited) retinexColorSpaceChanged(); gammaretinexChanged(); mapMethodChanged (); + viewMethodChanged (); medianmapConn.block(true); medianmapChanged (); @@ -751,6 +782,7 @@ void Retinex::read (const ProcParams* pp, const ParamsEdited* pedited) retinexColorSpaceConn.block(false); gammaretinexConn.block(false); mapMethodConn.block(false); + viewMethodConn.block(false); transmissionShape->setCurve (pp->retinex.transmissionCurve); @@ -796,6 +828,7 @@ void Retinex::write (ProcParams* pp, ParamsEdited* pedited) pedited->retinex.retinexcolorspace = retinexcolorspace->get_active_text() != M("GENERAL_UNCHANGED"); pedited->retinex.gammaretinex = gammaretinex->get_active_text() != M("GENERAL_UNCHANGED"); pedited->retinex.mapMethod = mapMethod->get_active_text() != M("GENERAL_UNCHANGED"); + pedited->retinex.viewMethod = viewMethod->get_active_text() != M("GENERAL_UNCHANGED"); //%%%%%%%%%%%%%%%%%%%%%% pedited->retinex.str = str->getEditedState (); @@ -853,6 +886,14 @@ void Retinex::write (ProcParams* pp, ParamsEdited* pedited) pp->retinex.mapMethod = "mapT"; } + if (viewMethod->get_active_row_number() == 0) { + pp->retinex.viewMethod = "none"; + } else if (viewMethod->get_active_row_number() == 1) { + pp->retinex.viewMethod = "mask"; + } else if (viewMethod->get_active_row_number() == 2) { + pp->retinex.viewMethod = "tran"; + } + if (retinexcolorspace->get_active_row_number() == 0) { pp->retinex.retinexcolorspace = "Lab"; } else if (retinexcolorspace->get_active_row_number() == 1) { @@ -894,20 +935,20 @@ void Retinex::retinexMethodChanged() void Retinex::mapMethodChanged() { - if(mapMethod->get_active_row_number() >= 1) { + if(mapMethod->get_active_row_number() == 1 || mapMethod->get_active_row_number() == 2) { curveEditormap->show(); highlights->show(); h_tonalwidth->show(); shadows->show(); s_tonalwidth->show(); radius->show(); - /* } else if(mapMethod->get_active_row_number() == 1) { - curveEditormap->show(); - highlights->hide(); - h_tonalwidth->hide(); - shadows->hide(); - s_tonalwidth->hide(); - radius->hide();*/ + } else if(mapMethod->get_active_row_number() == 3 || mapMethod->get_active_row_number() == 4) { + curveEditormap->show(); + highlights->show(); + h_tonalwidth->show(); + shadows->show(); + s_tonalwidth->show(); + radius->hide(); } else { curveEditormap->hide(); highlights->hide(); @@ -923,6 +964,40 @@ void Retinex::mapMethodChanged() } } +void Retinex::viewMethodChanged() +{ + /* + if(mapMethod->get_active_row_number() == 1 || mapMethod->get_active_row_number() == 2) { + curveEditormap->show(); + highlights->show(); + h_tonalwidth->show(); + shadows->show(); + s_tonalwidth->show(); + radius->show(); + } else if(mapMethod->get_active_row_number() == 3 || mapMethod->get_active_row_number() == 4) { + curveEditormap->show(); + highlights->show(); + h_tonalwidth->show(); + shadows->show(); + s_tonalwidth->show(); + radius->hide(); + } else { + curveEditormap->hide(); + highlights->hide(); + h_tonalwidth->hide(); + shadows->hide(); + s_tonalwidth->hide(); + radius->hide(); + + } + */ + if (listener) { + listener->panelChanged (EvviewMethod, viewMethod->get_active_text ()); + } +} + + + void Retinex::ColorSpaceUpdateUI () { if (!batchMode) { diff --git a/rtgui/retinex.h b/rtgui/retinex.h index ac55fea99..d24254757 100644 --- a/rtgui/retinex.h +++ b/rtgui/retinex.h @@ -50,6 +50,8 @@ protected: Gtk::HBox* dhbox; Gtk::HBox* mapbox; Gtk::Label* labmap; + Gtk::HBox* viewbox; + Gtk::Label* labview; Gtk::Label* labgam; Gtk::HBox* gambox; @@ -60,6 +62,7 @@ protected: MyComboBoxText* retinexcolorspace; MyComboBoxText* gammaretinex; MyComboBoxText* mapMethod; + MyComboBoxText* viewMethod; Gtk::CheckButton* medianmap; double nextmin; double nextmax; @@ -78,7 +81,7 @@ protected: DiagonalCurveEditor* cdshapeH; DiagonalCurveEditor* mapshape; CurveEditorGroup* transmissionCurveEditorG; - sigc::connection retinexMethodConn, neutralconn, mapMethodConn; + sigc::connection retinexMethodConn, neutralconn, mapMethodConn, viewMethodConn; sigc::connection retinexColorSpaceConn; sigc::connection gammaretinexConn; FlatCurveEditor* transmissionShape; @@ -108,6 +111,7 @@ public: void curveChanged (CurveEditor* ce); void retinexMethodChanged(); void mapMethodChanged(); + void viewMethodChanged(); void retinexColorSpaceChanged(); void gammaretinexChanged(); void ColorSpaceUpdateUI();