further cleanups
This commit is contained in:
parent
6caf33a589
commit
6cb29be31c
@ -29,7 +29,6 @@
|
||||
#include "improcfun.h"
|
||||
#include "LUT.h"
|
||||
#include "opthelper.h"
|
||||
#include "boxblur.h"
|
||||
#include "rt_math.h"
|
||||
#include "settings.h"
|
||||
|
||||
@ -247,46 +246,20 @@ void fillLut(LUTf &irangefn, int level, double dirpyrThreshold, float mult, floa
|
||||
}
|
||||
}
|
||||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
void idirpyr_eq_channel_loc(float ** data_coarse, float ** data_fine, float ** buffer, int width, int height, int level, float mult, const float blurcb, const double dirpyrThreshold, float ** hue, float ** chrom, const double skinprot, const bool gamutlab, float b_l, float t_l, float t_r, float b_r, int choice, int scaleprev, bool multiThread)
|
||||
void idirpyr_eq_channel_loc(float ** data_coarse, float ** data_fine, float ** buffer, int width, int height, int level, float mult, const double dirpyrThreshold, float ** hue, float ** chrom, const double skinprot, const bool gamutlab, float b_l, float t_l, float t_r, float b_r, int choice, int scaleprev, bool multiThread)
|
||||
{
|
||||
LUTf irangefn(0x20000);
|
||||
fillLut(irangefn, level, dirpyrThreshold, mult, skinprot);
|
||||
|
||||
#ifdef _OPENMP
|
||||
#pragma omp parallel for schedule(dynamic,16)
|
||||
#pragma omp parallel for schedule(dynamic,16)
|
||||
#endif
|
||||
for (int i = 0; i < height; i++) {
|
||||
for (int j = 0; j < width; j++) {
|
||||
|
||||
float hipass = (data_fine[i][j] - data_coarse[i][j]);
|
||||
buffer[i][j] += irangefn[hipass + 0x10000] * hipass;
|
||||
|
||||
}
|
||||
for (int i = 0; i < height; i++) {
|
||||
for (int j = 0; j < width; j++) {
|
||||
const float hipass = data_fine[i][j] - data_coarse[i][j];
|
||||
buffer[i][j] += irangefn[hipass + 0x10000] * hipass;
|
||||
}
|
||||
|
||||
if(blurcb > 0.f && choice == 0 && level != 5) {
|
||||
float multbis;
|
||||
if (level == 4 && mult > 1.f) {
|
||||
multbis = 1.f + 0.65f * (mult - 1.f);
|
||||
} else if (level == 5 && mult > 1.f) {
|
||||
multbis = 1.f + 0.45f * (mult - 1.f);
|
||||
} else {
|
||||
multbis = mult; //multbis to reduce artifacts for high values mult
|
||||
}
|
||||
AlignedBuffer<float> blurbufcbdl(width * height);
|
||||
float rad = 0.05f * blurcb * fabs((level + 1) * (multbis - 1.f)) / scaleprev;
|
||||
// printf("rad=%f level=%i\n", rad, level);
|
||||
|
||||
#ifdef _OPENMP
|
||||
#pragma omp parallel if (multiThread)
|
||||
#endif
|
||||
// rtengine::boxblur<float, float>(buffer, buffer, blurbufcbdl.data, rad, rad, width, height);
|
||||
rtengine::boxblur(buffer, buffer, rad, width, height, false);
|
||||
blurbufcbdl.resize(0);
|
||||
}
|
||||
|
||||
irangefn.clear();
|
||||
}
|
||||
}
|
||||
|
||||
void idirpyr_eq_channel(const float * const * data_coarse, const float * const * data_fine, float ** buffer, int width, int height, int level, float mult, const double dirpyrThreshold, const float * const * hue, const float * const * chrom, const double skinprot, float b_l, float t_l, float t_r)
|
||||
@ -552,7 +525,7 @@ void ImProcFunctions::dirpyr_equalizercam(const CieImage *ncie, float ** src, fl
|
||||
}
|
||||
}
|
||||
|
||||
void ImProcFunctions::cbdl_local_temp(float ** src, float ** loctemp, int srcwidth, int srcheight, const float * mult, float kchro, const double dirpyrThreshold, const float mergeL, const float contres, const float blurcb, const double skinprot, const bool gamutlab, float b_l, float t_l, float t_r, float b_r, int choice, int scaleprev, bool multiThread)
|
||||
void ImProcFunctions::cbdl_local_temp(float ** src, float ** loctemp, int srcwidth, int srcheight, const float * mult, float kchro, const double dirpyrThreshold, const float mergeL, const float contres, const double skinprot, const bool gamutlab, float b_l, float t_l, float t_r, float b_r, int choice, int scaleprev, bool multiThread)
|
||||
{
|
||||
constexpr int maxlevelloc = 6;
|
||||
constexpr int scalesloc[maxlevelloc] = {1, 2, 4, 8, 16, 32};
|
||||
@ -663,13 +636,12 @@ void ImProcFunctions::cbdl_local_temp(float ** src, float ** loctemp, int srcwid
|
||||
|
||||
|
||||
for (int level = lastlevel - 1; level > 0; level--) {
|
||||
idirpyr_eq_channel_loc(dirpyrlo[level], dirpyrlo[level - 1], residbuff, srcwidth, srcheight, level, multi[level], blurcb, dirpyrThreshold, nullptr, nullptr, skinprot, gamutlab, b_l, t_l, t_r, b_r, choice, scaleprev, multiThread);
|
||||
idirpyr_eq_channel_loc(dirpyrlo[level], dirpyrlo[level - 1], residbuff, srcwidth, srcheight, level, multi[level], dirpyrThreshold, nullptr, nullptr, skinprot, gamutlab, b_l, t_l, t_r, b_r, choice, scaleprev, multiThread);
|
||||
}
|
||||
|
||||
scale = scalesloc[0];
|
||||
|
||||
idirpyr_eq_channel_loc(dirpyrlo[0], src, residbuff, srcwidth, srcheight, 0, multi[0], blurcb, dirpyrThreshold, nullptr, nullptr, skinprot, gamutlab, b_l, t_l, t_r, b_r, choice, scaleprev, multiThread);
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
idirpyr_eq_channel_loc(dirpyrlo[0], src, residbuff, srcwidth, srcheight, 0, multi[0], dirpyrThreshold, nullptr, nullptr, skinprot, gamutlab, b_l, t_l, t_r, b_r, choice, scaleprev, multiThread);
|
||||
|
||||
array2D<float> loct(srcwidth, srcheight);
|
||||
#ifdef _OPENMP
|
||||
|
@ -281,7 +281,6 @@ void RawImageSource::fast_demosaic()
|
||||
int right = min(left + TS, W - bord + 2);
|
||||
|
||||
#ifdef __SSE2__
|
||||
int j, cc;
|
||||
__m128 wtuv, wtdv, wtlv, wtrv;
|
||||
__m128 greenv, tempv, absv, abs2v;
|
||||
__m128 c16v = _mm_set1_ps( 16.0f );
|
||||
@ -302,7 +301,7 @@ void RawImageSource::fast_demosaic()
|
||||
float wtu, wtd, wtl, wtr;
|
||||
#ifdef __SSE2__
|
||||
selmask = (vmask)_mm_andnot_ps( (__m128)selmask, (__m128)andmask);
|
||||
|
||||
int j, cc;
|
||||
for (j = left, cc = 0; j < right - 3; j += 4, cc += 4) {
|
||||
tempv = LVFU(rawData[i][j]);
|
||||
absv = vabsf(LVFU(rawData[i - 1][j]) - LVFU(rawData[i + 1][j]));
|
||||
@ -421,16 +420,12 @@ void RawImageSource::fast_demosaic()
|
||||
temp1v = LVFU(redtile[rr * TS + cc]);
|
||||
temp2v = greenv - zd25v * (greensumv - LVFU(redtile[(rr - 1) * TS + cc]) - LVFU(redtile[(rr + 1) * TS + cc]) - LVFU(redtile[rr * TS + cc - 1]) - LVFU(redtile[rr * TS + cc + 1]));
|
||||
|
||||
// temp2v = greenv - zd25v*((LVFU(greentile[(rr-1)*TS+cc])-LVFU(redtile[(rr-1)*TS+cc]))+(LVFU(greentile[(rr+1)*TS+cc])-LVFU(redtile[(rr+1)*TS+cc]))+
|
||||
// (LVFU(greentile[rr*TS+cc-1])-LVFU(redtile[rr*TS+cc-1]))+(LVFU(greentile[rr*TS+cc+1])-LVFU(redtile[rr*TS+cc+1])));
|
||||
_mm_storeu_ps( &redtile[rr * TS + cc], vself(selmask, temp1v, temp2v));
|
||||
|
||||
temp1v = LVFU(bluetile[rr * TS + cc]);
|
||||
|
||||
temp2v = greenv - zd25v * (greensumv - LVFU(bluetile[(rr - 1) * TS + cc]) - LVFU(bluetile[(rr + 1) * TS + cc]) - LVFU(bluetile[rr * TS + cc - 1]) - LVFU(bluetile[rr * TS + cc + 1]));
|
||||
|
||||
// temp2v = greenv - zd25v*((LVFU(greentile[(rr-1)*TS+cc])-LVFU(bluetile[(rr-1)*TS+cc]))+(LVFU(greentile[(rr+1)*TS+cc])-LVFU(bluetile[(rr+1)*TS+cc]))+
|
||||
// (LVFU(greentile[rr*TS+cc-1])-LVFU(bluetile[rr*TS+cc-1]))+(LVFU(greentile[rr*TS+cc+1])-LVFU(bluetile[rr*TS+cc+1])));
|
||||
_mm_storeu_ps( &bluetile[rr * TS + cc], vself(selmask, temp1v, temp2v));
|
||||
}
|
||||
|
||||
@ -450,7 +445,7 @@ void RawImageSource::fast_demosaic()
|
||||
|
||||
for (int i = top + 2, rr = 2; i < bottom - 2; i++, rr++) {
|
||||
#ifdef __SSE2__
|
||||
|
||||
int j, cc;
|
||||
for (j = left + 2, cc = 2; j < right - 5; j += 4, cc += 4) {
|
||||
_mm_storeu_ps(&red[i][j], vmaxf(LVFU(redtile[rr * TS + cc]), ZEROV));
|
||||
_mm_storeu_ps(&green[i][j], vmaxf(LVFU(greentile[rr * TS + cc]), ZEROV));
|
||||
|
@ -254,9 +254,9 @@ public:
|
||||
void fftw_tile_blur(int GW, int GH, int tilssize , int max_numblox_W, int min_numblox_W, float **tmp1, int numThreads, double radius);
|
||||
|
||||
void maskforretinex(int sp, int before, float ** luminance, float ** out, int W_L, int H_L, int skip,
|
||||
const LocCCmaskCurve & locccmasretiCurve, bool &lcmasretiutili, const LocLLmaskCurve & locllmasretiCurve, bool &llmasretiutili, const LocHHmaskCurve & lochhmasretiCurve, bool & lhmasretiutili,
|
||||
const LocCCmaskCurve & locccmasretiCurve, bool lcmasretiutili, const LocLLmaskCurve & locllmasretiCurve, bool llmasretiutili, const LocHHmaskCurve & lochhmasretiCurve, bool lhmasretiutili,
|
||||
int llretiMask, bool retiMasktmap, bool retiMask, float rad, float lap, bool pde, float gamm, float slop, float chro, float blend,
|
||||
LUTf & lmaskretilocalcurve, bool & localmaskretiutili,
|
||||
const LUTf & lmaskretilocalcurve, bool localmaskretiutili,
|
||||
LabImage * bufreti, LabImage * bufmask, LabImage * buforig, LabImage * buforigmas, bool multiThread,
|
||||
bool delt, const float hueref, const float chromaref, const float lumaref,
|
||||
float maxdE, float mindE, float maxdElim, float mindElim, float iterat, float limscope, int scope, float balance, float balanceh, float lumask);
|
||||
@ -269,8 +269,8 @@ public:
|
||||
void MSRLocal(int call, int sp, bool fftw, int lum, float** reducDE, LabImage * bufreti, LabImage * bufmask, LabImage * buforig, LabImage * buforigmas, float** luminance, const float* const *originalLuminance,
|
||||
const int width, const int height, int bfwr, int bfhr, const procparams::LocallabParams &loc, const int skip, const LocretigainCurve &locRETgainCcurve, const LocretitransCurve &locRETtransCcurve,
|
||||
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,
|
||||
const LocCCmaskCurve & locccmasretiCurve, bool &lcmasretiutili, const LocLLmaskCurve & locllmasretiCurve, bool &llmasretiutili, const LocHHmaskCurve & lochhmasretiCurve, bool & lhmasretiutili, int llretiMask,
|
||||
LUTf & lmaskretilocalcurve, bool & localmaskretiutili,
|
||||
const LocCCmaskCurve & locccmasretiCurve, bool lcmasretiutili, const LocLLmaskCurve & locllmasretiCurve, bool llmasretiutili, const LocHHmaskCurve & lochhmasretiCurve, bool lhmasretiutili, int llretiMask,
|
||||
const LUTf & lmaskretilocalcurve, bool localmaskretiutili,
|
||||
LabImage * transformed, bool retiMasktmap, bool retiMask,
|
||||
bool delt, const float hueref, const float chromaref, const float lumaref,
|
||||
float maxdE, float mindE, float maxdElim, float mindElim, float iterat, float limscope, int scope, float balance, float balanceh, float lumask);
|
||||
@ -424,7 +424,7 @@ public:
|
||||
float MadRgb(const float * DataList, int datalen);
|
||||
|
||||
// pyramid wavelet
|
||||
void cbdl_local_temp(float ** src, float ** loctemp, int srcwidth, int srcheight, const float * mult, float kchro, const double dirpyrThreshold, const float mergeL, const float contres, const float blurcb, const double skinprot, const bool gamutlab, float b_l, float t_l, float t_r, float b_r, int choice, int scale, bool multiThread);
|
||||
void cbdl_local_temp(float ** src, float ** loctemp, int srcwidth, int srcheight, const float * mult, float kchro, const double dirpyrThreshold, const float mergeL, const float contres, const double skinprot, const bool gamutlab, float b_l, float t_l, float t_r, float b_r, int choice, int scale, bool multiThread);
|
||||
void dirpyr_equalizer(const float * const * src, float ** dst, int srcwidth, int srcheight, const float * const * l_a, const float * const * l_b, const double * mult, double dirpyrThreshold, double skinprot, float b_l, float t_l, float t_r, int scale); //Emil's directional pyramid wavelet
|
||||
void dirpyr_equalizercam(const CieImage* ncie, float ** src, float ** dst, int srcwidth, int srcheight, const float * const * h_p, const float * const * C_p, const double * mult, const double dirpyrThreshold, const double skinprot, float b_l, float t_l, float t_r, int scale); //Emil's directional pyramid wavelet
|
||||
void defringe(LabImage* lab);
|
||||
|
@ -392,7 +392,6 @@ struct local_params {
|
||||
int chro, cont, sens, sensh, senscb, sensbn, senstm, sensex, sensexclu, sensden, senslc, senssf, senshs, senscolor;
|
||||
float clarityml;
|
||||
float contresid;
|
||||
float blurcbdl;
|
||||
bool deltaem;
|
||||
float struco;
|
||||
float strengrid;
|
||||
@ -988,7 +987,6 @@ static void calcLocalParams(int sp, int oW, int oH, const LocallabParams& locall
|
||||
int local_sensicb = locallab.spots.at(sp).sensicb;
|
||||
float local_clarityml = (float) locallab.spots.at(sp).clarityml;
|
||||
float local_contresid = (float) locallab.spots.at(sp).contresid;
|
||||
int local_blurcbdl = 0; //(float) locallab.spots.at(sp).blurcbdl;
|
||||
int local_contrast = locallab.spots.at(sp).contrast;
|
||||
float local_lightness = (float) locallab.spots.at(sp).lightness;
|
||||
float labgridALowloc = locallab.spots.at(sp).labgridALow;
|
||||
@ -1238,7 +1236,6 @@ static void calcLocalParams(int sp, int oW, int oH, const LocallabParams& locall
|
||||
lp.senscb = local_sensicb;
|
||||
lp.clarityml = local_clarityml;
|
||||
lp.contresid = local_contresid;
|
||||
lp.blurcbdl = local_blurcbdl;
|
||||
lp.cont = local_contrast;
|
||||
lp.ligh = local_lightness;
|
||||
lp.lowA = labgridALowloc;
|
||||
@ -10780,7 +10777,7 @@ void ImProcFunctions::Lab_Local(
|
||||
lp.mulloc[5] = 1.001f;
|
||||
}
|
||||
|
||||
ImProcFunctions::cbdl_local_temp(bufsh, loctemp->L, bfw, bfh, lp.mulloc, 1.f, lp.threshol, lp.clarityml, lp.contresid, lp.blurcbdl, skinprot, false, b_l, t_l, t_r, b_r, choice, sk, multiThread);
|
||||
ImProcFunctions::cbdl_local_temp(bufsh, loctemp->L, bfw, bfh, lp.mulloc, 1.f, lp.threshol, lp.clarityml, lp.contresid, skinprot, false, b_l, t_l, t_r, b_r, choice, sk, multiThread);
|
||||
|
||||
if (lp.softradiuscb > 0.f) {
|
||||
softproc(origcbdl.get(), loctemp.get(), lp.softradiuscb, bfh, bfw, 0.001, 0.00001, 0.5f, sk, multiThread, 1);
|
||||
@ -10819,7 +10816,7 @@ void ImProcFunctions::Lab_Local(
|
||||
}
|
||||
|
||||
choice = 1;
|
||||
ImProcFunctions::cbdl_local_temp(bufsh, loctemp->L, bfw, bfh, multc, rtengine::max(lp.chromacb, 1.f), lp.threshol, clarich, 0.f, lp.blurcbdl, skinprot, false, b_l, t_l, t_r, b_r, choice, sk, multiThread);
|
||||
ImProcFunctions::cbdl_local_temp(bufsh, loctemp->L, bfw, bfh, multc, rtengine::max(lp.chromacb, 1.f), lp.threshol, clarich, 0.f, skinprot, false, b_l, t_l, t_r, b_r, choice, sk, multiThread);
|
||||
|
||||
|
||||
float minC = loctemp->L[0][0] - std::sqrt(SQR(loctemp->a[0][0]) + SQR(loctemp->b[0][0]));
|
||||
|
@ -779,9 +779,9 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e
|
||||
|
||||
|
||||
void ImProcFunctions::maskforretinex(int sp, int before, float ** luminance, float ** out, int W_L, int H_L, int skip,
|
||||
const LocCCmaskCurve & locccmasretiCurve, bool &lcmasretiutili, const LocLLmaskCurve & locllmasretiCurve, bool &llmasretiutili, const LocHHmaskCurve & lochhmasretiCurve, bool & lhmasretiutili,
|
||||
const LocCCmaskCurve & locccmasretiCurve, bool lcmasretiutili, const LocLLmaskCurve & locllmasretiCurve, bool llmasretiutili, const LocHHmaskCurve & lochhmasretiCurve, bool lhmasretiutili,
|
||||
int llretiMask, bool retiMasktmap, bool retiMask, float rad, float lap, bool pde, float gamm, float slop, float chro, float blend,
|
||||
LUTf & lmaskretilocalcurve, bool & localmaskretiutili,
|
||||
const LUTf & lmaskretilocalcurve, bool localmaskretiutili,
|
||||
LabImage * bufreti, LabImage * bufmask, LabImage * buforig, LabImage * buforigmas, bool multiThread,
|
||||
bool delt, const float hueref, const float chromaref, const float lumaref,
|
||||
float maxdE, float mindE, float maxdElim, float mindElim, float iterat, float limscope, int scope, float balance, float balanceh, float lumask)
|
||||
@ -1127,534 +1127,519 @@ void ImProcFunctions::maskforretinex(int sp, int before, float ** luminance, flo
|
||||
void ImProcFunctions::MSRLocal(int call, int sp, bool fftw, int lum, float** reducDE, LabImage * bufreti, LabImage * bufmask, LabImage * buforig, LabImage * buforigmas, float** luminance, const float* const *originalLuminance,
|
||||
const int width, const int height, int bfwr, int bfhr, const procparams::LocallabParams &loc, const int skip, const LocretigainCurve &locRETgainCcurve, const LocretitransCurve &locRETtransCcurve,
|
||||
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,
|
||||
const LocCCmaskCurve & locccmasretiCurve, bool &lcmasretiutili, const LocLLmaskCurve & locllmasretiCurve, bool &llmasretiutili, const LocHHmaskCurve & lochhmasretiCurve, bool & lhmasretiutili, int llretiMask,
|
||||
LUTf & lmaskretilocalcurve, bool & localmaskretiutili,
|
||||
const LocCCmaskCurve & locccmasretiCurve, bool lcmasretiutili, const LocLLmaskCurve & locllmasretiCurve, bool llmasretiutili, const LocHHmaskCurve & lochhmasretiCurve, bool lhmasretiutili, int llretiMask,
|
||||
const LUTf & lmaskretilocalcurve, bool localmaskretiutili,
|
||||
LabImage * transformed, bool retiMasktmap, bool retiMask,
|
||||
bool delt, const float hueref, const float chromaref, const float lumaref,
|
||||
float maxdE, float mindE, float maxdElim, float mindElim, float iterat, float limscope, int scope, float balance, float balanceh, float lumask)
|
||||
|
||||
{
|
||||
BENCHFUN
|
||||
bool py = true;
|
||||
|
||||
if (py) {//enabled
|
||||
float mean, stddv, maxtr, mintr;
|
||||
mean = 0.f;
|
||||
stddv = 0.f;
|
||||
maxtr = 0.f;
|
||||
mintr = 0.f;
|
||||
float delta;
|
||||
constexpr float eps = 2.f;
|
||||
bool useHslLin = false;
|
||||
const float offse = loc.spots.at(sp).offs;
|
||||
const float chrT = (float)(loc.spots.at(sp).chrrt) / 100.f;
|
||||
const int scal = (loc.spots.at(sp).scalereti);
|
||||
float vart = loc.spots.at(sp).vart / 100.f;//variance
|
||||
const float strength = loc.spots.at(sp).str / 100.f; // Blend with original L channel data
|
||||
const float dar = loc.spots.at(sp).darkness;
|
||||
const float lig = loc.spots.at(sp).lightnessreti;
|
||||
float value = pow(strength, 0.4f);
|
||||
float value_1 = pow(strength, 0.3f);
|
||||
bool logli = loc.spots.at(sp).loglin;
|
||||
float limD = loc.spots.at(sp).limd;//10.f
|
||||
limD = pow(limD, 1.7f); //about 2500 enough
|
||||
float ilimD = 1.f / limD;
|
||||
float threslum = loc.spots.at(sp).limd;
|
||||
const float elogt = 2.71828f;
|
||||
float mean, stddv, maxtr, mintr;
|
||||
mean = 0.f;
|
||||
stddv = 0.f;
|
||||
maxtr = 0.f;
|
||||
mintr = 0.f;
|
||||
constexpr float eps = 2.f;
|
||||
bool useHslLin = false;
|
||||
const float offse = loc.spots.at(sp).offs;
|
||||
const float chrT = (float)(loc.spots.at(sp).chrrt) / 100.f;
|
||||
const int scal = (loc.spots.at(sp).scalereti);
|
||||
float vart = loc.spots.at(sp).vart / 100.f;//variance
|
||||
const float strength = loc.spots.at(sp).str / 100.f; // Blend with original L channel data
|
||||
const float dar = loc.spots.at(sp).darkness;
|
||||
const float lig = loc.spots.at(sp).lightnessreti;
|
||||
float value = pow(strength, 0.4f);
|
||||
float value_1 = pow(strength, 0.3f);
|
||||
bool logli = loc.spots.at(sp).loglin;
|
||||
float limD = loc.spots.at(sp).limd;//10.f
|
||||
limD = pow(limD, 1.7f); //about 2500 enough
|
||||
float ilimD = 1.f / limD;
|
||||
float threslum = loc.spots.at(sp).limd;
|
||||
const float elogt = 2.71828f;
|
||||
|
||||
if (!logli) {
|
||||
useHslLin = true;
|
||||
if (!logli) {
|
||||
useHslLin = true;
|
||||
}
|
||||
|
||||
//empirical skip evaluation : very difficult because quasi all parameters interfere
|
||||
//to test on several images
|
||||
int nei = (int)(krad * loc.spots.at(sp).neigh);
|
||||
// printf("neigh=%i\n", nei);
|
||||
//several test to find good values ???!!!
|
||||
//very difficult to do because 4 factor are correlate with skip and cannot been solved easily
|
||||
// size of spots
|
||||
// radius - neigh
|
||||
// scal
|
||||
// variance vart
|
||||
//not too bad proposition
|
||||
float divsca = 1.f;
|
||||
|
||||
if (scal >= 3) {
|
||||
divsca = sqrt(scal / 3.f);
|
||||
}
|
||||
|
||||
if (skip >= 4) {
|
||||
//nei = (int)(0.1f * nei + 2.f); //not too bad
|
||||
nei = (int)(nei / (1.5f * skip)) / divsca;
|
||||
vart *= sqrt(skip);
|
||||
} else if (skip > 1) {
|
||||
//nei = (int)(0.3f * nei + 2.f);
|
||||
nei = (int)(nei / skip) / divsca;
|
||||
vart *= sqrt(skip);
|
||||
}
|
||||
|
||||
int moderetinex = 0;
|
||||
|
||||
if (loc.spots.at(sp).retinexMethod == "uni") {
|
||||
moderetinex = 0;
|
||||
} else if (loc.spots.at(sp).retinexMethod == "low") {
|
||||
moderetinex = 1;
|
||||
} else if (loc.spots.at(sp).retinexMethod == "high") {
|
||||
moderetinex = 2;
|
||||
}
|
||||
|
||||
const float high = 0.f; // Dummy to pass to retinex_scales(...)
|
||||
|
||||
constexpr auto maxRetinexScales = 10;
|
||||
float RetinexScales[maxRetinexScales];
|
||||
|
||||
retinex_scales(RetinexScales, scal, moderetinex, nei, high);
|
||||
|
||||
|
||||
const int H_L = height;
|
||||
const int W_L = width;
|
||||
std::unique_ptr<JaggedArray<float>> srcBuffer(new JaggedArray<float>(W_L, H_L));
|
||||
float** src = *(srcBuffer.get());
|
||||
|
||||
|
||||
#ifdef _OPENMP
|
||||
#pragma omp parallel for
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < H_L; i++)
|
||||
for (int j = 0; j < W_L; j++) {
|
||||
src[i][j] = luminance[i][j] + eps;
|
||||
luminance[i][j] = 0.f;
|
||||
}
|
||||
|
||||
//empirical skip evaluation : very difficult because quasi all parameters interfere
|
||||
//to test on several images
|
||||
int nei = (int)(krad * loc.spots.at(sp).neigh);
|
||||
// printf("neigh=%i\n", nei);
|
||||
//several test to find good values ???!!!
|
||||
//very difficult to do because 4 factor are correlate with skip and cannot been solved easily
|
||||
// size of spots
|
||||
// radius - neigh
|
||||
// scal
|
||||
// variance vart
|
||||
//not too bad proposition
|
||||
float divsca = 1.f;
|
||||
JaggedArray<float> out(W_L, H_L);
|
||||
|
||||
if (scal >= 3) {
|
||||
divsca = sqrt(scal / 3.f);
|
||||
float clipt = loc.spots.at(sp).cliptm;
|
||||
|
||||
const float logBetaGain = xlogf(16384.f);
|
||||
float pond = logBetaGain / (float) scal;
|
||||
|
||||
if (!useHslLin) {
|
||||
pond /= log(elogt);
|
||||
}
|
||||
|
||||
float kr;//on FFTW
|
||||
float kg = 1.f;//on Gaussianblur
|
||||
|
||||
for (int scale = scal - 1; scale >= 0; --scale) {
|
||||
// printf("retscale=%f scale=%i \n", mulradiusfftw * RetinexScales[scale], scale);
|
||||
//emprical adjustment between FFTW radius and Gaussainblur
|
||||
//under 50 ==> 10.f
|
||||
// 400 ==> 1.f
|
||||
float sigm = 1.f;
|
||||
|
||||
if (settings->fftwsigma == false) { //empirical formula
|
||||
sigm = RetinexScales[scale];
|
||||
float ak = -9.f / 350.f;
|
||||
float bk = 10.f - 50.f * ak;
|
||||
kr = ak * sigm + bk;
|
||||
|
||||
if (sigm < 50.f) {
|
||||
kr = 10.f;
|
||||
}
|
||||
|
||||
//above 400 at 5000 ==> 20.f
|
||||
if (sigm > 400.f) { //increase ==> 5000
|
||||
float ka = 19.f / 4600.f;
|
||||
float kb = 1.f - 400 * ka;
|
||||
kr = ka * sigm + kb;
|
||||
float kga = -0.14f / 4600.f;//decrease
|
||||
float kgb = 1.f - 400.f * kga;
|
||||
kg = kga * sigm + kgb;
|
||||
|
||||
if (sigm > 5000.f) {
|
||||
kr = ka * 5000.f + kb;
|
||||
kg = kga * 5000.f + kgb;
|
||||
}
|
||||
|
||||
}
|
||||
} else {//sigma *= sigma
|
||||
kg = 1.f;
|
||||
kr = sigm;
|
||||
}
|
||||
|
||||
if (skip >= 4) {
|
||||
//nei = (int)(0.1f * nei + 2.f); //not too bad
|
||||
nei = (int)(nei / (1.5f * skip)) / divsca;
|
||||
vart *= sqrt(skip);
|
||||
} else if (skip > 1 && skip < 4) {
|
||||
//nei = (int)(0.3f * nei + 2.f);
|
||||
nei = (int)(nei / skip) / divsca;
|
||||
vart *= sqrt(skip);
|
||||
if (!fftw) { // || (fftw && call != 2)) {
|
||||
if (scale == scal - 1) {
|
||||
gaussianBlur(src, out, W_L, H_L, kg * RetinexScales[scale], true);
|
||||
} else { // reuse result of last iteration
|
||||
// out was modified in last iteration => restore it
|
||||
gaussianBlur(out, out, W_L, H_L, sqrtf(SQR(kg * RetinexScales[scale]) - SQR(kg * RetinexScales[scale + 1])), true);
|
||||
}
|
||||
} else {
|
||||
if (scale == scal - 1) {
|
||||
if (settings->fftwsigma == false) { //empirical formula
|
||||
ImProcFunctions::fftw_convol_blur2(src, out, bfwr, bfhr, (kr * RetinexScales[scale]), 0, 0);
|
||||
} else {
|
||||
ImProcFunctions::fftw_convol_blur2(src, out, bfwr, bfhr, (SQR(RetinexScales[scale])), 0, 0);
|
||||
}
|
||||
} else { // reuse result of last iteration
|
||||
// out was modified in last iteration => restore it
|
||||
if (settings->fftwsigma == false) { //empirical formula
|
||||
ImProcFunctions::fftw_convol_blur2(out, out, bfwr, bfhr, sqrtf(SQR(kr * RetinexScales[scale]) - SQR(kr * RetinexScales[scale + 1])), 0, 0);
|
||||
} else {
|
||||
ImProcFunctions::fftw_convol_blur2(out, out, bfwr, bfhr, (SQR(RetinexScales[scale]) - SQR(RetinexScales[scale + 1])), 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int moderetinex = 0;
|
||||
if (scale == 1) { //equalize last scale with darkness and lightness of course acts on TM!
|
||||
if (dar != 1.f || lig != 1.f) {
|
||||
|
||||
if (loc.spots.at(sp).retinexMethod == "uni") {
|
||||
moderetinex = 0;
|
||||
} else if (loc.spots.at(sp).retinexMethod == "low") {
|
||||
moderetinex = 1;
|
||||
} else if (loc.spots.at(sp).retinexMethod == "high") {
|
||||
moderetinex = 2;
|
||||
#ifdef _OPENMP
|
||||
#pragma omp parallel for
|
||||
#endif
|
||||
|
||||
for (int y = 0; y < H_L; ++y) {
|
||||
for (int x = 0; x < W_L; ++x) {
|
||||
float buf = (src[y][x] - out[y][x]) * value;
|
||||
buf *= (buf > 0.f) ? lig : dar;
|
||||
out[y][x] = LIM(out[y][x] + buf, -100000.f, 100000.f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const float high = 0.f; // Dummy to pass to retinex_scales(...)
|
||||
#ifdef _OPENMP
|
||||
#pragma omp parallel for
|
||||
#endif
|
||||
|
||||
constexpr auto maxRetinexScales = 10;
|
||||
float RetinexScales[maxRetinexScales];
|
||||
for (int i = 0; i < H_L; i++) {
|
||||
int j = 0;
|
||||
|
||||
retinex_scales(RetinexScales, scal, moderetinex, nei, high);
|
||||
#ifdef __SSE2__
|
||||
const vfloat pondv = F2V(pond);
|
||||
const vfloat limMinv = F2V(ilimD);
|
||||
const vfloat limMaxv = F2V(limD);
|
||||
|
||||
if (useHslLin) {
|
||||
for (; j < W_L - 3; j += 4) {
|
||||
STVFU(luminance[i][j], LVFU(luminance[i][j]) + pondv * vclampf(LVFU(src[i][j]) / LVFU(out[i][j]), limMinv, limMaxv));
|
||||
}
|
||||
} else {
|
||||
for (; j < W_L - 3; j += 4) {
|
||||
STVFU(luminance[i][j], LVFU(luminance[i][j]) + pondv * xlogf(vclampf(LVFU(src[i][j]) / LVFU(out[i][j]), limMinv, limMaxv)));
|
||||
}
|
||||
}
|
||||
|
||||
const int H_L = height;
|
||||
const int W_L = width;
|
||||
std::unique_ptr<JaggedArray<float>> srcBuffer(new JaggedArray<float>(W_L, H_L));
|
||||
float** src = *(srcBuffer.get());
|
||||
#endif
|
||||
|
||||
if (useHslLin) {
|
||||
for (; j < W_L; j++) {
|
||||
luminance[i][j] += pond * (LIM(src[i][j] / out[i][j], ilimD, limD));
|
||||
}
|
||||
} else {
|
||||
for (; j < W_L; j++) {
|
||||
luminance[i][j] += pond * xlogf(LIM(src[i][j] / out[i][j], ilimD, limD));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (scal == 1) {//only if user select scal = 1
|
||||
|
||||
float kval = 1.f;
|
||||
#ifdef _OPENMP
|
||||
#pragma omp parallel for
|
||||
#endif
|
||||
|
||||
for (int y = 0; y < H_L; ++y) {
|
||||
for (int x = 0; x < W_L; ++x) {
|
||||
float threslow = threslum * 163.f;
|
||||
|
||||
if (src[y][x] < threslow) {
|
||||
kval = src[y][x] / threslow;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef _OPENMP
|
||||
#pragma omp parallel for
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < H_L; i++)
|
||||
for (int y = 0; y < H_L; ++y) {
|
||||
for (int x = 0; x < W_L; ++x) {
|
||||
float buf = (src[y][x] - out[y][x]) * value_1;
|
||||
buf *= (buf > 0.f) ? lig : dar;
|
||||
luminance[y][x] = LIM(src[y][x] + (1.f + kval) * buf, -32768.f, 32768.f);
|
||||
}
|
||||
}
|
||||
|
||||
double avg = 0.f;
|
||||
int ng = 0;
|
||||
|
||||
#ifdef _OPENMP
|
||||
#pragma omp parallel for
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < H_L; i++) {
|
||||
for (int j = 0; j < W_L; j++) {
|
||||
src[i][j] = luminance[i][j] + eps;
|
||||
luminance[i][j] = 0.f;
|
||||
avg += luminance[i][j];
|
||||
ng++;
|
||||
}
|
||||
|
||||
JaggedArray<float> out(W_L, H_L);
|
||||
|
||||
float clipt = loc.spots.at(sp).cliptm;
|
||||
|
||||
const float logBetaGain = xlogf(16384.f);
|
||||
float pond = logBetaGain / (float) scal;
|
||||
|
||||
if (!useHslLin) {
|
||||
pond /= log(elogt);
|
||||
}
|
||||
|
||||
float kr = 1.f;//on FFTW
|
||||
float kg = 1.f;//on Gaussianblur
|
||||
std::unique_ptr<float[]> buffer;
|
||||
buffer.reset(new float[W_L * H_L]);
|
||||
|
||||
for (int scale = scal - 1; scale >= 0; --scale) {
|
||||
// printf("retscale=%f scale=%i \n", mulradiusfftw * RetinexScales[scale], scale);
|
||||
//emprical adjustment between FFTW radius and Gaussainblur
|
||||
//under 50 ==> 10.f
|
||||
// 400 ==> 1.f
|
||||
float sigm = 1.f;
|
||||
|
||||
if (settings->fftwsigma == false) { //empirical formula
|
||||
sigm = RetinexScales[scale];
|
||||
float ak = -9.f / 350.f;
|
||||
float bk = 10.f - 50.f * ak;
|
||||
kr = ak * sigm + bk;
|
||||
|
||||
if (sigm < 50.f) {
|
||||
kr = 10.f;
|
||||
}
|
||||
|
||||
//above 400 at 5000 ==> 20.f
|
||||
if (sigm > 400.f) { //increase ==> 5000
|
||||
float ka = 19.f / 4600.f;
|
||||
float kb = 1.f - 400 * ka;
|
||||
kr = ka * sigm + kb;
|
||||
float kga = -0.14f / 4600.f;//decrease
|
||||
float kgb = 1.f - 400.f * kga;
|
||||
kg = kga * sigm + kgb;
|
||||
|
||||
if (sigm > 5000.f) {
|
||||
kr = ka * 5000.f + kb;
|
||||
kg = kga * 5000.f + kgb;
|
||||
}
|
||||
|
||||
}
|
||||
} else {//sigma *= sigma
|
||||
kg = 1.f;
|
||||
kr = sigm;
|
||||
}
|
||||
printf("call=%i\n", call);
|
||||
if (!fftw) { // || (fftw && call != 2)) {
|
||||
if (scale == scal - 1) {
|
||||
gaussianBlur(src, out, W_L, H_L, kg * RetinexScales[scale], true);
|
||||
} else { // reuse result of last iteration
|
||||
// out was modified in last iteration => restore it
|
||||
gaussianBlur(out, out, W_L, H_L, sqrtf(SQR(kg * RetinexScales[scale]) - SQR(kg * RetinexScales[scale + 1])), true);
|
||||
}
|
||||
} else {
|
||||
if (scale == scal - 1) {
|
||||
if (settings->fftwsigma == false) { //empirical formula
|
||||
ImProcFunctions::fftw_convol_blur2(src, out, bfwr, bfhr, (kr * RetinexScales[scale]), 0, 0);
|
||||
} else {
|
||||
ImProcFunctions::fftw_convol_blur2(src, out, bfwr, bfhr, (SQR(RetinexScales[scale])), 0, 0);
|
||||
}
|
||||
} else { // reuse result of last iteration
|
||||
// out was modified in last iteration => restore it
|
||||
if (settings->fftwsigma == false) { //empirical formula
|
||||
ImProcFunctions::fftw_convol_blur2(out, out, bfwr, bfhr, sqrtf(SQR(kr * RetinexScales[scale]) - SQR(kr * RetinexScales[scale + 1])), 0, 0);
|
||||
} else {
|
||||
ImProcFunctions::fftw_convol_blur2(out, out, bfwr, bfhr, (SQR(RetinexScales[scale]) - SQR(RetinexScales[scale + 1])), 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (scale == 1) { //equalize last scale with darkness and lightness of course acts on TM!
|
||||
if (dar != 1.f || lig != 1.f) {
|
||||
avg /= ng;
|
||||
avg /= 32768.f;
|
||||
avg = LIM01(avg);
|
||||
float contreal = 0.5f * vart;
|
||||
DiagonalCurve reti_contrast({
|
||||
DCT_NURBS,
|
||||
0, 0,
|
||||
avg - avg * (0.6 - contreal / 250.0), avg - avg * (0.6 + contreal / 250.0),
|
||||
avg + (1 - avg) * (0.6 - contreal / 250.0), avg + (1 - avg) * (0.6 + contreal / 250.0),
|
||||
1, 1
|
||||
});
|
||||
|
||||
#ifdef _OPENMP
|
||||
#pragma omp parallel for
|
||||
#pragma omp parallel for
|
||||
#endif
|
||||
|
||||
for (int y = 0; y < H_L; ++y) {
|
||||
for (int x = 0; x < W_L; ++x) {
|
||||
float buf = (src[y][x] - out[y][x]) * value;
|
||||
buf *= (buf > 0.f) ? lig : dar;
|
||||
out[y][x] = LIM(out[y][x] + buf, -100000.f, 100000.f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < H_L; i++) {
|
||||
for (int j = 0; j < W_L; j++) {
|
||||
float buf = LIM01(luminance[i][j] / 32768.f);
|
||||
buf = reti_contrast.getVal(buf);
|
||||
buf *= 32768.f;
|
||||
luminance[i][j] = buf;
|
||||
}
|
||||
|
||||
#ifdef _OPENMP
|
||||
#pragma omp parallel for
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < H_L; i++) {
|
||||
int j = 0;
|
||||
|
||||
#ifdef __SSE2__
|
||||
const vfloat pondv = F2V(pond);
|
||||
const vfloat limMinv = F2V(ilimD);
|
||||
const vfloat limMaxv = F2V(limD);
|
||||
|
||||
if (useHslLin) {
|
||||
for (; j < W_L - 3; j += 4) {
|
||||
STVFU(luminance[i][j], LVFU(luminance[i][j]) + pondv * vclampf(LVFU(src[i][j]) / LVFU(out[i][j]), limMinv, limMaxv));
|
||||
}
|
||||
} else {
|
||||
for (; j < W_L - 3; j += 4) {
|
||||
STVFU(luminance[i][j], LVFU(luminance[i][j]) + pondv * xlogf(vclampf(LVFU(src[i][j]) / LVFU(out[i][j]), limMinv, limMaxv)));
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
if (useHslLin) {
|
||||
for (; j < W_L; j++) {
|
||||
luminance[i][j] += pond * (LIM(src[i][j] / out[i][j], ilimD, limD));
|
||||
}
|
||||
} else {
|
||||
for (; j < W_L; j++) {
|
||||
luminance[i][j] += pond * xlogf(LIM(src[i][j] / out[i][j], ilimD, limD));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// srcBuffer.reset();
|
||||
srcBuffer.reset();
|
||||
|
||||
float str = strength * (chrome == 0 ? 1.f : 0.8f * (chrT - 0.4f));
|
||||
const float maxclip = (chrome == 0 ? 32768.f : 50000.f);
|
||||
|
||||
if (scal == 1) {//only if user select scal = 1
|
||||
if (scal != 1) {
|
||||
mean = 0.f;
|
||||
stddv = 0.f;
|
||||
|
||||
float kval = 1.f;
|
||||
#ifdef _OPENMP
|
||||
#pragma omp parallel for
|
||||
#endif
|
||||
mean_stddv2(luminance, mean, stddv, W_L, H_L, maxtr, mintr);
|
||||
|
||||
for (int y = 0; y < H_L; ++y) {
|
||||
for (int x = 0; x < W_L; ++x) {
|
||||
float threslow = threslum * 163.f;
|
||||
|
||||
if (src[y][x] < threslow) {
|
||||
kval = src[y][x] / threslow;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef _OPENMP
|
||||
#pragma omp parallel for
|
||||
#endif
|
||||
|
||||
for (int y = 0; y < H_L; ++y) {
|
||||
for (int x = 0; x < W_L; ++x) {
|
||||
float buf = (src[y][x] - out[y][x]) * value_1;
|
||||
buf *= (buf > 0.f) ? lig : dar;
|
||||
luminance[y][x] = LIM(src[y][x] + (1.f + kval) * buf, -32768.f, 32768.f);
|
||||
}
|
||||
}
|
||||
|
||||
double avg = 0.f;
|
||||
int ng = 0;
|
||||
|
||||
#ifdef _OPENMP
|
||||
#pragma omp parallel for
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < H_L; i++) {
|
||||
for (int j = 0; j < W_L; j++) {
|
||||
avg += luminance[i][j];
|
||||
ng++;
|
||||
}
|
||||
}
|
||||
|
||||
avg /= ng;
|
||||
avg /= 32768.f;
|
||||
avg = LIM01(avg);
|
||||
float contreal = 0.5f * vart;
|
||||
DiagonalCurve reti_contrast({
|
||||
DCT_NURBS,
|
||||
0, 0,
|
||||
avg - avg * (0.6 - contreal / 250.0), avg - avg * (0.6 + contreal / 250.0),
|
||||
avg + (1 - avg) * (0.6 - contreal / 250.0), avg + (1 - avg) * (0.6 + contreal / 250.0),
|
||||
1, 1
|
||||
});
|
||||
|
||||
#ifdef _OPENMP
|
||||
#pragma omp parallel for
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < H_L; i++)
|
||||
for (int j = 0; j < W_L; j++) {
|
||||
float buf = LIM01(luminance[i][j] / 32768.f);
|
||||
buf = reti_contrast.getVal(buf);
|
||||
buf *= 32768.f;
|
||||
luminance[i][j] = buf;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
srcBuffer.reset();
|
||||
|
||||
float str = strength * (chrome == 0 ? 1.f : 0.8f * (chrT - 0.4f));
|
||||
const float maxclip = (chrome == 0 ? 32768.f : 50000.f);
|
||||
|
||||
if (scal != 1) {
|
||||
mean = 0.f;
|
||||
stddv = 0.f;
|
||||
|
||||
mean_stddv2(luminance, mean, stddv, W_L, H_L, maxtr, mintr);
|
||||
// printf("mean=%f std=%f delta=%f maxtr=%f mintr=%f\n", mean, stddv, delta, maxtr, mintr);
|
||||
|
||||
if (locRETtransCcurve && mean != 0.f && stddv != 0.f) { //if curve
|
||||
float asig = 0.166666f / stddv;
|
||||
float bsig = 0.5f - asig * mean;
|
||||
float amax = 0.333333f / (maxtr - mean - stddv);
|
||||
float bmax = 1.f - amax * maxtr;
|
||||
float amin = 0.333333f / (mean - stddv - mintr);
|
||||
float bmin = -amin * mintr;
|
||||
|
||||
asig *= 500.f;
|
||||
bsig *= 500.f;
|
||||
amax *= 500.f;
|
||||
bmax *= 500.f;
|
||||
amin *= 500.f;
|
||||
bmin *= 500.f;
|
||||
|
||||
#ifdef _OPENMP
|
||||
#pragma omp parallel
|
||||
#endif
|
||||
{
|
||||
float absciss;
|
||||
#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++) { //for mintr to maxtr evalate absciss in function of original transmission
|
||||
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 { /*if(luminance[i][j] <= mean - stddv)*/
|
||||
absciss = amin * luminance[i][j] + bmin;
|
||||
}
|
||||
|
||||
//TODO : move multiplication by 4.f and subtraction of 1.f inside the curve
|
||||
luminance[i][j] *= (-1.f + 4.f * locRETtransCcurve[absciss]); //new transmission
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mean = 0.f;
|
||||
stddv = 0.f;
|
||||
mean_stddv2(luminance, mean, stddv, W_L, H_L, maxtr, mintr);//new calculation of mean...
|
||||
|
||||
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 *copylum[H_L] ALIGNED16;
|
||||
float *copylumBuffer = new float[H_L * W_L];
|
||||
|
||||
for (int i = 0; i < H_L; i++) {
|
||||
copylum[i] = ©lumBuffer[i * W_L];
|
||||
}
|
||||
|
||||
float cdfactor = (clipt * 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;
|
||||
|
||||
mean_stddv2(luminance, mean, stddv, W_L, H_L, maxtr, mintr);
|
||||
// printf("meanun=%f stdun=%f maxtr=%f mintr=%f\n", mean, stddv, maxtr, mintr);
|
||||
|
||||
float asig = 0.f, bsig = 0.f, amax = 0.f, bmax = 0.f, amin = 0.f, bmin = 0.f;
|
||||
const bool hasRetGainCurve = locRETgainCcurve && mean != 0.f && stddv != 0.f;
|
||||
|
||||
if (hasRetGainCurve) { //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;
|
||||
}
|
||||
if (locRETtransCcurve && mean != 0.f && stddv != 0.f) { //if curve
|
||||
float asig = 0.166666f / stddv;
|
||||
float bsig = 0.5f - asig * mean;
|
||||
float amax = 0.333333f / (maxtr - mean - stddv);
|
||||
float bmax = 1.f - amax * maxtr;
|
||||
float amin = 0.333333f / (mean - stddv - mintr);
|
||||
float bmin = -amin * mintr;
|
||||
|
||||
asig *= 500.f;
|
||||
bsig *= 500.f;
|
||||
amax *= 500.f;
|
||||
bmax *= 500.f;
|
||||
amin *= 500.f;
|
||||
bmin *= 500.f;
|
||||
|
||||
#ifdef _OPENMP
|
||||
#pragma omp parallel
|
||||
#endif
|
||||
{
|
||||
// float absciss;
|
||||
float cdmax = -999999.f, cdmin = 999999.f;
|
||||
float gan = 0.5f;
|
||||
|
||||
float absciss;
|
||||
#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 (hasRetGainCurve) {
|
||||
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
|
||||
for (int i = 0; i < H_L; i++)
|
||||
for (int j = 0; j < W_L; j++) { //for mintr to maxtr evalate absciss in function of original transmission
|
||||
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 { /*if(luminance[i][j] <= mean - stddv)*/
|
||||
absciss = amin * luminance[i][j] + bmin;
|
||||
}
|
||||
|
||||
//but we don't update mean stddv for display only...
|
||||
copylum[i][j] = gan * luminance[i][j];//update data for display
|
||||
float cd = gan * cdfactor * luminance[i][j] + offse;
|
||||
//TODO : move multiplication by 4.f and subtraction of 1.f inside the curve
|
||||
luminance[i][j] *= (-1.f + 4.f * locRETtransCcurve[absciss]); //new transmission
|
||||
|
||||
cdmax = cd > cdmax ? cd : cdmax;
|
||||
cdmin = cd < cdmin ? cd : cdmin;
|
||||
luminance[i][j] = intp(str * reducDE[i][j], clipretinex(cd, 0.f, maxclip), originalLuminance[i][j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mean = 0.f;
|
||||
stddv = 0.f;
|
||||
mean_stddv2(luminance, mean, stddv, W_L, H_L, maxtr, mintr);//new calculation of mean...
|
||||
|
||||
float epsil = 0.1f;
|
||||
|
||||
mini = mean - vart * stddv;
|
||||
|
||||
if (mini < mintr) {
|
||||
mini = mintr + epsil;
|
||||
}
|
||||
|
||||
maxi = mean + vart * stddv;
|
||||
|
||||
if (maxi > maxtr) {
|
||||
maxi = maxtr - epsil;
|
||||
}
|
||||
|
||||
float delta = maxi - mini;
|
||||
if (!delta) {
|
||||
delta = 1.0f;
|
||||
}
|
||||
|
||||
|
||||
float *copylum[H_L] ALIGNED16;
|
||||
float *copylumBuffer = new float[H_L * W_L];
|
||||
|
||||
for (int i = 0; i < H_L; i++) {
|
||||
copylum[i] = ©lumBuffer[i * W_L];
|
||||
}
|
||||
|
||||
float cdfactor = (clipt * 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;
|
||||
|
||||
mean_stddv2(luminance, mean, stddv, W_L, H_L, maxtr, mintr);
|
||||
// printf("meanun=%f stdun=%f maxtr=%f mintr=%f\n", mean, stddv, maxtr, mintr);
|
||||
|
||||
float asig = 0.f, bsig = 0.f, amax = 0.f, bmax = 0.f, amin = 0.f, bmin = 0.f;
|
||||
const bool hasRetGainCurve = locRETgainCcurve && mean != 0.f && stddv != 0.f;
|
||||
|
||||
if (hasRetGainCurve) { //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;
|
||||
}
|
||||
|
||||
|
||||
#ifdef _OPENMP
|
||||
#pragma omp critical
|
||||
#pragma omp parallel
|
||||
#endif
|
||||
{
|
||||
maxCD = maxCD > cdmax ? maxCD : cdmax;
|
||||
minCD = minCD < cdmin ? minCD : cdmin;
|
||||
}
|
||||
}
|
||||
mean = 0.f;
|
||||
stddv = 0.f;
|
||||
{
|
||||
// float absciss;
|
||||
float cdmax = -999999.f, cdmin = 999999.f;
|
||||
float gan = 0.5f;
|
||||
|
||||
mean_stddv2(copylum, mean, stddv, W_L, H_L, maxtr, mintr);
|
||||
delete [] copylumBuffer;
|
||||
copylumBuffer = nullptr;
|
||||
|
||||
// printf("mean=%f std=%f maxtr=%f mintr=%f\n", mean, stddv, maxtr, mintr);
|
||||
|
||||
} else {
|
||||
#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++) {
|
||||
luminance[i][j] = LIM(luminance[i][j], 0.f, maxclip) * str + (1.f - str) * originalLuminance[i][j];
|
||||
|
||||
if (hasRetGainCurve) {
|
||||
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
|
||||
}
|
||||
|
||||
//but we don't update mean stddv for display only...
|
||||
copylum[i][j] = gan * luminance[i][j];//update data for display
|
||||
float cd = gan * cdfactor * luminance[i][j] + offse;
|
||||
|
||||
cdmax = cd > cdmax ? cd : cdmax;
|
||||
cdmin = cd < cdmin ? cd : cdmin;
|
||||
luminance[i][j] = intp(str * reducDE[i][j], clipretinex(cd, 0.f, maxclip), originalLuminance[i][j]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifdef _OPENMP
|
||||
#pragma omp critical
|
||||
#endif
|
||||
{
|
||||
maxCD = maxCD > cdmax ? maxCD : cdmax;
|
||||
minCD = minCD < cdmin ? minCD : cdmin;
|
||||
}
|
||||
}
|
||||
mean = 0.f;
|
||||
stddv = 0.f;
|
||||
|
||||
float rad = loc.spots.at(sp).radmaskreti;
|
||||
float slop = loc.spots.at(sp).slomaskreti;
|
||||
float gamm = loc.spots.at(sp).gammaskreti;
|
||||
float blend = loc.spots.at(sp).blendmaskreti;
|
||||
float chro = loc.spots.at(sp).chromaskreti;
|
||||
float lap = loc.spots.at(sp).lapmaskreti;
|
||||
bool pde = params->locallab.spots.at(sp).laplac;
|
||||
mean_stddv2(copylum, mean, stddv, W_L, H_L, maxtr, mintr);
|
||||
delete [] copylumBuffer;
|
||||
copylumBuffer = nullptr;
|
||||
|
||||
if (lum == 1 && (llretiMask == 3 || llretiMask == 0 || llretiMask == 2 || llretiMask == 4)) { //only mask with luminance on last scale
|
||||
int before = 1;
|
||||
maskforretinex(sp, before, luminance, nullptr, W_L, H_L, skip,
|
||||
locccmasretiCurve, lcmasretiutili, locllmasretiCurve, llmasretiutili, lochhmasretiCurve, lhmasretiutili, llretiMask, retiMasktmap, retiMask,
|
||||
rad, lap, pde, gamm, slop, chro, blend,
|
||||
lmaskretilocalcurve, localmaskretiutili,
|
||||
bufreti, bufmask, buforig, buforigmas, multiThread,
|
||||
delt, hueref, chromaref, lumaref,
|
||||
maxdE, mindE, maxdElim, mindElim, iterat, limscope, scope, balance, balanceh, lumask
|
||||
);
|
||||
}
|
||||
} else {
|
||||
#ifdef _OPENMP
|
||||
#pragma omp for schedule(dynamic,16)
|
||||
#endif
|
||||
|
||||
//mask does not interfered with data displayed
|
||||
for (int i = 0; i < H_L; i ++)
|
||||
for (int j = 0; j < W_L; j++) {
|
||||
luminance[i][j] = LIM(luminance[i][j], 0.f, maxclip) * str + (1.f - str) * originalLuminance[i][j];
|
||||
|
||||
}
|
||||
|
||||
Tmean = mean;
|
||||
Tsigma = stddv;
|
||||
Tmin = mintr;
|
||||
Tmax = maxtr;
|
||||
}
|
||||
|
||||
float rad = loc.spots.at(sp).radmaskreti;
|
||||
float slop = loc.spots.at(sp).slomaskreti;
|
||||
float gamm = loc.spots.at(sp).gammaskreti;
|
||||
float blend = loc.spots.at(sp).blendmaskreti;
|
||||
float chro = loc.spots.at(sp).chromaskreti;
|
||||
float lap = loc.spots.at(sp).lapmaskreti;
|
||||
bool pde = params->locallab.spots.at(sp).laplac;
|
||||
|
||||
if (lum == 1 && (llretiMask == 3 || llretiMask == 0 || llretiMask == 2 || llretiMask == 4)) { //only mask with luminance on last scale
|
||||
int before = 1;
|
||||
maskforretinex(sp, before, luminance, nullptr, W_L, H_L, skip,
|
||||
locccmasretiCurve, lcmasretiutili, locllmasretiCurve, llmasretiutili, lochhmasretiCurve, lhmasretiutili, llretiMask, retiMasktmap, retiMask,
|
||||
rad, lap, pde, gamm, slop, chro, blend,
|
||||
lmaskretilocalcurve, localmaskretiutili,
|
||||
bufreti, bufmask, buforig, buforigmas, multiThread,
|
||||
delt, hueref, chromaref, lumaref,
|
||||
maxdE, mindE, maxdElim, mindElim, iterat, limscope, scope, balance, balanceh, lumask
|
||||
);
|
||||
}
|
||||
|
||||
//mask does not interfered with data displayed
|
||||
|
||||
Tmean = mean;
|
||||
Tsigma = stddv;
|
||||
Tmin = mintr;
|
||||
Tmax = maxtr;
|
||||
}
|
||||
}
|
||||
|
@ -283,20 +283,20 @@ void calcFrameBrightnessFactor(unsigned int frame, uint32_t datalen, LUTu *histo
|
||||
{
|
||||
float medians[4];
|
||||
|
||||
for(int i = 0; i < 4; ++i) {
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
//find median of histogram
|
||||
uint32_t median = 0, count = 0;
|
||||
uint32_t lmedian = 0, count = 0;
|
||||
|
||||
while(count < datalen / 2) {
|
||||
count += (*histo[i])[median];
|
||||
++median;
|
||||
while (count < datalen / 2) {
|
||||
count += (*histo[i])[lmedian];
|
||||
++lmedian;
|
||||
}
|
||||
|
||||
const float weight = (count - datalen / 2.f) / (*histo[i])[median - 1];
|
||||
medians[i] = rtengine::intp(weight, (float)(median - 2), (float)(median - 1));
|
||||
const float weight = (count - datalen / 2.f) / (*histo[i])[lmedian - 1];
|
||||
medians[i] = rtengine::intp(weight, (float)(lmedian - 2), (float)(lmedian - 1));
|
||||
}
|
||||
|
||||
for(int i = 0; i < 4; ++i) {
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
brightnessFactor[i] = medians[frame] / medians[i];
|
||||
}
|
||||
|
||||
|
@ -686,7 +686,7 @@ enum ProcEventCode {
|
||||
EvLocallabcontresid = 660,
|
||||
Evlocallabnoiselumf0 = 661,
|
||||
Evlocallabnoiselumf2 = 662,
|
||||
EvLocallabblurcbdl = 663,
|
||||
//EvLocallabblurcbdl = 663,
|
||||
Evlocallabblendmaskcb = 664,
|
||||
Evlocallabradmaskcb = 665,
|
||||
Evlocallabchromaskcb = 666,
|
||||
|
@ -3686,7 +3686,6 @@ LocallabParams::LocallabSpot::LocallabSpot() :
|
||||
sensicb(60),
|
||||
clarityml(0.1),
|
||||
contresid(0),
|
||||
blurcbdl(0.),
|
||||
softradiuscb(0.0),
|
||||
enacbMask(false),
|
||||
CCmaskcbcurve{
|
||||
@ -4309,7 +4308,6 @@ bool LocallabParams::LocallabSpot::operator ==(const LocallabSpot& other) const
|
||||
&& sensicb == other.sensicb
|
||||
&& clarityml == other.clarityml
|
||||
&& contresid == other.contresid
|
||||
&& blurcbdl == other.blurcbdl
|
||||
&& softradiuscb == other.softradiuscb
|
||||
&& enacbMask == other.enacbMask
|
||||
&& CCmaskcbcurve == other.CCmaskcbcurve
|
||||
@ -5833,7 +5831,6 @@ int ProcParams::save(const Glib::ustring& fname, const Glib::ustring& fname2, bo
|
||||
saveToKeyfile(!pedited || spot_edited->sensicb, "Locallab", "Sensicb_" + index_str, spot.sensicb, keyFile);
|
||||
saveToKeyfile(!pedited || spot_edited->clarityml, "Locallab", "Clarityml_" + index_str, spot.clarityml, keyFile);
|
||||
saveToKeyfile(!pedited || spot_edited->contresid, "Locallab", "Contresid_" + index_str, spot.contresid, keyFile);
|
||||
saveToKeyfile(!pedited || spot_edited->blurcbdl, "Locallab", "Blurcbdl_" + index_str, spot.blurcbdl, keyFile);
|
||||
saveToKeyfile(!pedited || spot_edited->softradiuscb, "Locallab", "Softradiuscb_" + index_str, spot.softradiuscb, keyFile);
|
||||
saveToKeyfile(!pedited || spot_edited->enacbMask, "Locallab", "EnacbMask_" + index_str, spot.enacbMask, keyFile);
|
||||
saveToKeyfile(!pedited || spot_edited->CCmaskcbcurve, "Locallab", "CCmaskcbCurve_" + index_str, spot.CCmaskcbcurve, keyFile);
|
||||
@ -7577,7 +7574,6 @@ int ProcParams::load(const Glib::ustring& fname, ParamsEdited* pedited)
|
||||
assignFromKeyfile(keyFile, "Locallab", "Sensicb_" + index_str, pedited, spot.sensicb, spotEdited.sensicb);
|
||||
assignFromKeyfile(keyFile, "Locallab", "Clarityml_" + index_str, pedited, spot.clarityml, spotEdited.clarityml);
|
||||
assignFromKeyfile(keyFile, "Locallab", "Contresid_" + index_str, pedited, spot.contresid, spotEdited.contresid);
|
||||
assignFromKeyfile(keyFile, "Locallab", "Blurcbdl_" + index_str, pedited, spot.blurcbdl, spotEdited.blurcbdl);
|
||||
assignFromKeyfile(keyFile, "Locallab", "Softradiuscb_" + index_str, pedited, spot.softradiuscb, spotEdited.softradiuscb);
|
||||
assignFromKeyfile(keyFile, "Locallab", "EnacbMask_" + index_str, pedited, spot.enacbMask, spotEdited.enacbMask);
|
||||
assignFromKeyfile(keyFile, "Locallab", "CCmaskcbCurve_" + index_str, pedited, spot.CCmaskcbcurve, spotEdited.CCmaskcbcurve);
|
||||
|
@ -1397,7 +1397,6 @@ struct LocallabParams {
|
||||
int sensicb;
|
||||
double clarityml;
|
||||
int contresid;
|
||||
double blurcbdl;
|
||||
double softradiuscb;
|
||||
bool enacbMask;
|
||||
std::vector<double> CCmaskcbcurve;
|
||||
|
@ -690,7 +690,7 @@ int refreshmap[rtengine::NUMOFEVENTS] = {
|
||||
LUMINANCECURVE, // EvLocallabcontresid
|
||||
LUMINANCECURVE, // Evlocallabnoiselumf0
|
||||
LUMINANCECURVE, // Evlocallabnoiselumf2
|
||||
LUMINANCECURVE, // Evlocallabblurcbdl
|
||||
0, // Evlocallabblurcbdl
|
||||
LUMINANCECURVE, // Evlocallabblendmaskcb
|
||||
LUMINANCECURVE, // Evlocallabradmaskcb
|
||||
LUMINANCECURVE, // Evlocallabchromaskcb
|
||||
|
@ -1180,7 +1180,6 @@ void ImProcFunctions::ToneMapFattal02(Imagefloat *rgb, const FattalToneMappingPa
|
||||
scale = (oldMedian == 0.f || newMedian == 0.f) ? 65535.f : (oldMedian / newMedian); // avoid Nan
|
||||
} else {
|
||||
|
||||
scale = 65535.f;
|
||||
{
|
||||
float ratio = 0.f;
|
||||
int ww, hh;
|
||||
|
@ -309,7 +309,6 @@ ControlSpotPanel::ControlSpotPanel():
|
||||
sigc::mem_fun(
|
||||
*this, &ControlSpotPanel::qualityMethodChanged));
|
||||
ctboxqualitymethod->pack_start(*qualityMethod_);
|
||||
// pack_start(*ctboxqualitymethod);
|
||||
|
||||
if (showtooltip) {
|
||||
expTransGrad_->set_tooltip_text(M("TP_LOCALLAB_TRANSIT_TOOLTIP"));
|
||||
@ -319,21 +318,9 @@ ControlSpotPanel::ControlSpotPanel():
|
||||
|
||||
if (showtooltip) {
|
||||
transit_->set_tooltip_text(M("TP_LOCALLAB_TRANSIT_TOOLTIP"));
|
||||
}
|
||||
|
||||
if (showtooltip) {
|
||||
transitweak_->set_tooltip_text(M("TP_LOCALLAB_TRANSITWEAK_TOOLTIP"));
|
||||
}
|
||||
|
||||
if (showtooltip) {
|
||||
feather_->set_tooltip_text(M("TP_LOCALLAB_FEATH_TOOLTIP"));
|
||||
}
|
||||
|
||||
if (showtooltip) {
|
||||
transitgrad_->set_tooltip_text(M("TP_LOCALLAB_TRANSITGRAD_TOOLTIP"));
|
||||
}
|
||||
|
||||
if (showtooltip) {
|
||||
scopemask_->set_tooltip_text(M("TP_LOCALLAB_SCOPEMASK_TOOLTIP"));
|
||||
}
|
||||
|
||||
|
@ -470,9 +470,8 @@ void HistogramRGBArea::updateBackBuffer (int r, int g, int b, const Glib::ustrin
|
||||
cc->set_antialias(Cairo::ANTIALIAS_NONE);
|
||||
cc->set_line_width (1.0 * s);
|
||||
|
||||
double xpos;
|
||||
|
||||
if ( r != -1 && g != -1 && b != -1 ) {
|
||||
double xpos;
|
||||
if (needRed) {
|
||||
// Red
|
||||
cc->set_source_rgb(1.0, 0.0, 0.0);
|
||||
|
@ -1093,7 +1093,6 @@ private:
|
||||
Gtk::Frame* const levFrame;
|
||||
Adjuster* const chromacbdl;
|
||||
Adjuster* const threshold;
|
||||
Adjuster* const blurcbdl;
|
||||
Adjuster* const clarityml;
|
||||
Adjuster* const contresid;
|
||||
Adjuster* const softradiuscb;
|
||||
|
@ -438,159 +438,63 @@ void LocallabTone::setDefaults(const rtengine::procparams::ProcParams* defParams
|
||||
|
||||
void LocallabTone::adjusterChanged(Adjuster* a, double newval)
|
||||
{
|
||||
if (isLocActivated && exp->getEnabled()) {
|
||||
if (isLocActivated && exp->getEnabled() && listener) {
|
||||
const auto spName = " (" + escapeHtmlChars(spotName) + ")";
|
||||
if (a == amount) {
|
||||
if (listener) {
|
||||
listener->panelChanged(Evlocallabamount,
|
||||
amount->getTextValue() + " (" + escapeHtmlChars(spotName) + ")");
|
||||
}
|
||||
}
|
||||
|
||||
if (a == stren) {
|
||||
if (listener) {
|
||||
listener->panelChanged(Evlocallabstren,
|
||||
stren->getTextValue() + " (" + escapeHtmlChars(spotName) + ")");
|
||||
}
|
||||
}
|
||||
|
||||
if (a == gamma) {
|
||||
if (listener) {
|
||||
listener->panelChanged(Evlocallabgamma,
|
||||
gamma->getTextValue() + " (" + escapeHtmlChars(spotName) + ")");
|
||||
}
|
||||
}
|
||||
|
||||
if (a == satur) {
|
||||
if (listener) {
|
||||
listener->panelChanged(Evlocallabsatur,
|
||||
satur->getTextValue() + " (" + escapeHtmlChars(spotName) + ")");
|
||||
}
|
||||
}
|
||||
|
||||
if (a == estop) {
|
||||
if (listener) {
|
||||
listener->panelChanged(Evlocallabestop,
|
||||
estop->getTextValue() + " (" + escapeHtmlChars(spotName) + ")");
|
||||
}
|
||||
}
|
||||
|
||||
if (a == scaltm) {
|
||||
if (listener) {
|
||||
listener->panelChanged(Evlocallabscaltm,
|
||||
scaltm->getTextValue() + " (" + escapeHtmlChars(spotName) + ")");
|
||||
}
|
||||
}
|
||||
|
||||
if (a == rewei) {
|
||||
if (listener) {
|
||||
listener->panelChanged(Evlocallabrewei,
|
||||
rewei->getTextValue() + " (" + escapeHtmlChars(spotName) + ")");
|
||||
}
|
||||
}
|
||||
|
||||
if (a == softradiustm) {
|
||||
if (listener) {
|
||||
listener->panelChanged(Evlocallabsoftradiustm,
|
||||
softradiustm->getTextValue() + " (" + escapeHtmlChars(spotName) + ")");
|
||||
}
|
||||
}
|
||||
|
||||
if (a == sensitm) {
|
||||
if (listener) {
|
||||
listener->panelChanged(Evlocallabsensitm,
|
||||
sensitm->getTextValue() + " (" + escapeHtmlChars(spotName) + ")");
|
||||
}
|
||||
}
|
||||
|
||||
if (a == blendmasktm) {
|
||||
if (listener) {
|
||||
listener->panelChanged(Evlocallabblendmasktm,
|
||||
blendmasktm->getTextValue() + " (" + escapeHtmlChars(spotName) + ")");
|
||||
}
|
||||
}
|
||||
|
||||
if (a == lapmasktm) {
|
||||
if (listener) {
|
||||
listener->panelChanged(Evlocallablapmasktm,
|
||||
lapmasktm->getTextValue() + " (" + escapeHtmlChars(spotName) + ")");
|
||||
}
|
||||
}
|
||||
|
||||
if (a == radmasktm) {
|
||||
if (listener) {
|
||||
listener->panelChanged(Evlocallabradmasktm,
|
||||
radmasktm->getTextValue() + " (" + escapeHtmlChars(spotName) + ")");
|
||||
}
|
||||
}
|
||||
|
||||
if (a == chromasktm) {
|
||||
if (listener) {
|
||||
listener->panelChanged(Evlocallabchromasktm,
|
||||
chromasktm->getTextValue() + " (" + escapeHtmlChars(spotName) + ")");
|
||||
}
|
||||
}
|
||||
|
||||
if (a == gammasktm) {
|
||||
if (listener) {
|
||||
listener->panelChanged(Evlocallabgammasktm,
|
||||
gammasktm->getTextValue() + " (" + escapeHtmlChars(spotName) + ")");
|
||||
}
|
||||
}
|
||||
|
||||
if (a == slomasktm) {
|
||||
if (listener) {
|
||||
listener->panelChanged(Evlocallabslomasktm,
|
||||
slomasktm->getTextValue() + " (" + escapeHtmlChars(spotName) + ")");
|
||||
}
|
||||
listener->panelChanged(Evlocallabamount, amount->getTextValue() + spName);
|
||||
} else if (a == stren) {
|
||||
listener->panelChanged(Evlocallabstren, stren->getTextValue() + spName);
|
||||
} else if (a == gamma) {
|
||||
listener->panelChanged(Evlocallabgamma, gamma->getTextValue() + spName);
|
||||
} else if (a == satur) {
|
||||
listener->panelChanged(Evlocallabsatur, satur->getTextValue() + spName);
|
||||
} else if (a == estop) {
|
||||
listener->panelChanged(Evlocallabestop, estop->getTextValue() + spName);
|
||||
} else if (a == scaltm) {
|
||||
listener->panelChanged(Evlocallabscaltm, scaltm->getTextValue() + spName);
|
||||
} else if (a == rewei) {
|
||||
listener->panelChanged(Evlocallabrewei, rewei->getTextValue() + spName);
|
||||
} else if (a == softradiustm) {
|
||||
listener->panelChanged(Evlocallabsoftradiustm, softradiustm->getTextValue() + spName);
|
||||
} else if (a == sensitm) {
|
||||
listener->panelChanged(Evlocallabsensitm, sensitm->getTextValue() + spName);
|
||||
} else if (a == blendmasktm) {
|
||||
listener->panelChanged(Evlocallabblendmasktm, blendmasktm->getTextValue() + spName);
|
||||
} else if (a == lapmasktm) {
|
||||
listener->panelChanged(Evlocallablapmasktm, lapmasktm->getTextValue() + spName);
|
||||
} else if (a == radmasktm) {
|
||||
listener->panelChanged(Evlocallabradmasktm, radmasktm->getTextValue() + spName);
|
||||
} else if (a == chromasktm) {
|
||||
listener->panelChanged(Evlocallabchromasktm, chromasktm->getTextValue() + spName);
|
||||
} else if (a == gammasktm) {
|
||||
listener->panelChanged(Evlocallabgammasktm, gammasktm->getTextValue() + spName);
|
||||
} else if (a == slomasktm) {
|
||||
listener->panelChanged(Evlocallabslomasktm, slomasktm->getTextValue() + spName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LocallabTone::curveChanged(CurveEditor* ce)
|
||||
{
|
||||
if (isLocActivated && exp->getEnabled()) {
|
||||
if (isLocActivated && exp->getEnabled() && listener) {
|
||||
const auto spName = M("HISTORY_CUSTOMCURVE") + " (" + escapeHtmlChars(spotName) + ")";
|
||||
if (ce == CCmasktmshape) {
|
||||
if (listener) {
|
||||
listener->panelChanged(EvlocallabCCmasktmshape,
|
||||
M("HISTORY_CUSTOMCURVE") + " (" + escapeHtmlChars(spotName) + ")");
|
||||
}
|
||||
}
|
||||
|
||||
if (ce == LLmasktmshape) {
|
||||
if (listener) {
|
||||
listener->panelChanged(EvlocallabLLmasktmshape,
|
||||
M("HISTORY_CUSTOMCURVE") + " (" + escapeHtmlChars(spotName) + ")");
|
||||
}
|
||||
}
|
||||
|
||||
if (ce == HHmasktmshape) {
|
||||
if (listener) {
|
||||
listener->panelChanged(EvlocallabHHmasktmshape,
|
||||
M("HISTORY_CUSTOMCURVE") + " (" + escapeHtmlChars(spotName) + ")");
|
||||
}
|
||||
}
|
||||
|
||||
if (ce == Lmasktmshape) {
|
||||
if (listener) {
|
||||
listener->panelChanged(EvlocallabLmasktmshape,
|
||||
M("HISTORY_CUSTOMCURVE") + " (" + escapeHtmlChars(spotName) + ")");
|
||||
}
|
||||
listener->panelChanged(EvlocallabCCmasktmshape, spName);
|
||||
} else if (ce == LLmasktmshape) {
|
||||
listener->panelChanged(EvlocallabLLmasktmshape, spName);
|
||||
} else if (ce == HHmasktmshape) {
|
||||
listener->panelChanged(EvlocallabHHmasktmshape, spName);
|
||||
} else if (ce == Lmasktmshape) {
|
||||
listener->panelChanged(EvlocallabLmasktmshape, spName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LocallabTone::enabledChanged()
|
||||
{
|
||||
if (isLocActivated) {
|
||||
if (listener) {
|
||||
if (exp->getEnabled()) {
|
||||
listener->panelChanged(EvLocenatonemap,
|
||||
M("GENERAL_ENABLED") + " (" + escapeHtmlChars(spotName) + ")");
|
||||
} else {
|
||||
listener->panelChanged(EvLocenatonemap,
|
||||
M("GENERAL_DISABLED") + " (" + escapeHtmlChars(spotName) + ")");
|
||||
}
|
||||
}
|
||||
if (isLocActivated && listener) {
|
||||
listener->panelChanged(EvLocenatonemap, (exp->getEnabled() ? M("GENERAL_ENABLED") : M("GENERAL_DISABLED"))
|
||||
+ " (" + escapeHtmlChars(spotName) + ")");
|
||||
}
|
||||
}
|
||||
|
||||
@ -3683,7 +3587,6 @@ LocallabCBDL::LocallabCBDL():
|
||||
levFrame(Gtk::manage(new Gtk::Frame(M("TP_LOCALLAB_LEVFRA")))),
|
||||
chromacbdl(Gtk::manage(new Adjuster(M("TP_LOCALLAB_CHROMACBDL"), 0., 1.5, 0.01, 0.))),
|
||||
threshold(Gtk::manage(new Adjuster(M("TP_DIRPYREQUALIZER_THRESHOLD"), 0, 1., 0.01, 0.2))),
|
||||
blurcbdl(Gtk::manage(new Adjuster(M("TP_LOCALLAB_BLURCBDL"), 0., 100., 0.1, 0.))),
|
||||
clarityml(Gtk::manage(new Adjuster(M("TP_LOCALLAB_CLARITYML"), 0.1, 100., 0.1, 0.1))),
|
||||
contresid(Gtk::manage(new Adjuster(M("TP_LOCALLAB_CONTRESID"), -100, 100, 1, 0))),
|
||||
softradiuscb(Gtk::manage(new Adjuster(M("TP_LOCALLAB_SOFTRADIUSCOL"), 0.0, 100.0, 0.5, 0.))),
|
||||
@ -3719,8 +3622,6 @@ LocallabCBDL::LocallabCBDL():
|
||||
|
||||
threshold->setAdjusterListener(this);
|
||||
|
||||
blurcbdl->setAdjusterListener(this);
|
||||
|
||||
clarityml->setAdjusterListener(this);
|
||||
|
||||
contresid->setAdjusterListener(this);
|
||||
@ -3803,7 +3704,6 @@ LocallabCBDL::LocallabCBDL():
|
||||
levBox->pack_start(*threshold);
|
||||
levFrame->add(*levBox);
|
||||
pack_start(*levFrame);
|
||||
// pack_start(*blurcbdl);
|
||||
Gtk::Frame* const residFrame = Gtk::manage(new Gtk::Frame(M("TP_LOCALLAB_RESID")));
|
||||
residFrame->set_label_align(0.025, 0.5);
|
||||
ToolParamBlock* const residBox = Gtk::manage(new ToolParamBlock());
|
||||
@ -3929,7 +3829,6 @@ void LocallabCBDL::read(const rtengine::procparams::ProcParams* pp, const Params
|
||||
|
||||
chromacbdl->setValue(spot.chromacbdl);
|
||||
threshold->setValue(spot.threshold);
|
||||
blurcbdl->setValue(spot.blurcbdl);
|
||||
clarityml->setValue(spot.clarityml);
|
||||
contresid->setValue((double)spot.contresid);
|
||||
softradiuscb->setValue(spot.softradiuscb);
|
||||
@ -3973,7 +3872,6 @@ void LocallabCBDL::write(rtengine::procparams::ProcParams* pp, ParamsEdited* ped
|
||||
|
||||
spot.chromacbdl = chromacbdl->getValue();
|
||||
spot.threshold = threshold->getValue();
|
||||
spot.blurcbdl = blurcbdl->getValue();
|
||||
spot.clarityml = clarityml->getValue();
|
||||
spot.contresid = contresid->getIntValue();
|
||||
spot.softradiuscb = softradiuscb->getValue();
|
||||
@ -4008,7 +3906,6 @@ void LocallabCBDL::setDefaults(const rtengine::procparams::ProcParams* defParams
|
||||
|
||||
chromacbdl->setDefault(defSpot.chromacbdl);
|
||||
threshold->setDefault(defSpot.threshold);
|
||||
blurcbdl->setDefault(defSpot.blurcbdl);
|
||||
clarityml->setDefault(defSpot.clarityml);
|
||||
contresid->setDefault((double)defSpot.contresid);
|
||||
softradiuscb->setDefault(defSpot.softradiuscb);
|
||||
@ -4055,13 +3952,6 @@ void LocallabCBDL::adjusterChanged(Adjuster* a, double newval)
|
||||
}
|
||||
}
|
||||
|
||||
if (a == blurcbdl) {
|
||||
if (listener) {
|
||||
listener->panelChanged(EvLocallabblurcbdl,
|
||||
blurcbdl->getTextValue() + " (" + escapeHtmlChars(spotName) + ")");
|
||||
}
|
||||
}
|
||||
|
||||
if (a == clarityml) {
|
||||
if (listener) {
|
||||
listener->panelChanged(EvLocallabclarityml,
|
||||
|
@ -1452,7 +1452,6 @@ void ParamsEdited::initFrom(const std::vector<rtengine::procparams::ProcParams>&
|
||||
locallab.spots.at(j).sensicb = locallab.spots.at(j).sensicb && pSpot.sensicb == otherSpot.sensicb;
|
||||
locallab.spots.at(j).clarityml = locallab.spots.at(j).clarityml && pSpot.clarityml == otherSpot.clarityml;
|
||||
locallab.spots.at(j).contresid = locallab.spots.at(j).contresid && pSpot.contresid == otherSpot.contresid;
|
||||
locallab.spots.at(j).blurcbdl = locallab.spots.at(j).blurcbdl && pSpot.blurcbdl == otherSpot.blurcbdl;
|
||||
locallab.spots.at(j).softradiuscb = locallab.spots.at(j).softradiuscb && pSpot.softradiuscb == otherSpot.softradiuscb;
|
||||
locallab.spots.at(j).enacbMask = locallab.spots.at(j).enacbMask && pSpot.enacbMask == otherSpot.enacbMask;
|
||||
locallab.spots.at(j).CCmaskcbcurve = locallab.spots.at(j).CCmaskcbcurve && pSpot.CCmaskcbcurve == otherSpot.CCmaskcbcurve;
|
||||
@ -4717,10 +4716,6 @@ void ParamsEdited::combine(rtengine::procparams::ProcParams& toEdit, const rteng
|
||||
toEdit.locallab.spots.at(i).contresid = mods.locallab.spots.at(i).contresid;
|
||||
}
|
||||
|
||||
if (locallab.spots.at(i).blurcbdl) {
|
||||
toEdit.locallab.spots.at(i).blurcbdl = mods.locallab.spots.at(i).blurcbdl;
|
||||
}
|
||||
|
||||
if (locallab.spots.at(i).softradiuscb) {
|
||||
toEdit.locallab.spots.at(i).softradiuscb = mods.locallab.spots.at(i).softradiuscb;
|
||||
}
|
||||
@ -6483,7 +6478,6 @@ LocallabParamsEdited::LocallabSpotEdited::LocallabSpotEdited(bool v) :
|
||||
sensicb(v),
|
||||
clarityml(v),
|
||||
contresid(v),
|
||||
blurcbdl(v),
|
||||
softradiuscb(v),
|
||||
enacbMask(v),
|
||||
CCmaskcbcurve(v),
|
||||
@ -6981,7 +6975,6 @@ void LocallabParamsEdited::LocallabSpotEdited::set(bool v)
|
||||
CCmaskcbcurve = v;
|
||||
LLmaskcbcurve = v;
|
||||
HHmaskcbcurve = v;
|
||||
blurcbdl = v;
|
||||
blendmaskcb = v;
|
||||
radmaskcb = v;
|
||||
chromaskcb = v;
|
||||
|
@ -810,7 +810,6 @@ public:
|
||||
bool sensicb;
|
||||
bool clarityml;
|
||||
bool contresid;
|
||||
bool blurcbdl;
|
||||
bool softradiuscb;
|
||||
bool enacbMask;
|
||||
bool CCmaskcbcurve;
|
||||
|
Loading…
x
Reference in New Issue
Block a user