merge with dev

This commit is contained in:
Desmis 2020-07-14 07:42:15 +02:00
commit 2a5ce3c0ba
10 changed files with 239 additions and 753 deletions

View File

@ -37,6 +37,33 @@
using namespace std;
namespace {
void fillCurveArray(const rtengine::DiagonalCurve* diagCurve, LUTf &outCurve, int skip, bool needed)
{
if (needed) {
for (int i = 0; i <= 0xffff; i += i < 0xffff - skip ? skip : 1) {
// change to [0,1] range
// apply custom/parametric/NURBS curve, if any
outCurve[i] = diagCurve->getVal(i / 65535.f);
}
// if skip > 1, let apply linear interpolation in the skipped points of the curve
if (skip > 1) {
const float skipmul = 1.f / skip;
for (int i = 0; i <= 0x10000 - skip; i += skip) {
for (int j = 1; j < skip; j++) {
outCurve[i + j] = (outCurve[i] * (skip - j) + outCurve[i + skip] * j) * skipmul;
}
}
}
outCurve *= 65535.f;
} else {
outCurve.makeIdentity();
}
}
}
namespace rtengine
{
bool sanitizeCurve(std::vector<double>& curve)
@ -200,35 +227,6 @@ void Curve::getControlPoint(int cpNum, double &x, double &y) const
const double CurveFactory::sRGBGamma = 2.2;
const double CurveFactory::sRGBGammaCurve = 2.4;
void fillCurveArray(DiagonalCurve* diagCurve, LUTf &outCurve, int skip, bool needed)
{
if (needed) {
for (int i = 0; i <= 0xffff; i += i < 0xffff - skip ? skip : 1) {
// change to [0,1] range
float val = (float)i / 65535.f;
// apply custom/parametric/NURBS curve, if any
val = diagCurve->getVal(val);
// store result in a temporary array
outCurve[i] = val;
}
// if skip>1, let apply linear interpolation in the skipped points of the curve
if (skip > 1) {
float skipmul = 1.f / (float) skip;
for (int i = 0; i <= 0x10000 - skip; i += skip) {
for (int j = 1; j < skip; j++) {
outCurve[i + j] = (outCurve[i] * (skip - j) + outCurve[i + skip] * j) * skipmul;
}
}
}
outCurve *= 65535.f;
} else {
outCurve.makeIdentity();
}
}
void CurveFactory::curveLightBrightColor(const std::vector<double>& curvePoints1, const std::vector<double>& curvePoints2, const std::vector<double>& curvePoints3,
const LUTu & histogram, LUTu & outBeforeCCurveHistogram,//for Luminance
const LUTu & histogramC, LUTu & outBeforeCCurveHistogramC,//for chroma
@ -334,113 +332,34 @@ void CurveFactory::curveBW(const std::vector<double>& curvePointsbw, const std::
}
}
// add curve Lab : C=f(L)
void CurveFactory::curveCL(bool & clcutili, const std::vector<double>& clcurvePoints, LUTf & clCurve, int skip)
{
clcutili = false;
std::unique_ptr<DiagonalCurve> dCurve;
if (!clcurvePoints.empty() && clcurvePoints[0] != 0) {
dCurve = std::unique_ptr<DiagonalCurve> (new DiagonalCurve(clcurvePoints, CURVES_MIN_POLY_POINTS / skip));
if (dCurve && !dCurve->isIdentity()) {
clcutili = true;
}
}
fillCurveArray(dCurve.get(), clCurve, skip, clcutili);
}
void CurveFactory::mapcurve(bool & mapcontlutili, const std::vector<double>& mapcurvePoints, LUTf & mapcurve, int skip, const LUTu & histogram, LUTu & outBeforeCurveHistogram)
bool CurveFactory::diagonalCurve2Lut(const std::vector<double>& curvePoints, LUTf & curve, int skip, const LUTu & histogram, LUTu & outBeforeCurveHistogram)
{
bool needed = false;
std::unique_ptr<DiagonalCurve> dCurve;
outBeforeCurveHistogram.clear();
bool histNeeded = false;
if (!mapcurvePoints.empty() && mapcurvePoints[0] != 0) {
dCurve = std::unique_ptr<DiagonalCurve> (new DiagonalCurve(mapcurvePoints, CURVES_MIN_POLY_POINTS / skip));
if (outBeforeCurveHistogram) {
histNeeded = true;
}
if (dCurve && !dCurve->isIdentity()) {
needed = true;
mapcontlutili = true;
}
}
if (histNeeded) {
histogram.compressTo(outBeforeCurveHistogram, 32768);
}
fillCurveArray(dCurve.get(), mapcurve, skip, needed);
}
void CurveFactory::curveDehaContL(bool & dehacontlutili, const std::vector<double>& dehaclcurvePoints, LUTf & dehaclCurve, int skip, const LUTu & histogram, LUTu & outBeforeCurveHistogram)
{
bool needed = false;
std::unique_ptr<DiagonalCurve> dCurve;
outBeforeCurveHistogram.clear();
bool histNeeded = false;
if (!dehaclcurvePoints.empty() && dehaclcurvePoints[0] != 0) {
dCurve = std::unique_ptr<DiagonalCurve> (new DiagonalCurve(dehaclcurvePoints, CURVES_MIN_POLY_POINTS / skip));
if (outBeforeCurveHistogram) {
histNeeded = true;
}
if (dCurve && !dCurve->isIdentity()) {
needed = true;
dehacontlutili = true;
}
}
if (histNeeded) {
histogram.compressTo(outBeforeCurveHistogram, 32768);
}
fillCurveArray(dCurve.get(), dehaclCurve, skip, needed);
}
// add curve Lab wavelet : Cont=f(L)
void CurveFactory::curveWavContL(bool & wavcontlutili, const std::vector<double>& wavclcurvePoints, LUTf & wavclCurve, /*LUTu & histogramwavcl, LUTu & outBeforeWavCLurveHistogram,*/int skip)
{
bool needed = false;
std::unique_ptr<DiagonalCurve> dCurve;
if (!wavclcurvePoints.empty() && wavclcurvePoints[0] != 0) {
dCurve = std::unique_ptr<DiagonalCurve> (new DiagonalCurve(wavclcurvePoints, CURVES_MIN_POLY_POINTS / skip));
if (dCurve && !dCurve->isIdentity()) {
needed = true;
wavcontlutili = true;
}
}
fillCurveArray(dCurve.get(), wavclCurve, skip, needed);
}
// add curve Colortoning : C=f(L) and CLf(L)
void CurveFactory::curveToning(const std::vector<double>& curvePoints, LUTf & ToningCurve, int skip)
{
bool needed = false;
std::unique_ptr<DiagonalCurve> dCurve;
if (!curvePoints.empty() && curvePoints[0] != 0) {
dCurve = std::unique_ptr<DiagonalCurve> (new DiagonalCurve(curvePoints, CURVES_MIN_POLY_POINTS / skip));
dCurve.reset(new DiagonalCurve(curvePoints, CURVES_MIN_POLY_POINTS / skip));
if (outBeforeCurveHistogram) {
histNeeded = true;
}
if (dCurve && !dCurve->isIdentity()) {
needed = true;
}
}
fillCurveArray(dCurve.get(), ToningCurve, skip, needed);
if (histNeeded) {
histogram.compressTo(outBeforeCurveHistogram, 32768);
}
fillCurveArray(dCurve.get(), curve, skip, needed);
return needed;
}
bool CurveFactory::curveLocal(const std::vector<double>& curvePoints, LUTf& LocalCurve, int skip)
bool CurveFactory::diagonalCurve2Lut(const std::vector<double>& curvePoints, LUTf& curve, int skip)
{
bool needed = false;
std::unique_ptr<DiagonalCurve> dCurve;
@ -453,217 +372,11 @@ bool CurveFactory::curveLocal(const std::vector<double>& curvePoints, LUTf& Loca
}
}
fillCurveArray(dCurve.get(), LocalCurve, skip, needed);
fillCurveArray(dCurve.get(), curve, skip, needed);
return needed;
}
void CurveFactory::curveskLocal(bool & localskutili, const std::vector<double>& curvePoints, LUTf & LocalskCurve, int skip)
{
bool needed = false;
std::unique_ptr<DiagonalCurve> dCurve;
// if (localskutili && !curvePoints.empty() && curvePoints[0] != 0) {
if (!curvePoints.empty() && curvePoints[0] != 0) {
dCurve = std::unique_ptr<DiagonalCurve> (new DiagonalCurve(curvePoints, CURVES_MIN_POLY_POINTS / skip));
if (dCurve && !dCurve->isIdentity()) {
needed = true;
localskutili = true;
}
}
fillCurveArray(dCurve.get(), LocalskCurve, skip, needed);
}
void CurveFactory::localLCurve(double br, double contr, /*const std::vector<double>& curvePoints,*/
LUTu & histogram, LUTf & outCurve,
int skip, bool & utili)
{
// curve without contrast
LUTf dcurve(65536, 0);
// clear array that stores histogram valid before applying the custom curve
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// tone curve base. a: slope (from exp.comp.), b: black, def_mul: max. x value (can be>1), hr,sr: highlight,shadow recovery
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// check if brightness curve is needed
if (br > 0.00001 || br < -0.00001) {
utili = true;
std::vector<double> brightcurvePoints;
brightcurvePoints.resize(9);
brightcurvePoints.at(0) = double (DCT_NURBS);
brightcurvePoints.at(1) = 0.; // black point. Value in [0 ; 1] range
brightcurvePoints.at(2) = 0.; // black point. Value in [0 ; 1] range
if (br > 0) {
brightcurvePoints.at(3) = 0.1; // toe point
brightcurvePoints.at(4) = 0.1 + br / 150.0; //value at toe point
brightcurvePoints.at(5) = 0.7; // shoulder point
brightcurvePoints.at(6) = min(1.0, 0.7 + br / 300.0); //value at shoulder point
} else {
brightcurvePoints.at(3) = 0.1 - br / 150.0; // toe point
brightcurvePoints.at(4) = 0.1; // value at toe point
brightcurvePoints.at(5) = min(1.0, 0.7 - br / 300.0); // shoulder point
brightcurvePoints.at(6) = 0.7; // value at shoulder point
}
brightcurvePoints.at(7) = 1.; // white point
brightcurvePoints.at(8) = 1.; // value at white point
DiagonalCurve* brightcurve = new DiagonalCurve(brightcurvePoints, CURVES_MIN_POLY_POINTS / skip);
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// Applying brightness curve
for (int i = 0; i < 32768; i++) { // L values range up to 32767, higher values are for highlight overflow
// change to [0,1] range
float val = (float)i / 32767.0;
// apply brightness curve
val = brightcurve->getVal(val);
// store result in a temporary array
dcurve[i] = val;
}
delete brightcurve;
} else {
for (int i = 0; i < 32768; i++) { // L values range up to 32767, higher values are for highlight overflow
// set the identity curve in the temporary array
dcurve[i] = (float)i / 32767.0;
}
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// check if contrast curve is needed
if (contr > 0.00001 || contr < -0.00001) {
utili = true;
DiagonalCurve* contrastcurve = NULL;
// compute mean luminance of the image with the curve applied
int sum = 0;
float avg = 0;
//float sqavg = 0;
for (int i = 0; i < 32768; i++) {
avg += dcurve[i] * histogram[i];
//sqavg += dcurve[i]*dcurve[i] * histogram[i];
sum += histogram[i];
}
if (sum) {
avg /= sum;
//sqavg /= sum;
//float stddev = sqrt(sqavg-avg*avg);
// printf("avg=%f\n",avg);
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
std::vector<double> contrastcurvePoints;
contrastcurvePoints.resize(9);
contrastcurvePoints.at(0) = double (DCT_NURBS);
contrastcurvePoints.at(1) = 0.; // black point. Value in [0 ; 1] range
contrastcurvePoints.at(2) = 0.; // black point. Value in [0 ; 1] range
contrastcurvePoints.at(3) = avg - avg * (0.6 - contr / 250.0); // toe point
contrastcurvePoints.at(4) = avg - avg * (0.6 + contr / 250.0); // value at toe point
contrastcurvePoints.at(5) = avg + (1 - avg) * (0.6 - contr / 250.0); // shoulder point
contrastcurvePoints.at(6) = avg + (1 - avg) * (0.6 + contr / 250.0); // value at shoulder point
contrastcurvePoints.at(7) = 1.; // white point
contrastcurvePoints.at(8) = 1.; // value at white point
contrastcurve = new DiagonalCurve(contrastcurvePoints, CURVES_MIN_POLY_POINTS / skip);
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
} else {
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// sum has an invalid value (next to 0, producing a division by zero, so we create a fake contrast curve, producing a white image
std::vector<double> contrastcurvePoints;
contrastcurvePoints.resize(5);
contrastcurvePoints.at(0) = double (DCT_NURBS);
contrastcurvePoints.at(1) = 0.; // black point. Value in [0 ; 1] range
contrastcurvePoints.at(2) = 1.; // black point. Value in [0 ; 1] range
contrastcurvePoints.at(3) = 1.; // white point
contrastcurvePoints.at(4) = 1.; // value at white point
contrastcurve = new DiagonalCurve(contrastcurvePoints, CURVES_MIN_POLY_POINTS / skip);
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
}
// apply contrast enhancement
for (int i = 0; i < 32768; i++) {
dcurve[i] = contrastcurve->getVal(dcurve[i]);
}
delete contrastcurve;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// create a curve if needed
/* DiagonalCurve* tcurve = NULL;
bool histNeeded = false;
if (!curvePoints.empty() && curvePoints[0]!=0) {
tcurve = new DiagonalCurve (curvePoints, CURVES_MIN_POLY_POINTS/skip);
}
if (tcurve && tcurve->isIdentity()) {
delete tcurve;
tcurve = NULL;
}
if (tcurve) {
utili=true;//if active
// L values go up to 32767, last stop is for highlight overflow
for (int i=0; i<32768; i++) {
float val;
// apply custom/parametric/NURBS curve, if any
val = tcurve->getVal (dcurve[i]);
outCurve[i] = (32767.0 * val);
}
}
else
*/
{
// Skip the slow getval method if no curve is used (or an identity curve)
// L values go up to 32767, last stop is for highlight overflow
for (int i = 0; i < 32768; i++) {
outCurve[i] = 32767.0 * dcurve[i];
}
}
for (int i = 32768; i < 65536; i++) {
outCurve[i] = (float)i;
}
// if (tcurve)
// delete tcurve;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void CurveFactory::complexsgnCurve(bool & autili, bool & butili, bool & ccutili, bool & cclutili,
const std::vector<double>& acurvePoints, const std::vector<double>& bcurvePoints, const std::vector<double>& cccurvePoints,
const std::vector<double>& lccurvePoints, LUTf & aoutCurve, LUTf & boutCurve, LUTf & satCurve, LUTf & lhskCurve,
@ -675,7 +388,7 @@ void CurveFactory::complexsgnCurve(bool & autili, bool & butili, bool & ccutili
// create a curve if needed
if (!acurvePoints.empty() && acurvePoints[0] != 0) {
dCurve = std::unique_ptr<DiagonalCurve> (new DiagonalCurve(acurvePoints, CURVES_MIN_POLY_POINTS / skip));
dCurve.reset(new DiagonalCurve(acurvePoints, CURVES_MIN_POLY_POINTS / skip));
if (dCurve && !dCurve->isIdentity()) {
autili = true;
@ -684,12 +397,12 @@ void CurveFactory::complexsgnCurve(bool & autili, bool & butili, bool & ccutili
fillCurveArray(dCurve.get(), aoutCurve, skip, autili);
dCurve = nullptr;
dCurve.reset();
//-----------------------------------------------------
if (!bcurvePoints.empty() && bcurvePoints[0] != 0) {
dCurve = std::unique_ptr<DiagonalCurve> (new DiagonalCurve(bcurvePoints, CURVES_MIN_POLY_POINTS / skip));
dCurve.reset(new DiagonalCurve(bcurvePoints, CURVES_MIN_POLY_POINTS / skip));
if (dCurve && !dCurve->isIdentity()) {
butili = true;
@ -698,12 +411,12 @@ void CurveFactory::complexsgnCurve(bool & autili, bool & butili, bool & ccutili
fillCurveArray(dCurve.get(), boutCurve, skip, butili);
dCurve = nullptr;
dCurve.reset();
//-----------------------------------------------
if (!cccurvePoints.empty() && cccurvePoints[0] != 0) {
dCurve = std::unique_ptr<DiagonalCurve> (new DiagonalCurve(cccurvePoints, CURVES_MIN_POLY_POINTS / skip));
dCurve.reset(new DiagonalCurve(cccurvePoints, CURVES_MIN_POLY_POINTS / skip));
if (dCurve && !dCurve->isIdentity()) {
ccutili = true;
@ -712,12 +425,12 @@ void CurveFactory::complexsgnCurve(bool & autili, bool & butili, bool & ccutili
fillCurveArray(dCurve.get(), satCurve, skip, ccutili);
dCurve = nullptr;
dCurve.reset();
//----------------------------
if (!lccurvePoints.empty() && lccurvePoints[0] != 0) {
dCurve = std::unique_ptr<DiagonalCurve> (new DiagonalCurve(lccurvePoints, CURVES_MIN_POLY_POINTS / skip));
dCurve.reset(new DiagonalCurve(lccurvePoints, CURVES_MIN_POLY_POINTS / skip));
if (dCurve && !dCurve->isIdentity()) {
cclutili = true;
@ -755,9 +468,7 @@ void CurveFactory::complexCurve (double ecomp, double black, double hlcompr, dou
// clear array that stores histogram valid before applying the custom curve
outBeforeCCurveHistogram.clear();
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// tone curve base. a: slope (from exp.comp.), b: black, def_mul: max. x value (can be>1), hr,sr: highlight,shadow recovery
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
std::unique_ptr<DiagonalCurve> brightcurve;
@ -787,11 +498,9 @@ void CurveFactory::complexCurve (double ecomp, double black, double hlcompr, dou
brightcurvePoints[7] = 1.; // white point
brightcurvePoints[8] = 1.; // value at white point
brightcurve = std::unique_ptr<DiagonalCurve> (new DiagonalCurve(brightcurvePoints, CURVES_MIN_POLY_POINTS / skip));
brightcurve.reset(new DiagonalCurve(brightcurvePoints, CURVES_MIN_POLY_POINTS / skip));
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
hlCurve.setClip(LUT_CLIP_BELOW); // used LUT_CLIP_BELOW, because we want to have a baseline of 2^expcomp in this curve. If we don't clip the lut we get wrong values, see Issue 2621 #14 for details
float exp_scale = a;
float scale = 65536.0;
@ -849,7 +558,6 @@ void CurveFactory::complexCurve (double ecomp, double black, double hlcompr, dou
// curve without contrast
LUTf dcurve(0x10000);
//%%%%%%%%%%%%%%%%%%%%%%%%%%
// change to [0,1] range
shCurve.setClip(LUT_CLIP_ABOVE); // used LUT_CLIP_ABOVE, because the curve converges to 1.0 at the upper end and we don't want to exceed this value.
if (black == 0.0) {
@ -889,11 +597,7 @@ void CurveFactory::complexCurve (double ecomp, double black, double hlcompr, dou
dcurve[i] = val;
}
brightcurve = nullptr;
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
brightcurve.reset();
// check if contrast curve is needed
if (contr > 0.00001 || contr < -0.00001) {
@ -910,7 +614,6 @@ void CurveFactory::complexCurve (double ecomp, double black, double hlcompr, dou
avg /= sum;
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
std::vector<double> contrastcurvePoints(9);
contrastcurvePoints[0] = DCT_NURBS;
@ -928,15 +631,12 @@ void CurveFactory::complexCurve (double ecomp, double black, double hlcompr, dou
const DiagonalCurve contrastcurve(contrastcurvePoints, CURVES_MIN_POLY_POINTS / skip);
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// apply contrast enhancement
for (int i = 0; i <= 0xffff; i++) {
dcurve[i] = contrastcurve.getVal(dcurve[i]);
}
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// create second curve if needed
bool histNeeded = false;
customToneCurve2.Reset();
@ -953,10 +653,6 @@ void CurveFactory::complexCurve (double ecomp, double black, double hlcompr, dou
}
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// create first curve if needed
customToneCurve1.Reset();
@ -972,8 +668,6 @@ void CurveFactory::complexCurve (double ecomp, double black, double hlcompr, dou
}
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#ifdef __SSE2__
vfloat gamma_v = F2V(gamma_);
vfloat startv = F2V(start);
@ -1076,8 +770,6 @@ void CurveFactory::Curvelocalhl(double ecomp, double hlcompr, double hlcomprthre
}
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void CurveFactory::complexCurvelocal(double ecomp, double black, double hlcompr, double hlcomprthresh,
double shcompr, double br, double cont, double lumare,
LUTf & hlCurve, LUTf & shCurve, LUTf & outCurve, LUTf & lightCurveloc, float avg,
@ -1091,8 +783,6 @@ void CurveFactory::complexCurvelocal(double ecomp, double black, double hlcompr,
const float add = 0.0954f;
float maxran = 65536.f; //65536
// ecomp /= 100.;
// check if brightness curve is needed
if (br > 0.00001 || br < -0.00001) {
// utili = true;
@ -1124,7 +814,6 @@ void CurveFactory::complexCurvelocal(double ecomp, double black, double hlcompr,
brightcurvePoints.at(8) = 1.; // value at white point
DiagonalCurve brightcurve(brightcurvePoints, CURVES_MIN_POLY_POINTS / skip);
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// Applying brightness curve
for (int i = 0; i < 32768; i++) { // L values range up to 32767, higher values are for highlight overflow
@ -1138,9 +827,6 @@ void CurveFactory::complexCurvelocal(double ecomp, double black, double hlcompr,
// store result in a temporary array
lightCurveloc[i] = val;
}
} else {
lightCurveloc.makeIdentity(32767.f);
}
@ -1151,42 +837,21 @@ void CurveFactory::complexCurvelocal(double ecomp, double black, double hlcompr,
int k = avg * 32768;
avg = lightCurveloc[k];
// printf("avg=%f lumaref=%f\n", avg, lumare/100.f);
std::vector<double> contrastcurvePoints;
bool lumm = true;
contrastcurvePoints.resize(9);
contrastcurvePoints.at(0) = double (DCT_NURBS);
if (lumm) {
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
contrastcurvePoints.resize(9);
contrastcurvePoints.at(0) = double (DCT_NURBS);
contrastcurvePoints.at(1) = 0.; // black point. Value in [0 ; 1] range
contrastcurvePoints.at(2) = 0.; // black point. Value in [0 ; 1] range
contrastcurvePoints.at(1) = 0.; // black point. Value in [0 ; 1] range
contrastcurvePoints.at(2) = 0.; // black point. Value in [0 ; 1] range
contrastcurvePoints.at(3) = avg - avg * (0.6 - cont / 250.0); // toe point
contrastcurvePoints.at(4) = avg - avg * (0.6 + cont / 250.0); // value at toe point
contrastcurvePoints.at(3) = avg - avg * (0.6 - cont / 250.0); // toe point
contrastcurvePoints.at(4) = avg - avg * (0.6 + cont / 250.0); // value at toe point
contrastcurvePoints.at(5) = avg + (1 - avg) * (0.6 - cont / 250.0); // shoulder point
contrastcurvePoints.at(6) = avg + (1 - avg) * (0.6 + cont / 250.0); // value at shoulder point
contrastcurvePoints.at(5) = avg + (1 - avg) * (0.6 - cont / 250.0); // shoulder point
contrastcurvePoints.at(6) = avg + (1 - avg) * (0.6 + cont / 250.0); // value at shoulder point
contrastcurvePoints.at(7) = 1.; // white point
contrastcurvePoints.at(8) = 1.; // value at white point
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
} else {
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// sum has an invalid value (next to 0, producing a division by zero, so we create a fake contrast curve, producing a white image
contrastcurvePoints.resize(5);
contrastcurvePoints.at(0) = double (DCT_NURBS);
contrastcurvePoints.at(1) = 0.; // black point. Value in [0 ; 1] range
contrastcurvePoints.at(2) = 1.; // black point. Value in [0 ; 1] range
contrastcurvePoints.at(3) = 1.; // white point
contrastcurvePoints.at(4) = 1.; // value at white point
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
}
contrastcurvePoints.at(7) = 1.; // white point
contrastcurvePoints.at(8) = 1.; // value at white point
DiagonalCurve contrastcurve(contrastcurvePoints, CURVES_MIN_POLY_POINTS / skip);
@ -1203,19 +868,12 @@ void CurveFactory::complexCurvelocal(double ecomp, double black, double hlcompr,
lightCurveloc[i] = (float)i;
}
// a: slope of the curve, black: starting point at the x axis
const float a = powf(2.0f, ecomp);
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// tone curve base. a: slope (from exp.comp.), b: black, def_mul: max. x value (can be>1), hr,sr: highlight,shadow recovery
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
hlCurve.setClip(LUT_CLIP_BELOW); // used LUT_CLIP_BELOW, because we want to have a baseline of 2^expcomp in this curve. If we don't clip the lut we get wrong values, see Issue 2621 #14 for details
float exp_scale = a;
// float scale = 65536.0;
float scale = maxran;
float comp = (max(0.0, ecomp) + 1.0) * hlcompr / 100.0;
float shoulder = ((scale / max(1.0f, exp_scale)) * (hlcomprthresh / 200.0)) + 0.1;
@ -1269,11 +927,9 @@ void CurveFactory::complexCurvelocal(double ecomp, double black, double hlcompr,
}
// curve without contrast
LUTf dcurve(maxran);
//%%%%%%%%%%%%%%%%%%%%%%%%%%
// change to [0,1] range
shCurve.setClip(LUT_CLIP_ABOVE); // used LUT_CLIP_ABOVE, because the curve converges to 1.0 at the upper end and we don't want to exceed this value.
if (black == 0.0) {
@ -1282,32 +938,22 @@ void CurveFactory::complexCurvelocal(double ecomp, double black, double hlcompr,
const float val = 1.f / (maxran - 1.f);
shCurve[0] = simplebasecurve(val, black, 0.015 * shcompr) / val;
}
// gamma correction
// gamma correction
float val = Color::gammatab_bt709[0] / maxran;
// store result in a temporary array
dcurve[0] = LIM01<float>(val);
for (int i = 1; i < maxran; i++) {
float val = i / (maxran - 1.f);
// float val2 = simplebasecurve(val, black, 0.015 * shcompr);
// shCurve[i] = val2 / val;
if (black != 0.0) {
const float val = i / 65535.f;
shCurve[i] = simplebasecurve(val, black, 0.015 * shcompr) / val;
const float bval = i / 65535.f;
shCurve[i] = simplebasecurve(bval, black, 0.015 * shcompr) / bval;
}
// gamma correction
val = Color::gammatab_bt709[i] / maxran;
// store result in a temporary array
dcurve[i] = val;
dcurve[i] = Color::gammatab_bt709[i] / maxran;
}
#ifdef __SSE2__
vfloat gamma_v = F2V(gamma_);
vfloat startv = F2V(start);
@ -1322,23 +968,13 @@ void CurveFactory::complexCurvelocal(double ecomp, double black, double hlcompr,
valv = igamma(valv, gamma_v, startv, slopev, mulv, addv);
STVFU(outCurve[i], c65535v * valv);
}
#else
for (int i = 0; i <= (maxran - 1.f); i++) {
float val = dcurve[i];
val = igamma(val, gamma_, start, slope, mul, add);
outCurve[i] = ((maxran - 1.) * val);
outCurve[i] = (maxran - 1.f) * igamma(dcurve[i], gamma_, start, slope, mul, add);
}
#endif
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void CurveFactory::complexLCurve(double br, double contr, const std::vector<double>& curvePoints,
const LUTu & histogram, LUTf & outCurve,
LUTu & outBeforeCCurveHistogram, int skip, bool & utili)
@ -1351,9 +987,7 @@ void CurveFactory::complexLCurve(double br, double contr, const std::vector<doub
outBeforeCCurveHistogram.clear();
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// tone curve base. a: slope (from exp.comp.), b: black, def_mul: max. x value (can be>1), hr,sr: highlight,shadow recovery
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// check if brightness curve is needed
if (br > 0.00001 || br < -0.00001) {
@ -1384,7 +1018,6 @@ void CurveFactory::complexLCurve(double br, double contr, const std::vector<doub
brightcurvePoints.at(8) = 1.; // value at white point
DiagonalCurve brightcurve(brightcurvePoints, CURVES_MIN_POLY_POINTS / skip);
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// Applying brightness curve
for (int i = 0; i < 32768; i++) { // L values range up to 32767, higher values are for highlight overflow
@ -1403,10 +1036,6 @@ void CurveFactory::complexLCurve(double br, double contr, const std::vector<doub
outCurve.makeIdentity(32767.f);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// check if contrast curve is needed
if (contr > 0.00001 || contr < -0.00001) {
utili = true;
@ -1425,7 +1054,6 @@ void CurveFactory::complexLCurve(double br, double contr, const std::vector<doub
if (sum) {
avg /= sum;
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
contrastcurvePoints.resize(9);
contrastcurvePoints.at(0) = double (DCT_NURBS);
@ -1440,10 +1068,7 @@ void CurveFactory::complexLCurve(double br, double contr, const std::vector<doub
contrastcurvePoints.at(7) = 1.; // white point
contrastcurvePoints.at(8) = 1.; // value at white point
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
} else {
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// sum has an invalid value (next to 0, producing a division by zero, so we create a fake contrast curve, producing a white image
contrastcurvePoints.resize(5);
contrastcurvePoints.at(0) = double (DCT_NURBS);
@ -1453,8 +1078,6 @@ void CurveFactory::complexLCurve(double br, double contr, const std::vector<doub
contrastcurvePoints.at(3) = 1.; // white point
contrastcurvePoints.at(4) = 1.; // value at white point
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
}
DiagonalCurve contrastcurve(contrastcurvePoints, CURVES_MIN_POLY_POINTS / skip);
@ -1466,25 +1089,19 @@ void CurveFactory::complexLCurve(double br, double contr, const std::vector<doub
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// create a curve if needed
std::unique_ptr<DiagonalCurve> tcurve;
bool histNeeded = false;
if (!curvePoints.empty() && curvePoints[0] != 0) {
tcurve = std::unique_ptr<DiagonalCurve> (new DiagonalCurve(curvePoints, CURVES_MIN_POLY_POINTS / skip));
tcurve.reset(new DiagonalCurve(curvePoints, CURVES_MIN_POLY_POINTS / skip));
if (outBeforeCCurveHistogram) {
histNeeded = true;
}
}
if (tcurve && tcurve->isIdentity()) {
tcurve = nullptr;
}
if (tcurve) {
if (tcurve && !tcurve->isIdentity()) {
utili = true; //if active
// L values go up to 32767, last stop is for highlight overflow
@ -1500,7 +1117,7 @@ void CurveFactory::complexLCurve(double br, double contr, const std::vector<doub
// apply custom/parametric/NURBS curve, if any
val = tcurve->getVal(outCurve[i]);
outCurve[i] = (32767.f * val);
outCurve[i] = 32767.f * val;
}
} else {
@ -1515,15 +1132,11 @@ void CurveFactory::complexLCurve(double br, double contr, const std::vector<doub
}
for (int i = 32768; i < 32770; i++) { // set last two elements of lut to 32768 and 32769 to allow linear interpolation
outCurve[i] = (float)i;
outCurve[i] = i;
}
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void CurveFactory::RGBCurve(const std::vector<double>& curvePoints, LUTf & outCurve, int skip)
{
@ -1531,14 +1144,10 @@ void CurveFactory::RGBCurve(const std::vector<double>& curvePoints, LUTf & outCu
std::unique_ptr<DiagonalCurve> tcurve;
if (!curvePoints.empty() && curvePoints[0] != 0) {
tcurve = std::unique_ptr<DiagonalCurve> (new DiagonalCurve(curvePoints, CURVES_MIN_POLY_POINTS / skip));
tcurve.reset(new DiagonalCurve(curvePoints, CURVES_MIN_POLY_POINTS / skip));
}
if (tcurve && tcurve->isIdentity()) {
tcurve = nullptr;
}
if (tcurve) {
if (tcurve && !tcurve->isIdentity()) {
if (!outCurve) {
outCurve(65536, 0);
}
@ -1555,7 +1164,6 @@ void CurveFactory::RGBCurve(const std::vector<double>& curvePoints, LUTf & outCu
}
}
LocretigainCurverab::LocretigainCurverab() : sum(0.f) {};
void LocretigainCurverab::Reset()
@ -3026,18 +2634,13 @@ void OpacityCurve::Set(const std::vector<double> &curvePoints, bool &opautili)
std::unique_ptr<FlatCurve> tcurve;
if (!curvePoints.empty() && curvePoints[0] > FCT_Linear && curvePoints[0] < FCT_Unchanged) {
tcurve = std::unique_ptr<FlatCurve> (new FlatCurve(curvePoints, false, CURVES_MIN_POLY_POINTS / 2));
tcurve.reset(new FlatCurve(curvePoints, false, CURVES_MIN_POLY_POINTS / 2));
tcurve->setIdentityValue(0.);
}
if (tcurve) {
Set(tcurve.get());
opautili = true;
tcurve = nullptr;
}
}
WavCurve::WavCurve() : sum(0.f) {}
void WavCurve::Reset()
@ -3464,10 +3067,7 @@ void ColorGradientCurve::SetXYZ(const std::vector<double> &curvePoints, const do
std::unique_ptr<FlatCurve> tcurve;
if (!curvePoints.empty() && curvePoints[0] > FCT_Linear && curvePoints[0] < FCT_Unchanged) {
tcurve = std::unique_ptr<FlatCurve> (new FlatCurve(curvePoints, false, CURVES_MIN_POLY_POINTS / 2));
}
if (tcurve) {
tcurve.reset(new FlatCurve(curvePoints, false, CURVES_MIN_POLY_POINTS / 2));
SetXYZ(tcurve.get(), xyz_rgb, satur, lumin);
}
}
@ -3555,10 +3155,7 @@ void ColorGradientCurve::SetRGB(const std::vector<double> &curvePoints)
std::unique_ptr<FlatCurve> tcurve;
if (!curvePoints.empty() && curvePoints[0] > FCT_Linear && curvePoints[0] < FCT_Unchanged) {
tcurve = std::unique_ptr<FlatCurve> (new FlatCurve(curvePoints, false, CURVES_MIN_POLY_POINTS / 2));
}
if (tcurve) {
tcurve.reset(new FlatCurve(curvePoints, false, CURVES_MIN_POLY_POINTS / 2));
SetRGB(tcurve.get());
}
}

View File

@ -367,23 +367,13 @@ public:
static void curveBW(const std::vector<double>& curvePointsbw, const std::vector<double>& curvePointsbw2, const LUTu & histogrambw, LUTu & outBeforeCCurveHistogrambw,
ToneCurve & customToneCurvebw1, ToneCurve & customToneCurvebw2, int skip);
static void curveCL(bool & clcutili, const std::vector<double>& clcurvePoints, LUTf & clCurve, int skip);
static void curveWavContL(bool & wavcontlutili, const std::vector<double>& wavclcurvePoints, LUTf & wavclCurve,/* LUTu & histogramwavcl, LUTu & outBeforeWavCLurveHistogram,*/int skip);
static void curveDehaContL(bool & dehacontlutili, const std::vector<double>& dehaclcurvePoints, LUTf & dehaclCurve, int skip, const LUTu & histogram, LUTu & outBeforeCurveHistogram);
static void mapcurve(bool & mapcontlutili, const std::vector<double>& mapcurvePoints, LUTf & mapcurve, int skip, const LUTu & histogram, LUTu & outBeforeCurveHistogram);
static void curveToning(const std::vector<double>& curvePoints, LUTf & ToningCurve, int skip);
static bool curveLocal(const std::vector<double>& curvePoints, LUTf& LocalCurve, int skip);
static void curveskLocal(bool & localskutili, const std::vector<double>& curvePoints, LUTf & LocalskCurve, int skip);
static bool diagonalCurve2Lut(const std::vector<double>& curvePoints, LUTf& curve, int skip, const LUTu & histogram, LUTu & outBeforeCurveHistogram);
static bool diagonalCurve2Lut(const std::vector<double>& curvePoints, LUTf& curve, int skip);
static void complexsgnCurve(bool & autili, bool & butili, bool & ccutili, bool & clcutili, const std::vector<double>& acurvePoints,
const std::vector<double>& bcurvePoints, const std::vector<double>& cccurvePoints, const std::vector<double>& lccurvePoints, LUTf & aoutCurve, LUTf & boutCurve, LUTf & satCurve, LUTf & lhskCurve,
int skip = 1);
static void localLCurve(double br, double contr,/* const std::vector<double>& curvePoints,*/ LUTu & histogram, LUTf & outCurve, int skip, bool & utili);
static void updatechroma(
const std::vector<double>& cccurvePoints,
LUTu & histogramC, LUTu & outBeforeCCurveHistogramC,//for chroma

View File

@ -974,22 +974,22 @@ void Crop::update(int todo)
const bool loccompwavutili = loccompwavCurve.Set(params.locallab.spots.at(sp).loccompwavcurve);
const bool loccomprewavutili = loccomprewavCurve.Set(params.locallab.spots.at(sp).loccomprewavcurve);
const bool locedgwavutili = locedgwavCurve.Set(params.locallab.spots.at(sp).locedgwavcurve);
const bool locallutili = CurveFactory::curveLocal(params.locallab.spots.at(sp).llcurve, lllocalcurve2, skip);
const bool localclutili = CurveFactory::curveLocal(params.locallab.spots.at(sp).clcurve, cllocalcurve2, skip);
const bool locallcutili = CurveFactory::curveLocal(params.locallab.spots.at(sp).lccurve, lclocalcurve2, skip);
const bool localrgbutili = CurveFactory::curveLocal(params.locallab.spots.at(sp).rgbcurve, rgblocalcurve2, skip);
const bool localcutili = CurveFactory::curveLocal(params.locallab.spots.at(sp).cccurve, cclocalcurve2, skip);
const bool localexutili = CurveFactory::curveLocal(params.locallab.spots.at(sp).excurve, exlocalcurve2, skip);
const bool localmaskutili = CurveFactory::curveLocal(params.locallab.spots.at(sp).Lmaskcurve, lmasklocalcurve2, skip);
const bool localmaskexputili = CurveFactory::curveLocal(params.locallab.spots.at(sp).Lmaskexpcurve, lmaskexplocalcurve2, skip);
const bool localmaskSHutili = CurveFactory::curveLocal(params.locallab.spots.at(sp).LmaskSHcurve, lmaskSHlocalcurve2, skip);
const bool localmaskvibutili = CurveFactory::curveLocal(params.locallab.spots.at(sp).Lmaskvibcurve, lmaskviblocalcurve2, skip);
const bool localmasktmutili = CurveFactory::curveLocal(params.locallab.spots.at(sp).Lmasktmcurve, lmasktmlocalcurve2, skip);
const bool localmaskretiutili = CurveFactory::curveLocal(params.locallab.spots.at(sp).Lmaskreticurve, lmaskretilocalcurve2, skip);
const bool localmaskcbutili = CurveFactory::curveLocal(params.locallab.spots.at(sp).Lmaskcbcurve, lmaskcblocalcurve2, skip);
const bool localmasklcutili = CurveFactory::curveLocal(params.locallab.spots.at(sp).Lmasklccurve, lmasklclocalcurve2, skip);
const bool localmaskblutili = CurveFactory::curveLocal(params.locallab.spots.at(sp).Lmaskblcurve, lmaskbllocalcurve2, skip);
const bool localmask_utili = CurveFactory::curveLocal(params.locallab.spots.at(sp).Lmask_curve, lmasklocal_curve2, skip);
const bool locallutili = CurveFactory::diagonalCurve2Lut(params.locallab.spots.at(sp).llcurve, lllocalcurve2, skip);
const bool localclutili = CurveFactory::diagonalCurve2Lut(params.locallab.spots.at(sp).clcurve, cllocalcurve2, skip);
const bool locallcutili = CurveFactory::diagonalCurve2Lut(params.locallab.spots.at(sp).lccurve, lclocalcurve2, skip);
const bool localrgbutili = CurveFactory::diagonalCurve2Lut(params.locallab.spots.at(sp).rgbcurve, rgblocalcurve2, skip);
const bool localcutili = CurveFactory::diagonalCurve2Lut(params.locallab.spots.at(sp).cccurve, cclocalcurve2, skip);
const bool localexutili = CurveFactory::diagonalCurve2Lut(params.locallab.spots.at(sp).excurve, exlocalcurve2, skip);
const bool localmaskutili = CurveFactory::diagonalCurve2Lut(params.locallab.spots.at(sp).Lmaskcurve, lmasklocalcurve2, skip);
const bool localmaskexputili = CurveFactory::diagonalCurve2Lut(params.locallab.spots.at(sp).Lmaskexpcurve, lmaskexplocalcurve2, skip);
const bool localmaskSHutili = CurveFactory::diagonalCurve2Lut(params.locallab.spots.at(sp).LmaskSHcurve, lmaskSHlocalcurve2, skip);
const bool localmaskvibutili = CurveFactory::diagonalCurve2Lut(params.locallab.spots.at(sp).Lmaskvibcurve, lmaskviblocalcurve2, skip);
const bool localmasktmutili = CurveFactory::diagonalCurve2Lut(params.locallab.spots.at(sp).Lmasktmcurve, lmasktmlocalcurve2, skip);
const bool localmaskretiutili = CurveFactory::diagonalCurve2Lut(params.locallab.spots.at(sp).Lmaskreticurve, lmaskretilocalcurve2, skip);
const bool localmaskcbutili = CurveFactory::diagonalCurve2Lut(params.locallab.spots.at(sp).Lmaskcbcurve, lmaskcblocalcurve2, skip);
const bool localmasklcutili = CurveFactory::diagonalCurve2Lut(params.locallab.spots.at(sp).Lmasklccurve, lmasklclocalcurve2, skip);
const bool localmaskblutili = CurveFactory::diagonalCurve2Lut(params.locallab.spots.at(sp).Lmaskblcurve, lmaskbllocalcurve2, skip);
const bool localmask_utili = CurveFactory::diagonalCurve2Lut(params.locallab.spots.at(sp).Lmask_curve, lmasklocal_curve2, skip);
double ecomp = params.locallab.spots.at(sp).expcomp;
double black = params.locallab.spots.at(sp).black;

View File

@ -876,8 +876,8 @@ void ImProcCoordinator::updatePreviewImage(int todo, bool panningRelatedChange)
{wprof[2][0], wprof[2][1], wprof[2][2]}
};
params->colorToning.getCurves(ctColorCurve, ctOpacityCurve, wp, opautili);
CurveFactory::curveToning(params->colorToning.clcurve, clToningcurve, scale == 1 ? 1 : 16);
CurveFactory::curveToning(params->colorToning.cl2curve, cl2Toningcurve, scale == 1 ? 1 : 16);
CurveFactory::diagonalCurve2Lut(params->colorToning.clcurve, clToningcurve, scale == 1 ? 1 : 16);
CurveFactory::diagonalCurve2Lut(params->colorToning.cl2curve, cl2Toningcurve, scale == 1 ? 1 : 16);
}
if (params->blackwhite.enabled) {
@ -1005,7 +1005,7 @@ void ImProcCoordinator::updatePreviewImage(int todo, bool panningRelatedChange)
if (todo & M_LUMACURVE) {
CurveFactory::curveCL(clcutili, params->labCurve.clcurve, clcurve, scale == 1 ? 1 : 16);
clcutili = CurveFactory::diagonalCurve2Lut(params->labCurve.clcurve, clcurve, scale == 1 ? 1 : 16);
CurveFactory::complexsgnCurve(autili, butili, ccutili, cclutili, params->labCurve.acurve, params->labCurve.bcurve, params->labCurve.cccurve,
params->labCurve.lccurve, chroma_acurve, chroma_bcurve, satcurve, lhskcurve, scale == 1 ? 1 : 16);
@ -1108,22 +1108,22 @@ void ImProcCoordinator::updatePreviewImage(int todo, bool panningRelatedChange)
const bool locwavdenutili = locwavCurveden.Set(params->locallab.spots.at(sp).locwavcurveden);
const bool locedgwavutili = locedgwavCurve.Set(params->locallab.spots.at(sp).locedgwavcurve);
const bool lmasutili_wav = loclmasCurve_wav.Set(params->locallab.spots.at(sp).LLmask_curvewav);
const bool locallutili = CurveFactory::curveLocal(params->locallab.spots.at(sp).llcurve, lllocalcurve, sca);
const bool localclutili = CurveFactory::curveLocal(params->locallab.spots.at(sp).clcurve, cllocalcurve, sca);
const bool locallcutili = CurveFactory::curveLocal(params->locallab.spots.at(sp).lccurve, lclocalcurve, sca);
const bool localcutili = CurveFactory::curveLocal(params->locallab.spots.at(sp).cccurve, cclocalcurve, sca);
const bool localrgbutili = CurveFactory::curveLocal(params->locallab.spots.at(sp).rgbcurve, rgblocalcurve, sca);
const bool localexutili = CurveFactory::curveLocal(params->locallab.spots.at(sp).excurve, exlocalcurve, sca);
const bool localmaskutili = CurveFactory::curveLocal(params->locallab.spots.at(sp).Lmaskcurve, lmasklocalcurve, sca);
const bool localmaskexputili = CurveFactory::curveLocal(params->locallab.spots.at(sp).Lmaskexpcurve, lmaskexplocalcurve, sca);
const bool localmaskSHutili = CurveFactory::curveLocal(params->locallab.spots.at(sp).LmaskSHcurve, lmaskSHlocalcurve, sca);
const bool localmaskvibutili = CurveFactory::curveLocal(params->locallab.spots.at(sp).Lmaskvibcurve, lmaskviblocalcurve, sca);
const bool localmasktmutili = CurveFactory::curveLocal(params->locallab.spots.at(sp).Lmasktmcurve, lmasktmlocalcurve, sca);
const bool localmaskretiutili = CurveFactory::curveLocal(params->locallab.spots.at(sp).Lmaskreticurve, lmaskretilocalcurve, sca);
const bool localmaskcbutili = CurveFactory::curveLocal(params->locallab.spots.at(sp).Lmaskcbcurve, lmaskcblocalcurve, sca);
const bool localmaskblutili = CurveFactory::curveLocal(params->locallab.spots.at(sp).Lmaskblcurve, lmaskbllocalcurve, sca);
const bool localmasklcutili = CurveFactory::curveLocal(params->locallab.spots.at(sp).Lmasklccurve, lmasklclocalcurve, sca);
const bool localmask_utili = CurveFactory::curveLocal(params->locallab.spots.at(sp).Lmask_curve, lmasklocal_curve, sca);
const bool locallutili = CurveFactory::diagonalCurve2Lut(params->locallab.spots.at(sp).llcurve, lllocalcurve, sca);
const bool localclutili = CurveFactory::diagonalCurve2Lut(params->locallab.spots.at(sp).clcurve, cllocalcurve, sca);
const bool locallcutili = CurveFactory::diagonalCurve2Lut(params->locallab.spots.at(sp).lccurve, lclocalcurve, sca);
const bool localcutili = CurveFactory::diagonalCurve2Lut(params->locallab.spots.at(sp).cccurve, cclocalcurve, sca);
const bool localrgbutili = CurveFactory::diagonalCurve2Lut(params->locallab.spots.at(sp).rgbcurve, rgblocalcurve, sca);
const bool localexutili = CurveFactory::diagonalCurve2Lut(params->locallab.spots.at(sp).excurve, exlocalcurve, sca);
const bool localmaskutili = CurveFactory::diagonalCurve2Lut(params->locallab.spots.at(sp).Lmaskcurve, lmasklocalcurve, sca);
const bool localmaskexputili = CurveFactory::diagonalCurve2Lut(params->locallab.spots.at(sp).Lmaskexpcurve, lmaskexplocalcurve, sca);
const bool localmaskSHutili = CurveFactory::diagonalCurve2Lut(params->locallab.spots.at(sp).LmaskSHcurve, lmaskSHlocalcurve, sca);
const bool localmaskvibutili = CurveFactory::diagonalCurve2Lut(params->locallab.spots.at(sp).Lmaskvibcurve, lmaskviblocalcurve, sca);
const bool localmasktmutili = CurveFactory::diagonalCurve2Lut(params->locallab.spots.at(sp).Lmasktmcurve, lmasktmlocalcurve, sca);
const bool localmaskretiutili = CurveFactory::diagonalCurve2Lut(params->locallab.spots.at(sp).Lmaskreticurve, lmaskretilocalcurve, sca);
const bool localmaskcbutili = CurveFactory::diagonalCurve2Lut(params->locallab.spots.at(sp).Lmaskcbcurve, lmaskcblocalcurve, sca);
const bool localmaskblutili = CurveFactory::diagonalCurve2Lut(params->locallab.spots.at(sp).Lmaskblcurve, lmaskbllocalcurve, sca);
const bool localmasklcutili = CurveFactory::diagonalCurve2Lut(params->locallab.spots.at(sp).Lmasklccurve, lmasklclocalcurve, sca);
const bool localmask_utili = CurveFactory::diagonalCurve2Lut(params->locallab.spots.at(sp).Lmask_curve, lmasklocal_curve, sca);
double ecomp = params->locallab.spots.at(sp).expcomp;
double black = params->locallab.spots.at(sp).black;
double hlcompr = params->locallab.spots.at(sp).hlcompr;
@ -1275,9 +1275,7 @@ void ImProcCoordinator::updatePreviewImage(int todo, bool panningRelatedChange)
}
}
wavcontlutili = false;
CurveFactory::curveWavContL(wavcontlutili, params->wavelet.wavclCurve, wavclCurve, scale == 1 ? 1 : 16);
wavcontlutili = CurveFactory::diagonalCurve2Lut(params->wavelet.wavclCurve, wavclCurve, scale == 1 ? 1 : 16);
if ((params->wavelet.enabled)) {
WaveletParams WaveParams = params->wavelet;

View File

@ -387,7 +387,7 @@ public:
void Eval2(const float* const* WavCoeffs_L, int level, int W_L, int H_L, float *mean, float *meanN, float *sigma, float *sigmaN, float *MaxP, float *MaxN, int numThreads);
void calceffect(int level, float *mean, float *sigma, float *mea, float effect, float offs);
std::unique_ptr<LUTf> buildMeaLut(const float inVals[11], const float mea[10], float& lutFactor);
void Aver(const float* HH_Coeffs, int datalen, float &averagePlus, float &averageNeg, float &max, float &min, int numThreads);
void Sigma(const float* HH_Coeffs, int datalen, float averagePlus, float averageNeg, float &sigmaPlus, float &sigmaNeg, int numThreads);
void calckoe(const float* const* WavCoeffs_LL, float gradw, float tloww, float ** koeLi, int level, int dir, int W_L, int H_L, float edd, float &maxkoeLi, float **tmC = nullptr);

View File

@ -69,42 +69,6 @@ constexpr int TS = 64; // Tile size
constexpr float epsilonw = 0.001f / (TS * TS); //tolerance
constexpr int offset = 25; // shift between tiles
std::unique_ptr<LUTf> buildMeaLut(const float inVals[11], const float mea[10], float& lutFactor)
{
constexpr int lutSize = 100;
const float lutMax = std::ceil(mea[9]);
const float lutDiff = lutMax / lutSize;
std::vector<float> lutVals(lutSize);
int jStart = 1;
for (int i = 0; i < lutSize; ++i) {
const float val = i * lutDiff;
if (val < mea[0]) {
// still < first value => no interpolation
lutVals[i] = inVals[0];
} else {
for (int j = jStart; j < 10; ++j) {
if (val == mea[j]) {
// exact match => no interpolation
lutVals[i] = inVals[j];
++jStart;
break;
}
if (val < mea[j]) {
// interpolate
const float dist = (val - mea[j - 1]) / (mea[j] - mea[j - 1]);
lutVals[i] = rtengine::intp(dist, inVals[j], inVals[j - 1]);
break;
}
lutVals[i] = inVals[10];
}
}
}
lutFactor = 1.f / lutDiff;
return std::unique_ptr<LUTf>(new LUTf(lutVals));
}
constexpr float clipLoc(float x)
{
return rtengine::LIM(x, 0.f, 32767.f);

View File

@ -50,6 +50,8 @@
#endif
#include "cplx_wavelet_dec.h"
#define BENCHMARK
#include "StopWatch.h"
namespace rtengine
{
@ -162,6 +164,41 @@ struct cont_params {
int wavNestedLevels = 1;
std::unique_ptr<LUTf> ImProcFunctions::buildMeaLut(const float inVals[11], const float mea[10], float& lutFactor)
{
constexpr int lutSize = 100;
const float lutMax = std::ceil(mea[9]);
const float lutDiff = lutMax / lutSize;
std::vector<float> lutVals(lutSize);
int jStart = 1;
for (int i = 0; i < lutSize; ++i) {
const float val = i * lutDiff;
if (val < mea[0]) {
// still < first value => no interpolation
lutVals[i] = inVals[0];
} else {
for (int j = jStart; j < 10; ++j) {
if (val == mea[j]) {
// exact match => no interpolation
lutVals[i] = inVals[j];
++jStart;
break;
}
if (val < mea[j]) {
// interpolate
const float dist = (val - mea[j - 1]) / (mea[j] - mea[j - 1]);
lutVals[i] = rtengine::intp(dist, inVals[j], inVals[j - 1]);
break;
}
lutVals[i] = inVals[10];
}
}
}
lutFactor = 1.f / lutDiff;
return std::unique_ptr<LUTf>(new LUTf(lutVals));
}
void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int kall, const procparams::WaveletParams & waparams, const WavCurve & wavCLVCcurve, const Wavblcurve & wavblcurve, const WavOpacityCurveRG & waOpacityCurveRG, const WavOpacityCurveSH & waOpacityCurveSH, const WavOpacityCurveBY & waOpacityCurveBY, const WavOpacityCurveW & waOpacityCurveW, const WavOpacityCurveWL & waOpacityCurveWL, const LUTf &wavclCurve, int skip)
@ -1974,6 +2011,7 @@ void ImProcFunctions::WaveletcontAllLfinal(wavelet_decomposition& WaveletCoeffs_
void ImProcFunctions::WaveletcontAllL(LabImage * labco, float ** varhue, float **varchrom, wavelet_decomposition& WaveletCoeffs_L, const Wavblcurve & wavblcurve,
struct cont_params &cp, int skip, float *mean, float *sigma, float *MaxP, float *MaxN, const WavCurve & wavCLVCcurve, const WavOpacityCurveW & waOpacityCurveW, const WavOpacityCurveSH & waOpacityCurveSH, FlatCurve* ChCurve, bool Chutili)
{
BENCHFUN
const int maxlvl = WaveletCoeffs_L.maxlevel();
const int W_L = WaveletCoeffs_L.level_W(0);
const int H_L = WaveletCoeffs_L.level_H(0);
@ -2129,10 +2167,6 @@ void ImProcFunctions::WaveletcontAllL(LabImage * labco, float ** varhue, float *
}
}
//
int n0, n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n32;
n0 = n1 = n2 = n3 = n4 = n5 = n6 = n7 = n8 = n9 = n10 = n32 = 0;
float *koeLi[12];
const std::unique_ptr<float[]> koeLibuffer(new float[12 * H_L * W_L]());
@ -2281,13 +2315,14 @@ void ImProcFunctions::WaveletcontAllL(LabImage * labco, float ** varhue, float *
for (int i = 0; i < 500; i++) {
if (wavblcurve[i] != 0.) {
wavcurvecomp = true;
break;
}
}
}
std::unique_ptr<float[]> aft;
#ifdef _OPENMP
// #pragma omp for schedule(dynamic) collapse(2)
#pragma omp for reduction(+:n0, n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n32) schedule(dynamic) collapse(2)
#pragma omp for schedule(dynamic) collapse(2)
#endif
for (int dir = 1; dir < 4; dir++) {
@ -2299,85 +2334,37 @@ void ImProcFunctions::WaveletcontAllL(LabImage * labco, float ** varhue, float *
float* const* WavCoeffs_L = WaveletCoeffs_L.level_coeffs(lvl);
ContAllL(koeLi, maxkoeLi[lvl * 3 + dir - 1], true, maxlvl, labco, varhue, varchrom, WavCoeffs_L, WavCoeffs_L0, lvl, dir, cp, Wlvl_L, Hlvl_L, skip, mean, sigma, MaxP, MaxN, wavCLVCcurve, waOpacityCurveW, waOpacityCurveSH, ChCurve, Chutili);
int minWL = min(Wlvl_L, Hlvl_L);
if(minWL > 180) {
if (std::min(Wlvl_L, Hlvl_L) > 180) {
if (wavblcurve && wavcurvecomp && cp.blena) {
// printf("Blur level L\n");
float mea[10];
const float effect = cp.bluwav;
constexpr float offs = 1.f;
float * beta = new float[Wlvl_L * Hlvl_L];
calceffect(lvl, mean, sigma, mea, effect, offs);
float * bef = new float[Wlvl_L * Hlvl_L];
float * aft = new float[Wlvl_L * Hlvl_L];
for (int co = 0; co < Hlvl_L * Wlvl_L; co++) {
bef[co] = WavCoeffs_L[dir][co];
float WavCL = std::fabs(WavCoeffs_L[dir][co]);
if (WavCL < mea[0]) {
beta[co] = 0.05f;
n0++;
if (WavCL < 32.7) {
n32++;
}
} else if (WavCL < mea[1]) {
beta[co] = 0.2f;
n1++;
} else if (WavCL < mea[2]) {
beta[co] = 0.7f;
n2++;
} else if (WavCL < mea[3]) {
beta[co] = 1.f; //standard
n3++;
} else if (WavCL < mea[4]) {
beta[co] = 1.f;
n4++;
} else if (WavCL < mea[5]) {
beta[co] = 0.8f; //+sigma
n5++;
} else if (WavCL < mea[6]) {
beta[co] = 0.6f;
n6++;
} else if (WavCL < mea[7]) {
beta[co] = 0.4f;
n7++;
} else if (WavCL < mea[8]) {
beta[co] = 0.2f; // + 2 sigma
n8++;
} else if (WavCL < mea[9]) {
beta[co] = 0.1f;
n9++;
} else {
beta[co] = 0.01f;
n10++;
}
float lutFactor;
const float inVals[] = {0.05f, 0.2f, 0.7f, 1.f, 1.f, 0.8f, 0.6f, 0.4f, 0.2f, 0.1f, 0.01f};
const auto meaLut = buildMeaLut(inVals, mea, lutFactor);
if (!aft.get()) {
aft.reset(new float[Wlvl_L * Hlvl_L]);
}
if (settings->verbose) {
printf("lvl=%i n0=%i n32=%i n1=%i n2=%i n3=%i n4=%i n5=%i n6=%i n7=%i n8=%i n9=%i n10=%i\n", lvl, n0, n0 - n32, n1, n2, n3, n4, n5, n6, n7, n8, n9, n10);
//blur level
const float klev = wavblcurve[lvl * 55.5f] * 80.f / skip;
auto WavL = WavCoeffs_L[dir];
boxblur(WavL, aft.get(), klev, Wlvl_L, Hlvl_L, false);
int co = 0;
#ifdef __SSE2__
const vfloat lutFactorv = F2V(lutFactor);
for (; co < Hlvl_L * Wlvl_L - 3; co += 4) {
const vfloat valv = LVFU(WavL[co]);
STVFU(WavL[co], intp((*meaLut)[vabsf(valv) * lutFactorv], LVFU(aft[co]), valv));
}
float klev = (wavblcurve[lvl * 55.5f]);
//blur level
klev *= 80.f / skip;
boxblur(bef, aft, klev, Wlvl_L, Hlvl_L, false);
for (int co = 0; co < Hlvl_L * Wlvl_L; co++) {
aft[co] = bef[co] * (1.f - beta[co]) + aft[co] * beta[co];
WavCoeffs_L[dir][co] = aft[co];
#endif
for (; co < Hlvl_L * Wlvl_L; co++) {
WavL[co] = intp((*meaLut)[std::fabs(WavL[co]) * lutFactor], aft[co], WavL[co]);
}
delete[] bef;
delete[] aft;
delete[] beta;
}
}
}
@ -2454,7 +2441,7 @@ void ImProcFunctions::WaveletAandBAllAB(wavelet_decomposition& WaveletCoeffs_a,
void ImProcFunctions::WaveletcontAllAB(LabImage * labco, float ** varhue, float **varchrom, wavelet_decomposition& WaveletCoeffs_ab, const Wavblcurve & wavblcurve, const WavOpacityCurveW & waOpacityCurveW,
struct cont_params &cp, const bool useChannelA, int skip, float *meanab, float *sigmaab)
{
BENCHFUN
int maxlvl = WaveletCoeffs_ab.maxlevel();
int W_L = WaveletCoeffs_ab.level_W(0);
int H_L = WaveletCoeffs_ab.level_H(0);
@ -2594,10 +2581,12 @@ void ImProcFunctions::WaveletcontAllAB(LabImage * labco, float ** varhue, float
for (int i = 0; i < 500; i++) {
if (wavblcurve[i] != 0.) {
wavcurvecomp = true;
break;
}
}
}
std::unique_ptr<float[]> aft;
#ifdef _OPENMP
#pragma omp for schedule(dynamic) collapse(2)
#endif
@ -2610,85 +2599,44 @@ void ImProcFunctions::WaveletcontAllAB(LabImage * labco, float ** varhue, float
float* const* WavCoeffs_ab = WaveletCoeffs_ab.level_coeffs(lvl);
ContAllAB(labco, maxlvl, varhue, varchrom, WavCoeffs_ab, WavCoeffs_ab0, lvl, dir, waOpacityCurveW, cp, Wlvl_ab, Hlvl_ab, useChannelA, meanab, sigmaab);
int minWL = min(Wlvl_ab, Hlvl_ab);
if(minWL > 180) {
if(std::min(Wlvl_ab, Hlvl_ab) > 180) {
if (wavblcurve && wavcurvecomp && cp.blena && cp.chrwav > 0.f) {
float mea[10];
float effect = cp.bluwav;
float offs = 1.f;
float * beta = new float[Wlvl_ab * Hlvl_ab];
for (int co = 0; co < Wlvl_ab * Hlvl_ab; co++) {
beta[co] = 1.f;
}
const float effect = cp.bluwav;
constexpr float offs = 1.f;
calceffect(lvl, meanab, sigmaab, mea, effect, offs);
float lutFactor;
const float inVals[] = {0.05f, 0.2f, 0.7f, 1.f, 1.f, 0.8f, 0.6f, 0.4f, 0.2f, 0.1f, 0.00f};
const auto meaLut = buildMeaLut(inVals, mea, lutFactor);
float * bef = new float[Wlvl_ab * Hlvl_ab];
float * aft = new float[Wlvl_ab * Hlvl_ab];
float klev;
for (int co = 0; co < Hlvl_ab * Wlvl_ab; co++) {
bef[co] = WavCoeffs_ab[dir][co];
float WavCab = std::fabs(WavCoeffs_ab[dir][co]);
if (WavCab < mea[0]) {
beta[co] = 0.05f;
} else if (WavCab < mea[1]) {
beta[co] = 0.2f;
} else if (WavCab < mea[2]) {
beta[co] = 0.7f;
} else if (WavCab < mea[3]) {
beta[co] = 1.f; //standard
} else if (WavCab < mea[4]) {
beta[co] = 1.f;
} else if (WavCab < mea[5]) {
beta[co] = 0.8f; //+sigma
} else if (WavCab < mea[6]) {
beta[co] = 0.6f;
} else if (WavCab < mea[7]) {
beta[co] = 0.4f;
} else if (WavCab < mea[8]) {
beta[co] = 0.2f; // + 2 sigma
} else if (WavCab < mea[9]) {
beta[co] = 0.1f;
} else {
beta[co] = 0.0f;
}
if (!aft.get()) {
aft.reset(new float[Wlvl_ab * Hlvl_ab]);
}
klev = (wavblcurve[lvl * 55.5f]);
//blur level
const float klev = wavblcurve[lvl * 55.5f] * 80.f / skip;
boxblur(WavCoeffs_ab[dir], aft.get(), klev, Wlvl_ab, Hlvl_ab, false);
klev *= cp.chrwav * 80.f / skip;
boxblur(bef, aft, klev, Wlvl_ab, Hlvl_ab, false);
for (int co = 0; co < Hlvl_ab * Wlvl_ab; co++) {
aft[co] = bef[co] * (1.f - beta[co]) + aft[co] * beta[co];
WavCoeffs_ab[dir][co] = aft[co];
auto WavAb = WavCoeffs_ab[dir];
int co = 0;
#ifdef __SSE2__
const vfloat lutFactorv = F2V(lutFactor);
for (; co < Hlvl_ab * Wlvl_ab - 3; co += 4) {
const vfloat valv = LVFU(WavAb[co]);
STVFU(WavAb[co], intp((*meaLut)[vabsf(valv) * lutFactorv], LVFU(aft[co]), valv));
}
#endif
for (; co < Hlvl_ab * Wlvl_ab; co++) {
WavAb[co] = intp((*meaLut)[std::fabs(WavAb[co]) * lutFactor], aft[co], WavAb[co]);
}
delete[] bef;
delete[] aft;
delete[] beta;
}
}
}
}
}
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//void ImProcFunctions::calckoe(float ** WavCoeffs_LL, const cont_params& cp, float *koeLi[12], int level, int dir, int W_L, int H_L, float edd, float *maxkoeLi, float **tmC)
void ImProcFunctions::calckoe (const float* const* WavCoeffs_LL, float gradw, float tloww, float *koeLi[12], int level, int dir, int W_L, int H_L, float edd, float &maxkoeLi, float **tmC)
{
int borderL = 2;
@ -3432,32 +3380,26 @@ void ImProcFunctions::ContAllL(float *koeLi[12], float maxkoeLi, bool lipschitz,
}
}
if (!cp.link && cp.noiseena) { //used both with denoise 1 2 3
float refine = 0.f;
if (level == 0) {
refine = cp.lev0s / 40.f;
} else if (level == 1) {
refine = cp.lev1s / 40.f;
} else if (level == 2) {
refine = cp.lev2s / 40.f;
} else if (level == 3) {
refine = cp.lev3s / 40.f;
}
for (int i = 0; i < W_L * H_L; i++) {
if (level == 0) {
refine = cp.lev0s / 40.f;
if (refine != 0.f) {
refine += 1.f;
for (int i = 0; i < W_L * H_L; i++) {
WavCoeffs_L[dir][i] *= refine;
}
if (level == 1) {
refine = cp.lev1s / 40.f;
}
if (level == 2) {
refine = cp.lev2s / 40.f;
}
if (level == 3) {
refine = cp.lev3s / 40.f;
}
WavCoeffs_L[dir][i] *= (1.f + refine);
}
}
float cpMul = cp.mul[level];
if (cpMul != 0.f && cp.contena) { // cpMul == 0.f means all will be multiplied by 1.f, so we can skip this

View File

@ -1948,12 +1948,12 @@ void RawImageSource::retinexPrepareCurves(const RetinexParams &retinexParams, LU
useHsl = (retinexParams.retinexcolorspace == "HSLLOG" || retinexParams.retinexcolorspace == "HSLLIN");
if (useHsl) {
CurveFactory::curveDehaContL (retinexcontlutili, retinexParams.cdHcurve, cdcurve, 1, lhist16RETI, histLRETI);
retinexcontlutili = CurveFactory::diagonalCurve2Lut(retinexParams.cdHcurve, cdcurve, 1, lhist16RETI, histLRETI);
} else {
CurveFactory::curveDehaContL (retinexcontlutili, retinexParams.cdcurve, cdcurve, 1, lhist16RETI, histLRETI);
retinexcontlutili = CurveFactory::diagonalCurve2Lut(retinexParams.cdcurve, cdcurve, 1, lhist16RETI, histLRETI);
}
CurveFactory::mapcurve(mapcontlutili, retinexParams.mapcurve, mapcurve, 1, lhist16RETI, histLRETI);
mapcontlutili = CurveFactory::diagonalCurve2Lut(retinexParams.mapcurve, mapcurve, 1, lhist16RETI, histLRETI);
mapcurve *= 0.5f;
retinexParams.getCurves(retinextransmissionCurve, retinexgaintransmissionCurve);
}

View File

@ -1327,10 +1327,10 @@ IImage8* Thumbnail::processImage (const procparams::ProcParams& params, eSensorT
params.colorToning.getCurves (ctColorCurve, ctOpacityCurve, wp, opautili);
clToningcurve (65536);
CurveFactory::curveToning (params.colorToning.clcurve, clToningcurve, scale == 1 ? 1 : 16);
CurveFactory::diagonalCurve2Lut (params.colorToning.clcurve, clToningcurve, scale == 1 ? 1 : 16);
cl2Toningcurve (65536);
CurveFactory::curveToning (params.colorToning.cl2curve, cl2Toningcurve, scale == 1 ? 1 : 16);
CurveFactory::diagonalCurve2Lut (params.colorToning.cl2curve, cl2Toningcurve, scale == 1 ? 1 : 16);
}
if (params.blackwhite.enabled) {
@ -1406,8 +1406,7 @@ IImage8* Thumbnail::processImage (const procparams::ProcParams& params, eSensorT
CurveFactory::complexLCurve (params.labCurve.brightness, params.labCurve.contrast, params.labCurve.lcurve,
hist16, lumacurve, dummy, 16, utili);
bool clcutili;
CurveFactory::curveCL (clcutili, params.labCurve.clcurve, clcurve, 16);
const bool clcutili = CurveFactory::diagonalCurve2Lut(params.labCurve.clcurve, clcurve, 16);
bool autili, butili, ccutili, cclutili;
CurveFactory::complexsgnCurve (autili, butili, ccutili, cclutili, params.labCurve.acurve, params.labCurve.bcurve, params.labCurve.cccurve,

View File

@ -965,9 +965,9 @@ private:
};
params.colorToning.getCurves(ctColorCurve, ctOpacityCurve, wp, opautili);
clToningcurve(65536, 0);
CurveFactory::curveToning(params.colorToning.clcurve, clToningcurve, 1);
CurveFactory::diagonalCurve2Lut(params.colorToning.clcurve, clToningcurve, 1);
cl2Toningcurve(65536, 0);
CurveFactory::curveToning(params.colorToning.cl2curve, cl2Toningcurve, 1);
CurveFactory::diagonalCurve2Lut(params.colorToning.cl2curve, cl2Toningcurve, 1);
}
labView = new LabImage(fw, fh);
@ -1070,8 +1070,7 @@ private:
bool utili;
CurveFactory::complexLCurve(params.labCurve.brightness, params.labCurve.contrast, params.labCurve.lcurve, hist16, lumacurve, dummy, 1, utili);
bool clcutili;
CurveFactory::curveCL(clcutili, params.labCurve.clcurve, clcurve, 1);
const bool clcutili = CurveFactory::diagonalCurve2Lut(params.labCurve.clcurve, clcurve, 1);
bool ccutili, cclutili;
CurveFactory::complexsgnCurve(autili, butili, ccutili, cclutili, params.labCurve.acurve, params.labCurve.bcurve, params.labCurve.cccurve,
@ -1209,22 +1208,22 @@ private:
const bool loccompwavutili = loccompwavCurve.Set(params.locallab.spots.at(sp).loccompwavcurve);
const bool loccomprewavutili = loccomprewavCurve.Set(params.locallab.spots.at(sp).loccomprewavcurve);
const bool locedgwavutili = locedgwavCurve.Set(params.locallab.spots.at(sp).locedgwavcurve);
const bool locallutili = CurveFactory::curveLocal(params.locallab.spots.at(sp).llcurve, lllocalcurve, 1);
const bool localclutili = CurveFactory::curveLocal(params.locallab.spots.at(sp).clcurve, cllocalcurve, 1);
const bool locallcutili = CurveFactory::curveLocal(params.locallab.spots.at(sp).lccurve, lclocalcurve, 1);
const bool localcutili = CurveFactory::curveLocal(params.locallab.spots.at(sp).cccurve, cclocalcurve, 1);
const bool localrgbutili = CurveFactory::curveLocal(params.locallab.spots.at(sp).rgbcurve, rgblocalcurve, 1);
const bool localexutili = CurveFactory::curveLocal(params.locallab.spots.at(sp).excurve, exlocalcurve, 1);
const bool localmaskutili = CurveFactory::curveLocal(params.locallab.spots.at(sp).Lmaskcurve, lmasklocalcurve, 1);
const bool localmaskexputili = CurveFactory::curveLocal(params.locallab.spots.at(sp).Lmaskexpcurve, lmaskexplocalcurve, 1);
const bool localmaskSHutili = CurveFactory::curveLocal(params.locallab.spots.at(sp).LmaskSHcurve, lmaskSHlocalcurve, 1);
const bool localmaskvibutili = CurveFactory::curveLocal(params.locallab.spots.at(sp).Lmaskvibcurve, lmaskviblocalcurve, 1);
const bool localmasktmutili = CurveFactory::curveLocal(params.locallab.spots.at(sp).Lmasktmcurve, lmasktmlocalcurve, 1);
const bool localmaskretiutili = CurveFactory::curveLocal(params.locallab.spots.at(sp).Lmaskreticurve, lmaskretilocalcurve, 1);
const bool localmaskcbutili = CurveFactory::curveLocal(params.locallab.spots.at(sp).Lmaskcbcurve, lmaskcblocalcurve, 1);
const bool localmaskblutili = CurveFactory::curveLocal(params.locallab.spots.at(sp).Lmaskblcurve, lmaskbllocalcurve, 1);
const bool localmasklcutili = CurveFactory::curveLocal(params.locallab.spots.at(sp).Lmasklccurve, lmasklclocalcurve, 1);
const bool localmask_utili = CurveFactory::curveLocal(params.locallab.spots.at(sp).Lmask_curve, lmasklocal_curve, 1);
const bool locallutili = CurveFactory::diagonalCurve2Lut(params.locallab.spots.at(sp).llcurve, lllocalcurve, 1);
const bool localclutili = CurveFactory::diagonalCurve2Lut(params.locallab.spots.at(sp).clcurve, cllocalcurve, 1);
const bool locallcutili = CurveFactory::diagonalCurve2Lut(params.locallab.spots.at(sp).lccurve, lclocalcurve, 1);
const bool localcutili = CurveFactory::diagonalCurve2Lut(params.locallab.spots.at(sp).cccurve, cclocalcurve, 1);
const bool localrgbutili = CurveFactory::diagonalCurve2Lut(params.locallab.spots.at(sp).rgbcurve, rgblocalcurve, 1);
const bool localexutili = CurveFactory::diagonalCurve2Lut(params.locallab.spots.at(sp).excurve, exlocalcurve, 1);
const bool localmaskutili = CurveFactory::diagonalCurve2Lut(params.locallab.spots.at(sp).Lmaskcurve, lmasklocalcurve, 1);
const bool localmaskexputili = CurveFactory::diagonalCurve2Lut(params.locallab.spots.at(sp).Lmaskexpcurve, lmaskexplocalcurve, 1);
const bool localmaskSHutili = CurveFactory::diagonalCurve2Lut(params.locallab.spots.at(sp).LmaskSHcurve, lmaskSHlocalcurve, 1);
const bool localmaskvibutili = CurveFactory::diagonalCurve2Lut(params.locallab.spots.at(sp).Lmaskvibcurve, lmaskviblocalcurve, 1);
const bool localmasktmutili = CurveFactory::diagonalCurve2Lut(params.locallab.spots.at(sp).Lmasktmcurve, lmasktmlocalcurve, 1);
const bool localmaskretiutili = CurveFactory::diagonalCurve2Lut(params.locallab.spots.at(sp).Lmaskreticurve, lmaskretilocalcurve, 1);
const bool localmaskcbutili = CurveFactory::diagonalCurve2Lut(params.locallab.spots.at(sp).Lmaskcbcurve, lmaskcblocalcurve, 1);
const bool localmaskblutili = CurveFactory::diagonalCurve2Lut(params.locallab.spots.at(sp).Lmaskblcurve, lmaskbllocalcurve, 1);
const bool localmasklcutili = CurveFactory::diagonalCurve2Lut(params.locallab.spots.at(sp).Lmasklccurve, lmasklclocalcurve, 1);
const bool localmask_utili = CurveFactory::diagonalCurve2Lut(params.locallab.spots.at(sp).Lmask_curve, lmasklocal_curve, 1);
//provisory
double ecomp = params.locallab.spots.at(sp).expcomp;
@ -1363,9 +1362,6 @@ private:
if ((params.wavelet.enabled)) {
LabImage *unshar = nullptr;
Glib::ustring provis;
bool wavcontlutili = false;
WaveletParams WaveParams = params.wavelet;
WavCurve wavCLVCurve;
Wavblcurve wavblcurve;
@ -1394,10 +1390,10 @@ private:
params.wavelet.getCurves(wavCLVCurve, wavblcurve, waOpacityCurveRG, waOpacityCurveSH, waOpacityCurveBY, waOpacityCurveW, waOpacityCurveWL);
CurveFactory::curveWavContL(wavcontlutili, params.wavelet.wavclCurve, wavclCurve,/* hist16C, dummy,*/ 1);
CurveFactory::diagonalCurve2Lut(params.wavelet.wavclCurve, wavclCurve, 1);
if ((WaveParams.ushamethod == "sharp" || WaveParams.ushamethod == "clari") && WaveParams.expclari && WaveParams.CLmethod != "all") {
provis = params.wavelet.CLmethod;
const Glib::ustring provis = params.wavelet.CLmethod;
params.wavelet.CLmethod = "all";
ipf.ip_wavelet(labView, labView, 2, WaveParams, wavCLVCurve, wavblcurve, waOpacityCurveRG, waOpacityCurveSH, waOpacityCurveBY, waOpacityCurveW, waOpacityCurveWL, wavclCurve, 1);
unshar = new LabImage(*labView, true);