From b5ddef00ed0db41dd0f111093cca3fa743f79cc3 Mon Sep 17 00:00:00 2001 From: Desmis Date: Sat, 15 Jul 2017 17:50:32 +0200 Subject: [PATCH] Init new - add GUI and Mip for local vibrance - does nothing --- rtdata/languages/default | 1 + rtengine/curves.cc | 18 ++ rtengine/curves.h | 1 + rtengine/dcrop.cc | 102 +++++++- rtengine/improccoordinator.cc | 436 ++++++++++++++++++++++++++++-- rtengine/improccoordinator.h | 17 +- rtengine/improcfun.cc | 24 +- rtengine/iplocallab.cc | 105 +------- rtengine/procevents.h | 10 + rtengine/procparams.cc | 135 ++++++++++ rtengine/procparams.h | 13 +- rtengine/refreshmap.cc | 14 +- rtengine/rtengine.h | 4 +- rtengine/simpleprocess.cc | 174 +++++++++++- rtgui/locallab.cc | 480 ++++++++++++++++++++++++++++++++-- rtgui/locallab.h | 41 ++- rtgui/paramsedited.cc | 58 +++- rtgui/paramsedited.h | 10 + 18 files changed, 1457 insertions(+), 186 deletions(-) diff --git a/rtdata/languages/default b/rtdata/languages/default index 26300601e..6c68499c9 100644 --- a/rtdata/languages/default +++ b/rtdata/languages/default @@ -1814,6 +1814,7 @@ 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_LOCALLAB_VIBRANCE;Vibrance TP_LOCAL_HEIGHT;Bottom TP_LOCAL_HEIGHT_T;Top TP_LOCAL_WIDTH;Right diff --git a/rtengine/curves.cc b/rtengine/curves.cc index f70f658ad..a34e4358c 100644 --- a/rtengine/curves.cc +++ b/rtengine/curves.cc @@ -447,6 +447,24 @@ void CurveFactory::curveCCLocal (bool & localcutili, const std::vector& } +void CurveFactory::curveskLocal (bool & localskutili, const std::vector& curvePoints, LUTf & LocalskCurve, 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; + localskutili = true; + } + } + + fillCurveArray (dCurve.get(), LocalskCurve, skip, needed); + +} + void CurveFactory::localLCurve (double br, double contr, /*const std::vector& curvePoints,*/ LUTu & histogram, LUTf & outCurve, diff --git a/rtengine/curves.h b/rtengine/curves.h index a45a8f11d..05737415f 100644 --- a/rtengine/curves.h +++ b/rtengine/curves.h @@ -298,6 +298,7 @@ public: static void curveLocal ( bool & locallutili, const std::vector& curvePoints, LUTf & LocalLCurve, int skip); static void curveCCLocal ( bool & localcutili, const std::vector& curvePoints, LUTf & LocalCCurve, int skip); + static void curveskLocal ( bool & localskutili, const std::vector& curvePoints, LUTf & LocalskCurve, 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, diff --git a/rtengine/dcrop.cc b/rtengine/dcrop.cc index a90fdd642..b29a07889 100644 --- a/rtengine/dcrop.cc +++ b/rtengine/dcrop.cc @@ -820,6 +820,9 @@ void Crop::update (int todo) LUTf lllocalcurve2 (65536, 0); bool localcutili = parent->locallutili; LUTf cclocalcurve2 (65536, 0); + bool localskutili = parent->localskutili; + LUTf sklocalcurve2 (65536, 0); + bool LHutili = parent->LHutili; bool HHutili = parent->HHutili; @@ -833,11 +836,11 @@ void Crop::update (int todo) locallutili = false; int sca = skip; - // bool tyty = false; + bool tyty = false; int maxspot = settings->nspot + 1; if (needslocal ) { - // if (tyty ) { + // if (tyty ) { std::string mdfive = getMD5 (parent->imgsrc->getFileName()); @@ -989,6 +992,28 @@ void Crop::update (int todo) params.locallab.qualitycurveMethod = "enh" ; } + params.locallab.sensiv = parent->sensivs[sp]; + params.locallab.pastels = parent->pastels[sp]; + params.locallab.saturated = parent->saturateds[sp]; + + if (parent->protectskinss[sp] == 0) { + params.locallab.protectskins = false; + } else { + params.locallab.protectskins = true; + } + + if (parent->avoidcolorshifts[sp] == 0) { + params.locallab.avoidcolorshift = false; + } else { + params.locallab.avoidcolorshift = true; + } + + if (parent->pastsattogs[sp] == 0) { + params.locallab.pastsattog = false; + } else { + params.locallab.pastsattog = true; + } + std::vector cretie; for (int j = 0; j < parent->sizeretics[sp]; j++) { @@ -1034,11 +1059,24 @@ void Crop::update (int todo) params.locallab.HHcurve.clear(); params.locallab.HHcurve = hhc; + std::vector skc; + + for (int j = 0; j < parent->sizeskintonecurves[sp]; j++) { + skc.push_back ((double) (parent->skintonescurves[sp * 500 + j]) / 1000.); + } + + params.locallab.skintonescurve.clear(); + params.locallab.skintonescurve = skc; + + params.locallab.psthreshold.setValues (parent->psthresholds[sp * 500], parent->psthresholds[sp * 500 + 1]); + params.locallab.getCurves (locRETgainCurve, locRETgainCurverab, loclhCurve, lochhCurve, LHutili, HHutili); locallutili = false; CurveFactory::curveLocal (locallutili, params.locallab.llcurve, lllocalcurve2, sca); localcutili = false; CurveFactory::curveCCLocal (localcutili, params.locallab.cccurve, cclocalcurve2, sca); + localskutili = false; + CurveFactory::curveskLocal (localskutili, params.locallab.skintonescurve, sklocalcurve2, sca); params.locallab.hueref = (parent->huerefs[sp]) / 100.f; params.locallab.chromaref = parent->chromarefs[sp]; @@ -1049,6 +1087,7 @@ void Crop::update (int todo) 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, lochhCurve, LHutili, HHutili, cclocalcurve2, params.locallab.hueref, params.locallab.chromaref, params.locallab.lumaref); lllocalcurve2.clear(); cclocalcurve2.clear(); + sklocalcurve2.clear(); if (skip <= 2) { usleep (settings->cropsleep); //wait to avoid crash when crop 100% and move window @@ -1230,6 +1269,40 @@ void Crop::update (int todo) parent->qualitycurves[sp] = 2; } + parent->sensivs[sp] = params.locallab.sensiv = parent->sensivs[0]; + parent->pastels[sp] = params.locallab.pastels = parent->pastels[0]; + parent->saturateds[sp] = params.locallab.saturated = parent->saturateds[0]; + + if (parent->protectskinss[0] == 0) { + params.locallab.protectskins = false; + parent->protectskinss[sp] = 0; + + } else { + params.locallab.protectskins = true; + parent->protectskinss[sp] = 1; + + } + + if (parent->avoidcolorshifts[0] == 0) { + params.locallab.avoidcolorshift = false; + parent->avoidcolorshifts[sp] = 0; + + } else { + params.locallab.avoidcolorshift = true; + parent->avoidcolorshifts[sp] = 1; + + } + + if (parent->pastsattogs[0] == 0) { + params.locallab.pastsattog = false; + parent->pastsattogs[sp] = 0; + + } else { + params.locallab.pastsattog = true; + parent->pastsattogs[sp] = 1; + + } + std::vector ccret; for (int j = 0; j < parent->sizeretics[sp]; j++) { @@ -1279,22 +1352,41 @@ void Crop::update (int todo) params.locallab.HHcurve.clear(); params.locallab.HHcurve = hhcL; + + std::vector skcL; + + for (int j = 0; j < parent->sizeskintonecurves[sp]; j++) { + skcL.push_back ((double) (parent->skintonescurves[0 * 500 + j]) / 1000.); + parent->skintonescurves[sp * 500 + j] = parent->skintonescurves[0 * 500 + j] ; + } + + params.locallab.skintonescurve.clear(); + params.locallab.skintonescurve = skcL; + + parent->skintonescurves[sp * 500] = parent->skintonescurves[0 * 500]; + parent->skintonescurves[sp * 500 + 1] = parent->skintonescurves[0 * 500 + 1]; + + params.locallab.psthreshold.setValues (parent->psthresholds[0 * 500], parent->psthresholds[0 * 500 + 1]); + params.locallab.getCurves (locRETgainCurve, locRETgainCurverab, loclhCurve, lochhCurve, LHutili, HHutili); locallutili = false; localcutili = false; + localskutili = false; - CurveFactory::curveLocal (locallutili, params.locallab.llcurve, lllocalcurve2, sca); // skip == 1 ? 1 : 16); - CurveFactory::curveCCLocal (localcutili, params.locallab.cccurve, cclocalcurve2, sca); // skip == 1 ? 1 : 16); + CurveFactory::curveLocal (locallutili, params.locallab.llcurve, lllocalcurve2, sca); + CurveFactory::curveCCLocal (localcutili, params.locallab.cccurve, cclocalcurve2, sca); + CurveFactory::curveskLocal (localskutili, params.locallab.skintonescurve, sklocalcurve2, sca); params.locallab.hueref = (parent->huerefs[sp]) / 100.f; params.locallab.chromaref = parent->chromarefs[sp]; params.locallab.lumaref = parent->lumarefs[sp]; - // printf ("dcr2 sp=%i huer=%f \n", sp, parent->huerefs[sp] / 100.f); + // printf ("dcr2 = sp=%i huer=%f \n", sp, parent->huerefs[sp] / 100.f); 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, lochhCurve, LHutili, HHutili, cclocalcurve2, params.locallab.hueref, params.locallab.chromaref, params.locallab.lumaref); lllocalcurve2.clear(); cclocalcurve2.clear(); + sklocalcurve2.clear(); } diff --git a/rtengine/improccoordinator.cc b/rtengine/improccoordinator.cc index 9bd9800d9..3a4237f2b 100644 --- a/rtengine/improccoordinator.cc +++ b/rtengine/improccoordinator.cc @@ -27,6 +27,7 @@ #include #include #include "../rtgui/md5helper.h" +#include "../rtgui/thresholdselector.h" #include "iccstore.h" #ifdef _OPENMP @@ -57,6 +58,7 @@ ImProcCoordinator::ImProcCoordinator () clToningcurve (65536, 0), lllocalcurve (65536, 0), cclocalcurve (65536, 0), + sklocalcurve (65536, 0), cl2Toningcurve (65536, 0), Noisecurve (65536, 0), NoiseCCcurve (65536, 0), @@ -93,7 +95,7 @@ ImProcCoordinator::ImProcCoordinator () plistener (nullptr), awbListener (nullptr), imageListener (nullptr), aeListener (nullptr), acListener (nullptr), abwListener (nullptr), aloListener (nullptr), actListener (nullptr), adnListener (nullptr), awavListener (nullptr), dehaListener (nullptr), frameCountListener (nullptr), imageTypeListener (nullptr), hListener (nullptr), resultValid (false), lastOutputProfile ("BADFOOD"), lastOutputIntent (RI__COUNT), lastOutputBPC (false), thread (nullptr), changeSinceLast (0), updaterRunning (false), destroying (false), utili (false), autili (false), butili (false), ccutili (false), cclutili (false), clcutili (false), opautili (false), wavcontlutili (false), - dataspot (nullptr), retistr (nullptr), llstr (nullptr), lhstr (nullptr), ccstr (nullptr), hhstr (nullptr), + dataspot (nullptr), retistr (nullptr), llstr (nullptr), lhstr (nullptr), ccstr (nullptr), hhstr (nullptr), skinstr (nullptr), pthstr (nullptr), circrads (500, -10000), centerx (500, -10000), centery (500, -10000), @@ -162,6 +164,15 @@ ImProcCoordinator::ImProcCoordinator () sizehhcs (500, -10000), cccurvs (25000, -10000), //allow 500 values for each control point * 500 sizecccs (500, -10000), + sensivs (500, -10000), + saturateds (500, -10000), + pastels (500, -10000), + psthresholds (500, -10000), + protectskinss (500, -10000), + avoidcolorshifts (500, -10000), + pastsattogs (500, -10000), + skintonescurves (500, -10000), + sizeskintonecurves (500, -10000), huerefs (500, -100000.f), chromarefs (500, -100000.f), lumarefs (500, -100000.f), @@ -922,6 +933,16 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) //versionmip = 10008 HHcurv std::string t_curvhh = "1000A0B500C350D350E166F500G350H350I333J500K350L350M500N500O350P350Q666R500S350T350U833V500W350X350Y"; + //10008 + int t_sensiv = 19; + int t_pastel = 0; + int t_saturated = 0; + std::string t_psthres = "0A75B"; + int t_proskin = 0; + int t_avoidcsh = 0; + int t_pastsat = 0; + std::string t_curvskin = "3000A0B0C1000D1000E"; //"3000A0B0C499D501E1000F1000G";// "3000A0B0C1000D1000E";//with that it works ! + //all variables except locRETgainCurve 'coomon for all) fic << "Mipversion=" << t_mipversion << '@' << endl; fic << "Spot=" << t_sp << '@' << endl; @@ -984,11 +1005,20 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) fic << "Curvactiv=" << t_curvactiv << '@' << endl; fic << "qualitycurveMethod=" << t_qualitycurveMethod << '@' << endl; + fic << "Sensiv=" << t_sensiv << '@' << endl; + fic << "Pastel=" << t_pastel << '@' << endl; + fic << "Saturated=" << t_saturated << '@' << endl; + fic << "Proskin=" << t_proskin << '@' << endl; + fic << "Avoidcsh=" << t_avoidcsh << '@' << endl; + fic << "Pastsat=" << t_pastsat << '@' << endl; + fic << "curveReti=" << t_curvret << '@' << endl; fic << "curveLL=" << t_curvll << '@' << endl; fic << "curveLH=" << t_curvlh << '@' << endl; fic << "curveCC=" << t_curvcc << '@' << endl; fic << "curveHH=" << t_curvhh << '@' << endl; + fic << "curveskin=" << t_curvskin << '@' << endl; + fic << "pthres=" << t_psthres << '@' << endl; fic << endl; } @@ -1007,9 +1037,9 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) int realspot = params.locallab.nbspot; std::string inser; - dataspot = new int*[61]; + dataspot = new int*[67]; - for (int i = 0; i < 61; i++) { + for (int i = 0; i < 67; i++) { dataspot[i] = new int[maxspot]; } @@ -1018,6 +1048,8 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) lhstr = new std::string[maxspot]; ccstr = new std::string[maxspot]; hhstr = new std::string[maxspot]; + skinstr = new std::string[maxspot]; + pthstr = new std::string[maxspot]; { @@ -1146,6 +1178,29 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) dataspot[57][0] = qualitycurves[0] = 2; } + + dataspot[58][0] = sensivs[0] = params.locallab.sensiv; + dataspot[59][0] = pastels[0] = params.locallab.pastels; + dataspot[60][0] = saturateds[0] = params.locallab.saturated; + + if (!params.locallab.protectskins) { + dataspot[61][0] = protectskinss[0] = 0; + } else { + dataspot[61][0] = protectskinss[0] = 1; + } + + if (!params.locallab.avoidcolorshift) { + dataspot[62][0] = avoidcolorshifts[0] = 0; + } else { + dataspot[62][0] = avoidcolorshifts[0] = 1; + } + + if (!params.locallab.pastsattog) { + dataspot[63][0] = pastsattogs[0] = 0; + } else { + dataspot[63][0] = pastsattogs[0] = 1; + } + //curve Reti local int siz = params.locallab.localTgaincurve.size(); @@ -1237,6 +1292,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) lhstr[0] = lh_str + "@"; + //HH curve //curve local H f(H) int sizhh = params.locallab.HHcurve.size(); @@ -1261,18 +1317,62 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) hhstr[0] = hh_str + "@"; //end local L = f(H) + + //Skin curve + int sizsk = params.locallab.skintonescurve.size(); + + if (sizsk > 69) { + sizsk = 69;//to avoid crash + } + + + int s_datcursk[sizsk + 1]; + + for (int j = 0; j < sizsk; j++) { + s_datcursk[j] = skintonescurves[0 + j] = (int) (1000. * params.locallab.skintonescurve[j]); + } + + std::string sk_str = ""; + + for (int j = 0; j < sizsk; j++) { + sk_str = sk_str + std::to_string (s_datcursk[j]) + delim[j]; + } + + skinstr[0] = sk_str + "@"; + + //end local skin + + + //PSThreshold + int sizps = 2; + int s_datps[sizps + 1]; + s_datps[1] = psthresholds[0] = static_cast (params.locallab.psthreshold.value[ThresholdSelector::TS_TOPLEFT]); + + s_datps[0] = psthresholds[1] = static_cast (params.locallab.psthreshold.value[ThresholdSelector::TS_BOTTOMLEFT]); + + std::string ps_str = ""; + + //printf("0=%i 1=%i\n", s_datps[0], s_datps[1]); + for (int j = 0; j < sizps; j++) { + ps_str = ps_str + std::to_string (s_datps[j]) + delim[j]; + } + + pthstr[0] = ps_str + "@"; + + //end local ps + //spot references /* - dataspot[58][0] = huerefs[0] = 100.f * params.locallab.hueref; - dataspot[59][0] = chromarefs[0] = params.locallab.chromaref; - dataspot[60][0] = lumarefs[0] = params.locallab.lumaref; + dataspot[64][0] = huerefs[0] = 100.f * params.locallab.hueref; + dataspot[65][0] = chromarefs[0] = params.locallab.chromaref; + dataspot[66][0] = lumarefs[0] = params.locallab.lumaref; printf("dataspot58-0=%i\n", dataspot[58][0]); */ 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], ccstr[0], hhstr[0], 0, 1); + aloListener->localretChanged (dataspot, retistr[0], llstr[0], lhstr[0], ccstr[0], hhstr[0], skinstr[0], pthstr[0], 0, 1); } } @@ -1292,6 +1392,8 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) bool excurvlh = true; bool excurvcc = true; bool excurvhh = true; + bool excurvsk = true; + bool excpth = true; ifstream fich (datal, ios::in); @@ -1301,7 +1403,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) std::string line; std::string spotline; int cont = 0; - int maxind = 58; + int maxind = 64; if (versionmip == 10000) { maxind = 49; @@ -1309,6 +1411,9 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) excurvll = false; excurvlh = false; excurvhh = false; + excurvsk = false; + excpth = false; + } if (versionmip == 10001) { @@ -1317,6 +1422,8 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) excurvll = false; excurvlh = false; excurvhh = false; + excurvsk = false; + excpth = false; } @@ -1332,6 +1439,10 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) maxind = 57; } + if (versionmip == 10007 || versionmip == 10008) { + maxind = 58; + } + while (getline (fich, line)) { spotline = line; @@ -1453,6 +1564,40 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) // sizelh = longeh; } + if (excurvsk && spotline.substr (0, pos) == "curveskin") { + std::string curstskin; + // int longecurh; + std::string strendsk = spotline.substr (posend - 1, 1); + // std::size_t poszh = spotline.find (strendh); + // int longeh; + + for (int sh = 0; sh < 69; sh++) { + if (delim[sh] == strendsk) { + // longeh = sh + 1; + } + } + + skinstr[ns] = str3; + // sizelh = longeh; + } + + if (excpth && spotline.substr (0, pos) == "pthres") { + std::string curstpth; + // int longecurh; + std::string strendpt = spotline.substr (posend - 1, 1); + // std::size_t poszh = spotline.find (strendh); + // int longeh; + + for (int sh = 0; sh < 69; sh++) { + if (delim[sh] == strendpt) { + // longeh = sh + 1; + } + } + + pthstr[ns] = str3; + // sizelh = longeh; + } + } @@ -1529,13 +1674,29 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) } } + if (versionmip == 10008) { + + for (int sp = 1; sp < maxspot; sp++) { // spots default + + dataspot[58][sp] = 19; + dataspot[59][sp] = 0; + dataspot[60][sp] = 0; + dataspot[61][sp] = 0; + dataspot[62][sp] = 0; + dataspot[63][sp] = 0; + std::string sk_str = "3000A0B0C1000D1000E"; + skinstr[sp] = sk_str + "@"; + pthstr[sp] = "0A75B@"; + } + } + 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 = 10008; + int t_mipversion = 10009; int t_circrad = 18; int t_locX = 250; int t_locY = 250; @@ -1607,6 +1768,17 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) int t_qualitycurveMethod = 0; std::string t_curvhh = "1000A0B500C350D350E166F500G350H350I333J500K350L350M500N500O350P350Q666R500S350T350U833V500W350X350Y"; //10008 + std::string t_curvskin = "3000A0B0C1000D1000E"; //"3000A0B0C499D501E1000F1000G"; //"3000A0B0C1000D1000E";//0 points with marks + + + int t_sensiv = 19; + int t_pastel = 0; + int t_saturated = 0; + std::string t_psthres = "0A75B"; + int t_proskin = 0; + int t_avoidcsh = 0; + int t_pastsat = 0; + fic << "Mipversion=" << t_mipversion << '@' << endl; fic << "Spot=" << t_sp << '@' << endl; fic << "Circrad=" << t_circrad << '@' << endl; @@ -1667,11 +1839,20 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) fic << "Curvactiv=" << t_curvactiv << '@' << endl; fic << "qualitycurveMethod=" << t_qualitycurveMethod << '@' << endl; + fic << "Sensiv=" << t_sensiv << '@' << endl; + fic << "Pastel=" << t_pastel << '@' << endl; + fic << "Saturated=" << t_saturated << '@' << endl; + fic << "Proskin=" << t_proskin << '@' << endl; + fic << "Avoidcsh=" << t_avoidcsh << '@' << endl; + fic << "Pastsat=" << t_pastsat << '@' << endl; + fic << "curveReti=" << t_curvret << '@' << endl; fic << "curveLL=" << t_curvll << '@' << endl; fic << "curveLH=" << t_curvlh << '@' << endl; fic << "curveCC=" << t_curvcc << '@' << endl; fic << "curveHH=" << t_curvhh << '@' << endl; + fic << "curveskin=" << t_curvskin << '@' << endl; + fic << "pthres=" << t_psthres << '@' << endl; fic << endl; } @@ -1687,7 +1868,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) std::string spotline2; int cont2 = 0; int ns2 = 0; - int maxin = 58; + int maxin = 64; // int sizecu2; // int sizell2; // int sizelh2; @@ -1819,6 +2000,44 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) } + + if (spotline2.substr (0, pos2) == "curveskin") { + std::string curstr2sk; + // int longecur2h; + std::string strend2sk = spotline2.substr (posend2 - 1, 1); + // std::size_t posz2h = spotline2.find (strend2h); + // int longe2h; + + for (int sh = 0; sh < 69; sh++) { + if (delim[sh] == strend2sk) { + // longe2h = sh + 1; + } + } + + skinstr[ns] = str32; + // sizelh2 = longe2h; + + } + + + if (spotline2.substr (0, pos2) == "pthres") { + std::string curstpth; + // int longecurh; + std::string strendpt = spotline2.substr (posend2 - 1, 1); + // std::size_t poszh = spotline.find (strendh); + // int longeh; + + for (int sh = 0; sh < 69; sh++) { + if (delim[sh] == strendpt) { + // longeh = sh + 1; + } + } + + pthstr[ns] = str32; + // sizelh = longeh; + } + + } fich2.close() ; @@ -1831,10 +2050,10 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) for (int sp = 1; sp < maxspot; sp++) { //spots default - params.locallab.hueref = dataspot[58][sp] / 100.; - params.locallab.chromaref = dataspot[59][sp]; + params.locallab.hueref = dataspot[64][sp] / 100.; + params.locallab.chromaref = dataspot[65][sp]; bool locutili = false; - params.locallab.lumaref = dataspot[60][sp]; + params.locallab.lumaref = dataspot[66][sp]; params.locallab.circrad = circrads[sp] = dataspot[2][sp]; params.locallab.locX = locx[sp] = dataspot[3][sp]; params.locallab.locY = locy[sp] = dataspot[4][sp]; @@ -1987,6 +2206,36 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) params.locallab.qualitycurveMethod = "enh" ; } + params.locallab.sensiv = sensivs[sp] = dataspot[58][sp]; + params.locallab.pastels = pastels[sp] = dataspot[59][sp]; + params.locallab.saturated = saturateds[sp] = dataspot[60][sp]; + + if (dataspot[61][sp] == 0) { + protectskinss[sp] = 0; + params.locallab.protectskins = false; + } else { + protectskinss[sp] = 1; + params.locallab.protectskins = true; + } + + if (dataspot[62][sp] == 0) { + avoidcolorshifts[sp] = 0; + params.locallab.avoidcolorshift = false; + } else { + avoidcolorshifts[sp] = 1; + params.locallab.avoidcolorshift = true; + } + + if (dataspot[63][sp] == 0) { + pastsattogs[sp] = 0; + params.locallab.pastsattog = false; + } else { + pastsattogs[sp] = 1; + params.locallab.pastsattog = true; + } + + + int *s_datc; s_datc = new int[70]; int siz; @@ -2074,6 +2323,36 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) delete [] s_datchh; + + int *s_datcsk; + s_datcsk = new int[70]; + int sizsk; + + ipf.strcurv_data (skinstr[sp], s_datcsk, sizsk); + + sizeskintonecurves[sp] = sizsk; + + std::vector cskend; + + for (int j = 0; j < sizsk; j++) { + skintonescurves[sp * 500 + j] = s_datcsk[j]; + cskend.push_back ((double) (s_datcsk[j]) / 1000.); + } + + delete [] s_datcsk; + + //PSThreshold + 1 + int sizps = 2; + int s_datcps[sizps + 1]; + ipf.strcurv_data (pthstr[sp], s_datcps, sizps); + + psthresholds[sp * 500] = s_datcps[0]; + psthresholds[sp * 500 + 1] = s_datcps[1]; + + params.locallab.psthreshold.setValues (s_datcps[0], s_datcps[1]); + + //end local PS + params.locallab.localTgaincurve.clear(); params.locallab.localTgaincurve = cretiend; @@ -2091,12 +2370,18 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) params.locallab.HHcurve.clear(); params.locallab.HHcurve = chhend; + params.locallab.skintonescurve.clear(); + params.locallab.skintonescurve = cskend; + + locallutili = false; localcutili = false; + localskutili = false; LHutili = false; HHutili = false; std::string t_curvhhref = "1000A0B500C350D350E166F500G350H350I333J500K350L350M500N500O350P350Q666R500S350T350U833V500W350X350Y@"; + //printf("hhs=%s \n", hhstr[sp].c_str()); if (lhstr[sp].c_str() != t_curvhhref) { LHutili = true; } @@ -2109,6 +2394,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) params.locallab.getCurves (locRETgainCurve, locRETgainCurverab, loclhCurve, lochhCurve, LHutili, HHutili); CurveFactory::curveLocal (locallutili, params.locallab.llcurve, lllocalcurve, sca); //scale == 1 ? 1 : 16); CurveFactory::curveCCLocal (localcutili, params.locallab.cccurve, cclocalcurve, sca); //scale == 1 ? 1 : 16); + CurveFactory::curveskLocal (localskutili, params.locallab.skintonescurve, sklocalcurve, sca); //scale == 1 ? 1 : 16); double huere, chromare, lumare; ipf.calc_ref (3, sp, (float**)shbuffer, nprevl, nprevl, 0, 0, 0, 0, pW, pH, fw, fh, locutili, scale, locRETgainCurve, locallutili, lllocalcurve, loclhCurve, cclocalcurve, huere, chromare, lumare); huer = huere; @@ -2117,13 +2403,14 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) params.locallab.hueref = huer; params.locallab.chromaref = chromar; params.locallab.lumaref = lumar; - dataspot[58][sp] = huerefs[sp] = 100.f * params.locallab.hueref; - dataspot[59][sp] = chromarefs[sp] = params.locallab.chromaref; - dataspot[60][sp] = lumarefs[sp] = params.locallab.lumaref; + dataspot[64][sp] = huerefs[sp] = 100.f * params.locallab.hueref; + dataspot[65][sp] = chromarefs[sp] = params.locallab.chromaref; + dataspot[66][sp] = lumarefs[sp] = params.locallab.lumaref; //printf("sp=%i huerefsp=%f\n", sp, huerefs[sp]); ipf.Lab_Local (3, sp, (float**)shbuffer, nprevl, nprevl, 0, 0, 0, 0, pW, pH, fw, fh, locutili, scale, locRETgainCurve, locallutili, lllocalcurve, loclhCurve, lochhCurve, LHutili, HHutili, cclocalcurve, params.locallab.hueref, params.locallab.chromaref, params.locallab.lumaref); lllocalcurve.clear(); cclocalcurve.clear(); + sklocalcurve.clear(); } @@ -2137,7 +2424,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) if (aloListener && realspot != dataspot[16][0]) { //update GUI and MIP - aloListener->localChanged (dataspot, retistr[sp], llstr[sp], lhstr[sp], ccstr[sp], hhstr[sp], sp, maxreal); + aloListener->localChanged (dataspot, retistr[sp], llstr[sp], lhstr[sp], ccstr[sp], hhstr[sp], skinstr[sp], pthstr[sp], sp, maxreal); } @@ -2325,6 +2612,42 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) dataspot[57][sp] = 2; } + dataspot[58][sp] = sensivs[sp] = params.locallab.sensiv = dataspot[58][0]; + dataspot[59][sp] = pastels[sp] = params.locallab.pastels = dataspot[59][0]; + dataspot[60][sp] = saturateds[sp] = params.locallab.saturated = dataspot[60][0]; + + if (dataspot[61][0] == 0) { + params.locallab.protectskins = false; + dataspot[61][sp] = 0; + protectskinss[sp] = 0; + } else { + params.locallab.protectskins = true; + dataspot[61][sp] = 1; + protectskinss[sp] = 1; + } + + if (dataspot[62][0] == 0) { + params.locallab.avoidcolorshift = false; + dataspot[62][sp] = 0; + avoidcolorshifts[sp] = 0; + } else { + params.locallab.avoidcolorshift = true; + dataspot[62][sp] = 1; + avoidcolorshifts[sp] = 1; + } + + if (dataspot[63][0] == 0) { + params.locallab.pastsattog = false; + dataspot[63][sp] = 0; + pastsattogs[sp] = 0; + } else { + params.locallab.pastsattog = true; + dataspot[63][sp] = 1; + pastsattogs[sp] = 1; + } + + + int *s_datc; s_datc = new int[70]; int siz; @@ -2433,6 +2756,42 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) params.locallab.HHcurve = chhend; delete [] s_datchh; + + int *s_datcsk; + s_datcsk = new int[70]; + int sizsk; + + ipf.strcurv_data (skinstr[0], s_datcsk, sizsk); + sizeskintonecurves[sp] = sizsk; + std::vector cskend; + + skinstr[sp] = skinstr[0]; + + for (int j = 0; j < sizsk; j++) { + skintonescurves[sp * 500 + j] = s_datcsk[j]; + cskend.push_back ((double) (s_datcsk[j]) / 1000.); + + } + + params.locallab.skintonescurve.clear(); + params.locallab.skintonescurve = cskend; + + delete [] s_datcsk; + + + + //PSThreshold + 1 + int sizps = 2; + int s_datcps[sizps + 1]; + ipf.strcurv_data (pthstr[0], s_datcps, sizps); + + psthresholds[sp * 500] = s_datcps[0]; + psthresholds[sp * 500 + 1] = s_datcps[1]; + pthstr[sp] = pthstr[0]; + params.locallab.psthreshold.setValues (s_datcps[0], s_datcps[1]); + + //end local PS + LHutili = false; HHutili = false; @@ -2449,9 +2808,11 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) params.locallab.getCurves (locRETgainCurve, locRETgainCurverab, loclhCurve, lochhCurve, LHutili, HHutili); locallutili = false; localcutili = false; + localskutili = false; CurveFactory::curveLocal (locallutili, params.locallab.llcurve, lllocalcurve, sca); //scale == 1 ? 1 : 16); CurveFactory::curveCCLocal (localcutili, params.locallab.cccurve, cclocalcurve, sca); //scale == 1 ? 1 : 16); + CurveFactory::curveskLocal (localskutili, params.locallab.skintonescurve, sklocalcurve, sca); //scale == 1 ? 1 : 16); params.locallab.hueref = huerefs[sp] / 100.; params.locallab.chromaref = chromarefs[sp]; params.locallab.lumaref = lumarefs[sp]; @@ -2460,6 +2821,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) ipf.Lab_Local (3, sp, (float**)shbuffer, nprevl, nprevl, 0, 0, 0, 0, pW, pH, fw, fh, locutili, scale, locRETgainCurve, locallutili, lllocalcurve, loclhCurve, lochhCurve, LHutili, HHutili, cclocalcurve, params.locallab.hueref, params.locallab.chromaref, params.locallab.lumaref ); lllocalcurve.clear(); cclocalcurve.clear(); + sklocalcurve.clear(); ofstream fou (datal, ios::out | ios::trunc); @@ -2469,7 +2831,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) for (int spe = 1; spe < maxspot; spe++) { int t_sp = spe; - int t_mipversion = 10008; + int t_mipversion = 10009; int t_circrad = dataspot[2][spe]; int t_locX = dataspot[3][spe]; int t_locY = dataspot[4][spe]; @@ -2528,15 +2890,24 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) int t_curvactiv = dataspot[56][spe]; int t_qualitycurveMethod = dataspot[57][spe]; - int t_hueref = dataspot[58][spe]; - int t_chromaref = dataspot[59][spe]; - int t_lumaref = dataspot[60][spe]; + int t_sensiv = dataspot[58][spe]; + int t_pastel = dataspot[59][spe]; + int t_saturated = dataspot[60][spe]; + int t_proskin = dataspot[61][spe]; + int t_avoidcsh = dataspot[62][spe]; + int t_pastsat = dataspot[63][spe]; + + int t_hueref = dataspot[64][spe]; + int t_chromaref = dataspot[65][spe]; + int t_lumaref = dataspot[66][spe]; std::string t_curvret = retistr[spe]; std::string t_curvll = llstr[spe]; std::string t_curvlh = lhstr[spe]; std::string t_curvcc = ccstr[spe]; std::string t_curvhh = hhstr[spe]; + std::string t_curvskin = skinstr[spe]; + std::string t_psthres = pthstr[spe]; fou << "Mipversion=" << t_mipversion << '@' << endl; fou << "Spot=" << t_sp << '@' << endl; @@ -2599,14 +2970,23 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) fou << "Curvactiv=" << t_curvactiv << '@' << endl; fou << "qualitycurveMethod=" << t_qualitycurveMethod << '@' << endl; + fou << "Sensiv=" << t_sensiv << '@' << endl; + fou << "Pastel=" << t_pastel << '@' << endl; + fou << "Saturated=" << t_saturated << '@' << endl; + fou << "Proskin=" << t_proskin << '@' << endl; + fou << "Avoidcsh=" << t_avoidcsh << '@' << endl; + fou << "Pastsat=" << t_pastsat << '@' << 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 << "curveCC=" << t_curvcc << endl; - fou << "curveHH=" << t_curvhh << endl; + fou << "curveLL=" << t_curvll << endl; + fou << "curveLH=" << t_curvlh << endl; + fou << "curveCC=" << t_curvcc << endl; + fou << "curveHH=" << t_curvhh << endl; + fou << "curveskin=" << t_curvskin << endl; + fou << "pthres=" << t_psthres << endl; fou << endl; } @@ -2616,7 +2996,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) - for (int i = 0; i < 61; i++) { + for (int i = 0; i < 67; i++) { delete [] dataspot[i]; } @@ -2627,8 +3007,8 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) delete [] lhstr; delete [] ccstr; delete [] hhstr; - - + delete [] skinstr; + delete [] pthstr; // } } diff --git a/rtengine/improccoordinator.h b/rtengine/improccoordinator.h index 5b3023d95..c2c939465 100644 --- a/rtengine/improccoordinator.h +++ b/rtengine/improccoordinator.h @@ -112,6 +112,8 @@ protected: LUTf clToningcurve; LUTf lllocalcurve; LUTf cclocalcurve; + LUTf sklocalcurve; + LUTf cl2Toningcurve; LUTf Noisecurve; LUTf NoiseCCcurve; @@ -224,6 +226,7 @@ protected: bool wavcontlutili; bool locallutili; bool localcutili; + bool localskutili; bool LHutili; bool HHutili; @@ -233,6 +236,8 @@ protected: std::string *lhstr; std::string *ccstr; std::string *hhstr; + std::string *skinstr; + std::string *pthstr; LUTi circrads; LUTi centerx; @@ -283,7 +288,7 @@ protected: LUTi thresholds; LUTi sensicbs; LUTi activlums; - int versionmip; + int versionmip; LUTi strens; LUTi gammas; LUTi estops; @@ -304,6 +309,16 @@ protected: LUTi cccurvs; LUTi sizecccs; + LUTi sensivs; + LUTi saturateds; + LUTi pastels; + LUTi psthresholds; + LUTi protectskinss; + LUTi avoidcolorshifts; + LUTi pastsattogs; + LUTi skintonescurves; + LUTi sizeskintonecurves; + LUTf huerefs; LUTf chromarefs; LUTf lumarefs; diff --git a/rtengine/improcfun.cc b/rtengine/improcfun.cc index 1517c7255..849fb4986 100644 --- a/rtengine/improcfun.cc +++ b/rtengine/improcfun.cc @@ -5812,9 +5812,9 @@ SSEFUNCTION void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBu float l_r;//Luminance Lab in 0..1 l_r = Lprov1 / 100.f; { - //double hr = 0.5 * ((HH / rtengine::RT_PI) + 1.); + //double hr = 0.5 * ((HH / rtengine::RT_PI) + 1.); //float valparam = float ((lhCurve->getVal (hr - 0.5f)*2));//get l_r=f(H) - + float valparam = float ((lhCurve->getVal (Color::huelab_to_huehsv2 (HH)) - 0.5f)); //get l_r=f(H) float valparamneg; valparamneg = valparam; @@ -5877,9 +5877,9 @@ SSEFUNCTION void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBu // calculate C=f(H) if (chutili) { - double hr = Color::huelab_to_huehsv2 (HH); + double hr = Color::huelab_to_huehsv2 (HH); //double hr = 0.5 * ((HH / rtengine::RT_PI) + 1.); - + float chparam = float ((chCurve->getVal (hr) - 0.5f) * 2.0f); //get C=f(H) float chromaChfactor = 1.0f + chparam; atmp *= chromaChfactor;//apply C=f(H) @@ -5888,19 +5888,9 @@ SSEFUNCTION void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBu if (hhutili) { // H=f(H) //hue Lab in -PI +PI - double hr = 0.5 * ((HH / rtengine::RT_PI) + 1.); - - // float valparam = float ((hhCurve->getVal (Color::huelab_to_huehsv2 (HH)) - 0.5f) * 1.7f) + hr; //get H=f(H) 1.7 optimisation ! - float valparam = float ((hhCurve->getVal (hr - 0.5f)) * 2.) + hr; - - if (valparam > 1.0f) { - valparam -= 1.0f; - } else if ( valparam < 0.0f) { - valparam += 1.0f; - } - - float v = (2.f * valparam - 1.f) * rtengine::RT_PI; - sincosval = xsincosf (v); + float valparam = float ((hhCurve->getVal (Color::huelab_to_huehsv2 (HH)) - 0.5f) * 1.7f) + HH; //get H=f(H) 1.7 optimisation ! + HH = valparam; + sincosval = xsincosf (HH); } if (!bwToning) { diff --git a/rtengine/iplocallab.cc b/rtengine/iplocallab.cc index 991e11a6e..0af9e5295 100644 --- a/rtengine/iplocallab.cc +++ b/rtengine/iplocallab.cc @@ -2924,12 +2924,13 @@ void ImProcFunctions::ColorLight_Local (int call, LabImage * bufcolorig, float * original->b[y][x] = 0.01f; } - float eps = 0.f; - - if (fabs (original->b[y][x]) < 0.001f) { - eps = 0.01f; - } + /* + float eps = 0.f; + if (fabs (original->b[y][x]) < 0.001f) { + eps = 0.01f; + } + */ //retriev data curve lightness float cli = (buflight[loy - begy][lox - begx]); //parameters for linear interpolation in function of real hue @@ -2959,7 +2960,7 @@ void ImProcFunctions::ColorLight_Local (int call, LabImage * bufcolorig, float * float amoinsclighsl = (clisl - 1.f) / delhu; float bmoinsclighsl = 1.f - amoinsclighsl * huemoins; - float kab = (original->a[y][x] / (original->b[y][x] + eps)); + // float kab = (original->a[y][x] / (original->b[y][x] + eps)); //prepare shape detection // real... = coefficient to apply at lightness, chroma,... @@ -3356,8 +3357,6 @@ void ImProcFunctions::ColorLight_Local (int call, LabImage * bufcolorig, float * diflc *= factorx; //transition lightness transformed->L[y][x] = CLIPL (1.f * (original->L[y][x] + diflc)); - bool toty = false; - if (lochhCurve && lp.qualcurvemet >= 1 && HHutili) { @@ -3470,9 +3469,8 @@ void ImProcFunctions::ColorLight_Local (int call, LabImage * bufcolorig, float * kdiff *= fach * kch; diflc *= kdiff ; transformed->L[y][x] = CLIPL (1.f * (original->L[y][x] + diflc)); - float ka = 0.f, kb = 0.f; - float newchro = sqrt (SQR (original->a[y][x]) + SQR (original->b[y][x])); - bool toty = false; + + // float newchro = sqrt (SQR (original->a[y][x]) + SQR (original->b[y][x])); if (lochhCurve && lp.qualcurvemet >= 1 && HHutili) { float addh = 0.f; @@ -4216,7 +4214,7 @@ void ImProcFunctions::Lab_Local (int call, int sp, float** shbuffer, LabImage * if (!lp.inv && (lp.chro != 0 || lp.ligh != 0.f || lp.qualcurvemet != 0) && lp.colorena) { // || lllocalcurve)) { //interior ellipse renforced lightness and chroma //locallutili float hueplus = hueref + dhue; float huemoins = hueref - dhue; - float ddhue = 0.f; + // float ddhue = 0.f; //printf("hueplus=%f huemoins=%f dhu=%f\n", hueplus, huemoins, dhue); if (hueplus > rtengine::RT_PI) { @@ -4231,7 +4229,6 @@ void ImProcFunctions::Lab_Local (int call, int sp, float** shbuffer, LabImage * float chprov = 1.f; float chpro = 1.f; float cligh = 1.f; - float hhpro = 1.f; float clighL = 1.f; float clighmax ; float **buflight = nullptr; @@ -4385,94 +4382,12 @@ void ImProcFunctions::Lab_Local (int call, int sp, float** shbuffer, LabImage * } - bool tyty = false; - - // if(HHutili) printf("HHutili true\n"); if (lochhCurve && lp.qualcurvemet == 2 && HHutili) { - // printf("a"); - // if (tyty) { float hhforcurv = xatan2f (bufcolorig->b[loy - begy][lox - begx], bufcolorig->a[loy - begy][lox - begx]); float valparam = float ((lochhCurve[500.f * Color::huelab_to_huehsv2 (hhforcurv)] - 0.5f)); //get H=f(H) 1.7 optimisation ! float ddhue = CLIPRET (200.f * valparam); - - // float aa = bufcolorig->a[loy - begy][lox - begx]; - // float bb = bufcolorig->b[loy - begy][lox - begx]; - // float ll = bufcolorig->L[loy - begy][lox - begx]; - /* - TMatrix wiprof = ICCStore::getInstance()->workingSpaceInverseMatrix (params->icm.working); - TMatrix wprof = ICCStore::getInstance()->workingSpaceMatrix (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])} - }; - float wp[3][3] = { - {static_cast (wprof[0][0]), static_cast (wprof[0][1]), static_cast (wprof[0][2])}, - {static_cast (wprof[1][0]), static_cast (wprof[1][1]), static_cast (wprof[1][2])}, - {static_cast (wprof[2][0]), static_cast (wprof[2][1]), static_cast (wprof[2][2])} - }; - */ - /* - float X, Y, Z; - float r, g, b; - float hh, s, v; - Color::Lab2XYZ (ll, aa, bb, X, Y, Z); - Color::xyz2rgb (X, Y, Z, r, g, b, wip); - Color::rgb2hsv (r, g, b, hh, s, v); - */ - // float hr = 0.f; // = Color::huelab_to_huehsv2 (hhforcurv); - /* - if (hhforcurv >= 0.6f && hhforcurv < rtengine::RT_PI) { - hr = hhforcurv * 0.1652507f - 0.09915f;// hr 0 0.42 - } - - if (hhforcurv >= -rtengine::RT_PI && hhforcurv < 0.6f) { - hr = hhforcurv * 0.155014f + 0.90699f; - } - - - float valparam = float ((lochhCurve[500.f * (hr)] - 0.5f)); // + hr; //get H=f(H) - */ - ////////// float hh = 0.5 * ((hhforcurv / rtengine::RT_PI) + 1.); - // float hr = Color::huelab_to_huehsv2 (hhforcurv); - - // float valparam = float ((hhCurve->getVal (Color::huelab_to_huehsv2 (HH)) - 0.5f) * 1.7f) + hr; //get H=f(H) 1.7 optimisation ! - // float valparam = float ((hhCurve->getVal (hr - 0.5f))* 2.); //get H=f(H) 1.7 optimisation ! - /////////// float valparamdh = float ((lochhCurve[500.f * (hh)] - 0.5f) * 2); // + hr; //get H=f(H) - - //float hhhh = (2 * valparamdh - 1)* rtengine::RT_PI; - /* - if (valparamdh > 1.0f) { - valparamdh -= 1.0f; - } else if ( valparamdh < 0.0f) { - valparamdh += 1.0f; - } - */ - /* - float R, G, B; - float xx, yy, zz; - Color::hsv2rgb (valparamdh, s, v, R, G, B); - Color::rgbxyz (R, G, B, xx, yy, zz, wp); - float llf, aaf, bbf; - Color::XYZ2Lab (xx, yy, zz, llf, aaf, bbf); - float hhfin = xatan2f (bbf, aaf); - float hhresult = hhfin - hhforcurv; - */ - // float dh = valparam; - - /* - if (valparam < 0.42f) { - dh = 6.051411f * valparam + 0.6f; - } else { - dh = -4.38205629f * valparam + 4.98205629f; - } - - // float dh = Color::huehsv2_to_huelab (valparam); - */ - // float hhhh = (2 * valparamdh - 1)* rtengine::RT_PI; bufhh[loy - begy][lox - begx] = ddhue;//valparamdh; // } diff --git a/rtengine/procevents.h b/rtengine/procevents.h index 4b2ec94b8..ad595f91d 100644 --- a/rtengine/procevents.h +++ b/rtengine/procevents.h @@ -573,6 +573,16 @@ enum ProcEvent { Evlocallabchromaref = 543, Evlocallablumaref = 544, EvlocallabHHshape = 545, + EvLocenavibrance = 546, + EvlocallabSkinTonesCurve = 547, + EvlocallabProtectSkins = 548, + EvlocallabAvoidColorShift = 549, + EvlocallabPastSatTog = 550, + EvlocallabPastels = 551, + EvlocallabSaturated = 552, + EvlocallabPastSatThreshold = 553, + Evlocallabsensiv = 554, + NUMOFEVENTS diff --git a/rtengine/procparams.cc b/rtengine/procparams.cc index 85d35d800..698a6b560 100644 --- a/rtengine/procparams.cc +++ b/rtengine/procparams.cc @@ -954,6 +954,16 @@ void LocallabParams::setDefaults() lightness = 0; contrast = 0; chroma = 0; + pastels = 0; + saturated = 0; + psthreshold.setValues (0, 75); + protectskins = false; + avoidcolorshift = true; + pastsattog = true; + skintonescurve.clear (); + skintonescurve.push_back (DCT_Linear); + sensiv = 19; + noiselumf = 0; noiselumc = 0; noisechrof = 0; @@ -1000,6 +1010,7 @@ void LocallabParams::setDefaults() cccurve.clear (); cccurve.push_back (DCT_Linear); expcolor = false; + expvibrance = false; expblur = false; exptonemap = false; expreti = false; @@ -2747,6 +2758,10 @@ int ProcParams::save (const Glib::ustring &fname, const Glib::ustring &fname2, b keyFile.set_boolean ("Locallab", "Expcolor", locallab.expcolor); } + if (!pedited || pedited->locallab.expvibrance) { + keyFile.set_boolean ("Locallab", "Expvibrance", locallab.expvibrance); + } + if (!pedited || pedited->locallab.expblur) { keyFile.set_boolean ("Locallab", "Expblur", locallab.expblur); } @@ -2897,6 +2912,42 @@ int ProcParams::save (const Glib::ustring &fname, const Glib::ustring &fname2, b keyFile.set_integer ("Locallab", "Chroma", locallab.chroma); } + if (!pedited || pedited->locallab.pastels) { + keyFile.set_integer ("Locallab", "Pastels", locallab.pastels); + } + + if (!pedited || pedited->locallab.saturated) { + keyFile.set_integer ("Locallab", "Saturated", locallab.saturated); + } + + if (!pedited || pedited->locallab.psthreshold) { + Glib::ArrayHandle thresh (locallab.psthreshold.value, 2, Glib::OWNERSHIP_NONE); + keyFile.set_integer_list ("Locallab", "PSThreshold", thresh); + } + + if (!pedited || pedited->locallab.sensiv) { + keyFile.set_integer ("Locallab", "Sensiv", locallab.sensiv); + } + + if (!pedited || pedited->locallab.protectskins) { + keyFile.set_boolean ("Locallab", "ProtectSkins", locallab.protectskins); + } + + if (!pedited || pedited->locallab.avoidcolorshift) { + keyFile.set_boolean ("Locallab", "AvoidColorShift", locallab.avoidcolorshift); + } + + if (!pedited || pedited->locallab.pastsattog) { + keyFile.set_boolean ("Locallab", "PastSatTog", locallab.pastsattog); + } + + if (!pedited || pedited->locallab.skintonescurve) { + Glib::ArrayHandle skintonescurve = locallab.skintonescurve; + keyFile.set_double_list ("Locallab", "SkinTonesCurve", skintonescurve); + } + + + if (!pedited || pedited->locallab.noiselumf) { keyFile.set_integer ("Locallab", "noiselumf", locallab.noiselumf); } @@ -4404,6 +4455,14 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) } } + if (keyFile.has_key ("Locallab", "Expvibrance")) { + locallab.expvibrance = keyFile.get_boolean ("Locallab", "Expvibrance"); + + if (pedited) { + pedited->locallab.expvibrance = true; + } + } + if (keyFile.has_key ("Locallab", "Expblur")) { locallab.expblur = keyFile.get_boolean ("Locallab", "Expblur"); @@ -4896,6 +4955,73 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) } } + if (keyFile.has_key ("Locallab", "Sensiv")) { + locallab.sensiv = keyFile.get_integer ("Locallab", "Sensiv"); + + if (pedited) { + pedited->locallab.sensiv = true; + } + } + + if (keyFile.has_key ("Locallab", "Pastels")) { + locallab.pastels = keyFile.get_integer ("Locallab", "Pastels"); + + if (pedited) { + pedited->locallab.pastels = true; + } + } + + if (keyFile.has_key ("Locallab", "Saturated")) { + locallab.saturated = keyFile.get_integer ("Locallab", "Saturated"); + + if (pedited) { + pedited->locallab.saturated = true; + } + } + + if (keyFile.has_key ("Locallab", "PSThreshold")) { + Glib::ArrayHandle thresh = keyFile.get_integer_list ("Locallab", "PSThreshold"); + locallab.psthreshold.setValues (thresh.data()[0], thresh.data()[1]); + + + if (pedited) { + pedited->locallab.psthreshold = true; + } + } + + if (keyFile.has_key ("Locallab", "ProtectSkins")) { + locallab.protectskins = keyFile.get_boolean ("Locallab", "ProtectSkins"); + + if (pedited) { + pedited->locallab.protectskins = true; + } + } + + if (keyFile.has_key ("Locallab", "AvoidColorShift")) { + locallab.avoidcolorshift = keyFile.get_boolean ("Locallab", "AvoidColorShift"); + + if (pedited) { + pedited->locallab.avoidcolorshift = true; + } + } + + if (keyFile.has_key ("Locallab", "PastSatTog")) { + locallab.pastsattog = keyFile.get_boolean ("Locallab", "PastSatTog"); + + if (pedited) { + pedited->locallab.pastsattog = true; + } + } + + if (keyFile.has_key ("Locallab", "SkinTonesCurve")) { + locallab.skintonescurve = keyFile.get_double_list ("Locallab", "SkinTonesCurve"); + + if (pedited) { + pedited->locallab.skintonescurve = true; + } + } + + //IND if (keyFile.has_key ("Locallab", "Radius")) { locallab.radius = keyFile.get_integer ("Locallab", "Radius"); @@ -9424,6 +9550,14 @@ bool ProcParams::operator== (const ProcParams& other) && locallab.lightness == other.locallab.lightness && locallab.contrast == other.locallab.contrast && locallab.chroma == other.locallab.chroma + && locallab.pastels == other.locallab.pastels + && locallab.sensiv == other.locallab.sensiv + && locallab.saturated == other.locallab.saturated + && locallab.psthreshold == other.locallab.psthreshold + && locallab.protectskins == other.locallab.protectskins + && locallab.avoidcolorshift == other.locallab.avoidcolorshift + && locallab.pastsattog == other.locallab.pastsattog + && locallab.skintonescurve == other.locallab.skintonescurve && locallab.noiselumf == other.locallab.noiselumf && locallab.noiselumc == other.locallab.noiselumc && locallab.noisechrof == other.locallab.noisechrof @@ -9458,6 +9592,7 @@ bool ProcParams::operator== (const ProcParams& other) && locallab.vart == other.locallab.vart && locallab.threshold == other.locallab.threshold && locallab.expcolor == other.locallab.expcolor + && locallab.expvibrance == other.locallab.expvibrance && locallab.expblur == other.locallab.expblur && locallab.exptonemap == other.locallab.exptonemap && locallab.expreti == other.locallab.expreti diff --git a/rtengine/procparams.h b/rtengine/procparams.h index eb5a18728..25db1065a 100644 --- a/rtengine/procparams.h +++ b/rtengine/procparams.h @@ -879,6 +879,7 @@ public: Glib::ustring qualityMethod; Glib::ustring qualitycurveMethod; bool expcolor; + bool expvibrance; bool expblur; bool exptonemap; bool expreti; @@ -889,6 +890,16 @@ public: int lightness; int contrast; int chroma; + + int pastels; + int saturated; + Threshold psthreshold; + bool protectskins; + bool avoidcolorshift; + bool pastsattog; + std::vector skintonescurve; + int sensiv; + int sharradius; int sharamount; int shardamping; @@ -941,7 +952,7 @@ public: double mult[5]; double threshold; - LocallabParams () + LocallabParams (): psthreshold (0, 75, false) { setDefaults(); } diff --git a/rtengine/refreshmap.cc b/rtengine/refreshmap.cc index 9f97a2b9f..c3a96d217 100644 --- a/rtengine/refreshmap.cc +++ b/rtengine/refreshmap.cc @@ -572,7 +572,17 @@ int refreshmap[rtengine::NUMOFEVENTS] = { LUMINANCECURVE, // Evlocallabhueref LUMINANCECURVE, // Evlocallabchromaref LUMINANCECURVE, // Evlocallablumaref - LUMINANCECURVE // EvlocallabHHshape - + LUMINANCECURVE, // EvlocallabHHshape + LUMINANCECURVE, // Evlocenavibrance + LUMINANCECURVE, //EvlocallabSkinTonesCurve + LUMINANCECURVE, //EvlocallabProtectSkins + LUMINANCECURVE, //EvlocallabAvoidColorShift + LUMINANCECURVE, //EvlocallabPastSatTog + LUMINANCECURVE, //EvlocallabPastels + LUMINANCECURVE, //EvlocallabSaturated + LUMINANCECURVE, // EvlocallabPastSatThreshold + LUMINANCECURVE //Evlocallabsensiv + + }; diff --git a/rtengine/rtengine.h b/rtengine/rtengine.h index d56bfe6f8..4395e5cbd 100644 --- a/rtengine/rtengine.h +++ b/rtengine/rtengine.h @@ -315,8 +315,8 @@ class localListener { public : virtual ~localListener() {} - virtual void localChanged (int **datasp, std::string datastr, std::string ll_str, std::string lh_str, std::string cc_str, std::string hh_str, int sp, int maxdat) {} - virtual void localretChanged (int **datasp, std::string datastr, std::string ll_str, std::string lh_str, std::string cc_str, std::string hh_str, int sp, int maxdat) {} + virtual void localChanged (int **datasp, std::string datastr, std::string ll_str, std::string lh_str, std::string cc_str, std::string hh_str, std::string sk_str, std::string ps_str, int sp, int maxdat) {} + virtual void localretChanged (int **datasp, std::string datastr, std::string ll_str, std::string lh_str, std::string cc_str, std::string hh_str, std::string sk_str, std::string ps_str, int sp, int maxdat) {} }; diff --git a/rtengine/simpleprocess.cc b/rtengine/simpleprocess.cc index 4350b6592..ce019ec12 100644 --- a/rtengine/simpleprocess.cc +++ b/rtengine/simpleprocess.cc @@ -33,6 +33,7 @@ #include #include #include "../rtgui/md5helper.h" +#include "../rtgui/thresholdselector.h" #undef THREAD_PRIORITY_NORMAL @@ -1045,6 +1046,7 @@ private: LocretigainCurverab locRETgainCurverab; LUTf lllocalcurve (65536, 0); LUTf cclocalcurve (65536, 0); + LUTf sklocalcurve (65536, 0); // int realspot = params.locallab.nbspot; int maxspot = settings->nspot + 1; @@ -1096,9 +1098,9 @@ private: std::string inser; int **dataspots; - dataspots = new int*[61]; + dataspots = new int*[67]; - for (int i = 0; i < 61; i++) { + for (int i = 0; i < 67; i++) { dataspots[i] = new int[maxspot]; } @@ -1118,6 +1120,12 @@ private: std::string *hhstrs; hhstrs = new std::string[maxspot]; + std::string *skinstrs; + skinstrs = new std::string[maxspot]; + + std::string *pthstrs; + pthstrs = new std::string[maxspot]; + { dataspots[2][0] = params.locallab.circrad; dataspots[3][0] = params.locallab.locX; @@ -1243,9 +1251,31 @@ private: dataspots[57][0] = 2; } - dataspots[58][0] = 100.f * params.locallab.hueref; - dataspots[59][0] = params.locallab.chromaref; - dataspots[60][0] = params.locallab.lumaref; + dataspots[58][0] = params.locallab.sensiv; + dataspots[59][0] = params.locallab.pastels; + dataspots[60][0] = params.locallab.saturated; + + if (!params.locallab.protectskins) { + dataspots[61][0] = 0; + } else { + dataspots[61][0] = 1; + } + + if (!params.locallab.avoidcolorshift) { + dataspots[62][0] = 0; + } else { + dataspots[62][0] = 1; + } + + if (!params.locallab.pastsattog) { + dataspots[63][0] = 0; + } else { + dataspots[63][0] = 1; + } + + dataspots[64][0] = 100.f * params.locallab.hueref; + dataspots[65][0] = params.locallab.chromaref; + dataspots[66][0] = params.locallab.lumaref; //curve Reti local int siz = params.locallab.localTgaincurve.size(); @@ -1356,6 +1386,46 @@ private: hhstrs[0] = hh_str + "@"; + //Skin curve + int sizsk = params.locallab.skintonescurve.size(); + + if (sizsk > 69) { + sizsk = 69;//to avoid crash + } + + + int s_datcursk[sizsk + 1]; + + for (int j = 0; j < sizsk; j++) { + s_datcursk[j] = (int) (1000. * params.locallab.skintonescurve[j]); + } + + std::string sk_str = ""; + + for (int j = 0; j < sizsk; j++) { + sk_str = sk_str + std::to_string (s_datcursk[j]) + delim[j]; + } + + skinstrs[0] = sk_str + "@"; + + //end local skin + //PSThreshold + int sizps = 2; + int s_datps[sizps + 1]; + s_datps[1] = static_cast (params.locallab.psthreshold.value[ThresholdSelector::TS_TOPLEFT]); + + s_datps[0] = static_cast (params.locallab.psthreshold.value[ThresholdSelector::TS_BOTTOMLEFT]); + + std::string ps_str = ""; + + for (int j = 0; j < sizps; j++) { + ps_str = ps_str + std::to_string (s_datps[j]) + delim[j]; + } + + pthstrs[0] = ps_str + "@"; + + //end local ps + } // locallutili = false; @@ -1404,7 +1474,7 @@ private: dataspots[16][0] = std::stoi (str3.c_str()); } - if (cont > 16 && cont < 61) { + if (cont > 16 && cont < 67) { dataspots[cont][ns] = std::stoi (str3.c_str()); } @@ -1495,6 +1565,39 @@ private: // sizecc = longec; } + if (spotline.substr (0, pos) == "curveskin") { + std::string curstskin; + // int longecurh; + std::string strendsk = spotline.substr (posend - 1, 1); + // std::size_t poszh = spotline.find (strendh); + // int longeh; + + for (int sh = 0; sh < 69; sh++) { + if (delim[sh] == strendsk) { + // longeh = sh + 1; + } + } + + skinstrs[ns] = str3; + // sizelh = longeh; + } + + if (spotline.substr (0, pos) == "pthres") { + std::string curstpth; + // int longecurh; + std::string strendpt = spotline.substr (posend - 1, 1); + // std::size_t poszh = spotline.find (strendh); + // int longeh; + + for (int sh = 0; sh < 69; sh++) { + if (delim[sh] == strendpt) { + // longeh = sh + 1; + } + } + + pthstrs[ns] = str3; + } + } fich.close(); @@ -1629,9 +1732,32 @@ private: params.locallab.qualitycurveMethod = "enh" ; } - params.locallab.hueref = ((float) dataspots[58][sp]) / 100.f; - params.locallab.chromaref = dataspots[59][sp]; - params.locallab.lumaref = dataspots[60][sp]; + + params.locallab.sensiv = dataspots[58][sp]; + params.locallab.pastels = dataspots[59][sp]; + params.locallab.saturated = dataspots[60][sp]; + + if (dataspots[61][sp] == 0) { + params.locallab.protectskins = false; + } else { + params.locallab.protectskins = true; + } + + if (dataspots[62][sp] == 0) { + params.locallab.avoidcolorshift = false; + } else { + params.locallab.avoidcolorshift = true; + } + + if (dataspots[63][sp] == 0) { + params.locallab.pastsattog = false; + } else { + params.locallab.pastsattog = true; + } + + params.locallab.hueref = ((float) dataspots[64][sp]) / 100.f; + params.locallab.chromaref = dataspots[65][sp]; + params.locallab.lumaref = dataspots[66][sp]; int *s_datc; @@ -1703,17 +1829,43 @@ private: chhend.push_back ((double) (s_datchh[j]) / 1000.); } + delete [] s_datchh; + + int *s_datcsk; + s_datcsk = new int[70]; + int sizsk; + + ipf.strcurv_data (skinstrs[sp], s_datcsk, sizsk); + + + std::vector cskend; + + for (int j = 0; j < sizsk; j++) { + cskend.push_back ((double) (s_datcsk[j]) / 1000.); + } + + delete [] s_datcsk; + + //PSThreshold + 1 + int sizps = 2; + int s_datcps[sizps + 1]; + ipf.strcurv_data (pthstrs[sp], s_datcps, sizps); + + params.locallab.psthreshold.setValues (s_datcps[0], s_datcps[1]); + params.locallab.localTgaincurve.clear(); params.locallab.llcurve.clear(); params.locallab.LHcurve.clear(); params.locallab.cccurve.clear(); params.locallab.HHcurve.clear(); + params.locallab.skintonescurve.clear(); params.locallab.localTgaincurve = cretiend; params.locallab.llcurve = cllend; params.locallab.LHcurve = clhend; params.locallab.cccurve = cccend; params.locallab.HHcurve = chhend; + params.locallab.skintonescurve = cskend; bool LHutili = false; bool HHutili = false; @@ -1731,9 +1883,12 @@ private: params.locallab.getCurves (locRETgainCurve, locRETgainCurverab, loclhCurve, lochhCurve, LHutili, HHutili); bool locallutili = false; bool localcutili = false; + bool localskutili = false; CurveFactory::curveLocal (locallutili, params.locallab.llcurve, lllocalcurve, 1); CurveFactory::curveCCLocal (localcutili, params.locallab.cccurve, cclocalcurve, 1); + CurveFactory::curveskLocal (localskutili, params.locallab.skintonescurve, sklocalcurve, 1); + double huere, chromare, lumare; ipf.calc_ref (2, sp, (float**)shbuffer, labView, labView, 0, 0, 0, 0, fw, fh, fw, fh, locutili, 1, locRETgainCurve, locallutili, lllocalcurve, loclhCurve, cclocalcurve, huere, chromare, lumare); @@ -1744,6 +1899,7 @@ private: ipf.Lab_Local (2, sp, (float**)shbuffer, labView, labView, 0, 0, 0, 0, fw, fh, fw, fh, locutili, 1, locRETgainCurve, locallutili, lllocalcurve, loclhCurve, lochhCurve, LHutili, HHutili, cclocalcurve, params.locallab.hueref, params.locallab.chromaref, params.locallab.lumaref); lllocalcurve.clear(); cclocalcurve.clear(); + sklocalcurve.clear(); } diff --git a/rtgui/locallab.cc b/rtgui/locallab.cc index 3973001af..5f8d8ec4f 100644 --- a/rtgui/locallab.cc +++ b/rtgui/locallab.cc @@ -41,6 +41,7 @@ Locallab::Locallab (): FoldableToolPanel (this, "locallab", M ("TP_LOCALLAB_LABEL"), false, true), EditSubscriber (ET_OBJECTS), lastObject (-1), expcolor (new MyExpander (true, M ("TP_LOCALLAB_COFR"))), + expvibrance (new MyExpander (true, M ("TP_LOCALLAB_VIBRANCE"))), expblur (new MyExpander (true, M ("TP_LOCALLAB_BLUFR"))), exptonemap (new MyExpander (true, M ("TP_LOCALLAB_TM"))), expreti (new MyExpander (true, M ("TP_LOCALLAB_RETI"))), @@ -180,6 +181,9 @@ Locallab::Locallab (): 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) ); + expvibrance->signal_button_release_event().connect_notify ( sigc::bind ( sigc::mem_fun (this, &Locallab::foldAllButMe), expvibrance) ); + enablevibranceConn = expvibrance->signal_enabled_toggled().connect ( sigc::bind ( sigc::mem_fun (this, &Locallab::enableToggled), expvibrance) ); + 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) ); @@ -302,7 +306,7 @@ Locallab::Locallab (): LHshape->setBottomBarBgGradient (milestones); rtengine::LocallabParams::getDefaultHHCurve (defaultCurve5); - + HHshape = static_cast (llCurveEditorG->addCurve (CT_Flat, "H(H)", nullptr, false, true)); HHshape->setIdentityValue (0.); @@ -320,7 +324,7 @@ Locallab::Locallab (): } HHshape->setBottomBarBgGradient (milestones); - + llCurveEditorG->curveListComplete(); @@ -601,6 +605,76 @@ Locallab::Locallab (): expcolor->add (*colorBox); expcolor->setLevel (2); pack_start (*expcolor); + + + ToolParamBlock* const vibranceBox = Gtk::manage (new ToolParamBlock()); + std::vector milestonesvib; + float R, G, B; + // -0.1 rad < Hue < 1.6 rad + Color::hsv2rgb01 (0.92f, 0.45f, 0.6f, R, G, B); + milestonesvib.push_back ( GradientMilestone (0.0, double (R), double (G), double (B)) ); + Color::hsv2rgb01 (0.14056f, 0.45f, 0.6f, R, G, B); + milestonesvib.push_back ( GradientMilestone (1.0, double (R), double (G), double (B)) ); + + saturated = Gtk::manage (new Adjuster (M ("TP_VIBRANCE_SATURATED"), -100., 100., 1., 0.)); + saturated->setAdjusterListener (this); + saturated->set_sensitive (false); + vibranceBox->pack_start ( *saturated, Gtk::PACK_SHRINK, 0); + + pastels = Gtk::manage (new Adjuster (M ("TP_VIBRANCE_PASTELS"), -100., 100., 1., 0.)); + pastels->setAdjusterListener (this); + vibranceBox->pack_start ( *pastels, Gtk::PACK_SHRINK, 0); + + psThreshold = Gtk::manage (new ThresholdAdjuster (M ("TP_VIBRANCE_PSTHRESHOLD"), -100., 100., 0., M ("TP_VIBRANCE_PSTHRESHOLD_WEIGTHING"), 0, 0., 100., 75., M ("TP_VIBRANCE_PSTHRESHOLD_SATTHRESH"), 0, this, false)); + psThreshold->setAdjusterListener (this); + psThreshold->set_tooltip_markup (M ("TP_VIBRANCE_PSTHRESHOLD_TOOLTIP")); + psThreshold->set_sensitive (false); + vibranceBox->pack_start ( *psThreshold, Gtk::PACK_SHRINK, 0); + + protectSkins = Gtk::manage (new Gtk::CheckButton (M ("TP_VIBRANCE_PROTECTSKINS"))); + protectSkins->set_active (true); + vibranceBox->pack_start (*protectSkins, Gtk::PACK_SHRINK, 0); + + avoidColorShift = Gtk::manage (new Gtk::CheckButton (M ("TP_VIBRANCE_AVOIDCOLORSHIFT"))); + avoidColorShift->set_active (true); + vibranceBox->pack_start (*avoidColorShift, Gtk::PACK_SHRINK, 0); + + pastSatTog = Gtk::manage (new Gtk::CheckButton (M ("TP_VIBRANCE_PASTSATTOG"))); + pastSatTog->set_active (true); + vibranceBox->pack_start (*pastSatTog, Gtk::PACK_SHRINK, 0); + + sensiv = Gtk::manage (new Adjuster (M ("TP_LOCALLAB_SENSI"), 0, 100, 1, 19)); + sensiv->setAdjusterListener (this); + + vibranceBox->pack_start (*sensiv, Gtk::PACK_SHRINK, 0); + + curveEditorGG = new CurveEditorGroup (options.lastlocalCurvesDir, M ("TP_VIBRANCE_CURVEEDITOR_SKINTONES_LABEL")); + curveEditorGG->setCurveListener (this); + + skinTonesCurve = static_cast (curveEditorGG->addCurve (CT_Diagonal, M ("TP_VIBRANCE_CURVEEDITOR_SKINTONES"))); + skinTonesCurve->setTooltip (M ("TP_VIBRANCE_CURVEEDITOR_SKINTONES_TOOLTIP")); + skinTonesCurve->setBottomBarBgGradient (milestonesvib); + skinTonesCurve->setLeftBarBgGradient (milestonesvib); + skinTonesCurve->setRangeLabels ( + M ("TP_VIBRANCE_CURVEEDITOR_SKINTONES_RANGE1"), M ("TP_VIBRANCE_CURVEEDITOR_SKINTONES_RANGE2"), + M ("TP_VIBRANCE_CURVEEDITOR_SKINTONES_RANGE3"), M ("TP_VIBRANCE_CURVEEDITOR_SKINTONES_RANGE4") + ); + skinTonesCurve->setRangeDefaultMilestones (0.1, 0.4, 0.85); + curveEditorGG->curveListComplete(); + + vibranceBox->pack_start (*curveEditorGG, Gtk::PACK_SHRINK, 4); + + pskinsconn = protectSkins->signal_toggled().connect ( sigc::mem_fun (*this, &Locallab::protectskins_toggled) ); + ashiftconn = avoidColorShift->signal_toggled().connect ( sigc::mem_fun (*this, &Locallab::avoidcolorshift_toggled) ); + pastsattogconn = pastSatTog->signal_toggled().connect ( sigc::mem_fun (*this, &Locallab::pastsattog_toggled) ); + + expvibrance->add (*vibranceBox); + expvibrance->setLevel (2); + pack_start (*expvibrance); + + + + ToolParamBlock* const blurrBox = Gtk::manage (new ToolParamBlock()); blurrBox->pack_start (*radius); @@ -938,6 +1012,7 @@ void Locallab::foldAllButMe (GdkEventButton* event, MyExpander *expander) if (event->button == 3) { expsettings->set_expanded (expsettings == expander); expcolor->set_expanded (expcolor == expander); + expvibrance->set_expanded (expvibrance == expander); expblur->set_expanded (expblur == expander); exptonemap->set_expanded (exptonemap == expander); expreti->set_expanded (expreti == expander); @@ -955,6 +1030,8 @@ void Locallab::enableToggled (MyExpander *expander) if (expander == expcolor) { event = EvLocenacolor; + } else if (expander == expvibrance) { + event = EvLocenavibrance; } else if (expander == expblur) { event = EvLocenablur; } else if (expander == exptonemap) { @@ -986,6 +1063,7 @@ void Locallab::writeOptions (std::vector &tpOpen) { tpOpen.push_back (expsettings->get_expanded ()); tpOpen.push_back (expcolor->get_expanded ()); + tpOpen.push_back (expvibrance->get_expanded ()); tpOpen.push_back (expblur->get_expanded ()); tpOpen.push_back (exptonemap->get_expanded ()); tpOpen.push_back (expreti->get_expanded ()); @@ -997,15 +1075,16 @@ void Locallab::writeOptions (std::vector &tpOpen) void Locallab::updateToolState (std::vector &tpOpen) { - if (tpOpen.size() == 8) { + if (tpOpen.size() == 9) { expsettings->set_expanded (tpOpen.at (0)); expcolor->set_expanded (tpOpen.at (1)); - expblur->set_expanded (tpOpen.at (2)); - exptonemap->set_expanded (tpOpen.at (3)); - expreti->set_expanded (tpOpen.at (4)); - expsharp->set_expanded (tpOpen.at (5)); - expcbdl->set_expanded (tpOpen.at (6)); - expdenoi->set_expanded (tpOpen.at (7)); + expvibrance->set_expanded (tpOpen.at (2)); + expblur->set_expanded (tpOpen.at (3)); + exptonemap->set_expanded (tpOpen.at (4)); + expreti->set_expanded (tpOpen.at (5)); + expsharp->set_expanded (tpOpen.at (6)); + expcbdl->set_expanded (tpOpen.at (7)); + expdenoi->set_expanded (tpOpen.at (8)); } } @@ -1214,7 +1293,28 @@ bool Locallab::localretComputed_ () delete [] s_datchh; HHshape->setCurve (chh); - + + //skinTonesCurve + int *s_datcsk; + s_datcsk = new int[70]; + int sizsk; + ImProcFunctions::strcurv_data (nextsk_str2, s_datcsk, sizsk); + std::vector csk; + + for (int j = 0; j < sizsk; j++) { + csk.push_back ((double) (s_datcsk[j]) / 1000.); + } + + delete [] s_datcsk; + + skinTonesCurve->setCurve (csk); + + //PSthreshold + int sizps = 2; + int s_datcps[sizps + 1]; + ImProcFunctions::strcurv_data (nextps_str2, s_datcps, sizps); + psThreshold->setValue (s_datcps[0], s_datcps[1]); + enableListener (); //update all sliders by this strange process! @@ -1288,7 +1388,16 @@ bool Locallab::localretComputed_ () if (listener) {//for curve listener->panelChanged (EvlocallabHHshape, M ("")); } - + + if (listener) {//for curve + listener->panelChanged (EvlocallabSkinTonesCurve, M ("")); + } + + if (listener) {//for PSthreshold + listener->panelChanged (EvlocallabPastSatThreshold, M ("")); + } + + return false; } @@ -1441,10 +1550,35 @@ bool Locallab::localComputed_ () qualitycurveMethod->set_active (2); } - double intermed = 0.01 * (double) nextdatasp[58]; + sensiv->setValue (nextdatasp[58]); + pastels->setValue (nextdatasp[59]); + saturated->setValue (nextdatasp[60]); + + //protectskin + if (nextdatasp[61] == 0) { + protectSkins->set_active (false); + } else { + protectSkins->set_active (true); + } + + //avoidColorShift + if (nextdatasp[62] == 0) { + avoidColorShift->set_active (false); + } else { + avoidColorShift->set_active (true); + } + + //pastSatTog + if (nextdatasp[63] == 0) { + pastSatTog->set_active (false); + } else { + pastSatTog->set_active (true); + } + + double intermed = 0.01 * (double) nextdatasp[64]; hueref->setValue (intermed); - chromaref->setValue (nextdatasp[59]); - lumaref->setValue (nextdatasp[60]); + chromaref->setValue (nextdatasp[65]); + lumaref->setValue (nextdatasp[66]); int *s_datc; s_datc = new int[70]; @@ -1526,9 +1660,27 @@ bool Locallab::localComputed_ () delete [] s_datchh; HHshape->setCurve (chh); - - // usleep(10000); + //skinTonesCurve + int *s_datcsk; + s_datcsk = new int[70]; + int sizsk; + ImProcFunctions::strcurv_data (nextsk_str, s_datcsk, sizsk); + std::vector csk; + + for (int j = 0; j < sizsk; j++) { + csk.push_back ((double) (s_datcsk[j]) / 1000.); + } + + delete [] s_datcsk; + + skinTonesCurve->setCurve (csk); + + //PSthreshold + int sizps = 2; + int s_datcps[sizps + 1]; + ImProcFunctions::strcurv_data (nextps_str, s_datcps, sizps); + psThreshold->setValue (s_datcps[0], s_datcps[1]); enableListener (); @@ -1644,13 +1796,34 @@ bool Locallab::localComputed_ () if (listener) {//for curve LH listener->panelChanged (EvlocallabHHshape, M ("")); } - + + if (listener) {//for curve Skin + listener->panelChanged (EvlocallabSkinTonesCurve, M ("")); + } + + if (listener) {//for PSthreshold + listener->panelChanged (EvlocallabPastSatThreshold, M ("")); + } + + //for checkbox + if (listener) {//for PSthreshold + listener->panelChanged (EvlocallabProtectSkins, M ("")); + } + + if (listener) {//for PSthreshold + listener->panelChanged (EvlocallabAvoidColorShift, M ("")); + } + + if (listener) {//for PSthreshold + listener->panelChanged (EvlocallabPastSatTog, M ("")); + } + return false; } -void Locallab::localChanged (int **datasp, std::string datastr, std::string ll_str, std::string lh_str, std::string cc_str, std::string hh_str, int sp, int maxdat) +void Locallab::localChanged (int **datasp, std::string datastr, std::string ll_str, std::string lh_str, std::string cc_str, std::string hh_str, std::string sk_str, std::string ps_str, int sp, int maxdat) { - for (int i = 2; i < 61; i++) { + for (int i = 2; i < 67; i++) { nextdatasp[i] = datasp[i][sp]; } @@ -1659,12 +1832,14 @@ void Locallab::localChanged (int **datasp, std::string datastr, std::string ll_ nextlh_str = lh_str; nextcc_str = cc_str; nexthh_str = hh_str; + nextsk_str = sk_str; + nextps_str = ps_str; nextlength = maxdat; g_idle_add (localChangedUI, this); } -void Locallab::localretChanged (int **datasp, std::string datastr, std::string ll_str, std::string lh_str, std::string cc_str, std::string hh_str, int sp, int maxdat) +void Locallab::localretChanged (int **datasp, std::string datastr, std::string ll_str, std::string lh_str, std::string cc_str, std::string hh_str, std::string sk_str, std::string ps_str, int sp, int maxdat) { nextlength = maxdat; nextstr2 = datastr; @@ -1672,6 +1847,8 @@ void Locallab::localretChanged (int **datasp, std::string datastr, std::string nextlh_str2 = lh_str; nextcc_str2 = cc_str; nexthh_str2 = hh_str; + nextsk_str2 = sk_str; + nextps_str2 = ps_str; g_idle_add (localretChangedUI, this); } @@ -1686,6 +1863,7 @@ void Locallab::read (const ProcParams* pp, const ParamsEdited* pedited) disableListener (); enablecolorConn.block (true); + enablevibranceConn.block (true); enableblurConn.block (true); enabletonemapConn.block (true); enableretiConn.block (true); @@ -1718,6 +1896,15 @@ void Locallab::read (const ProcParams* pp, const ParamsEdited* pedited) noisechrof->setEditedState (pedited->locallab.noisechrof ? Edited : UnEdited); noisechroc->setEditedState (pedited->locallab.noisechroc ? Edited : UnEdited); + pastels->setEditedState (pedited->locallab.pastels ? Edited : UnEdited); + saturated->setEditedState (pedited->locallab.saturated ? Edited : UnEdited); + psThreshold->setEditedState (pedited->locallab.psthreshold ? Edited : UnEdited); + protectSkins->set_inconsistent (!pedited->locallab.protectskins); + avoidColorShift->set_inconsistent (!pedited->locallab.avoidcolorshift); + pastSatTog->set_inconsistent (!pedited->locallab.pastsattog); + skinTonesCurve->setUnChanged (!pedited->locallab.skintonescurve); + sensiv->setEditedState (pedited->locallab.sensiv ? Edited : UnEdited); + for (int i = 0; i < 5; i++) { multiplier[i]->setEditedState (pedited->locallab.mult[i] ? Edited : UnEdited); } @@ -1763,6 +1950,7 @@ void Locallab::read (const ProcParams* pp, const ParamsEdited* pedited) inversret->set_inconsistent (multiImage && !pedited->locallab.inversret); cTgainshaperab->setUnChanged (!pedited->locallab.localTgaincurverab); expcolor->set_inconsistent (!pedited->locallab.expcolor); + expvibrance->set_inconsistent (!pedited->locallab.expvibrance); expblur->set_inconsistent (!pedited->locallab.expblur); exptonemap->set_inconsistent (!pedited->locallab.exptonemap); expreti->set_inconsistent (!pedited->locallab.expreti); @@ -1871,6 +2059,43 @@ void Locallab::read (const ProcParams* pp, const ParamsEdited* pedited) noisechrof->setValue (pp->locallab.noisechrof); noisechroc->setValue (pp->locallab.noisechroc); expcolor->setEnabled (pp->locallab.expcolor); + expvibrance->setEnabled (pp->locallab.expvibrance); + sensiv->setValue (pp->locallab.sensiv); + + pskinsconn.block (true); + protectSkins->set_active (pp->locallab.protectskins); + pskinsconn.block (false); + lastProtectSkins = pp->locallab.protectskins; + + ashiftconn.block (true); + avoidColorShift->set_active (pp->locallab.avoidcolorshift); + ashiftconn.block (false); + lastAvoidColorShift = pp->locallab.avoidcolorshift; + + pastsattogconn.block (true); + pastSatTog->set_active (pp->locallab.pastsattog); + pastsattogconn.block (false); + lastPastSatTog = pp->locallab.pastsattog; + + pastels->setValue (pp->locallab.pastels); + psThreshold->setValue (pp->locallab.psthreshold); + + if (lastPastSatTog) { + // Link both slider, so we set saturated and psThresholds unsensitive + psThreshold->set_sensitive (false); + saturated->set_sensitive (false); + saturated->setValue (pp->locallab.pastels); // Pastels and Saturated are linked + } else { + // Separate sliders, so we set saturated and psThresholds sensitive again + psThreshold->set_sensitive (true); + saturated->set_sensitive (true); + saturated->setValue (pp->locallab.saturated); // Pastels and Saturated are separate + } + + skinTonesCurve->setCurve (pp->locallab.skintonescurve); + + + expblur->setEnabled (pp->locallab.expblur); exptonemap->setEnabled (pp->locallab.exptonemap); expreti->setEnabled (pp->locallab.expreti); @@ -1966,6 +2191,7 @@ void Locallab::read (const ProcParams* pp, const ParamsEdited* pedited) } enablecolorConn.block (false); + enablevibranceConn.block (false); enableblurConn.block (false); enabletonemapConn.block (false); enableretiConn.block (false); @@ -2252,6 +2478,7 @@ void Locallab::write (ProcParams* pp, ParamsEdited* pedited) pp->locallab.LHcurve = LHshape->getCurve (); pp->locallab.HHcurve = HHshape->getCurve (); pp->locallab.expcolor = expcolor->getEnabled(); + pp->locallab.expvibrance = expvibrance->getEnabled(); pp->locallab.expblur = expblur->getEnabled(); pp->locallab.exptonemap = exptonemap->getEnabled(); pp->locallab.expreti = expreti->getEnabled(); @@ -2265,6 +2492,16 @@ void Locallab::write (ProcParams* pp, ParamsEdited* pedited) pp->locallab.threshold = threshold->getIntValue(); + pp->locallab.pastels = pastels->getIntValue(); + pp->locallab.saturated = pastSatTog->get_active() ? pp->locallab.pastels : saturated->getIntValue (); + pp->locallab.psthreshold = psThreshold->getValue (); + pp->locallab.protectskins = protectSkins->get_active (); + pp->locallab.avoidcolorshift = avoidColorShift->get_active (); + pp->locallab.pastsattog = pastSatTog->get_active (); + pp->locallab.skintonescurve = skinTonesCurve->getCurve (); + pp->locallab.sensiv = sensiv->getIntValue (); + + if (pedited) { pedited->locallab.degree = degree->getEditedState (); pedited->locallab.Smethod = Smethod->get_active_text() != M ("GENERAL_UNCHANGED"); @@ -2331,6 +2568,7 @@ void Locallab::write (ProcParams* pp, ParamsEdited* pedited) pedited->locallab.LHcurve = !LHshape->isUnChanged (); pedited->locallab.HHcurve = !HHshape->isUnChanged (); pedited->locallab.expcolor = !expcolor->get_inconsistent(); + pedited->locallab.expvibrance = !expvibrance->get_inconsistent(); pedited->locallab.expblur = !expblur->get_inconsistent(); pedited->locallab.exptonemap = !exptonemap->get_inconsistent(); pedited->locallab.expreti = !expreti->get_inconsistent(); @@ -2343,6 +2581,14 @@ void Locallab::write (ProcParams* pp, ParamsEdited* pedited) } pedited->locallab.threshold = threshold->getEditedState(); + pedited->locallab.pastels = pastels->getEditedState (); + pedited->locallab.saturated = saturated->getEditedState (); + pedited->locallab.psthreshold = psThreshold->getEditedState (); + pedited->locallab.protectskins = !protectSkins->get_inconsistent(); + pedited->locallab.avoidcolorshift = !avoidColorShift->get_inconsistent(); + pedited->locallab.pastsattog = !pastSatTog->get_inconsistent(); + pedited->locallab.skintonescurve = !skinTonesCurve->isUnChanged (); + pedited->locallab.sensiv = sensiv->getEditedState (); } @@ -2403,6 +2649,92 @@ void Locallab::write (ProcParams* pp, ParamsEdited* pedited) } } +void Locallab::protectskins_toggled () +{ + if (batchMode) { + if (protectSkins->get_inconsistent()) { + protectSkins->set_inconsistent (false); + pskinsconn.block (true); + protectSkins->set_active (false); + pskinsconn.block (false); + } else if (lastProtectSkins) { + protectSkins->set_inconsistent (true); + } + + lastProtectSkins = protectSkins->get_active (); + } + + if (listener && getEnabled()) { + if (protectSkins->get_active ()) { + listener->panelChanged (EvlocallabProtectSkins, M ("GENERAL_ENABLED")); + } else { + listener->panelChanged (EvlocallabProtectSkins, M ("GENERAL_DISABLED")); + } + } +} + +void Locallab::avoidcolorshift_toggled () +{ + if (batchMode) { + if (avoidColorShift->get_inconsistent()) { + avoidColorShift->set_inconsistent (false); + ashiftconn.block (true); + avoidColorShift->set_active (false); + ashiftconn.block (false); + } else if (lastAvoidColorShift) { + avoidColorShift->set_inconsistent (true); + } + + lastAvoidColorShift = avoidColorShift->get_active (); + } + + if (listener && getEnabled()) { + if (avoidColorShift->get_active ()) { + listener->panelChanged (EvlocallabAvoidColorShift, M ("GENERAL_ENABLED")); + } else { + listener->panelChanged (EvlocallabAvoidColorShift, M ("GENERAL_DISABLED")); + } + } +} + +void Locallab::pastsattog_toggled () +{ + if (batchMode) { + if (pastSatTog->get_inconsistent()) { + pastSatTog->set_inconsistent (false); + pastsattogconn.block (true); + pastSatTog->set_active (false); + pastsattogconn.block (false); + } else if (lastPastSatTog) { + pastSatTog->set_inconsistent (true); + } + + lastPastSatTog = pastSatTog->get_active (); + } + + if (pastSatTog->get_active()) { + // Link both slider, so we set saturated and psThresholds unsensitive + psThreshold->set_sensitive (false); + saturated->set_sensitive (false); + saturated->setValue (pastels->getValue()); // Pastels and Saturated are linked + } else { + // Separate sliders, so we set saturated and psThresholds sensitive again + psThreshold->set_sensitive (true); + saturated->set_sensitive (true); + } + + if (listener && getEnabled()) { + if (pastSatTog->get_active ()) { + listener->panelChanged (EvlocallabPastSatTog, M ("GENERAL_ENABLED")); + } else { + listener->panelChanged (EvlocallabPastSatTog, M ("GENERAL_DISABLED")); + } + } +} + + + + void Locallab::curveChanged (CurveEditor* ce) { @@ -2463,8 +2795,23 @@ void Locallab::curveChanged (CurveEditor* ce) adjusterChanged (retrab, strval); + + } else if (ce == skinTonesCurve) { + listener->panelChanged (EvlocallabSkinTonesCurve, 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); + + + } + } } @@ -2830,6 +3177,10 @@ void Locallab::setDefaults (const ProcParams * defParams, const ParamsEdited * p } threshold->setDefault (defParams->locallab.threshold); + pastels->setDefault (defParams->locallab.pastels); + saturated->setDefault (defParams->locallab.saturated); + psThreshold->setDefault (defParams->locallab.psthreshold); + sensiv->setDefault (defParams->locallab.sensiv); if (pedited) { @@ -2885,6 +3236,11 @@ void Locallab::setDefaults (const ProcParams * defParams, const ParamsEdited * p threshold->setDefaultEditedState (pedited->locallab.threshold ? Edited : UnEdited); + pastels->setDefaultEditedState (pedited->locallab.pastels ? Edited : UnEdited); + saturated->setDefaultEditedState (pedited->locallab.saturated ? Edited : UnEdited); + psThreshold->setDefaultEditedState (pedited->locallab.psthreshold ? Edited : UnEdited); + sensiv->setDefaultEditedState (pedited->locallab.sensiv ? Edited : UnEdited); + } else { degree->setDefaultEditedState (Irrelevant); locY->setDefaultEditedState (Irrelevant); @@ -2938,10 +3294,22 @@ void Locallab::setDefaults (const ProcParams * defParams, const ParamsEdited * p threshold->setDefaultEditedState (Irrelevant); + pastels->setDefaultEditedState (Irrelevant); + saturated->setDefaultEditedState (Irrelevant); + psThreshold->setDefaultEditedState (Irrelevant); + sensiv->setDefaultEditedState (Irrelevant); } } +void Locallab::adjusterChanged (ThresholdAdjuster* a, int newBottom, int newTop) +{ + if (listener && getEnabled()) { + listener->panelChanged (EvlocallabPastSatThreshold, psThreshold->getHistoryString()); + } +} + + void Locallab::adjusterChanged (Adjuster * a, double newval) { @@ -3018,6 +3386,17 @@ void Locallab::adjusterChanged (Adjuster * a, double newval) listener->panelChanged (Evlocallabcontrast, contrast->getTextValue()); } else if (a == chroma) { listener->panelChanged (Evlocallabchroma, chroma->getTextValue()); + } else if (a == pastels ) { + listener->panelChanged (EvlocallabPastels, pastels->getTextValue() ); + } else if (a == saturated && !pastSatTog->get_active()) { + listener->panelChanged (EvlocallabSaturated, saturated->getTextValue() ); + } else if (a == sensiv) { + listener->panelChanged (Evlocallabsensiv, sensiv->getTextValue()); + + + + + } else if (a == noiselumf) { listener->panelChanged (Evlocallabnoiselumf, noiselumf->getTextValue()); } else if (a == noiselumc) { @@ -3222,6 +3601,9 @@ void Locallab::trimValues (rtengine::procparams::ProcParams * pp) } threshold->trimValue (pp->locallab.threshold); + pastels->trimValue (pp->locallab.pastels); + saturated->trimValue (pp->locallab.saturated); + sensiv->trimValue (pp->locallab.sensiv); } @@ -3290,9 +3672,67 @@ void Locallab::setBatchMode (bool batchMode) } threshold->showEditedCB(); + pastels->showEditedCB (); + saturated->showEditedCB (); + psThreshold->showEditedCB (); + sensiv->showEditedCB (); + + curveEditorGG->setBatchMode (batchMode); } +std::vector Locallab::getCurvePoints (ThresholdSelector* tAdjuster) const +{ + std::vector points; + double threshold, transitionWeighting; + tAdjuster->getPositions (transitionWeighting, threshold); // ( range -100;+100, range 0;+100 ) + transitionWeighting /= 100.; // range -1., +1. + threshold /= 100.; // range 0., +1. + + // Initial point + points.push_back (0.); + points.push_back (0.); + + double p2 = 3.0 * threshold / 4.0; // same one than in ipvibrance.cc + double s0 = threshold + (1.0 - threshold) / 4.0; // same one than in ipvibrance.cc + + // point at the beginning of the first linear transition + points.push_back (p2); + points.push_back (0.); + + // Y value of the chroma mean point, calculated to get a straight line between p2 and s0 + double chromaMean = (threshold / 4.0) / (s0 - p2); + + // move chromaMean up or down depending on transitionWeighting + if (transitionWeighting > 0.0) { + // positive values -> give more weight to Saturated + chromaMean = (1.0 - chromaMean) * transitionWeighting + chromaMean; + } else if (transitionWeighting < 0.0) { + // negative values -> give more weight to Pastels + chromaMean = chromaMean * transitionWeighting + chromaMean; + } + + // point at the location of the Top cursor, at the end of the first linear transition and the beginning of the second one + points.push_back (threshold); + points.push_back (chromaMean); + + if (threshold < 1.0) { + + // point at the end of the second linear transition + points.push_back (s0); + points.push_back (1.0); + + // end point + points.push_back (1.0); + points.push_back (1.0); + } + + return points; +} + + + + void Locallab::setEditProvider (EditDataProvider * provider) { EditSubscriber::setEditProvider (provider); diff --git a/rtgui/locallab.h b/rtgui/locallab.h index 35fcff114..3b595f35b 100644 --- a/rtgui/locallab.h +++ b/rtgui/locallab.h @@ -15,6 +15,7 @@ #include "options.h" #include #include "../rtengine/improcfun.h" +#include "thresholdadjuster.h" class Locallab : @@ -24,7 +25,9 @@ class Locallab : public rtengine::localListener, public CurveListener, public EditSubscriber, - public ColorProvider + public ColorProvider, + public ThresholdCurveProvider, + public ThresholdAdjusterListener { private: @@ -35,6 +38,7 @@ private: //protected: MyExpander* const expcolor; + MyExpander* const expvibrance; MyExpander* const expblur; MyExpander* const exptonemap; MyExpander* const expreti; @@ -153,13 +157,30 @@ private: FlatCurveEditor* LHshape; FlatCurveEditor* HHshape; + CurveEditorGroup* curveEditorGG; + Adjuster* pastels; + Adjuster* saturated; + ThresholdAdjuster* psThreshold; + Gtk::CheckButton* protectSkins; + Gtk::CheckButton* avoidColorShift; + Gtk::CheckButton* pastSatTog; + DiagonalCurveEditor* skinTonesCurve; + Adjuster* sensiv; + + bool lastProtectSkins; + bool lastAvoidColorShift; + bool lastPastSatTog; + + sigc::connection pskinsconn; + sigc::connection ashiftconn; + sigc::connection pastsattogconn; sigc::connection lumaneutralPressedConn; sigc::connection lumacontrastPlusPressedConn; sigc::connection lumacontrastMinusPressedConn; - sigc::connection enablecolorConn, enableblurConn, enabletonemapConn; + sigc::connection enablecolorConn, enablevibranceConn, enableblurConn, enabletonemapConn; sigc::connection enableretiConn, enablesharpConn, enablecbdlConn; sigc::connection enabledenoiConn; sigc::connection editConn, avoidConn, inversConn, curvactivConn, activlumConn, inversradConn, inversretConn, inversshaConn, neutralconn, neutralconn1; @@ -170,7 +191,7 @@ private: - int nextdatasp[61]; + int nextdatasp[67]; int nextlength; std::string nextstr; std::string nextstr2; @@ -182,6 +203,10 @@ private: std::string nextcc_str2; std::string nexthh_str; std::string nexthh_str2; + std::string nextsk_str; + std::string nextsk_str2; + std::string nextps_str; + std::string nextps_str2; double draggedPointOldAngle; double draggedPointAdjusterAngle; @@ -213,6 +238,8 @@ public: void updateToolState (std::vector &tpOpen); void adjusterChanged (Adjuster* a, double newval); + void adjusterChanged (ThresholdAdjuster* a, int newBottom, int newTop); + 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); @@ -225,8 +252,8 @@ public: void inversshaChanged (); void curveChanged (CurveEditor* ce); void autoOpenCurve (); - void localChanged (int **datasp, std::string datastr, std::string ll_str, std::string lh_str, std::string cc_str, std::string hh_str, int sp, int maxdat); - void localretChanged (int **datasp, std::string datastr, std::string ll_str, std::string lh_str, std::string cc_str, std::string hh_str, int sp, int maxdat); + void localChanged (int **datasp, std::string datastr, std::string ll_str, std::string lh_str, std::string cc_str, std::string hh_str, std::string sk_str, std::string ps_str, int sp, int maxdat); + void localretChanged (int **datasp, std::string datastr, std::string ll_str, std::string lh_str, std::string cc_str, std::string hh_str, std::string sk_str, std::string ps_str, int sp, int maxdat); bool localComputed_ (); bool localretComputed_ (); void setEditProvider (EditDataProvider* provider); @@ -238,6 +265,10 @@ public: void lumacontrastMinusPressed (); void neutral_pressed (); virtual void colorForValue (double valX, double valY, enum ColorCaller::ElemType elemType, int callerId, ColorCaller* caller); + void protectskins_toggled (); + void avoidcolorshift_toggled (); + void pastsattog_toggled (); + std::vector getCurvePoints (ThresholdSelector* tAdjuster) const; // EditSubscriber interface CursorShape getCursor (int objectID); diff --git a/rtgui/paramsedited.cc b/rtgui/paramsedited.cc index d39a5fdf8..65dd4f9fd 100644 --- a/rtgui/paramsedited.cc +++ b/rtgui/paramsedited.cc @@ -291,6 +291,7 @@ void ParamsEdited::set (bool v) gradient.centerY = v; locallab.enabled = v; locallab.expcolor = v; + locallab.expvibrance = v; locallab.expblur = v; locallab.exptonemap = v; locallab.expreti = v; @@ -365,6 +366,15 @@ void ParamsEdited::set (bool v) } locallab.threshold = v; + locallab.pastels = v; + locallab.saturated = v; + locallab.psthreshold = v; + locallab.protectskins = v; + locallab.avoidcolorshift = v; + locallab.pastsattog = v; + locallab.skintonescurve = v; + locallab.sensiv = v; + pcvignette.enabled = v; pcvignette.strength = v; @@ -953,6 +963,7 @@ void ParamsEdited::initFrom (const std::vector locallab.LHcurve = locallab.LHcurve && p.locallab.LHcurve == other.locallab.LHcurve; locallab.HHcurve = locallab.HHcurve && p.locallab.HHcurve == other.locallab.HHcurve; locallab.expcolor = locallab.expcolor && p.locallab.expcolor == other.locallab.expcolor; + locallab.expvibrance = locallab.expvibrance && p.locallab.expvibrance == other.locallab.expvibrance; 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; @@ -965,6 +976,14 @@ void ParamsEdited::initFrom (const std::vector } locallab.threshold = locallab.threshold && p.locallab.threshold == other.locallab.threshold; + locallab.pastels = locallab.pastels && p.locallab.pastels == other.locallab.pastels; + locallab.saturated = locallab.saturated && p.locallab.saturated == other.locallab.saturated; + locallab.psthreshold = locallab.psthreshold && p.locallab.psthreshold == other.locallab.psthreshold; + locallab.protectskins = locallab.protectskins && p.locallab.protectskins == other.locallab.protectskins; + locallab.avoidcolorshift = locallab.avoidcolorshift && p.locallab.avoidcolorshift == other.locallab.avoidcolorshift; + locallab.pastsattog = locallab.pastsattog && p.locallab.pastsattog == other.locallab.pastsattog; + locallab.skintonescurve = locallab.skintonescurve && p.locallab.skintonescurve == other.locallab.skintonescurve; + locallab.sensiv = locallab.sensiv && p.locallab.sensiv == other.locallab.sensiv; pcvignette.enabled = pcvignette.enabled && p.pcvignette.enabled == other.pcvignette.enabled; pcvignette.strength = pcvignette.strength && p.pcvignette.strength == other.pcvignette.strength; @@ -2201,6 +2220,10 @@ void ParamsEdited::combine (rtengine::procparams::ProcParams& toEdit, const rten toEdit.locallab.expcolor = mods.locallab.expcolor; } + if (locallab.expvibrance) { + toEdit.locallab.expvibrance = mods.locallab.expvibrance; + } + if (locallab.expblur) { toEdit.locallab.expblur = mods.locallab.expblur; } @@ -2321,6 +2344,39 @@ void ParamsEdited::combine (rtengine::procparams::ProcParams& toEdit, const rten toEdit.locallab.chroma = mods.locallab.chroma; } + if (locallab.pastels) { + toEdit.locallab.pastels = mods.locallab.pastels; + } + + if (locallab.saturated) { + toEdit.locallab.saturated = mods.locallab.saturated; + } + + if (locallab.psthreshold) { + toEdit.locallab.psthreshold = mods.locallab.psthreshold; + } + + if (locallab.protectskins) { + toEdit.locallab.protectskins = mods.locallab.protectskins; + } + + if (locallab.avoidcolorshift) { + toEdit.locallab.avoidcolorshift = mods.locallab.avoidcolorshift; + } + + if (locallab.pastsattog) { + toEdit.locallab.pastsattog = mods.locallab.pastsattog; + } + + if (locallab.skintonescurve) { + toEdit.locallab.skintonescurve = mods.locallab.skintonescurve; + } + + if (locallab.sensiv) { + toEdit.locallab.sensiv = mods.locallab.sensiv; + } + + if (locallab.noiselumf) { toEdit.locallab.noiselumf = mods.locallab.noiselumf; } @@ -2469,7 +2525,7 @@ void ParamsEdited::combine (rtengine::procparams::ProcParams& toEdit, const rten if (locallab.HHcurve) { toEdit.locallab.HHcurve = mods.locallab.HHcurve; } - + if (locallab.localTgaincurverab) { toEdit.locallab.localTgaincurverab = mods.locallab.localTgaincurverab; } diff --git a/rtgui/paramsedited.h b/rtgui/paramsedited.h index 8100131e2..a05be6bc2 100644 --- a/rtgui/paramsedited.h +++ b/rtgui/paramsedited.h @@ -482,12 +482,22 @@ public: bool mult[5]; bool threshold; bool expcolor; + bool expvibrance; bool expblur; bool exptonemap; bool expreti; bool expsharp; bool expcbdl; bool expdenoi; + bool pastels; + bool saturated; + bool psthreshold; + bool protectskins; + bool avoidcolorshift; + bool pastsattog; + bool skintonescurve; + bool sensiv; + };