From 7e40527926d64089c5b757ca12606060d4a4cc34 Mon Sep 17 00:00:00 2001 From: Desmis Date: Mon, 24 Jul 2017 10:57:15 +0200 Subject: [PATCH] add Exposure contrast curve --- rtengine/dcrop.cc | 41 +++++- rtengine/improccoordinator.cc | 228 ++++++++++++++++++++++++++++------ rtengine/improccoordinator.h | 9 +- rtengine/improcfun.h | 2 +- rtengine/iplocallab.cc | 24 +++- rtengine/procparams.cc | 5 +- rtengine/procparams.h | 2 +- rtengine/rtengine.h | 4 +- rtengine/simpleprocess.cc | 75 ++++++++++- rtgui/locallab.cc | 55 ++++++-- rtgui/locallab.h | 6 +- 11 files changed, 387 insertions(+), 64 deletions(-) diff --git a/rtengine/dcrop.cc b/rtengine/dcrop.cc index 60b636839..59661bb9f 100644 --- a/rtengine/dcrop.cc +++ b/rtengine/dcrop.cc @@ -822,6 +822,8 @@ void Crop::update (int todo) LUTf cclocalcurve2 (65536, 0); bool localskutili = parent->localskutili; LUTf sklocalcurve2 (65536, 0); + bool localexutili = parent->localexutili; + LUTf exlocalcurve2 (65536, 0); LUTf hltonecurveloc2 (32768, 0);//65536 LUTf shtonecurveloc2 (32768, 0); LUTf tonecurveloc2 (32768, 0); @@ -838,11 +840,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()); @@ -1080,6 +1082,16 @@ void Crop::update (int todo) params.locallab.psthreshold.setValues (parent->psthresholds[sp * 500], parent->psthresholds[sp * 500 + 1]); + std::vector sex; + + for (int j = 0; j < parent->sizeexcurves[sp]; j++) { + sex.push_back ((double) (parent->excurves[sp * 500 + j]) / 1000.); + } + + params.locallab.excurve.clear(); + params.locallab.excurve = sex; + + params.locallab.getCurves (locRETgainCurve, locRETgainCurverab, loclhCurve, lochhCurve, LHutili, HHutili); locallutili = false; CurveFactory::curveLocal (locallutili, params.locallab.llcurve, lllocalcurve2, sca); @@ -1087,6 +1099,7 @@ void Crop::update (int todo) CurveFactory::curveCCLocal (localcutili, params.locallab.cccurve, cclocalcurve2, sca); //localskutili = false; CurveFactory::curveskLocal (localskutili, params.locallab.skintonescurve, sklocalcurve2, sca); + CurveFactory::curveexLocal (localexutili, params.locallab.excurve, exlocalcurve2, sca); double br = 0.; @@ -1107,10 +1120,12 @@ void Crop::update (int todo) // printf ("dcr1 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, localskutili, sklocalcurve2, hltonecurveloc2 , shtonecurveloc2, tonecurveloc2, params.locallab.hueref, params.locallab.chromaref, params.locallab.lumaref); + 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, localskutili, sklocalcurve2, localexutili, exlocalcurve2, hltonecurveloc2 , shtonecurveloc2, tonecurveloc2, params.locallab.hueref, params.locallab.chromaref, params.locallab.lumaref); lllocalcurve2.clear(); cclocalcurve2.clear(); sklocalcurve2.clear(); + exlocalcurve2.clear(); if (skip <= 2) { usleep (settings->cropsleep); //wait to avoid crash when crop 100% and move window @@ -1398,6 +1413,17 @@ void Crop::update (int todo) params.locallab.psthreshold.setValues (parent->psthresholds[0 * 500], parent->psthresholds[0 * 500 + 1]); + + std::vector sexL; + + for (int j = 0; j < parent->sizeexcurves[sp]; j++) { + sexL.push_back ((double) (parent->excurves[0 * 500 + j]) / 1000.); + parent->excurves[sp * 500 + j] = parent->excurves[0 * 500 + j] ; + } + + params.locallab.excurve.clear(); + params.locallab.excurve = sexL; + params.locallab.getCurves (locRETgainCurve, locRETgainCurverab, loclhCurve, lochhCurve, LHutili, HHutili); locallutili = false; localcutili = false; @@ -1406,6 +1432,7 @@ void Crop::update (int todo) CurveFactory::curveLocal (locallutili, params.locallab.llcurve, lllocalcurve2, sca); CurveFactory::curveCCLocal (localcutili, params.locallab.cccurve, cclocalcurve2, sca); CurveFactory::curveskLocal (localskutili, params.locallab.skintonescurve, sklocalcurve2, sca); + CurveFactory::curveexLocal (localexutili, params.locallab.excurve, exlocalcurve2, sca); double br = 0.; double contr = 0.; @@ -1423,11 +1450,13 @@ void Crop::update (int todo) 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); - 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, localskutili, sklocalcurve2, hltonecurveloc2 , shtonecurveloc2, tonecurveloc2, params.locallab.hueref, params.locallab.chromaref, params.locallab.lumaref); + 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, localskutili, sklocalcurve2, localexutili, exlocalcurve2, hltonecurveloc2 , shtonecurveloc2, tonecurveloc2, params.locallab.hueref, params.locallab.chromaref, params.locallab.lumaref); lllocalcurve2.clear(); cclocalcurve2.clear(); sklocalcurve2.clear(); + exlocalcurve2.clear(); } @@ -1438,8 +1467,8 @@ void Crop::update (int todo) parent->ipf.chromiLuminanceCurve (this, 1, labnCrop, labnCrop, parent->chroma_acurve, parent->chroma_bcurve, parent->satcurve, parent->lhskcurve, parent->clcurve, parent->lumacurve, utili, autili, butili, ccutili, cclutili, clcutili, dummy, dummy); parent->ipf.vibrance (labnCrop); - if((params.colorappearance.enabled && !params.colorappearance.tonecie) || (!params.colorappearance.enabled)) { - parent->ipf.EPDToneMap(labnCrop, 5, skip); + if ((params.colorappearance.enabled && !params.colorappearance.tonecie) || (!params.colorappearance.enabled)) { + parent->ipf.EPDToneMap (labnCrop, 5, skip); } //parent->ipf.EPDToneMap(labnCrop, 5, 1); //Go with much fewer than normal iterates for fast redisplay. diff --git a/rtengine/improccoordinator.cc b/rtengine/improccoordinator.cc index fa121c043..9dd6a084e 100644 --- a/rtengine/improccoordinator.cc +++ b/rtengine/improccoordinator.cc @@ -59,6 +59,7 @@ ImProcCoordinator::ImProcCoordinator () lllocalcurve (65536, 0), cclocalcurve (65536, 0), sklocalcurve (65536, 0), + exlocalcurve (65536, 0), hltonecurveloc (32768, 0),//32768 shtonecurveloc (32768, 0), tonecurveloc (32768, 0), @@ -99,7 +100,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), skinstr (nullptr), pthstr (nullptr), + dataspot (nullptr), retistr (nullptr), llstr (nullptr), lhstr (nullptr), ccstr (nullptr), hhstr (nullptr), skinstr (nullptr), pthstr (nullptr), exstr (nullptr), circrads (500, -10000), centerx (500, -10000), centery (500, -10000), @@ -183,13 +184,10 @@ ImProcCoordinator::ImProcCoordinator () protectskinss (500, -10000), avoidcolorshifts (500, -10000), pastsattogs (500, -10000), - skintonescurves (500, -10000), + skintonescurves (25000, -10000), sizeskintonecurves (500, -10000), - // hltonecurvelocs (500, -10000), - // shtonecurvelocs (500, -10000), - // tonecurvelocs (500, -10000), - // customToneCurve1locs (500, -10000), - + excurves (25000, -10000), + sizeexcurves (500, -10000), huerefs (500, -100000.f), chromarefs (500, -100000.f), lumarefs (500, -100000.f), @@ -871,7 +869,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) { for (int sp = 1; sp < maxspot; sp++) { // spots default int t_sp = sp; - int t_mipversion = 10010;//new value for tone mapping + int t_mipversion = 10011;//new value for tone mapping int t_circrad = 18; int t_locX = 250; int t_locY = 250; @@ -968,6 +966,9 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) int t_shcompr = 50; int t_sensiex = 19; + //10011 + std::string t_curvex = "3000A0B0C1000D1000E"; + //all variables except locRETgainCurve 'coomon for all) fic << "Mipversion=" << t_mipversion << '@' << endl; fic << "Spot=" << t_sp << '@' << endl; @@ -1052,6 +1053,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) fic << "curveHH=" << t_curvhh << '@' << endl; fic << "curveskin=" << t_curvskin << '@' << endl; fic << "pthres=" << t_psthres << '@' << endl; + fic << "curveex=" << t_curvex << '@' << endl; fic << endl; } @@ -1083,6 +1085,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) hhstr = new std::string[maxspot]; skinstr = new std::string[maxspot]; pthstr = new std::string[maxspot]; + exstr = new std::string[maxspot]; { @@ -1402,18 +1405,37 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) // printf("ps0=%s\n", pthstr[0].c_str()); //end local ps - //spot references - /* - 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]); - */ + + //Exp curve + int sizex = params.locallab.excurve.size(); + + if (sizex > 69) { + sizex = 69;//to avoid crash + } + + + int s_datcurex[sizex + 1]; + + for (int j = 0; j < sizex; j++) { + s_datcurex[j] = excurves[0 + j] = (int) (1000. * params.locallab.excurve[j]); + } + + std::string ex_str = ""; + + for (int j = 0; j < sizex; j++) { + ex_str = ex_str + std::to_string (s_datcurex[j]) + delim[j]; + } + + exstr[0] = ex_str + "@"; + + //end local Exp + + 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], skinstr[0], pthstr[0], 0, 1); + aloListener->localretChanged (dataspot, retistr[0], llstr[0], lhstr[0], ccstr[0], hhstr[0], skinstr[0], pthstr[0], exstr[0], 0, 1); } } @@ -1435,6 +1457,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) bool excurvhh = true; bool excurvsk = true; bool excpth = true; + bool excurvex = true; ifstream fich (datal, ios::in); @@ -1454,6 +1477,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) excurvhh = false; excurvsk = false; excpth = false; + excurvex = false; } @@ -1465,6 +1489,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) excurvhh = false; excurvsk = false; excpth = false; + excurvex = false; } @@ -1642,6 +1667,26 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) // sizelh = longeh; } + if (excurvex && spotline.substr (0, pos) == "curveex") { + std::string curstex; + // int longecurh; + std::string strendex = spotline.substr (posend - 1, 1); + // std::size_t poszh = spotline.find (strendh); + // int longeh; + + for (int sh = 0; sh < 69; sh++) { + if (delim[sh] == strendex) { + // longeh = sh + 1; + } + } + + exstr[ns] = str3; + // sizelh = longeh; + // printf ("0 str=%s \n", exstr[ns].c_str()); + + } + + } @@ -1649,7 +1694,6 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) } - //new fields for TM if (versionmip == 10000) { for (int sp = 1; sp < maxspot; sp++) { // spots default @@ -1746,13 +1790,22 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) } } + if (versionmip == 10010) { + + for (int sp = 1; sp < maxspot; sp++) { // spots default + std::string ex_str = "3000A0B0C1000D1000E"; + exstr[sp] = ex_str + "@"; + } + } + + 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 = 10010; + int t_mipversion = 10011; int t_circrad = 18; int t_locX = 250; int t_locY = 250; @@ -1826,7 +1879,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) //10008 std::string t_curvskin = "3000A0B0C1000D1000E"; //"3000A0B0C499D501E1000F1000G"; //"3000A0B0C1000D1000E";//0 points with marks - + //10009 int t_sensiv = 19; int t_pastel = 0; int t_saturated = 0; @@ -1841,6 +1894,8 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) int t_hlcomprthresh = 33; int t_shcompr = 50; int t_sensiex = 19; + //10010 + std::string t_curvex = "3000A0B0C1000D1000E"; fic << "Mipversion=" << t_mipversion << '@' << endl; fic << "Spot=" << t_sp << '@' << endl; @@ -1923,6 +1978,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) fic << "curveHH=" << t_curvhh << '@' << endl; fic << "curveskin=" << t_curvskin << '@' << endl; fic << "pthres=" << t_psthres << '@' << endl; + fic << "curveex=" << t_curvex << '@' << endl; fic << endl; } @@ -1939,10 +1995,6 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) int cont2 = 0; int ns2 = 0; int maxin = 70;//64 - // int sizecu2; - // int sizell2; - // int sizelh2; - // int sizecc2; while (getline (fich2, line2)) { spotline2 = line2; @@ -2107,6 +2159,25 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) // sizelh = longeh; } + if (spotline2.substr (0, pos2) == "curveex") { + std::string curstr2ex; + // int longecur2h; + std::string strend2ex = spotline2.substr (posend2 - 1, 1); + // std::size_t posz2h = spotline2.find (strend2h); + // int longe2h; + + for (int sh = 0; sh < 69; sh++) { + if (delim[sh] == strend2ex) { + // longe2h = sh + 1; + } + } + + exstr[ns] = str32; + // sizelh2 = longe2h; + + } + + } @@ -2431,6 +2502,43 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) //end local PS + /* + 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; + */ + //exposure + int *s_datcexx; + s_datcexx = new int[70]; + int sizexx; + + ipf.strcurv_data (exstr[sp], s_datcexx, sizexx); + + sizeexcurves[sp] = sizexx; + + std::vector cexend; + + for (int j = 0; j < sizexx; j++) { + excurves[sp * 500 + j] = s_datcexx[j]; + cexend.push_back ((double) (s_datcexx[j]) / 1000.); + } + + delete [] s_datcexx; + + params.locallab.localTgaincurve.clear(); params.locallab.localTgaincurve = cretiend; @@ -2452,9 +2560,14 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) params.locallab.skintonescurve = cskend; + params.locallab.excurve.clear(); + params.locallab.excurve = cexend; + locallutili = false; localcutili = false; localskutili = false; + localexutili = false; + LHutili = false; HHutili = false; std::string t_curvhhref = "1000A0B500C350D350E166F500G350H350I333J500K350L350M500N500O350P350Q666R500S350T350U833V500W350X350Y@"; @@ -2475,12 +2588,18 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) localskutili = true; } + std::string t_curvexref = "3000A0B0C1000D1000E@"; + + if (exstr[sp].c_str() != t_curvexref && exstr[sp].c_str() != t_none) { + localexutili = true; + } + // printf ("HHstr=%s\n", hhstr[sp].c_str()); 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); - CurveFactory::curveexLocal (localexutili, params.locallab.excurve, exlocalcurve, sca); //scale == 1 ? 1 : 16); + CurveFactory::curveLocal (locallutili, params.locallab.llcurve, lllocalcurve, sca); + CurveFactory::curveCCLocal (localcutili, params.locallab.cccurve, cclocalcurve, sca); + CurveFactory::curveskLocal (localskutili, params.locallab.skintonescurve, sklocalcurve, sca); + CurveFactory::curveexLocal (localexutili, params.locallab.excurve, exlocalcurve, sca); //provisory double br = 0.; double contr = 0.; @@ -2506,7 +2625,8 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) dataspot[71][sp] = chromarefs[sp] = params.locallab.chromaref; dataspot[72][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, localskutili, sklocalcurve, hltonecurveloc , shtonecurveloc, tonecurveloc, params.locallab.hueref, params.locallab.chromaref, params.locallab.lumaref); + 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, localskutili, sklocalcurve, localexutili, exlocalcurve, hltonecurveloc , shtonecurveloc, tonecurveloc, params.locallab.hueref, params.locallab.chromaref, params.locallab.lumaref); lllocalcurve.clear(); cclocalcurve.clear(); sklocalcurve.clear(); @@ -2524,7 +2644,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], skinstr[sp], pthstr[sp], sp, maxreal); + aloListener->localChanged (dataspot, retistr[sp], llstr[sp], lhstr[sp], ccstr[sp], hhstr[sp], skinstr[sp], pthstr[sp], exstr[sp], sp, maxreal); } @@ -2905,6 +3025,28 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) //end local PS + //expos + int *s_datcex; + s_datcex = new int[70]; + int sizex; + // printf ("ex0=%s \n", exstr[0].c_str()); + ipf.strcurv_data (exstr[0], s_datcex, sizex); + sizeexcurves[sp] = sizex; + std::vector cexend; + + exstr[sp] = exstr[0]; + + for (int j = 0; j < sizex; j++) { + excurves[sp * 500 + j] = s_datcex[j]; + cexend.push_back ((double) (s_datcex[j]) / 1000.); + + } + + params.locallab.excurve.clear(); + params.locallab.excurve = cexend; + + delete [] s_datcex; + LHutili = false; HHutili = false; @@ -2922,6 +3064,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) locallutili = false; localcutili = false; localskutili = false; + localexutili = false; std::string t_curvskinref2 = "3000A0B0C1000D1000E@"; std::string t_none2 = "0A@"; @@ -2931,6 +3074,11 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) localskutili = true; } + std::string t_curvexref2 = "3000A0B0C1000D1000E@"; + + if (exstr[sp].c_str() != t_curvexref2 && exstr[sp].c_str() != t_none2) { + localexutili = true; + } double br = 0.; double contr = 0.; @@ -2944,18 +3092,22 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) lhist16, hltonecurveloc , shtonecurveloc, tonecurveloc, sca); - 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); + CurveFactory::curveLocal (locallutili, params.locallab.llcurve, lllocalcurve, sca); + CurveFactory::curveCCLocal (localcutili, params.locallab.cccurve, cclocalcurve, sca); + CurveFactory::curveskLocal (localskutili, params.locallab.skintonescurve, sklocalcurve, sca); + CurveFactory::curveexLocal (localexutili, params.locallab.excurve, exlocalcurve, sca); + params.locallab.hueref = huerefs[sp] / 100.; params.locallab.chromaref = chromarefs[sp]; params.locallab.lumaref = lumarefs[sp]; // printf("sp=%i hueres=%i\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, localskutili, sklocalcurve, hltonecurveloc , shtonecurveloc, tonecurveloc, params.locallab.hueref, params.locallab.chromaref, params.locallab.lumaref ); + 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, + localskutili, sklocalcurve, localexutili, exlocalcurve, hltonecurveloc , shtonecurveloc, tonecurveloc, params.locallab.hueref, params.locallab.chromaref, params.locallab.lumaref ); lllocalcurve.clear(); cclocalcurve.clear(); sklocalcurve.clear(); + exlocalcurve.clear(); ofstream fou (datal, ios::out | ios::trunc); @@ -2965,7 +3117,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) for (int spe = 1; spe < maxspot; spe++) { int t_sp = spe; - int t_mipversion = 100010; + int t_mipversion = 100011; int t_circrad = dataspot[2][spe]; int t_locX = dataspot[3][spe]; int t_locY = dataspot[4][spe]; @@ -3051,6 +3203,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) std::string t_curvhh = hhstr[spe]; std::string t_curvskin = skinstr[spe]; std::string t_psthres = pthstr[spe]; + std::string t_curvex = exstr[spe]; fou << "Mipversion=" << t_mipversion << '@' << endl; fou << "Spot=" << t_sp << '@' << endl; @@ -3138,6 +3291,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) fou << "curveHH=" << t_curvhh << endl; fou << "curveskin=" << t_curvskin << endl; fou << "pthres=" << t_psthres << endl; + fou << "curveex=" << t_curvex << endl; fou << endl; } @@ -3160,6 +3314,8 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) delete [] hhstr; delete [] skinstr; delete [] pthstr; + delete [] exstr; + // } } @@ -3169,8 +3325,8 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) ipf.chromiLuminanceCurve (nullptr, pW, nprevl, nprevl, chroma_acurve, chroma_bcurve, satcurve, lhskcurve, clcurve, lumacurve, utili, autili, butili, ccutili, cclutili, clcutili, histCCurve, histLCurve); ipf.vibrance (nprevl); - if((params.colorappearance.enabled && !params.colorappearance.tonecie) || (!params.colorappearance.enabled)) { - ipf.EPDToneMap(nprevl, 5, scale); + if ((params.colorappearance.enabled && !params.colorappearance.tonecie) || (!params.colorappearance.enabled)) { + ipf.EPDToneMap (nprevl, 5, scale); } // for all treatments Defringe, Sharpening, Contrast detail , Microcontrast they are activated if "CIECAM" function are disabled diff --git a/rtengine/improccoordinator.h b/rtengine/improccoordinator.h index 40dcffe87..4b4c452df 100644 --- a/rtengine/improccoordinator.h +++ b/rtengine/improccoordinator.h @@ -134,7 +134,7 @@ protected: LUTu histBlue, histBlueRaw; LUTu histLuma, histToneCurve, histToneCurveBW, histLCurve, histCCurve; LUTu histLLCurve, histLCAM, histCCAM, histClad, bcabhist, histChroma, histLRETI; - LUTu lhist16; + LUTu lhist16; LUTf CAMBrightCurveJ, CAMBrightCurveQ; LUTf rCurve; @@ -246,6 +246,7 @@ protected: std::string *hhstr; std::string *skinstr; std::string *pthstr; + std::string *exstr; LUTi circrads; LUTi centerx; @@ -333,10 +334,8 @@ protected: LUTi pastsattogs; LUTi skintonescurves; LUTi sizeskintonecurves; -// LUTi hltonecurvelocs; -// LUTi shtonecurvelocs; -// LUTi tonecurvelocs; -// LUTi customToneCurve1locs; + LUTi excurves; + LUTi sizeexcurves; LUTf huerefs; LUTf chromarefs; diff --git a/rtengine/improcfun.h b/rtengine/improcfun.h index 633560197..9eeed46b7 100644 --- a/rtengine/improcfun.h +++ b/rtengine/improcfun.h @@ -279,7 +279,7 @@ public: //locallab void MSRLocal (float** luminance, float** templ, const float* const *originalLuminance, const int width, const int height, const LocallabParams &loc, const int skip, const LocretigainCurve &locRETgainCcurve, const int chrome, const int scall, const float krad, float &minCD, float &maxCD, float &mini, float &maxi, float &Tmean, float &Tsigma, float &Tmin, float &Tmax); void calc_ref (int call, int sp, float** shbuffer, LabImage* original, LabImage* transformed, int sx, int sy, int cx, int cy, int oW, int oH, int fw, int fh, bool locutili, int sk, const LocretigainCurve & locRETgainCcurve, bool locallutili, LUTf & lllocalcurve, const LocLHCurve & loclhCurve, LUTf & cclocalcurve, LUTf & sklocalcurve, double &huere, double &chromare, double &lumare); - void Lab_Local (int call, int sp, float** shbuffer, LabImage* original, LabImage* transformed, int sx, int sy, int cx, int cy, int oW, int oH, int fw, int fh, bool locutili, int sk, const LocretigainCurve & locRETgainCcurve, bool locallutili, LUTf & lllocalcurve, const LocLHCurve & loclhCurve, const LocHHCurve & lochhCurve, bool &LHutili, bool &HHutili, LUTf & cclocalcurve, bool & localskutili, LUTf & sklocalcurve, LUTf & hltonecurve, LUTf & shtonecurve, LUTf & tonecurve, double &hueref, double &chromaref, double &lumaref); + void Lab_Local (int call, int sp, float** shbuffer, LabImage* original, LabImage* transformed, int sx, int sy, int cx, int cy, int oW, int oH, int fw, int fh, bool locutili, int sk, const LocretigainCurve & locRETgainCcurve, bool locallutili, LUTf & lllocalcurve, const LocLHCurve & loclhCurve, const LocHHCurve & lochhCurve, bool &LHutili, bool &HHutili, LUTf & cclocalcurve, bool & localskutili, LUTf & sklocalcurve, bool & localexutili, LUTf & exlocalcurve,LUTf & hltonecurve, LUTf & shtonecurve, LUTf & tonecurve, double &hueref, double &chromaref, double &lumaref); void addGaNoise (LabImage *lab, LabImage *dst, const float mean, const float variance, const int sk); void BlurNoise_Localold (int call, const struct local_params& lp, LabImage* original, LabImage* transformed, const LabImage* const tmp1, int cx, int cy); void InverseBlurNoise_Local (const struct local_params& lp, LabImage* original, LabImage* transformed, const LabImage* const tmp1, int cx, int cy); diff --git a/rtengine/iplocallab.cc b/rtengine/iplocallab.cc index 116667cf6..fb846639c 100644 --- a/rtengine/iplocallab.cc +++ b/rtengine/iplocallab.cc @@ -4901,7 +4901,9 @@ void ImProcFunctions::calc_ref (int call, int sp, float** shbuffer, LabImage * o } } -void ImProcFunctions::Lab_Local (int call, int sp, float** shbuffer, LabImage * original, LabImage * transformed, int sx, int sy, int cx, int cy, int oW, int oH, int fw, int fh, bool locutili, int sk, const LocretigainCurve & locRETgainCcurve, bool locallutili, LUTf & lllocalcurve, const LocLHCurve & loclhCurve, const LocHHCurve & lochhCurve, bool &LHutili, bool &HHutili, LUTf & cclocalcurve, bool & localskutili, LUTf & sklocalcurve, LUTf & hltonecurveloc, LUTf & shtonecurveloc, LUTf & tonecurveloc, double & hueref, double & chromaref, double & lumaref) +void ImProcFunctions::Lab_Local (int call, int sp, float** shbuffer, LabImage * original, LabImage * transformed, int sx, int sy, int cx, int cy, int oW, int oH, int fw, int fh, bool locutili, int sk, + const LocretigainCurve & locRETgainCcurve, bool locallutili, LUTf & lllocalcurve, const LocLHCurve & loclhCurve, const LocHHCurve & lochhCurve, + bool &LHutili, bool &HHutili, LUTf & cclocalcurve, bool & localskutili, LUTf & sklocalcurve, bool & localexutili, LUTf & exlocalcurve, LUTf & hltonecurveloc, LUTf & shtonecurveloc, LUTf & tonecurveloc, double & hueref, double & chromaref, double & lumaref) { //general call of others functions : important return hueref, chromaref, lumaref if (params->locallab.enabled) { @@ -6021,6 +6023,26 @@ void ImProcFunctions::Lab_Local (int call, int sp, float** shbuffer, LabImage * ImProcFunctions::exlabLocal (lp, bfh, bfw, bufexporig, bufexpfin, hltonecurveloc, shtonecurveloc, tonecurveloc); + if (exlocalcurve && localexutili) {// L=f(L) curve enhanced +#ifdef _OPENMP + #pragma omp parallel for schedule(dynamic,16) +#endif + + for (int y = 0; y < transformed->H ; y++) //{ + for (int x = 0; x < transformed->W; x++) { + int lox = cx + x; + int loy = cy + y; + + if (lox >= begx && lox < xEn && loy >= begy && loy < yEn) { + + float lighn = bufexpfin->L[loy - begy][lox - begx]; + float lh = exlocalcurve[lighn]; // / ((lighn) / 1.9f) / 3.61f; //lh between 0 and 0 50 or more + bufexpfin->L[loy - begy][lox - begx] = lh; + } + } + } + + #ifdef _OPENMP #pragma omp parallel for schedule(dynamic,16) diff --git a/rtengine/procparams.cc b/rtengine/procparams.cc index 16f398d9f..07fb7c6ec 100644 --- a/rtengine/procparams.cc +++ b/rtengine/procparams.cc @@ -1040,7 +1040,7 @@ void LocallabParams::setDefaults() getDefaultLHCurve (LHcurve); getDefaultCCCurve (cccurve); getDefaultHHCurve (HHcurve); - getDefaultexCurve (excurve); + // getDefaultexCurve (excurve); } @@ -1162,7 +1162,7 @@ void LocallabParams::getDefaultCCCurve (std::vector &curve) curve.at (i) = v[i - 1]; } } - +/* void LocallabParams::getDefaultexCurve (std::vector &curve) { double v[4] = { 0.00, 0.00, @@ -1178,6 +1178,7 @@ void LocallabParams::getDefaultexCurve (std::vector &curve) } } +*/ void LocallabParams::getCurves (LocretigainCurve &cTgainCurve, LocretigainCurverab &cTgainCurverab, LocLHCurve &lhCurve, LocHHCurve &hhCurve, bool &LHutili, bool &HHutili) const { diff --git a/rtengine/procparams.h b/rtengine/procparams.h index e98fa1f28..c3c0fe4a7 100644 --- a/rtengine/procparams.h +++ b/rtengine/procparams.h @@ -973,7 +973,7 @@ public: static void getDefaultLHCurve (std::vector &curve); static void getDefaultCCCurve (std::vector &curve); static void getDefaultHHCurve (std::vector &curve); - static void getDefaultexCurve (std::vector &curve); +// static void getDefaultexCurve (std::vector &curve); }; diff --git a/rtengine/rtengine.h b/rtengine/rtengine.h index 4395e5cbd..f51afc807 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, 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) {} + 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, std::string ex_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, std::string ex_str, int sp, int maxdat) {} }; diff --git a/rtengine/simpleprocess.cc b/rtengine/simpleprocess.cc index e40d6ae60..04d250a67 100644 --- a/rtengine/simpleprocess.cc +++ b/rtengine/simpleprocess.cc @@ -1129,6 +1129,9 @@ private: std::string *pthstrs; pthstrs = new std::string[maxspot]; + std::string *exstrs; + exstrs = new std::string[maxspot]; + { dataspots[2][0] = params.locallab.circrad; dataspots[3][0] = params.locallab.locX; @@ -1436,6 +1439,31 @@ private: //end local ps + //expos + //Skin curve + int sizex = params.locallab.excurve.size(); + + if (sizex > 69) { + sizex = 69;//to avoid crash + } + + + int s_datcurex[sizsk + 1]; + + for (int j = 0; j < sizex; j++) { + s_datcurex[j] = (int) (1000. * params.locallab.excurve[j]); + } + + std::string ex_str = ""; + + for (int j = 0; j < sizex; j++) { + ex_str = ex_str + std::to_string (s_datcurex[j]) + delim[j]; + } + + exstrs[0] = ex_str + "@"; + + + } // locallutili = false; @@ -1608,6 +1636,24 @@ private: pthstrs[ns] = str3; } + if (spotline.substr (0, pos) == "curveex") { + std::string curstex; + // int longecurh; + std::string strendex = spotline.substr (posend - 1, 1); + // std::size_t poszh = spotline.find (strendh); + // int longeh; + + for (int sh = 0; sh < 69; sh++) { + if (delim[sh] == strendex) { + // longeh = sh + 1; + } + } + + exstrs[ns] = str3; + // sizelh = longeh; + } + + } fich.close(); @@ -1870,12 +1916,29 @@ private: params.locallab.psthreshold.setValues (s_datcps[0], s_datcps[1]); + //expos + int *s_datcex; + s_datcex = new int[70]; + int sizex; + + ipf.strcurv_data (exstrs[sp], s_datcex, sizex); + + + std::vector cexend; + + for (int j = 0; j < sizex; j++) { + cexend.push_back ((double) (s_datcex[j]) / 1000.); + } + + delete [] s_datcex; + 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.excurve.clear(); params.locallab.localTgaincurve = cretiend; params.locallab.llcurve = cllend; @@ -1883,6 +1946,7 @@ private: params.locallab.cccurve = cccend; params.locallab.HHcurve = chhend; params.locallab.skintonescurve = cskend; + params.locallab.excurve = cexend; bool LHutili = false; bool HHutili = false; @@ -1909,6 +1973,12 @@ private: localskutili = true; } + std::string t_curvexref = "3000A0B0C1000D1000E@"; + + if (exstrs[sp].c_str() != t_curvexref && exstrs[sp].c_str() != t_none) { + localexutili = true; + } + CurveFactory::curveLocal (locallutili, params.locallab.llcurve, lllocalcurve, 1); CurveFactory::curveCCLocal (localcutili, params.locallab.cccurve, cclocalcurve, 1); CurveFactory::curveskLocal (localskutili, params.locallab.skintonescurve, sklocalcurve, 1); @@ -1934,7 +2004,8 @@ private: params.locallab.chromaref = chromare; params.locallab.lumaref = lumare; - 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, localskutili, sklocalcurve, hltonecurveloc , shtonecurveloc, tonecurveloc, params.locallab.hueref, params.locallab.chromaref, params.locallab.lumaref); + 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, localskutili, sklocalcurve, localexutili, exlocalcurve, hltonecurveloc , shtonecurveloc, tonecurveloc, params.locallab.hueref, params.locallab.chromaref, params.locallab.lumaref); lllocalcurve.clear(); cclocalcurve.clear(); sklocalcurve.clear(); @@ -1958,6 +2029,8 @@ private: delete [] lhstrs; delete [] ccstrs; delete [] hhstrs; + delete [] skinstrs; + delete [] exstrs; if (params.locallab.inverssha) { diff --git a/rtgui/locallab.cc b/rtgui/locallab.cc index 0ca1654ed..fc81906bc 100644 --- a/rtgui/locallab.cc +++ b/rtgui/locallab.cc @@ -1361,6 +1361,22 @@ bool Locallab::localretComputed_ () ImProcFunctions::strcurv_data (nextps_str2, s_datcps, sizps); psThreshold->setValue (s_datcps[0], s_datcps[1]); + + //exCurve + int *s_datcex; + s_datcex = new int[70]; + int sizex; + ImProcFunctions::strcurv_data (nextex_str2, s_datcex, sizex); + std::vector cex; + + for (int j = 0; j < sizex; j++) { + cex.push_back ((double) (s_datcex[j]) / 1000.); + } + + delete [] s_datcex; + + shape->setCurve (cex); + enableListener (); //update all sliders by this strange process! @@ -1443,6 +1459,10 @@ bool Locallab::localretComputed_ () listener->panelChanged (EvlocallabPastSatThreshold, M ("")); } + if (listener) {//for PSthreshold + listener->panelChanged (Evlocallabshape, M ("")); + } + return false; @@ -1633,8 +1653,8 @@ bool Locallab::localComputed_ () hlcomprthresh->setValue (nextdatasp[67]); shcompr->setValue (nextdatasp[68]); sensiex->setValue (nextdatasp[69]); - - + + double intermed = 0.01 * (double) nextdatasp[64]; hueref->setValue (intermed); chromaref->setValue (nextdatasp[65]); @@ -1743,6 +1763,21 @@ bool Locallab::localComputed_ () psThreshold->setValue (s_datcps[0], s_datcps[1]); + //exCurve + int *s_datcex; + s_datcex = new int[70]; + int sizex; + ImProcFunctions::strcurv_data (nextex_str, s_datcex, sizex); + std::vector cex; + + for (int j = 0; j < sizex; j++) { + cex.push_back ((double) (s_datcex[j]) / 1000.); + } + + delete [] s_datcex; + shape->setCurve (cex); + + enableListener (); //update all sliders by this strange process! @@ -1866,22 +1901,26 @@ bool Locallab::localComputed_ () } //for checkbox - if (listener) {//for PSthreshold + if (listener) {//f listener->panelChanged (EvlocallabProtectSkins, M ("")); } - if (listener) {//for PSthreshold + if (listener) {//fo listener->panelChanged (EvlocallabAvoidColorShift, M ("")); } - if (listener) {//for PSthreshold + if (listener) {//for listener->panelChanged (EvlocallabPastSatTog, M ("")); } + if (listener) {//for + listener->panelChanged (Evlocallabshape, 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, std::string sk_str, std::string ps_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, std::string ex_str, int sp, int maxdat) { for (int i = 2; i < 73; i++) { nextdatasp[i] = datasp[i][sp]; @@ -1894,12 +1933,13 @@ void Locallab::localChanged (int **datasp, std::string datastr, std::string ll_ nexthh_str = hh_str; nextsk_str = sk_str; nextps_str = ps_str; + nextex_str = ex_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, std::string sk_str, std::string ps_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, std::string ex_str, int sp, int maxdat) { nextlength = maxdat; nextstr2 = datastr; @@ -1909,6 +1949,7 @@ void Locallab::localretChanged (int **datasp, std::string datastr, std::string nexthh_str2 = hh_str; nextsk_str2 = sk_str; nextps_str2 = ps_str; + nextex_str2 = ex_str; g_idle_add (localretChangedUI, this); } diff --git a/rtgui/locallab.h b/rtgui/locallab.h index 43687fdd8..4208bfde0 100644 --- a/rtgui/locallab.h +++ b/rtgui/locallab.h @@ -225,6 +225,8 @@ private: std::string nextsk_str2; std::string nextps_str; std::string nextps_str2; + std::string nextex_str; + std::string nextex_str2; double draggedPointOldAngle; double draggedPointAdjusterAngle; @@ -270,8 +272,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, 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); + 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, std::string ex_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, std::string ex_str, int sp, int maxdat); bool localComputed_ (); bool localretComputed_ (); void setEditProvider (EditDataProvider* provider);