diff --git a/rtengine/dcrop.cc b/rtengine/dcrop.cc index d42b90d2e..6b030a701 100644 --- a/rtengine/dcrop.cc +++ b/rtengine/dcrop.cc @@ -890,894 +890,51 @@ void Crop::update(int todo) // bool tyty = false; int maxspot = settings->nspot + 1; - // TODO Locallab - /* if (needslocal) { - // if (tyty ) { - - std::string mdfive = getMD5(parent->imgsrc->getFileName()); - - Glib::ustring pop = options.cacheBaseDir + "/mip/"; - - Glib::ustring datalab; - - if (options.mip == MI_opt) { - datalab = pop + Glib::path_get_basename(parent->imgsrc->getFileName() + "." + mdfive + ".mip"); - } - - if (options.mip == MI_prev) { - datalab = parent->imgsrc->getFileName() + ".mip"; - } - - - ifstream fich(datalab, ios::in); - - if (fich && parent->versionmip != 0) {//to avoid crash in some cases - // int **dataspotd; - - int realspot = params.locallab.nbspot; - // bool tata = true; - - for (int sp = 1; sp < maxspot; sp++) { - if (sp != realspot) { - - params.locallab.circrad = parent->circrads[sp] ; - params.locallab.locX = parent->locx[sp] ; - params.locallab.locY = parent->locy[sp]; - params.locallab.locYT = parent->locyt[sp]; - params.locallab.locXL = parent->locxl[sp]; - params.locallab.centerX = parent->centerx[sp]; - params.locallab.centerY = parent->centery[sp]; - params.locallab.lightness = parent->lights[sp]; - params.locallab.contrast = parent->contrs[sp]; - params.locallab.chroma = parent->chroms[sp]; - params.locallab.sensi = parent->sensis[sp]; - params.locallab.transit = parent->transits[sp]; - - if (parent->inverss[sp] == 0) { - params.locallab.invers = false; - } else { - params.locallab.invers = true; - } - - if (parent->smeths[sp] == 0) { - params.locallab.Smethod = "IND" ; - } else if (parent->smeths[sp] == 1) { - params.locallab.Smethod = "SYM" ; - } else if (parent->smeths[sp] == 2) { - params.locallab.Smethod = "INDSL"; - } else if (parent->smeths[sp] == 3) { - params.locallab.Smethod = "SYMSL"; - } - - params.locallab.radius = parent->radiuss[sp]; - params.locallab.strength = parent->strengths[sp]; - params.locallab.sensibn = parent->sensibns[sp]; - - if (parent->inversrads[sp] == 0) { - params.locallab.inversrad = false; - } else { - params.locallab.inversrad = true; - } - - params.locallab.str = parent->strs[sp]; - params.locallab.chrrt = parent->chrrts[sp]; - params.locallab.neigh = parent->neighs[sp]; - params.locallab.vart = parent->varts[sp]; - params.locallab.sensih = parent->sensihs[sp]; - - if (parent->inversrets[sp] == 0) { - params.locallab.inversret = false; - } else { - params.locallab.inversret = true; - } - - if (parent->retinexs[sp] == 0) { - params.locallab.retinexMethod = "low" ; - } else if (parent->retinexs[sp] == 1) { - params.locallab.retinexMethod = "uni" ; - } else if (parent->retinexs[sp] == 2) { - params.locallab.retinexMethod = "high"; - } - - params.locallab.sharradius = parent->sharradiuss[sp]; - params.locallab.sharamount = parent->sharamounts[sp]; - params.locallab.shardamping = parent->shardampings[sp]; - params.locallab.shariter = parent->shariters[sp]; - params.locallab.sensisha = parent->sensishas[sp]; - - if (parent->inversshas[sp] == 0) { - params.locallab.inverssha = false; - } else { - params.locallab.inverssha = true; - } - - if (parent->qualitys[sp] == 0) { - params.locallab.qualityMethod = "std" ; - } else if (parent->qualitys[sp] == 1) { - params.locallab.qualityMethod = "enh" ; - } else if (parent->qualitys[sp] == 2) { - params.locallab.qualityMethod = "enhden" ; - } - - params.locallab.thres = parent->thress[sp]; - params.locallab.proxi = parent->proxis[sp]; - - params.locallab.noiselumf = parent->noiselumfs[sp]; - params.locallab.noiselumc = parent->noiselumcs[sp]; - params.locallab.noisechrof = parent->noisechrofs[sp]; - params.locallab.noisechroc = parent->noisechrocs[sp]; - params.locallab.mult[0] = parent->mult0s[sp]; - params.locallab.mult[1] = parent->mult1s[sp]; - params.locallab.mult[2] = parent->mult2s[sp]; - params.locallab.mult[3] = parent->mult3s[sp]; - params.locallab.mult[4] = parent->mult4s[sp]; - params.locallab.threshold = parent->thresholds[sp]; - params.locallab.sensicb = parent->sensicbs[sp]; - - if (parent->activlums[sp] == 0) { - params.locallab.activlum = false; - } else { - params.locallab.activlum = true; - } - - params.locallab.stren = parent->strens[sp]; - params.locallab.gamma = parent->gammas[sp]; - params.locallab.estop = parent->estops[sp]; - params.locallab.scaltm = parent->scaltms[sp]; - params.locallab.rewei = parent->reweis[sp]; - params.locallab.sensitm = parent->sensitms[sp]; - params.locallab.retrab = parent->retrabs[sp]; - - if (parent->curvactivs[sp] == 0) { - params.locallab.curvactiv = false; - } else { - params.locallab.curvactiv = true; - } - - if (parent->qualitycurves[sp] == 0) { - params.locallab.qualitycurveMethod = "none" ; - } else if (parent->qualitycurves[sp] == 1) { - params.locallab.qualitycurveMethod = "std" ; - } else if (parent->qualitycurves[sp] == 2) { - 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; - } - - - params.locallab.expcomp = parent->expcomps[sp]; - params.locallab.black = parent->blacks[sp]; - params.locallab.hlcompr = parent->hlcomprs[sp]; - params.locallab.hlcomprthresh = parent->hlcomprthreshs[sp]; - params.locallab.shcompr = parent->shcomprs[sp]; - params.locallab.sensiex = parent->sensiexs[sp]; - - params.locallab.centerXbuf = parent->centerxbufs[sp]; - params.locallab.centerYbuf = parent->centerybufs[sp]; - params.locallab.adjblur = parent->adjblurs[sp]; - - if (parent->cutpasts[sp] == 0) { - params.locallab.cutpast = false; - } else { - params.locallab.cutpast = true; - } - - params.locallab.chromacbdl = parent->chromacbdls[sp]; - - if (parent->lastdusts[sp] == 0) { - params.locallab.lastdust = false; - } else { - params.locallab.lastdust = true; - } - - if (parent->blurmets[sp] == 0) { - params.locallab.blurMethod = "norm" ; - } else if (parent->blurmets[sp] == 1) { - params.locallab.blurMethod = "inv" ; - } else if (parent->blurmets[sp] == 2) { - params.locallab.blurMethod = "enh" ; - } - - if (parent->dustmets[sp] == 0) { - params.locallab.dustMethod = "cop" ; - } else if (parent->dustmets[sp] == 1) { - params.locallab.dustMethod = "mov" ; - } else if (parent->dustmets[sp] == 2) { - params.locallab.dustMethod = "pas" ; - } - - if (parent->exclumets[sp] == 0) { - params.locallab.Exclumethod = "norm" ; - } else if (parent->exclumets[sp] == 1) { - params.locallab.Exclumethod = "exc" ; - } - - params.locallab.sensiexclu = parent->sensiexclus[sp]; - params.locallab.struc = parent->strucs[sp]; - params.locallab.warm = parent->warms[sp]; - params.locallab.noiselumdetail = parent->noiselumdetails[sp]; - params.locallab.noisechrodetail = parent->noisechrodetails[sp]; - params.locallab.sensiden = parent->sensidens[sp]; - - if (parent->expdenois[sp] == 0) { - params.locallab.expdenoi = false; - } else { - params.locallab.expdenoi = true; - } - - if (parent->expcolors[sp] == 0) { - params.locallab.expcolor = false; - } else { - params.locallab.expcolor = true; - } - - if (parent->expvibrances[sp] == 0) { - params.locallab.expvibrance = false; - } else { - params.locallab.expvibrance = true; - } - - if (parent->expblurs[sp] == 0) { - params.locallab.expblur = false; - } else { - params.locallab.expblur = true; - } - - if (parent->exptonemaps[sp] == 0) { - params.locallab.exptonemap = false; - } else { - params.locallab.exptonemap = true; - } - - if (parent->expretis[sp] == 0) { - params.locallab.expreti = false; - } else { - params.locallab.expreti = true; - } - - if (parent->expsharps[sp] == 0) { - params.locallab.expsharp = false; - } else { - params.locallab.expsharp = true; - } - - if (parent->expcbdls[sp] == 0) { - params.locallab.expcbdl = false; - } else { - params.locallab.expcbdl = true; - } - - if (parent->expexposes[sp] == 0) { - params.locallab.expexpose = false; - } else { - params.locallab.expexpose = true; - } - - params.locallab.bilateral = parent->bilaterals[sp]; - params.locallab.noiselequal = parent->noiselequals[sp]; - - if (parent->shapemets[sp] == 0) { - params.locallab.shapemethod = "ELI" ; - } else if (parent->shapemets[sp] == 1) { - params.locallab.shapemethod = "RECT" ; - } - - std::vector cretie; - - for (int j = 0; j < parent->sizeretics[sp]; j++) { - cretie.push_back((double)(parent->reticurvs[sp * 500 + j]) / 1000.); - } - - params.locallab.localTgaincurve.clear(); - params.locallab.localTgaincurve = cretie; - - std::vector llc; - - for (int j = 0; j < parent->sizellcs[sp]; j++) { - llc.push_back((double)(parent->llcurvs[sp * 500 + j]) / 1000.); - } - - params.locallab.llcurve.clear(); - params.locallab.llcurve = llc; - - std::vector ccc; - - for (int j = 0; j < parent->sizecccs[sp]; j++) { - ccc.push_back((double)(parent->cccurvs[sp * 500 + j]) / 1000.); - } - - params.locallab.cccurve.clear(); - params.locallab.cccurve = ccc; - - std::vector lhc; - - for (int j = 0; j < parent->sizelhcs[sp]; j++) { - lhc.push_back((double)(parent->lhcurvs[sp * 500 + j]) / 1000.); - } - - params.locallab.LHcurve.clear(); - params.locallab.LHcurve = lhc; - - std::vector hhc; - - for (int j = 0; j < parent->sizehhcs[sp]; j++) { - hhc.push_back((double)(parent->hhcurvs[sp * 500 + j]) / 1000.); - } - - 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]); - - 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); - localcutili = false; - 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 ecomp = params.locallab.expcomp; - double black = params.locallab.black; - double hlcompr = params.locallab.hlcompr; - double hlcomprthresh = params.locallab.hlcomprthresh; - double shcompr = params.locallab.shcompr; - double br = params.locallab.lightness; - - CurveFactory::complexCurvelocal(ecomp, black / 65535., hlcompr, hlcomprthresh, shcompr, br, - hltonecurveloc2, shtonecurveloc2, tonecurveloc2, lightCurveloc2, - sca); - - params.locallab.huerefblur = (parent->huerefblurs[sp]) / 100.f; - params.locallab.hueref = (parent->huerefs[sp]) / 100.f; - params.locallab.chromaref = parent->chromarefs[sp]; - params.locallab.lumaref = parent->lumarefs[sp]; - params.locallab.sobelref = parent->sobelrefs[sp]; - - parent->ipf.Lab_Local(1, maxspot, sp, parent->huerefs, parent->sobelrefs, parent->centerx, parent->centery, (float**)shbuffer, labnCrop, labnCrop, reservCrop, cropx / skip, cropy / skip, skips(parent->fw, skip), skips(parent->fh, skip), skip, locRETgainCurve, lllocalcurve2, - loclhCurve, lochhCurve, LHutili, HHutili, cclocalcurve2, localskutili, sklocalcurve2, localexutili, exlocalcurve2, hltonecurveloc2, shtonecurveloc2, tonecurveloc2, lightCurveloc2, params.locallab.huerefblur, params.locallab.hueref, params.locallab.chromaref, params.locallab.lumaref, params.locallab.sobelref); - lllocalcurve2.clear(); - cclocalcurve2.clear(); - sklocalcurve2.clear(); - exlocalcurve2.clear(); - - if (skip <= 2) { - usleep(settings->cropsleep); //wait to avoid crash when crop 100% and move window - } - } - } - - - - int sp ; - sp = realspot; - locallutili = false; - - parent->sps[sp] = sp; - parent->circrads[sp] = params.locallab.circrad = parent->circrads[0]; - parent->locx[sp] = params.locallab.locX = parent->locx[0]; - parent->locy[sp] = params.locallab.locY = parent->locy[0]; - parent->locyt[sp] = params.locallab.locYT = parent->locyt[0]; - parent->locxl[sp] = params.locallab.locXL = parent->locxl[0]; - parent->centerx[sp] = params.locallab.centerX = parent->centerx[0]; - parent->centery[sp] = params.locallab.centerY = parent->centery[0]; - parent->lights[sp] = params.locallab.lightness = parent->lights[0]; - parent->contrs[sp] = params.locallab.contrast = parent->contrs[0]; - parent->chroms[sp] = params.locallab.chroma = parent->chroms[0]; - parent->sensis[sp] = params.locallab.sensi = parent->sensis[0]; - parent->transits[sp] = params.locallab.transit = parent->transits[0]; - - if (parent->inverss[0] == 0) { - params.locallab.invers = false; - parent->inverss[sp] = 0; - - } else { - params.locallab.invers = true; - parent->inverss[sp] = 1; - - } - - if (parent->smeths[0] == 0) { - params.locallab.Smethod = "IND" ; - parent->smeths[sp] = 0; - - } else if (parent->smeths[0] == 1) { - params.locallab.Smethod = "SYM" ; - parent->smeths[sp] = 1; - - } else if (parent->smeths[0] == 2) { - params.locallab.Smethod = "INDSL"; - parent->smeths[2] = 0; - - - } else if (parent->smeths[0] == 3) { - params.locallab.Smethod = "SYMSL"; - parent->smeths[sp] = 3; - - } - - params.locallab.radius = parent->radiuss[0]; - params.locallab.strength = parent->strengths[0]; - params.locallab.sensibn = parent->sensibns[0]; - - parent->radiuss[sp] = params.locallab.radius; - parent->strengths[sp] = params.locallab.strength; - parent->sensibns[sp] = params.locallab.sensibn; - - if (parent->inversrads[0] == 0) { - params.locallab.inversrad = false; - parent->inversrads[sp] = 0; - } else { - params.locallab.inversrad = true; - parent->inversrads[sp] = 1; - } - - parent->strs[sp] = params.locallab.str = parent->strs[0]; - parent->chrrts[sp] = params.locallab.chrrt = parent->chrrts[0]; - parent->neighs[sp] = params.locallab.neigh = parent->neighs[0]; - parent->varts[sp] = params.locallab.vart = parent->varts[0]; - parent->sensihs[sp] = params.locallab.sensih = parent->sensihs[0]; - - if (parent->inversrets[0] == 0) { - params.locallab.inversret = false; - parent->inversrets[sp] = 0; - } else { - params.locallab.inversret = true; - parent->inversrets[sp] = 1; - - } - - if (parent->retinexs[sp] == 0) { - params.locallab.retinexMethod = "low" ; - parent->retinexs[sp] = 0; - } else if (parent->retinexs[sp] == 1) { - params.locallab.retinexMethod = "uni" ; - parent->retinexs[sp] = 1; - - } else if (parent->retinexs[sp] == 2) { - params.locallab.retinexMethod = "high"; - parent->retinexs[sp] = 2; - - } - - parent->sharradiuss[sp] = params.locallab.sharradius = parent->sharradiuss[0]; - - parent->sharamounts[sp] = params.locallab.sharamount = parent->sharamounts[0]; - parent->shardampings[sp] = params.locallab.shardamping = parent->shardampings[0]; - parent->shariters[sp] = params.locallab.shariter = parent->shariters[0]; - parent->sensishas[sp] = params.locallab.sensisha = parent->sensishas[0]; - - if (parent->inversshas[0] == 0) { - params.locallab.inverssha = false; - parent->inversshas[sp] = 0; - } else { - params.locallab.inverssha = true; - parent->inversshas[sp] = 1; - - } - - if (parent->qualitys[sp] == 0) { - params.locallab.qualityMethod = "std" ; - parent->qualitys[sp] = 0; - } else if (parent->qualitys[sp] == 1) { - params.locallab.qualityMethod = "enh" ; - parent->qualitys[sp] = 1; - } else if (parent->qualitys[sp] == 2) { - params.locallab.qualityMethod = "enhden" ; - parent->qualitys[sp] = 2; - } - - parent->thress[sp] = params.locallab.thres = parent->thress[0]; - parent->proxis[sp] = params.locallab.proxi = parent->proxis[0]; - - parent->noiselumfs[sp] = params.locallab.noiselumf = parent->noiselumfs[0]; - parent->noiselumcs[sp] = params.locallab.noiselumc = parent->noiselumcs[0]; - parent->noisechrofs[sp] = params.locallab.noisechrof = parent->noisechrofs[0]; - parent->noisechrocs[sp] = params.locallab.noisechroc = parent->noisechrocs[0]; - parent->mult0s[sp] = params.locallab.mult[0] = parent->mult0s[0]; - parent->mult1s[sp] = params.locallab.mult[1] = parent->mult1s[0]; - parent->mult2s[sp] = params.locallab.mult[2] = parent->mult2s[0]; - parent->mult3s[sp] = params.locallab.mult[3] = parent->mult3s[0]; - parent->mult4s[sp] = params.locallab.mult[4] = parent->mult4s[0]; - parent->thresholds[sp] = params.locallab.threshold = parent->thresholds[0]; - parent->sensicbs[sp] = params.locallab.sensicb = parent->sensicbs[0]; - - if (parent->activlums[0] == 0) { - params.locallab.activlum = false; - parent->activlums[sp] = 0; - } else { - params.locallab.activlum = true; - parent->activlums[sp] = 1; - - } - - parent->strens[sp] = params.locallab.stren = parent->strens[0]; - parent->gammas[sp] = params.locallab.gamma = parent->gammas[0]; - parent->estops[sp] = params.locallab.estop = parent->estops[0]; - parent->scaltms[sp] = params.locallab.scaltm = parent->scaltms[0]; - parent->reweis[sp] = params.locallab.rewei = parent->reweis[0]; - parent->sensitms[sp] = params.locallab.sensitm = parent->sensitms[0]; - parent->retrabs[sp] = params.locallab.retrab = parent->retrabs[0]; - - if (parent->curvactivs[0] == 0) { - params.locallab.curvactiv = false; - parent->curvactivs[sp] = 0; - - } else { - params.locallab.curvactiv = true; - parent->curvactivs[sp] = 1; - - } - - if (parent->qualitycurves[sp] == 0) { - params.locallab.qualitycurveMethod = "none" ; - parent->qualitycurves[sp] = 0; - } else if (parent->qualitycurves[sp] == 1) { - params.locallab.qualitycurveMethod = "std" ; - parent->qualitycurves[sp] = 1; - } else if (parent->qualitycurves[sp] == 2) { - params.locallab.qualitycurveMethod = "enh" ; - 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; - - } - - parent->expcomps[sp] = params.locallab.expcomp = parent->expcomps[0]; - parent->blacks[sp] = params.locallab.black = parent->blacks[0]; - parent->hlcomprs[sp] = params.locallab.hlcompr = parent->hlcomprs[0]; - parent->hlcomprthreshs[sp] = params.locallab.hlcomprthresh = parent->hlcomprthreshs[0]; - parent->shcomprs[sp] = params.locallab.shcompr = parent->shcomprs[0]; - parent->sensiexs[sp] = params.locallab.sensiex = parent->sensiexs[0]; - - parent->centerxbufs[sp] = params.locallab.centerXbuf = parent->centerxbufs[0]; - parent->centerybufs[sp] = params.locallab.centerYbuf = parent->centerybufs[0]; - parent->adjblurs[sp] = params.locallab.adjblur = parent->adjblurs[0]; - - if (parent->cutpasts[0] == 0) { - params.locallab.cutpast = false; - parent->cutpasts[sp] = 0; - } else { - params.locallab.cutpast = true; - parent->cutpasts[sp] = 1; - - } - - parent->chromacbdls[sp] = params.locallab.chromacbdl = parent->chromacbdls[0]; - - if (parent->lastdusts[0] == 0) { - params.locallab.lastdust = false; - parent->lastdusts[sp] = 0; - } else { - params.locallab.lastdust = true; - parent->lastdusts[sp] = 1; - - } - - if (parent->blurmets[sp] == 0) { - params.locallab.blurMethod = "norm" ; - parent->qualitycurves[sp] = 0; - } else if (parent->blurmets[sp] == 1) { - params.locallab.blurMethod = "inv" ; - parent->blurmets[sp] = 1; - } else if (parent->blurmets[sp] == 2) { - params.locallab.blurMethod = "sym" ; - parent->blurmets[sp] = 2; - } - - if (parent->dustmets[sp] == 0) { - params.locallab.dustMethod = "cop" ; - parent->dustmets[sp] = 0; - } else if (parent->dustmets[sp] == 1) { - params.locallab.dustMethod = "mov" ; - parent->dustmets[sp] = 1; - } else if (parent->dustmets[sp] == 2) { - params.locallab.dustMethod = "pas" ; - parent->dustmets[sp] = 2; - } - - if (parent->exclumets[sp] == 0) { - params.locallab.Exclumethod = "norm" ; - parent->exclumets[sp] = 0; - } else if (parent->exclumets[sp] == 1) { - params.locallab.Exclumethod = "exc" ; - parent->exclumets[sp] = 1; - } - - parent->sensiexclus[sp] = params.locallab.sensiexclu = parent->sensiexclus[0]; - parent->strucs[sp] = params.locallab.struc = parent->strucs[0]; - parent->warms[sp] = params.locallab.warm = parent->warms[0]; - parent->noiselumdetails[sp] = params.locallab.noiselumdetail = parent->noiselumdetails[0]; - parent->noisechrodetails[sp] = params.locallab.noisechrodetail = parent->noisechrodetails[0]; - parent->sensidens[sp] = params.locallab.sensiden = parent->sensidens[0]; - - if (parent->expdenois[0] == 0) { - params.locallab.expdenoi = false; - parent->expdenois[sp] = 0; - - } else { - params.locallab.expdenoi = true; - parent->expdenois[sp] = 1; - - } - - if (parent->expcolors[0] == 0) { - params.locallab.expcolor = false; - parent->expcolors[sp] = 0; - - } else { - params.locallab.expcolor = true; - parent->expcolors[sp] = 1; - - } - - if (parent->expvibrances[0] == 0) { - params.locallab.expvibrance = false; - parent->expvibrances[sp] = 0; - - } else { - params.locallab.expvibrance = true; - parent->expvibrances[sp] = 1; - - } - - if (parent->expblurs[0] == 0) { - params.locallab.expblur = false; - parent->expblurs[sp] = 0; - - } else { - params.locallab.expblur = true; - parent->expblurs[sp] = 1; - - } - - if (parent->exptonemaps[0] == 0) { - params.locallab.exptonemap = false; - parent->exptonemaps[sp] = 0; - - } else { - params.locallab.exptonemap = true; - parent->exptonemaps[sp] = 1; - - } - - if (parent->expretis[0] == 0) { - params.locallab.expreti = false; - parent->expretis[sp] = 0; - - } else { - params.locallab.expreti = true; - parent->expretis[sp] = 1; - - } - - if (parent->expsharps[0] == 0) { - params.locallab.expsharp = false; - parent->expsharps[sp] = 0; - - } else { - params.locallab.expsharp = true; - parent->expsharps[sp] = 1; - - } - - if (parent->expcbdls[0] == 0) { - params.locallab.expcbdl = false; - parent->expcbdls[sp] = 0; - - } else { - params.locallab.expcbdl = true; - parent->expcbdls[sp] = 1; - - } - - if (parent->expexposes[0] == 0) { - params.locallab.expexpose = false; - parent->expexposes[sp] = 0; - - } else { - params.locallab.expexpose = true; - parent->expexposes[sp] = 1; - - } - - parent->bilaterals[sp] = params.locallab.bilateral = parent->bilaterals[0]; - parent->noiselequals[sp] = params.locallab.noiselequal = parent->noiselequals[0]; - - if (parent->shapemets[sp] == 0) { - params.locallab.shapemethod = "ELI" ; - parent->shapemets[sp] = 0; - } else if (parent->shapemets[sp] == 1) { - params.locallab.shapemethod = "RECT" ; - parent->shapemets[sp] = 1; - } - - std::vector ccret; - - for (int j = 0; j < parent->sizeretics[sp]; j++) { - ccret.push_back((double)(parent->reticurvs[0 * 500 + j]) / 1000.); - parent->reticurvs[sp * 500 + j] = parent->reticurvs[0 * 500 + j]; - } - - params.locallab.localTgaincurve.clear(); - params.locallab.localTgaincurve = ccret; - - std::vector llcL; - - for (int j = 0; j < parent->sizellcs[sp]; j++) { - llcL.push_back((double)(parent->llcurvs[0 * 500 + j]) / 1000.); - parent->llcurvs[sp * 500 + j] = parent->llcurvs[0 * 500 + j] ; - } - - params.locallab.llcurve.clear(); - params.locallab.llcurve = llcL; - - std::vector cccL; - - for (int j = 0; j < parent->sizecccs[sp]; j++) { - cccL.push_back((double)(parent->cccurvs[0 * 500 + j]) / 1000.); - parent->cccurvs[sp * 500 + j] = parent->cccurvs[0 * 500 + j] ; - } - - params.locallab.cccurve.clear(); - params.locallab.cccurve = cccL; - - std::vector lhcL; - - for (int j = 0; j < parent->sizelhcs[sp]; j++) { - lhcL.push_back((double)(parent->lhcurvs[0 * 500 + j]) / 1000.); - parent->lhcurvs[sp * 500 + j] = parent->lhcurvs[0 * 500 + j] ; - } - - params.locallab.LHcurve.clear(); - params.locallab.LHcurve = lhcL; - - std::vector hhcL; - - for (int j = 0; j < parent->sizehhcs[sp]; j++) { - hhcL.push_back((double)(parent->hhcurvs[0 * 500 + j]) / 1000.); - parent->hhcurvs[sp * 500 + j] = parent->hhcurvs[0 * 500 + j] ; - } - - 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]); - - - 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); + for (int sp = 0; sp < params.locallab.nbspot; sp++) { + locRETgainCurve.Set(params.locallab.localTgaincurve.at(sp)); + loclhCurve.Set(params.locallab.LHcurve.at(sp), LHutili); + lochhCurve.Set(params.locallab.HHcurve.at(sp), HHutili); locallutili = false; + CurveFactory::curveLocal(locallutili, params.locallab.llcurve.at(sp), lllocalcurve2, sca); localcutili = false; + CurveFactory::curveCCLocal(localcutili, params.locallab.cccurve.at(sp), cclocalcurve2, sca); + //localskutili = false; + CurveFactory::curveskLocal(localskutili, params.locallab.skintonescurve.at(sp), sklocalcurve2, sca); + CurveFactory::curveexLocal(localexutili, params.locallab.excurve.at(sp), exlocalcurve2, sca); - 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 ecomp = params.locallab.expcomp; - double black = params.locallab.black; - double hlcompr = params.locallab.hlcompr; - double hlcomprthresh = params.locallab.hlcomprthresh; - double shcompr = params.locallab.shcompr; - double br = params.locallab.lightness; + double ecomp = params.locallab.expcomp.at(sp); + double black = params.locallab.black.at(sp); + double hlcompr = params.locallab.hlcompr.at(sp); + double hlcomprthresh = params.locallab.hlcomprthresh.at(sp); + double shcompr = params.locallab.shcompr.at(sp); + double br = params.locallab.lightness.at(sp); CurveFactory::complexCurvelocal(ecomp, black / 65535., hlcompr, hlcomprthresh, shcompr, br, hltonecurveloc2, shtonecurveloc2, tonecurveloc2, lightCurveloc2, sca); - params.locallab.huerefblur = (parent->huerefblurs[sp]) / 100.f; - params.locallab.hueref = (parent->huerefs[sp]) / 100.f; - params.locallab.chromaref = parent->chromarefs[sp]; - params.locallab.lumaref = parent->lumarefs[sp]; - params.locallab.sobelref = parent->sobelrefs[sp]; - parent->ipf.Lab_Local(1, maxspot, sp, parent->huerefs, parent->sobelrefs, parent->centerx, parent->centery, (float**)shbuffer, labnCrop, labnCrop, reservCrop, cropx / skip, cropy / skip, skips(parent->fw, skip), skips(parent->fh, skip), skip, locRETgainCurve, lllocalcurve2, loclhCurve, lochhCurve, - LHutili, HHutili, cclocalcurve2, localskutili, sklocalcurve2, localexutili, exlocalcurve2, hltonecurveloc2, shtonecurveloc2, tonecurveloc2, lightCurveloc2, params.locallab.huerefblur, params.locallab.hueref, params.locallab.chromaref, params.locallab.lumaref, params.locallab.sobelref); + double huere, chromare, lumare, huerefblu, sobelre; + huerefblu = parent->huerefblurs[sp]; + huere = parent->huerefs[sp]; + chromare = parent->chromarefs[sp]; + lumare = parent->lumarefs[sp]; + sobelre = parent->sobelrefs[sp]; + + parent->ipf.Lab_Local(1, maxspot, sp, parent->huerefs, parent->sobelrefs, parent->centerx, parent->centery, (float**)shbuffer, labnCrop, labnCrop, reservCrop, cropx / skip, cropy / skip, skips(parent->fw, skip), skips(parent->fh, skip), skip, locRETgainCurve, lllocalcurve2, + loclhCurve, lochhCurve, LHutili, HHutili, cclocalcurve2, localskutili, sklocalcurve2, localexutili, exlocalcurve2, hltonecurveloc2, shtonecurveloc2, tonecurveloc2, lightCurveloc2, huerefblu, huere, chromare, lumare, sobelre); lllocalcurve2.clear(); cclocalcurve2.clear(); sklocalcurve2.clear(); exlocalcurve2.clear(); - + if (skip <= 2) { + usleep(settings->cropsleep); //wait to avoid crash when crop 100% and move window + } } } - */ // int moderetinex; // parent->ipf.MSR(labnCrop, labnCrop->W, labnCrop->H, 1); diff --git a/rtengine/improccoordinator.cc b/rtengine/improccoordinator.cc index fb48c7e5d..c5dadc94e 100644 --- a/rtengine/improccoordinator.cc +++ b/rtengine/improccoordinator.cc @@ -280,6 +280,7 @@ DetailedCrop* ImProcCoordinator::createCrop(::EditDataProvider *editDataProvider // cropCall: calling crop, used to prevent self-updates ...doesn't seem to be used void ImProcCoordinator::updatePreviewImage(int todo, Crop* cropCall) { + // TODO Locallab printf printf("updatePreviewImage\n"); MyMutex::MyLock processingLock(mProcessing); @@ -775,7 +776,10 @@ void ImProcCoordinator::updatePreviewImage(int todo, Crop* cropCall) int maxspot = settings->nspot + 1; progress("Applying Color Boost...", 100 * readyphase / numofphases); - // TODO Locallab + //************************************************************* + // locallab + //************************************************************* + if (params.locallab.enabled) { /* * This file is part of RawTherapee. @@ -795,2899 +799,87 @@ void ImProcCoordinator::updatePreviewImage(int todo, Crop* cropCall) * You should have received a copy of the GNU General Public License * along with RawTherapee. If not, see . * 2017 2018 Jacques Desmis + * 2018 Pierre Cabrera */ - /* - //********************************************************* - //advertissment - //we can probably put all these function outside main process - // but for now, I think it s mode readable - // we have similar process in dcrop. and simpleprocess.cc - // see rawpedia for all "fantaisies" - // all this code is probably not optimal...but actually it run :) - //there are probably errors... - //*********************************************************** - - // Get image file MD5 - std::string mdfive = getMD5(imgsrc->getFileName()); - - // Check if new image file has been loaded - bool newimage = false; - - if (prevmdfive == "" || prevmdfive != mdfive) { - printf("New image loaded\n"); - newimage = true; - prevmdfive = mdfive; - } - - // Check if destination folder is writable and get .mip file path - if (newimage) { // To avoid systematic access to hard disk - bool isascii = true; - Glib::ustring datainterm = imgsrc->getFileName() + ".ii";//extansion ii arbitrary to test if mip file is possible - - ofstream finterm(datainterm, ios::out); - - if (finterm.fail()) { - printf("Non ascii Mip file possible..switch to Profiles\n"); - isascii = false; - } else { - printf("ascii Mip file possible!\n"); - } - - finterm.close(); - - if (isascii == true) { - if (std::remove(datainterm.c_str()) != 0) { - perror("Error deleting test ii file"); - } else { - puts("Test ii file successfully deleted"); - } - } - - Glib::ustring pop = options.cacheBaseDir + "/mip/"; - - if (options.mip == MI_opt || !isascii) { - datal = pop + Glib::path_get_basename(imgsrc->getFileName() + "." + mdfive + ".mip"); - } - - if (options.mip == MI_prev && isascii) {//&& isascii - datal = imgsrc->getFileName() + ".mip"; - } - } - - printf("mip files in=%s\n", datal.c_str()); - */ - /* - //test to see if wofstream and wifstream works with NON ASCII, but it's bad - wofstream test(datal, ios::out); - if(test.fail()) printf("ca va pas\n"); - else ("ca va bien\n"); - test.close(); - */ - /* - ifstream fic0(datal, ios::in); - - // if(! fic0.fail()) { float **shbuffer = nullptr; - versionmip = 0; - // int maxdat; int sca = 1; - //string delim ==> delimiter to separate integer in a string, 70 is largely enough for curves : noramlly 3 to 21 must be suffisant - //curious method, but I am a poor informatic scientist... - std::string delim[69] = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", - "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", - "&", "#", "{", "[", "]", "}", "$", "*", "?", ">", "!", ";", "<", "(", ")", "+", "-" - }; - - - maxdata = 102; //101 10023 //100 10022 //99 10021 // 90 10020 //88 10019//87 10018 //86 10017 //85 10016;// 82 10015//78;//73 for 10011 - //same value in simpleprocess.cc - //same value in locallab.h for int nextdatasp[102];//102 = maxdata - - if (fic0) { - //find current version mip - std::string line; - std::string spotline; - // int cont = 0; - - while (getline(fic0, line)) { - spotline = line; - std::size_t pos = spotline.find("="); - std::size_t posend = spotline.find("@"); //in case of for futur use - - if (spotline.substr(0, pos) == "Mipversion") { - std::string strversion = spotline.substr(pos + 1, (posend - pos)); - versionmip = std::stoi(strversion.c_str()); - } - - - } - - fic0.close(); - } - - printf("current mipvers=%i\n", versionmip); - ifstream fic(datal, ios::in); - - - - if (fic.fail() || versionmip == 0 || params.locallab.nbspot == 0) { //initialize mip with default values if no file or old file to prevent crash - - ofstream fic(datal, ios::out | ios::trunc); // ouverture en écriture avec effacement du fichier ouvert - - if (params.locallab.nbspot == 0) { - params.locallab.nbspot = 1; - } - - - if (fic) { - mipver = 10024;//to actualize for each change, must be change also at the end just before save all datas mip files - - //*************************************************************************************** - //initialize new values when first utilisation of Locallab. Prepare creation of Mip files - //**************************************************************************************** - for (int sp = 1; sp < maxspot; sp++) { // spots default - int t_sp = sp; - int t_mipversion = mipver;//new value for each change neads here, if it is first use - int t_circrad = 18; - int t_locX = 250; - int t_locY = 250; - int t_locYT = 250; - int t_locXL = 250; - int t_centerX = 0; - int t_centerY = 0; - int t_lightness = 0; - int t_contrast = 0; - int t_chroma = 0; - int t_sensi = 19; - int t_transit = 60; - int t_invers = 0; - int t_Smeth = 0; - int t_currentspot = 1; - int t_radius = 1; - int t_strength = 0; - int t_sensibn = 40; - int t_inversrad = 0; - int t_str = 0; - int t_chrrt = 0; - int t_neigh = 50; - int t_vart = 200; - int t_sensih = 19; - int t_inversret = 0; - int t_retinexMethod = 2; - int t_sharradius = 40; - int t_sharamount = 75; - int t_shardamping = 75; - int t_shariter = 30; - int t_sensisha = 19; - int t_inverssha = 0; - int t_qualityMethod = 1; - int t_thres = 18; - int t_proxi = 0; - int t_noiselumf = 0; - int t_noiselumc = 0; - int t_noisechrof = 0; - int t_noisechroc = 0; - int t_mult0 = 100; - int t_mult1 = 100; - int t_mult2 = 100; - int t_mult3 = 100; - int t_mult4 = 100; - int t_threshold = 20; - int t_sensicb = 19; - int t_activlum = 0; - - // end versionmip = 10000 - - //begin versionmip = 10001 Tone mapping - int t_stren = 0; - int t_gamma = 100; - int t_estop = 140; - int t_scaltm = 10; - int t_rewei = 0; - int t_sensitm = 19; - - //versionmip = 10002 Reticurv - int t_retrab = 500; - - std::string t_curvret = "1000A0B120C350D350E700F500G350H350I1000J120K350L350M";//12 points - //10003 - //std::string t_curvll = "0A"; - std::string t_curvll = "3000A0B0C1000D1000E"; //"3000A0B0C499D501E1000F1000G";// "3000A0B0C1000D1000E";//with that it works ! - - //versionmip = 10004 LHcurv - std::string t_curvlh = "1000A0B500C350D350E166F500G350H350I333J500K350L350M500N500O350P350Q666R500S350T350U833V500W350X350Y"; - //10005 - int t_curvactiv = 0; - //10006 - std::string t_curvcc = "3000A0B0C1000D1000E"; //"3000A0B0C499D501E1000F1000G";// "3000A0B0C1000D1000E";//with that it works ! - - //10007 - int t_qualitycurveMethod = 0; - //versionmip = 10008 HHcurv - std::string t_curvhh = "1000A0B500C350D350E166F500G350H350I333J500K350L350M500N500O350P350Q666R500S350T350U833V500W350X350Y"; - - //10009 - 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 ! - - //10010 - int t_expcomp = 0; - int t_black = 0; - int t_hlcompr = 20; - int t_hlcomprthresh = 33; - int t_shcompr = 50; - int t_sensiex = 19; - - //10011 - std::string t_curvex = "3000A0B0C1000D1000E"; - - //10012 - int t_centerXbuf = 0; - int t_centerYbuf = 0; - int t_adjblur = 0; - int t_cutpast = 0; - - //10013 - int t_chromacbdl = 0; - - //10014 - int t_lastdust = 0; - int t_blurMethod = 0; - int t_dustMethod = 1; - - //10016 - int t_excludemeth = 0; - int t_sensiexclu = 19; - int t_struc = 0; - - //10017 - int t_warm = 0; - //10018 - int t_noiselumdetail = 0; - //10019 - int t_noisechrodetail = 0; - //10019 - int t_sensiden = 30; - - //10021 - int t_expdenoi = 0; - - //10022 - int t_bilateral = 0; - - int t_expcolor = 0; - int t_expvibrance = 0; - int t_expblur = 0; - int t_exptonemap = 0; - int t_expreti = 0; - int t_expsharp = 0; - int t_expcbdl = 0; - int t_expexpose = 0; - //10023 - int t_noiselequal = 7; - - //10024 - int t_shapemeth = 0; - - //all variables except locRETgainCurve 'coomon for all) - fic << "Mipversion=" << t_mipversion << '@' << endl; - fic << "Spot=" << t_sp << '@' << endl; - fic << "Circrad=" << t_circrad << '@' << endl; - fic << "LocX=" << t_locX << '@' << endl; - fic << "LocY=" << t_locY << '@' << endl; - fic << "LocYT=" << t_locYT << '@' << endl; - fic << "LocXL=" << t_locXL << '@' << endl ; - fic << "CenterX=" << t_centerX << '@' << endl; - fic << "CenterY=" << t_centerY << '@' << endl; - fic << "Lightness=" << t_lightness << '@' << endl; - fic << "Contrast=" << t_contrast << '@' << endl; - fic << "Chroma=" << t_chroma << '@' << endl; - fic << "Sensi=" << t_sensi << '@' << endl; - fic << "Transit=" << t_transit << '@' << endl; - fic << "Invers=" << t_invers << '@' << endl; - fic << "Smethod=" << t_Smeth << '@' << endl; - fic << "Currentspot=" << t_currentspot << '@' << endl; - fic << "Radius=" << t_radius << '@' << endl; - fic << "Strength=" << t_strength << '@' << endl; - fic << "Sensibn=" << t_sensibn << '@' << endl; - fic << "Inversrad=" << t_inversrad << '@' << endl; - fic << "Str=" << t_str << '@' << endl; - fic << "Chroma=" << t_chrrt << '@' << endl; - fic << "Neigh=" << t_neigh << '@' << endl; - fic << "Vart=" << t_vart << '@' << endl; - fic << "Sensih=" << t_sensih << '@' << endl; - fic << "Inversret=" << t_inversret << '@' << endl; - fic << "retinexMethod=" << t_retinexMethod << '@' << endl; - fic << "Sharradius=" << t_sharradius << '@' << endl; - fic << "Sharamount=" << t_sharamount << '@' << endl; - fic << "Shardamping=" << t_shardamping << '@' << endl; - fic << "Shariter=" << t_shariter << '@' << endl; - fic << "Sensisha=" << t_sensisha << '@' << endl; - fic << "Inverssha=" << t_inverssha << '@' << endl; - fic << "qualityMethod=" << t_qualityMethod << '@' << endl; - fic << "Thres=" << t_thres << '@' << endl; - fic << "Proxi=" << t_proxi << '@' << endl; - fic << "Noiselumf=" << t_noiselumf << '@' << endl; - fic << "Noiselumc=" << t_noiselumc << '@' << endl; - fic << "Noisechrof=" << t_noisechrof << '@' << endl; - fic << "Noisechroc=" << t_noisechroc << '@' << endl; - fic << "Mult0=" << t_mult0 << '@' << endl; - fic << "Mult1=" << t_mult1 << '@' << endl; - fic << "Mult2=" << t_mult2 << '@' << endl; - fic << "Mult3=" << t_mult3 << '@' << endl; - fic << "Mult4=" << t_mult4 << '@' << endl; - fic << "Threshold=" << t_threshold << '@' << endl; - fic << "Sensicb=" << t_sensicb << '@' << endl; - fic << "Activblurlum=" << t_activlum << '@' << endl; - - fic << "Stren=" << t_stren << '@' << endl; - fic << "Gamma=" << t_gamma << '@' << endl; - fic << "Estop=" << t_estop << '@' << endl; - fic << "Scaltm=" << t_scaltm << '@' << endl; - fic << "Rewei=" << t_rewei << '@' << endl; - fic << "Sensitm=" << t_sensitm << '@' << endl; - - fic << "Retrab=" << t_retrab << '@' << endl; - fic << "Curvactiv=" << t_curvactiv << '@' << endl; - fic << "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 << "Expcomp=" << t_expcomp << '@' << endl; - fic << "Black=" << t_black << '@' << endl; - fic << "Hlcompr=" << t_hlcompr << '@' << endl; - fic << "Hlcomprthresh=" << t_hlcomprthresh << '@' << endl; - fic << "Shcompr=" << t_shcompr << '@' << endl; - fic << "Sensiex=" << t_sensiex << '@' << endl; - - fic << "CenterXbuf=" << t_centerXbuf << '@' << endl; - fic << "CenterYbuf=" << t_centerYbuf << '@' << endl; - fic << "Adjblur=" << t_adjblur << '@' << endl; - fic << "Cutpast=" << t_cutpast << '@' << endl; - - fic << "Chromacbdl=" << t_chromacbdl << '@' << endl; - - fic << "Lastdust=" << t_lastdust << '@' << endl; - fic << "BlurMethod=" << t_blurMethod << '@' << endl; - fic << "DustMethod=" << t_dustMethod << '@' << endl; - - fic << "ExcludeMethod=" << t_excludemeth << '@' << endl; - fic << "Sensiexclu=" << t_sensiexclu << '@' << endl; - fic << "Struc=" << t_struc << '@' << endl; - fic << "Warm=" << t_warm << '@' << endl; - fic << "Noiselumdetail=" << t_noiselumdetail << '@' << endl; - fic << "Noisechrodetail=" << t_noisechrodetail << '@' << endl; - - fic << "Sensiden=" << t_sensiden << '@' << endl; - fic << "Expdenoi=" << t_expdenoi << '@' << endl; - fic << "Expcolor=" << t_expcolor << '@' << endl; - fic << "Expvibrance=" << t_expvibrance << '@' << endl; - fic << "Expblur=" << t_expblur << '@' << endl; - fic << "Exptonemap=" << t_exptonemap << '@' << endl; - fic << "Expreti=" << t_expreti << '@' << endl; - fic << "Expsharp=" << t_expsharp << '@' << endl; - fic << "Expcbdl=" << t_expcbdl << '@' << endl; - fic << "Expexpose=" << t_expexpose << '@' << endl; - - fic << "Bilateral=" << t_bilateral << '@' << endl; - fic << "Noiselequal=" << t_noiselequal << '@' << endl; - fic << "ShapeMethod=" << t_shapemeth << '@' << 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 << "curveex=" << t_curvex << '@' << endl; - fic << endl; - } - - fic.close(); - - } else - - { - cerr << "can't open file !" << endl; - } - - } - - //*************************************************************************************** - //End initialize new values when first utilisation of Locallab. Prepare creation of Mip files - //**************************************************************************************** - - - int realspot = params.locallab.nbspot; - - if (realspot >= maxspot) { - params.locallab.nbspot = realspot = 1; - } - - std::string inser; - - //create data for mip files - dataspot = new int*[maxdata]; - - //initilize data "0" with params - for (int i = 0; i < maxdata; i++) { - dataspot[i] = new int[maxspot]; - } - - retistr = new std::string[maxspot]; - llstr = new std::string[maxspot]; - 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]; - exstr = new std::string[maxspot]; - */ - /* - //****************************************************************** - //initialize data[xx][0] and Lut cache with params - //****************************************************************** - { - sps[0] = 0; - dataspot[2][0] = circrads[0] = params.locallab.circrad;//copy params in dataspot and in LUTi - dataspot[3][0] = locx[0] = params.locallab.locX; - dataspot[4][0] = locy[0] = params.locallab.locY; - dataspot[5][0] = locyt[0] = params.locallab.locYT; - dataspot[6][0] = locxl[0] = params.locallab.locXL; - dataspot[7][0] = centerx[0] = params.locallab.centerX; - dataspot[8][0] = centery[0] = params.locallab.centerY; - dataspot[9][0] = lights[0] = params.locallab.lightness; - dataspot[10][0] = contrs[0] = params.locallab.contrast; - dataspot[11][0] = chroms[0] = params.locallab.chroma; - dataspot[12][0] = sensis[0] = params.locallab.sensi; - dataspot[13][0] = transits[0] = params. locallab.transit; - - if (!params.locallab.invers) { - dataspot[14][0] = inverss[0] = 0; - } else { - dataspot[14][0] = inverss[0] = 1; - } - - if (params.locallab.Smethod == "IND") { - dataspot[15][0] = smeths[0] = 0; - } else if (params.locallab.Smethod == "SYM") { - dataspot[15][0] = smeths[0] = 1; - } else if (params.locallab.Smethod == "INDSL") { - dataspot[15][0] = smeths[0] = 2; - } else if (params.locallab.Smethod == "SYMSL") { - dataspot[15][0] = smeths[0] = 3; - } - - dataspot[16][0] = curens[0] = params.locallab.nbspot; - dataspot[17][0] = radiuss[0] = params.locallab.radius; - dataspot[18][0] = strengths[0] = params.locallab.strength; - dataspot[19][0] = sensibns[0] = params.locallab.sensibn; - - - if (!params.locallab.inversrad) { - dataspot[20][0] = inversrads[0] = 0; - } else { - dataspot[20][0] = inversrads[0] = 1; - } - - dataspot[21][0] = strs[0] = params.locallab.str; - dataspot[22][0] = chrrts[0] = params.locallab.chrrt; - dataspot[23][0] = neighs[0] = params.locallab.neigh; - dataspot[24][0] = varts[0] = params.locallab.vart; - dataspot[25][0] = sensihs[0] = params.locallab.sensih; - - if (!params.locallab.inversret) { - dataspot[26][0] = inversrets[0] = 0; - } else { - dataspot[26][0] = inversrets[0] = 1; - } - - if (params.locallab.retinexMethod == "low") { - dataspot[27][0] = retinexs[0] = 0; - } else if (params.locallab.retinexMethod == "uni") { - dataspot[27][0] = retinexs[0] = 1; - } else if (params.locallab.retinexMethod == "high") { - dataspot[27][0] = retinexs[0] = 2; - } - - dataspot[28][0] = sharradiuss[0] = params.locallab.sharradius; - dataspot[29][0] = sharamounts[0] = params.locallab.sharamount; - dataspot[30][0] = shardampings[0] = params.locallab.shardamping; - dataspot[31][0] = shariters[0] = params.locallab.shariter; - dataspot[32][0] = sensishas[0] = params.locallab.sensisha; - - if (!params.locallab.inverssha) { - dataspot[33][0] = inversshas[0] = 0; - } else { - dataspot[33][0] = inversshas[0] = 1; - } - - if (params.locallab.qualityMethod == "std") { - dataspot[34][0] = qualitys[0] = 0; - } else if (params.locallab.qualityMethod == "enh") { - dataspot[34][0] = qualitys[0] = 1; - } else if (params.locallab.qualityMethod == "enhden") { - dataspot[34][0] = qualitys[0] = 2; - } - - dataspot[35][0] = thress[0] = params.locallab.thres; - dataspot[36][0] = proxis[0] = params.locallab.proxi; - dataspot[37][0] = noiselumfs[0] = params.locallab.noiselumf; - dataspot[38][0] = noiselumcs[0] = params.locallab.noiselumc; - dataspot[39][0] = noisechrofs[0] = params.locallab.noisechrof; - dataspot[40][0] = noisechrocs[0] = params.locallab.noisechroc; - - dataspot[41][0] = mult0s[0] = params.locallab.mult[0]; - dataspot[42][0] = mult1s[0] = params.locallab.mult[1]; - dataspot[43][0] = mult2s[0] = params.locallab.mult[2]; - dataspot[44][0] = mult3s[0] = params.locallab.mult[3]; - dataspot[45][0] = mult4s[0] = params.locallab.mult[4]; - dataspot[46][0] = thresholds[0] = params.locallab.threshold; - dataspot[47][0] = sensicbs[0] = params.locallab.sensicb; - - if (!params.locallab.activlum) { - dataspot[48][0] = activlums[0] = 0; - } else { - dataspot[48][0] = activlums[0] = 1; - } - - dataspot[49][0] = strens[0] = params.locallab.stren; - dataspot[50][0] = gammas[0] = params.locallab.gamma; - dataspot[51][0] = estops[0] = params.locallab.estop; - dataspot[52][0] = scaltms[0] = params.locallab.scaltm; - dataspot[53][0] = reweis[0] = params.locallab.rewei; - dataspot[54][0] = sensitms[0] = params.locallab.sensitm; - dataspot[55][0] = retrabs[0] = params.locallab.retrab; - - if (!params.locallab.curvactiv) { - dataspot[56][0] = curvactivs[0] = 0; - } else { - dataspot[56][0] = curvactivs[0] = 1; - } - - if (params.locallab.qualitycurveMethod == "none") { - dataspot[57][0] = qualitycurves[0] = 0; - } else if (params.locallab.qualitycurveMethod == "std") { - dataspot[57][0] = qualitycurves[0] = 1; - } else if (params.locallab.qualitycurveMethod == "enh") { - 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; - } - - dataspot[64][0] = expcomps[0] = params.locallab.expcomp; - dataspot[65][0] = blacks[0] = params.locallab.black; - dataspot[66][0] = hlcomprs[0] = params.locallab.hlcompr; - dataspot[67][0] = hlcomprthreshs[0] = params.locallab.hlcomprthresh; - dataspot[68][0] = shcomprs[0] = params.locallab.shcompr; - dataspot[69][0] = sensiexs[0] = params.locallab.sensiex; - - dataspot[70][0] = centerxbufs[0] = params.locallab.centerXbuf; - dataspot[71][0] = centerybufs[0] = params.locallab.centerYbuf; - dataspot[72][0] = adjblurs[0] = params.locallab.adjblur; - - if (!params.locallab.cutpast) { - dataspot[73][0] = cutpasts[0] = 0; - } else { - dataspot[73][0] = cutpasts[0] = 1; - } - - - dataspot[74][0] = chromacbdls[0] = params.locallab.chromacbdl; - - if (!params.locallab.lastdust) { - dataspot[75][0] = lastdusts[0] = 0; - } else { - dataspot[75][0] = lastdusts[0] = 1; - } - - if (params.locallab.blurMethod == "norm") { - dataspot[76][0] = blurmets[0] = 0; - } else if (params.locallab.blurMethod == "inv") { - dataspot[76][0] = blurmets[0] = 1; - } else if (params.locallab.blurMethod == "sym") { - dataspot[76][0] = blurmets[0] = 2; - } - - if (params.locallab.dustMethod == "cop") { - dataspot[77][0] = dustmets[0] = 0; - } else if (params.locallab.dustMethod == "mov") { - dataspot[77][0] = dustmets[0] = 1; - } else if (params.locallab.dustMethod == "pas") { - dataspot[77][0] = dustmets[0] = 2; - } - - if (params.locallab.Exclumethod == "norm") { - dataspot[78][0] = exclumets[0] = 0; - } else if (params.locallab.Exclumethod == "exc") { - dataspot[78][0] = exclumets[0] = 1; - } - - dataspot[79][0] = sensiexclus[0] = params.locallab.sensiexclu; - dataspot[80][0] = strucs[0] = params.locallab.struc; - dataspot[81][0] = warms[0] = params.locallab.warm; - dataspot[82][0] = noiselumdetails[0] = params.locallab.noiselumdetail; - dataspot[83][0] = noisechrodetails[0] = params.locallab.noisechrodetail; - dataspot[84][0] = sensidens[0] = params.locallab.sensiden; - - if (!params.locallab.expdenoi) { - dataspot[85][0] = expdenois[0] = 0; - } else { - dataspot[85][0] = expdenois[0] = 1; - } - - if (!params.locallab.expcolor) { - dataspot[86][0] = expcolors[0] = 0; - } else { - dataspot[86][0] = expcolors[0] = 1; - } - - if (!params.locallab.expvibrance) { - dataspot[87][0] = expvibrances[0] = 0; - } else { - dataspot[87][0] = expvibrances[0] = 1; - } - - if (!params.locallab.expblur) { - dataspot[88][0] = expblurs[0] = 0; - } else { - dataspot[88][0] = expblurs[0] = 1; - } - - if (!params.locallab.exptonemap) { - dataspot[89][0] = exptonemaps[0] = 0; - } else { - dataspot[89][0] = exptonemaps[0] = 1; - } - - if (!params.locallab.expreti) { - dataspot[90][0] = expretis[0] = 0; - } else { - dataspot[90][0] = expretis[0] = 1; - } - - if (!params.locallab.expsharp) { - dataspot[91][0] = expsharps[0] = 0; - } else { - dataspot[91][0] = expsharps[0] = 1; - } - - if (!params.locallab.expcbdl) { - dataspot[92][0] = expcbdls[0] = 0; - } else { - dataspot[92][0] = expcbdls[0] = 1; - } - - if (!params.locallab.expexpose) { - dataspot[93][0] = expexposes[0] = 0; - } else { - dataspot[93][0] = expexposes[0] = 1; - } - - dataspot[94][0] = bilaterals[0] = params.locallab.bilateral; - dataspot[95][0] = noiselequals[0] = params.locallab.noiselequal; - - if (params.locallab.shapemethod == "ELI") { - dataspot[96][0] = shapemets[0] = 0; - } else if (params.locallab.shapemethod == "RECT") { - dataspot[96][0] = shapemets[0] = 1; - } - - // for all curves work around - I do not know how to do with params curves... - //curve Reti local - int siz = params.locallab.localTgaincurve.size(); - - if (siz > 69) {//max due to codage with strcurv_data () - siz = 69; //to avoid crash - } - - int s_datcur[siz + 1]; - - for (int j = 0; j < siz; j++) { - s_datcur[j] = reticurvs[0 + j] = (int)(1000. * params.locallab.localTgaincurve[j]); - } - - std::string cur_str = ""; - - for (int j = 0; j < siz; j++) { - cur_str = cur_str + std::to_string(s_datcur[j]) + delim[j]; - } - - inser = retistr[0] = cur_str + "@"; - //end retistr - - //curve local L Lum - int sizl = params.locallab.llcurve.size(); - - if (sizl > 69) { - sizl = 69;//to avoid crash - } - - int s_datcurl[sizl + 1]; - - for (int j = 0; j < sizl; j++) { - s_datcurl[j] = llcurvs[0 + j] = (int)(1000. * params.locallab.llcurve[j]); - } - - std::string ll_str = ""; - - for (int j = 0; j < sizl; j++) { - ll_str = ll_str + std::to_string(s_datcurl[j]) + delim[j]; - } - - llstr[0] = ll_str + "@"; - //end local L f(L) - - //curve local C chrom - int sizc = params.locallab.cccurve.size(); - - if (sizc > 69) {//max - sizc = 69;//to avoid crash - } - - int s_datcurc[sizc + 1]; - - for (int j = 0; j < sizc; j++) { - s_datcurc[j] = cccurvs[0 + j] = (int)(1000. * params.locallab.cccurve[j]); - } - - std::string cc_str = ""; - - for (int j = 0; j < sizc; j++) { - cc_str = cc_str + std::to_string(s_datcurc[j]) + delim[j]; - } - - ccstr[0] = cc_str + "@"; - //end local C f(C) - - - //curve local L f(H) - int sizh = params.locallab.LHcurve.size(); - - if (sizh > 69) { - sizh = 69;//to avoid crash - } - - // int s_curh[sizh + 1]; - int s_datcurh[sizh + 1]; - - for (int j = 0; j < sizh; j++) { - s_datcurh[j] = lhcurvs[0 + j] = (int)(1000. * params.locallab.LHcurve[j]); - } - - std::string lh_str = ""; - - for (int j = 0; j < sizh; j++) { - lh_str = lh_str + std::to_string(s_datcurh[j]) + delim[j]; - } - - lhstr[0] = lh_str + "@"; - - - //HH curve - //curve local H f(H) - int sizhh = params.locallab.HHcurve.size(); - - if (sizhh > 69) { - sizhh = 69;//to avoid crash - } - - - int s_datcurhh[sizhh + 1]; - - for (int j = 0; j < sizhh; j++) { - s_datcurhh[j] = hhcurvs[0 + j] = (int)(1000. * params.locallab.HHcurve[j]); - } - - std::string hh_str = ""; - - for (int j = 0; j < sizhh; j++) { - hh_str = hh_str + std::to_string(s_datcurhh[j]) + delim[j]; - } - - 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[1] = static_cast(params.locallab.psthreshold.getTopLeft()); - - s_datps[0] = psthresholds[0] = static_cast(params.locallab.psthreshold.getBottomLeft()); - - std::string ps_str = ""; - - ps_str = ps_str + std::to_string(s_datps[0]) + delim[0] + std::to_string(s_datps[1]) + delim[1]; - - pthstr[0] = ps_str + "@"; - //end local ps - - - //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], exstr[0], 0, 1); - } - } + for (int sp = 0; sp < params.locallab.nbspot; sp++) { + // Set local curves of current spot to LUT + LHutili = false; + HHutili = false; locallutili = false; localexutili = false; localcutili = false; localskutili = false; - - LHutili = false; - HHutili = false; - - } - //****************************************************************** - //end initialize data[xx][0] and cache with params - //****************************************************************** - - - //******************************************************************** - //read mip file - //******************************************************************** - int ns = 0; - // int realsp = params.locallab.nbspot; - bool excurvret = true; - bool excurvll = true; - bool excurvlh = true; - bool excurvcc = true; - bool excurvhh = true; - bool excurvsk = true; - bool excpth = true; - bool excurvex = true; - - ifstream fich(datal, ios::in); - - //read mip file - if (fich) {//may be a file with versionmip = 10000 - //we must add new fields at the good place - std::string line; - std::string spotline; - int cont = 0; - int maxind = maxdata - 4 ; // - - if (versionmip == 10000) { - maxind = 49; - excurvret = false; - excurvll = false; - excurvlh = false; - excurvhh = false; - excurvsk = false; - excpth = false; - excurvex = false; - - } - - if (versionmip == 10001) { - maxind = 55; - excurvret = false; - excurvll = false; - excurvlh = false; - excurvhh = false; - excurvsk = false; - excpth = false; - excurvex = false; - - } - - if (versionmip == 10004) { - maxind = 56; - } - - if (versionmip == 10005) { - excurvcc = false; - } - - if (versionmip == 10006) { - maxind = 57; - } - - if (versionmip == 10008) { - maxind = 58; - } - - if (versionmip == 10009) { - maxind = 69; - } - - // I have forgotten 10010 ==> probably crash...but now it's passed... - //enabled this code after... - if (versionmip == 10011) { - maxind = 70; - } - - if (versionmip == 10012) { - maxind = 74; - } - - if (versionmip == 10013) { - maxind = 77; - } - - if (versionmip == 10015) { - maxind = 77; - } - - if (versionmip == 10016) { - maxind = 80; - } - - if (versionmip == 10017) { - maxind = 81; - } - - if (versionmip == 10018) { - maxind = 82; - } - - if (versionmip == 10019) { - maxind = 83; - } - - if (versionmip == 10020) { - maxind = 84; - } - - if (versionmip == 10021) { - maxind = 92; - } - - if (versionmip == 10022) { - maxind = 93; - } - - if (versionmip == 10023) { - maxind = 94; - } - - while (getline(fich, line)) { - spotline = line; - std::size_t pos = spotline.find("="); - std::size_t posend = spotline.find("@"); //in case of for futur use - - if (spotline.substr(0, pos) == "Mipversion") { - std::string strversion = spotline.substr(pos + 1, (posend - pos)); - versionmip = std::stoi(strversion.c_str()); - } - - if (spotline.substr(0, pos) == "Spot") { - cont = 0; - } - - cont++; - std::string str3 = spotline.substr(pos + 1, (posend - pos)); - - if (cont == 1) { - ns = std::stoi(str3.c_str()); - } - - if (ns < maxspot) { - if (cont >= 2 && cont < 16) { - dataspot[cont][ns] = std::stoi(str3.c_str()); - } - - if (spotline.substr(0, pos) == "Currentspot") { - dataspot[16][0] = std::stoi(str3.c_str()); - } - - if (cont > 16 && cont < maxind) { - dataspot[cont][ns] = std::stoi(str3.c_str()); - } - - - if (excurvret && spotline.substr(0, pos) == "curveReti") { - retistr[ns] = str3; - } - - if (excurvll && spotline.substr(0, pos) == "curveLL") { - llstr[ns] = str3; - } - - - if (excurvlh && spotline.substr(0, pos) == "curveLH") { - - lhstr[ns] = str3; - } - - if (excurvcc && spotline.substr(0, pos) == "curveCC") { - ccstr[ns] = str3; - } - - if (excurvhh && spotline.substr(0, pos) == "curveHH") { - hhstr[ns] = str3; - } - - if (excurvsk && spotline.substr(0, pos) == "curveskin") { - skinstr[ns] = str3; - } - - if (excpth && spotline.substr(0, pos) == "pthres") { - pthstr[ns] = str3; - } - - if (excurvex && spotline.substr(0, pos) == "curveex") { - exstr[ns] = str3; - } - } - - } - - fich.close(); - } - - //new filed for each update - //new fields for TM - if (versionmip == 10000) { - for (int sp = 1; sp < maxspot; sp++) { // spots default - dataspot[49][sp] = 0; //stren - dataspot[50][sp] = 100; //gamma - dataspot[51][sp] = 140; //estop - dataspot[52][sp] = 10; //scaltm - dataspot[53][sp] = 0; //rewei - dataspot[54][sp] = 40; //sensitm - - } - } - - if (versionmip <= 10001) { - - for (int sp = 1; sp < maxspot; sp++) { // spots default - dataspot[55][sp] = 500; //retrab - std::string cur_str = "1000A0B120C350D350E700F500G350H350I1000J120K350L350M";//12 points - retistr[sp] = cur_str + "@"; - } - } - - if (versionmip <= 10002) { - - for (int sp = 1; sp < maxspot; sp++) { // spots default - std::string ll_str = "3000A0B0C1000D1000E"; //"3000A0B0C499D501E1000F1000G"; //"3000A0B0C1000D1000E"; //"3000A0B0C200D200E800F800G1000H1000I";//"0A" - llstr[sp] = ll_str + "@"; - } - } - - if (versionmip <= 10003) { - - for (int sp = 1; sp < maxspot; sp++) { // spots default - std::string lh_str = "1000A0B500C350D350E166F500G350H350I333J500K350L350M500N500O350P350Q666R500S350T350U833V500W350X350Y"; - lhstr[sp] = lh_str + "@"; - } - } - - if (versionmip <= 10004) { - - for (int sp = 1; sp < maxspot; sp++) { // spots default - dataspot[56][sp] = 0; //curvactiv - } - } - - if (versionmip <= 10005) { - - for (int sp = 1; sp < maxspot; sp++) { // spots default - std::string cc_str = "3000A0B0C1000D1000E"; - ccstr[sp] = cc_str + "@"; - } - } - - if (versionmip <= 10006) { - - for (int sp = 1; sp < maxspot; sp++) { // spots default - dataspot[57][sp] = 0; //qualitycurveMethod - } - } - - if (versionmip <= 10007) { - - for (int sp = 1; sp < maxspot; sp++) { // spots default - std::string hh_str = "1000A0B500C350D350E166F500G350H350I333J500K350L350M500N500O350P350Q666R500S350T350U833V500W350X350Y"; - hhstr[sp] = hh_str + "@"; - } - } - - if (versionmip <= 10008) { - //vibrance - 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 (versionmip <= 10009) {//exposure - for (int sp = 1; sp < maxspot; sp++) { // spots default - dataspot[64][sp] = 0; - dataspot[65][sp] = 0; - dataspot[66][sp] = 20; - dataspot[67][sp] = 33; - dataspot[68][sp] = 50; - dataspot[69][sp] = 19; - - } - } - - if (versionmip <= 10010) { - - for (int sp = 1; sp < maxspot; sp++) { // spots default - std::string ex_str = "3000A0B0C1000D1000E"; - exstr[sp] = ex_str + "@"; - } - } - - if (versionmip <= 10011) {// - for (int sp = 1; sp < maxspot; sp++) { // spots default - dataspot[70][sp] = 0; - dataspot[71][sp] = 0; - dataspot[72][sp] = 0; - dataspot[73][sp] = 0; - - } - } - - if (versionmip <= 10012) {// - for (int sp = 1; sp < maxspot; sp++) { // spots default - dataspot[74][sp] = 0; - - } - } - - if (versionmip <= 10013) {// - for (int sp = 1; sp < maxspot; sp++) { // spots default - dataspot[75][sp] = 0; - dataspot[76][sp] = 0; - dataspot[77][sp] = 1; - - } - } - - if (versionmip <= 10015) {// - for (int sp = 1; sp < maxspot; sp++) { // spots default - dataspot[78][sp] = 0; - dataspot[79][sp] = 19; - dataspot[80][sp] = 0; - - } - } - - if (versionmip <= 10016) {// - for (int sp = 1; sp < maxspot; sp++) { // spots default - dataspot[81][sp] = 0; - } - } - - if (versionmip <= 10017) {// - for (int sp = 1; sp < maxspot; sp++) { // spots default - dataspot[82][sp] = 0; - } - } - - if (versionmip <= 10018) {// - for (int sp = 1; sp < maxspot; sp++) { // spots default - dataspot[83][sp] = 0; - } - } - - if (versionmip <= 10019) {// - for (int sp = 1; sp < maxspot; sp++) { // spots default - dataspot[84][sp] = 30; - } - } - - if (versionmip <= 10020) {// - for (int sp = 1; sp < maxspot; sp++) { // spots default - dataspot[85][sp] = 0; - dataspot[86][sp] = 0; - dataspot[87][sp] = 0; - dataspot[88][sp] = 0; - dataspot[89][sp] = 0; - dataspot[90][sp] = 0; - dataspot[91][sp] = 0; - dataspot[92][sp] = 0; - dataspot[93][sp] = 0; - } - } - - if (versionmip <= 10021) {// - for (int sp = 1; sp < maxspot; sp++) { // spots default - dataspot[94][sp] = 0; - - } - } - - if (versionmip <= 10022) {// - for (int sp = 1; sp < maxspot; sp++) { // spots default - dataspot[95][sp] = 7; - - } - } - - if (versionmip <= 10023) {// - for (int sp = 1; sp < maxspot; sp++) { // spots default - dataspot[96][sp] = 0; - - } - } - - //************************************************************** - //here we change the number of spot if change in options - //************************************************************** - if (ns < (maxspot - 1)) { //only for increasing, in case of decreasing, datas are "forgoten" - changenumberofspot(dataspot, maxdata, maxspot, ns, datal, versionmip); - - } - - //************************************************************************** - //end change number of spots - //************************************************************************** - - //************************************************************************************************ - //duplicated spot - //************************************************************************************************ - int spottodupli = dataspot[16][0];//current value - - if (params.locallab.spotduplicated) { - lastspotdup = true;//probably unused - } - - if (params.locallab.spotduplicated && spottodupli >= 1) { - - spotduplic(dataspot, spottodupli, maxdata); - - if (aloListener && params.locallab.spotduplicated) { - //update GUI and MIP - int sp = spottodupli; - int maxreal = maxdata; - aloListener->localChanged(dataspot, retistr[sp], llstr[sp], lhstr[sp], ccstr[sp], hhstr[sp], skinstr[sp], pthstr[sp], exstr[sp], sp, maxreal); - aloListener->spotdupChanged(false);//put checkbox to false, and spotduplicated to false - params.locallab.spotduplicated = false; - - } - - } - - //************************************************ - //end duplicated spot - //************************************************ - - //************************************************************************* - //main algorithm for all spots - //************************************************************************* - - for (int sp = 1; sp < maxspot; sp++) { //spots default - params.locallab.huerefblur = dataspot[maxdata - 5][sp] / 100.; - params.locallab.hueref = dataspot[maxdata - 4][sp] / 100.; - params.locallab.chromaref = dataspot[maxdata - 3][sp]; - params.locallab.lumaref = dataspot[maxdata - 2][sp]; - params.locallab.sobelref = dataspot[maxdata - 1][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]; - params.locallab.locYT = locyt[sp] = dataspot[5][sp]; - params.locallab.locXL = locxl[sp] = dataspot[6][sp]; - params.locallab.centerX = centerx[sp] = dataspot[7][sp]; - params.locallab.centerY = centery[sp] = dataspot[8][sp]; - params.locallab.lightness = lights[sp] = dataspot[9][sp]; - params.locallab.contrast = contrs[sp] = dataspot[10][sp]; - params.locallab.chroma = chroms[sp] = dataspot[11][sp]; - params.locallab.sensi = sensis[sp] = dataspot[12][sp]; - params.locallab.transit = transits[sp] = dataspot[13][sp]; - sps[sp] = sp; - - if (dataspot[14][sp] == 0) { - inverss[sp] = 0; - params.locallab.invers = false; - } else { - inverss[sp] = 1; - params.locallab.invers = true; - } - - if (dataspot[15][sp] == 0) { - smeths[sp] = 0; - params.locallab.Smethod = "IND" ; - } else if (dataspot[15][sp] == 1) { - smeths[sp] = 1; - params.locallab.Smethod = "SYM" ; - } else if (dataspot[15][sp] == 2) { - smeths[sp] = 2; - params.locallab.Smethod = "INDSL"; - } else if (dataspot[15][sp] == 3) { - smeths[sp] = 3; - params.locallab.Smethod = "SYMSL"; - } - - radiuss[sp] = dataspot[17][sp]; - strengths[sp] = dataspot[18][sp]; - params.locallab.radius = dataspot[17][sp]; - params.locallab.strength = dataspot[18][sp]; - params.locallab.sensibn = sensibns[sp] = dataspot[19][sp]; - - if (dataspot[20][sp] == 0) { - inversrads[sp] = 0; - params.locallab.inversrad = false; - } else { - inversrads[sp] = 1; - params.locallab.inversrad = true; - } - - - params.locallab.str = strs[sp] = dataspot[21][sp]; - params.locallab.chrrt = chrrts[sp] = dataspot[22][sp]; - params.locallab.neigh = neighs[sp] = dataspot[23][sp]; - params.locallab.vart = varts[sp] = dataspot[24][sp]; - params.locallab.sensih = sensihs[sp] = dataspot[25][sp]; - - if (dataspot[26][sp] == 0) { - inversrets[sp] = 0; - params.locallab.inversret = false; - } else { - inversrets[sp] = 1; - params.locallab.inversret = true; - } - - if (dataspot[27][sp] == 0) { - retinexs[sp] = 0; - params.locallab.retinexMethod = "low" ; - } else if (dataspot[27][sp] == 1) { - retinexs[sp] = 1; - params.locallab.retinexMethod = "uni" ; - } else if (dataspot[27][sp] == 2) { - retinexs[sp] = 2; - params.locallab.retinexMethod = "high"; - } - - sharradiuss[sp] = dataspot[28][sp]; - params.locallab.sharradius = dataspot[28][sp]; - - params.locallab.sharamount = sharamounts[sp] = dataspot[29][sp]; - params.locallab.shardamping = shardampings[sp] = dataspot[30][sp]; - params.locallab.shariter = shariters[sp] = dataspot[31][sp]; - params.locallab.sensisha = sensishas[sp] = dataspot[32][sp]; - - if (dataspot[33][sp] == 0) { - inversshas[sp] = 0; - params.locallab.inverssha = false; - } else { - inversshas[sp] = 1; - params.locallab.inverssha = true; - } - - if (dataspot[34][sp] == 0) { - qualitys[sp] = 0; - params.locallab.qualityMethod = "std" ; - } else if (dataspot[34][sp] == 1) { - qualitys[sp] = 1; - params.locallab.qualityMethod = "enh" ; - } else if (dataspot[34][sp] == 2) { - qualitys[sp] = 2; - params.locallab.qualityMethod = "enhden" ; - } - - params.locallab.thres = thress[sp] = dataspot[35][sp]; - params.locallab.proxi = proxis[sp] = dataspot[36][sp]; - params.locallab.noiselumf = noiselumfs[sp] = dataspot[37][sp]; - params.locallab.noiselumc = noiselumcs[sp] = dataspot[38][sp]; - params.locallab.noisechrof = noisechrofs[sp] = dataspot[39][sp]; - params.locallab.noisechroc = noisechrocs[sp] = dataspot[40][sp]; - params.locallab.mult[0] = mult0s[sp] = dataspot[41][sp]; - params.locallab.mult[1] = mult1s[sp] = dataspot[42][sp]; - params.locallab.mult[2] = mult2s[sp] = dataspot[43][sp]; - params.locallab.mult[3] = mult3s[sp] = dataspot[44][sp]; - params.locallab.mult[4] = mult4s[sp] = dataspot[45][sp]; - params.locallab.threshold = thresholds[sp] = dataspot[46][sp]; - params.locallab.sensicb = sensicbs[sp] = dataspot[47][sp]; - - if (dataspot[48][sp] == 0) { - activlums[sp] = 0; - params.locallab.activlum = false; - } else { - activlums[sp] = 1; - params.locallab.activlum = true; - } - - params.locallab.stren = strens[sp] = dataspot[49][sp]; - params.locallab.gamma = gammas[sp] = dataspot[50][sp]; - params.locallab.estop = estops[sp] = dataspot[51][sp]; - params.locallab.scaltm = scaltms[sp] = dataspot[52][sp]; - params.locallab.rewei = reweis[sp] = dataspot[53][sp]; - params.locallab.sensitm = sensitms[sp] = dataspot[54][sp]; - params.locallab.retrab = retrabs[sp] = dataspot[55][sp]; - - if (dataspot[56][sp] == 0) { - curvactivs[sp] = 0; - params.locallab.curvactiv = false; - } else { - curvactivs[sp] = 1; - params.locallab.curvactiv = true; - } - - if (dataspot[57][sp] == 0) { - qualitycurves[sp] = 0; - params.locallab.qualitycurveMethod = "none" ; - } else if (dataspot[57][sp] == 1) { - qualitycurves[sp] = 1; - params.locallab.qualitycurveMethod = "std" ; - } else if (dataspot[57][sp] == 2) { - qualitycurves[sp] = 2; - 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; - } - - - - params.locallab.expcomp = expcomps[sp] = dataspot[64][sp]; - params.locallab.black = blacks[sp] = dataspot[65][sp]; - params.locallab.hlcompr = hlcomprs[sp] = dataspot[66][sp]; - params.locallab.hlcomprthresh = hlcomprthreshs[sp] = dataspot[67][sp]; - params.locallab.shcompr = shcomprs[sp] = dataspot[68][sp]; - params.locallab.sensiex = sensiexs[sp] = dataspot[69][sp]; - - params.locallab.centerXbuf = centerxbufs[sp] = dataspot[70][sp]; - params.locallab.centerYbuf = centerybufs[sp] = dataspot[71][sp]; - params.locallab.adjblur = adjblurs[sp] = dataspot[72][sp]; - - if (dataspot[73][sp] == 0) { - cutpasts[sp] = 0; - params.locallab.cutpast = false; - } else { - cutpasts[sp] = 1; - params.locallab.cutpast = true; - } - - params.locallab.chromacbdl = chromacbdls[sp] = dataspot[74][sp]; - - if (dataspot[75][sp] == 0) { - lastdusts[sp] = 0; - params.locallab.lastdust = false; - } else { - lastdusts[sp] = 1; - params.locallab.lastdust = true; - } - - if (dataspot[76][sp] == 0) { - blurmets[sp] = 0; - params.locallab.blurMethod = "norm" ; - } else if (dataspot[76][sp] == 1) { - blurmets[sp] = 1; - params.locallab.blurMethod = "inv" ; - } else if (dataspot[76][sp] == 2) { - blurmets[sp] = 2; - params.locallab.blurMethod = "sym" ; - } - - if (dataspot[77][sp] == 0) { - dustmets[sp] = 0; - params.locallab.dustMethod = "cop" ; - } else if (dataspot[77][sp] == 1) { - dustmets[sp] = 1; - params.locallab.dustMethod = "mov" ; - } else if (dataspot[77][sp] == 2) { - dustmets[sp] = 2; - params.locallab.dustMethod = "pas" ; - } - - if (dataspot[78][sp] == 0) { - exclumets[sp] = 0; - params.locallab.Exclumethod = "norm" ; - } else if (dataspot[78][sp] == 1) { - exclumets[sp] = 1; - params.locallab.Exclumethod = "exc" ; - } - - params.locallab.sensiexclu = sensiexclus[sp] = dataspot[79][sp]; - params.locallab.struc = strucs[sp] = dataspot[80][sp]; - params.locallab.warm = warms[sp] = dataspot[81][sp]; - params.locallab.noiselumdetail = noiselumdetails[sp] = dataspot[82][sp]; - params.locallab.noisechrodetail = noisechrodetails[sp] = dataspot[83][sp]; - params.locallab.sensiden = sensidens[sp] = dataspot[84][sp]; - - if (dataspot[85][sp] == 0) { - expdenois[sp] = 0; - params.locallab.expdenoi = false; - } else { - expdenois[sp] = 1; - params.locallab.expdenoi = true; - } - - if (dataspot[86][sp] == 0) { - expcolors[sp] = 0; - params.locallab.expcolor = false; - } else { - expcolors[sp] = 1; - params.locallab.expcolor = true; - } - - if (dataspot[87][sp] == 0) { - expvibrances[sp] = 0; - params.locallab.expvibrance = false; - } else { - expvibrances[sp] = 1; - params.locallab.expvibrance = true; - } - - if (dataspot[88][sp] == 0) { - expblurs[sp] = 0; - params.locallab.expblur = false; - } else { - expblurs[sp] = 1; - params.locallab.expblur = true; - } - - if (dataspot[89][sp] == 0) { - exptonemaps[sp] = 0; - params.locallab.exptonemap = false; - } else { - exptonemaps[sp] = 1; - params.locallab.exptonemap = true; - } - - if (dataspot[90][sp] == 0) { - expretis[sp] = 0; - params.locallab.expreti = false; - } else { - expretis[sp] = 1; - params.locallab.expreti = true; - } - - if (dataspot[91][sp] == 0) { - expsharps[sp] = 0; - params.locallab.expsharp = false; - } else { - expsharps[sp] = 1; - params.locallab.expsharp = true; - } - - if (dataspot[92][sp] == 0) { - expcbdls[sp] = 0; - params.locallab.expcbdl = false; - } else { - expcbdls[sp] = 1; - params.locallab.expcbdl = true; - } - - if (dataspot[93][sp] == 0) { - expexposes[sp] = 0; - params.locallab.expexpose = false; - } else { - expcbdls[sp] = 1; - params.locallab.expexpose = true; - } - - params.locallab.bilateral = bilaterals[sp] = dataspot[94][sp]; - params.locallab.noiselequal = noiselequals[sp] = dataspot[95][sp]; - - if (dataspot[96][sp] == 0) { - shapemets[sp] = 0; - params.locallab.shapemethod = "ELI" ; - } else if (dataspot[96][sp] == 1) { - shapemets[sp] = 1; - params.locallab.shapemethod = "RECT" ; - } - - int *s_datc; - s_datc = new int[70]; - int siz; - - ipf.strcurv_data(retistr[sp], s_datc, siz); //convert data in int string with strcurv_data () - it is a work around ! - - sizeretics[sp] = siz; - - std::vector cretiend; - - for (int j = 0; j < siz; j++) { - reticurvs[sp * 500 + j] = s_datc[j]; - cretiend.push_back((double)(s_datc[j]) / 1000.); - } - - delete [] s_datc; - - int *s_datcl; - s_datcl = new int[70]; - int sizl; - - ipf.strcurv_data(llstr[sp], s_datcl, sizl); - - sizellcs[sp] = sizl; - - std::vector cllend; - - for (int j = 0; j < sizl; j++) { - llcurvs[sp * 500 + j] = s_datcl[j]; - cllend.push_back((double)(s_datcl[j]) / 1000.); - } - - delete [] s_datcl; - - - int *s_datcc; - s_datcc = new int[70]; - int sizc; - - ipf.strcurv_data(ccstr[sp], s_datcc, sizc); - - sizecccs[sp] = sizc; - - std::vector cccend; - - for (int j = 0; j < sizc; j++) { - cccurvs[sp * 500 + j] = s_datcc[j]; - cccend.push_back((double)(s_datcc[j]) / 1000.); - } - - delete [] s_datcc; - - int *s_datch; - s_datch = new int[70]; - int sizh; - - ipf.strcurv_data(lhstr[sp], s_datch, sizh); - - sizelhcs[sp] = sizh; - - std::vector clhend; - - for (int j = 0; j < sizh; j++) { - lhcurvs[sp * 500 + j] = s_datch[j]; - clhend.push_back((double)(s_datch[j]) / 1000.); - } - - delete [] s_datch; - - - int *s_datchh; - s_datchh = new int[70]; - int sizhh; - - ipf.strcurv_data(hhstr[sp], s_datchh, sizhh); - - sizehhcs[sp] = sizhh; - - std::vector chhend; - - for (int j = 0; j < sizhh; j++) { - hhcurvs[sp * 500 + j] = s_datchh[j]; - chhend.push_back((double)(s_datchh[j]) / 1000.); - } - - 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]; - // printf("A 0=%i 1=%i\n", s_datcps[0], s_datcps[1]); - params.locallab.psthreshold.setValues(s_datcps[0], s_datcps[1]); - - //end local PS - - //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; - - // int lenc = params.locallab.localTgaincurve.size(); - - params.locallab.llcurve.clear(); - params.locallab.llcurve = cllend; - - params.locallab.LHcurve.clear(); - params.locallab.LHcurve = clhend; - - params.locallab.cccurve.clear(); - params.locallab.cccurve = cccend; - - params.locallab.HHcurve.clear(); - params.locallab.HHcurve = chhend; - - params.locallab.skintonescurve.clear(); - 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@"; - - if (lhstr[sp].c_str() != t_curvhhref) { - //LHutili = true; - } - - if (hhstr[sp].c_str() != t_curvhhref) { - // HHutili = true; - } - - std::string t_curvskinref = "3000A0B0C1000D1000E@"; - std::string t_none = "0A@"; - - if (skinstr[sp].c_str() != t_curvskinref && skinstr[sp].c_str() != t_none) { - // localskutili = true; - } - - std::string t_curvexref = "3000A0B0C1000D1000E@"; - - if (exstr[sp].c_str() != t_curvexref && exstr[sp].c_str() != t_none) { - // localexutili = true; - } - - params.locallab.getCurves(locRETgainCurve, locRETgainCurverab, loclhCurve, lochhCurve, LHutili, HHutili); - 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 ecomp = params.locallab.expcomp; - double black = params.locallab.black; - double hlcompr = params.locallab.hlcompr; - double hlcomprthresh = params.locallab.hlcomprthresh; - double shcompr = params.locallab.shcompr; - double br = params.locallab.lightness; + locRETgainCurve.Set(params.locallab.localTgaincurve.at(sp)); + loclhCurve.Set(params.locallab.LHcurve.at(sp), LHutili); + lochhCurve.Set(params.locallab.HHcurve.at(sp), HHutili); + CurveFactory::curveLocal(locallutili, params.locallab.llcurve.at(sp), lllocalcurve, sca); + CurveFactory::curveCCLocal(localcutili, params.locallab.cccurve.at(sp), cclocalcurve, sca); + CurveFactory::curveskLocal(localskutili, params.locallab.skintonescurve.at(sp), sklocalcurve, sca); + CurveFactory::curveexLocal(localexutili, params.locallab.excurve.at(sp), exlocalcurve, sca); + double ecomp = params.locallab.expcomp.at(sp); + double black = params.locallab.black.at(sp); + double hlcompr = params.locallab.hlcompr.at(sp); + double hlcomprthresh = params.locallab.hlcomprthresh.at(sp); + double shcompr = params.locallab.shcompr.at(sp); + double br = params.locallab.lightness.at(sp); CurveFactory::complexCurvelocal(ecomp, black / 65535., hlcompr, hlcomprthresh, shcompr, br, hltonecurveloc, shtonecurveloc, tonecurveloc, lightCurveloc, sca); - double huere, chromare, lumare, huerefblu; - double sobelre; + // Reference parameters computation + double huere, chromare, lumare, huerefblu, sobelre; - if (params.locallab.Exclumethod == "exc") { - ipf.calc_ref(reserv, reserv, 0, 0, pW, pH, scale, huerefblu, huere, chromare, lumare, sobelre); + if (params.locallab.spotMethod.at(sp) == "exc") { + ipf.calc_ref(sp, reserv, reserv, 0, 0, pW, pH, scale, huerefblu, huere, chromare, lumare, sobelre); } else { - ipf.calc_ref(nprevl, nprevl, 0, 0, pW, pH, scale, huerefblu, huere, chromare, lumare, sobelre); + ipf.calc_ref(sp, nprevl, nprevl, 0, 0, pW, pH, scale, huerefblu, huere, chromare, lumare, sobelre); } - huerblu = huerefblu; - huer = huere; - chromar = chromare; - lumar = lumare ; - sobeler = sobelre; - params.locallab.huerefblur = huerblu; - params.locallab.hueref = huer; - params.locallab.chromaref = chromar; - params.locallab.lumaref = lumar; - params.locallab.sobelref = sobeler; + huerblu = huerefblurs[sp] = huerefblu; + huer = huerefs[sp] = huere; + chromar = chromarefs[sp] = chromare; + lumar = lumarefs[sp] = lumare ; + sobeler = sobelrefs[sp] = sobelre; - dataspot[maxdata - 5][sp] = huerefblurs[sp] = 100.f * params.locallab.huerefblur; - dataspot[maxdata - 4][sp] = huerefs[sp] = 100.f * params.locallab.hueref; - dataspot[maxdata - 3][sp] = chromarefs[sp] = params.locallab.chromaref; - dataspot[maxdata - 2][sp] = lumarefs[sp] = params.locallab.lumaref; - dataspot[maxdata - 1][sp] = sobelrefs[sp] = params.locallab.sobelref; - //printf("sp=%i huerefsp=%f\n", sp, huerefs[sp]); + printf("huerblu=%f, huer=%f, chromar=%f, lumar=%f, sobeler=%f\n", huerblu, huer, chromar, lumar, sobeler); + + // Locallab tools computation + /* Notes: + * - maxspot, huerefs, centerx and centery aren't used in Lab_Local (only for printf) so values aren't important + * - shbuffer is used as nullptr + */ ipf.Lab_Local(3, maxspot, sp, huerefs, sobelrefs, centerx, centery, (float**)shbuffer, nprevl, nprevl, reserv, 0, 0, pW, pH, scale, locRETgainCurve, lllocalcurve, loclhCurve, lochhCurve, - LHutili, HHutili, cclocalcurve, localskutili, sklocalcurve, localexutili, exlocalcurve, hltonecurveloc, shtonecurveloc, tonecurveloc, lightCurveloc, params.locallab.huerefblur, params.locallab.hueref, params.locallab.chromaref, params.locallab.lumaref, params.locallab.sobelref); + LHutili, HHutili, cclocalcurve, localskutili, sklocalcurve, localexutili, exlocalcurve, hltonecurveloc, shtonecurveloc, tonecurveloc, lightCurveloc, huerblu, huer, chromar, lumar, sobeler); + + // Clear local curves lllocalcurve.clear(); cclocalcurve.clear(); sklocalcurve.clear(); exlocalcurve.clear(); - } + } - //*********************************************************** - //end main algoritm - //*********************************************************** + //************************************************************* + // end locallab + //************************************************************* - int sp ; - sp = realspot; - //now for current spot - int maxreal = maxdata; + histCCurve.clear(); + histLCurve.clear(); + ipf.chromiLuminanceCurve(nullptr, pW, nprevl, nprevl, chroma_acurve, chroma_bcurve, satcurve, lhskcurve, clcurve, lumacurve, utili, autili, butili, ccutili, cclutili, clcutili, histCCurve, histLCurve); + ipf.vibrance(nprevl); - //************************************************************* - //update GUI and Mip files - //************************************************************* - 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], exstr[sp], sp, maxreal); - } - - - //**************************************************************** - //now works on current spot - //**************************************************************** - params.locallab.huerefblur = INFINITY; - params.locallab.hueref = INFINITY; - params.locallab.chromaref = INFINITY; - params.locallab.lumaref = INFINITY; - params.locallab.sobelref = INFINITY; - locallutili = false; - localexutili = false; - // locallutili = false; - localcutili = false; - localskutili = false; - // localexutili = false; - - LHutili = false; - HHutili = false; - - sps[sp] = sp; - dataspot[2][sp] = circrads[sp] = params.locallab.circrad = dataspot[2][0]; - dataspot[3][sp] = locx[sp] = params.locallab.locX = dataspot[3][0]; - dataspot[4][sp] = locy[sp] = params.locallab.locY = dataspot[4][0]; - dataspot[5][sp] = locyt[sp] = params.locallab.locYT = dataspot[5][0]; - dataspot[6][sp] = locxl[sp] = params.locallab.locXL = dataspot[6][0]; - dataspot[7][sp] = centerx[sp] = params.locallab.centerX = dataspot[7][0]; - dataspot[8][sp] = centery[sp] = params.locallab.centerY = dataspot[8][0]; - dataspot[9][sp] = lights[sp] = params.locallab.lightness = dataspot[9][0]; - dataspot[10][sp] = contrs[sp] = params.locallab.contrast = dataspot[10][0]; - dataspot[11][sp] = chroms[sp] = params.locallab.chroma = dataspot[11][0]; - dataspot[12][sp] = sensis[sp] = params.locallab.sensi = dataspot[12][0]; - dataspot[13][sp] = transits[sp] = params.locallab.transit = dataspot[13][0]; - - if (dataspot[14][0] == 0) { - params.locallab.invers = false; - dataspot[14][sp] = 0; - inverss[sp] = 0; - } else { - params.locallab.invers = true; - dataspot[14][sp] = 1; - inverss[sp] = 1; - } - - if (dataspot[15][0] == 0) { - params.locallab.Smethod = "IND" ; - smeths[sp] = 0; - dataspot[15][sp] = 0; - } else if (dataspot[15][0] == 1) { - params.locallab.Smethod = "SYM" ; - smeths[sp] = 1; - dataspot[15][sp] = 1; - - } else if (dataspot[15][0] == 2) { - params.locallab.Smethod = "INDSL" ; - smeths[sp] = 2; - dataspot[15][sp] = 2; - } else if (dataspot[15][0] == 3) { - params.locallab.Smethod = "SYMSL" ; - smeths[sp] = 3; - dataspot[15][sp] = 3; - } - - params.locallab.radius = dataspot[17][0]; - params.locallab.strength = dataspot[18][0]; - params.locallab.sensibn = dataspot[19][0]; - - dataspot[17][sp] = radiuss[sp] = params.locallab.radius; - dataspot[18][sp] = strengths[sp] = params.locallab.strength; - dataspot[19][sp] = sensibns[sp] = params.locallab.sensibn; - - if (dataspot[20][0] == 0) { - params.locallab.inversrad = false; - dataspot[20][sp] = 0; - inversrads[sp] = 0; - } else { - params.locallab.inversrad = true; - dataspot[20][sp] = 1; - inversrads[sp] = 1; - } - - dataspot[21][sp] = strs[sp] = params.locallab.str = dataspot[21][0]; - dataspot[22][sp] = chrrts[sp] = params.locallab.chrrt = dataspot[22][0]; - dataspot[23][sp] = neighs[sp] = params.locallab.neigh = dataspot[23][0]; - dataspot[24][sp] = varts[sp] = params.locallab.vart = dataspot[24][0]; - dataspot[25][sp] = sensihs[sp] = params.locallab.sensih = dataspot[25][0]; - - if (dataspot[26][0] == 0) { - params.locallab.inversret = false; - inversrets[sp] = 0; - dataspot[26][sp] = 0; - } else { - params.locallab.inversret = true; - inversrets[sp] = 1; - dataspot[26][sp] = 1; - } - - if (dataspot[27][0] == 0) { - params.locallab.retinexMethod = "low" ; - retinexs[sp] = 0; - dataspot[27][sp] = 0; - } else if (dataspot[27][0] == 1) { - params.locallab.retinexMethod = "uni" ; - retinexs[sp] = 1; - dataspot[27][sp] = 1; - } else if (dataspot[27][0] == 2) { - params.locallab.Smethod = "high" ; - retinexs[sp] = 2; - dataspot[27][sp] = 2; - } - - dataspot[28][sp] = sharradiuss[sp] = params.locallab.sharradius = dataspot[28][0]; - - dataspot[29][sp] = sharamounts[sp] = params.locallab.sharamount = dataspot[29][0]; - dataspot[30][sp] = shardampings[sp] = params.locallab.shardamping = dataspot[30][0]; - dataspot[31][sp] = shariters[sp] = params.locallab.shariter = dataspot[31][0]; - dataspot[32][sp] = sensishas[sp] = params.locallab.sensisha = dataspot[32][0]; - - if (dataspot[33][0] == 0) { - params.locallab.inverssha = 0; - inversshas[sp] = 0; - dataspot[33][sp] = 0; - } else { - params.locallab.inverssha = 1; - inversshas[sp] = 1; - dataspot[33][sp] = 1; - } - - if (dataspot[34][0] == 0) { - params.locallab.qualityMethod = "std" ; - qualitys[sp] = 0; - dataspot[34][sp] = 0; - } else if (dataspot[34][0] == 1) { - params.locallab.qualityMethod = "enh" ; - qualitys[sp] = 1; - dataspot[34][sp] = 1; - } else if (dataspot[34][0] == 2) { - params.locallab.qualityMethod = "enhden" ; - qualitys[sp] = 2; - dataspot[34][sp] = 2; - } - - dataspot[35][sp] = thress[sp] = params.locallab.thres = dataspot[35][0]; - dataspot[36][sp] = proxis[sp] = params.locallab.proxi = dataspot[36][0]; - dataspot[37][sp] = noiselumfs[sp] = params.locallab.noiselumf = dataspot[37][0]; - dataspot[38][sp] = noiselumcs[sp] = params.locallab.noiselumc = dataspot[38][0]; - dataspot[39][sp] = noisechrofs[sp] = params.locallab.noisechrof = dataspot[39][0]; - dataspot[40][sp] = noisechrocs[sp] = params.locallab.noisechroc = dataspot[40][0]; - dataspot[41][sp] = mult0s[sp] = params.locallab.mult[0] = dataspot[41][0]; - dataspot[42][sp] = mult1s[sp] = params.locallab.mult[1] = dataspot[42][0]; - dataspot[43][sp] = mult2s[sp] = params.locallab.mult[2] = dataspot[43][0]; - dataspot[44][sp] = mult3s[sp] = params.locallab.mult[3] = dataspot[44][0]; - dataspot[45][sp] = mult4s[sp] = params.locallab.mult[4] = dataspot[45][0]; - dataspot[46][sp] = thresholds[sp] = params.locallab.threshold = dataspot[46][0]; - dataspot[47][sp] = sensicbs[sp] = params.locallab.sensicb = dataspot[47][0]; - - if (dataspot[48][0] == 0) { - params.locallab.activlum = 0; - activlums[sp] = 0; - dataspot[48][sp] = 0; - } else { - params.locallab.activlum = 1; - activlums[sp] = 1; - dataspot[48][sp] = 1; - } - - dataspot[49][sp] = strens[sp] = params.locallab.stren = dataspot[49][0]; - dataspot[50][sp] = gammas[sp] = params.locallab.gamma = dataspot[50][0]; - dataspot[51][sp] = estops[sp] = params.locallab.estop = dataspot[51][0]; - dataspot[52][sp] = scaltms[sp] = params.locallab.scaltm = dataspot[52][0]; - dataspot[53][sp] = reweis[sp] = params.locallab.rewei = dataspot[53][0]; - dataspot[54][sp] = sensitms[sp] = params.locallab.sensitm = dataspot[54][0]; - dataspot[55][sp] = retrabs[sp] = params.locallab.retrab = dataspot[55][0]; - - if (dataspot[56][0] == 0) { - params.locallab.curvactiv = false; - dataspot[56][sp] = 0; - curvactivs[sp] = 0; - } else { - params.locallab.curvactiv = true; - dataspot[56][sp] = 1; - curvactivs[sp] = 1; - } - - if (dataspot[57][0] == 0) { - params.locallab.qualitycurveMethod = "none" ; - qualitycurves[sp] = 0; - dataspot[57][sp] = 0; - } else if (dataspot[57][0] == 1) { - params.locallab.qualitycurveMethod = "std" ; - qualitycurves[sp] = 1; - dataspot[57][sp] = 1; - } else if (dataspot[57][0] == 2) { - params.locallab.qualitycurveMethod = "enh" ; - qualitycurves[sp] = 2; - 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; - } - - dataspot[64][sp] = expcomps[sp] = params.locallab.expcomp = dataspot[64][0]; - dataspot[65][sp] = blacks[sp] = params.locallab.black = dataspot[65][0]; - dataspot[66][sp] = hlcomprs[sp] = params.locallab.hlcompr = dataspot[66][0]; - dataspot[67][sp] = hlcomprthreshs[sp] = params.locallab.hlcomprthresh = dataspot[67][0]; - dataspot[68][sp] = shcomprs[sp] = params.locallab.shcompr = dataspot[68][0]; - dataspot[69][sp] = sensiexs[sp] = params.locallab.sensiex = dataspot[69][0]; - - dataspot[70][sp] = centerxbufs[sp] = params.locallab.centerXbuf = dataspot[70][0]; - dataspot[71][sp] = centerybufs[sp] = params.locallab.centerYbuf = dataspot[71][0]; - dataspot[72][sp] = adjblurs[sp] = params.locallab.adjblur = dataspot[72][0]; - - if (dataspot[73][0] == 0) { - params.locallab.cutpast = false; - dataspot[73][sp] = 0; - cutpasts[sp] = 0; - } else { - params.locallab.cutpast = true; - dataspot[73][sp] = 1; - cutpasts[sp] = 1; - } - - dataspot[74][sp] = chromacbdls[sp] = params.locallab.chromacbdl = dataspot[74][0]; - - if (dataspot[75][0] == 0) { - params.locallab.lastdust = false; - dataspot[75][sp] = 0; - lastdusts[sp] = 0; - } else { - params.locallab.lastdust = true; - dataspot[75][sp] = 1; - lastdusts[sp] = 1; - } - - if (dataspot[76][0] == 0) { - params.locallab.blurMethod = "norm" ; - blurmets[sp] = 0; - dataspot[76][sp] = 0; - } else if (dataspot[76][0] == 1) { - params.locallab.blurMethod = "inv" ; - blurmets[sp] = 1; - dataspot[76][sp] = 1; - } else if (dataspot[76][0] == 2) { - params.locallab.blurMethod = "sym" ; - blurmets[sp] = 2; - dataspot[76][sp] = 2; - } - - if (dataspot[77][0] == 0) { - params.locallab.dustMethod = "cop" ; - dustmets[sp] = 0; - dataspot[77][sp] = 0; - } else if (dataspot[77][0] == 1) { - params.locallab.dustMethod = "mov" ; - dustmets[sp] = 1; - dataspot[77][sp] = 1; - } else if (dataspot[77][0] == 2) { - params.locallab.dustMethod = "pas" ; - dustmets[sp] = 2; - dataspot[77][sp] = 2; - } - - if (dataspot[78][0] == 0) { - params.locallab.Exclumethod = "norm" ; - exclumets[sp] = 0; - dataspot[78][sp] = 0; - } else if (dataspot[78][0] == 1) { - params.locallab.Exclumethod = "exc" ; - exclumets[sp] = 1; - dataspot[78][sp] = 1; - } - - dataspot[79][sp] = sensiexclus[sp] = params.locallab.sensiexclu = dataspot[79][0]; - dataspot[80][sp] = strucs[sp] = params.locallab.struc = dataspot[80][0]; - dataspot[81][sp] = warms[sp] = params.locallab.warm = dataspot[81][0]; - dataspot[82][sp] = noiselumdetails[sp] = params.locallab.noiselumdetail = dataspot[82][0]; - dataspot[83][sp] = noisechrodetails[sp] = params.locallab.noisechrodetail = dataspot[83][0]; - dataspot[84][sp] = sensidens[sp] = params.locallab.sensiden = dataspot[84][0]; - - if (dataspot[85][0] == 0) { - params.locallab.expdenoi = false; - dataspot[85][sp] = 0; - expdenois[sp] = 0; - } else { - params.locallab.expdenoi = true; - dataspot[85][sp] = 1; - expdenois[sp] = 1; - } - - if (dataspot[86][0] == 0) { - params.locallab.expcolor = false; - dataspot[86][sp] = 0; - expcolors[sp] = 0; - } else { - params.locallab.expcolor = true; - dataspot[86][sp] = 1; - expcolors[sp] = 1; - } - - if (dataspot[87][0] == 0) { - params.locallab.expvibrance = false; - dataspot[87][sp] = 0; - expvibrances[sp] = 0; - } else { - params.locallab.expvibrance = true; - dataspot[87][sp] = 1; - expvibrances[sp] = 1; - } - - if (dataspot[88][0] == 0) { - params.locallab.expblur = false; - dataspot[88][sp] = 0; - expblurs[sp] = 0; - } else { - params.locallab.expblur = true; - dataspot[88][sp] = 1; - expblurs[sp] = 1; - } - - if (dataspot[89][0] == 0) { - params.locallab.exptonemap = false; - dataspot[89][sp] = 0; - exptonemaps[sp] = 0; - } else { - params.locallab.exptonemap = true; - dataspot[89][sp] = 1; - exptonemaps[sp] = 1; - } - - if (dataspot[90][0] == 0) { - params.locallab.expreti = false; - dataspot[90][sp] = 0; - expretis[sp] = 0; - } else { - params.locallab.expreti = true; - dataspot[90][sp] = 1; - expretis[sp] = 1; - } - - if (dataspot[91][0] == 0) { - params.locallab.expsharp = false; - dataspot[91][sp] = 0; - expsharps[sp] = 0; - } else { - params.locallab.expsharp = true; - dataspot[91][sp] = 1; - expsharps[sp] = 1; - } - - if (dataspot[92][0] == 0) { - params.locallab.expcbdl = false; - dataspot[92][sp] = 0; - expcbdls[sp] = 0; - } else { - params.locallab.expcbdl = true; - dataspot[92][sp] = 1; - expcbdls[sp] = 1; - } - - if (dataspot[93][0] == 0) { - params.locallab.expexpose = false; - dataspot[93][sp] = 0; - expexposes[sp] = 0; - } else { - params.locallab.expexpose = true; - dataspot[93][sp] = 1; - expexposes[sp] = 1; - } - - dataspot[94][sp] = bilaterals[sp] = params.locallab.bilateral = dataspot[94][0]; - dataspot[95][sp] = noiselequals[sp] = params.locallab.noiselequal = dataspot[95][0]; - - if (dataspot[96][0] == 0) { - params.locallab.shapemethod = "ELI" ; - shapemets[sp] = 0; - dataspot[96][sp] = 0; - } else if (dataspot[96][0] == 1) { - params.locallab.shapemethod = "RECT" ; - shapemets[sp] = 1; - dataspot[96][sp] = 1; - } - - int *s_datc; - s_datc = new int[70]; - int siz; - - ipf.strcurv_data(retistr[0], s_datc, siz); - sizeretics[sp] = siz; - std::vector cretiend; - - retistr[sp] = retistr[0]; - - for (int j = 0; j < siz; j++) { - reticurvs[sp * 500 + j] = s_datc[j]; - cretiend.push_back((double)(s_datc[j]) / 1000.); - - } - - params.locallab.localTgaincurve.clear(); - params.locallab.localTgaincurve = cretiend; - - delete [] s_datc; - - int *s_datcl; - s_datcl = new int[70]; - int sizl; - - ipf.strcurv_data(llstr[0], s_datcl, sizl); - sizellcs[sp] = sizl; - std::vector cllend; - - llstr[sp] = llstr[0]; - - for (int j = 0; j < sizl; j++) { - llcurvs[sp * 500 + j] = s_datcl[j]; - cllend.push_back((double)(s_datcl[j]) / 1000.); - - } - - params.locallab.llcurve.clear(); - params.locallab.llcurve = cllend; - - delete [] s_datcl; - - - int *s_datcc; - s_datcc = new int[70]; - int sizc; - - ipf.strcurv_data(ccstr[0], s_datcc, sizc); - sizecccs[sp] = sizc; - std::vector cccend; - - ccstr[sp] = ccstr[0]; - - for (int j = 0; j < sizc; j++) { - cccurvs[sp * 500 + j] = s_datcc[j]; - cccend.push_back((double)(s_datcc[j]) / 1000.); - - } - - params.locallab.cccurve.clear(); - params.locallab.cccurve = cccend; - - delete [] s_datcc; - - int *s_datch; - s_datch = new int[70]; - int sizh; - - ipf.strcurv_data(lhstr[0], s_datch, sizh); - sizelhcs[sp] = sizh; - std::vector clhend; - - lhstr[sp] = lhstr[0]; - - for (int j = 0; j < sizh; j++) { - lhcurvs[sp * 500 + j] = s_datch[j]; - clhend.push_back((double)(s_datch[j]) / 1000.); - - } - - params.locallab.LHcurve.clear(); - params.locallab.LHcurve = clhend; - - delete [] s_datch; - - int *s_datchh; - s_datchh = new int[70]; - int sizhh; - - ipf.strcurv_data(hhstr[0], s_datchh, sizhh); - sizehhcs[sp] = sizhh; - std::vector chhend; - - hhstr[sp] = hhstr[0]; - - for (int j = 0; j < sizhh; j++) { - hhcurvs[sp * 500 + j] = s_datchh[j]; - chhend.push_back((double)(s_datchh[j]) / 1000.); - - } - - params.locallab.HHcurve.clear(); - 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]; - // printf("B 0=%i 1=%i\n", s_datcps[0], s_datcps[1]); - std::string ps_str2 = ""; - - ps_str2 = ps_str2 + std::to_string(s_datcps[0]) + delim[0] + std::to_string(s_datcps[1]) + delim[1]; - pthstr[0] = ps_str2 + "@"; - - pthstr[sp] = pthstr[0]; - params.locallab.psthreshold.setValues(s_datcps[0], s_datcps[1]); - - //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; - - std::string t_curvhhref2 = "1000A0B500C350D350E166F500G350H350I333J500K350L350M500N500O350P350Q666R500S350T350U833V500W350X350Y@"; - - if (hhstr[sp].c_str() != t_curvhhref2) { - // HHutili = true; - } - - if (lhstr[sp].c_str() != t_curvhhref2) { - // LHutili = true; - } - - params.locallab.getCurves(locRETgainCurve, locRETgainCurverab, loclhCurve, lochhCurve, LHutili, HHutili); - locallutili = false; - localcutili = false; - localskutili = false; - localexutili = false; - - std::string t_curvskinref2 = "3000A0B0C1000D1000E@"; - std::string t_none2 = "0A@"; - - if (skinstr[sp].c_str() != t_curvskinref2 && skinstr[sp].c_str() != t_none2) { - // localskutili = true; - } - - std::string t_curvexref2 = "3000A0B0C1000D1000E@"; - - if (exstr[sp].c_str() != t_curvexref2 && exstr[sp].c_str() != t_none2) { - // localexutili = true; - } - - double ecomp = params.locallab.expcomp; - double black = params.locallab.black; - double hlcompr = params.locallab.hlcompr; - double hlcomprthresh = params.locallab.hlcomprthresh; - double shcompr = params.locallab.shcompr; - double br = params.locallab.lightness; - - CurveFactory::complexCurvelocal(ecomp, black / 65535., hlcompr, hlcomprthresh, shcompr, br, - hltonecurveloc, shtonecurveloc, tonecurveloc, lightCurveloc, - sca); - - 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.huerefblur = huerefblurs[sp] / 100.; - params.locallab.hueref = huerefs[sp] / 100.; - params.locallab.chromaref = chromarefs[sp]; - params.locallab.lumaref = lumarefs[sp]; - params.locallab.sobelref = sobelrefs[sp]; - ipf.Lab_Local(3, maxspot, sp, huerefs, sobelrefs, centerx, centery, (float**)shbuffer, nprevl, nprevl, reserv, 0, 0, pW, pH, scale, locRETgainCurve, lllocalcurve, loclhCurve, lochhCurve, LHutili, HHutili, cclocalcurve, - localskutili, sklocalcurve, localexutili, exlocalcurve, hltonecurveloc, shtonecurveloc, tonecurveloc, lightCurveloc, params.locallab.huerefblur, params.locallab.hueref, params.locallab.chromaref, params.locallab.lumaref, params.locallab.sobelref); - lllocalcurve.clear(); - cclocalcurve.clear(); - sklocalcurve.clear(); - exlocalcurve.clear(); - - //******************************************************* - //end current spot - //******************************************************* - - //******************************************************* - //write mip file in real time - //******************************************************* - - ofstream fou(datal, ios::out | ios::trunc); - - if (fou) { - mipver = 10024; //confirm new versionmip - last - same value as at beginning, - - for (int spe = 1; spe < maxspot; spe++) { - int t_sp = spe; - int t_mipversion = mipver;//actualize for current usage - int t_circrad = dataspot[2][spe]; - int t_locX = dataspot[3][spe]; - int t_locY = dataspot[4][spe]; - int t_locYT = dataspot[5][spe]; - int t_locXL = dataspot[6][spe]; - int t_centerX = dataspot[7][spe]; - int t_centerY = dataspot[8][spe]; - int t_lightness = dataspot[9][spe]; - int t_contrast = dataspot[10][spe]; - int t_chroma = dataspot[11][spe]; - int t_sensi = dataspot[12][spe]; - int t_transit = dataspot[13][spe]; - int t_invers = dataspot[14][spe]; - int t_Smeth = dataspot[15][spe]; - int t_currentspot = realspot; - int t_radius = dataspot[17][spe]; - int t_strength = dataspot[18][spe]; - int t_sensibn = dataspot[19][spe]; - int t_inversrad = dataspot[20][spe]; - int t_str = dataspot[21][spe]; - int t_chrrt = dataspot[22][spe]; - int t_neigh = dataspot[23][spe]; - int t_vart = dataspot[24][spe]; - int t_sensih = dataspot[25][spe]; - int t_inversret = dataspot[26][spe]; - int t_retinexMethod = dataspot[27][spe]; - int t_sharradius = dataspot[28][spe]; - int t_sharamount = dataspot[29][spe]; - int t_shardamping = dataspot[30][spe]; - int t_shariter = dataspot[31][spe]; - int t_sensisha = dataspot[32][spe]; - int t_inverssha = dataspot[33][spe]; - int t_qualityMethod = dataspot[34][spe]; - int t_thres = dataspot[35][spe]; - int t_proxi = dataspot[36][spe]; - int t_noiselumf = dataspot[37][spe]; - int t_noiselumc = dataspot[38][spe]; - int t_noisechrof = dataspot[39][spe]; - int t_noisechroc = dataspot[40][spe]; - int t_mult0 = dataspot[41][spe]; - int t_mult1 = dataspot[42][spe]; - int t_mult2 = dataspot[43][spe]; - int t_mult3 = dataspot[44][spe]; - int t_mult4 = dataspot[45][spe]; - int t_threshold = dataspot[46][spe]; - int t_sensicb = dataspot[47][spe]; - int t_activlum = dataspot[48][spe]; - - int t_stren = dataspot[49][spe]; - int t_gamma = dataspot[50][spe]; - int t_estop = dataspot[51][spe]; - int t_scaltm = dataspot[52][spe]; - int t_rewei = dataspot[53][spe]; - int t_sensitm = dataspot[54][spe]; - int t_retrab = dataspot[55][spe]; - int t_curvactiv = dataspot[56][spe]; - int t_qualitycurveMethod = dataspot[57][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_expcomp = dataspot[64][spe]; - int t_black = dataspot[65][spe]; - int t_hlcompr = dataspot[66][spe]; - int t_hlcomprthresh = dataspot[67][spe]; - int t_shcompr = dataspot[68][spe]; - int t_sensiex = dataspot[69][spe]; - - int t_centerXbuf = dataspot[70][spe]; - int t_centerYbuf = dataspot[71][spe]; - int t_adjblur = dataspot[72][spe]; - int t_cutpast = dataspot[73][spe]; - - int t_chromacbdl = dataspot[74][spe]; - - int t_lastdust = dataspot[75][spe]; - int t_blurMethod = dataspot[76][spe]; - int t_dustMethod = dataspot[77][spe]; - - int t_excludemeth = dataspot[78][spe]; - int t_sensiexclu = dataspot[79][spe]; - int t_struc = dataspot[80][spe]; - int t_warm = dataspot[81][spe]; - int t_noiselumdetail = dataspot[82][spe]; - int t_noisechrodetail = dataspot[83][spe]; - int t_sensiden = dataspot[84][spe]; - int t_expdenoi = dataspot[85][spe]; - - int t_expcolor = dataspot[86][spe]; - int t_expvibrance = dataspot[87][spe]; - int t_expblur = dataspot[88][spe]; - int t_exptonemap = dataspot[89][spe]; - int t_expreti = dataspot[90][spe]; - int t_expsharp = dataspot[91][spe]; - int t_expcbdl = dataspot[92][spe]; - int t_expexpose = dataspot[93][spe]; - - int t_bilateral = dataspot[94][spe]; - int t_noiselequal = dataspot[95][spe]; - int t_shapemeth = dataspot[96][spe]; - - int t_huerefblur = dataspot[maxdata - 5][spe]; - int t_hueref = dataspot[maxdata - 4][spe]; - int t_chromaref = dataspot[maxdata - 3][spe]; - int t_lumaref = dataspot[maxdata - 2][spe]; - int t_sobelref = dataspot[maxdata - 1][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]; - std::string t_curvex = exstr[spe]; - - fou << "Mipversion=" << t_mipversion << '@' << endl; - fou << "Spot=" << t_sp << '@' << endl; - fou << "Circrad=" << t_circrad << '@' << endl; - fou << "LocX=" << t_locX << '@' << endl; - fou << "LocY=" << t_locY << '@' << endl; - fou << "LocYT=" << t_locYT << '@' << endl; - fou << "LocXL=" << t_locXL << '@' << endl ; - fou << "CenterX=" << t_centerX << '@' << endl; - fou << "CenterY=" << t_centerY << '@' << endl; - fou << "Lightness=" << t_lightness << '@' << endl; - fou << "Contrast=" << t_contrast << '@' << endl; - fou << "Chroma=" << t_chroma << '@' << endl; - fou << "Sensi=" << t_sensi << '@' << endl; - fou << "Transit=" << t_transit << '@' << endl; - fou << "Invers=" << t_invers << '@' << endl; - fou << "Smethod=" << t_Smeth << '@' << endl; - fou << "Currentspot=" << t_currentspot << '@' << endl; - fou << "Radius=" << t_radius << '@' << endl; - fou << "Strength=" << t_strength << '@' << endl; - fou << "Sesibn=" << t_sensibn << '@' << endl; - fou << "Inversrad=" << t_inversrad << '@' << endl; - fou << "Str=" << t_str << '@' << endl; - fou << "Chroma=" << t_chrrt << '@' << endl; - fou << "Neigh=" << t_neigh << '@' << endl; - fou << "Vart=" << t_vart << '@' << endl; - fou << "Sensih=" << t_sensih << '@' << endl; - fou << "Inversret=" << t_inversret << '@' << endl; - fou << "retinexMethod=" << t_retinexMethod << '@' << endl; - fou << "Sharradius=" << t_sharradius << '@' << endl; - fou << "Sharamount=" << t_sharamount << '@' << endl; - fou << "Shardamping=" << t_shardamping << '@' << endl; - fou << "Shariter=" << t_shariter << '@' << endl; - fou << "Sensisha=" << t_sensisha << '@' << endl; - fou << "Inverssha=" << t_inverssha << '@' << endl; - fou << "qualityMethod=" << t_qualityMethod << '@' << endl; - fou << "Thres=" << t_thres << '@' << endl; - fou << "Proxi=" << t_proxi << '@' << endl; - fou << "Noiselumf=" << t_noiselumf << '@' << endl; - fou << "Noiselumc=" << t_noiselumc << '@' << endl; - fou << "Noisechrof=" << t_noisechrof << '@' << endl; - fou << "Noisechroc=" << t_noisechroc << '@' << endl; - fou << "Mult0=" << t_mult0 << '@' << endl; - fou << "Mult1=" << t_mult1 << '@' << endl; - fou << "Mult2=" << t_mult2 << '@' << endl; - fou << "Mult3=" << t_mult3 << '@' << endl; - fou << "Mult4=" << t_mult4 << '@' << endl; - fou << "Threshold=" << t_threshold << '@' << endl; - fou << "Sensicb=" << t_sensicb << '@' << endl; - fou << "Activblurlum=" << t_activlum << '@' << endl; - - fou << "Stren=" << t_stren << '@' << endl; - fou << "Gamma=" << t_gamma << '@' << endl; - fou << "Estop=" << t_estop << '@' << endl; - fou << "Scaltm=" << t_scaltm << '@' << endl; - fou << "Rewei=" << t_rewei << '@' << endl; - fou << "Sensitm=" << t_sensitm << '@' << endl; - - fou << "Retrab=" << t_retrab << '@' << endl; - fou << "Curvactiv=" << t_curvactiv << '@' << endl; - fou << "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 << "Expcomp=" << t_expcomp << '@' << endl; - fou << "Black=" << t_black << '@' << endl; - fou << "Hlcompr=" << t_hlcompr << '@' << endl; - fou << "Hlcomprthresh=" << t_hlcomprthresh << '@' << endl; - fou << "Shcompr=" << t_shcompr << '@' << endl; - fou << "Sensiex=" << t_sensiex << '@' << endl; - - fou << "CenterXbuf=" << t_centerXbuf << '@' << endl; - fou << "CenterYbuf=" << t_centerYbuf << '@' << endl; - fou << "Adjblur=" << t_adjblur << '@' << endl; - fou << "Cutpast=" << t_cutpast << '@' << endl; - - fou << "Chromacbdl=" << t_chromacbdl << '@' << endl; - fou << "Lastdust=" << t_lastdust << '@' << endl; - fou << "BlurMethod=" << t_blurMethod << '@' << endl; - fou << "DustMethod=" << t_dustMethod << '@' << endl; - - fou << "ExcludeMethod=" << t_excludemeth << '@' << endl; - fou << "Sensiexclu=" << t_sensiexclu << '@' << endl; - fou << "Struc=" << t_struc << '@' << endl; - fou << "Warm=" << t_warm << '@' << endl; - fou << "Noiselumdetail=" << t_noiselumdetail << '@' << endl; - fou << "Noisechrodetail=" << t_noisechrodetail << '@' << endl; - fou << "Sensiden=" << t_sensiden << '@' << endl; - fou << "Expdenoi=" << t_expdenoi << '@' << endl; - fou << "Expcolor=" << t_expcolor << '@' << endl; - fou << "Expvibrance=" << t_expvibrance << '@' << endl; - fou << "Expblur=" << t_expblur << '@' << endl; - fou << "Exptonemap=" << t_exptonemap << '@' << endl; - fou << "Expreti=" << t_expreti << '@' << endl; - fou << "Expsharp=" << t_expsharp << '@' << endl; - fou << "Expcbdl=" << t_expcbdl << '@' << endl; - fou << "Expexpose=" << t_expexpose << '@' << endl; - - fou << "Bilateral=" << t_bilateral << '@' << endl; - fou << "Noiselequal=" << t_noiselequal << '@' << endl; - fou << "ShapeMethod=" << t_shapemeth << '@' << endl; - - fou << "huerefblur=" << t_huerefblur << '@' << endl; - fou << "hueref=" << t_hueref << '@' << endl; - fou << "chromaref=" << t_chromaref << '@' << endl; - fou << "lumaref=" << t_lumaref << '@' << endl; - fou << "sobelref=" << t_sobelref << '@' << 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 << "curveskin=" << t_curvskin << endl; - fou << "pthres=" << t_psthres << endl; - fou << "curveex=" << t_curvex << endl; - - fou << endl; - } - - fou.close(); - } - - //******************************************************** - //end write mip file - //********************************************************* - - //clean all - for (int i = 0; i < maxdata; i++) { - delete [] dataspot[i]; - } - - delete [] dataspot; - - delete [] retistr; - delete [] llstr; - delete [] lhstr; - delete [] ccstr; - delete [] hhstr; - delete [] skinstr; - delete [] pthstr; - delete [] exstr; - - } - - //************************************************************* - // end locallab - //************************************************************* - - histCCurve.clear(); - histLCurve.clear(); - ipf.chromiLuminanceCurve(nullptr, pW, nprevl, nprevl, chroma_acurve, chroma_bcurve, satcurve, lhskcurve, clcurve, lumacurve, utili, autili, butili, ccutili, cclutili, clcutili, histCCurve, histLCurve); - ipf.vibrance(nprevl); - - if ((params.colorappearance.enabled && !params.colorappearance.tonecie) || (!params.colorappearance.enabled)) { + 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 - readyphase++; + // for all treatments Defringe, Sharpening, Contrast detail , Microcontrast they are activated if "CIECAM" function are disabled + readyphase++; - /* Issue 2785, disabled some 1:1 tools + /* Issue 2785, disabled some 1:1 tools if (scale==1) { if((params.colorappearance.enabled && !settings->autocielab) || (!params.colorappearance.enabled)){ progress ("Denoising luminance impulse...",100*readyphase/numofphases); @@ -3725,9 +917,8 @@ void ImProcCoordinator::updatePreviewImage(int todo, Crop* cropCall) delete [] buffer; readyphase++; } - */ - } - + } + */ if (params.dirpyrequalizer.cbdlMethod == "aft") { if (((params.colorappearance.enabled && !settings->autocielab) || (!params.colorappearance.enabled))) { progress("Pyramid wavelet...", 100 * readyphase / numofphases); diff --git a/rtengine/improccoordinator.h b/rtengine/improccoordinator.h index 8b06c85cb..8cb71eea5 100644 --- a/rtengine/improccoordinator.h +++ b/rtengine/improccoordinator.h @@ -242,8 +242,6 @@ protected: bool HHutili; bool curveutili; - std::string prevmdfive; - Glib::ustring datal; int **dataspot; int maxdata; std::string *retistr; @@ -254,7 +252,6 @@ protected: std::string *skinstr; std::string *pthstr; std::string *exstr; - std::string *name; LUTi circrads; LUTi centerx; diff --git a/rtengine/improcfun.cc b/rtengine/improcfun.cc index 896adeaff..08072550c 100644 --- a/rtengine/improcfun.cc +++ b/rtengine/improcfun.cc @@ -5224,21 +5224,14 @@ void ImProcFunctions::EPDToneMapCIE(CieImage *ncie, float a_w, float c_, int Wid */ } -void ImProcFunctions::EPDToneMaplocal(LabImage *lab, LabImage *tmp1, unsigned int Iterates, int skip) +void ImProcFunctions::EPDToneMaplocal(int sp, LabImage *lab, LabImage *tmp1, unsigned int Iterates, int skip) { - // TODO Locallab - /* - float stren = ((float)params->locallab.stren) / 100.f; - float edgest = ((float)params->locallab.estop) / 100.f; - float sca = ((float)params->locallab.scaltm) / 10.f; - float gamm = ((float)params->locallab.gamma) / 100.f; - float rew = ((float)params->locallab.rewei); - */ - float stren = 0.f; - float edgest = 0.f; - float sca = 0.f; - float gamm = 0.f; - float rew = 0.f; + + float stren = ((float)params->locallab.stren.at(sp)) / 100.f; + float edgest = ((float)params->locallab.estop.at(sp)) / 100.f; + float sca = ((float)params->locallab.scaltm.at(sp)) / 10.f; + float gamm = ((float)params->locallab.gamma.at(sp)) / 100.f; + float rew = ((float)params->locallab.rewei.at(sp)); //Pointers to whole data and size of it. float *L = lab->L[0]; float *a = lab->a[0]; diff --git a/rtengine/improcfun.h b/rtengine/improcfun.h index 9b31bbc7a..bde24a6f8 100644 --- a/rtengine/improcfun.h +++ b/rtengine/improcfun.h @@ -202,7 +202,7 @@ public: double lumimul[3]; ImProcFunctions(const ProcParams* iparams, bool imultiThread = true) - : monitorTransform (nullptr), params (iparams), scale (1), multiThread (imultiThread), lumimul{} {} + : monitorTransform(nullptr), params(iparams), scale(1), multiThread(imultiThread), lumimul{} {} ~ImProcFunctions(); bool needsLuminanceOnly() { @@ -216,10 +216,10 @@ public: void firstAnalysis(const Imagefloat* const working, const ProcParams ¶ms, LUTu & vhist16); void updateColorProfiles(const Glib::ustring& monitorProfile, RenderingIntent monitorIntent, bool softProof, bool gamutCheck); void rgbProc(Imagefloat* working, LabImage* lab, PipetteBuffer *pipetteBuffer, LUTf & hltonecurve, LUTf & shtonecurve, LUTf & tonecurve, - int sat, LUTf & rCurve, LUTf & gCurve, LUTf & bCurve, float satLimit, float satLimitOpacity, const ColorGradientCurve & ctColorCurve, const OpacityCurve & ctOpacityCurve, bool opautili, LUTf & clcurve, LUTf & cl2curve, const ToneCurve & customToneCurve1, const ToneCurve & customToneCurve2, + int sat, LUTf & rCurve, LUTf & gCurve, LUTf & bCurve, float satLimit, float satLimitOpacity, const ColorGradientCurve & ctColorCurve, const OpacityCurve & ctOpacityCurve, bool opautili, LUTf & clcurve, LUTf & cl2curve, const ToneCurve & customToneCurve1, const ToneCurve & customToneCurve2, const ToneCurve & customToneCurvebw1, const ToneCurve & customToneCurvebw2, double &rrm, double &ggm, double &bbm, float &autor, float &autog, float &autob, DCPProfile *dcpProf, const DCPProfile::ApplyState &asIn, LUTu &histToneCurve); void rgbProc(Imagefloat* working, LabImage* lab, PipetteBuffer *pipetteBuffer, LUTf & hltonecurve, LUTf & shtonecurve, LUTf & tonecurve, - int sat, LUTf & rCurve, LUTf & gCurve, LUTf & bCurve, float satLimit, float satLimitOpacity, const ColorGradientCurve & ctColorCurve, const OpacityCurve & ctOpacityCurve, bool opautili, LUTf & clcurve, LUTf & cl2curve, const ToneCurve & customToneCurve1, const ToneCurve & customToneCurve2, + int sat, LUTf & rCurve, LUTf & gCurve, LUTf & bCurve, float satLimit, float satLimitOpacity, const ColorGradientCurve & ctColorCurve, const OpacityCurve & ctOpacityCurve, bool opautili, LUTf & clcurve, LUTf & cl2curve, const ToneCurve & customToneCurve1, const ToneCurve & customToneCurve2, const ToneCurve & customToneCurvebw1, const ToneCurve & customToneCurvebw2, double &rrm, double &ggm, double &bbm, float &autor, float &autog, float &autob, double expcomp, int hlcompr, int hlcomprthresh, DCPProfile *dcpProf, const DCPProfile::ApplyState &asIn, LUTu &histToneCurve); void labtoning(float r, float g, float b, float &ro, float &go, float &bo, int algm, int metchrom, int twoc, float satLimit, float satLimitOpacity, const ColorGradientCurve & ctColorCurve, const OpacityCurve & ctOpacityCurve, LUTf & clToningcurve, LUTf & cl2Toningcurve, float iplow, float iphigh, double wp[3][3], double wip[3][3]); @@ -234,17 +234,17 @@ public: void luminanceCurve(LabImage* lold, LabImage* lnew, LUTf &curve); - void ciecamloc_02float(LabImage* lab, LabImage* dest); + void ciecamloc_02float(int sp, LabImage* lab, LabImage* dest); void ciecam_02float(CieImage* ncie, float adap, int pW, int pwb, LabImage* lab, const ProcParams* params, const ColorAppearance & customColCurve1, const ColorAppearance & customColCurve, const ColorAppearance & customColCurve3, - LUTu &histLCAM, LUTu &histCCAM, LUTf & CAMBrightCurveJ, LUTf & CAMBrightCurveQ, float &mean, int Iterates, int scale, bool execsharp, float &d, float &dj, float &yb, int rtt, - bool showSharpMask = false); + LUTu &histLCAM, LUTu &histCCAM, LUTf & CAMBrightCurveJ, LUTf & CAMBrightCurveQ, float &mean, int Iterates, int scale, bool execsharp, float &d, float &dj, float &yb, int rtt, + bool showSharpMask = false); void chromiLuminanceCurve(PipetteBuffer *pipetteBuffer, int pW, LabImage* lold, LabImage* lnew, LUTf &acurve, LUTf &bcurve, LUTf & satcurve, LUTf & satclcurve, LUTf &clcurve, LUTf &curve, bool utili, bool autili, bool butili, bool ccutili, bool cclutili, bool clcutili, LUTu &histCCurve, LUTu &histLurve); void vibrance(LabImage* lab); //Jacques' vibrance // void colorCurve (LabImage* lold, LabImage* lnew); - void sharpening (LabImage* lab, const SharpeningParams &sharpenParam, bool showMask = false); - void sharpeningcam (CieImage* ncie, float** buffer, bool showMask = false); + void sharpening(LabImage* lab, const SharpeningParams &sharpenParam, bool showMask = false); + void sharpeningcam(CieImage* ncie, float** buffer, bool showMask = false); void transform(Imagefloat* original, Imagefloat* transformed, int cx, int cy, int sx, int sy, int oW, int oH, int fW, int fH, const FramesMetaData *metadata, int rawRotationDeg, bool fullImage); float resizeScale(const ProcParams* params, int fw, int fh, int &imw, int &imh); void lab2monitorRgb(LabImage* lab, Image8* image); @@ -275,7 +275,7 @@ public: float *ContrastDR(float *Source, int W_L, int H_L, float *Contrast = nullptr); void EPDToneMap(LabImage *lab, unsigned int Iterates = 0, int skip = 1); - void EPDToneMaplocal(LabImage *lab, LabImage *tmp1, unsigned int Iterates, int skip); + void EPDToneMaplocal(int sp, LabImage *lab, LabImage *tmp1, unsigned int Iterates, int skip); void EPDToneMapCIE(CieImage *ncie, float a_w, float c_, int Wid, int Hei, float minQ, float maxQ, unsigned int Iterates = 0, int skip = 1); // pyramid denoise @@ -285,9 +285,9 @@ public: void idirpyr(LabImage* data_coarse, LabImage* data_fine, int level, LUTf &rangefn_L, LUTf & nrwt_l, LUTf & nrwt_ab, int pitch, int scale, const int luma, const int chroma/*, LUTf & Lcurve, LUTf & abcurve*/); //locallab - void MSRLocal(float** luminance, float** templ, const float* const *originalLuminance, const int width, const int height, const LocallabParams &loc, const int skip, const LocretigainCurve &locRETgainCcurve, const int chrome, const int scall, const float krad, float &minCD, float &maxCD, float &mini, float &maxi, float &Tmean, float &Tsigma, float &Tmin, float &Tmax); + void MSRLocal(int sp, 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 (LabImage* original, LabImage* transformed, int cx, int cy, int oW, int oH, int sk, double &huere, double &chromare, double &lumare, double &sobelref); - void calc_ref(LabImage* original, LabImage* transformed, int cx, int cy, int oW, int oH, int sk, double &huerefblur, double &huere, double &chromare, double &lumare, double &sobelref); + void calc_ref(int sp, LabImage* original, LabImage* transformed, int cx, int cy, int oW, int oH, int sk, double &huerefblur, double &huere, double &chromare, double &lumare, double &sobelref); void copy_ref(LabImage* spotbuffer, LabImage* original, LabImage* transformed, int cx, int cy, int sk, const struct local_params & lp, double &huerefspot, double &chromarefspot, double &lumarefspot); void paste_ref(LabImage* spotbuffer, LabImage* transformed, int cx, int cy, int sk, const struct local_params & lp); void Lab_Local(int call, int maxspot, int sp, LUTf & huerefs, LUTf & sobelrefs, LUTi & centerx, LUTi & centery, float** shbuffer, LabImage* original, LabImage* transformed, LabImage* reserved, int cx, int cy, int oW, int oH, int sk, const LocretigainCurve & locRETgainCcurve, 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, LUTf & lightCurveloc, double & huerefblur, double &hueref, double &chromaref, double &lumaref, double &sobelref); @@ -303,7 +303,7 @@ public: static void strcurv_data(std::string retistr, int *s_datc, int &siz); void InverseContrast_Local(float ave, struct local_contra & lco, const struct local_params & lp, const float hueplus, const float huemoins, const float hueref, const float dhue, const float chromaref, const float lumaref, LabImage * original, LabImage * transformed, int cx, int cy, int sk); - void vibrancelocal(int bfw, int bfh, LabImage* lab, LabImage* dest, bool & localskutili, LUTf & sklocalcurve); + void vibrancelocal(int sp, int bfw, int bfh, LabImage* lab, LabImage* dest, bool & localskutili, LUTf & sklocalcurve); void Expo_vibr_Local(int senstype, float **buflight, float **bufchro, const float hueplus, const float huemoins, const float hueref, const float dhue, const float chromaref, const float lumaref, const struct local_params & lp, LabImage * original, LabImage * transformed, const LabImage * const tmp1, int cx, int cy, int sk); void exlabLocal(const local_params& lp, int bfh, int bfw, LabImage* bufexporig, LabImage* lab, LUTf & hltonecurve, LUTf & shtonecurve, LUTf & tonecurve); void Exclude_Local(int sen, float **deltaso, float **buflight, float **bufchro, const float hueplus, const float huemoins, const float hueref, const float dhue, const float chromaref, const float lumaref, const struct local_params & lp, LabImage * original, LabImage * transformed, LabImage * rsv, int cx, int cy, int sk); @@ -389,13 +389,13 @@ public: void idirpyr_eq_channelcam(float ** data_coarse, float ** data_fine, float ** buffer, int width, int height, int level, float multi[6], const double dirpyrThreshold, float ** l_a_h, float ** l_b_c, const double skinprot, float b_l, float t_l, float t_r); void defringe(LabImage* lab); void defringecam(CieImage* ncie); - void badpixcam (CieImage* ncie, double rad, int thr, int mode, float chrom, bool hotbad); - void badpixlab (LabImage* lab, double rad, int thr, float chrom); + void badpixcam(CieImage* ncie, double rad, int thr, int mode, float chrom, bool hotbad); + void badpixlab(LabImage* lab, double rad, int thr, float chrom); - void PF_correct_RT (LabImage * lab, double radius, int thresh); - void PF_correct_RTcam (CieImage * ncie, double radius, int thresh); - void Badpixelscam (CieImage * ncie, double radius, int thresh, int mode, float chrom, bool hotbad); - void BadpixelsLab (LabImage * lab, double radius, int thresh, float chrom); + void PF_correct_RT(LabImage * lab, double radius, int thresh); + void PF_correct_RTcam(CieImage * ncie, double radius, int thresh); + void Badpixelscam(CieImage * ncie, double radius, int thresh, int mode, float chrom, bool hotbad); + void BadpixelsLab(LabImage * lab, double radius, int thresh, float chrom); void ToneMapFattal02(Imagefloat *rgb); void localContrast(LabImage *lab); diff --git a/rtengine/iplocallab.cc b/rtengine/iplocallab.cc index a5656c3a4..002035e2c 100644 --- a/rtengine/iplocallab.cc +++ b/rtengine/iplocallab.cc @@ -327,120 +327,119 @@ static void SobelCannyLuma(float **sobelL, float **luma, int bfw, int bfh, float -static void calcLocalParams(int oW, int oH, const LocallabParams& locallab, struct local_params& lp) +static void calcLocalParams(int sp, int oW, int oH, const LocallabParams& locallab, struct local_params& lp) { - // TODO Locallab - /* int w = oW; int h = oH; - int circr = locallab.circrad; - float streng = ((float)locallab.stren) / 100.f; - float gam = ((float)locallab.gamma) / 100.f; - float est = ((float)locallab.estop) / 100.f; - float scal_tm = ((float)locallab.scaltm) / 10.f; - float rewe = ((float)locallab.rewei); + int circr = locallab.circrad.at(sp); + float streng = ((float)locallab.stren.at(sp)) / 100.f; + float gam = ((float)locallab.gamma.at(sp)) / 100.f; + float est = ((float)locallab.estop.at(sp)) / 100.f; + float scal_tm = ((float)locallab.scaltm.at(sp)) / 10.f; + float rewe = ((float)locallab.rewei.at(sp)); - float thre = locallab.thres / 100.f; - double local_x = locallab.locX / 2000.0; - double local_y = locallab.locY / 2000.0; - double local_xL = locallab.locXL / 2000.0; - double local_yT = locallab.locYT / 2000.0; - double local_center_x = locallab.centerX / 2000.0 + 0.5; - double local_center_y = locallab.centerY / 2000.0 + 0.5; - double local_center_xbuf = locallab.centerXbuf / 2000.0; - double local_center_ybuf = locallab.centerYbuf / 2000.0; - double local_dxx = locallab.proxi / 8000.0;//for proxi = 2==> # 1 pixel - double local_dyy = locallab.proxi / 8000.0; - float iterati = (float) locallab.proxi; - // double local_dyy = locallab.proxi; + float thre = locallab.thresh.at(sp) / 100.f; + double local_x = locallab.locX.at(sp) / 2000.0; + double local_y = locallab.locY.at(sp) / 2000.0; + double local_xL = locallab.locXL.at(sp) / 2000.0; + double local_yT = locallab.locYT.at(sp) / 2000.0; + double local_center_x = locallab.centerX.at(sp) / 2000.0 + 0.5; + double local_center_y = locallab.centerY.at(sp) / 2000.0 + 0.5; + double local_center_xbuf = 0.0; // Provision + double local_center_ybuf = 0.0; // Provision + double local_dxx = locallab.iter.at(sp) / 8000.0; //for proxi = 2==> # 1 pixel + double local_dyy = locallab.iter.at(sp) / 8000.0; + float iterati = (float) locallab.iter.at(sp); +// double local_dyy = locallab.proxi; - float chromaPastel = float (locallab.pastels) / 100.0f; - float chromaSatur = float (locallab.saturated) / 100.0f; - int local_sensiv = locallab.sensiv; - int local_sensiex = locallab.sensiex; + float chromaPastel = float (locallab.pastels.at(sp)) / 100.0f; + float chromaSatur = float (locallab.saturated.at(sp)) / 100.0f; + int local_sensiv = locallab.sensiv.at(sp); + int local_sensiex = locallab.sensiex.at(sp); - if (locallab.qualityMethod == "std") { + if (locallab.qualityMethod.at(sp) == "std") { lp.qualmet = 0; - } else if (locallab.qualityMethod == "enh") { + } else if (locallab.qualityMethod.at(sp) == "enh") { lp.qualmet = 1; - } else if (locallab.qualityMethod == "enhden") { + } else if (locallab.qualityMethod.at(sp) == "enhden") { lp.qualmet = 2; } - if (locallab.qualitycurveMethod == "none") { + if (locallab.qualitycurveMethod.at(sp) == "none") { lp.qualcurvemet = 0; - } else if (locallab.qualitycurveMethod == "std") { + } else if (locallab.qualitycurveMethod.at(sp) == "std") { lp.qualcurvemet = 1; - } else if (locallab.qualitycurveMethod == "enh") { + } else if (locallab.qualitycurveMethod.at(sp) == "enh") { lp.qualcurvemet = 2; } - if (locallab.blurMethod == "norm") { + if (locallab.blurMethod.at(sp) == "norm") { lp.blurmet = 0; - } else if (locallab.blurMethod == "inv") { + } else if (locallab.blurMethod.at(sp) == "inv") { lp.blurmet = 1; - } else if (locallab.blurMethod == "sym") { + } else if (locallab.blurMethod.at(sp) == "sym") { lp.blurmet = 2; } - if (locallab.Exclumethod == "norm") { + if (locallab.spotMethod.at(sp) == "norm") { lp.excmet = 0; - } else if (locallab.Exclumethod == "exc") { + } else if (locallab.spotMethod.at(sp) == "exc") { lp.excmet = 1; } - if (locallab.shapemethod == "ELI") { + if (locallab.shape.at(sp) == "ELI") { lp.shapmet = 0; - } else if (locallab.shapemethod == "RECT") { + } else if (locallab.shape.at(sp) == "RECT") { lp.shapmet = 1; } - float local_noiself = (float)locallab.noiselumf; - float local_noiselc = (float)locallab.noiselumc; - float local_noiseldetail = locallab.noiselumdetail; - int local_noiselequal = locallab.noiselequal; - float local_noisechrodetail = locallab.noisechrodetail; - int local_sensiden = locallab.sensiden; + float local_noiself = (float)locallab.noiselumf.at(sp); + float local_noiselc = (float)locallab.noiselumc.at(sp); + float local_noiseldetail = locallab.noiselumdetail.at(sp); + int local_noiselequal = locallab.noiselequal.at(sp); + float local_noisechrodetail = 0.f; // Provision + int local_sensiden = locallab.sensiden.at(sp); - float local_noisecf = ((float)locallab.noisechrof) / 10.f; - float local_noisecc = ((float)locallab.noisechroc) / 10.f; + float local_noisecf = ((float)locallab.noisechrof.at(sp)) / 10.f; + float local_noisecc = ((float)locallab.noisechroc.at(sp)) / 10.f; float multi[5]; for (int y = 0; y < 5; y++) { - multi[y] = ((float) locallab.mult[y]) / 100.f; + multi[y] = ((float) locallab.mult[y].at(sp)) / 100.f; } - float thresho = ((float)locallab.threshold) / 100.f; - float chromcbdl = (float)locallab.chromacbdl ; + float thresho = ((float)locallab.threshold.at(sp)) / 100.f; + float chromcbdl = (float)locallab.chromacbdl.at(sp); - int local_chroma = locallab.chroma; - int local_sensi = locallab.sensi; - int local_sensibn = locallab.sensibn; - int local_sensitm = locallab.sensitm; - int local_sensiexclu = locallab.sensiexclu; - int local_struc = locallab.struc; - int local_warm = locallab.warm; - int local_sensih = locallab.sensih; - int local_sensicb = locallab.sensicb; - int local_contrast = locallab.contrast; - float local_lightness = (float) locallab.lightness; - int local_transit = locallab.transit; - double radius = (double) locallab.radius; - double sharradius = ((double) locallab.sharradius) / 100. ; - int local_sensisha = locallab.sensisha; - int local_sharamount = locallab.sharamount; - int local_shardamping = locallab.shardamping; - int local_shariter = locallab.shariter; - bool inverse = locallab.invers; - bool curvacti = locallab.curvactiv; - bool acti = locallab.activlum; - bool cupas = locallab.cutpast; + int local_chroma = locallab.chroma.at(sp); + int local_sensi = locallab.sensi.at(sp); + int local_sensibn = locallab.sensibn.at(sp); + int local_sensitm = locallab.sensitm.at(sp); + int local_sensiexclu = 19; // Provision + int local_struc = 0; // Provision + int local_warm = locallab.warm.at(sp); + int local_sensih = locallab.sensih.at(sp); + int local_sensicb = locallab.sensicb.at(sp); + int local_contrast = locallab.contrast.at(sp); + float local_lightness = (float) locallab.lightness.at(sp); + int local_transit = locallab.transit.at(sp); + double radius = (double) locallab.radius.at(sp); + double sharradius = ((double) locallab.sharradius.at(sp)) / 100. ; + int local_sensisha = locallab.sensisha.at(sp); + int local_sharamount = locallab.sharamount.at(sp); + int local_shardamping = locallab.shardamping.at(sp); + int local_shariter = locallab.shariter.at(sp); + bool inverse = locallab.invers.at(sp); + bool curvacti = locallab.curvactiv.at(sp); + bool acti = locallab.activlum.at(sp); + bool cupas = false; // Provision + + bool inverserad = false; // Provision + bool inverseret = locallab.inversret.at(sp); + bool inversesha = locallab.inverssha.at(sp); + double strength = (double) locallab.strength.at(sp); + float str = (float)locallab.str.at(sp); - bool inverserad = locallab.inversrad; - bool inverseret = locallab.inversret; - bool inversesha = locallab.inverssha; - double strength = (double) locallab.strength; - float str = (float)locallab.str; lp.cir = circr; lp.actsp = acti; lp.xc = w * local_center_x; @@ -491,8 +490,8 @@ static void calcLocalParams(int oW, int oH, const LocallabParams& locallab, stru lp.noisecf = local_noisecf; lp.noisecc = local_noisecc; lp.sensden = local_sensiden; - lp.bilat = locallab.bilateral; - lp.adjch = (float) locallab.adjblur; + lp.bilat = locallab.bilateral.at(sp); + lp.adjch = (float) locallab.adjblur.at(sp); lp.strengt = streng; lp.gamm = gam; lp.esto = est; @@ -506,29 +505,28 @@ static void calcLocalParams(int oW, int oH, const LocallabParams& locallab, stru lp.threshol = thresho; lp.chromacb = chromcbdl; - lp.colorena = locallab.expcolor; - lp.blurena = locallab.expblur; - lp.tonemapena = locallab.exptonemap; - lp.retiena = locallab.expreti; - lp.sharpena = locallab.expsharp; - lp.cbdlena = locallab.expcbdl; - lp.denoiena = locallab.expdenoi; - lp.expvib = locallab.expvibrance; + lp.colorena = locallab.expcolor.at(sp); + lp.blurena = locallab.expblur.at(sp); + lp.tonemapena = locallab.exptonemap.at(sp); + lp.retiena = locallab.expreti.at(sp); + lp.sharpena = locallab.expsharp.at(sp); + lp.cbdlena = locallab.expcbdl.at(sp); + lp.denoiena = locallab.expdenoi.at(sp); + lp.expvib = locallab.expvibrance.at(sp); lp.sensv = local_sensiv; lp.past = chromaPastel; lp.satur = chromaSatur; - lp.exposena = locallab.expexpose; + lp.exposena = locallab.expexpose.at(sp); lp.cut_past = cupas; - lp.blac = locallab.black; - lp.shcomp = locallab.shcompr; - lp.hlcomp = locallab.hlcompr; - lp.hlcompthr = locallab.hlcomprthresh; - lp.expcomp = locallab.expcomp / 100.; + lp.blac = locallab.black.at(sp); + lp.shcomp = locallab.shcompr.at(sp); + lp.hlcomp = locallab.hlcompr.at(sp); + lp.hlcompthr = locallab.hlcomprthresh.at(sp); + lp.expcomp = locallab.expcomp.at(sp) / 100.; lp.sensex = local_sensiex; lp.strucc = local_struc; lp.war = local_warm; - */ } @@ -741,7 +739,7 @@ void ImProcFunctions::strcurv_data(std::string retistr, int *s_datc, int &siz) } -void ImProcFunctions::ciecamloc_02float(LabImage* lab, LabImage* dest) +void ImProcFunctions::ciecamloc_02float(int sp, LabImage* lab, LabImage* dest) { //be carefull quasi duplicate with branch cat02wb BENCHFUN @@ -763,14 +761,11 @@ void ImProcFunctions::ciecamloc_02float(LabImage* lab, LabImage* dest) int tempo; - // TODO Locallab - /* - if (params->locallab.warm > 0) { - tempo = 5000 - 30 * params->locallab.warm; + if (params->locallab.warm.at(sp) > 0) { + tempo = 5000 - 30 * params->locallab.warm.at(sp); } else { - tempo = 5000 - 49 * params->locallab.warm; + tempo = 5000 - 49 * params->locallab.warm.at(sp); } - */ ColorTemp::temp2mulxyz(params->wb.temperature, params->wb.method, Xw, Zw); //compute white Xw Yw Zw : white current WB ColorTemp::temp2mulxyz(tempo, "Custom", Xwout, Zwout); @@ -1030,27 +1025,25 @@ void ImProcFunctions::ciecamloc_02float(LabImage* lab, LabImage* dest) -void ImProcFunctions::vibrancelocal(int bfw, int bfh, LabImage* lab, LabImage* dest, bool & localskutili, LUTf & sklocalcurve) +void ImProcFunctions::vibrancelocal(int sp, int bfw, int bfh, LabImage* lab, LabImage* dest, bool & localskutili, LUTf & sklocalcurve) { - // TODO Locallab - /* - if (!params->locallab.expvibrance) { + if (!((bool)params->locallab.expvibrance.at(sp))) { return; } const int width = bfw; const int height = bfh; - #ifdef _DEBUG +#ifdef _DEBUG MyTime t1e, t2e; t1e.set(); int negat = 0, moreRGB = 0, negsat = 0, moresat = 0; - #endif +#endif - const float chromaPastel = float (params->locallab.pastels) / 100.0f; - const float chromaSatur = float (params->locallab.saturated) / 100.0f; + const float chromaPastel = float (params->locallab.pastels.at(sp)) / 100.0f; + const float chromaSatur = float (params->locallab.saturated.at(sp)) / 100.0f; const float p00 = 0.07f; - const float limitpastelsatur = (static_cast(params->locallab.psthreshold.getTopLeft()) / 100.0f) * (1.0f - p00) + p00; + const float limitpastelsatur = (static_cast(params->locallab.psthreshold.at(sp).getTopLeft()) / 100.0f) * (1.0f - p00) + p00; const float maxdp = (limitpastelsatur - p00) / 4.0f; const float maxds = (1.0 - limitpastelsatur) / 4.0f; const float p0 = p00 + maxdp; @@ -1059,7 +1052,7 @@ void ImProcFunctions::vibrancelocal(int bfw, int bfh, LabImage* lab, LabImage* const float s0 = limitpastelsatur + maxds; const float s1 = limitpastelsatur + 2.0f * maxds; const float s2 = limitpastelsatur + 3.0f * maxds; - const float transitionweighting = static_cast(params->locallab.psthreshold.getBottomLeft()) / 100.0f; + const float transitionweighting = static_cast(params->locallab.psthreshold.at(sp).getBottomLeft()) / 100.0f; float chromamean = 0.0f; if (chromaPastel != chromaSatur) { @@ -1091,8 +1084,8 @@ void ImProcFunctions::vibrancelocal(int bfw, int bfh, LabImage* lab, LabImage* const bool highlight = params->toneCurve.hrenabled;//Get the value if "highlight reconstruction" is activated - const bool protectskins = params->locallab.protectskins; - const bool avoidcolorshift = params->locallab.avoidcolorshift; + const bool protectskins = params->locallab.protectskins.at(sp); + const bool avoidcolorshift = params->locallab.avoidcolorshift.at(sp); TMatrix wiprof = ICCStore::getInstance()->workingSpaceInverseMatrix(params->icm.working); //inverse matrix user select @@ -1103,7 +1096,7 @@ void ImProcFunctions::vibrancelocal(int bfw, int bfh, LabImage* lab, LabImage* }; - #ifdef _DEBUG +#ifdef _DEBUG MunsellDebugInfo* MunsDebugInfo = nullptr; if (avoidcolorshift) { @@ -1111,21 +1104,21 @@ void ImProcFunctions::vibrancelocal(int bfw, int bfh, LabImage* lab, LabImage* } #pragma omp parallel default(shared) firstprivate(lab, dest, MunsDebugInfo) reduction(+: negat, moreRGB, negsat, moresat) if (multiThread) - #else +#else #pragma omp parallel default(shared) if (multiThread) - #endif +#endif { float sathue[5], sathue2[4]; // adjust sat in function of hue - #ifdef _OPENMP +#ifdef _OPENMP if (settings->verbose && omp_get_thread_num() == 0) { - #else +#else if (settings->verbose) { - #endif +#endif printf("vibrance: p0=%1.2f p1=%1.2f p2=%1.2f s0=%1.2f s1=%1.2f s2=%1.2f\n", p0, p1, p2, s0, s1, s2); printf(" pastel=%f satur=%f limit= %1.2f chromamean=%0.5f\n", 1.0f + chromaPastel, 1.0f + chromaSatur, limitpastelsatur, chromamean); } @@ -1160,7 +1153,7 @@ void ImProcFunctions::vibrancelocal(int bfw, int bfh, LabImage* lab, LabImage* sincosval.x = lab->b[i][j] / (CC * 327.68f); } - #ifdef _DEBUG +#ifdef _DEBUG bool neg = false; bool more_rgb = false; //gamut control : Lab values are in gamut @@ -1174,10 +1167,10 @@ void ImProcFunctions::vibrancelocal(int bfw, int bfh, LabImage* lab, LabImage* moreRGB++; } - #else +#else //gamut control : Lab values are in gamut Color::gamutLchonly(HH, sincosval, Lprov, Chprov, R, G, B, wip, highlight, 0.15f, 0.98f); - #endif +#endif if (Chprov > 6.0f) { const float saturation = SAT(R, G, B); @@ -1193,489 +1186,487 @@ void ImProcFunctions::vibrancelocal(int bfw, int bfh, LabImage* lab, LabImage* //blue: -1.80 -3.14 green = 2.1 3.14 green-yellow=1.4 2.1 red:0 1.4 blue-purple:-0.7 -1.4 purple: 0 -0.7 //these values allow a better and differential response if (LL < 20.0f) { //more for blue-purple, blue and red modulate - if (/*HH> -3.1415f &&*//* HH < -1.5f) { - sathue[0] = 1.3f; //blue - sathue[1] = 1.2f; - sathue[2] = 1.1f; - sathue[3] = 1.05f; - sathue[4] = 0.4f; - sathue2[0] = 1.05f; - sathue2[1] = 1.1f ; - sathue2[2] = 1.05f; - sathue2[3] = 1.0f; - } else if (/*HH>=-1.5f &&*//* HH < -0.7f) { - sathue[0] = 1.6f; //blue purple 1.2 1.1 - sathue[1] = 1.4f; - sathue[2] = 1.3f; - sathue[3] = 1.2f ; - sathue[4] = 0.4f; - sathue2[0] = 1.2f ; - sathue2[1] = 1.15f; - sathue2[2] = 1.1f ; - sathue2[3] = 1.0f; - } else if (/*HH>=-0.7f &&*//* HH < 0.0f) { - sathue[0] = 1.2f; //purple - sathue[1] = 1.0f; - sathue[2] = 1.0f; - sathue[3] = 1.0f ; - sathue[4] = 0.4f; - sathue2[0] = 1.0f ; - sathue2[1] = 1.0f ; - sathue2[2] = 1.0f ; - sathue2[3] = 1.0f; - } - // else if( HH>= 0.0f && HH<= 1.4f ) {sathue[0]=1.1f;sathue[1]=1.1f;sathue[2]=1.1f;sathue[3]=1.0f ;sathue[4]=0.4f;sathue2[0]=1.0f ;sathue2[1]=1.0f ;sathue2[2]=1.0f ;sathue2[3]=1.0f;}//red 0.8 0.7 - else if (/*HH>= 0.0f &&*//* HH <= 1.4f) { - sathue[0] = 1.3f; //red 0.8 0.7 - sathue[1] = 1.2f; - sathue[2] = 1.1f; - sathue[3] = 1.0f ; - sathue[4] = 0.4f; - sathue2[0] = 1.0f ; - sathue2[1] = 1.0f ; - sathue2[2] = 1.0f ; - sathue2[3] = 1.0f; - } else if (/*HH> 1.4f &&*//* HH <= 2.1f) { - sathue[0] = 1.0f; //green yellow 1.2 1.1 - sathue[1] = 1.0f; - sathue[2] = 1.0f; - sathue[3] = 1.0f ; - sathue[4] = 0.4f; - sathue2[0] = 1.0f ; - sathue2[1] = 1.0f ; - sathue2[2] = 1.0f ; - sathue2[3] = 1.0f; - } else { /*if(HH> 2.1f && HH<= 3.1415f)*//* - sathue[0] = 1.4f; //green - sathue[1] = 1.3f; - sathue[2] = 1.2f; - sathue[3] = 1.15f; - sathue[4] = 0.4f; - sathue2[0] = 1.15f; - sathue2[1] = 1.1f ; - sathue2[2] = 1.05f; - sathue2[3] = 1.0f; - } - } else if (LL < 50.0f) { //more for blue and green, less for red and green-yellow - if (/*HH> -3.1415f &&*//* HH < -1.5f) { - sathue[0] = 1.5f; //blue - sathue[1] = 1.4f; - sathue[2] = 1.3f; - sathue[3] = 1.2f ; - sathue[4] = 0.4f; - sathue2[0] = 1.2f ; - sathue2[1] = 1.1f ; - sathue2[2] = 1.05f; - sathue2[3] = 1.0f; - } else if (/*HH>=-1.5f &&*//* HH < -0.7f) { - sathue[0] = 1.3f; //blue purple 1.2 1.1 - sathue[1] = 1.2f; - sathue[2] = 1.1f; - sathue[3] = 1.05f; - sathue[4] = 0.4f; - sathue2[0] = 1.05f; - sathue2[1] = 1.05f; - sathue2[2] = 1.0f ; - sathue2[3] = 1.0f; - } else if (/*HH>=-0.7f &&*//* HH < 0.0f) { - sathue[0] = 1.2f; //purple - sathue[1] = 1.0f; - sathue[2] = 1.0f; - sathue[3] = 1.0f ; - sathue[4] = 0.4f; - sathue2[0] = 1.0f ; - sathue2[1] = 1.0f ; - sathue2[2] = 1.0f ; - sathue2[3] = 1.0f; - } - // else if( HH>= 0.0f && HH<= 1.4f ) {sathue[0]=0.8f;sathue[1]=0.8f;sathue[2]=0.8f;sathue[3]=0.8f ;sathue[4]=0.4f;sathue2[0]=0.8f ;sathue2[1]=0.8f ;sathue2[2]=0.8f ;sathue2[3]=0.8f;}//red 0.8 0.7 - else if (/*HH>= 0.0f &&*//* HH <= 1.4f) { - sathue[0] = 1.1f; //red 0.8 0.7 - sathue[1] = 1.0f; - sathue[2] = 0.9f; - sathue[3] = 0.8f ; - sathue[4] = 0.4f; - sathue2[0] = 0.8f ; - sathue2[1] = 0.8f ; - sathue2[2] = 0.8f ; - sathue2[3] = 0.8f; - } else if (/*HH> 1.4f &&*//* HH <= 2.1f) { - sathue[0] = 1.1f; //green yellow 1.2 1.1 - sathue[1] = 1.1f; - sathue[2] = 1.1f; - sathue[3] = 1.05f; - sathue[4] = 0.4f; - sathue2[0] = 0.9f ; - sathue2[1] = 0.8f ; - sathue2[2] = 0.7f ; - sathue2[3] = 0.6f; - } else { /*if(HH> 2.1f && HH<= 3.1415f)*//* - sathue[0] = 1.5f; //green - sathue[1] = 1.4f; - sathue[2] = 1.3f; - sathue[3] = 1.2f ; - sathue[4] = 0.4f; - sathue2[0] = 1.2f ; - sathue2[1] = 1.1f ; - sathue2[2] = 1.05f; - sathue2[3] = 1.0f; - } + if (/*HH> -3.1415f &&*/ HH < -1.5f) { + sathue[0] = 1.3f; //blue + sathue[1] = 1.2f; + sathue[2] = 1.1f; + sathue[3] = 1.05f; + sathue[4] = 0.4f; + sathue2[0] = 1.05f; + sathue2[1] = 1.1f ; + sathue2[2] = 1.05f; + sathue2[3] = 1.0f; + } else if (/*HH>=-1.5f &&*/ HH < -0.7f) { + sathue[0] = 1.6f; //blue purple 1.2 1.1 + sathue[1] = 1.4f; + sathue[2] = 1.3f; + sathue[3] = 1.2f ; + sathue[4] = 0.4f; + sathue2[0] = 1.2f ; + sathue2[1] = 1.15f; + sathue2[2] = 1.1f ; + sathue2[3] = 1.0f; + } else if (/*HH>=-0.7f &&*/ HH < 0.0f) { + sathue[0] = 1.2f; //purple + sathue[1] = 1.0f; + sathue[2] = 1.0f; + sathue[3] = 1.0f ; + sathue[4] = 0.4f; + sathue2[0] = 1.0f ; + sathue2[1] = 1.0f ; + sathue2[2] = 1.0f ; + sathue2[3] = 1.0f; + } + // else if( HH>= 0.0f && HH<= 1.4f ) {sathue[0]=1.1f;sathue[1]=1.1f;sathue[2]=1.1f;sathue[3]=1.0f ;sathue[4]=0.4f;sathue2[0]=1.0f ;sathue2[1]=1.0f ;sathue2[2]=1.0f ;sathue2[3]=1.0f;}//red 0.8 0.7 + else if (/*HH>= 0.0f &&*/ HH <= 1.4f) { + sathue[0] = 1.3f; //red 0.8 0.7 + sathue[1] = 1.2f; + sathue[2] = 1.1f; + sathue[3] = 1.0f ; + sathue[4] = 0.4f; + sathue2[0] = 1.0f ; + sathue2[1] = 1.0f ; + sathue2[2] = 1.0f ; + sathue2[3] = 1.0f; + } else if (/*HH> 1.4f &&*/ HH <= 2.1f) { + sathue[0] = 1.0f; //green yellow 1.2 1.1 + sathue[1] = 1.0f; + sathue[2] = 1.0f; + sathue[3] = 1.0f ; + sathue[4] = 0.4f; + sathue2[0] = 1.0f ; + sathue2[1] = 1.0f ; + sathue2[2] = 1.0f ; + sathue2[3] = 1.0f; + } else { /*if(HH> 2.1f && HH<= 3.1415f)*/ + sathue[0] = 1.4f; //green + sathue[1] = 1.3f; + sathue[2] = 1.2f; + sathue[3] = 1.15f; + sathue[4] = 0.4f; + sathue2[0] = 1.15f; + sathue2[1] = 1.1f ; + sathue2[2] = 1.05f; + sathue2[3] = 1.0f; + } + } else if (LL < 50.0f) { //more for blue and green, less for red and green-yellow + if (/*HH> -3.1415f &&*/ HH < -1.5f) { + sathue[0] = 1.5f; //blue + sathue[1] = 1.4f; + sathue[2] = 1.3f; + sathue[3] = 1.2f ; + sathue[4] = 0.4f; + sathue2[0] = 1.2f ; + sathue2[1] = 1.1f ; + sathue2[2] = 1.05f; + sathue2[3] = 1.0f; + } else if (/*HH>=-1.5f &&*/ HH < -0.7f) { + sathue[0] = 1.3f; //blue purple 1.2 1.1 + sathue[1] = 1.2f; + sathue[2] = 1.1f; + sathue[3] = 1.05f; + sathue[4] = 0.4f; + sathue2[0] = 1.05f; + sathue2[1] = 1.05f; + sathue2[2] = 1.0f ; + sathue2[3] = 1.0f; + } else if (/*HH>=-0.7f &&*/ HH < 0.0f) { + sathue[0] = 1.2f; //purple + sathue[1] = 1.0f; + sathue[2] = 1.0f; + sathue[3] = 1.0f ; + sathue[4] = 0.4f; + sathue2[0] = 1.0f ; + sathue2[1] = 1.0f ; + sathue2[2] = 1.0f ; + sathue2[3] = 1.0f; + } + // else if( HH>= 0.0f && HH<= 1.4f ) {sathue[0]=0.8f;sathue[1]=0.8f;sathue[2]=0.8f;sathue[3]=0.8f ;sathue[4]=0.4f;sathue2[0]=0.8f ;sathue2[1]=0.8f ;sathue2[2]=0.8f ;sathue2[3]=0.8f;}//red 0.8 0.7 + else if (/*HH>= 0.0f &&*/ HH <= 1.4f) { + sathue[0] = 1.1f; //red 0.8 0.7 + sathue[1] = 1.0f; + sathue[2] = 0.9f; + sathue[3] = 0.8f ; + sathue[4] = 0.4f; + sathue2[0] = 0.8f ; + sathue2[1] = 0.8f ; + sathue2[2] = 0.8f ; + sathue2[3] = 0.8f; + } else if (/*HH> 1.4f &&*/ HH <= 2.1f) { + sathue[0] = 1.1f; //green yellow 1.2 1.1 + sathue[1] = 1.1f; + sathue[2] = 1.1f; + sathue[3] = 1.05f; + sathue[4] = 0.4f; + sathue2[0] = 0.9f ; + sathue2[1] = 0.8f ; + sathue2[2] = 0.7f ; + sathue2[3] = 0.6f; + } else { /*if(HH> 2.1f && HH<= 3.1415f)*/ + sathue[0] = 1.5f; //green + sathue[1] = 1.4f; + sathue[2] = 1.3f; + sathue[3] = 1.2f ; + sathue[4] = 0.4f; + sathue2[0] = 1.2f ; + sathue2[1] = 1.1f ; + sathue2[2] = 1.05f; + sathue2[3] = 1.0f; + } - } else if (LL < 80.0f) { //more for green, less for red and green-yellow - if (/*HH> -3.1415f &&*//* HH < -1.5f) { - sathue[0] = 1.3f; //blue - sathue[1] = 1.2f; - sathue[2] = 1.15f; - sathue[3] = 1.1f ; - sathue[4] = 0.3f; - sathue2[0] = 1.1f ; - sathue2[1] = 1.1f ; - sathue2[2] = 1.05f; - sathue2[3] = 1.0f; - } else if (/*HH>=-1.5f &&*//* HH < -0.7f) { - sathue[0] = 1.3f; //blue purple 1.2 1.1 - sathue[1] = 1.2f; - sathue[2] = 1.15f; - sathue[3] = 1.1f ; - sathue[4] = 0.3f; - sathue2[0] = 1.1f ; - sathue2[1] = 1.05f; - sathue2[2] = 1.0f ; - sathue2[3] = 1.0f; - } else if (/*HH>=-0.7f &&*//* HH < 0.0f) { - sathue[0] = 1.2f; //purple - sathue[1] = 1.0f; - sathue[2] = 1.0f ; - sathue[3] = 1.0f ; - sathue[4] = 0.3f; - sathue2[0] = 1.0f ; - sathue2[1] = 1.0f ; - sathue2[2] = 1.0f ; - sathue2[3] = 1.0f; - } - // else if( HH>= 0.0f && HH<= 1.4f ) {sathue[0]=0.8f;sathue[1]=0.8f;sathue[2]=0.8f ;sathue[3]=0.8f ;sathue[4]=0.3f;sathue2[0]=0.8f ;sathue2[1]=0.8f ;sathue2[2]=0.8f ;sathue2[3]=0.8f;}//red 0.8 0.7 - else if (/*HH>= 0.0f &&*//* HH <= 1.4f) { - sathue[0] = 1.1f; //red 0.8 0.7 - sathue[1] = 1.0f; - sathue[2] = 0.9f ; - sathue[3] = 0.8f ; - sathue[4] = 0.3f; - sathue2[0] = 0.8f ; - sathue2[1] = 0.8f ; - sathue2[2] = 0.8f ; - sathue2[3] = 0.8f; - } else if (/*HH> 1.4f &&*//* HH <= 2.1f) { - sathue[0] = 1.3f; //green yellow 1.2 1.1 - sathue[1] = 1.2f; - sathue[2] = 1.1f ; - sathue[3] = 1.05f; - sathue[4] = 0.3f; - sathue2[0] = 1.0f ; - sathue2[1] = 0.9f ; - sathue2[2] = 0.8f ; - sathue2[3] = 0.7f; - } else { /*if(HH> 2.1f && HH<= 3.1415f)*//* - sathue[0] = 1.6f; //green - even with Prophoto green are too "little" 1.5 1.3 - sathue[1] = 1.4f; - sathue[2] = 1.3f ; - sathue[3] = 1.25f; - sathue[4] = 0.3f; - sathue2[0] = 1.25f; - sathue2[1] = 1.2f ; - sathue2[2] = 1.15f; - sathue2[3] = 1.05f; - } - } else { /*if (LL>=80.0f)*//* //more for green-yellow, less for red and purple - if (/*HH> -3.1415f &&*//* HH < -1.5f) { - sathue[0] = 1.0f; //blue - sathue[1] = 1.0f; - sathue[2] = 0.9f; - sathue[3] = 0.8f; - sathue[4] = 0.2f; - sathue2[0] = 0.8f; - sathue2[1] = 0.8f ; - sathue2[2] = 0.8f ; - sathue2[3] = 0.8f; - } else if (/*HH>=-1.5f &&*//* HH < -0.7f) { - sathue[0] = 1.0f; //blue purple 1.2 1.1 - sathue[1] = 1.0f; - sathue[2] = 0.9f; - sathue[3] = 0.8f; - sathue[4] = 0.2f; - sathue2[0] = 0.8f; - sathue2[1] = 0.8f ; - sathue2[2] = 0.8f ; - sathue2[3] = 0.8f; - } else if (/*HH>=-0.7f &&*//* HH < 0.0f) { - sathue[0] = 1.2f; //purple - sathue[1] = 1.0f; - sathue[2] = 1.0f; - sathue[3] = 0.9f; - sathue[4] = 0.2f; - sathue2[0] = 0.9f; - sathue2[1] = 0.9f ; - sathue2[2] = 0.8f ; - sathue2[3] = 0.8f; - } - // else if( HH>= 0.0f && HH<= 1.4f ) {sathue[0]=0.8f;sathue[1]=0.8f;sathue[2]=0.8f;sathue[3]=0.8f;sathue[4]=0.2f;sathue2[0]=0.8f;sathue2[1]=0.8f ;sathue2[2]=0.8f ;sathue2[3]=0.8f;}//red 0.8 0.7 - else if (/*HH>= 0.0f &&*//* HH <= 1.4f) { - sathue[0] = 1.1f; //red 0.8 0.7 - sathue[1] = 1.0f; - sathue[2] = 0.9f; - sathue[3] = 0.8f; - sathue[4] = 0.2f; - sathue2[0] = 0.8f; - sathue2[1] = 0.8f ; - sathue2[2] = 0.8f ; - sathue2[3] = 0.8f; - } else if (/*HH> 1.4f &&*//* HH <= 2.1f) { - sathue[0] = 1.6f; //green yellow 1.2 1.1 - sathue[1] = 1.5f; - sathue[2] = 1.4f; - sathue[3] = 1.2f; - sathue[4] = 0.2f; - sathue2[0] = 1.1f; - sathue2[1] = 1.05f; - sathue2[2] = 1.0f ; - sathue2[3] = 1.0f; - } else { /*if(HH> 2.1f && HH<= 3.1415f)*//* - sathue[0] = 1.4f; //green - sathue[1] = 1.3f; - sathue[2] = 1.2f; - sathue[3] = 1.1f; - sathue[4] = 0.2f; - sathue2[0] = 1.1f; - sathue2[1] = 1.05f; - sathue2[2] = 1.05f; - sathue2[3] = 1.0f; + } else if (LL < 80.0f) { //more for green, less for red and green-yellow + if (/*HH> -3.1415f &&*/ HH < -1.5f) { + sathue[0] = 1.3f; //blue + sathue[1] = 1.2f; + sathue[2] = 1.15f; + sathue[3] = 1.1f ; + sathue[4] = 0.3f; + sathue2[0] = 1.1f ; + sathue2[1] = 1.1f ; + sathue2[2] = 1.05f; + sathue2[3] = 1.0f; + } else if (/*HH>=-1.5f &&*/ HH < -0.7f) { + sathue[0] = 1.3f; //blue purple 1.2 1.1 + sathue[1] = 1.2f; + sathue[2] = 1.15f; + sathue[3] = 1.1f ; + sathue[4] = 0.3f; + sathue2[0] = 1.1f ; + sathue2[1] = 1.05f; + sathue2[2] = 1.0f ; + sathue2[3] = 1.0f; + } else if (/*HH>=-0.7f &&*/ HH < 0.0f) { + sathue[0] = 1.2f; //purple + sathue[1] = 1.0f; + sathue[2] = 1.0f ; + sathue[3] = 1.0f ; + sathue[4] = 0.3f; + sathue2[0] = 1.0f ; + sathue2[1] = 1.0f ; + sathue2[2] = 1.0f ; + sathue2[3] = 1.0f; + } + // else if( HH>= 0.0f && HH<= 1.4f ) {sathue[0]=0.8f;sathue[1]=0.8f;sathue[2]=0.8f ;sathue[3]=0.8f ;sathue[4]=0.3f;sathue2[0]=0.8f ;sathue2[1]=0.8f ;sathue2[2]=0.8f ;sathue2[3]=0.8f;}//red 0.8 0.7 + else if (/*HH>= 0.0f &&*/ HH <= 1.4f) { + sathue[0] = 1.1f; //red 0.8 0.7 + sathue[1] = 1.0f; + sathue[2] = 0.9f ; + sathue[3] = 0.8f ; + sathue[4] = 0.3f; + sathue2[0] = 0.8f ; + sathue2[1] = 0.8f ; + sathue2[2] = 0.8f ; + sathue2[3] = 0.8f; + } else if (/*HH> 1.4f &&*/ HH <= 2.1f) { + sathue[0] = 1.3f; //green yellow 1.2 1.1 + sathue[1] = 1.2f; + sathue[2] = 1.1f ; + sathue[3] = 1.05f; + sathue[4] = 0.3f; + sathue2[0] = 1.0f ; + sathue2[1] = 0.9f ; + sathue2[2] = 0.8f ; + sathue2[3] = 0.7f; + } else { /*if(HH> 2.1f && HH<= 3.1415f)*/ + sathue[0] = 1.6f; //green - even with Prophoto green are too "little" 1.5 1.3 + sathue[1] = 1.4f; + sathue[2] = 1.3f ; + sathue[3] = 1.25f; + sathue[4] = 0.3f; + sathue2[0] = 1.25f; + sathue2[1] = 1.2f ; + sathue2[2] = 1.15f; + sathue2[3] = 1.05f; + } + } else { /*if (LL>=80.0f)*/ //more for green-yellow, less for red and purple + if (/*HH> -3.1415f &&*/ HH < -1.5f) { + sathue[0] = 1.0f; //blue + sathue[1] = 1.0f; + sathue[2] = 0.9f; + sathue[3] = 0.8f; + sathue[4] = 0.2f; + sathue2[0] = 0.8f; + sathue2[1] = 0.8f ; + sathue2[2] = 0.8f ; + sathue2[3] = 0.8f; + } else if (/*HH>=-1.5f &&*/ HH < -0.7f) { + sathue[0] = 1.0f; //blue purple 1.2 1.1 + sathue[1] = 1.0f; + sathue[2] = 0.9f; + sathue[3] = 0.8f; + sathue[4] = 0.2f; + sathue2[0] = 0.8f; + sathue2[1] = 0.8f ; + sathue2[2] = 0.8f ; + sathue2[3] = 0.8f; + } else if (/*HH>=-0.7f &&*/ HH < 0.0f) { + sathue[0] = 1.2f; //purple + sathue[1] = 1.0f; + sathue[2] = 1.0f; + sathue[3] = 0.9f; + sathue[4] = 0.2f; + sathue2[0] = 0.9f; + sathue2[1] = 0.9f ; + sathue2[2] = 0.8f ; + sathue2[3] = 0.8f; + } + // else if( HH>= 0.0f && HH<= 1.4f ) {sathue[0]=0.8f;sathue[1]=0.8f;sathue[2]=0.8f;sathue[3]=0.8f;sathue[4]=0.2f;sathue2[0]=0.8f;sathue2[1]=0.8f ;sathue2[2]=0.8f ;sathue2[3]=0.8f;}//red 0.8 0.7 + else if (/*HH>= 0.0f &&*/ HH <= 1.4f) { + sathue[0] = 1.1f; //red 0.8 0.7 + sathue[1] = 1.0f; + sathue[2] = 0.9f; + sathue[3] = 0.8f; + sathue[4] = 0.2f; + sathue2[0] = 0.8f; + sathue2[1] = 0.8f ; + sathue2[2] = 0.8f ; + sathue2[3] = 0.8f; + } else if (/*HH> 1.4f &&*/ HH <= 2.1f) { + sathue[0] = 1.6f; //green yellow 1.2 1.1 + sathue[1] = 1.5f; + sathue[2] = 1.4f; + sathue[3] = 1.2f; + sathue[4] = 0.2f; + sathue2[0] = 1.1f; + sathue2[1] = 1.05f; + sathue2[2] = 1.0f ; + sathue2[3] = 1.0f; + } else { /*if(HH> 2.1f && HH<= 3.1415f)*/ + sathue[0] = 1.4f; //green + sathue[1] = 1.3f; + sathue[2] = 1.2f; + sathue[3] = 1.1f; + sathue[4] = 0.2f; + sathue2[0] = 1.1f; + sathue2[1] = 1.05f; + sathue2[2] = 1.05f; + sathue2[3] = 1.0f; + } } } - } - float chmodpastel = 0.f, chmodsat = 0.f; - // variables to improve transitions - float pa, pb;// transition = pa*saturation + pb - float chl00 = chromaPastel * satredu * sathue[4]; - float chl0 = chromaPastel * satredu * sathue[0]; - float chl1 = chromaPastel * satredu * sathue[1]; - float chl2 = chromaPastel * satredu * sathue[2]; - float chl3 = chromaPastel * satredu * sathue[3]; - float chs0 = chromaSatur * satredu * sathue2[0]; - float chs1 = chromaSatur * satredu * sathue2[1]; - float chs2 = chromaSatur * satredu * sathue2[2]; - float chs3 = chromaSatur * satredu * sathue2[3]; - float s3 = 1.0f; + float chmodpastel = 0.f, chmodsat = 0.f; + // variables to improve transitions + float pa, pb;// transition = pa*saturation + pb + float chl00 = chromaPastel * satredu * sathue[4]; + float chl0 = chromaPastel * satredu * sathue[0]; + float chl1 = chromaPastel * satredu * sathue[1]; + float chl2 = chromaPastel * satredu * sathue[2]; + float chl3 = chromaPastel * satredu * sathue[3]; + float chs0 = chromaSatur * satredu * sathue2[0]; + float chs1 = chromaSatur * satredu * sathue2[1]; + float chs2 = chromaSatur * satredu * sathue2[2]; + float chs3 = chromaSatur * satredu * sathue2[3]; + float s3 = 1.0f; - // We handle only positive values here ; improve transitions - if (saturation < p00) { - chmodpastel = chl00 ; //neutral tones - } else if (saturation < p0) { - pa = (chl00 - chl0) / (p00 - p0); - pb = chl00 - pa * p00; - chmodpastel = pa * saturation + pb; - } else if (saturation < p1) { - pa = (chl0 - chl1) / (p0 - p1); - pb = chl0 - pa * p0; - chmodpastel = pa * saturation + pb; - } else if (saturation < p2) { - pa = (chl1 - chl2) / (p1 - p2); - pb = chl1 - pa * p1; - chmodpastel = pa * saturation + pb; - } else if (saturation < limitpastelsatur) { - pa = (chl2 - chl3) / (p2 - limitpastelsatur); - pb = chl2 - pa * p2; - chmodpastel = pa * saturation + pb; - } else if (saturation < s0) { - pa = (chl3 - chs0) / (limitpastelsatur - s0) ; - pb = chl3 - pa * limitpastelsatur; - chmodsat = pa * saturation + pb; - } else if (saturation < s1) { - pa = (chs0 - chs1) / (s0 - s1); - pb = chs0 - pa * s0; - chmodsat = pa * saturation + pb; - } else if (saturation < s2) { - pa = (chs1 - chs2) / (s1 - s2); - pb = chs1 - pa * s1; - chmodsat = pa * saturation + pb; - } else { - pa = (chs2 - chs3) / (s2 - s3); - pb = chs2 - pa * s2; - chmodsat = pa * saturation + pb; - } - - if (chromaPastel != chromaSatur) { - - // Pastels - if (saturation > p2 && saturation < limitpastelsatur) { - float newchromaPastel = chromaPastel_a * saturation + chromaPastel_b; - chmodpastel = newchromaPastel * satredu * sathue[3]; + // We handle only positive values here ; improve transitions + if (saturation < p00) { + chmodpastel = chl00 ; //neutral tones + } else if (saturation < p0) { + pa = (chl00 - chl0) / (p00 - p0); + pb = chl00 - pa * p00; + chmodpastel = pa * saturation + pb; + } else if (saturation < p1) { + pa = (chl0 - chl1) / (p0 - p1); + pb = chl0 - pa * p0; + chmodpastel = pa * saturation + pb; + } else if (saturation < p2) { + pa = (chl1 - chl2) / (p1 - p2); + pb = chl1 - pa * p1; + chmodpastel = pa * saturation + pb; + } else if (saturation < limitpastelsatur) { + pa = (chl2 - chl3) / (p2 - limitpastelsatur); + pb = chl2 - pa * p2; + chmodpastel = pa * saturation + pb; + } else if (saturation < s0) { + pa = (chl3 - chs0) / (limitpastelsatur - s0) ; + pb = chl3 - pa * limitpastelsatur; + chmodsat = pa * saturation + pb; + } else if (saturation < s1) { + pa = (chs0 - chs1) / (s0 - s1); + pb = chs0 - pa * s0; + chmodsat = pa * saturation + pb; + } else if (saturation < s2) { + pa = (chs1 - chs2) / (s1 - s2); + pb = chs1 - pa * s1; + chmodsat = pa * saturation + pb; + } else { + pa = (chs2 - chs3) / (s2 - s3); + pb = chs2 - pa * s2; + chmodsat = pa * saturation + pb; } - // Saturated - if (saturation < s0 && saturation >= limitpastelsatur) { - float newchromaSatur = chromaSatur_a * saturation + chromaSatur_b; - chmodsat = newchromaSatur * satredu * sathue2[0]; - } - }// end transition + if (chromaPastel != chromaSatur) { - if (saturation <= limitpastelsatur) { - if (chmodpastel > 2.0f) { - chmodpastel = 2.0f; //avoid too big values - } else if (chmodpastel < -0.93f) { - chmodpastel = -0.93f; //avoid negative values - } + // Pastels + if (saturation > p2 && saturation < limitpastelsatur) { + float newchromaPastel = chromaPastel_a * saturation + chromaPastel_b; + chmodpastel = newchromaPastel * satredu * sathue[3]; + } - Chprov *= (1.0f + chmodpastel); + // Saturated + if (saturation < s0 && saturation >= limitpastelsatur) { + float newchromaSatur = chromaSatur_a * saturation + chromaSatur_b; + chmodsat = newchromaSatur * satredu * sathue2[0]; + } + }// end transition - if (Chprov < 6.0f) { - Chprov = 6.0f; - } - } else { //if (saturation > limitpastelsatur) - if (chmodsat > 1.8f) { - chmodsat = 1.8f; //saturated - } else if (chmodsat < -0.93f) { - chmodsat = -0.93f; - } + if (saturation <= limitpastelsatur) { + if (chmodpastel > 2.0f) { + chmodpastel = 2.0f; //avoid too big values + } else if (chmodpastel < -0.93f) { + chmodpastel = -0.93f; //avoid negative values + } - Chprov *= 1.0f + chmodsat; + Chprov *= (1.0f + chmodpastel); - if (Chprov < 6.0f) { - Chprov = 6.0f; + if (Chprov < 6.0f) { + Chprov = 6.0f; + } + } else { //if (saturation > limitpastelsatur) + if (chmodsat > 1.8f) { + chmodsat = 1.8f; //saturated + } else if (chmodsat < -0.93f) { + chmodsat = -0.93f; + } + + Chprov *= 1.0f + chmodsat; + + if (Chprov < 6.0f) { + Chprov = 6.0f; + } } } } - } - bool hhModified = false; + bool hhModified = false; - // Vibrance's Skin curve - if (sklocalcurve && localskutili) { - if (HH > skbeg && HH < skend) { - if (Chprov < 60.0f) { //skin hue : todo ==> transition - float HHsk = ask * HH + bsk; + // Vibrance's Skin curve + if (sklocalcurve && localskutili) { + if (HH > skbeg && HH < skend) { + if (Chprov < 60.0f) { //skin hue : todo ==> transition + float HHsk = ask * HH + bsk; + float Hn = (sklocalcurve[HHsk] - bsk) / ask; + float Hc = (Hn * xx + HH * (1.0f - xx)); + HH = Hc; + hhModified = true; + } else if (Chprov < (60.0f + dchr)) { //transition chroma + float HHsk = ask * HH + bsk; + float Hn = (sklocalcurve[HHsk] - bsk) / ask; + float Hc = (Hn * xx + HH * (1.0f - xx)); + float aa = (HH - Hc) / dchr ; + float bb = HH - (60.0f + dchr) * aa; + HH = aa * Chprov + bb; + hhModified = true; + } + } + //transition hue + else if (HH > (skbeg - dhue) && HH <= skbeg && Chprov < (60.0f + dchr * 0.5f)) { + float HHsk = ask * skbeg + bsk; float Hn = (sklocalcurve[HHsk] - bsk) / ask; - float Hc = (Hn * xx + HH * (1.0f - xx)); - HH = Hc; + float Hcc = (Hn * xx + skbeg * (1.0f - xx)); + float adh = (Hcc - (skbeg - dhue)) / (dhue); + float bdh = Hcc - adh * skbeg; + HH = adh * HH + bdh; hhModified = true; - } else if (Chprov < (60.0f + dchr)) { //transition chroma - float HHsk = ask * HH + bsk; + } else if (HH >= skend && HH < (skend + dhue) && Chprov < (60.0f + dchr * 0.5f)) { + float HHsk = ask * skend + bsk; float Hn = (sklocalcurve[HHsk] - bsk) / ask; - float Hc = (Hn * xx + HH * (1.0f - xx)); - float aa = (HH - Hc) / dchr ; - float bb = HH - (60.0f + dchr) * aa; - HH = aa * Chprov + bb; + float Hcc = (Hn * xx + skend * (1.0f - xx)); + float adh = (skend + dhue - Hcc) / (dhue); + float bdh = Hcc - adh * skend; + HH = adh * HH + bdh; hhModified = true; } + } // end skin hue + + //Munsell correction + if (!avoidcolorshift && hhModified) { + sincosval = xsincosf(HH); } - //transition hue - else if (HH > (skbeg - dhue) && HH <= skbeg && Chprov < (60.0f + dchr * 0.5f)) { - float HHsk = ask * skbeg + bsk; - float Hn = (sklocalcurve[HHsk] - bsk) / ask; - float Hcc = (Hn * xx + skbeg * (1.0f - xx)); - float adh = (Hcc - (skbeg - dhue)) / (dhue); - float bdh = Hcc - adh * skbeg; - HH = adh * HH + bdh; - hhModified = true; - } else if (HH >= skend && HH < (skend + dhue) && Chprov < (60.0f + dchr * 0.5f)) { - float HHsk = ask * skend + bsk; - float Hn = (sklocalcurve[HHsk] - bsk) / ask; - float Hcc = (Hn * xx + skend * (1.0f - xx)); - float adh = (skend + dhue - Hcc) / (dhue); - float bdh = Hcc - adh * skend; - HH = adh * HH + bdh; - hhModified = true; - } - } // end skin hue - //Munsell correction - if (!avoidcolorshift && hhModified) { - sincosval = xsincosf(HH); - } + float aprovn, bprovn; + bool inGamut; - float aprovn, bprovn; - bool inGamut; + do { + inGamut = true; - do { - inGamut = true; - - if (avoidcolorshift) { - float correctionHue = 0.0f; - float correctlum = 0.0f; + if (avoidcolorshift) { + float correctionHue = 0.0f; + float correctlum = 0.0f; #ifdef _DEBUG - Color::AllMunsellLch(false, Lprov, Lprov, HH, Chprov, CC, correctionHue, correctlum, MunsDebugInfo); + Color::AllMunsellLch(false, Lprov, Lprov, HH, Chprov, CC, correctionHue, correctlum, MunsDebugInfo); #else - Color::AllMunsellLch(false, Lprov, Lprov, HH, Chprov, CC, correctionHue, correctlum); + Color::AllMunsellLch(false, Lprov, Lprov, HH, Chprov, CC, correctionHue, correctlum); #endif - if (correctionHue != 0.f || hhModified) { - sincosval = xsincosf(HH + correctionHue); - hhModified = false; + if (correctionHue != 0.f || hhModified) { + sincosval = xsincosf(HH + correctionHue); + hhModified = false; + } } - } - aprovn = Chprov * sincosval.y; - bprovn = Chprov * sincosval.x; + aprovn = Chprov * sincosval.y; + bprovn = Chprov * sincosval.x; - float fyy = (Color::c1By116 * Lprov) + Color::c16By116; - float fxx = (0.002f * aprovn) + fyy; - float fzz = fyy - (0.005f * bprovn); - float xx_ = 65535.f * Color::f2xyz(fxx) * Color::D50x; - // float yy_ = 65535.0f * Color::f2xyz(fyy); - float zz_ = 65535.f * Color::f2xyz(fzz) * Color::D50z; - float yy_ = 65535.f * ((Lprov > Color::epskap) ? fyy * fyy*fyy : Lprov / Color::kappa); + float fyy = (Color::c1By116 * Lprov) + Color::c16By116; + float fxx = (0.002f * aprovn) + fyy; + float fzz = fyy - (0.005f * bprovn); + float xx_ = 65535.f * Color::f2xyz(fxx) * Color::D50x; + // float yy_ = 65535.0f * Color::f2xyz(fyy); + float zz_ = 65535.f * Color::f2xyz(fzz) * Color::D50z; + float yy_ = 65535.f * ((Lprov > Color::epskap) ? fyy * fyy*fyy : Lprov / Color::kappa); - Color::xyz2rgb(xx_, yy_, zz_, R, G, B, wip); + Color::xyz2rgb(xx_, yy_, zz_, R, G, B, wip); - if (R < 0.0f || G < 0.0f || B < 0.0f) { + if (R < 0.0f || G < 0.0f || B < 0.0f) { #ifdef _DEBUG - negsat++; + negsat++; #endif - Chprov *= 0.98f; - inGamut = false; - } + Chprov *= 0.98f; + inGamut = false; + } - // if "highlight reconstruction" enabled don't control Gamut for highlights - if ((!highlight) && (R > 65535.0f || G > 65535.0f || B > 65535.0f)) { + // if "highlight reconstruction" enabled don't control Gamut for highlights + if ((!highlight) && (R > 65535.0f || G > 65535.0f || B > 65535.0f)) { #ifdef _DEBUG - moresat++; + moresat++; #endif - Chprov *= 0.98f; - inGamut = false; - } - } while (!inGamut); + Chprov *= 0.98f; + inGamut = false; + } + } while (!inGamut); - //put new values in Lab - dest->L[i][j] = Lprov * 327.68f; - dest->a[i][j] = aprovn * 327.68f; - dest->b[i][j] = bprovn * 327.68f; + //put new values in Lab + dest->L[i][j] = Lprov * 327.68f; + dest->a[i][j] = aprovn * 327.68f; + dest->b[i][j] = bprovn * 327.68f; + } + } // end of parallelization + +#ifdef _DEBUG + t2e.set(); + + if (settings->verbose) { + printf("Vibrance local (performed in %d usec):\n", t2e.etime(t1e)); + printf(" Gamut: G1negat=%iiter G165535=%iiter G2negsat=%iiter G265535=%iiter\n", negat, moreRGB, negsat, moresat); + + if (MunsDebugInfo) { + printf(" Munsell chrominance: MaxBP=%1.2frad MaxRY=%1.2frad MaxGY=%1.2frad MaxRP=%1.2frad depass=%u\n", MunsDebugInfo->maxdhue[0], MunsDebugInfo->maxdhue[1], MunsDebugInfo->maxdhue[2], MunsDebugInfo->maxdhue[3], MunsDebugInfo->depass); } -} // end of parallelization - -#ifdef _DEBUG -t2e.set(); - -if (settings->verbose) { - printf("Vibrance local (performed in %d usec):\n", t2e.etime(t1e)); - printf(" Gamut: G1negat=%iiter G165535=%iiter G2negsat=%iiter G265535=%iiter\n", negat, moreRGB, negsat, moresat); + } if (MunsDebugInfo) { - printf(" Munsell chrominance: MaxBP=%1.2frad MaxRY=%1.2frad MaxGY=%1.2frad MaxRP=%1.2frad depass=%u\n", MunsDebugInfo->maxdhue[0], MunsDebugInfo->maxdhue[1], MunsDebugInfo->maxdhue[2], MunsDebugInfo->maxdhue[3], MunsDebugInfo->depass); + delete MunsDebugInfo; } -} - -if (MunsDebugInfo) { - delete MunsDebugInfo; -} #endif -*/ + } void ImProcFunctions::exlabLocal(const local_params& lp, int bfh, int bfw, LabImage* bufexporig, LabImage* lab, LUTf & hltonecurve, LUTf & shtonecurve, LUTf & tonecurve) { - // TODO Locallab - /* //exposure local float maxran = 65536.f; //65536 @@ -1685,11 +1676,11 @@ void ImProcFunctions::exlabLocal(const local_params& lp, int bfh, int bfw, LabIm const float hlrange = maxran - shoulder; - #define TSE 112 +#define TSE 112 - #ifdef _OPENMP +#ifdef _OPENMP #pragma omp parallel if (multiThread) - #endif +#endif { char *buffer; @@ -1705,9 +1696,9 @@ void ImProcFunctions::exlabLocal(const local_params& lp, int bfh, int bfw, LabIm int tW; int tH; - #ifdef _OPENMP +#ifdef _OPENMP #pragma omp for schedule(dynamic) collapse(2) - #endif +#endif for (int ii = 0; ii < bfh; ii += TSE) for (int jj = 0; jj < bfw; jj += TSE) { @@ -1757,43 +1748,43 @@ void ImProcFunctions::exlabLocal(const local_params& lp, int bfh, int bfw, LabIm } } - /* - if (lp.chro != 0) { + /* + if (lp.chro != 0) { + for (int i = istart, ti = 0; i < tH; i++, ti++) { + for (int j = jstart, tj = 0; j < tW; j++, tj++) { + + float satby100 = lp.chro / 100.f; + float a = atemp[ti * TSE + tj]; + float b = btemp[ti * TSE + tj]; + + atemp[ti * TSE + tj] = a * (1.f + satby100); + btemp[ti * TSE + tj] = b * (1.f + satby100); + } + } + } + */ + + bool vasy = true; + + if (vasy) { + // ready, fill lab for (int i = istart, ti = 0; i < tH; i++, ti++) { for (int j = jstart, tj = 0; j < tW; j++, tj++) { - float satby100 = lp.chro / 100.f; - float a = atemp[ti * TSE + tj]; - float b = btemp[ti * TSE + tj]; - - atemp[ti * TSE + tj] = a * (1.f + satby100); - btemp[ti * TSE + tj] = b * (1.f + satby100); + lab->L[i][j] = Ltemp[ti * TSE + tj]; + lab->a[i][j] = atemp[ti * TSE + tj]; + lab->b[i][j] = btemp[ti * TSE + tj]; } } } - *//* - - bool vasy = true; - - if (vasy) { - // ready, fill lab - for (int i = istart, ti = 0; i < tH; i++, ti++) { - for (int j = jstart, tj = 0; j < tW; j++, tj++) { - - lab->L[i][j] = Ltemp[ti * TSE + tj]; - lab->a[i][j] = atemp[ti * TSE + tj]; - lab->b[i][j] = btemp[ti * TSE + tj]; - } - } } - } - free(buffer); + free(buffer); -} + } + -*/ } @@ -7555,12 +7546,12 @@ void ImProcFunctions::InverseColorLight_Local(const struct local_params & lp, LU } -void ImProcFunctions::calc_ref(LabImage * original, LabImage * transformed, int cx, int cy, int oW, int oH, int sk, double & huerefblur, double & hueref, double & chromaref, double & lumaref, double & sobelref) +void ImProcFunctions::calc_ref(int sp, LabImage * original, LabImage * transformed, int cx, int cy, int oW, int oH, int sk, double & huerefblur, double & hueref, double & chromaref, double & lumaref, double & sobelref) { if (params->locallab.enabled) { //always calculate hueref, chromaref, lumaref before others operations use in normal mode for all modules exceprt denoise struct local_params lp; - calcLocalParams(oW, oH, params->locallab, lp); + calcLocalParams(sp, oW, oH, params->locallab, lp); // double precision for large summations double aveA = 0.; @@ -8064,7 +8055,7 @@ void ImProcFunctions::Lab_Local(int call, int maxspot, int sp, LUTf & huerefs, L int del = 3; // to avoid crash with [loy - begy] and [lox - begx] and bfh bfw // with gtk2 [loy - begy-1] [lox - begx -1 ] and del = 1 struct local_params lp; - calcLocalParams(oW, oH, params->locallab, lp); + calcLocalParams(sp, oW, oH, params->locallab, lp); const float radius = lp.rad / (sk * 1.4f); //0 to 70 ==> see skip int strred = (lp.strucc - 1); @@ -8282,6 +8273,7 @@ void ImProcFunctions::Lab_Local(int call, int maxspot, int sp, LUTf & huerefs, L centerx[sp]; centery[sp]; */ + /* int currentcenterx = centerx[0]; int currentcentery = centery[0]; printf("cuX=%i cuY=%i sp=%i\n", currentcenterx, currentcentery, sp); @@ -8290,6 +8282,7 @@ void ImProcFunctions::Lab_Local(int call, int maxspot, int sp, LUTf & huerefs, L printf("i=%i hue=%f sob=%f cex=%i cey=%i\n", i, huerefs[i], sobelrefs[i], centerx[i], centery[i]); } + */ JaggedArray Cdeltae(bfw, bfh); JaggedArray Cdeltaesob(bfw, bfh); @@ -8731,7 +8724,7 @@ void ImProcFunctions::Lab_Local(int call, int maxspot, int sp, LUTf & huerefs, L nbaft ++; } - if (val[m][r] < 0.4f * sobelrefs[1]) { + if (val[m][r] < 0.4f * sobelrefs[1]) { // TODO Locallab Correct ? rma = r; break; } @@ -10855,7 +10848,7 @@ void ImProcFunctions::Lab_Local(int call, int maxspot, int sp, LUTf & huerefs, L } } - ImProcFunctions::ciecamloc_02float(bufcat02, bufcat02fin); + ImProcFunctions::ciecamloc_02float(sp, bufcat02, bufcat02fin); #ifdef _OPENMP #pragma omp parallel for schedule(dynamic,16) @@ -11120,7 +11113,7 @@ void ImProcFunctions::Lab_Local(int call, int maxspot, int sp, LUTf & huerefs, L - ImProcFunctions::vibrancelocal(bfw, bfh, bufexporig, bufexpfin, localskutili, sklocalcurve); + ImProcFunctions::vibrancelocal(sp, bfw, bfh, bufexporig, bufexpfin, localskutili, sklocalcurve); @@ -11214,7 +11207,7 @@ void ImProcFunctions::Lab_Local(int call, int maxspot, int sp, LUTf & huerefs, L } tmp1 = new LabImage(bfw, bfh); - ImProcFunctions::EPDToneMaplocal(bufgb, tmp1, 5, sk); + ImProcFunctions::EPDToneMaplocal(sp, bufgb, tmp1, 5, sk); } /*else { //stay here in case of tmp = new LabImage (transformed->W, transformed->H); @@ -11448,15 +11441,11 @@ void ImProcFunctions::Lab_Local(int call, int maxspot, int sp, LUTf & huerefs, L // } //sharpen only square area instaed of all image - // TODO Locallab - /* - ImProcFunctions::deconvsharpeningloc(bufsh, hbuffer, bfw, bfh, loctemp, params->locallab.shardamping, (double)params->locallab.sharradius / 100., params->locallab.shariter, params->locallab.sharamount); - */ + ImProcFunctions::deconvsharpeningloc(bufsh, hbuffer, bfw, bfh, loctemp, params->locallab.shardamping.at(sp), (double)params->locallab.sharradius.at(sp) / 100., params->locallab.shariter.at(sp), params->locallab.sharamount.at(sp)); } else { //call from dcrop.cc - // TODO Locallab - /* - ImProcFunctions::deconvsharpeningloc(original->L, shbuffer, bfw, bfh, loctemp, params->locallab.shardamping, (double)params->locallab.sharradius / 100., params->locallab.shariter, params->locallab.sharamount); - */ + + ImProcFunctions::deconvsharpeningloc(original->L, shbuffer, bfw, bfh, loctemp, params->locallab.shardamping.at(sp), (double)params->locallab.sharradius.at(sp) / 100., params->locallab.shariter.at(sp), params->locallab.sharamount.at(sp)); + } float hueplus = hueref + dhuesha; @@ -11478,10 +11467,7 @@ void ImProcFunctions::Lab_Local(int call, int maxspot, int sp, LUTf & huerefs, L int GH = original->H; JaggedArray loctemp(GW, GH); - // TODO Locallab - /* - ImProcFunctions::deconvsharpeningloc(original->L, shbuffer, GW, GH, loctemp, params->locallab.shardamping, (double)params->locallab.sharradius / 100., params->locallab.shariter, params->locallab.sharamount); - */ + ImProcFunctions::deconvsharpeningloc(original->L, shbuffer, GW, GH, loctemp, params->locallab.shardamping.at(sp), (double)params->locallab.sharradius.at(sp) / 100., params->locallab.shariter.at(sp), params->locallab.sharamount.at(sp)); float hueplus = hueref + dhuesha; float huemoins = hueref - dhuesha; @@ -11618,7 +11604,7 @@ void ImProcFunctions::Lab_Local(int call, int maxspot, int sp, LUTf & huerefs, L } float minCD, maxCD, mini, maxi, Tmean, Tsigma, Tmin, Tmax; - ImProcFunctions::MSRLocal(orig, tmpl->L, orig1, Wd, Hd, params->locallab, sk, locRETgainCcurve, 0, 4, 0.8f, minCD, maxCD, mini, maxi, Tmean, Tsigma, Tmin, Tmax); + ImProcFunctions::MSRLocal(sp, orig, tmpl->L, orig1, Wd, Hd, params->locallab, sk, locRETgainCcurve, 0, 4, 0.8f, minCD, maxCD, mini, maxi, Tmean, Tsigma, Tmin, Tmax); #ifdef _OPENMP #pragma omp parallel for #endif @@ -11645,15 +11631,13 @@ void ImProcFunctions::Lab_Local(int call, int maxspot, int sp, LUTf & huerefs, L InverseReti_Local(lp, original, transformed, tmpl, cx, cy, 0); } - // TODO Locallab - /* - if (params->locallab.chrrt > 0) { + if (params->locallab.chrrt.at(sp) > 0) { if (!lp.invret && call <= 3) { - #ifdef _OPENMP +#ifdef _OPENMP #pragma omp parallel for schedule(dynamic,16) - #endif +#endif for (int ir = 0; ir < Hd; ir += 1) for (int jr = 0; jr < Wd; jr += 1) { @@ -11664,9 +11648,9 @@ void ImProcFunctions::Lab_Local(int call, int maxspot, int sp, LUTf & huerefs, L } else { - #ifdef _OPENMP +#ifdef _OPENMP #pragma omp parallel for schedule(dynamic,16) - #endif +#endif for (int ir = 0; ir < GH; ir += 1) for (int jr = 0; jr < GW; jr += 1) { @@ -11675,14 +11659,14 @@ void ImProcFunctions::Lab_Local(int call, int maxspot, int sp, LUTf & huerefs, L } } - ImProcFunctions::MSRLocal(orig, tmpl->L, orig1, Wd, Hd, params->locallab, sk, locRETgainCcurve, 1, 4, 0.8f, minCD, maxCD, mini, maxi, Tmean, Tsigma, Tmin, Tmax); + ImProcFunctions::MSRLocal(sp, orig, tmpl->L, orig1, Wd, Hd, params->locallab, sk, locRETgainCcurve, 1, 4, 0.8f, minCD, maxCD, mini, maxi, Tmean, Tsigma, Tmin, Tmax); if (!lp.invret && call <= 3) { - #ifdef _OPENMP +#ifdef _OPENMP #pragma omp parallel for - #endif +#endif for (int ir = 0; ir < Hd; ir += 1) for (int jr = 0; jr < Wd; jr += 1) { @@ -11707,9 +11691,9 @@ void ImProcFunctions::Lab_Local(int call, int maxspot, int sp, LUTf & huerefs, L } else { - #ifdef _OPENMP +#ifdef _OPENMP #pragma omp parallel for schedule(dynamic,16) - #endif +#endif for (int ir = 0; ir < Hd; ir += 1) for (int jr = 0; jr < Wd; jr += 1) { @@ -11732,7 +11716,6 @@ void ImProcFunctions::Lab_Local(int call, int maxspot, int sp, LUTf & huerefs, L } } - */ delete tmpl; delete [] origBuffer; @@ -11748,9 +11731,7 @@ void ImProcFunctions::Lab_Local(int call, int maxspot, int sp, LUTf & huerefs, L // Gamut and Munsell control - very important do not desactivated to avoid crash - // TODO Locallab - /* - if (params->locallab.avoid) { + if (params->locallab.avoid.at(sp)) { TMatrix wiprof = ICCStore::getInstance()->workingSpaceInverseMatrix(params->icm.working); float wip[3][3] = { {static_cast(wiprof[0][0]), static_cast(wiprof[0][1]), static_cast(wiprof[0][2])}, @@ -11759,29 +11740,29 @@ void ImProcFunctions::Lab_Local(int call, int maxspot, int sp, LUTf & huerefs, L }; const bool highlight = params->toneCurve.hrenabled; const bool needHH = (lp.chro != 0.f); - #ifdef _OPENMP +#ifdef _OPENMP #pragma omp parallel if (multiThread) - #endif +#endif { - #ifdef __SSE2__ +#ifdef __SSE2__ float atan2Buffer[transformed->W] ALIGNED16; float sqrtBuffer[transformed->W] ALIGNED16; float sincosyBuffer[transformed->W] ALIGNED16; float sincosxBuffer[transformed->W] ALIGNED16; vfloat c327d68v = F2V(327.68f); vfloat onev = F2V(1.f); - #endif +#endif - #ifdef _OPENMP - #ifdef _DEBUG +#ifdef _OPENMP +#ifdef _DEBUG #pragma omp for schedule(dynamic,16) firstprivate(MunsDebugInfo) - #else +#else #pragma omp for schedule(dynamic,16) - #endif - #endif +#endif +#endif for (int y = 0; y < transformed->H; y++) { - #ifdef __SSE2__ +#ifdef __SSE2__ int i = 0; for (; i < transformed->W - 3; i += 4) { @@ -11824,19 +11805,19 @@ void ImProcFunctions::Lab_Local(int call, int maxspot, int sp, LUTf & huerefs, L } - #endif +#endif for (int x = 0; x < transformed->W; x++) { float Lprov1 = transformed->L[y][x] / 327.68f; float2 sincosval; - #ifdef __SSE2__ +#ifdef __SSE2__ float HH = atan2Buffer[x]; // reading HH from line buffer even if line buffer is not filled is faster than branching float Chprov1 = sqrtBuffer[x]; sincosval.y = sincosyBuffer[x]; sincosval.x = sincosxBuffer[x]; float chr = 0.f; - #else +#else float aa = transformed->a[y][x]; float bb = transformed->b[y][x]; float HH = 0.f, chr = 0.f; @@ -11855,19 +11836,19 @@ void ImProcFunctions::Lab_Local(int call, int maxspot, int sp, LUTf & huerefs, L sincosval.x = bb / (Chprov1 * 327.68f); } - #endif +#endif - #ifdef _DEBUG +#ifdef _DEBUG bool neg = false; bool more_rgb = false; Chprov1 = min(Chprov1, chr); Color::gamutLchonly(sincosval, Lprov1, Chprov1, wip, highlight, 0.15f, 0.92f, neg, more_rgb); - #else +#else Color::pregamutlab(Lprov1, HH, chr); Chprov1 = min(Chprov1, chr); Color::gamutLchonly(sincosval, Lprov1, Chprov1, wip, highlight, 0.15f, 0.92f); - #endif +#endif transformed->L[y][x] = Lprov1 * 327.68f; transformed->a[y][x] = 327.68f * Chprov1 * sincosval.y; @@ -11879,11 +11860,11 @@ void ImProcFunctions::Lab_Local(int call, int maxspot, int sp, LUTf & huerefs, L float correctlum = 0.f; float memChprov = sqrtf(SQR(original->a[y][x]) + SQR(original->b[y][x])) / 327.68f; float Chprov = sqrtf(SQR(transformed->a[y][x]) + SQR(transformed->b[y][x])) / 327.68f; - #ifdef _DEBUG +#ifdef _DEBUG Color::AllMunsellLch(true, Lprov1, Lprov2, HH, Chprov, memChprov, correctionHue, correctlum, MunsDebugInfo); - #else +#else Color::AllMunsellLch(true, Lprov1, Lprov2, HH, Chprov, memChprov, correctionHue, correctlum); - #endif +#endif if (fabs(correctionHue) < 0.015f) { HH += correctlum; // correct only if correct Munsell chroma very little. @@ -11898,7 +11879,6 @@ void ImProcFunctions::Lab_Local(int call, int maxspot, int sp, LUTf & huerefs, L } } } - */ #ifdef _DEBUG diff --git a/rtengine/ipretinex.cc b/rtengine/ipretinex.cc index daff210d2..bf36ab885 100644 --- a/rtengine/ipretinex.cc +++ b/rtengine/ipretinex.cc @@ -802,10 +802,8 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e } } -void ImProcFunctions::MSRLocal(float** luminance, float** templ, const float* const *originalLuminance, const int width, const int height, const LocallabParams &loc, const int skip, const LocretigainCurve &locRETgainCcurve, const int chrome, const int scall, const float krad, float &minCD, float &maxCD, float &mini, float &maxi, float &Tmean, float &Tsigma, float &Tmin, float &Tmax) +void ImProcFunctions::MSRLocal(int sp, 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) { - // TODO Locallab - /* BENCHFUN bool py = true; @@ -816,10 +814,10 @@ void ImProcFunctions::MSRLocal(float** luminance, float** templ, const float* co // constexpr bool useHsl = false; //never used constexpr bool useHslLin = false;//never used const float offse = 0.f; //loc.offs; - const float chrT = (float)(loc.chrrt) / 100.f; + const float chrT = (float)(loc.chrrt.at(sp)) / 100.f; const int scal = scall;//3;//loc.scale;; - const float vart = loc.vart / 100.f;//variance - const float strength = loc.str / 100.f; // Blend with original L channel data + const float vart = loc.vart.at(sp) / 100.f;//variance + const float strength = loc.str.at(sp) / 100.f; // Blend with original L channel data float limD = 10.f;//(float) loc.limd; limD = pow(limD, 1.7f); //about 2500 enough //limD *= useHslLin ? 10.f : 1.f; @@ -828,7 +826,7 @@ void ImProcFunctions::MSRLocal(float** luminance, float** templ, const float* co //empirical skip evaluation : very difficult because quasi all parameters interfere //to test on several images - int nei = (int)(krad * loc.neigh); + int nei = (int)(krad * loc.neigh.at(sp)); if (skip >= 4) { nei = (int)(0.1f * nei + 2.f); //not too bad @@ -838,12 +836,12 @@ void ImProcFunctions::MSRLocal(float** luminance, float** templ, const float* co int moderetinex = 0; - if (loc.retinexMethod == "uni") { + if (loc.retinexMethod.at(sp) == "uni") { moderetinex = 0; - } else if (loc.retinexMethod == "low") { + } else if (loc.retinexMethod.at(sp) == "low") { moderetinex = 1; } else { - if (loc.retinexMethod == "high") { // default to 2 ( deh.retinexMethod == "high" ) + if (loc.retinexMethod.at(sp) == "high") { // default to 2 ( deh.retinexMethod == "high" ) moderetinex = 2; } } @@ -874,9 +872,9 @@ void ImProcFunctions::MSRLocal(float** luminance, float** templ, const float* co const double shradius = mapmet == 4 ? 40 : 40.; constexpr int it = 1;//in case of !! - #ifdef _OPENMP +#ifdef _OPENMP #pragma omp parallel for - #endif +#endif for (int i = 0; i < H_L; i++) for (int j = 0; j < W_L; j++) { @@ -903,9 +901,9 @@ void ImProcFunctions::MSRLocal(float** luminance, float** templ, const float* co float *buffer = new float[W_L * H_L]; for (int scale = scal - 1; scale >= 0; scale--) { - #ifdef _OPENMP +#ifdef _OPENMP #pragma omp parallel - #endif +#endif { if (scale == scal - 1) @@ -916,9 +914,9 @@ void ImProcFunctions::MSRLocal(float** luminance, float** templ, const float* co // out was modified in last iteration => restore it if (((mapmet == 4)) && it == 1) { - #ifdef _OPENMP +#ifdef _OPENMP #pragma omp for - #endif +#endif for (int i = 0; i < H_L; i++) { for (int j = 0; j < W_L; j++) { @@ -933,9 +931,9 @@ void ImProcFunctions::MSRLocal(float** luminance, float** templ, const float* co if ((mapmet == 4) && it == 1 && scale > 0) { // out will be modified => store it for use in next iteration. We even don't need a new buffer because 'buffer' is free after gaussianBlur :) - #ifdef _OPENMP +#ifdef _OPENMP #pragma omp for - #endif +#endif for (int i = 0; i < H_L; i++) { for (int j = 0; j < W_L; j++) { @@ -958,9 +956,9 @@ void ImProcFunctions::MSRLocal(float** luminance, float** templ, const float* co if ((mapmet == 4) && it == 1) { - #ifdef _OPENMP +#ifdef _OPENMP #pragma omp parallel for schedule(dynamic,16) - #endif +#endif for (int i = 0; i < H_L; i++) { for (int j = 0; j < W_L; j++) { @@ -976,20 +974,20 @@ void ImProcFunctions::MSRLocal(float** luminance, float** templ, const float* co } - #ifdef __SSE2__ +#ifdef __SSE2__ vfloat pondv = F2V(pond); vfloat limMinv = F2V(ilimD); vfloat limMaxv = F2V(limD); - #endif - #ifdef _OPENMP +#endif +#ifdef _OPENMP #pragma omp parallel for - #endif +#endif for (int i = 0; i < H_L; i++) { int j = 0; - #ifdef __SSE2__ +#ifdef __SSE2__ if (useHslLin) { //keep in case of ?? for (; j < W_L - 3; j += 4) { @@ -1001,7 +999,7 @@ void ImProcFunctions::MSRLocal(float** luminance, float** templ, const float* co } } - #endif +#endif if (useHslLin) { for (; j < W_L; j++) { @@ -1069,173 +1067,173 @@ void ImProcFunctions::MSRLocal(float** luminance, float** templ, const float* co // luminance[i][j] *= (-1.f + 4.f * wavRETCcurve[absciss]); //new transmission } - *//* - // median filter on transmission ==> reduce artifacts - bool ty = false; + */ + // median filter on transmission ==> reduce artifacts + bool ty = false; - if (ty) {//not used here to simplify interface - int wid = W_L; - int hei = H_L; - float *tmL[hei] ALIGNED16; - float *tmLBuffer = new float[wid * hei]; - int borderL = 1; + if (ty) {//not used here to simplify interface + int wid = W_L; + int hei = H_L; + float *tmL[hei] ALIGNED16; + float *tmLBuffer = new float[wid * hei]; + int borderL = 1; - for (int i = 0; i < hei; i++) { - tmL[i] = &tmLBuffer[i * wid]; - } - -#ifdef _OPENMP - #pragma omp parallel for -#endif - - for (int i = borderL; i < hei - borderL; i++) { - // float pp[9], temp; - - for (int j = borderL; j < wid - borderL; j++) { - tmL[i][j] = median(luminance[i][j], luminance[i - 1][j], luminance[i + 1][j], luminance[i][j + 1], luminance[i][j - 1], luminance[i - 1][j - 1], luminance[i - 1][j + 1], luminance[i + 1][j - 1], luminance[i + 1][j + 1]); //3x3 + for (int i = 0; i < hei; i++) { + tmL[i] = &tmLBuffer[i * wid]; } - } #ifdef _OPENMP - #pragma omp parallel for + #pragma omp parallel for #endif - for (int i = borderL; i < hei - borderL; i++) { - for (int j = borderL; j < wid - borderL; j++) { - luminance[i][j] = tmL[i][j]; - } - } + for (int i = borderL; i < hei - borderL; i++) { + // float pp[9], temp; - delete [] tmLBuffer; - - } - - // I call mean_stddv2 instead of mean_stddv ==> logBetaGain - // mean_stddv( luminance, mean, stddv, W_L, H_L, 1.f, maxtr, mintr); - mean_stddv2(luminance, mean, stddv, W_L, H_L, maxtr, mintr); - - } - - float epsil = 0.1f; - - mini = mean - vart * stddv; - - if (mini < mintr) { - mini = mintr + epsil; - } - - maxi = mean + vart * stddv; - - if (maxi > maxtr) { - maxi = maxtr - epsil; - } - - delta = maxi - mini; - //printf("maxi=%f mini=%f mean=%f std=%f delta=%f maxtr=%f mintr=%f\n", maxi, mini, mean, stddv, delta, maxtr, mintr); - - if (!delta) { - delta = 1.0f; - } - - float cdfactor = 32768.f / delta; - maxCD = -9999999.f; - minCD = 9999999.f; - - //prepare work for curve gain -#ifdef _OPENMP - #pragma omp parallel for -#endif - - for (int i = 0; i < H_L; i++) { - for (int j = 0; j < W_L; j++) { - luminance[i][j] = luminance[i][j] - mini; - } - } - - mean = 0.f; - stddv = 0.f; - // I call mean_stddv2 instead of mean_stddv ==> logBetaGain - - mean_stddv2(luminance, mean, stddv, W_L, H_L, maxtr, mintr); - float asig = 0.f, bsig = 0.f, amax = 0.f, bmax = 0.f, amin = 0.f, bmin = 0.f; - // bool gaincurve = false; //wavRETgainCcurve - const bool hasWavRetGainCurve = locRETgainCcurve && mean != 0.f && stddv != 0.f; - - if (hasWavRetGainCurve) { //if curve - asig = 0.166666f / stddv; - bsig = 0.5f - asig * mean; - amax = 0.333333f / (maxtr - mean - stddv); - bmax = 1.f - amax * maxtr; - amin = 0.333333f / (mean - stddv - mintr); - bmin = -amin * mintr; - - asig *= 500.f; - bsig *= 500.f; - amax *= 500.f; - bmax *= 500.f; - amin *= 500.f; - bmin *= 500.f; - cdfactor *= 2.f; - } - - - const float maxclip = (chrome == 0 ? 32768.f : 50000.f); - float str = strength * (chrome == 0 ? 1.f : chrT); -#ifdef _OPENMP - #pragma omp parallel -#endif - { - // float absciss; - float cdmax = -999999.f, cdmin = 999999.f; - float gan = 0.5f; -#ifdef _OPENMP - #pragma omp for schedule(dynamic,16) -#endif - - for (int i = 0; i < H_L; i ++) - for (int j = 0; j < W_L; j++) { - if (hasWavRetGainCurve) { - float absciss; - - if (LIKELY(fabsf(luminance[i][j] - mean) < stddv)) { - absciss = asig * luminance[i][j] + bsig; - } else if (luminance[i][j] >= mean) { - absciss = amax * luminance[i][j] + bmax; - } else { - absciss = amin * luminance[i][j] + bmin; + for (int j = borderL; j < wid - borderL; j++) { + tmL[i][j] = median(luminance[i][j], luminance[i - 1][j], luminance[i + 1][j], luminance[i][j + 1], luminance[i][j - 1], luminance[i - 1][j - 1], luminance[i - 1][j + 1], luminance[i + 1][j - 1], luminance[i + 1][j + 1]); //3x3 } - - gan = locRETgainCcurve[absciss]; //new gain function transmission } - float cd = gan * cdfactor * luminance[i][j] + offse; +#ifdef _OPENMP + #pragma omp parallel for +#endif + + for (int i = borderL; i < hei - borderL; i++) { + for (int j = borderL; j < wid - borderL; j++) { + luminance[i][j] = tmL[i][j]; + } + } + + delete [] tmLBuffer; - cdmax = cd > cdmax ? cd : cdmax; - cdmin = cd < cdmin ? cd : cdmin; - luminance[i][j] = LIM(cd, 0.f, maxclip) * str + (1.f - str) * originalLuminance[i][j]; - // templ[i][j] = LIM( cd, 0.f, maxclip ) * str + (1.f - str) * originalLuminance[i][j]; - // luminance[i][j] = LIM( cd, 0.f, maxclip ); } + // I call mean_stddv2 instead of mean_stddv ==> logBetaGain + // mean_stddv( luminance, mean, stddv, W_L, H_L, 1.f, maxtr, mintr); + mean_stddv2(luminance, mean, stddv, W_L, H_L, maxtr, mintr); + + } + + float epsil = 0.1f; + + mini = mean - vart * stddv; + + if (mini < mintr) { + mini = mintr + epsil; + } + + maxi = mean + vart * stddv; + + if (maxi > maxtr) { + maxi = maxtr - epsil; + } + + delta = maxi - mini; + //printf("maxi=%f mini=%f mean=%f std=%f delta=%f maxtr=%f mintr=%f\n", maxi, mini, mean, stddv, delta, maxtr, mintr); + + if (!delta) { + delta = 1.0f; + } + + float cdfactor = 32768.f / delta; + maxCD = -9999999.f; + minCD = 9999999.f; + + //prepare work for curve gain #ifdef _OPENMP - #pragma omp critical + #pragma omp parallel for +#endif + + for (int i = 0; i < H_L; i++) { + for (int j = 0; j < W_L; j++) { + luminance[i][j] = luminance[i][j] - mini; + } + } + + mean = 0.f; + stddv = 0.f; + // I call mean_stddv2 instead of mean_stddv ==> logBetaGain + + mean_stddv2(luminance, mean, stddv, W_L, H_L, maxtr, mintr); + float asig = 0.f, bsig = 0.f, amax = 0.f, bmax = 0.f, amin = 0.f, bmin = 0.f; + // bool gaincurve = false; //wavRETgainCcurve + const bool hasWavRetGainCurve = locRETgainCcurve && mean != 0.f && stddv != 0.f; + + if (hasWavRetGainCurve) { //if curve + asig = 0.166666f / stddv; + bsig = 0.5f - asig * mean; + amax = 0.333333f / (maxtr - mean - stddv); + bmax = 1.f - amax * maxtr; + amin = 0.333333f / (mean - stddv - mintr); + bmin = -amin * mintr; + + asig *= 500.f; + bsig *= 500.f; + amax *= 500.f; + bmax *= 500.f; + amin *= 500.f; + bmin *= 500.f; + cdfactor *= 2.f; + } + + + const float maxclip = (chrome == 0 ? 32768.f : 50000.f); + float str = strength * (chrome == 0 ? 1.f : chrT); +#ifdef _OPENMP + #pragma omp parallel #endif { - maxCD = maxCD > cdmax ? maxCD : cdmax; - minCD = minCD < cdmin ? minCD : cdmin; + // float absciss; + float cdmax = -999999.f, cdmin = 999999.f; + float gan = 0.5f; +#ifdef _OPENMP + #pragma omp for schedule(dynamic,16) +#endif + + for (int i = 0; i < H_L; i ++) + for (int j = 0; j < W_L; j++) { + if (hasWavRetGainCurve) { + float absciss; + + if (LIKELY(fabsf(luminance[i][j] - mean) < stddv)) { + absciss = asig * luminance[i][j] + bsig; + } else if (luminance[i][j] >= mean) { + absciss = amax * luminance[i][j] + bmax; + } else { + absciss = amin * luminance[i][j] + bmin; + } + + gan = locRETgainCcurve[absciss]; //new gain function transmission + } + + float cd = gan * cdfactor * luminance[i][j] + offse; + + cdmax = cd > cdmax ? cd : cdmax; + cdmin = cd < cdmin ? cd : cdmin; + luminance[i][j] = LIM(cd, 0.f, maxclip) * str + (1.f - str) * originalLuminance[i][j]; + // templ[i][j] = LIM( cd, 0.f, maxclip ) * str + (1.f - str) * originalLuminance[i][j]; + // luminance[i][j] = LIM( cd, 0.f, maxclip ); + } + +#ifdef _OPENMP + #pragma omp critical +#endif + { + maxCD = maxCD > cdmax ? maxCD : cdmax; + minCD = minCD < cdmin ? minCD : cdmin; + } + } + Tmean = mean; + Tsigma = stddv; + Tmin = mintr; + Tmax = maxtr; + + } - Tmean = mean; - Tsigma = stddv; - Tmin = mintr; - Tmax = maxtr; } - - -*/ -} } diff --git a/rtengine/refreshmap.cc b/rtengine/refreshmap.cc index 1bd23ad7f..8e76ff975 100644 --- a/rtengine/refreshmap.cc +++ b/rtengine/refreshmap.cc @@ -520,6 +520,7 @@ int refreshmap[rtengine::NUMOFEVENTS] = { ALLNORAW, // EvWBEnabled RGBCURVE, // EvRGBEnabled LUMINANCECURVE, // EvLEnabled + 0, // unused LUMINANCECURVE, // EvLocallabSpotCreated LUMINANCECURVE, // EvLocallabSpotDeleted M_VOID, // EvLocallabSpotSelected diff --git a/rtengine/simpleprocess.cc b/rtengine/simpleprocess.cc index c991293bb..d04faa701 100644 --- a/rtengine/simpleprocess.cc +++ b/rtengine/simpleprocess.cc @@ -1040,32 +1040,17 @@ private: // bool localcutili = false; reservView->CopyFrom(labView); - // TODO Locallab - /* if (params.locallab.enabled) { MyTime t1, t2; t1.set(); - std::string mdfive = getMD5(imgsrc->getFileName()); - - Glib::ustring pop = options.cacheBaseDir + "/mip/"; - - Glib::ustring datalab; - - if (options.mip == MI_opt) { - datalab = pop + Glib::path_get_basename(imgsrc->getFileName() + "." + mdfive + ".mip"); - } - - if (options.mip == MI_prev) { - datalab = imgsrc->getFileName() + ".mip"; - } - - + LUTf huerefs(500, -10000.f); + LUTf sobelrefs(500, -10000.f); + LUTi centerx(500, -10000); + LUTi centery(500, -10000); LocretigainCurve locRETgainCurve; LocLHCurve loclhCurve; LocHHCurve lochhCurve; - - LocretigainCurverab locRETgainCurverab; LUTf lllocalcurve(65536, 0); LUTf cclocalcurve(65536, 0); LUTf sklocalcurve(65536, 0); @@ -1074,1124 +1059,64 @@ private: LUTf tonecurveloc(65536, 0); LUTf lightCurveloc(32770, 0); LUTf exlocalcurve(65536, 0); - // int realspot = params.locallab.nbspot; + int maxspot = settings->nspot + 1; - ifstream fic0(datalab, ios::in); float** shbuffer = nullptr; - int versionmip = 0; - std::string delim[69] = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", - "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", - "&", "#", "{", "[", "]", "}", "$", "*", "?", ">", "!", ";", "<"",(", ")", "+", "-" - }; - if (params.locallab.inverssha) { - shbuffer = new float*[fh]; + for (int sp = 0; sp < params.locallab.nbspot; sp++) { + if (params.locallab.inverssha.at(sp)) { + shbuffer = new float*[fh]; - for (int i = 0; i < fh; i++) { - shbuffer[i] = new float[fw]; + for (int i = 0; i < fh; i++) { + shbuffer[i] = new float[fw]; + } } - } - if (fic0) {//normally we don't use here but ?? - //find the version mip - string line; - string spotline; - // int cont = 0; + // Set local curves of current spot to LUT + bool LHutili = false; + bool HHutili = false; + bool locallutili = false; + bool localcutili = false; + bool localskutili = false; + bool localexutili = false; + locRETgainCurve.Set(params.locallab.localTgaincurve.at(sp)); + loclhCurve.Set(params.locallab.LHcurve.at(sp), LHutili); + lochhCurve.Set(params.locallab.HHcurve.at(sp), HHutili); + CurveFactory::curveLocal(locallutili, params.locallab.llcurve.at(sp), lllocalcurve, 1); + CurveFactory::curveCCLocal(localcutili, params.locallab.cccurve.at(sp), cclocalcurve, 1); + CurveFactory::curveskLocal(localskutili, params.locallab.skintonescurve.at(sp), sklocalcurve, 1); + CurveFactory::curveexLocal(localexutili, params.locallab.excurve.at(sp), exlocalcurve, 1); + //provisory + double ecomp = params.locallab.expcomp.at(sp); + double black = params.locallab.black.at(sp); + double hlcompr = params.locallab.hlcompr.at(sp); + double hlcomprthresh = params.locallab.hlcomprthresh.at(sp); + double shcompr = params.locallab.shcompr.at(sp); + double br = params.locallab.lightness.at(sp); + CurveFactory::complexCurvelocal(ecomp, black / 65535., hlcompr, hlcomprthresh, shcompr, br, + hltonecurveloc, shtonecurveloc, tonecurveloc, lightCurveloc, + 1); - while (getline(fic0, line)) { - spotline = line; - std::size_t pos = spotline.find("="); - std::size_t posend = spotline.find("@"); //in case of for futur use - - if (spotline.substr(0, pos) == "Mipversion") { - string strversion = spotline.substr(pos + 1, (posend - pos)); - versionmip = std::stoi(strversion.c_str()); - } - - if (spotline.substr(0, pos) == "Spot") { - // cont = 0; - } + // Reference parameters computation + double huere, chromare, lumare, huerefblu, sobelre; + if (params.locallab.spotMethod.at(sp) == "exc") { + ipf.calc_ref(sp, reservView, reservView, 0, 0, fw, fh, 1, huerefblu, huere, chromare, lumare, sobelre); + } else { + ipf.calc_ref(sp, labView, labView, 0, 0, fw, fh, 1, huerefblu, huere, chromare, lumare, sobelre); } - fic0.close(); - } + ipf.Lab_Local(2, maxspot, sp, huerefs, sobelrefs, centerx, centery, (float**)shbuffer, labView, labView, reservView, 0, 0, fw, fh, 1, locRETgainCurve, lllocalcurve, loclhCurve, lochhCurve, + LHutili, HHutili, cclocalcurve, localskutili, sklocalcurve, localexutili, exlocalcurve, hltonecurveloc, shtonecurveloc, tonecurveloc, lightCurveloc, huerefblu, huere, chromare, lumare, sobelre); - ifstream fich(datalab, ios::in); - int maxdata = 102; //101 10023 //100 10022 //99 10021 // 91 10021 //88 10019 //87 10018//86 10017//85 10016 //82;//78;//73 10011 - //it must be the same value as in improccoordinator.cc + // Clear local curves + lllocalcurve.clear(); + cclocalcurve.clear(); + sklocalcurve.clear(); + exlocalcurve.clear(); - if (fich && versionmip != 0) { - std::string inser; - - int **dataspots; - dataspots = new int*[maxdata]; - LUTf huerefs(500, -10000.f); - LUTf sobelrefs(500, -10000.f); - LUTi centerx(500, -10000); - LUTi centery(500, -10000); - - for (int i = 0; i < maxdata; i++) { - dataspots[i] = new int[maxspot]; - } - - - std::string *retistrs; - retistrs = new std::string[maxspot]; - std::string *llstrs; - - llstrs = new std::string[maxspot]; - - std::string *lhstrs; - lhstrs = new std::string[maxspot]; - - std::string *ccstrs; - ccstrs = new std::string[maxspot]; - - std::string *hhstrs; - hhstrs = new std::string[maxspot]; - - std::string *skinstrs; - skinstrs = new std::string[maxspot]; - - 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; - dataspots[4][0] = params.locallab.locY; - dataspots[5][0] = params.locallab.locYT; - dataspots[6][0] = params.locallab.locXL; - dataspots[7][0] = params.locallab.centerX; - dataspots[8][0] = params.locallab.centerY; - dataspots[9][0] = params.locallab.lightness; - dataspots[10][0] = params.locallab.contrast; - dataspots[11][0] = params.locallab.chroma; - dataspots[12][0] = params.locallab.sensi; - dataspots[13][0] = params.locallab.transit; - - if (!params.locallab.invers) { - dataspots[14][0] = 0; - } else { - dataspots[14][0] = 1; - } - - if (params.locallab.Smethod == "IND") { - dataspots[15][0] = 0; - } else if (params.locallab.Smethod == "SYM") { - dataspots[15][0] = 1; - } else if (params.locallab.Smethod == "INDSL") { - dataspots[15][0] = 2; - } else if (params.locallab.Smethod == "SYMSL") { - dataspots[15][0] = 3; - } - - dataspots[17][0] = params.locallab.radius; - dataspots[18][0] = params.locallab.strength; - dataspots[19][0] = params.locallab.sensibn; - - if (!params.locallab.inversrad) { - dataspots[20][0] = 0; - } else { - dataspots[20][0] = 1; - } - - dataspots[21][0] = params.locallab.str; - dataspots[22][0] = params.locallab.chrrt; - dataspots[23][0] = params.locallab.neigh; - dataspots[24][0] = params.locallab.vart; - dataspots[25][0] = params.locallab.sensih; - - if (!params.locallab.inversret) { - dataspots[26][0] = 0; - } else { - dataspots[26][0] = 1; - } - - if (params.locallab.retinexMethod == "low") { - dataspots[27][0] = 0; - } else if (params.locallab.retinexMethod == "uni") { - dataspots[27][0] = 1; - } else if (params.locallab.retinexMethod == "high") { - dataspots[27][0] = 2; - } - - - dataspots[28][0] = params.locallab.sharradius; - dataspots[29][0] = params.locallab.sharamount; - dataspots[30][0] = params.locallab.shardamping; - dataspots[31][0] = params.locallab.shariter; - dataspots[32][0] = params.locallab.sensisha; - - if (!params.locallab.inverssha) { - dataspots[33][0] = 0; - } else { - dataspots[33][0] = 1; - } - - if (params.locallab.qualityMethod == "std") { - dataspots[34][0] = 0; - } else if (params.locallab.qualityMethod == "enh") { - dataspots[34][0] = 1; - } else if (params.locallab.qualityMethod == "enhden") { - dataspots[34][0] = 2; - } - - dataspots[35][0] = params.locallab.thres; - dataspots[36][0] = params.locallab.proxi; - - dataspots[37][0] = params.locallab.noiselumf; - dataspots[38][0] = params.locallab.noiselumc; - dataspots[39][0] = params.locallab.noisechrof; - dataspots[40][0] = params.locallab.noisechroc; - - dataspots[41][0] = params.locallab.mult[0]; - dataspots[42][0] = params.locallab.mult[1]; - dataspots[43][0] = params.locallab.mult[2]; - dataspots[44][0] = params.locallab.mult[3]; - dataspots[45][0] = params.locallab.mult[4]; - dataspots[46][0] = params.locallab.threshold; - dataspots[47][0] = params.locallab.sensicb; - - if (!params.locallab.activlum) { - dataspots[48][0] = 0; - } else { - dataspots[48][0] = 1; - } - - dataspots[49][0] = params.locallab.stren; - dataspots[50][0] = params.locallab.gamma; - dataspots[51][0] = params.locallab.estop; - dataspots[52][0] = params.locallab.scaltm; - dataspots[53][0] = params.locallab.rewei; - dataspots[54][0] = params.locallab.sensitm; - dataspots[55][0] = params.locallab.retrab; - - if (!params.locallab.curvactiv) { - dataspots[56][0] = 0; - } else { - dataspots[56][0] = 1; - } - - if (params.locallab.qualitycurveMethod == "none") { - dataspots[57][0] = 0; - } else if (params.locallab.qualitycurveMethod == "std") { - dataspots[57][0] = 1; - } else if (params.locallab.qualitycurveMethod == "enh") { - dataspots[57][0] = 2; - } - - 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] = params.locallab.expcomp; - dataspots[65][0] = params.locallab.black; - dataspots[66][0] = params.locallab.hlcompr; - dataspots[67][0] = params.locallab.hlcomprthresh; - dataspots[68][0] = params.locallab.shcompr; - dataspots[69][0] = params.locallab.sensiex; - - dataspots[70][0] = params.locallab.centerXbuf; - dataspots[71][0] = params.locallab.centerYbuf; - dataspots[72][0] = params.locallab.adjblur; - - if (!params.locallab.cutpast) { - dataspots[73][0] = 0; - } else { - dataspots[73][0] = 1; - } - - dataspots[74][0] = params.locallab.chromacbdl; - - if (!params.locallab.lastdust) { - dataspots[75][0] = 0; - } else { - dataspots[75][0] = 1; - } - - if (params.locallab.blurMethod == "norm") { - dataspots[76][0] = 0; - } else if (params.locallab.blurMethod == "inv") { - dataspots[76][0] = 1; - } else if (params.locallab.blurMethod == "sym") { - dataspots[76][0] = 2; - } - - if (params.locallab.dustMethod == "cop") { - dataspots[77][0] = 0; - } else if (params.locallab.dustMethod == "mov") { - dataspots[77][0] = 1; - } else if (params.locallab.dustMethod == "pas") { - dataspots[77][0] = 2; - } - - - if (params.locallab.Exclumethod == "norm") { - dataspots[78][0] = 0; - } else if (params.locallab.Exclumethod == "exc") { - dataspots[78][0] = 1; - } - - dataspots[79][0] = params.locallab.sensiexclu; - dataspots[80][0] = params.locallab.struc; - dataspots[81][0] = params.locallab.warm; - dataspots[82][0] = params.locallab.noiselumdetail; - dataspots[83][0] = params.locallab.noisechrodetail; - dataspots[84][0] = params.locallab.sensiden; - - if (!params.locallab.expdenoi) { - dataspots[85][0] = 0; - } else { - dataspots[85][0] = 1; - } - - if (!params.locallab.expcolor) { - dataspots[86][0] = 0; - } else { - dataspots[86][0] = 1; - } - - if (!params.locallab.expvibrance) { - dataspots[87][0] = 0; - } else { - dataspots[87][0] = 1; - } - - if (!params.locallab.expblur) { - dataspots[88][0] = 0; - } else { - dataspots[88][0] = 1; - } - - if (!params.locallab.exptonemap) { - dataspots[89][0] = 0; - } else { - dataspots[89][0] = 1; - } - - if (!params.locallab.expreti) { - dataspots[90][0] = 0; - } else { - dataspots[90][0] = 1; - } - - if (!params.locallab.expsharp) { - dataspots[91][0] = 0; - } else { - dataspots[91][0] = 1; - } - - if (!params.locallab.expcbdl) { - dataspots[92][0] = 0; - } else { - dataspots[92][0] = 1; - } - - if (!params.locallab.expexpose) { - dataspots[93][0] = 0; - } else { - dataspots[93][0] = 1; - } - - dataspots[94][0] = params.locallab.bilateral; - dataspots[95][0] = params.locallab.noiselequal; - - if (params.locallab.shapemethod == "ELI") { - dataspots[96][0] = 0; - } else if (params.locallab.shapemethod == "RECT") { - dataspots[96][0] = 1; - } - - dataspots[maxdata - 5][0] = 100.f * params.locallab.huerefblur; - dataspots[maxdata - 4][0] = 100.f * params.locallab.hueref; - dataspots[maxdata - 3][0] = params.locallab.chromaref; - dataspots[maxdata - 2][0] = params.locallab.lumaref; - dataspots[maxdata - 1][0] = params.locallab.sobelref; - - //curve Reti local - int siz = params.locallab.localTgaincurve.size(); - - if (siz > 69) { - siz = 69;//avoid crash - } - - // int s_cur[siz + 1]; - int s_datcur[siz + 1]; - - for (int j = 0; j < siz; j++) { - s_datcur[j] = (int)(1000. * params.locallab.localTgaincurve[j]); - } - - std::string cur_str = ""; - - for (int j = 0; j < siz; j++) { - cur_str = cur_str + std::to_string(s_datcur[j]) + delim[j]; - } - - inser = retistrs[0] = cur_str + "@"; - - int sizl = params.locallab.llcurve.size(); - - if (sizl > 69) { - sizl = 69; - } - - // int s_curl[sizl + 1]; - int s_datcurl[sizl + 1]; - - for (int j = 0; j < sizl; j++) { - s_datcurl[j] = (int)(1000. * params.locallab.llcurve[j]); - } - - std::string ll_str = ""; - - for (int j = 0; j < sizl; j++) { - ll_str = ll_str + std::to_string(s_datcurl[j]) + delim[j]; - } - - llstrs[0] = ll_str + "@"; - - - int sizc = params.locallab.cccurve.size(); - - if (sizc > 69) { - sizc = 69; - } - - // int s_curc[sizc + 1]; - int s_datcurc[sizc + 1]; - - for (int j = 0; j < sizc; j++) { - s_datcurc[j] = (int)(1000. * params.locallab.cccurve[j]); - } - - std::string cc_str = ""; - - for (int j = 0; j < sizc; j++) { - cc_str = cc_str + std::to_string(s_datcurc[j]) + delim[j]; - } - - ccstrs[0] = cc_str + "@"; - - // - - int sizh = params.locallab.LHcurve.size(); - - if (sizh > 69) { - sizh = 69; - } - - // int s_curh[sizh + 1]; - int s_datcurh[sizh + 1]; - - for (int j = 0; j < sizh; j++) { - s_datcurh[j] = (int)(1000. * params.locallab.LHcurve[j]); - } - - std::string lh_str = ""; - - for (int j = 0; j < sizh; j++) { - lh_str = lh_str + std::to_string(s_datcurh[j]) + delim[j]; - } - - lhstrs[0] = lh_str + "@"; - - int sizhh = params.locallab.HHcurve.size(); - - if (sizhh > 69) { - sizhh = 69; - } - - // int s_curh[sizh + 1]; - int s_datcurhh[sizhh + 1]; - - for (int j = 0; j < sizhh; j++) { - s_datcurhh[j] = (int)(1000. * params.locallab.HHcurve[j]); - } - - std::string hh_str = ""; - - for (int j = 0; j < sizhh; j++) { - hh_str = hh_str + std::to_string(s_datcurhh[j]) + delim[j]; - } - - 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.getTopLeft()); - - s_datps[0] = static_cast(params.locallab.psthreshold.getBottomLeft()); - - 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 - - //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 + "@"; - - - - - } - - - int ns = 0; - - if (fich) { - - std::string line; - std::string spotline; - int cont = 0; - - while (getline(fich, line)) { - spotline = line; - std::size_t pos = spotline.find("="); - std::size_t posend = spotline.find("@"); //in case of for futur use - - if (spotline.substr(0, pos) == "Mipversion") { - std::string strversion = spotline.substr(pos + 1, (posend - pos)); - versionmip = std::stoi(strversion.c_str()); - } - - if (spotline.substr(0, pos) == "Spot") { - cont = 0; - } - - cont++; - std::string str3 = spotline.substr(pos + 1, (posend - pos)); - - if (cont == 1) { - ns = std::stoi(str3.c_str()); - } - - if (cont >= 2 && cont < 16) { - dataspots[cont][ns] = std::stoi(str3.c_str()); - - } - - if (spotline.substr(0, pos) == "Currentspot") { - dataspots[16][0] = std::stoi(str3.c_str()); - } - - if (cont > 16 && cont < maxdata) { - dataspots[cont][ns] = std::stoi(str3.c_str()); - - } - - if (spotline.substr(0, pos) == "curveReti") { - retistrs[ns] = str3; - } - - if (spotline.substr(0, pos) == "curveLL") { - llstrs[ns] = str3; - } - - if (spotline.substr(0, pos) == "curveLH") { - lhstrs[ns] = str3; - } - - if (spotline.substr(0, pos) == "curveHH") { - hhstrs[ns] = str3; - } - - if (spotline.substr(0, pos) == "curveCC") { - ccstrs[ns] = str3; - } - - if (spotline.substr(0, pos) == "curveskin") { - skinstrs[ns] = str3; - } - - if (spotline.substr(0, pos) == "pthres") { - pthstrs[ns] = str3; - } - - if (spotline.substr(0, pos) == "curveex") { - exstrs[ns] = str3; - } - - - } - - fich.close(); - } - - - for (int sp = 1; sp < maxspot; sp++) { //spots default - params.locallab.huerefblur = INFINITY; - params.locallab.hueref = INFINITY; - params.locallab.chromaref = INFINITY; - params.locallab.lumaref = INFINITY; - params.locallab.sobelref = INFINITY; - - params.locallab.circrad = dataspots[2][sp]; - params.locallab.locX = dataspots[3][sp]; - params.locallab.locY = dataspots[4][sp]; - params.locallab.locYT = dataspots[5][sp]; - params.locallab.locXL = dataspots[6][sp]; - params.locallab.centerX = centerx[sp] = dataspots[7][sp]; - params.locallab.centerY = centery[sp] = dataspots[8][sp]; - params.locallab.lightness = dataspots[9][sp]; - params.locallab.contrast = dataspots[10][sp]; - params.locallab.chroma = dataspots[11][sp]; - params.locallab.sensi = dataspots[12][sp]; - params.locallab.transit = dataspots[13][sp]; - - if (dataspots[14][sp] == 0) { - params.locallab.invers = false; - } else { - params.locallab.invers = true; - } - - if (dataspots[15][sp] == 0) { - params.locallab.Smethod = "IND" ; - } else if (dataspots[15][sp] == 1) { - params.locallab.Smethod = "SYM" ; - } else if (dataspots[15][sp] == 2) { - params.locallab.Smethod = "INDSL"; - } else if (dataspots[15][sp] == 3) { - params.locallab.Smethod = "SYMSL"; - } - - params.locallab.radius = dataspots[17][sp]; - params.locallab.strength = dataspots[18][sp]; - params.locallab.sensibn = dataspots[19][sp]; - - if (dataspots[20][sp] == 0) { - params.locallab.inversrad = false; - } else { - params.locallab.inversrad = true; - } - - params.locallab.str = dataspots[21][sp]; - params.locallab.chrrt = dataspots[22][sp]; - params.locallab.neigh = dataspots[23][sp]; - params.locallab.vart = dataspots[24][sp]; - params.locallab.sensih = dataspots[25][sp]; - - if (dataspots[26][sp] == 0) { - params.locallab.inversret = false; - } else { - params.locallab.inversret = true; - } - - if (dataspots[27][sp] == 0) { - params.locallab.retinexMethod = "low" ; - } else if (dataspots[27][sp] == 1) { - params.locallab.retinexMethod = "uni" ; - } else if (dataspots[27][sp] == 2) { - params.locallab.retinexMethod = "high"; - } - - params.locallab.sharradius = dataspots[28][sp]; - params.locallab.sharamount = dataspots[29][sp]; - params.locallab.shardamping = dataspots[30][sp]; - params.locallab.shariter = dataspots[31][sp]; - params.locallab.sensisha = dataspots[32][sp]; - - if (dataspots[33][sp] == 0) { - params.locallab.inverssha = false; - } else { - params.locallab.inverssha = true; - } - - if (dataspots[34][sp] == 0) { - params.locallab.qualityMethod = "std" ; - } else if (dataspots[34][sp] == 1) { - params.locallab.qualityMethod = "enh" ; - } else if (dataspots[34][sp] == 2) { - params.locallab.qualityMethod = "enhden" ; - } - - params.locallab.thres = dataspots[35][sp]; - params.locallab.proxi = dataspots[36][sp]; - - params.locallab.noiselumf = dataspots[37][sp]; - params.locallab.noiselumc = dataspots[38][sp]; - params.locallab.noisechrof = dataspots[39][sp]; - params.locallab.noisechroc = dataspots[40][sp]; - - params.locallab.mult[0] = dataspots[41][sp]; - params.locallab.mult[1] = dataspots[42][sp]; - params.locallab.mult[2] = dataspots[43][sp]; - params.locallab.mult[3] = dataspots[44][sp]; - params.locallab.mult[4] = dataspots[45][sp]; - params.locallab.threshold = dataspots[46][sp]; - params.locallab.sensicb = dataspots[47][sp]; - - if (dataspots[48][sp] == 0) { - params.locallab.activlum = false; - } else { - params.locallab.activlum = true; - } - - params.locallab.stren = dataspots[49][sp]; - params.locallab.gamma = dataspots[50][sp]; - params.locallab.estop = dataspots[51][sp]; - params.locallab.scaltm = dataspots[52][sp]; - params.locallab.rewei = dataspots[53][sp]; - params.locallab.sensitm = dataspots[54][sp]; - params.locallab.retrab = dataspots[55][sp]; - - if (dataspots[56][sp] == 0) { - params.locallab.curvactiv = false; - } else { - params.locallab.curvactiv = true; - } - - if (dataspots[57][sp] == 0) { - params.locallab.qualitycurveMethod = "none" ; - } else if (dataspots[57][sp] == 1) { - params.locallab.qualitycurveMethod = "std" ; - } else if (dataspots[57][sp] == 2) { - params.locallab.qualitycurveMethod = "enh" ; - } - - - 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.expcomp = dataspots[64][sp]; - params.locallab.black = dataspots[65][sp]; - params.locallab.hlcompr = dataspots[66][sp]; - params.locallab.hlcomprthresh = dataspots[67][sp]; - params.locallab.shcompr = dataspots[68][sp]; - params.locallab.sensiex = dataspots[69][sp]; - - params.locallab.centerXbuf = dataspots[70][sp]; - params.locallab.centerYbuf = dataspots[71][sp]; - params.locallab.adjblur = dataspots[72][sp]; - - if (dataspots[73][sp] == 0) { - params.locallab.cutpast = false; - } else { - params.locallab.cutpast = true; - } - - params.locallab.chromacbdl = dataspots[74][sp]; - - if (dataspots[75][sp] == 0) { - params.locallab.lastdust = false; - } else { - params.locallab.lastdust = true; - } - - if (dataspots[76][sp] == 0) { - params.locallab.blurMethod = "norm" ; - } else if (dataspots[76][sp] == 1) { - params.locallab.blurMethod = "inv" ; - } else if (dataspots[76][sp] == 2) { - params.locallab.blurMethod = "sym" ; - } - - if (dataspots[77][sp] == 0) { - params.locallab.dustMethod = "cop" ; - } else if (dataspots[77][sp] == 1) { - params.locallab.dustMethod = "mov" ; - } else if (dataspots[77][sp] == 2) { - params.locallab.dustMethod = "pas" ; - } - - - if (dataspots[78][sp] == 0) { - params.locallab.Exclumethod = "norm" ; - } else if (dataspots[78][sp] == 1) { - params.locallab.Exclumethod = "exc" ; - } - - params.locallab.sensiexclu = dataspots[79][sp]; - params.locallab.struc = dataspots[80][sp]; - params.locallab.warm = dataspots[81][sp]; - params.locallab.noiselumdetail = dataspots[82][sp]; - params.locallab.noisechrodetail = dataspots[83][sp]; - params.locallab.sensiden = dataspots[84][sp]; - - if (dataspots[85][sp] == 0) { - params.locallab.expdenoi = false; - } else { - params.locallab.expdenoi = true; - } - - if (dataspots[86][sp] == 0) { - params.locallab.expcolor = false; - } else { - params.locallab.expcolor = true; - } - - if (dataspots[87][sp] == 0) { - params.locallab.expvibrance = false; - } else { - params.locallab.expvibrance = true; - } - - if (dataspots[88][sp] == 0) { - params.locallab.expblur = false; - } else { - params.locallab.expblur = true; - } - - if (dataspots[89][sp] == 0) { - params.locallab.exptonemap = false; - } else { - params.locallab.exptonemap = true; - } - - if (dataspots[90][sp] == 0) { - params.locallab.expreti = false; - } else { - params.locallab.expreti = true; - } - - if (dataspots[91][sp] == 0) { - params.locallab.expsharp = false; - } else { - params.locallab.expsharp = true; - } - - if (dataspots[92][sp] == 0) { - params.locallab.expcbdl = false; - } else { - params.locallab.expcbdl = true; - } - - if (dataspots[93][sp] == 0) { - params.locallab.expexpose = false; - } else { - params.locallab.expexpose = true; - } - - params.locallab.bilateral = dataspots[94][sp]; - params.locallab.noiselequal = dataspots[95][sp]; - - if (dataspots[96][sp] == 0) { - params.locallab.shapemethod = "ELI" ; - } else if (dataspots[96][sp] == 1) { - params.locallab.shapemethod = "RECT" ; - } - - params.locallab.huerefblur = ((float) dataspots[maxdata - 5][sp]) / 100.f; - params.locallab.hueref = huerefs[sp] = ((float) dataspots[maxdata - 4][sp]) / 100.f; - huerefs[sp] *= 100.f; - params.locallab.chromaref = dataspots[maxdata - 3][sp]; - params.locallab.lumaref = dataspots[maxdata - 2][sp]; - params.locallab.sobelref = sobelrefs[sp] = dataspots[maxdata - 1][sp]; - - - int *s_datc; - s_datc = new int[70]; - int siz; - - ipf.strcurv_data(retistrs[sp], s_datc, siz); - std::vector cretiend; - - for (int j = 0; j < siz; j++) { - cretiend.push_back((double)(s_datc[j]) / 1000.); - } - - delete [] s_datc; - - int *s_datcl; - s_datcl = new int[70]; - int sizl; - - ipf.strcurv_data(llstrs[sp], s_datcl, sizl); - - - std::vector cllend; - - for (int j = 0; j < sizl; j++) { - cllend.push_back((double)(s_datcl[j]) / 1000.); - } - - delete [] s_datcl; - - int *s_datcc; - s_datcc = new int[70]; - int sizc; - - ipf.strcurv_data(ccstrs[sp], s_datcc, sizc); - - - std::vector cccend; - - for (int j = 0; j < sizc; j++) { - cccend.push_back((double)(s_datcc[j]) / 1000.); - } - - delete [] s_datcc; - - int *s_datch; - s_datch = new int[70]; - int sizh; - - ipf.strcurv_data(lhstrs[sp], s_datch, sizh); - - - std::vector clhend; - - for (int j = 0; j < sizh; j++) { - clhend.push_back((double)(s_datch[j]) / 1000.); - } - - int *s_datchh; - s_datchh = new int[70]; - int sizhh; - - ipf.strcurv_data(hhstrs[sp], s_datchh, sizhh); - - - std::vector chhend; - - for (int j = 0; j < sizhh; j++) { - 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]); - - //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; - params.locallab.LHcurve = clhend; - params.locallab.cccurve = cccend; - params.locallab.HHcurve = chhend; - params.locallab.skintonescurve = cskend; - params.locallab.excurve = cexend; - - bool LHutili = false; - bool HHutili = false; - std::string t_curvhhref = "1000A0B500C350D350E166F500G350H350I333J500K350L350M500N500O350P350Q666R500S350T350U833V500W350X350Y@"; - - if (lhstrs[sp].c_str() != t_curvhhref) { - // LHutili = true; - } - - if (hhstrs[sp].c_str() != t_curvhhref) { - // HHutili = true; - } - - - params.locallab.getCurves(locRETgainCurve, locRETgainCurverab, loclhCurve, lochhCurve, LHutili, HHutili); - bool locallutili = false; - bool localcutili = false; - bool localskutili = false; - bool localexutili = false; - std::string t_curvskinref = "3000A0B0C1000D1000E@"; - std::string t_none = "0A@"; - - if (skinstrs[sp].c_str() != t_curvskinref && skinstrs[sp].c_str() != t_none) { - // 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); - - CurveFactory::curveexLocal(localexutili, params.locallab.excurve, exlocalcurve, 1); - //provisory - double ecomp = params.locallab.expcomp; - double black = params.locallab.black; - double hlcompr = params.locallab.hlcompr; - double hlcomprthresh = params.locallab.hlcomprthresh; - double shcompr = params.locallab.shcompr; - double br = params.locallab.lightness; - - CurveFactory::complexCurvelocal(ecomp, black / 65535., hlcompr, hlcomprthresh, shcompr, br, - hltonecurveloc, shtonecurveloc, tonecurveloc, lightCurveloc, - - 1); - - double huere, chromare, lumare, huerefblu; - double sobelre; - - if (params.locallab.Exclumethod == "exc") { - - ipf.calc_ref(reservView, reservView, 0, 0, fw, fh, 1, huerefblu, huere, chromare, lumare, sobelre); - } else { - ipf.calc_ref(labView, labView, 0, 0, fw, fh, 1, huerefblu, huere, chromare, lumare, sobelre); - - } - - params.locallab.huerefblur = huerefblu; - params.locallab.hueref = huere; - params.locallab.chromaref = chromare; - params.locallab.lumaref = lumare; - params.locallab.sobelref = sobelre; - //nullptr or dataspot ?? - - ipf.Lab_Local(2, maxspot, sp, huerefs, sobelrefs, centerx, centery, (float**)shbuffer, labView, labView, reservView, 0, 0, fw, fh, 1, locRETgainCurve, lllocalcurve, loclhCurve, lochhCurve, - LHutili, HHutili, cclocalcurve, localskutili, sklocalcurve, localexutili, exlocalcurve, hltonecurveloc, shtonecurveloc, tonecurveloc, lightCurveloc, params.locallab.huerefblur, params.locallab.hueref, params.locallab.chromaref, params.locallab.lumaref, params.locallab.sobelref); - lllocalcurve.clear(); - cclocalcurve.clear(); - sklocalcurve.clear(); - exlocalcurve.clear(); - - } - - - - for (int i = 0; i < maxdata; i++) { - delete [] dataspots[i]; - } - - delete [] dataspots; - - - - - delete [] retistrs; - delete [] llstrs; - delete [] lhstrs; - delete [] ccstrs; - delete [] hhstrs; - delete [] skinstrs; - delete [] exstrs; - - if (params.locallab.inverssha) { + if (params.locallab.inverssha.at(sp)) { for (int i = 0; i < fh; i++) { delete [] shbuffer[i]; @@ -2210,7 +1135,6 @@ private: } } - */ delete reservView; reservView = nullptr; diff --git a/rtgui/locallab.cc b/rtgui/locallab.cc index 473494193..c5688a36b 100644 --- a/rtgui/locallab.cc +++ b/rtgui/locallab.cc @@ -3118,8 +3118,16 @@ void Locallab::pastsattog_toggled() */ } + // Update Vibrance GUI according to pastsattog button state if (pastSatTog->get_active()) { - saturated->setValue(pastels->getValue()); + // 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 (getEnabled() && expvibrance->getEnabled()) { @@ -3226,6 +3234,13 @@ void Locallab::blurMethodChanged() { printf("blurMethodChanged\n"); + // Update Blur & Noise GUI according to blurMethod combobox + if (blurMethod->get_active_row_number() == 0 || blurMethod->get_active_row_number() == 2) { + sensibn->show(); + } else { + sensibn->hide(); + } + if (getEnabled() && expblur->getEnabled()) { if (listener) { listener->panelChanged(EvlocallabblurMethod, blurMethod->get_active_text()); @@ -3359,9 +3374,9 @@ void Locallab::SmethodChanged() if (listener && getEnabled()) { if (Smethod->get_active_row_number() == 1 || Smethod->get_active_row_number() == 3) { - listener->panelChanged(EvlocallabSmet, Smethod->get_active_text()); - locXL->setValue(locX->getValue()); - locYT->setValue(locY->getValue()); +listener->panelChanged(EvlocallabSmet, Smethod->get_active_text()); +locXL->setValue(locX->getValue()); +locYT->setValue(locY->getValue()); } // else if(Smethod->get_active_row_number()==2) { // listener->panelChanged (EvlocallabSmet, Smethod->get_active_text ()); @@ -3372,7 +3387,7 @@ if (Smethod->get_active_row_number() == 1 || Smethod->get_active_row_number() = else { - listener->panelChanged(EvlocallabSmet, Smethod->get_active_text()); +listener->panelChanged(EvlocallabSmet, Smethod->get_active_text()); } } @@ -3576,6 +3591,13 @@ void Locallab::inversshaChanged() */ } + // Update Sharpening GUI according to inverssha button state + if (inverssha->get_active()) { + sensisha->hide(); + } else { + sensisha->show(); + } + if (getEnabled() && expsharp->getEnabled()) { if (listener) { if (inverssha->get_active()) { @@ -3606,6 +3628,13 @@ void Locallab::inversretChanged() */ } + // Update Retinex GUI according to inversret button state + if (inversret->get_active()) { + sensih->hide(); + } else { + sensih->show(); + } + if (getEnabled() && expsharp->getEnabled()) { if (listener) { if (inversret->get_active()) { @@ -3905,6 +3934,11 @@ void Locallab::adjusterChanged(Adjuster * a, double newval) } // Exposure + if (a == black) { + // Update Exposure GUI according to black adjuster state + shcompr->set_sensitive(!((int)black->getValue() == 0)); // At black = 0, shcompr value has no effect + } + if (getEnabled() && expexpose->getEnabled()) { if (a == expcomp) { if (listener) { @@ -4783,6 +4817,13 @@ void Locallab::updateLocallabGUI(const rtengine::procparams::ProcParams* pp, int saturated->set_sensitive(true); } + // Update Blur & Noise GUI according to blurMethod combobox + if (blurMethod->get_active_row_number() == 0 || blurMethod->get_active_row_number() == 2) { + sensibn->show(); + } else { + sensibn->hide(); + } + // Update Retinex GUI according to inversret button state if (inversret->get_active()) { sensih->hide();