Merge remote-tracking branch 'origin/master' into softproofing
This commit is contained in:
commit
ad5ef21648
@ -2138,16 +2138,15 @@ void Color::gamutLchonly (float HH, float2 sincosval, float &Lprov1, float &Chpr
|
|||||||
void Color::gamutLchonly (float HH, float2 sincosval, float &Lprov1, float &Chprov1, float &R, float &G, float &B, const double wip[3][3], const bool isHLEnabled, const float lowerCoef, const float higherCoef)
|
void Color::gamutLchonly (float HH, float2 sincosval, float &Lprov1, float &Chprov1, float &R, float &G, float &B, const double wip[3][3], const bool isHLEnabled, const float lowerCoef, const float higherCoef)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
const float ClipLevel = 65535.0f;
|
constexpr float ClipLevel = 65535.0f;
|
||||||
bool inGamut;
|
bool inGamut;
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
neg = false, more_rgb = false;
|
neg = false, more_rgb = false;
|
||||||
#endif
|
#endif
|
||||||
|
float ChprovSave = Chprov1;
|
||||||
do {
|
do {
|
||||||
inGamut = true;
|
inGamut = true;
|
||||||
|
|
||||||
//Lprov1=LL;
|
|
||||||
float aprov1 = Chprov1 * sincosval.y;
|
float aprov1 = Chprov1 * sincosval.y;
|
||||||
float bprov1 = Chprov1 * sincosval.x;
|
float bprov1 = Chprov1 * sincosval.x;
|
||||||
|
|
||||||
@ -2157,9 +2156,8 @@ void Color::gamutLchonly (float HH, float2 sincosval, float &Lprov1, float &Chpr
|
|||||||
float fz = fy - (0.005f * bprov1);
|
float fz = fy - (0.005f * bprov1);
|
||||||
|
|
||||||
float x_ = 65535.0f * f2xyz(fx) * D50x;
|
float x_ = 65535.0f * f2xyz(fx) * D50x;
|
||||||
// float y_ = 65535.0f * f2xyz(fy);
|
|
||||||
float z_ = 65535.0f * f2xyz(fz) * D50z;
|
float z_ = 65535.0f * f2xyz(fz) * D50z;
|
||||||
float y_ = (Lprov1 > epskap) ? 65535.0 * fy * fy * fy : 65535.0 * Lprov1 / kappa;
|
float y_ = (Lprov1 > epskap) ? 65535.0f * fy * fy * fy : 65535.0f * Lprov1 / kappa;
|
||||||
|
|
||||||
xyz2rgb(x_, y_, z_, R, G, B, wip);
|
xyz2rgb(x_, y_, z_, R, G, B, wip);
|
||||||
|
|
||||||
@ -2168,6 +2166,11 @@ void Color::gamutLchonly (float HH, float2 sincosval, float &Lprov1, float &Chpr
|
|||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
neg = true;
|
neg = true;
|
||||||
#endif
|
#endif
|
||||||
|
if (isnan(HH)) {
|
||||||
|
float atemp = ChprovSave * sincosval.y * 327.68;
|
||||||
|
float btemp = ChprovSave * sincosval.x * 327.68;
|
||||||
|
HH = xatan2f(btemp, atemp);
|
||||||
|
}
|
||||||
|
|
||||||
if (Lprov1 < 0.1f) {
|
if (Lprov1 < 0.1f) {
|
||||||
Lprov1 = 0.1f;
|
Lprov1 = 0.1f;
|
||||||
|
@ -2999,21 +2999,25 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer
|
|||||||
TMatrix wprof = iccStore->workingSpaceMatrix (params->icm.working);
|
TMatrix wprof = iccStore->workingSpaceMatrix (params->icm.working);
|
||||||
TMatrix wiprof = iccStore->workingSpaceInverseMatrix (params->icm.working);
|
TMatrix wiprof = iccStore->workingSpaceInverseMatrix (params->icm.working);
|
||||||
|
|
||||||
double toxyz[3][3] = {
|
float toxyz[3][3] = {
|
||||||
{
|
{
|
||||||
( wprof[0][0] / Color::D50x),
|
static_cast<float>( wprof[0][0] / Color::D50x),
|
||||||
( wprof[0][1] / Color::D50x),
|
static_cast<float>( wprof[0][1] / Color::D50x),
|
||||||
( wprof[0][2] / Color::D50x)
|
static_cast<float>( wprof[0][2] / Color::D50x)
|
||||||
}, {
|
}, {
|
||||||
( wprof[1][0]),
|
static_cast<float>( wprof[1][0]),
|
||||||
( wprof[1][1]),
|
static_cast<float>( wprof[1][1]),
|
||||||
( wprof[1][2])
|
static_cast<float>( wprof[1][2])
|
||||||
}, {
|
}, {
|
||||||
( wprof[2][0] / Color::D50z),
|
static_cast<float>( wprof[2][0] / Color::D50z),
|
||||||
( wprof[2][1] / Color::D50z),
|
static_cast<float>( wprof[2][1] / Color::D50z),
|
||||||
( wprof[2][2] / Color::D50z)
|
static_cast<float>( wprof[2][2] / Color::D50z)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
float maxFactorToxyz = max(toxyz[1][0],toxyz[1][1],toxyz[1][2]);
|
||||||
|
float equalR = maxFactorToxyz / toxyz[1][0];
|
||||||
|
float equalG = maxFactorToxyz / toxyz[1][1];
|
||||||
|
float equalB = maxFactorToxyz / toxyz[1][2];
|
||||||
|
|
||||||
//inverse matrix user select
|
//inverse matrix user select
|
||||||
double wip[3][3] = {
|
double wip[3][3] = {
|
||||||
@ -3650,59 +3654,51 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer
|
|||||||
|
|
||||||
for (int i = istart, ti = 0; i < tH; i++, ti++) {
|
for (int i = istart, ti = 0; i < tH; i++, ti++) {
|
||||||
for (int j = jstart, tj = 0; j < tW; j++, tj++) {
|
for (int j = jstart, tj = 0; j < tW; j++, tj++) {
|
||||||
float r1, g1, b1, r2, g2, b2, L_1, L_2, Lfactor, a_1, b_1, x_, y_, z_, R, G, B ;
|
|
||||||
float y, fy, yy, fyy, x, z, fx, fz;
|
|
||||||
|
|
||||||
// rgb values before RGB curves
|
// rgb values before RGB curves
|
||||||
r1 = rtemp[ti * TS + tj] ;
|
float r = rtemp[ti * TS + tj] ;
|
||||||
g1 = gtemp[ti * TS + tj] ;
|
float g = gtemp[ti * TS + tj] ;
|
||||||
b1 = btemp[ti * TS + tj] ;
|
float b = btemp[ti * TS + tj] ;
|
||||||
//convert to Lab to get a&b before RGB curves
|
//convert to Lab to get a&b before RGB curves
|
||||||
x = toxyz[0][0] * r1 + toxyz[0][1] * g1 + toxyz[0][2] * b1;
|
float x = toxyz[0][0] * r + toxyz[0][1] * g + toxyz[0][2] * b;
|
||||||
y = toxyz[1][0] * r1 + toxyz[1][1] * g1 + toxyz[1][2] * b1;
|
float y = toxyz[1][0] * r + toxyz[1][1] * g + toxyz[1][2] * b;
|
||||||
z = toxyz[2][0] * r1 + toxyz[2][1] * g1 + toxyz[2][2] * b1;
|
float z = toxyz[2][0] * r + toxyz[2][1] * g + toxyz[2][2] * b;
|
||||||
|
|
||||||
fx = (x < 65535.0f ? Color::cachef[std::max(x, 0.f)] : 327.68f * std::cbrt(x / MAXVALF));
|
float fx = x < MAXVALF ? Color::cachef[x] : 327.68f * std::cbrt(x / MAXVALF);
|
||||||
fy = (y < 65535.0f ? Color::cachef[std::max(y, 0.f)] : 327.68f * std::cbrt(y / MAXVALF));
|
float fy = y < MAXVALF ? Color::cachef[y] : 327.68f * std::cbrt(y / MAXVALF);
|
||||||
fz = (z < 65535.0f ? Color::cachef[std::max(z, 0.f)] : 327.68f * std::cbrt(z / MAXVALF));
|
float fz = z < MAXVALF ? Color::cachef[z] : 327.68f * std::cbrt(z / MAXVALF);
|
||||||
|
|
||||||
L_1 = (116.0f * fy - 5242.88f); //5242.88=16.0*327.68;
|
float a_1 = 500.0f * (fx - fy);
|
||||||
a_1 = (500.0f * (fx - fy) );
|
float b_1 = 200.0f * (fy - fz);
|
||||||
b_1 = (200.0f * (fy - fz) );
|
|
||||||
|
|
||||||
// rgb values after RGB curves
|
// rgb values after RGB curves
|
||||||
if (rCurve) {
|
if (rCurve) {
|
||||||
r2 = rCurve[ rtemp[ti * TS + tj]];
|
float rNew = rCurve[r];
|
||||||
} else {
|
r += (rNew - r) * equalR;
|
||||||
r2 = r1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gCurve) {
|
if (gCurve) {
|
||||||
g2 = gCurve[ gtemp[ti * TS + tj]];
|
float gNew = gCurve[g];
|
||||||
} else {
|
g += (gNew - g) * equalG;
|
||||||
g2 = g1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bCurve) {
|
if (bCurve) {
|
||||||
b2 = bCurve[ btemp[ti * TS + tj]];
|
float bNew = bCurve[b];
|
||||||
} else {
|
b += (bNew - b) * equalB;
|
||||||
b2 = b1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Luminosity after
|
// Luminosity after
|
||||||
// only Luminance in Lab
|
// only Luminance in Lab
|
||||||
yy = toxyz[1][0] * r2 + toxyz[1][1] * g2 + toxyz[1][2] * b2;
|
float newy = toxyz[1][0] * r + toxyz[1][1] * g + toxyz[1][2] * b;
|
||||||
fyy = (yy < 65535.0f ? Color::cachef[std::max(yy, 0.f)] : 327.68f * std::cbrt(yy / MAXVALF));
|
float newfy = newy < MAXVALF ? Color::cachef[newy] : 327.68f * std::cbrt(newy / MAXVALF);
|
||||||
L_2 = (116.0f * fyy - 5242.88f);
|
float L_2 = 116.0f * newfy - 5242.88f;
|
||||||
|
|
||||||
//gamut control
|
//gamut control
|
||||||
if(settings->rgbcurveslumamode_gamut) {
|
if(settings->rgbcurveslumamode_gamut) {
|
||||||
float RR, GG, BB;
|
float Lpro = L_2 / 327.68f;
|
||||||
float HH, Lpro, Chpro;
|
float Chpro = sqrtf(SQR(a_1) + SQR(b_1)) / 327.68f;
|
||||||
Lpro = L_2 / 327.68f;
|
float HH = NAN; // we set HH to NAN, because then it will be calculated in Color::gamutLchonly only if needed
|
||||||
Chpro = sqrt(SQR(a_1) + SQR(b_1)) / 327.68f;
|
// float HH = xatan2f(b_1, a_1);
|
||||||
HH = xatan2f(b_1, a_1);
|
// According to mathematical laws we can get the sin and cos of HH by simple operations even if we don't calculate HH
|
||||||
// According to mathematical laws we can get the sin and cos of HH by simple operations
|
|
||||||
float2 sincosval;
|
float2 sincosval;
|
||||||
|
|
||||||
if(Chpro == 0.0f) {
|
if(Chpro == 0.0f) {
|
||||||
@ -3717,30 +3713,18 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer
|
|||||||
bool neg = false;
|
bool neg = false;
|
||||||
bool more_rgb = false;
|
bool more_rgb = false;
|
||||||
//gamut control : Lab values are in gamut
|
//gamut control : Lab values are in gamut
|
||||||
Color::gamutLchonly(HH, Lpro, Chpro, RR, GG, BB, wip, highlight, 0.15f, 0.96f, neg, more_rgb);
|
Color::gamutLchonly(HH, sincosval, Lpro, Chpro, rtemp[ti * TS + tj], gtemp[ti * TS + tj], btemp[ti * TS + tj], wip, highlight, 0.15f, 0.96f, neg, more_rgb);
|
||||||
#else
|
#else
|
||||||
//gamut control : Lab values are in gamut
|
//gamut control : Lab values are in gamut
|
||||||
Color::gamutLchonly(HH, Lpro, Chpro, RR, GG, BB, wip, highlight, 0.15f, 0.96f);
|
Color::gamutLchonly(HH, sincosval, Lpro, Chpro, rtemp[ti * TS + tj], gtemp[ti * TS + tj], btemp[ti * TS + tj], wip, highlight, 0.15f, 0.96f);
|
||||||
#endif
|
#endif
|
||||||
|
//end of gamut control
|
||||||
//Color::gamutLchonly(HH,Lpro,Chpro, RR, GG, BB, wip, highlight, 0.15f, 0.96f);
|
} else {
|
||||||
|
float x_, y_, z_;
|
||||||
|
|
||||||
|
|
||||||
// float2 sincosval = xsincosf(HH);
|
|
||||||
|
|
||||||
L_2 = Lpro * 327.68f;
|
|
||||||
a_1 = 327.68f * Chpro * sincosval.y;
|
|
||||||
b_1 = 327.68f * Chpro * sincosval.x;
|
|
||||||
} //end of gamut control
|
|
||||||
|
|
||||||
//calculate RGB with L_2 and old value of a and b
|
//calculate RGB with L_2 and old value of a and b
|
||||||
Color::Lab2XYZ(L_2, a_1, b_1, x_, y_, z_) ;
|
Color::Lab2XYZ(L_2, a_1, b_1, x_, y_, z_) ;
|
||||||
Color::xyz2rgb(x_, y_, z_, R, G, B, wip);
|
Color::xyz2rgb(x_, y_, z_, rtemp[ti * TS + tj], gtemp[ti * TS + tj], btemp[ti * TS + tj], wip);
|
||||||
|
}
|
||||||
rtemp[ti * TS + tj] = R;
|
|
||||||
gtemp[ti * TS + tj] = G;
|
|
||||||
btemp[ti * TS + tj] = B;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -736,8 +736,6 @@ int Options::readFromFile (Glib::ustring fname)
|
|||||||
try {
|
try {
|
||||||
if (keyFile.load_from_file (fname)) {
|
if (keyFile.load_from_file (fname)) {
|
||||||
|
|
||||||
setDefaults ();
|
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
if (keyFile.has_group ("General")) {
|
if (keyFile.has_group ("General")) {
|
||||||
@ -1791,14 +1789,10 @@ int Options::readFromFile (Glib::ustring fname)
|
|||||||
if (options.rtSettings.verbose) {
|
if (options.rtSettings.verbose) {
|
||||||
printf("Options::readFromFile / Error code %d while reading values from \"%s\":\n%s\n", err.code(), fname.c_str(), err.what().c_str());
|
printf("Options::readFromFile / Error code %d while reading values from \"%s\":\n%s\n", err.code(), fname.c_str(), err.what().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
setDefaults ();
|
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
if (options.rtSettings.verbose) {
|
if (options.rtSettings.verbose) {
|
||||||
printf("Options::readFromFile / Unknown exception while trying to load \"%s\"!\n", fname.c_str());
|
printf("Options::readFromFile / Unknown exception while trying to load \"%s\"!\n", fname.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
setDefaults ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user