Merge branch 'dev' into metadata-exiv2
This commit is contained in:
@@ -16,28 +16,32 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with RawTherapee. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <glibmm/thread.h>
|
||||
#include <glibmm/ustring.h>
|
||||
|
||||
#include "cieimage.h"
|
||||
#include "dcp.h"
|
||||
#include "imagefloat.h"
|
||||
#include "labimage.h"
|
||||
#include "rtengine.h"
|
||||
#include "clutstore.h"
|
||||
#include "color.h"
|
||||
#include "colortemp.h"
|
||||
#include "curves.h"
|
||||
#include "dcp.h"
|
||||
#include "guidedfilter.h"
|
||||
#include "iccstore.h"
|
||||
#include "imagefloat.h"
|
||||
#include "imagesource.h"
|
||||
#include "improcfun.h"
|
||||
#include "curves.h"
|
||||
#include "iccstore.h"
|
||||
#include "clutstore.h"
|
||||
#include "labimage.h"
|
||||
#include "metadata.h"
|
||||
#include "mytime.h"
|
||||
#include "processingjob.h"
|
||||
#include "procparams.h"
|
||||
#include <glibmm/ustring.h>
|
||||
#include <glibmm/thread.h>
|
||||
#include "../rtgui/options.h"
|
||||
#include "rawimagesource.h"
|
||||
#include "rtengine.h"
|
||||
#include "utils.h"
|
||||
|
||||
#include "../rtgui/multilangmgr.h"
|
||||
#include "mytime.h"
|
||||
#include "guidedfilter.h"
|
||||
#include "color.h"
|
||||
#include "metadata.h"
|
||||
#include "../rtgui/options.h"
|
||||
|
||||
#undef THREAD_PRIORITY_NORMAL
|
||||
|
||||
@@ -793,6 +797,11 @@ private:
|
||||
params.toneCurve.black = 0;
|
||||
}
|
||||
|
||||
// Spot Removal
|
||||
if (params.spot.enabled && !params.spot.entries.empty ()) {
|
||||
ipf.removeSpots (baseImg, imgsrc, params.spot.entries, pp, currWB, nullptr, tr);
|
||||
}
|
||||
|
||||
// at this stage, we can flush the raw data to free up quite an important amount of memory
|
||||
// commented out because it makes the application crash when batch processing...
|
||||
// TODO: find a better place to flush rawData and rawRGB
|
||||
@@ -916,6 +925,14 @@ private:
|
||||
//ImProcFunctions ipf (¶ms, true);
|
||||
ImProcFunctions &ipf = * (ipf_p.get());
|
||||
|
||||
for (int sp = 0; sp < (int)params.locallab.spots.size(); sp++) {
|
||||
if(params.locallab.spots.at(sp).expsharp && params.dirpyrequalizer.cbdlMethod == "bef") {
|
||||
if(params.locallab.spots.at(sp).shardamping < 1) {
|
||||
params.locallab.spots.at(sp).shardamping = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (params.dirpyrequalizer.cbdlMethod == "bef" && params.dirpyrequalizer.enabled && !params.colorappearance.enabled) {
|
||||
const int W = baseImg->getWidth();
|
||||
const int H = baseImg->getHeight();
|
||||
@@ -925,21 +942,6 @@ private:
|
||||
ipf.lab2rgb(labcbdl, *baseImg, params.icm.workingProfile);
|
||||
}
|
||||
|
||||
/* //gamma TRC working
|
||||
if (params.icm.workingTRC == "Custom") { //exec TRC IN free
|
||||
const Glib::ustring profile = params.icm.workingProfile;
|
||||
|
||||
if (profile == "sRGB" || profile == "Adobe RGB" || profile == "ProPhoto" || profile == "WideGamut" || profile == "BruceRGB" || profile == "Beta RGB" || profile == "BestRGB" || profile == "Rec2020" || profile == "ACESp0" || profile == "ACESp1") {
|
||||
const int cw = baseImg->getWidth();
|
||||
const int ch = baseImg->getHeight();
|
||||
cmsHTRANSFORM dummyTransForm = nullptr;
|
||||
// put gamma TRC to 1
|
||||
ipf.workingtrc(baseImg, baseImg, cw, ch, -5, params.icm.workingProfile, 2.4, 12.92310, dummyTransForm, true, false, false);
|
||||
//adjust TRC
|
||||
ipf.workingtrc(baseImg, baseImg, cw, ch, 5, params.icm.workingProfile, params.icm.workingTRCGamma, params.icm.workingTRCSlope, dummyTransForm, false, true, false);
|
||||
}
|
||||
}
|
||||
*/
|
||||
// RGB processing
|
||||
|
||||
labView = new LabImage(fw, fh);
|
||||
@@ -959,6 +961,9 @@ private:
|
||||
LocLHCurve loclhCurve;
|
||||
LocHHCurve lochhCurve;
|
||||
LocCHCurve locchCurve;
|
||||
LocHHCurve lochhCurvejz;
|
||||
LocCHCurve locchCurvejz;
|
||||
LocLHCurve loclhCurvejz;
|
||||
LocCCmaskCurve locccmasCurve;
|
||||
LocLLmaskCurve locllmasCurve;
|
||||
LocHHmaskCurve lochhmasCurve;
|
||||
@@ -990,6 +995,9 @@ private:
|
||||
LocCCmaskCurve locccmaslogCurve;
|
||||
LocLLmaskCurve locllmaslogCurve;
|
||||
LocHHmaskCurve lochhmaslogCurve;
|
||||
LocCCmaskCurve locccmascieCurve;
|
||||
LocLLmaskCurve locllmascieCurve;
|
||||
LocHHmaskCurve lochhmascieCurve;
|
||||
|
||||
LocCCmaskCurve locccmas_Curve;
|
||||
LocLLmaskCurve locllmas_Curve;
|
||||
@@ -1000,6 +1008,7 @@ private:
|
||||
LocwavCurve loclmasCurvecolwav;
|
||||
LocwavCurve loclmasCurve_wav;
|
||||
LocwavCurve locwavCurve;
|
||||
LocwavCurve locwavCurvejz;
|
||||
LocwavCurve loclevwavCurve;
|
||||
LocwavCurve locconwavCurve;
|
||||
LocwavCurve loccompwavCurve;
|
||||
@@ -1028,6 +1037,12 @@ private:
|
||||
LUTf lmasklclocalcurve(65536, LUT_CLIP_OFF);
|
||||
LUTf lmaskloglocalcurve(65536, LUT_CLIP_OFF);
|
||||
LUTf lmasklocal_curve(65536, LUT_CLIP_OFF);
|
||||
LUTf lmaskcielocalcurve(65536, LUT_CLIP_OFF);
|
||||
LUTf cielocalcurve(65536, LUT_CLIP_OFF);
|
||||
LUTf cielocalcurve2(65536, LUT_CLIP_OFF);
|
||||
LUTf jzlocalcurve(65536, LUT_CLIP_OFF);
|
||||
LUTf czlocalcurve(65536, LUT_CLIP_OFF);
|
||||
LUTf czjzlocalcurve(65536, LUT_CLIP_OFF);
|
||||
|
||||
array2D<float> shbuffer;
|
||||
for (size_t sp = 0; sp < params.locallab.spots.size(); sp++) {
|
||||
@@ -1045,6 +1060,9 @@ private:
|
||||
const bool LHutili = loclhCurve.Set(params.locallab.spots.at(sp).LHcurve);
|
||||
const bool HHutili = lochhCurve.Set(params.locallab.spots.at(sp).HHcurve);
|
||||
const bool CHutili = locchCurve.Set(params.locallab.spots.at(sp).CHcurve);
|
||||
const bool HHutilijz = lochhCurvejz.Set(params.locallab.spots.at(sp).HHcurvejz);
|
||||
const bool CHutilijz = locchCurvejz.Set(params.locallab.spots.at(sp).CHcurvejz);
|
||||
const bool LHutilijz = loclhCurvejz.Set(params.locallab.spots.at(sp).LHcurvejz);
|
||||
const bool lcmasutili = locccmasCurve.Set(params.locallab.spots.at(sp).CCmaskcurve);
|
||||
const bool llmasutili = locllmasCurve.Set(params.locallab.spots.at(sp).LLmaskcurve);
|
||||
const bool lhmasutili = lochhmasCurve.Set(params.locallab.spots.at(sp).HHmaskcurve);
|
||||
@@ -1074,6 +1092,9 @@ private:
|
||||
const bool lcmaslogutili = locccmaslogCurve.Set(params.locallab.spots.at(sp).CCmaskcurveL);
|
||||
const bool llmaslogutili = locllmaslogCurve.Set(params.locallab.spots.at(sp).LLmaskcurveL);
|
||||
const bool lhmaslogutili = lochhmaslogCurve.Set(params.locallab.spots.at(sp).HHmaskcurveL);
|
||||
const bool lcmascieutili = locccmascieCurve.Set(params.locallab.spots.at(sp).CCmaskciecurve);
|
||||
const bool llmascieutili = locllmascieCurve.Set(params.locallab.spots.at(sp).LLmaskciecurve);
|
||||
const bool lhmascieutili = lochhmascieCurve.Set(params.locallab.spots.at(sp).HHmaskciecurve);
|
||||
|
||||
const bool lcmas_utili = locccmas_Curve.Set(params.locallab.spots.at(sp).CCmask_curve);
|
||||
const bool llmas_utili = locllmas_Curve.Set(params.locallab.spots.at(sp).LLmask_curve);
|
||||
@@ -1085,6 +1106,7 @@ private:
|
||||
const bool llmaslcutili = locllmaslcCurve.Set(params.locallab.spots.at(sp).LLmasklccurve);
|
||||
const bool lmasutili_wav = loclmasCurve_wav.Set(params.locallab.spots.at(sp).LLmask_curvewav);
|
||||
const bool locwavutili = locwavCurve.Set(params.locallab.spots.at(sp).locwavcurve);
|
||||
const bool locwavutilijz = locwavCurvejz.Set(params.locallab.spots.at(sp).locwavcurvejz);
|
||||
const bool locwavhueutili = locwavCurvehue.Set(params.locallab.spots.at(sp).locwavcurvehue);
|
||||
const bool locwavdenutili = locwavCurveden.Set(params.locallab.spots.at(sp).locwavcurveden);
|
||||
const bool loclevwavutili = loclevwavCurve.Set(params.locallab.spots.at(sp).loclevwavcurve);
|
||||
@@ -1109,6 +1131,12 @@ private:
|
||||
const bool localmasklcutili = CurveFactory::diagonalCurve2Lut(params.locallab.spots.at(sp).Lmasklccurve, lmasklclocalcurve, 1);
|
||||
const bool localmasklogutili = CurveFactory::diagonalCurve2Lut(params.locallab.spots.at(sp).LmaskcurveL, lmaskloglocalcurve, 1);
|
||||
const bool localmask_utili = CurveFactory::diagonalCurve2Lut(params.locallab.spots.at(sp).Lmask_curve, lmasklocal_curve, 1);
|
||||
const bool localmaskcieutili = CurveFactory::diagonalCurve2Lut(params.locallab.spots.at(sp).Lmaskciecurve, lmaskcielocalcurve, 1);
|
||||
const bool localcieutili = CurveFactory::diagonalCurve2Lut(params.locallab.spots.at(sp).ciecurve, cielocalcurve, 1);
|
||||
const bool localcieutili2 = CurveFactory::diagonalCurve2Lut(params.locallab.spots.at(sp).ciecurve2, cielocalcurve2, 1);
|
||||
const bool localjzutili = CurveFactory::diagonalCurve2Lut(params.locallab.spots.at(sp).jzcurve, jzlocalcurve, 1);
|
||||
const bool localczutili = CurveFactory::diagonalCurve2Lut(params.locallab.spots.at(sp).czcurve, czlocalcurve, 1);
|
||||
const bool localczjzutili = CurveFactory::diagonalCurve2Lut(params.locallab.spots.at(sp).czjzcurve, czjzlocalcurve, 1);
|
||||
|
||||
//provisory
|
||||
double ecomp = params.locallab.spots.at(sp).expcomp;
|
||||
@@ -1130,6 +1158,7 @@ private:
|
||||
float stdtme;
|
||||
float meanretie;
|
||||
float stdretie;
|
||||
float fab = 1.f;
|
||||
|
||||
if (params.locallab.spots.at(sp).spotMethod == "exc") {
|
||||
ipf.calc_ref(sp, reservView.get(), reservView.get(), 0, 0, fw, fh, 1, huerefblu, chromarefblu, lumarefblu, huere, chromare, lumare, sobelre, avge, locwavCurveden, locwavdenutili);
|
||||
@@ -1149,11 +1178,12 @@ private:
|
||||
float Tmax;
|
||||
|
||||
// No Locallab mask is shown in exported picture
|
||||
ipf.Lab_Local(2, sp, shbuffer, labView, labView, reservView.get(), savenormtmView.get(), savenormretiView.get(), lastorigView.get(), 0, 0, fw, fh, 1, locRETgainCurve, locRETtransCurve,
|
||||
ipf.Lab_Local(2, sp, shbuffer, labView, labView, reservView.get(), savenormtmView.get(), savenormretiView.get(), lastorigView.get(), fw, fh, 0, 0, fw, fh, 1, locRETgainCurve, locRETtransCurve,
|
||||
lllocalcurve, locallutili,
|
||||
cllocalcurve, localclutili,
|
||||
lclocalcurve, locallcutili,
|
||||
loclhCurve, lochhCurve, locchCurve,
|
||||
lochhCurvejz, locchCurvejz,loclhCurvejz,
|
||||
lmasklocalcurve, localmaskutili,
|
||||
lmaskexplocalcurve, localmaskexputili,
|
||||
lmaskSHlocalcurve, localmaskSHutili,
|
||||
@@ -1165,6 +1195,12 @@ private:
|
||||
lmasklclocalcurve, localmasklcutili,
|
||||
lmaskloglocalcurve, localmasklogutili,
|
||||
lmasklocal_curve, localmask_utili,
|
||||
lmaskcielocalcurve, localmaskcieutili,
|
||||
cielocalcurve, localcieutili,
|
||||
cielocalcurve2, localcieutili2,
|
||||
jzlocalcurve, localjzutili,
|
||||
czlocalcurve, localczutili,
|
||||
czjzlocalcurve, localczjzutili,
|
||||
|
||||
locccmasCurve, lcmasutili, locllmasCurve, llmasutili, lochhmasCurve, lhmasutili, lochhhmasCurve, lhhmasutili, locccmasexpCurve, lcmasexputili, locllmasexpCurve, llmasexputili, lochhmasexpCurve, lhmasexputili,
|
||||
locccmasSHCurve, lcmasSHutili, locllmasSHCurve, llmasSHutili, lochhmasSHCurve, lhmasSHutili,
|
||||
@@ -1177,10 +1213,12 @@ private:
|
||||
locccmaslogCurve, lcmaslogutili, locllmaslogCurve, llmaslogutili, lochhmaslogCurve, lhmaslogutili,
|
||||
|
||||
locccmas_Curve, lcmas_utili, locllmas_Curve, llmas_utili, lochhmas_Curve, lhmas_utili,
|
||||
locccmascieCurve, lcmascieutili, locllmascieCurve, llmascieutili, lochhmascieCurve, lhmascieutili,
|
||||
lochhhmas_Curve, lhhmas_utili,
|
||||
loclmasCurveblwav,lmasutiliblwav,
|
||||
loclmasCurvecolwav,lmasutilicolwav,
|
||||
locwavCurve, locwavutili,
|
||||
locwavCurvejz, locwavutilijz,
|
||||
loclevwavCurve, loclevwavutili,
|
||||
locconwavCurve, locconwavutili,
|
||||
loccompwavCurve, loccompwavutili,
|
||||
@@ -1189,10 +1227,10 @@ private:
|
||||
locwavCurveden, locwavdenutili,
|
||||
locedgwavCurve, locedgwavutili,
|
||||
loclmasCurve_wav,lmasutili_wav,
|
||||
LHutili, HHutili, CHutili, cclocalcurve, localcutili, rgblocalcurve, localrgbutili, localexutili, exlocalcurve, hltonecurveloc, shtonecurveloc, tonecurveloc, lightCurveloc,
|
||||
huerefblu, chromarefblu, lumarefblu, huere, chromare, lumare, sobelre, lastsav, false, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
LHutili, HHutili, CHutili, HHutilijz, CHutilijz, LHutilijz, cclocalcurve, localcutili, rgblocalcurve, localrgbutili, localexutili, exlocalcurve, hltonecurveloc, shtonecurveloc, tonecurveloc, lightCurveloc,
|
||||
huerefblu, chromarefblu, lumarefblu, huere, chromare, lumare, sobelre, lastsav, false, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
minCD, maxCD, mini, maxi, Tmean, Tsigma, Tmin, Tmax,
|
||||
meantme, stdtme, meanretie, stdretie
|
||||
meantme, stdtme, meanretie, stdretie, fab
|
||||
);
|
||||
|
||||
if (sp + 1u < params.locallab.spots.size()) {
|
||||
@@ -1372,6 +1410,7 @@ private:
|
||||
|
||||
ipf.chromiLuminanceCurve(nullptr, 1, labView, labView, curve1, curve2, satcurve, lhskcurve, clcurve, lumacurve, utili, autili, butili, ccutili, cclutili, clcutili, dummy, dummy);
|
||||
|
||||
|
||||
if ((params.colorappearance.enabled && !params.colorappearance.tonecie) || (!params.colorappearance.enabled)) {
|
||||
ipf.EPDToneMap (labView, 0, 1);
|
||||
}
|
||||
@@ -1571,6 +1610,52 @@ private:
|
||||
|
||||
ipf.softLight(labView, params.softlight);
|
||||
|
||||
|
||||
if (params.icm.workingTRC != ColorManagementParams::WorkingTrc::NONE) {
|
||||
const int GW = labView->W;
|
||||
const int GH = labView->H;
|
||||
std::unique_ptr<LabImage> provis;
|
||||
const float pres = 0.01f * params.icm.preser;
|
||||
if (pres > 0.f && params.icm.wprim != ColorManagementParams::Primaries::DEFAULT) {
|
||||
provis.reset(new LabImage(GW, GH));
|
||||
provis->CopyFrom(labView);
|
||||
}
|
||||
|
||||
const std::unique_ptr<Imagefloat> tmpImage1(new Imagefloat(GW, GH));
|
||||
|
||||
ipf.lab2rgb(*labView, *tmpImage1, params.icm.workingProfile);
|
||||
|
||||
const float gamtone = params.icm.workingTRCGamma;
|
||||
const float slotone = params.icm.workingTRCSlope;
|
||||
|
||||
int illum = toUnderlying(params.icm.will);
|
||||
const int prim = toUnderlying(params.icm.wprim);
|
||||
|
||||
Glib::ustring prof = params.icm.workingProfile;
|
||||
|
||||
cmsHTRANSFORM dummy = nullptr;
|
||||
int ill = 0;
|
||||
ipf.workingtrc(tmpImage1.get(), tmpImage1.get(), GW, GH, -5, prof, 2.4, 12.92310, ill, 0, dummy, true, false, false);
|
||||
ipf.workingtrc(tmpImage1.get(), tmpImage1.get(), GW, GH, 5, prof, gamtone, slotone, illum, prim, dummy, false, true, true);
|
||||
|
||||
ipf.rgb2lab(*tmpImage1, *labView, params.icm.workingProfile);
|
||||
// labView and provis
|
||||
if(provis) {
|
||||
ipf.preserv(labView, provis.get(), GW, GH);
|
||||
}
|
||||
if(params.icm.fbw) {
|
||||
#ifdef _OPENMP
|
||||
#pragma omp parallel for
|
||||
#endif
|
||||
for (int x = 0; x < GH; x++)
|
||||
for (int y = 0; y < GW; y++) {
|
||||
labView->a[x][y] = 0.f;
|
||||
labView->b[x][y] = 0.f;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Colorappearance and tone-mapping associated
|
||||
|
||||
int f_w = 1, f_h = 1;
|
||||
@@ -1606,8 +1691,9 @@ private:
|
||||
}//if no exif data or wrong
|
||||
else {
|
||||
double E_V = fcomp + log2 ((fnum * fnum) / fspeed / (fiso / 100.f));
|
||||
E_V += params.toneCurve.expcomp;// exposure compensation in tonecurve ==> direct EV
|
||||
E_V += log2(params.raw.expos); // exposure raw white point ; log2 ==> linear to EV
|
||||
double kexp = 0.;
|
||||
E_V += kexp * params.toneCurve.expcomp;// exposure compensation in tonecurve ==> direct EV
|
||||
E_V += 0.5 * log2(params.raw.expos); // exposure raw white point ; log2 ==> linear to EV
|
||||
adap = std::pow(2.0, E_V - 3.0); //cd / m2
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user