merge with dev

This commit is contained in:
Desmis
2020-02-24 11:05:55 +01:00
178 changed files with 4236 additions and 4545 deletions

View File

@@ -31,15 +31,16 @@
#include "cieimage.h"
#include "clutstore.h"
#include "color.h"
#include "colortemp.h"
#include "curves.h"
#include "dcp.h"
#include "EdgePreservingDecomposition.h"
#include "iccmatrices.h"
#include "iccstore.h"
#include "imagesource.h"
#include "improccoordinator.h"
#include "improcfun.h"
#include "labimage.h"
#include "pipettebuffer.h"
#include "procparams.h"
#include "rt_math.h"
#include "rtengine.h"
@@ -54,9 +55,6 @@
#include "mytime.h"
#endif
#undef CLIPD
#define CLIPD(a) ((a)>0.0f?((a)<1.0f?(a):1.0f):0.0f)
namespace {
using namespace rtengine;
@@ -137,7 +135,7 @@ void highlightToneCurve(const LUTf &hltonecurve, float *rtemp, float *gtemp, flo
float b = btemp[ti * tileSize + tj + k];
float tonefactor = ((r < MAXVALF ? hltonecurve[r] : CurveFactory::hlcurve(exp_scale, comp, hlrange, r)) +
(g < MAXVALF ? hltonecurve[g] : CurveFactory::hlcurve(exp_scale, comp, hlrange, g)) +
(b < MAXVALF ? hltonecurve[b] : CurveFactory::hlcurve(exp_scale, comp, hlrange, b))) / 3.0;
(b < MAXVALF ? hltonecurve[b] : CurveFactory::hlcurve(exp_scale, comp, hlrange, b))) / 3.f;
// note: tonefactor includes exposure scaling, that is here exposure slider and highlight compression takes place
rtemp[ti * tileSize + tj + k] = r * tonefactor;
@@ -165,7 +163,7 @@ void highlightToneCurve(const LUTf &hltonecurve, float *rtemp, float *gtemp, flo
//float tonefactor = hltonecurve[(0.299f*r+0.587f*g+0.114f*b)];
float tonefactor = ((r < MAXVALF ? hltonecurve[r] : CurveFactory::hlcurve(exp_scale, comp, hlrange, r)) +
(g < MAXVALF ? hltonecurve[g] : CurveFactory::hlcurve(exp_scale, comp, hlrange, g)) +
(b < MAXVALF ? hltonecurve[b] : CurveFactory::hlcurve(exp_scale, comp, hlrange, b))) / 3.0;
(b < MAXVALF ? hltonecurve[b] : CurveFactory::hlcurve(exp_scale, comp, hlrange, b))) / 3.f;
// note: tonefactor includes exposure scaling, that is here exposure slider and highlight compression takes place
rtemp[ti * tileSize + tj] = r * tonefactor;
@@ -518,8 +516,7 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int pW, int pw
int width = lab->W, height = lab->H;
float minQ = 10000.f;
float maxQ = -1000.f;
float Yw;
Yw = 1.0;
double Yw = 1.0;
double Xw, Zw;
float f = 0.f, nc = 0.f, la, c = 0.f, xw, yw, zw, f2 = 1.f, c2 = 1.f, nc2 = 1.f, yb2;
float fl, n, nbb, ncb, aw; //d
@@ -596,13 +593,13 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int pW, int pw
algepd = true;
}
xwd = 100.f * Xwout;
zwd = 100.f * Zwout;
ywd = 100.f / params->colorappearance.greenout;//approximation to simplify
xwd = 100.0 * Xwout;
zwd = 100.0 * Zwout;
ywd = 100.0 / params->colorappearance.greenout;//approximation to simplify
xws = 100.f * Xwsc;
zws = 100.f * Zwsc;
yws = 100.f / params->colorappearance.greensc;//approximation to simplify
xws = 100.0 * Xwsc;
zws = 100.0 * Zwsc;
yws = 100.0 / params->colorappearance.greensc;//approximation to simplify
/*
@@ -699,20 +696,20 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int pW, int pw
if (alg == 3 || alg == 1) {
schr = params->colorappearance.schroma;
if (schr > 0.0) {
schr = schr / 2.0f; //divide sensibility for saturation
if (schr > 0.f) {
schr = schr / 2.f; //divide sensibility for saturation
}
if (alg == 3) {
if (schr == -100.0f) {
if (schr == -100.f) {
schr = -99.f;
}
if (schr == 100.0f) {
if (schr == 100.f) {
schr = 98.f;
}
} else {
if (schr == -100.0f) {
if (schr == -100.f) {
schr = -99.8f;
}
}
@@ -751,7 +748,7 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int pW, int pw
LUTu hist16J;
LUTu hist16Q;
if ((needJ && CAMBrightCurveJ.dirty) || (needQ && CAMBrightCurveQ.dirty) || (std::isnan (mean) && settings->viewinggreySc != 0)) {
if ((needJ && CAMBrightCurveJ.dirty) || (needQ && CAMBrightCurveQ.dirty) || (std::isnan(mean) && settings->viewinggreySc != 0)) {
if (needJ) {
hist16J (32768);
@@ -788,7 +785,7 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int pW, int pw
#endif
for (int i = 0; i < height; i++)
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) { //rough correspondence between L and J
float currL = lab->L[i][j] / 327.68f;
float koef; //rough correspondence between L and J
@@ -849,10 +846,11 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int pW, int pw
//hist16Qthr[ (int) (sqrtf ((koef * (lab->L[i][j])) * 32768.f))]++; //for brightness Q : approximation for Q=wh*sqrt(J/100) J not equal L
}
sum += koef * lab->L[i][j]; //evaluate mean J to calculate Yb
sum += static_cast<double>(koef) * static_cast<double>(lab->L[i][j]); //evaluate mean J to calculate Yb
//sumQ += whestim * sqrt ((koef * (lab->L[i][j])) / 32768.f);
//can be used in case of...
}
}
#ifdef _OPENMP
#pragma omp critical
@@ -868,8 +866,8 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int pW, int pw
}
if (std::isnan (mean)) {
mean = (sum / ((height) * width)) / 327.68f; //for Yb for all image...if one day "pipette" we can adapt Yb for each zone
if (std::isnan(mean)) {
mean = (sum / ((height) * width)) / 327.68; //for Yb for all image...if one day "pipette" we can adapt Yb for each zone
}
}
#ifdef _OPENMP
@@ -916,9 +914,9 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int pW, int pw
const bool highlight = params->toneCurve.hrenabled; //Get the value if "highlight reconstruction" is activated
const int gamu = (params->colorappearance.gamut) ? 1 : 0;
xw = 100.0f * Xw;
yw = 100.0f * Yw;
zw = 100.0f * Zw;
xw = 100.0 * Xw;
yw = 100.0 * Yw;
zw = 100.0 * Zw;
float xw1 = 0.f, yw1 = 0.f, zw1 = 0.f, xw2 = 0.f, yw2 = 0.f, zw2 = 0.f;
// settings of WB: scene and viewing
@@ -2002,9 +2000,9 @@ void ImProcFunctions::moyeqt (Imagefloat* working, float &moyS, float &eqty)
for (int i = 0; i < tHh; i++) {
for (int j = 0; j < tWw; j++) {
float s = Color::rgb2s (CLIP (working->r (i, j)), CLIP (working->g (i, j)), CLIP (working->b (i, j)));
double s = Color::rgb2s (CLIP (working->r (i, j)), CLIP (working->g (i, j)), CLIP (working->b (i, j)));
moy += s;
sqrs += SQR (s);
sqrs += SQR(s);
}
}
@@ -2108,17 +2106,17 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer
float toxyz[3][3] = {
{
static_cast<float> ( wprof[0][0] / Color::D50x),
static_cast<float> ( wprof[0][1] / Color::D50x),
static_cast<float> ( wprof[0][2] / Color::D50x)
static_cast<float>(wprof[0][0] / static_cast<double>(Color::D50x)),
static_cast<float>(wprof[0][1] / static_cast<double>(Color::D50x)),
static_cast<float>(wprof[0][2] / static_cast<double>(Color::D50x))
}, {
static_cast<float> ( wprof[1][0]),
static_cast<float> ( wprof[1][1]),
static_cast<float> ( wprof[1][2])
static_cast<float>(wprof[1][0]),
static_cast<float>(wprof[1][1]),
static_cast<float>(wprof[1][2])
}, {
static_cast<float> ( wprof[2][0] / Color::D50z),
static_cast<float> ( wprof[2][1] / Color::D50z),
static_cast<float> ( wprof[2][2] / Color::D50z)
static_cast<float>(wprof[2][0] / static_cast<double>(Color::D50z)),
static_cast<float>(wprof[2][1] / static_cast<double>(Color::D50z)),
static_cast<float>(wprof[2][2] / static_cast<double>(Color::D50z))
}
};
float maxFactorToxyz = max (toxyz[1][0], toxyz[1][1], toxyz[1][2]);
@@ -2238,10 +2236,10 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer
const float film_simulation_strength = static_cast<float> (params->filmSimulation.strength) / 100.0f;
const float exp_scale = pow (2.0, expcomp);
const float comp = (max (0.0, expcomp) + 1.0) * hlcompr / 100.0;
const float shoulder = ((65536.0 / max (1.0f, exp_scale)) * (hlcomprthresh / 200.0)) + 0.1;
const float hlrange = 65536.0 - shoulder;
const float exp_scale = pow(2.0, expcomp);
const float comp = (max(0.0, expcomp) + 1.0) * hlcompr / 100.0;
const float shoulder = ((65536.f / max(1.0f, exp_scale)) * (hlcomprthresh / 200.f)) + 0.1f;
const float hlrange = 65536.f - shoulder;
const bool isProPhoto = (params->icm.workingProfile == "ProPhoto");
// extracting data from 'params' to avoid cache flush (to be confirmed)
ToneCurveMode curveMode = params->toneCurve.curveMode;
@@ -2303,43 +2301,43 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer
}
*/
float RedLow = params->colorToning.redlow / 100.f;
float GreenLow = params->colorToning.greenlow / 100.f;
float BlueLow = params->colorToning.bluelow / 100.f;
float RedMed = params->colorToning.redmed / 100.f;
float GreenMed = params->colorToning.greenmed / 100.f;
float BlueMed = params->colorToning.bluemed / 100.f;
float RedHigh = params->colorToning.redhigh / 100.f;
float GreenHigh = params->colorToning.greenhigh / 100.f;
float BlueHigh = params->colorToning.bluehigh / 100.f;
float SatLow = float (params->colorToning.shadowsColSat.getBottom()) / 100.f;
float SatHigh = float (params->colorToning.hlColSat.getBottom()) / 100.f;
float RedLow = params->colorToning.redlow / 100.0;
float GreenLow = params->colorToning.greenlow / 100.0;
float BlueLow = params->colorToning.bluelow / 100.0;
float RedMed = params->colorToning.redmed / 100.0;
float GreenMed = params->colorToning.greenmed / 100.0;
float BlueMed = params->colorToning.bluemed / 100.0;
float RedHigh = params->colorToning.redhigh / 100.0;
float GreenHigh = params->colorToning.greenhigh / 100.0;
float BlueHigh = params->colorToning.bluehigh / 100.0;
float SatLow = params->colorToning.shadowsColSat.getBottom() / 100.f;
float SatHigh = params->colorToning.hlColSat.getBottom() / 100.f;
float Balan = float (params->colorToning.balance);
float Balan = params->colorToning.balance;
float chMixRR = float (params->chmixer.red[0])/10.f;
float chMixRG = float (params->chmixer.red[1])/10.f;
float chMixRB = float (params->chmixer.red[2])/10.f;
float chMixGR = float (params->chmixer.green[0])/10.f;
float chMixGG = float (params->chmixer.green[1])/10.f;
float chMixGB = float (params->chmixer.green[2])/10.f;
float chMixBR = float (params->chmixer.blue[0])/10.f;
float chMixBG = float (params->chmixer.blue[1])/10.f;
float chMixBB = float (params->chmixer.blue[2])/10.f;
float chMixRR = params->chmixer.red[0] / 10.f;
float chMixRG = params->chmixer.red[1] / 10.f;
float chMixRB = params->chmixer.red[2] / 10.f;
float chMixGR = params->chmixer.green[0] / 10.f;
float chMixGG = params->chmixer.green[1] / 10.f;
float chMixGB = params->chmixer.green[2] / 10.f;
float chMixBR = params->chmixer.blue[0] / 10.f;
float chMixBG = params->chmixer.blue[1] / 10.f;
float chMixBB = params->chmixer.blue[2] / 10.f;
bool blackwhite = params->blackwhite.enabled;
bool complem = params->blackwhite.enabledcc;
float bwr = float (params->blackwhite.mixerRed);
float bwg = float (params->blackwhite.mixerGreen);
float bwb = float (params->blackwhite.mixerBlue);
float bwrgam = float (params->blackwhite.gammaRed);
float bwggam = float (params->blackwhite.gammaGreen);
float bwbgam = float (params->blackwhite.gammaBlue);
float mixerOrange = float (params->blackwhite.mixerOrange);
float mixerYellow = float (params->blackwhite.mixerYellow);
float mixerCyan = float (params->blackwhite.mixerCyan);
float mixerMagenta = float (params->blackwhite.mixerMagenta);
float mixerPurple = float (params->blackwhite.mixerPurple);
float bwr = params->blackwhite.mixerRed;
float bwg = params->blackwhite.mixerGreen;
float bwb = params->blackwhite.mixerBlue;
float bwrgam = params->blackwhite.gammaRed;
float bwggam = params->blackwhite.gammaGreen;
float bwbgam = params->blackwhite.gammaBlue;
float mixerOrange = params->blackwhite.mixerOrange;
float mixerYellow = params->blackwhite.mixerYellow;
float mixerCyan = params->blackwhite.mixerCyan;
float mixerMagenta = params->blackwhite.mixerMagenta;
float mixerPurple = params->blackwhite.mixerPurple;
int algm = 0;
if (params->blackwhite.method == "Desaturation") {
@@ -2720,7 +2718,7 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer
//HSV equalizer
if (hCurveEnabled) {
h = (hCurve->getVal (double (h)) - 0.5) * 2.f + h;
h = (hCurve->getVal(h) - 0.5) * 2.0 + static_cast<double>(h);
if (h > 1.0f) {
h -= 1.0f;
@@ -2751,7 +2749,7 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer
}
//shift value
float valparam = vCurve->getVal ((double)h) - 0.5f;
float valparam = vCurve->getVal(h) - 0.5;
valparam *= (1.f - SQR (SQR (1.f - min (s, 1.0f))));
if (valparam > 0.00001f) {
@@ -3063,7 +3061,7 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer
if (bwlCurveEnabled) {
L /= 32768.f;
double hr = Color::huelab_to_huehsv2 (HH);
float valparam = float ((bwlCurve->getVal (hr) - 0.5f) * 2.0f); //get l_r=f(H)
float valparam = (bwlCurve->getVal(hr) - 0.5) * 2.0; //get l_r=f(H)
float kcc = (CC / 70.f); //take Chroma into account...70 "middle" of chromaticity (arbitrary and simple), one can imagine other algorithme
//reduct action for low chroma and increase action for high chroma
valparam *= kcc;
@@ -3317,9 +3315,9 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer
for (int i = 0; i < tH; i++) {
for (int j = 0; j < tW; j++) {
nr += tmpImage->r (i, j);
ng += tmpImage->g (i, j);
nb += tmpImage->b (i, j);
nr += static_cast<double>(tmpImage->r(i, j));
ng += static_cast<double>(tmpImage->g(i, j));
nb += static_cast<double>(tmpImage->b(i, j));
}
}
@@ -4386,8 +4384,7 @@ void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBuffer, int pW
float factnoise = 1.f;
if (params->dirpyrDenoise.enabled) {
factnoise = (1.f + params->dirpyrDenoise.chroma / 500.f); //levels=5
// if(yyyy) factnoise=(1.f+params->dirpyrDenoise.chroma/100.f);//levels=7
factnoise = 1.0 + params->dirpyrDenoise.chroma / 500.0; //levels=5
}
const float scaleConst = 100.0f / 100.1f;
@@ -4565,7 +4562,7 @@ void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBuffer, int pW
float l_r;//Luminance Lab in 0..1
l_r = Lprov1 / 100.f;
{
float valparam = float ((lhCurve->getVal (Color::huelab_to_huehsv2 (HH)) - 0.5f)); //get l_r=f(H)
float valparam = lhCurve->getVal(Color::huelab_to_huehsv2(HH)) - 0.5; //get l_r=f(H)
float valparamneg;
valparamneg = valparam;
float kcc = (CC / amountchroma); //take Chroma into account...40 "middle low" of chromaticity (arbitrary and simple), one can imagine other algorithme
@@ -4598,9 +4595,9 @@ void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBuffer, int pW
float fx = (0.002f * aprov1) + fy;
float fz = fy - (0.005f * bprov1);
float x_ = 65535.0f * Color::f2xyz (fx) * Color::D50x;
float z_ = 65535.0f * Color::f2xyz (fz) * Color::D50z;
float y_ = (Lprov1 > Color::epskap) ? 65535.0 * fy * fy * fy : 65535.0 * Lprov1 / Color::kappa;
float x_ = 65535.f * Color::f2xyz (fx) * Color::D50x;
float z_ = 65535.f * Color::f2xyz (fz) * Color::D50z;
float y_ = Lprov1 > Color::epskapf ? 65535.f * fy * fy * fy : 65535.f * Lprov1 / Color::kappaf;
float R, G, B;
Color::xyz2rgb (x_, y_, z_, R, G, B, wip);
@@ -4628,7 +4625,7 @@ void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBuffer, int pW
// calculate C=f(H)
if (chutili) {
double hr = Color::huelab_to_huehsv2 (HH);
float chparam = float ((chCurve->getVal (hr) - 0.5f) * 2.0f); //get C=f(H)
float chparam = (chCurve->getVal(hr) - 0.5) * 2.0; //get C=f(H)
float chromaChfactor = 1.0f + chparam;
atmp *= chromaChfactor;//apply C=f(H)
btmp *= chromaChfactor;
@@ -4636,9 +4633,9 @@ void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBuffer, int pW
if (hhutili) { // H=f(H)
//hue Lab in -PI +PI
float valparam = float ((hhCurve->getVal (Color::huelab_to_huehsv2 (HH)) - 0.5f) * 1.7f) + HH; //get H=f(H) 1.7 optimisation !
float valparam = (hhCurve->getVal(Color::huelab_to_huehsv2(HH)) - 0.5) * 1.7 + static_cast<double>(HH); //get H=f(H) 1.7 optimisation !
HH = valparam;
sincosval = xsincosf (HH);
sincosval = xsincosf(HH);
}
if (!bwToning) {
@@ -4714,11 +4711,11 @@ void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBuffer, int pW
deltaHH = protect_redhcur; //transition hue
if (chromaCfactor > 0.0) {
if (chromaCfactor > 0.f) {
Color::scalered ( rstprotection, chromaCfactor, 0.0, HH, deltaHH, scale, scaleext); //1.0
}
if (chromaCfactor > 1.0) {
if (chromaCfactor > 1.f) {
float interm = (chromaCfactor - 1.0f) * 100.0f;
factorskin = 1.0f + (interm * scale) / 100.0f;
factorskinext = 1.0f + (interm * scaleext) / 100.0f;
@@ -4775,11 +4772,11 @@ void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBuffer, int pW
deltaHH = protect_redhcur; //transition hue
if (chromaCfactor > 0.0) {
if (chromaCfactor > 0.f) {
Color::scalered ( rstprotection, chromaCfactor, 0.0, HH, deltaHH, scale, scaleext); //1.0
}
if (chromaCfactor > 1.0) {
if (chromaCfactor > 1.f) {
float interm = (chromaCfactor - 1.0f) * 100.0f;
factorskin = 1.0f + (interm * scale) / 100.0f;
factorskinext = 1.0f + (interm * scaleext) / 100.0f;
@@ -5062,7 +5059,7 @@ void ImProcFunctions::impulsedenoise (LabImage* lab)
if (params->impulseDenoise.enabled && lab->W >= 8 && lab->H >= 8)
{
impulse_nr (lab, (float)params->impulseDenoise.thresh / 20.0 );
impulse_nr(lab, params->impulseDenoise.thresh / 20.0);
}
}
@@ -5072,7 +5069,7 @@ void ImProcFunctions::impulsedenoisecam (CieImage* ncie, float **buffers[3])
if (params->impulseDenoise.enabled && ncie->W >= 8 && ncie->H >= 8)
{
impulse_nrcam (ncie, (float)params->impulseDenoise.thresh / 20.0, buffers );
impulse_nrcam(ncie, params->impulseDenoise.thresh / 20.0, buffers);
}
}
@@ -5142,11 +5139,11 @@ void ImProcFunctions::EPDToneMapCIE (CieImage *ncie, float a_w, float c_, int Wi
float sca = params->epd.scale;
float gamm = params->epd.gamma;
float rew = params->epd.reweightingIterates;
float Qpro = ( 4.0 / c_) * ( a_w + 4.0 ) ; //estimate Q max if J=100.0
float Qpro = (4.f / c_) * (a_w + 4.f) ; //estimate Q max if J=100.0
float *Qpr = ncie->Q_p[0];
if (settings->verbose) {
printf ("minQ=%f maxQ=%f Qpro=%f\n", minQ, maxQ, Qpro);
printf ("minQ=%f maxQ=%f Qpro=%f\n", static_cast<double>(minQ), static_cast<double>(maxQ), static_cast<double>(Qpro));
}
if (maxQ > Qpro) {
@@ -5173,7 +5170,7 @@ void ImProcFunctions::EPDToneMapCIE (CieImage *ncie, float a_w, float c_, int Wi
//Auto select number of iterates. Note that p->EdgeStopping = 0 makes a Gaussian blur.
if (Iterates == 0) {
Iterates = (unsigned int) (edgest * 15.0);
Iterates = edgest * 15.f;
}
//Jacques Desmis : always Iterates=5 for compatibility images between preview and output
@@ -5400,7 +5397,7 @@ void ImProcFunctions::getAutoExp (const LUTu &histogram, int histcompr, double
octile[count] += histogram[j];
if (octile[count] > sum / 8.f || (count == 7 && octile[count] > sum / 16.f)) {
octile[count] = xlog (1. + j) / log (2.f);
octile[count] = xlog(1. + j) / log(2.0);
count++;// = min(count+1,7);
}
}
@@ -5413,7 +5410,7 @@ void ImProcFunctions::getAutoExp (const LUTu &histogram, int histcompr, double
octile[count] += histogram[j];
if (octile[count] > sum / 8.f || (count == 7 && octile[count] > sum / 16.f)) {
octile[count] = xlog (1. + j) / log (2.f);
octile[count] = xlog(1. + j) / log(2.0);
count++;// = min(count+1,7);
}
}
@@ -5488,7 +5485,7 @@ void ImProcFunctions::getAutoExp (const LUTu &histogram, int histcompr, double
}
//compute clipped white point
unsigned int clippable = (int) (sum * clip / 100.f );
unsigned int clippable = (int) (static_cast<double>(sum) * clip / 100.0 );
clipped = 0;
int whiteclip = (imax) - 1;
@@ -5547,8 +5544,8 @@ void ImProcFunctions::getAutoExp (const LUTu &histogram, int histcompr, double
hlcomprthresh = 0;
//this is a series approximation of the actual formula for comp,
//which is a transcendental equation
float comp = (gain * ((float)whiteclip) / scale - 1.f) * 2.3f; // 2.3 instead of 2 to increase slightly comp
hlcompr = (int) (100.*comp / (max (0.0, expcomp) + 1.0));
double comp = (gain * whiteclip / scale - 1.f) * 2.3f; // 2.3 instead of 2 to increase slightly comp
hlcompr = 100.0 * comp / (max(0.0, expcomp) + 1.0);
hlcompr = max (0, min (100, hlcompr));
//now find brightness if gain didn't bring ave to midgray using
@@ -5556,9 +5553,9 @@ void ImProcFunctions::getAutoExp (const LUTu &histogram, int histcompr, double
float midtmp = gain * sqrt (median * ave) / scale;
if (midtmp < 0.1f) {
bright = (midgray - midtmp) * 15.0 / (midtmp);
bright = (midgray - midtmp) * 15.f / (midtmp);
} else {
bright = (midgray - midtmp) * 15.0 / (0.10833 - 0.0833 * midtmp);
bright = (midgray - midtmp) * 15.f / (0.10833f - 0.0833f * midtmp);
}
bright = 0.25 */*(median/ave)*(hidev/lodev)*/max (0, bright);
@@ -5567,7 +5564,7 @@ void ImProcFunctions::getAutoExp (const LUTu &histogram, int histcompr, double
contr = (int) 50.0f * (1.1f - ospread);
contr = max (0, min (100, contr));
//take gamma into account
double whiteclipg = (int) (CurveFactory::gamma2 (whiteclip * corr / 65536.0) * 65536.0);
double whiteclipg = (int) (CurveFactory::gamma2(whiteclip * static_cast<double>(corr) / 65536.0) * 65536.0);
float gavg = 0.;
@@ -5589,7 +5586,7 @@ void ImProcFunctions::getAutoExp (const LUTu &histogram, int histcompr, double
}
}
whiteclipg = CurveFactory::igamma2 ((float) (whiteclipg / 65535.0)) * 65535.0; //need to inverse gamma transform to get correct exposure compensation parameter
whiteclipg = CurveFactory::igamma2(whiteclipg / 65535.0) * 65535.0; //need to inverse gamma transform to get correct exposure compensation parameter
//correction with gamma
black = (int) ((65535 * black) / whiteclipg);
@@ -5824,8 +5821,8 @@ void ImProcFunctions::lab2rgb (const LabImage &src, Imagefloat &dst, const Glib:
*/
void ImProcFunctions::colorToningLabGrid(LabImage *lab, int xstart, int xend, int ystart, int yend, bool MultiThread)
{
const float factor = ColorToningParams::LABGRID_CORR_MAX * 3.f;
const float scaling = ColorToningParams::LABGRID_CORR_SCALE;
const double factor = ColorToningParams::LABGRID_CORR_MAX * 3.0;
const double scaling = ColorToningParams::LABGRID_CORR_SCALE;
float a_scale = (params->colorToning.labgridAHigh - params->colorToning.labgridALow) / factor / scaling;
float a_base = params->colorToning.labgridALow / scaling;
float b_scale = (params->colorToning.labgridBHigh - params->colorToning.labgridBLow) / factor / scaling;