Merge pull request #5850 from Beep6581/cppcheck_cleanups

make some files cppcheck clean
This commit is contained in:
Ingo Weyrich 2020-07-17 14:54:54 +02:00 committed by GitHub
commit 5935a3ef88
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 645 additions and 1012 deletions

View File

@ -2108,17 +2108,17 @@ float ImProcFunctions::Mad(const float * DataList, const int datalen)
} }
//find median of histogram //find median of histogram
int median = 0, count = 0; int lmedian = 0, count = 0;
while (count < datalen / 2) { while (count < datalen / 2) {
count += histo[median]; count += histo[lmedian];
++median; ++lmedian;
} }
int count_ = count - histo[median - 1]; int count_ = count - histo[lmedian - 1];
// interpolate // interpolate
return (((median - 1) + (datalen / 2 - count_) / (static_cast<float>(count - count_))) / 0.6745f); return ((lmedian - 1) + (datalen / 2 - count_) / (static_cast<float>(count - count_))) / 0.6745f;
} }
float ImProcFunctions::MadRgb(const float * DataList, const int datalen) float ImProcFunctions::MadRgb(const float * DataList, const int datalen)
@ -2141,18 +2141,18 @@ float ImProcFunctions::MadRgb(const float * DataList, const int datalen)
} }
//find median of histogram //find median of histogram
int median = 0, count = 0; int lmedian = 0, count = 0;
while (count < datalen / 2) { while (count < datalen / 2) {
count += histo[median]; count += histo[lmedian];
++median; ++lmedian;
} }
int count_ = count - histo[median - 1]; int count_ = count - histo[lmedian - 1];
// interpolate // interpolate
delete[] histo; delete[] histo;
return (((median - 1) + (datalen / 2 - count_) / (static_cast<float>(count - count_))) / 0.6745f); return ((lmedian - 1) + (datalen / 2 - count_) / (static_cast<float>(count - count_))) / 0.6745f;
} }

View File

@ -1770,10 +1770,10 @@ static void region_grow( int x, int y, image_double angles, struct point * reg,
int xx,yy,i; int xx,yy,i;
/* check parameters */ /* check parameters */
if( x < 0 || y < 0 || x >= (int) angles->xsize || y >= (int) angles->ysize )
error("region_grow: (x,y) out of the image.");
if( angles == NULL || angles->data == NULL ) if( angles == NULL || angles->data == NULL )
error("region_grow: invalid image 'angles'."); error("region_grow: invalid image 'angles'.");
if( x < 0 || y < 0 || x >= (int) angles->xsize || y >= (int) angles->ysize )
error("region_grow: (x,y) out of the image.");
if( reg == NULL ) error("region_grow: invalid 'reg'."); if( reg == NULL ) error("region_grow: invalid 'reg'.");
if( reg_size == NULL ) error("region_grow: invalid pointer 'reg_size'."); if( reg_size == NULL ) error("region_grow: invalid pointer 'reg_size'.");
if( reg_angle == NULL ) error("region_grow: invalid pointer 'reg_angle'."); if( reg_angle == NULL ) error("region_grow: invalid pointer 'reg_angle'.");

View File

@ -1189,48 +1189,26 @@ void Color::computeBWMixerConstants (const Glib::ustring &setting, const Glib::u
float koymcp = 0.f; float koymcp = 0.f;
if(setting == "ROYGCBPM-Abs" || setting == "ROYGCBPM-Rel") { if(setting == "ROYGCBPM-Abs" || setting == "ROYGCBPM-Rel") {
float obM = 0.f;
float ogM = 0.f;
float orM = 0.f;
float ybM = 0.f;
float yrM = 0.f;
float ygM = 0.f;
float mgM = 0.f;
float mrM = 0.f;
float mbM = 0.f;
float pgM = 0.f;
float prM = 0.f;
float pbM = 0.f;
float crM = 0.f;
float cgM = 0.f;
float cbM = 0.f;
//printf("mixred=%f\n",mixerRed);
float fcompl = 1.f; float fcompl = 1.f;
if(complement && algo == "SP") { if (complement && algo == "SP") {
fcompl = 3.f; //special fcompl = 3.f; //special
} else if(complement && algo == "LI") { } else if (complement && algo == "LI") {
fcompl = 1.5f; //linear fcompl = 1.5f; //linear
} }
// ponderate filters: report to R=G=B=33 // ponderate filters: report to R=G=B=33
// I ponder RGB channel, not only orange or yellow or cyan, etc...it's my choice ! // I ponder RGB channel, not only orange or yellow or cyan, etc...it's my choice !
if(mixerOrange != 33) { if (mixerOrange != 33.f) {
if (algo == "SP") { //special float ogM = 0.f;
if (mixerOrange >= 33) { float orM = 0.f;
orM = fcompl * (mixerOrange * 0.67f - 22.11f) / 100.f;
} else {
orM = fcompl * (-0.3f * mixerOrange + 9.9f) / 100.f;
}
if (mixerOrange >= 33) { if (algo == "SP") { //special
if (mixerOrange > 33.f) {
orM = fcompl * (mixerOrange * 0.67f - 22.11f) / 100.f;
ogM = fcompl * (-0.164f * mixerOrange + 5.412f) / 100.f; ogM = fcompl * (-0.164f * mixerOrange + 5.412f) / 100.f;
} else { } else {
orM = fcompl * (-0.3f * mixerOrange + 9.9f) / 100.f;
ogM = fcompl * (0.4f * mixerOrange - 13.2f) / 100.f; ogM = fcompl * (0.4f * mixerOrange - 13.2f) / 100.f;
} }
} else if (algo == "LI") { //linear } else if (algo == "LI") { //linear
@ -1238,30 +1216,24 @@ void Color::computeBWMixerConstants (const Glib::ustring &setting, const Glib::u
ogM = fcompl * (0.5f * mixerOrange - 16.5f) / 100.f; ogM = fcompl * (0.5f * mixerOrange - 16.5f) / 100.f;
} }
if(complement) { const float obM = complement ? (-0.492f * mixerOrange + 16.236f) / 100.f : 0.f;
obM = (-0.492f * mixerOrange + 16.236f) / 100.f;
}
mixerRed += orM; mixerRed += orM;
mixerGreen += ogM; mixerGreen += ogM;
mixerBlue += obM; mixerBlue += obM;
koymcp += (orM + ogM + obM); koymcp += (orM + ogM + obM);
// printf("mixred+ORange=%f\n",mixerRed);
} }
if(mixerYellow != 33) { if (mixerYellow != 33.f) {
float yrM = 0.f;
if (algo == "SP") { if (algo == "SP") {
yrM = fcompl * (-0.134f * mixerYellow + 4.422f) / 100.f; //22.4 yrM = fcompl * (-0.134f * mixerYellow + 4.422f) / 100.f; //22.4
} else if (algo == "LI") { } else if (algo == "LI") {
yrM = fcompl * (0.5f * mixerYellow - 16.5f) / 100.f; //22.4 yrM = fcompl * (0.5f * mixerYellow - 16.5f) / 100.f; //22.4
} }
ygM = fcompl * (0.5f * mixerYellow - 16.5f ) / 100.f; const float ygM = fcompl * (0.5f * mixerYellow - 16.5f ) / 100.f;
const float ybM = complement ? (-0.492f * mixerYellow + 16.236f) / 100.f : 0.f;
if(complement) {
ybM = (-0.492f * mixerYellow + 16.236f) / 100.f;
}
mixerRed += yrM; mixerRed += yrM;
mixerGreen += ygM; mixerGreen += ygM;
@ -1269,17 +1241,15 @@ void Color::computeBWMixerConstants (const Glib::ustring &setting, const Glib::u
koymcp += (yrM + ygM + ybM); koymcp += (yrM + ygM + ybM);
} }
if(mixerMagenta != 33) { if (mixerMagenta != 33.f) {
float mrM = 0.f;
float mbM = 0.f;
if (algo == "SP") { if (algo == "SP") {
if(mixerMagenta >= 33) { if (mixerMagenta > 33.f) {
mrM = fcompl * ( 0.67f * mixerMagenta - 22.11f) / 100.f; mrM = fcompl * ( 0.67f * mixerMagenta - 22.11f) / 100.f;
} else {
mrM = fcompl * (-0.3f * mixerMagenta + 9.9f) / 100.f;
}
if(mixerMagenta >= 33) {
mbM = fcompl * (-0.164f * mixerMagenta + 5.412f) / 100.f; mbM = fcompl * (-0.164f * mixerMagenta + 5.412f) / 100.f;
} else { } else {
mrM = fcompl * (-0.3f * mixerMagenta + 9.9f) / 100.f;
mbM = fcompl * ( 0.4f * mixerMagenta - 13.2f) / 100.f; mbM = fcompl * ( 0.4f * mixerMagenta - 13.2f) / 100.f;
} }
} else if (algo == "LI") { } else if (algo == "LI") {
@ -1287,9 +1257,7 @@ void Color::computeBWMixerConstants (const Glib::ustring &setting, const Glib::u
mbM = fcompl * (0.5f * mixerMagenta - 16.5f) / 100.f; mbM = fcompl * (0.5f * mixerMagenta - 16.5f) / 100.f;
} }
if(complement) { const float mgM = complement ? (-0.492f * mixerMagenta + 16.236f) / 100.f : 0.f;
mgM = (-0.492f * mixerMagenta + 16.236f) / 100.f;
}
mixerRed += mrM; mixerRed += mrM;
mixerGreen += mgM; mixerGreen += mgM;
@ -1297,18 +1265,16 @@ void Color::computeBWMixerConstants (const Glib::ustring &setting, const Glib::u
koymcp += (mrM + mgM + mbM); koymcp += (mrM + mgM + mbM);
} }
if(mixerPurple != 33) { if (mixerPurple != 33.f) {
float prM = 0.f;
if (algo == "SP") { if (algo == "SP") {
prM = fcompl * (-0.134f * mixerPurple + 4.422f) / 100.f; prM = fcompl * (-0.134f * mixerPurple + 4.422f) / 100.f;
} else if (algo == "LI") { } else if (algo == "LI") {
prM = fcompl * (0.5f * mixerPurple - 16.5f) / 100.f; prM = fcompl * (0.5f * mixerPurple - 16.5f) / 100.f;
} }
pbM = fcompl * (0.5f * mixerPurple - 16.5f) / 100.f; const float pbM = fcompl * (0.5f * mixerPurple - 16.5f) / 100.f;
const float pgM = complement ? (-0.492f * mixerPurple + 16.236f) / 100.f : 0.f;
if(complement) {
pgM = (-0.492f * mixerPurple + 16.236f) / 100.f;
}
mixerRed += prM; mixerRed += prM;
mixerGreen += pgM; mixerGreen += pgM;
@ -1316,18 +1282,16 @@ void Color::computeBWMixerConstants (const Glib::ustring &setting, const Glib::u
koymcp += (prM + pgM + pbM); koymcp += (prM + pgM + pbM);
} }
if(mixerCyan != 33) { if (mixerCyan != 33.f) {
float cgM = 0.f;
if (algo == "SP") { if (algo == "SP") {
cgM = fcompl * (-0.134f * mixerCyan + 4.422f) / 100.f; cgM = fcompl * (-0.134f * mixerCyan + 4.422f) / 100.f;
} else if (algo == "LI") { } else if (algo == "LI") {
cgM = fcompl * (0.5f * mixerCyan - 16.5f) / 100.f; cgM = fcompl * (0.5f * mixerCyan - 16.5f) / 100.f;
} }
cbM = fcompl * (0.5f * mixerCyan - 16.5f) / 100.f; const float cbM = fcompl * (0.5f * mixerCyan - 16.5f) / 100.f;
const float crM = complement ? (-0.492f * mixerCyan + 16.236f) / 100.f : 0.f;
if(complement) {
crM = (-0.492f * mixerCyan + 16.236f) / 100.f;
}
mixerRed += crM; mixerRed += crM;
mixerGreen += cgM; mixerGreen += cgM;
@ -1347,7 +1311,7 @@ void Color::computeBWMixerConstants (const Glib::ustring &setting, const Glib::u
filblue = 1.f; filblue = 1.f;
filcor = 1.f; filcor = 1.f;
if (filter == "None") { if (filter == "None") {
filred = 1.f; filred = 1.f;
filgreen = 1.f; filgreen = 1.f;
filblue = 1.f; filblue = 1.f;
@ -1496,101 +1460,79 @@ void Color::interpolateRGBColor (float realL, float iplow, float iphigh, int alg
const float xl, const float yl, const float zl, const float x2, const float y2, const float z2, const float xl, const float yl, const float zl, const float x2, const float y2, const float z2,
const double xyz_rgb[3][3], const double rgb_xyz[3][3], float &ro, float &go, float &bo) const double xyz_rgb[3][3], const double rgb_xyz[3][3], float &ro, float &go, float &bo)
{ {
float X1, Y1, Z1, X2, Y2, Z2, X, Y, Z, XL, YL, ZL; float L1 = 0.f, a_1 = 0.f, b_1 = 0.f, a_2 = 0.f, b_2 = 0.f, a_L = 0.f, b_L = 0.f;
float L1 = 0.f, L2, LL, a_1 = 0.f, b_1 = 0.f, a_2 = 0.f, b_2 = 0.f, a_L, b_L;
// converting color 1 to Lab (image) if (algm == 1) {//use H interpolate
Color::rgbxyz(r1, g1, b1, X1, Y1, Z1, xyz_rgb); // converting color 1 to Lab (image)
float X1, Y1, Z1;
if(algm == 1) {//use H interpolate Color::rgbxyz(r1, g1, b1, X1, Y1, Z1, xyz_rgb);
Color::XYZ2Lab(X1, Y1, Z1, L1, a_1, b_1); Color::XYZ2Lab(X1, Y1, Z1, L1, a_1, b_1);
//Color::Lab2Lch(a_1, b_1, c_1, h_1) ;
} }
// converting color l lab(low) first color // converting color l lab(low) first color
if(twoc == 0) { // 2 colours if (twoc == 0) { // 2 colours
//Color::rgbxyz(rl, gl, bl, XL, YL, ZL, xyz_rgb); if (algm == 1) {//use H interpolate
XL = xl; float unused;
YL = yl; Color::XYZ2Lab(xl, yl, zl, unused, a_L, b_L);
ZL = zl;
if(algm <= 1) {//use H interpolate
Color::XYZ2Lab(XL, YL, ZL, LL, a_L, b_L);
} }
} }
// converting color 2 to lab (universal or high) // converting color 2 to lab (universal or high)
X2 = x2; if (algm == 1) {
Y2 = y2; float unused;
Z2 = z2; Color::XYZ2Lab(x2, y2, z2, unused, a_2, b_2);
if(algm == 1 ) {
Color::XYZ2Lab(X2, Y2, Z2, L2, a_2, b_2);
//Color::Lab2Lch(a_2, b_2, c_2, h_2) ;
} }
float cal, calH, calm; float cal, calH;
cal = calH = calm = 1.f - chromat; cal = calH = 1.f - chromat;
float med = 1.f;
float medH = 0.f;
float calan;
calan = chromat;
float calby;
calby = luma;
if(twoc == 0) { // 2 colours
calan = chromat;
if (twoc == 0) { // 2 colours
//calculate new balance chroma //calculate new balance chroma
if (realL > iplow && realL <= med) { constexpr float med = 1.f;
cal = realL * calan / (iplow - med) - med * calan / (iplow - med); if (realL > iplow && realL <= med) {
cal = realL * chromat / (iplow - med) - chromat / (iplow - med);
} else if (realL <= iplow) { } else if (realL <= iplow) {
cal = realL * calan / iplow; cal = realL * chromat / iplow;
} }
if (realL > medH && realL <= iphigh) { if (realL > 0.f && realL <= iphigh) {
calH = realL * calan / (iphigh - medH) - medH * calan / (iphigh - medH); calH = realL * chromat / iphigh;
} else if (realL > iphigh) { } else if (realL > iphigh) {
calH = realL * calan; //*(iphigh-1.f) - calan*(iphigh-1.f);//it is better without transition in highlight calH = realL * chromat; //*(iphigh-1.f) - chromat*(iphigh-1.f);//it is better without transition in highlight
} }
} }
float aaH, bbH; if (algm <= 1) {
if (twoc == 0 && metchrom == 3) { // 2 colours only with special "ab"
if(algm <= 1) { if (algm == 1) {
if(twoc == 0 && metchrom == 3) { // 2 colours only with special "ab" const float aaH = a_1 + (a_2 - a_1) * calH;
if(algm == 1) { const float bbH = b_1 + (b_2 - b_1) * calH; //pass to line after
aaH = a_1 + (a_2 - a_1) * calH;
bbH = b_1 + (b_2 - b_1) * calH; //pass to line after
a_1 = aaH + (a_L - aaH) * cal * balance; a_1 = aaH + (a_L - aaH) * cal * balance;
b_1 = bbH + (b_L - bbH) * cal * balance; b_1 = bbH + (b_L - bbH) * cal * balance;
} }
} else if(twoc == 1) { } else if (twoc == 1) {
if(metchrom == 0) { if (metchrom == 0) {
a_1 = a_1 + (a_2 - a_1) * balance; a_1 = a_1 + (a_2 - a_1) * balance;
b_1 = b_1 + (b_2 - b_1) * balance; b_1 = b_1 + (b_2 - b_1) * balance;
} else if(metchrom == 1) { } else if (metchrom == 1) {
a_1 = a_1 + (a_2 - a_1) * calan * balance; a_1 = a_1 + (a_2 - a_1) * chromat * balance;
b_1 = b_1 + (b_2 - b_1) * calan * balance; b_1 = b_1 + (b_2 - b_1) * chromat * balance;
} else if(metchrom == 2) { } else if (metchrom == 2) {
a_1 = a_1 + (a_2 - a_1) * calan * balance; a_1 = a_1 + (a_2 - a_1) * chromat * balance;
b_1 = b_1 + (b_2 - b_1) * calby * balance; b_1 = b_1 + (b_2 - b_1) * luma * balance;
} }
} }
} }
float X, Y, Z;
Color::Lab2XYZ(L1, a_1, b_1, X, Y, Z); Color::Lab2XYZ(L1, a_1, b_1, X, Y, Z);
Color::xyz2rgb(X, Y, Z, ro, go, bo, rgb_xyz);// ro go bo in gamut Color::xyz2rgb(X, Y, Z, ro, go, bo, rgb_xyz);// ro go bo in gamut
} }
void Color::calcGamma (double pwr, double ts, int mode, GammaValues &gamma) void Color::calcGamma (double pwr, double ts, GammaValues &gamma)
{ {
//from Dcraw (D.Coffin) //from Dcraw (D.Coffin)
int i; double g[6], bnd[2] = {};
double g[6], bnd[2] = {0., 0.};
g[0] = pwr; g[0] = pwr;
g[1] = ts; g[1] = ts;
@ -1598,7 +1540,7 @@ void Color::calcGamma (double pwr, double ts, int mode, GammaValues &gamma)
bnd[g[1] >= 1.] = 1.; bnd[g[1] >= 1.] = 1.;
if (g[1] && (g[1] - 1.) * (g[0] - 1.) <= 0.) { if (g[1] && (g[1] - 1.) * (g[0] - 1.) <= 0.) {
for (i = 0; i < 99; i++) { for (int i = 0; i < 99; i++) {
g[2] = (bnd[0] + bnd[1]) / 2.; g[2] = (bnd[0] + bnd[1]) / 2.;
if (g[0]) { if (g[0]) {
@ -1621,16 +1563,13 @@ void Color::calcGamma (double pwr, double ts, int mode, GammaValues &gamma)
g[5] = 1. / (g[1] * SQR(g[3]) / 2. + 1. - g[2] - g[3] - g[2] * g[3] * (log(g[3]) - 1.)) - 1.; g[5] = 1. / (g[1] * SQR(g[3]) / 2. + 1. - g[2] - g[3] - g[2] * g[3] * (log(g[3]) - 1.)) - 1.;
} }
if (!mode--) { gamma[0] = g[0];
gamma[0] = g[0]; gamma[1] = g[1];
gamma[1] = g[1]; gamma[2] = g[2];
gamma[2] = g[2]; gamma[3] = g[3];
gamma[3] = g[3]; gamma[4] = g[4];
gamma[4] = g[4]; gamma[5] = g[5];
gamma[5] = g[5]; gamma[6] = 0.;
gamma[6] = 0.;
return;
}
} }
void Color::gammaf2lut (LUTf &gammacurve, float gamma, float start, float slope, float divisor, float factor) void Color::gammaf2lut (LUTf &gammacurve, float gamma, float start, float slope, float divisor, float factor)
{ {
@ -2039,7 +1978,7 @@ void Color::Lch2Luv(float c, float h, float &u, float &v)
* columns of the matrix p=xyz_rgb are RGB tristimulus primaries in XYZ * columns of the matrix p=xyz_rgb are RGB tristimulus primaries in XYZ
* c is the color fixed on the boundary; and m=0 for c=0, m=1 for c=255 * c is the color fixed on the boundary; and m=0 for c=0, m=1 for c=255
*/ */
void Color::gamutmap(float &X, float &Y, float &Z, const double p[3][3]) void Color::gamutmap(float &X, float Y, float &Z, const double p[3][3])
{ {
float u = 4 * X / (X + 15 * Y + 3 * Z) - u0; float u = 4 * X / (X + 15 * Y + 3 * Z) - u0;
float v = 9 * Y / (X + 15 * Y + 3 * Z) - v0; float v = 9 * Y / (X + 15 * Y + 3 * Z) - v0;
@ -2076,96 +2015,33 @@ void Color::gamutmap(float &X, float &Y, float &Z, const double p[3][3])
Z = (12 - 3 * u - 20 * v) * Y / (4 * v); Z = (12 - 3 * u - 20 * v) * Y / (4 * v);
} }
void Color::skinred ( double J, double h, double sres, double Sp, float dred, float protect_red, int sk, float rstprotection, float ko, double &s)
{
float factorskin, factorsat, factor, factorskinext, interm;
float scale = 100.0f / 100.1f; //reduction in normal zone
float scaleext = 1.0f; //reduction in transition zone
float deltaHH = 0.3f; //HH value transition : I have choice 0.3 radians
float HH;
bool doskin = false;
//rough correspondence between h (JC) and H (lab) that has relatively little importance because transitions that blur the correspondence is not linear
if ((float)h > 8.6f && (float)h <= 74.f ) {
HH = (1.15f / 65.4f) * (float)h - 0.0012f; //H > 0.15 H<1.3
doskin = true;
} else if((float)h > 0.f && (float)h <= 8.6f ) {
HH = (0.19f / 8.6f ) * (float)h - 0.04f; //H>-0.04 H < 0.15
doskin = true;
} else if((float)h > 355.f && (float)h <= 360.f) {
HH = (0.11f / 5.0f ) * (float)h - 7.96f; //H>-0.15 <-0.04
doskin = true;
} else if((float)h > 74.f && (float)h < 95.f ) {
HH = (0.30f / 21.0f) * (float)h + 0.24285f; //H>1.3 H<1.6
doskin = true;
}
if(doskin) {
float chromapro = sres / Sp;
if(sk == 1) { //in C mode to adapt dred to J
if (J < 16.0) {
dred = 40.0f;
} else if(J < 22.0) {
dred = 2.5f * (float)J;
} else if(J < 60.0) {
dred = 55.0f;
} else if(J < 70.0) {
dred = -1.5f * (float)J + 145.0f;
} else {
dred = 40.0f;
}
}
if(chromapro > 0.0) {
Color::scalered ( rstprotection, chromapro, 0.0, HH, deltaHH, scale, scaleext); //Scale factor
}
if(chromapro > 1.0) {
interm = (chromapro - 1.0f) * 100.0f;
factorskin = 1.0f + (interm * scale) / 100.0f;
factorskinext = 1.0f + (interm * scaleext) / 100.0f;
} else {
factorskin = chromapro ;
factorskinext = chromapro ;
}
factorsat = chromapro;
factor = factorsat;
Color::transitred ( HH, s, dred, factorskin, protect_red, factorskinext, deltaHH, factorsat, factor); //transition
s *= factor;
} else {
s = ko * sres;
}
}
void Color::skinredfloat ( float J, float h, float sres, float Sp, float dred, float protect_red, int sk, float rstprotection, float ko, float &s) void Color::skinredfloat ( float J, float h, float sres, float Sp, float dred, float protect_red, int sk, float rstprotection, float ko, float &s)
{ {
float HH; float HH;
bool doskin = false; bool doskin = false;
//rough correspondence between h (JC) and H (lab) that has relatively little importance because transitions that blur the correspondence is not linear //rough correspondence between h (JC) and H (lab) that has relatively little importance because transitions that blur the correspondence is not linear
if ((float)h > 8.6f && (float)h <= 74.f ) { if (h > 8.6f && h <= 74.f) {
HH = (1.15f / 65.4f) * (float)h - 0.0012f; //H > 0.15 H<1.3 HH = (1.15f / 65.4f) * h - 0.0012f; //H > 0.15 H<1.3
doskin = true; doskin = true;
} else if((float)h > 0.f && (float)h <= 8.6f ) { } else if(h > 0.f && h <= 8.6f) {
HH = (0.19f / 8.6f ) * (float)h - 0.04f; //H>-0.04 H < 0.15 HH = (0.19f / 8.6f) * h - 0.04f; //H>-0.04 H < 0.15
doskin = true; doskin = true;
} else if((float)h > 355.f && (float)h <= 360.f) { } else if(h > 355.f && h <= 360.f) {
HH = (0.11f / 5.0f ) * (float)h - 7.96f; //H>-0.15 <-0.04 HH = (0.11f / 5.0f) * h - 7.96f; //H>-0.15 <-0.04
doskin = true; doskin = true;
} else if((float)h > 74.f && (float)h < 95.f ) { } else if(h > 74.f && h < 95.f ) {
HH = (0.30f / 21.0f) * (float)h + 0.24285f; //H>1.3 H<1.6 HH = (0.30f / 21.0f) * h + 0.24285f; //H>1.3 H<1.6
doskin = true; doskin = true;
} }
if(doskin) { if(doskin) {
float factorskin, factorsat, factor, factorskinext; float factorskin, factor, factorskinext;
float deltaHH = 0.3f; //HH value transition : I have choice 0.3 radians float deltaHH = 0.3f; //HH value transition : I have choice 0.3 radians
float chromapro = sres / Sp; float chromapro = sres / Sp;
if(sk == 1) { //in C mode to adapt dred to J if(sk == 1) { //in C mode to adapt dred to J
if (J < 16.f) { if (J < 16.f) {
dred = 40.f; dred = 40.f;
} else if(J < 22.f) { } else if(J < 22.f) {
dred = 2.5f * J; dred = 2.5f * J;
@ -2182,7 +2058,7 @@ void Color::skinredfloat ( float J, float h, float sres, float Sp, float dred, f
float scale = 0.999000999f; // 100.0f/100.1f; reduction in normal zone float scale = 0.999000999f; // 100.0f/100.1f; reduction in normal zone
float scaleext = 1.0f; //reduction in transition zone float scaleext = 1.0f; //reduction in transition zone
Color::scalered ( rstprotection, chromapro, 0.0, HH, deltaHH, scale, scaleext);//Scale factor Color::scalered ( rstprotection, chromapro, 0.0, HH, deltaHH, scale, scaleext);//Scale factor
float interm = (chromapro - 1.0f); const float interm = chromapro - 1.0f;
factorskin = 1.0f + (interm * scale); factorskin = 1.0f + (interm * scale);
factorskinext = 1.0f + (interm * scaleext); factorskinext = 1.0f + (interm * scaleext);
} else { } else {
@ -2190,21 +2066,14 @@ void Color::skinredfloat ( float J, float h, float sres, float Sp, float dred, f
factorskinext = chromapro ; factorskinext = chromapro ;
} }
factorsat = chromapro; factor = chromapro;
factor = factorsat; Color::transitred ( HH, s, dred, factorskin, protect_red, factorskinext, deltaHH, chromapro, factor); //transition
Color::transitred ( HH, s, dred, factorskin, protect_red, factorskinext, deltaHH, factorsat, factor); //transition
s *= factor; s *= factor;
} else { } else {
s = ko * sres; s = ko * sres;
} }
} }
void Color::scalered ( const float rstprotection, const float param, const float limit, const float HH, const float deltaHH, float &scale, float &scaleext) void Color::scalered ( const float rstprotection, const float param, const float limit, const float HH, const float deltaHH, float &scale, float &scaleext)
{ {
if(rstprotection < 99.9999f) { if(rstprotection < 99.9999f) {
@ -2262,32 +2131,21 @@ void Color::transitred (const float HH, float const Chprov1, const float dred, c
void Color::AllMunsellLch(bool lumaMuns, float Lprov1, float Loldd, float HH, float Chprov1, float CC, float &correctionHuechroma, float &correctlum) void Color::AllMunsellLch(bool lumaMuns, float Lprov1, float Loldd, float HH, float Chprov1, float CC, float &correctionHuechroma, float &correctlum)
{ {
bool contin1, contin2; if (CC >= 6.f && CC < 140.f) { //if C > 140 we say C=140 (only in Prophoto ...with very large saturation)
float correctionHue = 0.0, correctionHueLum = 0.0; constexpr float huelimit[8] = { -2.48f, -0.55f, 0.44f, 1.52f, 1.87f, 3.09f, -0.27f, 0.44f}; //limits hue of blue-purple, red-yellow, green-yellow, red-purple
bool correctL;
if(CC >= 6.0 && CC < 140) { //if C > 140 we say C=140 (only in Prophoto ...with very large saturation) Chprov1 = rtengine::LIM(Chprov1, 6.f, 140.f);
static const float huelimit[8] = { -2.48, -0.55, 0.44, 1.52, 1.87, 3.09, -0.27, 0.44}; //limits hue of blue-purple, red-yellow, green-yellow, red-purple
if (Chprov1 > 140.f) { for (int zo = 1; zo <= 4; ++zo) {
Chprov1 = 139.f; //limits of LUTf if (HH > huelimit[2 * zo - 2] && HH < huelimit[2 * zo - 1]) {
} bool correctL = false;
float correctionHue = 0.f, correctionHueLum = 0.f;
if (Chprov1 < 6.f) {
Chprov1 = 6.f;
}
for(int zo = 1; zo <= 4; zo++) {
if(HH > huelimit[2 * zo - 2] && HH < huelimit[2 * zo - 1]) {
//zone=zo;
contin1 = contin2 = false;
correctL = false;
MunsellLch (Lprov1, HH, Chprov1, CC, correctionHue, zo, correctionHueLum, correctL); //munsell chroma correction MunsellLch (Lprov1, HH, Chprov1, CC, correctionHue, zo, correctionHueLum, correctL); //munsell chroma correction
correctionHuechroma = correctionHue; //preserve correctionHuechroma = correctionHue; //preserve
if(lumaMuns) { if(lumaMuns) {
bool contin1 = false;
float correctlumprov = 0.f; float correctlumprov = 0.f;
float correctlumprov2 = 0.f;
if(correctL) { if(correctL) {
//for Munsell luminance correction //for Munsell luminance correction
@ -2296,26 +2154,19 @@ void Color::AllMunsellLch(bool lumaMuns, float Lprov1, float Loldd, float HH, fl
correctL = false; correctL = false;
} }
correctionHueLum = 0.0; if (std::fabs(Lprov1 - Loldd) > 6.f) {
correctionHue = 0.0; correctionHueLum = 0.f;
correctionHue = 0.f;
if(fabs(Lprov1 - Loldd) > 6.0) {
// correction if delta L significative..Munsell luminance // correction if delta L significative..Munsell luminance
MunsellLch (Loldd, HH, Chprov1, Chprov1, correctionHue, zo, correctionHueLum, correctL); MunsellLch (Loldd, HH, Chprov1, Chprov1, correctionHue, zo, correctionHueLum, correctL);
if(correctL) { if(correctL) {
correctlumprov2 = correctionHueLum; if(contin1) {
contin2 = true; correctlum = correctionHueLum - correctlumprov;
correctL = false; }
}
correctionHueLum = 0.0;
if(contin1 && contin2) {
correctlum = correctlumprov2 - correctlumprov;
} }
} }
} }
break;
} }
} }
} }
@ -2337,9 +2188,6 @@ void Color::AllMunsellLch(bool lumaMuns, float Lprov1, float Loldd, float HH, fl
void Color::AllMunsellLch(float Lprov1, float HH, float Chprov1, float CC, float &correctionHuechroma) void Color::AllMunsellLch(float Lprov1, float HH, float Chprov1, float CC, float &correctionHuechroma)
{ {
float correctionHue = 0.f, correctionHueLum = 0.f;
bool correctL;
if(CC >= 6.f && CC < 140.f) { //if C > 140 we say C=140 (only in Prophoto ...with very large saturation) if(CC >= 6.f && CC < 140.f) { //if C > 140 we say C=140 (only in Prophoto ...with very large saturation)
static const float huelimit[8] = { -2.48f, -0.55f, 0.44f, 1.52f, 1.87f, 3.09f, -0.27f, 0.44f}; //limits hue of blue-purple, red-yellow, green-yellow, red-purple static const float huelimit[8] = { -2.48f, -0.55f, 0.44f, 1.52f, 1.87f, 3.09f, -0.27f, 0.44f}; //limits hue of blue-purple, red-yellow, green-yellow, red-purple
@ -2352,7 +2200,8 @@ void Color::AllMunsellLch(float Lprov1, float HH, float Chprov1, float CC, float
for(int zo = 1; zo <= 4; zo++) { for(int zo = 1; zo <= 4; zo++) {
if(HH > huelimit[2 * zo - 2] && HH < huelimit[2 * zo - 1]) { if(HH > huelimit[2 * zo - 2] && HH < huelimit[2 * zo - 1]) {
//zone=zo; //zone=zo;
correctL = false; float correctionHue = 0.f, correctionHueLum = 0.f;
bool correctL = false;
MunsellLch (Lprov1, HH, Chprov1, CC, correctionHue, zo, correctionHueLum, correctL); //munsell chroma correction MunsellLch (Lprov1, HH, Chprov1, CC, correctionHue, zo, correctionHueLum, correctL); //munsell chroma correction
correctionHuechroma = correctionHue; //preserve correctionHuechroma = correctionHue; //preserve
break; break;
@ -2761,8 +2610,6 @@ void Color::gamutLchonly (float2 sincosval, float &Lprov1, float &Chprov1, const
*/ */
void Color::LabGamutMunsell(float *labL, float *laba, float *labb, const int N, bool corMunsell, bool lumaMuns, bool isHLEnabled, bool gamut, const double wip[3][3]) void Color::LabGamutMunsell(float *labL, float *laba, float *labb, const int N, bool corMunsell, bool lumaMuns, bool isHLEnabled, bool gamut, const double wip[3][3])
{ {
float correctlum = 0.f;
float correctionHuechroma = 0.f;
#ifdef __SSE2__ #ifdef __SSE2__
// precalculate H and C using SSE // precalculate H and C using SSE
float HHBuffer[N]; float HHBuffer[N];
@ -2815,8 +2662,8 @@ void Color::LabGamutMunsell(float *labL, float *laba, float *labb, const int N,
} }
labL[j] = Lprov1 * 327.68f; labL[j] = Lprov1 * 327.68f;
correctionHuechroma = 0.f; float correctionHuechroma = 0.f;
correctlum = 0.f; float correctlum = 0.f;
if(corMunsell) if(corMunsell)
AllMunsellLch(lumaMuns, Lprov1, Loldd, HH, Chprov1, Coldd, correctionHuechroma, correctlum); AllMunsellLch(lumaMuns, Lprov1, Loldd, HH, Chprov1, Coldd, correctionHuechroma, correctlum);

View File

@ -1006,8 +1006,6 @@ public:
* @brief Get the gamma curves' parameters used by LCMS2 * @brief Get the gamma curves' parameters used by LCMS2
* @param pwr gamma value [>1] * @param pwr gamma value [>1]
* @param ts slope [0 ; 20] * @param ts slope [0 ; 20]
* @param mode [always 0]
* @imax imax [always 0]
* @param gamma a pointer to an array of 6 double gamma values: * @param gamma a pointer to an array of 6 double gamma values:
* gamma0 used in ip2Lab2rgb [0 ; 1], usually near 0.5 (return value) * gamma0 used in ip2Lab2rgb [0 ; 1], usually near 0.5 (return value)
* gamma1 used in ip2Lab2rgb [0 ; 20], can be superior to 20, but it's quite unusual(return value) * gamma1 used in ip2Lab2rgb [0 ; 20], can be superior to 20, but it's quite unusual(return value)
@ -1016,7 +1014,7 @@ public:
* gamma4 used in ip2Lab2rgb [0 ; 1], usually near 0.03(return value) * gamma4 used in ip2Lab2rgb [0 ; 1], usually near 0.03(return value)
* gamma5 used in ip2Lab2rgb [0 ; 1], usually near 0.5 (return value) * gamma5 used in ip2Lab2rgb [0 ; 1], usually near 0.5 (return value)
*/ */
static void calcGamma (double pwr, double ts, int mode, GammaValues &gamma); static void calcGamma (double pwr, double ts, GammaValues &gamma);
/** /**
@ -1468,9 +1466,7 @@ public:
static void scalered ( float rstprotection, float param, float limit, float HH, float deltaHH, float &scale, float &scaleext); static void scalered ( float rstprotection, float param, float limit, float HH, float deltaHH, float &scale, float &scaleext);
static void transitred (float HH, float Chprov1, float dred, float factorskin, float protect_red, float factorskinext, float deltaHH, float factorsat, float &factor); static void transitred (float HH, float Chprov1, float dred, float factorskin, float protect_red, float factorskinext, float deltaHH, float factorsat, float &factor);
static void skinred ( double J, double h, double sres, double Sp, float dred, float protect_red, int sk, float rstprotection, float ko, double &s);
static void skinredfloat ( float J, float h, float sres, float Sp, float dred, float protect_red, int sk, float rstprotection, float ko, float &s); static void skinredfloat ( float J, float h, float sres, float Sp, float dred, float protect_red, int sk, float rstprotection, float ko, float &s);
// static void scaleredcdbl ( float skinprot, float param, float limit, float HH, float deltaHH, float &scale,float &scaleext);
static inline void pregamutlab(float lum, float hue, float &chr) //big approximation to limit gamut (Prophoto) before good gamut procedure for locallab chroma, to avoid crash static inline void pregamutlab(float lum, float hue, float &chr) //big approximation to limit gamut (Prophoto) before good gamut procedure for locallab chroma, to avoid crash
{ {
@ -1801,11 +1797,11 @@ public:
/** /**
* @brief Gamut correction in the XYZ color space * @brief Gamut correction in the XYZ color space
* @param X X channel input value and corrected output value [0 ; 65535] * @param X X channel input value and corrected output value [0 ; 65535]
* @param Y Y channel input value and corrected output value [0 ; 65535] * @param Y Y channel input value[0 ; 65535]
* @param Z Z channel input value and corrected output value [0 ; 65535] * @param Z Z channel input value and corrected output value [0 ; 65535]
* @param p working profile * @param p working profile
*/ */
static void gamutmap(float &X, float &Y, float &Z, const double p[3][3]); static void gamutmap(float &X, float Y, float &Z, const double p[3][3]);
/** /**

View File

@ -29,7 +29,6 @@
#include "improcfun.h" #include "improcfun.h"
#include "LUT.h" #include "LUT.h"
#include "opthelper.h" #include "opthelper.h"
#include "boxblur.h"
#include "rt_math.h" #include "rt_math.h"
#include "settings.h" #include "settings.h"
@ -247,46 +246,20 @@ void fillLut(LUTf &irangefn, int level, double dirpyrThreshold, float mult, floa
} }
} }
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% void idirpyr_eq_channel_loc(float ** data_coarse, float ** data_fine, float ** buffer, int width, int height, int level, float mult, const double dirpyrThreshold, float ** hue, float ** chrom, const double skinprot, const bool gamutlab, float b_l, float t_l, float t_r, float b_r, int choice, int scaleprev, bool multiThread)
void idirpyr_eq_channel_loc(float ** data_coarse, float ** data_fine, float ** buffer, int width, int height, int level, float mult, const float blurcb, const double dirpyrThreshold, float ** hue, float ** chrom, const double skinprot, const bool gamutlab, float b_l, float t_l, float t_r, float b_r, int choice, int scaleprev, bool multiThread)
{ {
LUTf irangefn(0x20000); LUTf irangefn(0x20000);
fillLut(irangefn, level, dirpyrThreshold, mult, skinprot); fillLut(irangefn, level, dirpyrThreshold, mult, skinprot);
#ifdef _OPENMP #ifdef _OPENMP
#pragma omp parallel for schedule(dynamic,16) #pragma omp parallel for schedule(dynamic,16)
#endif #endif
for (int i = 0; i < height; i++) { for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) { for (int j = 0; j < width; j++) {
const float hipass = data_fine[i][j] - data_coarse[i][j];
float hipass = (data_fine[i][j] - data_coarse[i][j]); buffer[i][j] += irangefn[hipass + 0x10000] * hipass;
buffer[i][j] += irangefn[hipass + 0x10000] * hipass;
}
} }
}
if(blurcb > 0.f && choice == 0 && level != 5) {
float multbis;
if (level == 4 && mult > 1.f) {
multbis = 1.f + 0.65f * (mult - 1.f);
} else if (level == 5 && mult > 1.f) {
multbis = 1.f + 0.45f * (mult - 1.f);
} else {
multbis = mult; //multbis to reduce artifacts for high values mult
}
AlignedBuffer<float> blurbufcbdl(width * height);
float rad = 0.05f * blurcb * fabs((level + 1) * (multbis - 1.f)) / scaleprev;
// printf("rad=%f level=%i\n", rad, level);
#ifdef _OPENMP
#pragma omp parallel if (multiThread)
#endif
// rtengine::boxblur<float, float>(buffer, buffer, blurbufcbdl.data, rad, rad, width, height);
rtengine::boxblur(buffer, buffer, rad, width, height, false);
blurbufcbdl.resize(0);
}
irangefn.clear();
} }
void idirpyr_eq_channel(const float * const * data_coarse, const float * const * data_fine, float ** buffer, int width, int height, int level, float mult, const double dirpyrThreshold, const float * const * hue, const float * const * chrom, const double skinprot, float b_l, float t_l, float t_r) void idirpyr_eq_channel(const float * const * data_coarse, const float * const * data_fine, float ** buffer, int width, int height, int level, float mult, const double dirpyrThreshold, const float * const * hue, const float * const * chrom, const double skinprot, float b_l, float t_l, float t_r)
@ -552,7 +525,7 @@ void ImProcFunctions::dirpyr_equalizercam(const CieImage *ncie, float ** src, fl
} }
} }
void ImProcFunctions::cbdl_local_temp(float ** src, float ** loctemp, int srcwidth, int srcheight, const float * mult, float kchro, const double dirpyrThreshold, const float mergeL, const float contres, const float blurcb, const double skinprot, const bool gamutlab, float b_l, float t_l, float t_r, float b_r, int choice, int scaleprev, bool multiThread) void ImProcFunctions::cbdl_local_temp(float ** src, float ** loctemp, int srcwidth, int srcheight, const float * mult, float kchro, const double dirpyrThreshold, const float mergeL, const float contres, const double skinprot, const bool gamutlab, float b_l, float t_l, float t_r, float b_r, int choice, int scaleprev, bool multiThread)
{ {
constexpr int maxlevelloc = 6; constexpr int maxlevelloc = 6;
constexpr int scalesloc[maxlevelloc] = {1, 2, 4, 8, 16, 32}; constexpr int scalesloc[maxlevelloc] = {1, 2, 4, 8, 16, 32};
@ -663,13 +636,12 @@ void ImProcFunctions::cbdl_local_temp(float ** src, float ** loctemp, int srcwid
for (int level = lastlevel - 1; level > 0; level--) { for (int level = lastlevel - 1; level > 0; level--) {
idirpyr_eq_channel_loc(dirpyrlo[level], dirpyrlo[level - 1], residbuff, srcwidth, srcheight, level, multi[level], blurcb, dirpyrThreshold, nullptr, nullptr, skinprot, gamutlab, b_l, t_l, t_r, b_r, choice, scaleprev, multiThread); idirpyr_eq_channel_loc(dirpyrlo[level], dirpyrlo[level - 1], residbuff, srcwidth, srcheight, level, multi[level], dirpyrThreshold, nullptr, nullptr, skinprot, gamutlab, b_l, t_l, t_r, b_r, choice, scaleprev, multiThread);
} }
scale = scalesloc[0]; scale = scalesloc[0];
idirpyr_eq_channel_loc(dirpyrlo[0], src, residbuff, srcwidth, srcheight, 0, multi[0], blurcb, dirpyrThreshold, nullptr, nullptr, skinprot, gamutlab, b_l, t_l, t_r, b_r, choice, scaleprev, multiThread); idirpyr_eq_channel_loc(dirpyrlo[0], src, residbuff, srcwidth, srcheight, 0, multi[0], dirpyrThreshold, nullptr, nullptr, skinprot, gamutlab, b_l, t_l, t_r, b_r, choice, scaleprev, multiThread);
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
array2D<float> loct(srcwidth, srcheight); array2D<float> loct(srcwidth, srcheight);
#ifdef _OPENMP #ifdef _OPENMP

View File

@ -281,7 +281,6 @@ void RawImageSource::fast_demosaic()
int right = min(left + TS, W - bord + 2); int right = min(left + TS, W - bord + 2);
#ifdef __SSE2__ #ifdef __SSE2__
int j, cc;
__m128 wtuv, wtdv, wtlv, wtrv; __m128 wtuv, wtdv, wtlv, wtrv;
__m128 greenv, tempv, absv, abs2v; __m128 greenv, tempv, absv, abs2v;
__m128 c16v = _mm_set1_ps( 16.0f ); __m128 c16v = _mm_set1_ps( 16.0f );
@ -302,7 +301,7 @@ void RawImageSource::fast_demosaic()
float wtu, wtd, wtl, wtr; float wtu, wtd, wtl, wtr;
#ifdef __SSE2__ #ifdef __SSE2__
selmask = (vmask)_mm_andnot_ps( (__m128)selmask, (__m128)andmask); selmask = (vmask)_mm_andnot_ps( (__m128)selmask, (__m128)andmask);
int j, cc;
for (j = left, cc = 0; j < right - 3; j += 4, cc += 4) { for (j = left, cc = 0; j < right - 3; j += 4, cc += 4) {
tempv = LVFU(rawData[i][j]); tempv = LVFU(rawData[i][j]);
absv = vabsf(LVFU(rawData[i - 1][j]) - LVFU(rawData[i + 1][j])); absv = vabsf(LVFU(rawData[i - 1][j]) - LVFU(rawData[i + 1][j]));
@ -421,16 +420,12 @@ void RawImageSource::fast_demosaic()
temp1v = LVFU(redtile[rr * TS + cc]); temp1v = LVFU(redtile[rr * TS + cc]);
temp2v = greenv - zd25v * (greensumv - LVFU(redtile[(rr - 1) * TS + cc]) - LVFU(redtile[(rr + 1) * TS + cc]) - LVFU(redtile[rr * TS + cc - 1]) - LVFU(redtile[rr * TS + cc + 1])); temp2v = greenv - zd25v * (greensumv - LVFU(redtile[(rr - 1) * TS + cc]) - LVFU(redtile[(rr + 1) * TS + cc]) - LVFU(redtile[rr * TS + cc - 1]) - LVFU(redtile[rr * TS + cc + 1]));
// temp2v = greenv - zd25v*((LVFU(greentile[(rr-1)*TS+cc])-LVFU(redtile[(rr-1)*TS+cc]))+(LVFU(greentile[(rr+1)*TS+cc])-LVFU(redtile[(rr+1)*TS+cc]))+
// (LVFU(greentile[rr*TS+cc-1])-LVFU(redtile[rr*TS+cc-1]))+(LVFU(greentile[rr*TS+cc+1])-LVFU(redtile[rr*TS+cc+1])));
_mm_storeu_ps( &redtile[rr * TS + cc], vself(selmask, temp1v, temp2v)); _mm_storeu_ps( &redtile[rr * TS + cc], vself(selmask, temp1v, temp2v));
temp1v = LVFU(bluetile[rr * TS + cc]); temp1v = LVFU(bluetile[rr * TS + cc]);
temp2v = greenv - zd25v * (greensumv - LVFU(bluetile[(rr - 1) * TS + cc]) - LVFU(bluetile[(rr + 1) * TS + cc]) - LVFU(bluetile[rr * TS + cc - 1]) - LVFU(bluetile[rr * TS + cc + 1])); temp2v = greenv - zd25v * (greensumv - LVFU(bluetile[(rr - 1) * TS + cc]) - LVFU(bluetile[(rr + 1) * TS + cc]) - LVFU(bluetile[rr * TS + cc - 1]) - LVFU(bluetile[rr * TS + cc + 1]));
// temp2v = greenv - zd25v*((LVFU(greentile[(rr-1)*TS+cc])-LVFU(bluetile[(rr-1)*TS+cc]))+(LVFU(greentile[(rr+1)*TS+cc])-LVFU(bluetile[(rr+1)*TS+cc]))+
// (LVFU(greentile[rr*TS+cc-1])-LVFU(bluetile[rr*TS+cc-1]))+(LVFU(greentile[rr*TS+cc+1])-LVFU(bluetile[rr*TS+cc+1])));
_mm_storeu_ps( &bluetile[rr * TS + cc], vself(selmask, temp1v, temp2v)); _mm_storeu_ps( &bluetile[rr * TS + cc], vself(selmask, temp1v, temp2v));
} }
@ -450,7 +445,7 @@ void RawImageSource::fast_demosaic()
for (int i = top + 2, rr = 2; i < bottom - 2; i++, rr++) { for (int i = top + 2, rr = 2; i < bottom - 2; i++, rr++) {
#ifdef __SSE2__ #ifdef __SSE2__
int j, cc;
for (j = left + 2, cc = 2; j < right - 5; j += 4, cc += 4) { for (j = left + 2, cc = 2; j < right - 5; j += 4, cc += 4) {
_mm_storeu_ps(&red[i][j], vmaxf(LVFU(redtile[rr * TS + cc]), ZEROV)); _mm_storeu_ps(&red[i][j], vmaxf(LVFU(redtile[rr * TS + cc]), ZEROV));
_mm_storeu_ps(&green[i][j], vmaxf(LVFU(greentile[rr * TS + cc]), ZEROV)); _mm_storeu_ps(&green[i][j], vmaxf(LVFU(greentile[rr * TS + cc]), ZEROV));

View File

@ -351,7 +351,7 @@ cmsHPROFILE rtengine::ProfileContent::toProfile() const
double slope = slopetag == 0 ? eps : slopetag; double slope = slopetag == 0 ? eps : slopetag;
GammaValues g_b; //gamma parameters GammaValues g_b; //gamma parameters
Color::calcGamma(pwr, ts, 0, g_b); // call to calcGamma with selected gamma and slope : return parameters for LCMS2 Color::calcGamma(pwr, ts, g_b); // call to calcGamma with selected gamma and slope : return parameters for LCMS2
cmsFloat64Number gammaParams[7]; //gamma parameters cmsFloat64Number gammaParams[7]; //gamma parameters
gammaParams[4] = g_b[3] * ts; gammaParams[4] = g_b[3] * ts;
gammaParams[0] = gammatag; gammaParams[0] = gammatag;

View File

@ -109,35 +109,35 @@ public:
} tmp; } tmp;
tmp.f = f; tmp.f = f;
int32_t sign = (tmp.i >> 16) & 0x00008000; const int32_t lsign = (tmp.i >> 16) & 0x00008000;
int32_t exponent = ((tmp.i >> 23) & 0x000000ff) - (127 - 15); int32_t exponent = ((tmp.i >> 23) & 0x000000ff) - (127 - 15);
int32_t mantissa = tmp.i & 0x007fffff; int32_t mantissa = tmp.i & 0x007fffff;
if (exponent <= 0) { if (exponent <= 0) {
if (exponent < -10) { if (exponent < -10) {
return (uint16_t)sign; return (uint16_t)lsign;
} }
mantissa = (mantissa | 0x00800000) >> (1 - exponent); mantissa = (mantissa | 0x00800000) >> (1 - exponent);
if (mantissa & 0x00001000) if (mantissa & 0x00001000)
mantissa += 0x00002000; mantissa += 0x00002000;
return (uint16_t)(sign | (mantissa >> 13)); return (uint16_t)(lsign | (mantissa >> 13));
} else if (exponent == 0xff - (127 - 15)) { } else if (exponent == 0xff - (127 - 15)) {
if (mantissa == 0) { if (mantissa == 0) {
return (uint16_t)(sign | 0x7c00); return (uint16_t)(lsign | 0x7c00);
} else { } else {
return (uint16_t)(sign | 0x7c00 | (mantissa >> 13)); return (uint16_t)(lsign | 0x7c00 | (mantissa >> 13));
} }
} }
if (mantissa & 0x00001000) { if (mantissa & 0x00001000) {
mantissa += 0x00002000; mantissa += 0x00002000;
if (mantissa & 0x00800000) { if (mantissa & 0x00800000) {
mantissa = 0; // overflow in significand, mantissa = 0; // overflow in significand,
exponent += 1; // adjust exponent exponent += 1; // adjust exponent
} }
} }
if (exponent > 30) { if (exponent > 30) {
return (uint16_t)(sign | 0x7c00); // infinity with the same sign as f. return (uint16_t)(lsign | 0x7c00); // infinity with the same sign as f.
} }
return (uint16_t)(sign | (exponent << 10) | (mantissa >> 13)); return (uint16_t)(lsign | (exponent << 10) | (mantissa >> 13));
} }
// From DNG SDK dng_utils.h // From DNG SDK dng_utils.h
@ -148,13 +148,13 @@ public:
uint32_t i; uint32_t i;
} tmp; } tmp;
int32_t sign = (halfValue >> 15) & 0x00000001; const int32_t lsign = (halfValue >> 15) & 0x00000001;
int32_t exponent = (halfValue >> 10) & 0x0000001f; int32_t exponent = (halfValue >> 10) & 0x0000001f;
int32_t mantissa = halfValue & 0x000003ff; int32_t mantissa = halfValue & 0x000003ff;
if (exponent == 0) { if (exponent == 0) {
if (mantissa == 0) { if (mantissa == 0) {
// Plus or minus zero // Plus or minus zero
tmp.i = (uint32_t) (sign << 31); tmp.i = (uint32_t) (lsign << 31);
return tmp.f; return tmp.f;
} else { } else {
// Denormalized number -- renormalize it // Denormalized number -- renormalize it
@ -168,7 +168,7 @@ public:
} else if (exponent == 31) { } else if (exponent == 31) {
if (mantissa == 0) { if (mantissa == 0) {
// Positive or negative infinity, convert to maximum (16 bit) values. // Positive or negative infinity, convert to maximum (16 bit) values.
tmp.i = (uint32_t)((sign << 31) | ((0x1eL + 127 - 15) << 23) | (0x3ffL << 13)); tmp.i = (uint32_t)((lsign << 31) | ((0x1eL + 127 - 15) << 23) | (0x3ffL << 13));
return tmp.f; return tmp.f;
} else { } else {
// Nan -- Just set to zero. // Nan -- Just set to zero.
@ -179,32 +179,32 @@ public:
exponent += (127 - 15); exponent += (127 - 15);
mantissa <<= 13; mantissa <<= 13;
// Assemble sign, exponent and mantissa. // Assemble sign, exponent and mantissa.
tmp.i = (uint32_t) ((sign << 31) | (exponent << 23) | mantissa); tmp.i = (uint32_t) ((lsign << 31) | (exponent << 23) | mantissa);
return tmp.f; return tmp.f;
} }
inline uint32_t DNG_FP24ToFloat(const uint8_t * input) inline uint32_t DNG_FP24ToFloat(const uint8_t * input)
{ {
int32_t sign = (input [0] >> 7) & 0x01; const int32_t lsign = (input[0] >> 7) & 0x01;
int32_t exponent = (input [0] ) & 0x7F; int32_t exponent = input[0] & 0x7F;
int32_t mantissa = (((int32_t) input [1]) << 8) | input[2]; int32_t mantissa = (((int32_t) input[1]) << 8) | input[2];
if (exponent == 0) { if (exponent == 0) {
if (mantissa == 0) { if (mantissa == 0) {
// Plus or minus zero // Plus or minus zero
return (uint32_t) (sign << 31); return (uint32_t) (lsign << 31);
} else { } else {
// Denormalized number -- renormalize it // Denormalized number -- renormalize it
while (!(mantissa & 0x00010000)) { while (!(mantissa & 0x00010000)) {
mantissa <<= 1; mantissa <<= 1;
exponent -= 1; exponent -= 1;
} }
exponent += 1; exponent += 1;
mantissa &= ~0x00010000; mantissa &= ~0x00010000;
} }
} else if (exponent == 127) { } else if (exponent == 127) {
if (mantissa == 0) { if (mantissa == 0) {
// Positive or negative infinity, convert to maximum (24 bit) values. // Positive or negative infinity, convert to maximum (24 bit) values.
return (uint32_t) ((sign << 31) | ((0x7eL + 128 - 64) << 23) | (0xffffL << 7)); return (uint32_t) ((lsign << 31) | ((0x7eL + 128 - 64) << 23) | (0xffffL << 7));
} else { } else {
// Nan -- Just set to zero. // Nan -- Just set to zero.
return 0; return 0;
@ -214,7 +214,7 @@ public:
exponent += (128 - 64); exponent += (128 - 64);
mantissa <<= 7; mantissa <<= 7;
// Assemble sign, exponent and mantissa. // Assemble sign, exponent and mantissa.
return (uint32_t) ((sign << 31) | (exponent << 23) | mantissa); return (uint32_t) ((lsign << 31) | (exponent << 23) | mantissa);
} }
void normalizeFloat(float srcMinVal, float srcMaxVal) override; void normalizeFloat(float srcMinVal, float srcMaxVal) override;

View File

@ -254,9 +254,9 @@ public:
void fftw_tile_blur(int GW, int GH, int tilssize , int max_numblox_W, int min_numblox_W, float **tmp1, int numThreads, double radius); void fftw_tile_blur(int GW, int GH, int tilssize , int max_numblox_W, int min_numblox_W, float **tmp1, int numThreads, double radius);
void maskforretinex(int sp, int before, float ** luminance, float ** out, int W_L, int H_L, int skip, void maskforretinex(int sp, int before, float ** luminance, float ** out, int W_L, int H_L, int skip,
const LocCCmaskCurve & locccmasretiCurve, bool &lcmasretiutili, const LocLLmaskCurve & locllmasretiCurve, bool &llmasretiutili, const LocHHmaskCurve & lochhmasretiCurve, bool & lhmasretiutili, const LocCCmaskCurve & locccmasretiCurve, bool lcmasretiutili, const LocLLmaskCurve & locllmasretiCurve, bool llmasretiutili, const LocHHmaskCurve & lochhmasretiCurve, bool lhmasretiutili,
int llretiMask, bool retiMasktmap, bool retiMask, float rad, float lap, bool pde, float gamm, float slop, float chro, float blend, int llretiMask, bool retiMasktmap, bool retiMask, float rad, float lap, bool pde, float gamm, float slop, float chro, float blend,
LUTf & lmaskretilocalcurve, bool & localmaskretiutili, const LUTf & lmaskretilocalcurve, bool localmaskretiutili,
LabImage * bufreti, LabImage * bufmask, LabImage * buforig, LabImage * buforigmas, bool multiThread, LabImage * bufreti, LabImage * bufmask, LabImage * buforig, LabImage * buforigmas, bool multiThread,
bool delt, const float hueref, const float chromaref, const float lumaref, bool delt, const float hueref, const float chromaref, const float lumaref,
float maxdE, float mindE, float maxdElim, float mindElim, float iterat, float limscope, int scope, float balance, float balanceh, float lumask); float maxdE, float mindE, float maxdElim, float mindElim, float iterat, float limscope, int scope, float balance, float balanceh, float lumask);
@ -269,8 +269,8 @@ public:
void MSRLocal(int call, int sp, bool fftw, int lum, float** reducDE, LabImage * bufreti, LabImage * bufmask, LabImage * buforig, LabImage * buforigmas, float** luminance, const float* const *originalLuminance, void MSRLocal(int call, int sp, bool fftw, int lum, float** reducDE, LabImage * bufreti, LabImage * bufmask, LabImage * buforig, LabImage * buforigmas, float** luminance, const float* const *originalLuminance,
const int width, const int height, int bfwr, int bfhr, const procparams::LocallabParams &loc, const int skip, const LocretigainCurve &locRETgainCcurve, const LocretitransCurve &locRETtransCcurve, const int width, const int height, int bfwr, int bfhr, const procparams::LocallabParams &loc, const int skip, const LocretigainCurve &locRETgainCcurve, const LocretitransCurve &locRETtransCcurve,
const int chrome, const int scall, const float krad, float &minCD, float &maxCD, float &mini, float &maxi, float &Tmean, float &Tsigma, float &Tmin, float &Tmax, const int chrome, const int scall, const float krad, float &minCD, float &maxCD, float &mini, float &maxi, float &Tmean, float &Tsigma, float &Tmin, float &Tmax,
const LocCCmaskCurve & locccmasretiCurve, bool &lcmasretiutili, const LocLLmaskCurve & locllmasretiCurve, bool &llmasretiutili, const LocHHmaskCurve & lochhmasretiCurve, bool & lhmasretiutili, int llretiMask, const LocCCmaskCurve & locccmasretiCurve, bool lcmasretiutili, const LocLLmaskCurve & locllmasretiCurve, bool llmasretiutili, const LocHHmaskCurve & lochhmasretiCurve, bool lhmasretiutili, int llretiMask,
LUTf & lmaskretilocalcurve, bool & localmaskretiutili, const LUTf & lmaskretilocalcurve, bool localmaskretiutili,
LabImage * transformed, bool retiMasktmap, bool retiMask, LabImage * transformed, bool retiMasktmap, bool retiMask,
bool delt, const float hueref, const float chromaref, const float lumaref, bool delt, const float hueref, const float chromaref, const float lumaref,
float maxdE, float mindE, float maxdElim, float mindElim, float iterat, float limscope, int scope, float balance, float balanceh, float lumask); float maxdE, float mindE, float maxdElim, float mindElim, float iterat, float limscope, int scope, float balance, float balanceh, float lumask);
@ -424,7 +424,7 @@ public:
float MadRgb(const float * DataList, int datalen); float MadRgb(const float * DataList, int datalen);
// pyramid wavelet // pyramid wavelet
void cbdl_local_temp(float ** src, float ** loctemp, int srcwidth, int srcheight, const float * mult, float kchro, const double dirpyrThreshold, const float mergeL, const float contres, const float blurcb, const double skinprot, const bool gamutlab, float b_l, float t_l, float t_r, float b_r, int choice, int scale, bool multiThread); void cbdl_local_temp(float ** src, float ** loctemp, int srcwidth, int srcheight, const float * mult, float kchro, const double dirpyrThreshold, const float mergeL, const float contres, const double skinprot, const bool gamutlab, float b_l, float t_l, float t_r, float b_r, int choice, int scale, bool multiThread);
void dirpyr_equalizer(const float * const * src, float ** dst, int srcwidth, int srcheight, const float * const * l_a, const float * const * l_b, const double * mult, double dirpyrThreshold, double skinprot, float b_l, float t_l, float t_r, int scale); //Emil's directional pyramid wavelet void dirpyr_equalizer(const float * const * src, float ** dst, int srcwidth, int srcheight, const float * const * l_a, const float * const * l_b, const double * mult, double dirpyrThreshold, double skinprot, float b_l, float t_l, float t_r, int scale); //Emil's directional pyramid wavelet
void dirpyr_equalizercam(const CieImage* ncie, float ** src, float ** dst, int srcwidth, int srcheight, const float * const * h_p, const float * const * C_p, const double * mult, const double dirpyrThreshold, const double skinprot, float b_l, float t_l, float t_r, int scale); //Emil's directional pyramid wavelet void dirpyr_equalizercam(const CieImage* ncie, float ** src, float ** dst, int srcwidth, int srcheight, const float * const * h_p, const float * const * C_p, const double * mult, const double dirpyrThreshold, const double skinprot, float b_l, float t_l, float t_r, int scale); //Emil's directional pyramid wavelet
void defringe(LabImage* lab); void defringe(LabImage* lab);

View File

@ -485,8 +485,7 @@ void ImProcFunctions::workingtrc(const Imagefloat* src, Imagefloat* dst, int cw,
} }
GammaValues g_a; //gamma parameters GammaValues g_a; //gamma parameters
constexpr int mode = 0; Color::calcGamma(pwr, ts, g_a); // call to calcGamma with selected gamma and slope : return parameters for LCMS2
Color::calcGamma(pwr, ts, mode, g_a); // call to calcGamma with selected gamma and slope : return parameters for LCMS2
cmsFloat64Number gammaParams[7]; cmsFloat64Number gammaParams[7];

View File

@ -161,7 +161,7 @@ void calcGammaLut(double gamma, double ts, LUTf &gammaLut)
std::swap(pwr, gamm); std::swap(pwr, gamm);
} }
rtengine::Color::calcGamma(pwr, ts, 0, g_a); // call to calcGamma with selected gamma and slope rtengine::Color::calcGamma(pwr, ts, g_a); // call to calcGamma with selected gamma and slope
const double start = gamm2 < 1. ? g_a[2] : g_a[3]; const double start = gamm2 < 1. ? g_a[2] : g_a[3];
const double add = g_a[4]; const double add = g_a[4];
@ -392,7 +392,6 @@ struct local_params {
int chro, cont, sens, sensh, senscb, sensbn, senstm, sensex, sensexclu, sensden, senslc, senssf, senshs, senscolor; int chro, cont, sens, sensh, senscb, sensbn, senstm, sensex, sensexclu, sensden, senslc, senssf, senshs, senscolor;
float clarityml; float clarityml;
float contresid; float contresid;
float blurcbdl;
bool deltaem; bool deltaem;
float struco; float struco;
float strengrid; float strengrid;
@ -988,7 +987,6 @@ static void calcLocalParams(int sp, int oW, int oH, const LocallabParams& locall
int local_sensicb = locallab.spots.at(sp).sensicb; int local_sensicb = locallab.spots.at(sp).sensicb;
float local_clarityml = (float) locallab.spots.at(sp).clarityml; float local_clarityml = (float) locallab.spots.at(sp).clarityml;
float local_contresid = (float) locallab.spots.at(sp).contresid; float local_contresid = (float) locallab.spots.at(sp).contresid;
int local_blurcbdl = 0; //(float) locallab.spots.at(sp).blurcbdl;
int local_contrast = locallab.spots.at(sp).contrast; int local_contrast = locallab.spots.at(sp).contrast;
float local_lightness = (float) locallab.spots.at(sp).lightness; float local_lightness = (float) locallab.spots.at(sp).lightness;
float labgridALowloc = locallab.spots.at(sp).labgridALow; float labgridALowloc = locallab.spots.at(sp).labgridALow;
@ -1238,7 +1236,6 @@ static void calcLocalParams(int sp, int oW, int oH, const LocallabParams& locall
lp.senscb = local_sensicb; lp.senscb = local_sensicb;
lp.clarityml = local_clarityml; lp.clarityml = local_clarityml;
lp.contresid = local_contresid; lp.contresid = local_contresid;
lp.blurcbdl = local_blurcbdl;
lp.cont = local_contrast; lp.cont = local_contrast;
lp.ligh = local_lightness; lp.ligh = local_lightness;
lp.lowA = labgridALowloc; lp.lowA = labgridALowloc;
@ -10780,7 +10777,7 @@ void ImProcFunctions::Lab_Local(
lp.mulloc[5] = 1.001f; lp.mulloc[5] = 1.001f;
} }
ImProcFunctions::cbdl_local_temp(bufsh, loctemp->L, bfw, bfh, lp.mulloc, 1.f, lp.threshol, lp.clarityml, lp.contresid, lp.blurcbdl, skinprot, false, b_l, t_l, t_r, b_r, choice, sk, multiThread); ImProcFunctions::cbdl_local_temp(bufsh, loctemp->L, bfw, bfh, lp.mulloc, 1.f, lp.threshol, lp.clarityml, lp.contresid, skinprot, false, b_l, t_l, t_r, b_r, choice, sk, multiThread);
if (lp.softradiuscb > 0.f) { if (lp.softradiuscb > 0.f) {
softproc(origcbdl.get(), loctemp.get(), lp.softradiuscb, bfh, bfw, 0.001, 0.00001, 0.5f, sk, multiThread, 1); softproc(origcbdl.get(), loctemp.get(), lp.softradiuscb, bfh, bfw, 0.001, 0.00001, 0.5f, sk, multiThread, 1);
@ -10819,7 +10816,7 @@ void ImProcFunctions::Lab_Local(
} }
choice = 1; choice = 1;
ImProcFunctions::cbdl_local_temp(bufsh, loctemp->L, bfw, bfh, multc, rtengine::max(lp.chromacb, 1.f), lp.threshol, clarich, 0.f, lp.blurcbdl, skinprot, false, b_l, t_l, t_r, b_r, choice, sk, multiThread); ImProcFunctions::cbdl_local_temp(bufsh, loctemp->L, bfw, bfh, multc, rtengine::max(lp.chromacb, 1.f), lp.threshol, clarich, 0.f, skinprot, false, b_l, t_l, t_r, b_r, choice, sk, multiThread);
float minC = loctemp->L[0][0] - std::sqrt(SQR(loctemp->a[0][0]) + SQR(loctemp->b[0][0])); float minC = loctemp->L[0][0] - std::sqrt(SQR(loctemp->a[0][0]) + SQR(loctemp->b[0][0]));

View File

@ -74,7 +74,7 @@ void calcGammaLut(double gamma, double ts, LUTf &gammaLut)
std::swap(pwr, gamm); std::swap(pwr, gamm);
} }
rtengine::Color::calcGamma(pwr, ts, 0, g_a); // call to calcGamma with selected gamma and slope rtengine::Color::calcGamma(pwr, ts, g_a); // call to calcGamma with selected gamma and slope
const double start = gamm2 < 1. ? g_a[2] : g_a[3]; const double start = gamm2 < 1. ? g_a[2] : g_a[3];
const double add = g_a[4]; const double add = g_a[4];
@ -779,9 +779,9 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e
void ImProcFunctions::maskforretinex(int sp, int before, float ** luminance, float ** out, int W_L, int H_L, int skip, void ImProcFunctions::maskforretinex(int sp, int before, float ** luminance, float ** out, int W_L, int H_L, int skip,
const LocCCmaskCurve & locccmasretiCurve, bool &lcmasretiutili, const LocLLmaskCurve & locllmasretiCurve, bool &llmasretiutili, const LocHHmaskCurve & lochhmasretiCurve, bool & lhmasretiutili, const LocCCmaskCurve & locccmasretiCurve, bool lcmasretiutili, const LocLLmaskCurve & locllmasretiCurve, bool llmasretiutili, const LocHHmaskCurve & lochhmasretiCurve, bool lhmasretiutili,
int llretiMask, bool retiMasktmap, bool retiMask, float rad, float lap, bool pde, float gamm, float slop, float chro, float blend, int llretiMask, bool retiMasktmap, bool retiMask, float rad, float lap, bool pde, float gamm, float slop, float chro, float blend,
LUTf & lmaskretilocalcurve, bool & localmaskretiutili, const LUTf & lmaskretilocalcurve, bool localmaskretiutili,
LabImage * bufreti, LabImage * bufmask, LabImage * buforig, LabImage * buforigmas, bool multiThread, LabImage * bufreti, LabImage * bufmask, LabImage * buforig, LabImage * buforigmas, bool multiThread,
bool delt, const float hueref, const float chromaref, const float lumaref, bool delt, const float hueref, const float chromaref, const float lumaref,
float maxdE, float mindE, float maxdElim, float mindElim, float iterat, float limscope, int scope, float balance, float balanceh, float lumask) float maxdE, float mindE, float maxdElim, float mindElim, float iterat, float limscope, int scope, float balance, float balanceh, float lumask)
@ -1127,534 +1127,504 @@ void ImProcFunctions::maskforretinex(int sp, int before, float ** luminance, flo
void ImProcFunctions::MSRLocal(int call, int sp, bool fftw, int lum, float** reducDE, LabImage * bufreti, LabImage * bufmask, LabImage * buforig, LabImage * buforigmas, float** luminance, const float* const *originalLuminance, void ImProcFunctions::MSRLocal(int call, int sp, bool fftw, int lum, float** reducDE, LabImage * bufreti, LabImage * bufmask, LabImage * buforig, LabImage * buforigmas, float** luminance, const float* const *originalLuminance,
const int width, const int height, int bfwr, int bfhr, const procparams::LocallabParams &loc, const int skip, const LocretigainCurve &locRETgainCcurve, const LocretitransCurve &locRETtransCcurve, const int width, const int height, int bfwr, int bfhr, const procparams::LocallabParams &loc, const int skip, const LocretigainCurve &locRETgainCcurve, const LocretitransCurve &locRETtransCcurve,
const int chrome, const int scall, const float krad, float &minCD, float &maxCD, float &mini, float &maxi, float &Tmean, float &Tsigma, float &Tmin, float &Tmax, const int chrome, const int scall, const float krad, float &minCD, float &maxCD, float &mini, float &maxi, float &Tmean, float &Tsigma, float &Tmin, float &Tmax,
const LocCCmaskCurve & locccmasretiCurve, bool &lcmasretiutili, const LocLLmaskCurve & locllmasretiCurve, bool &llmasretiutili, const LocHHmaskCurve & lochhmasretiCurve, bool & lhmasretiutili, int llretiMask, const LocCCmaskCurve & locccmasretiCurve, bool lcmasretiutili, const LocLLmaskCurve & locllmasretiCurve, bool llmasretiutili, const LocHHmaskCurve & lochhmasretiCurve, bool lhmasretiutili, int llretiMask,
LUTf & lmaskretilocalcurve, bool & localmaskretiutili, const LUTf & lmaskretilocalcurve, bool localmaskretiutili,
LabImage * transformed, bool retiMasktmap, bool retiMask, LabImage * transformed, bool retiMasktmap, bool retiMask,
bool delt, const float hueref, const float chromaref, const float lumaref, bool delt, const float hueref, const float chromaref, const float lumaref,
float maxdE, float mindE, float maxdElim, float mindElim, float iterat, float limscope, int scope, float balance, float balanceh, float lumask) float maxdE, float mindE, float maxdElim, float mindElim, float iterat, float limscope, int scope, float balance, float balanceh, float lumask)
{ {
BENCHFUN BENCHFUN
bool py = true;
if (py) {//enabled float mean, stddv, maxtr, mintr;
float mean, stddv, maxtr, mintr; mean = 0.f;
mean = 0.f; stddv = 0.f;
stddv = 0.f; maxtr = 0.f;
maxtr = 0.f; mintr = 0.f;
mintr = 0.f; constexpr float eps = 2.f;
float delta; bool useHslLin = false;
constexpr float eps = 2.f; const float offse = loc.spots.at(sp).offs;
bool useHslLin = false; const float chrT = (float)(loc.spots.at(sp).chrrt) / 100.f;
const float offse = loc.spots.at(sp).offs; const int scal = (loc.spots.at(sp).scalereti);
const float chrT = (float)(loc.spots.at(sp).chrrt) / 100.f; float vart = loc.spots.at(sp).vart / 100.f;//variance
const int scal = (loc.spots.at(sp).scalereti); const float strength = loc.spots.at(sp).str / 100.f; // Blend with original L channel data
float vart = loc.spots.at(sp).vart / 100.f;//variance const float dar = loc.spots.at(sp).darkness;
const float strength = loc.spots.at(sp).str / 100.f; // Blend with original L channel data const float lig = loc.spots.at(sp).lightnessreti;
const float dar = loc.spots.at(sp).darkness; float value = pow(strength, 0.4f);
const float lig = loc.spots.at(sp).lightnessreti; float value_1 = pow(strength, 0.3f);
float value = pow(strength, 0.4f); bool logli = loc.spots.at(sp).loglin;
float value_1 = pow(strength, 0.3f); float limD = loc.spots.at(sp).limd;//10.f
bool logli = loc.spots.at(sp).loglin; limD = pow(limD, 1.7f); //about 2500 enough
float limD = loc.spots.at(sp).limd;//10.f float ilimD = 1.f / limD;
limD = pow(limD, 1.7f); //about 2500 enough float threslum = loc.spots.at(sp).limd;
float ilimD = 1.f / limD; const float elogt = 2.71828f;
float threslum = loc.spots.at(sp).limd;
const float elogt = 2.71828f;
if (!logli) { if (!logli) {
useHslLin = true; useHslLin = true;
}
//empirical skip evaluation : very difficult because quasi all parameters interfere
//to test on several images
int nei = (int)(krad * loc.spots.at(sp).neigh);
// printf("neigh=%i\n", nei);
//several test to find good values ???!!!
//very difficult to do because 4 factor are correlate with skip and cannot been solved easily
// size of spots
// radius - neigh
// scal
// variance vart
//not too bad proposition
float divsca = 1.f;
if (scal >= 3) {
divsca = sqrt(scal / 3.f);
}
if (skip >= 4) {
//nei = (int)(0.1f * nei + 2.f); //not too bad
nei = (int)(nei / (1.5f * skip)) / divsca;
vart *= sqrt(skip);
} else if (skip > 1) {
//nei = (int)(0.3f * nei + 2.f);
nei = (int)(nei / skip) / divsca;
vart *= sqrt(skip);
}
int moderetinex = 0;
if (loc.spots.at(sp).retinexMethod == "uni") {
moderetinex = 0;
} else if (loc.spots.at(sp).retinexMethod == "low") {
moderetinex = 1;
} else if (loc.spots.at(sp).retinexMethod == "high") {
moderetinex = 2;
}
const float high = 0.f; // Dummy to pass to retinex_scales(...)
constexpr auto maxRetinexScales = 10;
float RetinexScales[maxRetinexScales];
retinex_scales(RetinexScales, scal, moderetinex, nei, high);
const int H_L = height;
const int W_L = width;
std::unique_ptr<JaggedArray<float>> srcBuffer(new JaggedArray<float>(W_L, H_L));
float** src = *(srcBuffer.get());
#ifdef _OPENMP
#pragma omp parallel for
#endif
for (int i = 0; i < H_L; i++)
for (int j = 0; j < W_L; j++) {
src[i][j] = luminance[i][j] + eps;
luminance[i][j] = 0.f;
} }
//empirical skip evaluation : very difficult because quasi all parameters interfere JaggedArray<float> out(W_L, H_L);
//to test on several images
int nei = (int)(krad * loc.spots.at(sp).neigh);
// printf("neigh=%i\n", nei);
//several test to find good values ???!!!
//very difficult to do because 4 factor are correlate with skip and cannot been solved easily
// size of spots
// radius - neigh
// scal
// variance vart
//not too bad proposition
float divsca = 1.f;
if (scal >= 3) { float clipt = loc.spots.at(sp).cliptm;
divsca = sqrt(scal / 3.f);
const float logBetaGain = xlogf(16384.f);
float pond = logBetaGain / (float) scal;
if (!useHslLin) {
pond /= log(elogt);
}
float kr;//on FFTW
float kg = 1.f;//on Gaussianblur
for (int scale = scal - 1; scale >= 0; --scale) {
// printf("retscale=%f scale=%i \n", mulradiusfftw * RetinexScales[scale], scale);
//emprical adjustment between FFTW radius and Gaussainblur
//under 50 ==> 10.f
// 400 ==> 1.f
float sigm = 1.f;
if (settings->fftwsigma == false) { //empirical formula
sigm = RetinexScales[scale];
float ak = -9.f / 350.f;
float bk = 10.f - 50.f * ak;
kr = ak * sigm + bk;
if (sigm < 50.f) {
kr = 10.f;
}
//above 400 at 5000 ==> 20.f
if (sigm > 400.f) { //increase ==> 5000
float ka = 19.f / 4600.f;
float kb = 1.f - 400 * ka;
kr = ka * sigm + kb;
float kga = -0.14f / 4600.f;//decrease
float kgb = 1.f - 400.f * kga;
kg = kga * sigm + kgb;
if (sigm > 5000.f) {
kr = ka * 5000.f + kb;
kg = kga * 5000.f + kgb;
}
}
} else {//sigma *= sigma
kg = 1.f;
kr = sigm;
} }
if (skip >= 4) { if (!fftw) { // || (fftw && call != 2)) {
//nei = (int)(0.1f * nei + 2.f); //not too bad if (scale == scal - 1) {
nei = (int)(nei / (1.5f * skip)) / divsca; gaussianBlur(src, out, W_L, H_L, kg * RetinexScales[scale], true);
vart *= sqrt(skip); } else { // reuse result of last iteration
} else if (skip > 1 && skip < 4) { // out was modified in last iteration => restore it
//nei = (int)(0.3f * nei + 2.f); gaussianBlur(out, out, W_L, H_L, sqrtf(SQR(kg * RetinexScales[scale]) - SQR(kg * RetinexScales[scale + 1])), true);
nei = (int)(nei / skip) / divsca; }
vart *= sqrt(skip); } else {
if (scale == scal - 1) {
if (settings->fftwsigma == false) { //empirical formula
ImProcFunctions::fftw_convol_blur2(src, out, bfwr, bfhr, (kr * RetinexScales[scale]), 0, 0);
} else {
ImProcFunctions::fftw_convol_blur2(src, out, bfwr, bfhr, (SQR(RetinexScales[scale])), 0, 0);
}
} else { // reuse result of last iteration
// out was modified in last iteration => restore it
if (settings->fftwsigma == false) { //empirical formula
ImProcFunctions::fftw_convol_blur2(out, out, bfwr, bfhr, sqrtf(SQR(kr * RetinexScales[scale]) - SQR(kr * RetinexScales[scale + 1])), 0, 0);
} else {
ImProcFunctions::fftw_convol_blur2(out, out, bfwr, bfhr, (SQR(RetinexScales[scale]) - SQR(RetinexScales[scale + 1])), 0, 0);
}
}
} }
int moderetinex = 0; if (scale == 1) { //equalize last scale with darkness and lightness of course acts on TM!
if (dar != 1.f || lig != 1.f) {
if (loc.spots.at(sp).retinexMethod == "uni") { #ifdef _OPENMP
moderetinex = 0; #pragma omp parallel for
} else if (loc.spots.at(sp).retinexMethod == "low") { #endif
moderetinex = 1;
} else if (loc.spots.at(sp).retinexMethod == "high") { for (int y = 0; y < H_L; ++y) {
moderetinex = 2; for (int x = 0; x < W_L; ++x) {
float buf = (src[y][x] - out[y][x]) * value;
buf *= (buf > 0.f) ? lig : dar;
out[y][x] = LIM(out[y][x] + buf, -100000.f, 100000.f);
}
}
}
} }
const float high = 0.f; // Dummy to pass to retinex_scales(...)
constexpr auto maxRetinexScales = 10;
float RetinexScales[maxRetinexScales];
retinex_scales(RetinexScales, scal, moderetinex, nei, high);
const int H_L = height;
const int W_L = width;
std::unique_ptr<JaggedArray<float>> srcBuffer(new JaggedArray<float>(W_L, H_L));
float** src = *(srcBuffer.get());
#ifdef _OPENMP #ifdef _OPENMP
#pragma omp parallel for #pragma omp parallel for
#endif #endif
for (int i = 0; i < H_L; i++) for (int i = 0; i < H_L; i++) {
for (int j = 0; j < W_L; j++) { int j = 0;
src[i][j] = luminance[i][j] + eps;
luminance[i][j] = 0.f;
}
JaggedArray<float> out(W_L, H_L);
float clipt = loc.spots.at(sp).cliptm;
const float logBetaGain = xlogf(16384.f);
float pond = logBetaGain / (float) scal;
if (!useHslLin) {
pond /= log(elogt);
}
float kr = 1.f;//on FFTW
float kg = 1.f;//on Gaussianblur
std::unique_ptr<float[]> buffer;
buffer.reset(new float[W_L * H_L]);
for (int scale = scal - 1; scale >= 0; --scale) {
// printf("retscale=%f scale=%i \n", mulradiusfftw * RetinexScales[scale], scale);
//emprical adjustment between FFTW radius and Gaussainblur
//under 50 ==> 10.f
// 400 ==> 1.f
float sigm = 1.f;
if (settings->fftwsigma == false) { //empirical formula
sigm = RetinexScales[scale];
float ak = -9.f / 350.f;
float bk = 10.f - 50.f * ak;
kr = ak * sigm + bk;
if (sigm < 50.f) {
kr = 10.f;
}
//above 400 at 5000 ==> 20.f
if (sigm > 400.f) { //increase ==> 5000
float ka = 19.f / 4600.f;
float kb = 1.f - 400 * ka;
kr = ka * sigm + kb;
float kga = -0.14f / 4600.f;//decrease
float kgb = 1.f - 400.f * kga;
kg = kga * sigm + kgb;
if (sigm > 5000.f) {
kr = ka * 5000.f + kb;
kg = kga * 5000.f + kgb;
}
}
} else {//sigma *= sigma
kg = 1.f;
kr = sigm;
}
printf("call=%i\n", call);
if (!fftw) { // || (fftw && call != 2)) {
if (scale == scal - 1) {
gaussianBlur(src, out, W_L, H_L, kg * RetinexScales[scale], true);
} else { // reuse result of last iteration
// out was modified in last iteration => restore it
gaussianBlur(out, out, W_L, H_L, sqrtf(SQR(kg * RetinexScales[scale]) - SQR(kg * RetinexScales[scale + 1])), true);
}
} else {
if (scale == scal - 1) {
if (settings->fftwsigma == false) { //empirical formula
ImProcFunctions::fftw_convol_blur2(src, out, bfwr, bfhr, (kr * RetinexScales[scale]), 0, 0);
} else {
ImProcFunctions::fftw_convol_blur2(src, out, bfwr, bfhr, (SQR(RetinexScales[scale])), 0, 0);
}
} else { // reuse result of last iteration
// out was modified in last iteration => restore it
if (settings->fftwsigma == false) { //empirical formula
ImProcFunctions::fftw_convol_blur2(out, out, bfwr, bfhr, sqrtf(SQR(kr * RetinexScales[scale]) - SQR(kr * RetinexScales[scale + 1])), 0, 0);
} else {
ImProcFunctions::fftw_convol_blur2(out, out, bfwr, bfhr, (SQR(RetinexScales[scale]) - SQR(RetinexScales[scale + 1])), 0, 0);
}
}
}
if (scale == 1) { //equalize last scale with darkness and lightness of course acts on TM!
if (dar != 1.f || lig != 1.f) {
#ifdef _OPENMP
#pragma omp parallel for
#endif
for (int y = 0; y < H_L; ++y) {
for (int x = 0; x < W_L; ++x) {
float buf = (src[y][x] - out[y][x]) * value;
buf *= (buf > 0.f) ? lig : dar;
out[y][x] = LIM(out[y][x] + buf, -100000.f, 100000.f);
}
}
}
}
#ifdef _OPENMP
#pragma omp parallel for
#endif
for (int i = 0; i < H_L; i++) {
int j = 0;
#ifdef __SSE2__ #ifdef __SSE2__
const vfloat pondv = F2V(pond); const vfloat pondv = F2V(pond);
const vfloat limMinv = F2V(ilimD); const vfloat limMinv = F2V(ilimD);
const vfloat limMaxv = F2V(limD); const vfloat limMaxv = F2V(limD);
if (useHslLin) { if (useHslLin) {
for (; j < W_L - 3; j += 4) { for (; j < W_L - 3; j += 4) {
STVFU(luminance[i][j], LVFU(luminance[i][j]) + pondv * vclampf(LVFU(src[i][j]) / LVFU(out[i][j]), limMinv, limMaxv)); STVFU(luminance[i][j], LVFU(luminance[i][j]) + pondv * vclampf(LVFU(src[i][j]) / LVFU(out[i][j]), limMinv, limMaxv));
}
} else {
for (; j < W_L - 3; j += 4) {
STVFU(luminance[i][j], LVFU(luminance[i][j]) + pondv * xlogf(vclampf(LVFU(src[i][j]) / LVFU(out[i][j]), limMinv, limMaxv)));
}
} }
} else {
#endif for (; j < W_L - 3; j += 4) {
STVFU(luminance[i][j], LVFU(luminance[i][j]) + pondv * xlogf(vclampf(LVFU(src[i][j]) / LVFU(out[i][j]), limMinv, limMaxv)));
if (useHslLin) {
for (; j < W_L; j++) {
luminance[i][j] += pond * (LIM(src[i][j] / out[i][j], ilimD, limD));
}
} else {
for (; j < W_L; j++) {
luminance[i][j] += pond * xlogf(LIM(src[i][j] / out[i][j], ilimD, limD));
}
} }
} }
#endif
if (useHslLin) {
for (; j < W_L; j++) {
luminance[i][j] += pond * (LIM(src[i][j] / out[i][j], ilimD, limD));
}
} else {
for (; j < W_L; j++) {
luminance[i][j] += pond * xlogf(LIM(src[i][j] / out[i][j], ilimD, limD));
}
}
} }
// srcBuffer.reset(); }
if (scal == 1) {//only if user select scal = 1
const float threslow = threslum * 163.f;
if (scal == 1) {//only if user select scal = 1
float kval = 1.f;
#ifdef _OPENMP #ifdef _OPENMP
#pragma omp parallel for #pragma omp parallel for
#endif #endif
for (int y = 0; y < H_L; ++y) { for (int y = 0; y < H_L; ++y) {
for (int x = 0; x < W_L; ++x) { for (int x = 0; x < W_L; ++x) {
float threslow = threslum * 163.f; const float srcVal = src[y][x];
const float kval = rtengine::min(srcVal / threslow, 1.f);
if (src[y][x] < threslow) { float buf = (srcVal - out[y][x]) * value_1;
kval = src[y][x] / threslow; buf *= (buf > 0.f) ? lig : dar;
} luminance[y][x] = LIM(srcVal + (1.f + kval) * buf, -32768.f, 32768.f);
}
} }
#ifdef _OPENMP
#pragma omp parallel for
#endif
for (int y = 0; y < H_L; ++y) {
for (int x = 0; x < W_L; ++x) {
float buf = (src[y][x] - out[y][x]) * value_1;
buf *= (buf > 0.f) ? lig : dar;
luminance[y][x] = LIM(src[y][x] + (1.f + kval) * buf, -32768.f, 32768.f);
}
}
double avg = 0.f;
int ng = 0;
#ifdef _OPENMP
#pragma omp parallel for
#endif
for (int i = 0; i < H_L; i++) {
for (int j = 0; j < W_L; j++) {
avg += luminance[i][j];
ng++;
}
}
avg /= ng;
avg /= 32768.f;
avg = LIM01(avg);
float contreal = 0.5f * vart;
DiagonalCurve reti_contrast({
DCT_NURBS,
0, 0,
avg - avg * (0.6 - contreal / 250.0), avg - avg * (0.6 + contreal / 250.0),
avg + (1 - avg) * (0.6 - contreal / 250.0), avg + (1 - avg) * (0.6 + contreal / 250.0),
1, 1
});
#ifdef _OPENMP
#pragma omp parallel for
#endif
for (int i = 0; i < H_L; i++)
for (int j = 0; j < W_L; j++) {
float buf = LIM01(luminance[i][j] / 32768.f);
buf = reti_contrast.getVal(buf);
buf *= 32768.f;
luminance[i][j] = buf;
}
} }
srcBuffer.reset(); double avg = 0.f;
float str = strength * (chrome == 0 ? 1.f : 0.8f * (chrT - 0.4f));
const float maxclip = (chrome == 0 ? 32768.f : 50000.f);
if (scal != 1) {
mean = 0.f;
stddv = 0.f;
mean_stddv2(luminance, mean, stddv, W_L, H_L, maxtr, mintr);
// printf("mean=%f std=%f delta=%f maxtr=%f mintr=%f\n", mean, stddv, delta, maxtr, mintr);
if (locRETtransCcurve && mean != 0.f && stddv != 0.f) { //if curve
float asig = 0.166666f / stddv;
float bsig = 0.5f - asig * mean;
float amax = 0.333333f / (maxtr - mean - stddv);
float bmax = 1.f - amax * maxtr;
float amin = 0.333333f / (mean - stddv - mintr);
float bmin = -amin * mintr;
asig *= 500.f;
bsig *= 500.f;
amax *= 500.f;
bmax *= 500.f;
amin *= 500.f;
bmin *= 500.f;
#ifdef _OPENMP #ifdef _OPENMP
#pragma omp parallel #pragma omp parallel for reduction(+:avg)
#endif #endif
{
float absciss; for (int i = 0; i < H_L; i++) {
for (int j = 0; j < W_L; j++) {
avg += luminance[i][j];
}
}
avg /= H_L * W_L;
avg /= 32768.f;
avg = LIM01(avg);
float contreal = 0.5f * vart;
DiagonalCurve reti_contrast({
DCT_NURBS,
0, 0,
avg - avg * (0.6 - contreal / 250.0), avg - avg * (0.6 + contreal / 250.0),
avg + (1 - avg) * (0.6 - contreal / 250.0), avg + (1 - avg) * (0.6 + contreal / 250.0),
1, 1
});
#ifdef _OPENMP #ifdef _OPENMP
#pragma omp for schedule(dynamic,16) #pragma omp parallel for
#endif #endif
for (int i = 0; i < H_L; i++) for (int i = 0; i < H_L; i++) {
for (int j = 0; j < W_L; j++) { //for mintr to maxtr evalate absciss in function of original transmission for (int j = 0; j < W_L; j++) {
if (LIKELY(fabsf(luminance[i][j] - mean) < stddv)) { float buf = LIM01(luminance[i][j] / 32768.f);
absciss = asig * luminance[i][j] + bsig; buf = reti_contrast.getVal(buf);
} else if (luminance[i][j] >= mean) { buf *= 32768.f;
absciss = amax * luminance[i][j] + bmax; luminance[i][j] = buf;
} else { /*if(luminance[i][j] <= mean - stddv)*/
absciss = amin * luminance[i][j] + bmin;
}
//TODO : move multiplication by 4.f and subtraction of 1.f inside the curve
luminance[i][j] *= (-1.f + 4.f * locRETtransCcurve[absciss]); //new transmission
}
}
} }
}
}
mean = 0.f; srcBuffer.reset();
stddv = 0.f;
mean_stddv2(luminance, mean, stddv, W_L, H_L, maxtr, mintr);//new calculation of mean...
float epsil = 0.1f; float str = strength * (chrome == 0 ? 1.f : 0.8f * (chrT - 0.4f));
const float maxclip = (chrome == 0 ? 32768.f : 50000.f);
mini = mean - vart * stddv; if (scal != 1) {
mean = 0.f;
stddv = 0.f;
if (mini < mintr) { mean_stddv2(luminance, mean, stddv, W_L, H_L, maxtr, mintr);
mini = mintr + epsil;
}
maxi = mean + vart * stddv; if (locRETtransCcurve && mean != 0.f && stddv != 0.f) { //if curve
float asig = 0.166666f / stddv;
if (maxi > maxtr) { float bsig = 0.5f - asig * mean;
maxi = maxtr - epsil; float amax = 0.333333f / (maxtr - mean - stddv);
} float bmax = 1.f - amax * maxtr;
float amin = 0.333333f / (mean - stddv - mintr);
delta = maxi - mini; float bmin = -amin * mintr;
// printf("maxi=%f mini=%f mean=%f std=%f delta=%f maxtr=%f mintr=%f\n", maxi, mini, mean, stddv, delta, maxtr, mintr);
if (!delta) {
delta = 1.0f;
}
float *copylum[H_L] ALIGNED16;
float *copylumBuffer = new float[H_L * W_L];
for (int i = 0; i < H_L; i++) {
copylum[i] = &copylumBuffer[i * W_L];
}
float cdfactor = (clipt * 32768.f) / delta;
maxCD = -9999999.f;
minCD = 9999999.f;
//prepare work for curve gain
#ifdef _OPENMP
#pragma omp parallel for
#endif
for (int i = 0; i < H_L; i++) {
for (int j = 0; j < W_L; j++) {
luminance[i][j] = luminance[i][j] - mini;
}
}
mean = 0.f;
stddv = 0.f;
mean_stddv2(luminance, mean, stddv, W_L, H_L, maxtr, mintr);
// printf("meanun=%f stdun=%f maxtr=%f mintr=%f\n", mean, stddv, maxtr, mintr);
float asig = 0.f, bsig = 0.f, amax = 0.f, bmax = 0.f, amin = 0.f, bmin = 0.f;
const bool hasRetGainCurve = locRETgainCcurve && mean != 0.f && stddv != 0.f;
if (hasRetGainCurve) { //if curve
asig = 0.166666f / stddv;
bsig = 0.5f - asig * mean;
amax = 0.333333f / (maxtr - mean - stddv);
bmax = 1.f - amax * maxtr;
amin = 0.333333f / (mean - stddv - mintr);
bmin = -amin * mintr;
asig *= 500.f;
bsig *= 500.f;
amax *= 500.f;
bmax *= 500.f;
amin *= 500.f;
bmin *= 500.f;
cdfactor *= 2.f;
}
asig *= 500.f;
bsig *= 500.f;
amax *= 500.f;
bmax *= 500.f;
amin *= 500.f;
bmin *= 500.f;
#ifdef _OPENMP #ifdef _OPENMP
#pragma omp parallel #pragma omp parallel
#endif #endif
{ {
// float absciss; float absciss;
float cdmax = -999999.f, cdmin = 999999.f;
float gan = 0.5f;
#ifdef _OPENMP #ifdef _OPENMP
#pragma omp for schedule(dynamic,16) #pragma omp for schedule(dynamic,16)
#endif #endif
for (int i = 0; i < H_L; i ++) for (int i = 0; i < H_L; i++)
for (int j = 0; j < W_L; j++) { for (int j = 0; j < W_L; j++) { //for mintr to maxtr evalate absciss in function of original transmission
if (LIKELY(fabsf(luminance[i][j] - mean) < stddv)) {
if (hasRetGainCurve) { absciss = asig * luminance[i][j] + bsig;
float absciss; } else if (luminance[i][j] >= mean) {
absciss = amax * luminance[i][j] + bmax;
if (LIKELY(fabsf(luminance[i][j] - mean) < stddv)) { } else { /*if(luminance[i][j] <= mean - stddv)*/
absciss = asig * luminance[i][j] + bsig; absciss = amin * luminance[i][j] + bmin;
} else if (luminance[i][j] >= mean) {
absciss = amax * luminance[i][j] + bmax;
} else {
absciss = amin * luminance[i][j] + bmin;
}
gan = locRETgainCcurve[absciss]; //new gain function transmission
} }
//but we don't update mean stddv for display only... //TODO : move multiplication by 4.f and subtraction of 1.f inside the curve
copylum[i][j] = gan * luminance[i][j];//update data for display luminance[i][j] *= (-1.f + 4.f * locRETtransCcurve[absciss]); //new transmission
float cd = gan * cdfactor * luminance[i][j] + offse;
cdmax = cd > cdmax ? cd : cdmax;
cdmin = cd < cdmin ? cd : cdmin;
luminance[i][j] = intp(str * reducDE[i][j], clipretinex(cd, 0.f, maxclip), originalLuminance[i][j]);
} }
}
}
mean = 0.f;
stddv = 0.f;
mean_stddv2(luminance, mean, stddv, W_L, H_L, maxtr, mintr);//new calculation of mean...
float epsil = 0.1f;
mini = mean - vart * stddv;
if (mini < mintr) {
mini = mintr + epsil;
}
maxi = mean + vart * stddv;
if (maxi > maxtr) {
maxi = maxtr - epsil;
}
float delta = maxi - mini;
if (!delta) {
delta = 1.0f;
}
float *copylum[H_L] ALIGNED16;
float *copylumBuffer = new float[H_L * W_L];
for (int i = 0; i < H_L; i++) {
copylum[i] = &copylumBuffer[i * W_L];
}
float cdfactor = (clipt * 32768.f) / delta;
maxCD = -9999999.f;
minCD = 9999999.f;
//prepare work for curve gain
#ifdef _OPENMP
#pragma omp parallel for
#endif
for (int i = 0; i < H_L; i++) {
for (int j = 0; j < W_L; j++) {
luminance[i][j] = luminance[i][j] - mini;
}
}
mean = 0.f;
stddv = 0.f;
mean_stddv2(luminance, mean, stddv, W_L, H_L, maxtr, mintr);
// printf("meanun=%f stdun=%f maxtr=%f mintr=%f\n", mean, stddv, maxtr, mintr);
float asig = 0.f, bsig = 0.f, amax = 0.f, bmax = 0.f, amin = 0.f, bmin = 0.f;
const bool hasRetGainCurve = locRETgainCcurve && mean != 0.f && stddv != 0.f;
if (hasRetGainCurve) { //if curve
asig = 0.166666f / stddv;
bsig = 0.5f - asig * mean;
amax = 0.333333f / (maxtr - mean - stddv);
bmax = 1.f - amax * maxtr;
amin = 0.333333f / (mean - stddv - mintr);
bmin = -amin * mintr;
asig *= 500.f;
bsig *= 500.f;
amax *= 500.f;
bmax *= 500.f;
amin *= 500.f;
bmin *= 500.f;
cdfactor *= 2.f;
}
#ifdef _OPENMP #ifdef _OPENMP
#pragma omp critical #pragma omp parallel
#endif #endif
{ {
maxCD = maxCD > cdmax ? maxCD : cdmax; // float absciss;
minCD = minCD < cdmin ? minCD : cdmin; float cdmax = -999999.f, cdmin = 999999.f;
} float gan = 0.5f;
}
mean = 0.f;
stddv = 0.f;
mean_stddv2(copylum, mean, stddv, W_L, H_L, maxtr, mintr);
delete [] copylumBuffer;
copylumBuffer = nullptr;
// printf("mean=%f std=%f maxtr=%f mintr=%f\n", mean, stddv, maxtr, mintr);
} else {
#ifdef _OPENMP #ifdef _OPENMP
#pragma omp for schedule(dynamic,16) #pragma omp for schedule(dynamic,16)
#endif #endif
for (int i = 0; i < H_L; i ++) for (int i = 0; i < H_L; i ++)
for (int j = 0; j < W_L; j++) { for (int j = 0; j < W_L; j++) {
luminance[i][j] = LIM(luminance[i][j], 0.f, maxclip) * str + (1.f - str) * originalLuminance[i][j];
if (hasRetGainCurve) {
float absciss;
if (LIKELY(fabsf(luminance[i][j] - mean) < stddv)) {
absciss = asig * luminance[i][j] + bsig;
} else if (luminance[i][j] >= mean) {
absciss = amax * luminance[i][j] + bmax;
} else {
absciss = amin * luminance[i][j] + bmin;
}
gan = locRETgainCcurve[absciss]; //new gain function transmission
}
//but we don't update mean stddv for display only...
copylum[i][j] = gan * luminance[i][j];//update data for display
float cd = gan * cdfactor * luminance[i][j] + offse;
cdmax = cd > cdmax ? cd : cdmax;
cdmin = cd < cdmin ? cd : cdmin;
luminance[i][j] = intp(str * reducDE[i][j], clipretinex(cd, 0.f, maxclip), originalLuminance[i][j]);
} }
#ifdef _OPENMP
#pragma omp critical
#endif
{
maxCD = maxCD > cdmax ? maxCD : cdmax;
minCD = minCD < cdmin ? minCD : cdmin;
}
} }
mean = 0.f;
stddv = 0.f;
float rad = loc.spots.at(sp).radmaskreti; mean_stddv2(copylum, mean, stddv, W_L, H_L, maxtr, mintr);
float slop = loc.spots.at(sp).slomaskreti; delete [] copylumBuffer;
float gamm = loc.spots.at(sp).gammaskreti; copylumBuffer = nullptr;
float blend = loc.spots.at(sp).blendmaskreti;
float chro = loc.spots.at(sp).chromaskreti;
float lap = loc.spots.at(sp).lapmaskreti;
bool pde = params->locallab.spots.at(sp).laplac;
if (lum == 1 && (llretiMask == 3 || llretiMask == 0 || llretiMask == 2 || llretiMask == 4)) { //only mask with luminance on last scale } else {
int before = 1; #ifdef _OPENMP
maskforretinex(sp, before, luminance, nullptr, W_L, H_L, skip, #pragma omp for schedule(dynamic,16)
locccmasretiCurve, lcmasretiutili, locllmasretiCurve, llmasretiutili, lochhmasretiCurve, lhmasretiutili, llretiMask, retiMasktmap, retiMask, #endif
rad, lap, pde, gamm, slop, chro, blend,
lmaskretilocalcurve, localmaskretiutili,
bufreti, bufmask, buforig, buforigmas, multiThread,
delt, hueref, chromaref, lumaref,
maxdE, mindE, maxdElim, mindElim, iterat, limscope, scope, balance, balanceh, lumask
);
}
//mask does not interfered with data displayed for (int i = 0; i < H_L; i ++)
for (int j = 0; j < W_L; j++) {
luminance[i][j] = LIM(luminance[i][j], 0.f, maxclip) * str + (1.f - str) * originalLuminance[i][j];
}
Tmean = mean;
Tsigma = stddv;
Tmin = mintr;
Tmax = maxtr;
} }
float rad = loc.spots.at(sp).radmaskreti;
float slop = loc.spots.at(sp).slomaskreti;
float gamm = loc.spots.at(sp).gammaskreti;
float blend = loc.spots.at(sp).blendmaskreti;
float chro = loc.spots.at(sp).chromaskreti;
float lap = loc.spots.at(sp).lapmaskreti;
bool pde = params->locallab.spots.at(sp).laplac;
if (lum == 1 && (llretiMask == 3 || llretiMask == 0 || llretiMask == 2 || llretiMask == 4)) { //only mask with luminance on last scale
int before = 1;
maskforretinex(sp, before, luminance, nullptr, W_L, H_L, skip,
locccmasretiCurve, lcmasretiutili, locllmasretiCurve, llmasretiutili, lochhmasretiCurve, lhmasretiutili, llretiMask, retiMasktmap, retiMask,
rad, lap, pde, gamm, slop, chro, blend,
lmaskretilocalcurve, localmaskretiutili,
bufreti, bufmask, buforig, buforigmas, multiThread,
delt, hueref, chromaref, lumaref,
maxdE, mindE, maxdElim, mindElim, iterat, limscope, scope, balance, balanceh, lumask
);
}
//mask does not interfered with data displayed
Tmean = mean;
Tsigma = stddv;
Tmin = mintr;
Tmax = maxtr;
} }
} }

View File

@ -283,20 +283,20 @@ void calcFrameBrightnessFactor(unsigned int frame, uint32_t datalen, LUTu *histo
{ {
float medians[4]; float medians[4];
for(int i = 0; i < 4; ++i) { for (int i = 0; i < 4; ++i) {
//find median of histogram //find median of histogram
uint32_t median = 0, count = 0; uint32_t lmedian = 0, count = 0;
while(count < datalen / 2) { while (count < datalen / 2) {
count += (*histo[i])[median]; count += (*histo[i])[lmedian];
++median; ++lmedian;
} }
const float weight = (count - datalen / 2.f) / (*histo[i])[median - 1]; const float weight = (count - datalen / 2.f) / (*histo[i])[lmedian - 1];
medians[i] = rtengine::intp(weight, (float)(median - 2), (float)(median - 1)); medians[i] = rtengine::intp(weight, (float)(lmedian - 2), (float)(lmedian - 1));
} }
for(int i = 0; i < 4; ++i) { for (int i = 0; i < 4; ++i) {
brightnessFactor[i] = medians[frame] / medians[i]; brightnessFactor[i] = medians[frame] / medians[i];
} }

View File

@ -686,7 +686,7 @@ enum ProcEventCode {
EvLocallabcontresid = 660, EvLocallabcontresid = 660,
Evlocallabnoiselumf0 = 661, Evlocallabnoiselumf0 = 661,
Evlocallabnoiselumf2 = 662, Evlocallabnoiselumf2 = 662,
EvLocallabblurcbdl = 663, //EvLocallabblurcbdl = 663,
Evlocallabblendmaskcb = 664, Evlocallabblendmaskcb = 664,
Evlocallabradmaskcb = 665, Evlocallabradmaskcb = 665,
Evlocallabchromaskcb = 666, Evlocallabchromaskcb = 666,

View File

@ -3686,7 +3686,6 @@ LocallabParams::LocallabSpot::LocallabSpot() :
sensicb(60), sensicb(60),
clarityml(0.1), clarityml(0.1),
contresid(0), contresid(0),
blurcbdl(0.),
softradiuscb(0.0), softradiuscb(0.0),
enacbMask(false), enacbMask(false),
CCmaskcbcurve{ CCmaskcbcurve{
@ -4309,7 +4308,6 @@ bool LocallabParams::LocallabSpot::operator ==(const LocallabSpot& other) const
&& sensicb == other.sensicb && sensicb == other.sensicb
&& clarityml == other.clarityml && clarityml == other.clarityml
&& contresid == other.contresid && contresid == other.contresid
&& blurcbdl == other.blurcbdl
&& softradiuscb == other.softradiuscb && softradiuscb == other.softradiuscb
&& enacbMask == other.enacbMask && enacbMask == other.enacbMask
&& CCmaskcbcurve == other.CCmaskcbcurve && CCmaskcbcurve == other.CCmaskcbcurve
@ -5833,7 +5831,6 @@ int ProcParams::save(const Glib::ustring& fname, const Glib::ustring& fname2, bo
saveToKeyfile(!pedited || spot_edited->sensicb, "Locallab", "Sensicb_" + index_str, spot.sensicb, keyFile); saveToKeyfile(!pedited || spot_edited->sensicb, "Locallab", "Sensicb_" + index_str, spot.sensicb, keyFile);
saveToKeyfile(!pedited || spot_edited->clarityml, "Locallab", "Clarityml_" + index_str, spot.clarityml, keyFile); saveToKeyfile(!pedited || spot_edited->clarityml, "Locallab", "Clarityml_" + index_str, spot.clarityml, keyFile);
saveToKeyfile(!pedited || spot_edited->contresid, "Locallab", "Contresid_" + index_str, spot.contresid, keyFile); saveToKeyfile(!pedited || spot_edited->contresid, "Locallab", "Contresid_" + index_str, spot.contresid, keyFile);
saveToKeyfile(!pedited || spot_edited->blurcbdl, "Locallab", "Blurcbdl_" + index_str, spot.blurcbdl, keyFile);
saveToKeyfile(!pedited || spot_edited->softradiuscb, "Locallab", "Softradiuscb_" + index_str, spot.softradiuscb, keyFile); saveToKeyfile(!pedited || spot_edited->softradiuscb, "Locallab", "Softradiuscb_" + index_str, spot.softradiuscb, keyFile);
saveToKeyfile(!pedited || spot_edited->enacbMask, "Locallab", "EnacbMask_" + index_str, spot.enacbMask, keyFile); saveToKeyfile(!pedited || spot_edited->enacbMask, "Locallab", "EnacbMask_" + index_str, spot.enacbMask, keyFile);
saveToKeyfile(!pedited || spot_edited->CCmaskcbcurve, "Locallab", "CCmaskcbCurve_" + index_str, spot.CCmaskcbcurve, keyFile); saveToKeyfile(!pedited || spot_edited->CCmaskcbcurve, "Locallab", "CCmaskcbCurve_" + index_str, spot.CCmaskcbcurve, keyFile);
@ -7577,7 +7574,6 @@ int ProcParams::load(const Glib::ustring& fname, ParamsEdited* pedited)
assignFromKeyfile(keyFile, "Locallab", "Sensicb_" + index_str, pedited, spot.sensicb, spotEdited.sensicb); assignFromKeyfile(keyFile, "Locallab", "Sensicb_" + index_str, pedited, spot.sensicb, spotEdited.sensicb);
assignFromKeyfile(keyFile, "Locallab", "Clarityml_" + index_str, pedited, spot.clarityml, spotEdited.clarityml); assignFromKeyfile(keyFile, "Locallab", "Clarityml_" + index_str, pedited, spot.clarityml, spotEdited.clarityml);
assignFromKeyfile(keyFile, "Locallab", "Contresid_" + index_str, pedited, spot.contresid, spotEdited.contresid); assignFromKeyfile(keyFile, "Locallab", "Contresid_" + index_str, pedited, spot.contresid, spotEdited.contresid);
assignFromKeyfile(keyFile, "Locallab", "Blurcbdl_" + index_str, pedited, spot.blurcbdl, spotEdited.blurcbdl);
assignFromKeyfile(keyFile, "Locallab", "Softradiuscb_" + index_str, pedited, spot.softradiuscb, spotEdited.softradiuscb); assignFromKeyfile(keyFile, "Locallab", "Softradiuscb_" + index_str, pedited, spot.softradiuscb, spotEdited.softradiuscb);
assignFromKeyfile(keyFile, "Locallab", "EnacbMask_" + index_str, pedited, spot.enacbMask, spotEdited.enacbMask); assignFromKeyfile(keyFile, "Locallab", "EnacbMask_" + index_str, pedited, spot.enacbMask, spotEdited.enacbMask);
assignFromKeyfile(keyFile, "Locallab", "CCmaskcbCurve_" + index_str, pedited, spot.CCmaskcbcurve, spotEdited.CCmaskcbcurve); assignFromKeyfile(keyFile, "Locallab", "CCmaskcbCurve_" + index_str, pedited, spot.CCmaskcbcurve, spotEdited.CCmaskcbcurve);

View File

@ -1397,7 +1397,6 @@ struct LocallabParams {
int sensicb; int sensicb;
double clarityml; double clarityml;
int contresid; int contresid;
double blurcbdl;
double softradiuscb; double softradiuscb;
bool enacbMask; bool enacbMask;
std::vector<double> CCmaskcbcurve; std::vector<double> CCmaskcbcurve;

View File

@ -1717,10 +1717,8 @@ void RawImageSource::retinexPrepareBuffers(const ColorManagementParams& cmp, con
std::swap(pwr, gamm); std::swap(pwr, gamm);
} }
int mode = 0; Color::calcGamma(pwr, ts, g_a); // call to calcGamma with selected gamma and slope
Color::calcGamma(pwr, ts, mode, g_a); // call to calcGamma with selected gamma and slope
// printf("g_a0=%f g_a1=%f g_a2=%f g_a3=%f g_a4=%f\n", g_a0,g_a1,g_a2,g_a3,g_a4);
double start; double start;
double add; double add;
@ -1984,13 +1982,12 @@ void RawImageSource::retinex(const ColorManagementParams& cmp, const RetinexPara
double gamm = deh.gam; double gamm = deh.gam;
double gamm2 = gamm; double gamm2 = gamm;
double ts = deh.slope; double ts = deh.slope;
int mode = 0;
if (gamm2 < 1.) { if (gamm2 < 1.) {
std::swap(pwr, gamm); std::swap(pwr, gamm);
} }
Color::calcGamma(pwr, ts, mode, g_a); // call to calcGamma with selected gamma and slope Color::calcGamma(pwr, ts, g_a); // call to calcGamma with selected gamma and slope
double mul = 1. + g_a[4]; double mul = 1. + g_a[4];
double add; double add;

View File

@ -690,7 +690,7 @@ int refreshmap[rtengine::NUMOFEVENTS] = {
LUMINANCECURVE, // EvLocallabcontresid LUMINANCECURVE, // EvLocallabcontresid
LUMINANCECURVE, // Evlocallabnoiselumf0 LUMINANCECURVE, // Evlocallabnoiselumf0
LUMINANCECURVE, // Evlocallabnoiselumf2 LUMINANCECURVE, // Evlocallabnoiselumf2
LUMINANCECURVE, // Evlocallabblurcbdl 0, // Evlocallabblurcbdl
LUMINANCECURVE, // Evlocallabblendmaskcb LUMINANCECURVE, // Evlocallabblendmaskcb
LUMINANCECURVE, // Evlocallabradmaskcb LUMINANCECURVE, // Evlocallabradmaskcb
LUMINANCECURVE, // Evlocallabchromaskcb LUMINANCECURVE, // Evlocallabchromaskcb

View File

@ -1180,7 +1180,6 @@ void ImProcFunctions::ToneMapFattal02(Imagefloat *rgb, const FattalToneMappingPa
scale = (oldMedian == 0.f || newMedian == 0.f) ? 65535.f : (oldMedian / newMedian); // avoid Nan scale = (oldMedian == 0.f || newMedian == 0.f) ? 65535.f : (oldMedian / newMedian); // avoid Nan
} else { } else {
scale = 65535.f;
{ {
float ratio = 0.f; float ratio = 0.f;
int ww, hh; int ww, hh;

View File

@ -309,7 +309,6 @@ ControlSpotPanel::ControlSpotPanel():
sigc::mem_fun( sigc::mem_fun(
*this, &ControlSpotPanel::qualityMethodChanged)); *this, &ControlSpotPanel::qualityMethodChanged));
ctboxqualitymethod->pack_start(*qualityMethod_); ctboxqualitymethod->pack_start(*qualityMethod_);
// pack_start(*ctboxqualitymethod);
if (showtooltip) { if (showtooltip) {
expTransGrad_->set_tooltip_text(M("TP_LOCALLAB_TRANSIT_TOOLTIP")); expTransGrad_->set_tooltip_text(M("TP_LOCALLAB_TRANSIT_TOOLTIP"));
@ -319,21 +318,9 @@ ControlSpotPanel::ControlSpotPanel():
if (showtooltip) { if (showtooltip) {
transit_->set_tooltip_text(M("TP_LOCALLAB_TRANSIT_TOOLTIP")); transit_->set_tooltip_text(M("TP_LOCALLAB_TRANSIT_TOOLTIP"));
}
if (showtooltip) {
transitweak_->set_tooltip_text(M("TP_LOCALLAB_TRANSITWEAK_TOOLTIP")); transitweak_->set_tooltip_text(M("TP_LOCALLAB_TRANSITWEAK_TOOLTIP"));
}
if (showtooltip) {
feather_->set_tooltip_text(M("TP_LOCALLAB_FEATH_TOOLTIP")); feather_->set_tooltip_text(M("TP_LOCALLAB_FEATH_TOOLTIP"));
}
if (showtooltip) {
transitgrad_->set_tooltip_text(M("TP_LOCALLAB_TRANSITGRAD_TOOLTIP")); transitgrad_->set_tooltip_text(M("TP_LOCALLAB_TRANSITGRAD_TOOLTIP"));
}
if (showtooltip) {
scopemask_->set_tooltip_text(M("TP_LOCALLAB_SCOPEMASK_TOOLTIP")); scopemask_->set_tooltip_text(M("TP_LOCALLAB_SCOPEMASK_TOOLTIP"));
} }

View File

@ -470,9 +470,8 @@ void HistogramRGBArea::updateBackBuffer (int r, int g, int b, const Glib::ustrin
cc->set_antialias(Cairo::ANTIALIAS_NONE); cc->set_antialias(Cairo::ANTIALIAS_NONE);
cc->set_line_width (1.0 * s); cc->set_line_width (1.0 * s);
double xpos;
if ( r != -1 && g != -1 && b != -1 ) { if ( r != -1 && g != -1 && b != -1 ) {
double xpos;
if (needRed) { if (needRed) {
// Red // Red
cc->set_source_rgb(1.0, 0.0, 0.0); cc->set_source_rgb(1.0, 0.0, 0.0);

View File

@ -881,8 +881,7 @@ void ICCProfileCreator::savePressed()
double ts = slope; double ts = slope;
double slope2 = slope == 0 ? eps : slope; double slope2 = slope == 0 ? eps : slope;
int mode = 0; rtengine::Color::calcGamma(pwr, ts, g_a); // call to calcGamma with selected gamma and slope : return parameters for LCMS2
rtengine::Color::calcGamma(pwr, ts, mode, g_a); // call to calcGamma with selected gamma and slope : return parameters for LCMS2
ga[4] = g_a[3] * ts; ga[4] = g_a[3] * ts;
//printf("g_a.gamma0=%f g_a.gamma1=%f g_a.gamma2=%f g_a.gamma3=%f g_a.gamma4=%f\n", g_a.gamma0,g_a.gamma1,g_a.gamma2,g_a.gamma3,g_a.gamma4); //printf("g_a.gamma0=%f g_a.gamma1=%f g_a.gamma2=%f g_a.gamma3=%f g_a.gamma4=%f\n", g_a.gamma0,g_a.gamma1,g_a.gamma2,g_a.gamma3,g_a.gamma4);
ga[0] = gamma; ga[0] = gamma;

View File

@ -1093,7 +1093,6 @@ private:
Gtk::Frame* const levFrame; Gtk::Frame* const levFrame;
Adjuster* const chromacbdl; Adjuster* const chromacbdl;
Adjuster* const threshold; Adjuster* const threshold;
Adjuster* const blurcbdl;
Adjuster* const clarityml; Adjuster* const clarityml;
Adjuster* const contresid; Adjuster* const contresid;
Adjuster* const softradiuscb; Adjuster* const softradiuscb;

View File

@ -438,159 +438,63 @@ void LocallabTone::setDefaults(const rtengine::procparams::ProcParams* defParams
void LocallabTone::adjusterChanged(Adjuster* a, double newval) void LocallabTone::adjusterChanged(Adjuster* a, double newval)
{ {
if (isLocActivated && exp->getEnabled()) { if (isLocActivated && exp->getEnabled() && listener) {
const auto spName = " (" + escapeHtmlChars(spotName) + ")";
if (a == amount) { if (a == amount) {
if (listener) { listener->panelChanged(Evlocallabamount, amount->getTextValue() + spName);
listener->panelChanged(Evlocallabamount, } else if (a == stren) {
amount->getTextValue() + " (" + escapeHtmlChars(spotName) + ")"); listener->panelChanged(Evlocallabstren, stren->getTextValue() + spName);
} } else if (a == gamma) {
} listener->panelChanged(Evlocallabgamma, gamma->getTextValue() + spName);
} else if (a == satur) {
if (a == stren) { listener->panelChanged(Evlocallabsatur, satur->getTextValue() + spName);
if (listener) { } else if (a == estop) {
listener->panelChanged(Evlocallabstren, listener->panelChanged(Evlocallabestop, estop->getTextValue() + spName);
stren->getTextValue() + " (" + escapeHtmlChars(spotName) + ")"); } else if (a == scaltm) {
} listener->panelChanged(Evlocallabscaltm, scaltm->getTextValue() + spName);
} } else if (a == rewei) {
listener->panelChanged(Evlocallabrewei, rewei->getTextValue() + spName);
if (a == gamma) { } else if (a == softradiustm) {
if (listener) { listener->panelChanged(Evlocallabsoftradiustm, softradiustm->getTextValue() + spName);
listener->panelChanged(Evlocallabgamma, } else if (a == sensitm) {
gamma->getTextValue() + " (" + escapeHtmlChars(spotName) + ")"); listener->panelChanged(Evlocallabsensitm, sensitm->getTextValue() + spName);
} } else if (a == blendmasktm) {
} listener->panelChanged(Evlocallabblendmasktm, blendmasktm->getTextValue() + spName);
} else if (a == lapmasktm) {
if (a == satur) { listener->panelChanged(Evlocallablapmasktm, lapmasktm->getTextValue() + spName);
if (listener) { } else if (a == radmasktm) {
listener->panelChanged(Evlocallabsatur, listener->panelChanged(Evlocallabradmasktm, radmasktm->getTextValue() + spName);
satur->getTextValue() + " (" + escapeHtmlChars(spotName) + ")"); } else if (a == chromasktm) {
} listener->panelChanged(Evlocallabchromasktm, chromasktm->getTextValue() + spName);
} } else if (a == gammasktm) {
listener->panelChanged(Evlocallabgammasktm, gammasktm->getTextValue() + spName);
if (a == estop) { } else if (a == slomasktm) {
if (listener) { listener->panelChanged(Evlocallabslomasktm, slomasktm->getTextValue() + spName);
listener->panelChanged(Evlocallabestop,
estop->getTextValue() + " (" + escapeHtmlChars(spotName) + ")");
}
}
if (a == scaltm) {
if (listener) {
listener->panelChanged(Evlocallabscaltm,
scaltm->getTextValue() + " (" + escapeHtmlChars(spotName) + ")");
}
}
if (a == rewei) {
if (listener) {
listener->panelChanged(Evlocallabrewei,
rewei->getTextValue() + " (" + escapeHtmlChars(spotName) + ")");
}
}
if (a == softradiustm) {
if (listener) {
listener->panelChanged(Evlocallabsoftradiustm,
softradiustm->getTextValue() + " (" + escapeHtmlChars(spotName) + ")");
}
}
if (a == sensitm) {
if (listener) {
listener->panelChanged(Evlocallabsensitm,
sensitm->getTextValue() + " (" + escapeHtmlChars(spotName) + ")");
}
}
if (a == blendmasktm) {
if (listener) {
listener->panelChanged(Evlocallabblendmasktm,
blendmasktm->getTextValue() + " (" + escapeHtmlChars(spotName) + ")");
}
}
if (a == lapmasktm) {
if (listener) {
listener->panelChanged(Evlocallablapmasktm,
lapmasktm->getTextValue() + " (" + escapeHtmlChars(spotName) + ")");
}
}
if (a == radmasktm) {
if (listener) {
listener->panelChanged(Evlocallabradmasktm,
radmasktm->getTextValue() + " (" + escapeHtmlChars(spotName) + ")");
}
}
if (a == chromasktm) {
if (listener) {
listener->panelChanged(Evlocallabchromasktm,
chromasktm->getTextValue() + " (" + escapeHtmlChars(spotName) + ")");
}
}
if (a == gammasktm) {
if (listener) {
listener->panelChanged(Evlocallabgammasktm,
gammasktm->getTextValue() + " (" + escapeHtmlChars(spotName) + ")");
}
}
if (a == slomasktm) {
if (listener) {
listener->panelChanged(Evlocallabslomasktm,
slomasktm->getTextValue() + " (" + escapeHtmlChars(spotName) + ")");
}
} }
} }
} }
void LocallabTone::curveChanged(CurveEditor* ce) void LocallabTone::curveChanged(CurveEditor* ce)
{ {
if (isLocActivated && exp->getEnabled()) { if (isLocActivated && exp->getEnabled() && listener) {
const auto spName = M("HISTORY_CUSTOMCURVE") + " (" + escapeHtmlChars(spotName) + ")";
if (ce == CCmasktmshape) { if (ce == CCmasktmshape) {
if (listener) { listener->panelChanged(EvlocallabCCmasktmshape, spName);
listener->panelChanged(EvlocallabCCmasktmshape, } else if (ce == LLmasktmshape) {
M("HISTORY_CUSTOMCURVE") + " (" + escapeHtmlChars(spotName) + ")"); listener->panelChanged(EvlocallabLLmasktmshape, spName);
} } else if (ce == HHmasktmshape) {
} listener->panelChanged(EvlocallabHHmasktmshape, spName);
} else if (ce == Lmasktmshape) {
if (ce == LLmasktmshape) { listener->panelChanged(EvlocallabLmasktmshape, spName);
if (listener) {
listener->panelChanged(EvlocallabLLmasktmshape,
M("HISTORY_CUSTOMCURVE") + " (" + escapeHtmlChars(spotName) + ")");
}
}
if (ce == HHmasktmshape) {
if (listener) {
listener->panelChanged(EvlocallabHHmasktmshape,
M("HISTORY_CUSTOMCURVE") + " (" + escapeHtmlChars(spotName) + ")");
}
}
if (ce == Lmasktmshape) {
if (listener) {
listener->panelChanged(EvlocallabLmasktmshape,
M("HISTORY_CUSTOMCURVE") + " (" + escapeHtmlChars(spotName) + ")");
}
} }
} }
} }
void LocallabTone::enabledChanged() void LocallabTone::enabledChanged()
{ {
if (isLocActivated) { if (isLocActivated && listener) {
if (listener) { listener->panelChanged(EvLocenatonemap, (exp->getEnabled() ? M("GENERAL_ENABLED") : M("GENERAL_DISABLED"))
if (exp->getEnabled()) { + " (" + escapeHtmlChars(spotName) + ")");
listener->panelChanged(EvLocenatonemap,
M("GENERAL_ENABLED") + " (" + escapeHtmlChars(spotName) + ")");
} else {
listener->panelChanged(EvLocenatonemap,
M("GENERAL_DISABLED") + " (" + escapeHtmlChars(spotName) + ")");
}
}
} }
} }
@ -3686,7 +3590,6 @@ LocallabCBDL::LocallabCBDL():
levFrame(Gtk::manage(new Gtk::Frame(M("TP_LOCALLAB_LEVFRA")))), levFrame(Gtk::manage(new Gtk::Frame(M("TP_LOCALLAB_LEVFRA")))),
chromacbdl(Gtk::manage(new Adjuster(M("TP_LOCALLAB_CHROMACBDL"), 0., 1.5, 0.01, 0.))), chromacbdl(Gtk::manage(new Adjuster(M("TP_LOCALLAB_CHROMACBDL"), 0., 1.5, 0.01, 0.))),
threshold(Gtk::manage(new Adjuster(M("TP_DIRPYREQUALIZER_THRESHOLD"), 0, 1., 0.01, 0.2))), threshold(Gtk::manage(new Adjuster(M("TP_DIRPYREQUALIZER_THRESHOLD"), 0, 1., 0.01, 0.2))),
blurcbdl(Gtk::manage(new Adjuster(M("TP_LOCALLAB_BLURCBDL"), 0., 100., 0.1, 0.))),
clarityml(Gtk::manage(new Adjuster(M("TP_LOCALLAB_CLARITYML"), 0.1, 100., 0.1, 0.1))), clarityml(Gtk::manage(new Adjuster(M("TP_LOCALLAB_CLARITYML"), 0.1, 100., 0.1, 0.1))),
contresid(Gtk::manage(new Adjuster(M("TP_LOCALLAB_CONTRESID"), -100, 100, 1, 0))), contresid(Gtk::manage(new Adjuster(M("TP_LOCALLAB_CONTRESID"), -100, 100, 1, 0))),
softradiuscb(Gtk::manage(new Adjuster(M("TP_LOCALLAB_SOFTRADIUSCOL"), 0.0, 100.0, 0.5, 0.))), softradiuscb(Gtk::manage(new Adjuster(M("TP_LOCALLAB_SOFTRADIUSCOL"), 0.0, 100.0, 0.5, 0.))),
@ -3722,8 +3625,6 @@ LocallabCBDL::LocallabCBDL():
threshold->setAdjusterListener(this); threshold->setAdjusterListener(this);
blurcbdl->setAdjusterListener(this);
clarityml->setAdjusterListener(this); clarityml->setAdjusterListener(this);
contresid->setAdjusterListener(this); contresid->setAdjusterListener(this);
@ -3806,7 +3707,6 @@ LocallabCBDL::LocallabCBDL():
levBox->pack_start(*threshold); levBox->pack_start(*threshold);
levFrame->add(*levBox); levFrame->add(*levBox);
pack_start(*levFrame); pack_start(*levFrame);
// pack_start(*blurcbdl);
Gtk::Frame* const residFrame = Gtk::manage(new Gtk::Frame(M("TP_LOCALLAB_RESID"))); Gtk::Frame* const residFrame = Gtk::manage(new Gtk::Frame(M("TP_LOCALLAB_RESID")));
residFrame->set_label_align(0.025, 0.5); residFrame->set_label_align(0.025, 0.5);
ToolParamBlock* const residBox = Gtk::manage(new ToolParamBlock()); ToolParamBlock* const residBox = Gtk::manage(new ToolParamBlock());
@ -3932,7 +3832,6 @@ void LocallabCBDL::read(const rtengine::procparams::ProcParams* pp, const Params
chromacbdl->setValue(spot.chromacbdl); chromacbdl->setValue(spot.chromacbdl);
threshold->setValue(spot.threshold); threshold->setValue(spot.threshold);
blurcbdl->setValue(spot.blurcbdl);
clarityml->setValue(spot.clarityml); clarityml->setValue(spot.clarityml);
contresid->setValue((double)spot.contresid); contresid->setValue((double)spot.contresid);
softradiuscb->setValue(spot.softradiuscb); softradiuscb->setValue(spot.softradiuscb);
@ -3976,7 +3875,6 @@ void LocallabCBDL::write(rtengine::procparams::ProcParams* pp, ParamsEdited* ped
spot.chromacbdl = chromacbdl->getValue(); spot.chromacbdl = chromacbdl->getValue();
spot.threshold = threshold->getValue(); spot.threshold = threshold->getValue();
spot.blurcbdl = blurcbdl->getValue();
spot.clarityml = clarityml->getValue(); spot.clarityml = clarityml->getValue();
spot.contresid = contresid->getIntValue(); spot.contresid = contresid->getIntValue();
spot.softradiuscb = softradiuscb->getValue(); spot.softradiuscb = softradiuscb->getValue();
@ -4011,7 +3909,6 @@ void LocallabCBDL::setDefaults(const rtengine::procparams::ProcParams* defParams
chromacbdl->setDefault(defSpot.chromacbdl); chromacbdl->setDefault(defSpot.chromacbdl);
threshold->setDefault(defSpot.threshold); threshold->setDefault(defSpot.threshold);
blurcbdl->setDefault(defSpot.blurcbdl);
clarityml->setDefault(defSpot.clarityml); clarityml->setDefault(defSpot.clarityml);
contresid->setDefault((double)defSpot.contresid); contresid->setDefault((double)defSpot.contresid);
softradiuscb->setDefault(defSpot.softradiuscb); softradiuscb->setDefault(defSpot.softradiuscb);
@ -4058,13 +3955,6 @@ void LocallabCBDL::adjusterChanged(Adjuster* a, double newval)
} }
} }
if (a == blurcbdl) {
if (listener) {
listener->panelChanged(EvLocallabblurcbdl,
blurcbdl->getTextValue() + " (" + escapeHtmlChars(spotName) + ")");
}
}
if (a == clarityml) { if (a == clarityml) {
if (listener) { if (listener) {
listener->panelChanged(EvLocallabclarityml, listener->panelChanged(EvLocallabclarityml,

View File

@ -1452,7 +1452,6 @@ void ParamsEdited::initFrom(const std::vector<rtengine::procparams::ProcParams>&
locallab.spots.at(j).sensicb = locallab.spots.at(j).sensicb && pSpot.sensicb == otherSpot.sensicb; locallab.spots.at(j).sensicb = locallab.spots.at(j).sensicb && pSpot.sensicb == otherSpot.sensicb;
locallab.spots.at(j).clarityml = locallab.spots.at(j).clarityml && pSpot.clarityml == otherSpot.clarityml; locallab.spots.at(j).clarityml = locallab.spots.at(j).clarityml && pSpot.clarityml == otherSpot.clarityml;
locallab.spots.at(j).contresid = locallab.spots.at(j).contresid && pSpot.contresid == otherSpot.contresid; locallab.spots.at(j).contresid = locallab.spots.at(j).contresid && pSpot.contresid == otherSpot.contresid;
locallab.spots.at(j).blurcbdl = locallab.spots.at(j).blurcbdl && pSpot.blurcbdl == otherSpot.blurcbdl;
locallab.spots.at(j).softradiuscb = locallab.spots.at(j).softradiuscb && pSpot.softradiuscb == otherSpot.softradiuscb; locallab.spots.at(j).softradiuscb = locallab.spots.at(j).softradiuscb && pSpot.softradiuscb == otherSpot.softradiuscb;
locallab.spots.at(j).enacbMask = locallab.spots.at(j).enacbMask && pSpot.enacbMask == otherSpot.enacbMask; locallab.spots.at(j).enacbMask = locallab.spots.at(j).enacbMask && pSpot.enacbMask == otherSpot.enacbMask;
locallab.spots.at(j).CCmaskcbcurve = locallab.spots.at(j).CCmaskcbcurve && pSpot.CCmaskcbcurve == otherSpot.CCmaskcbcurve; locallab.spots.at(j).CCmaskcbcurve = locallab.spots.at(j).CCmaskcbcurve && pSpot.CCmaskcbcurve == otherSpot.CCmaskcbcurve;
@ -4717,10 +4716,6 @@ void ParamsEdited::combine(rtengine::procparams::ProcParams& toEdit, const rteng
toEdit.locallab.spots.at(i).contresid = mods.locallab.spots.at(i).contresid; toEdit.locallab.spots.at(i).contresid = mods.locallab.spots.at(i).contresid;
} }
if (locallab.spots.at(i).blurcbdl) {
toEdit.locallab.spots.at(i).blurcbdl = mods.locallab.spots.at(i).blurcbdl;
}
if (locallab.spots.at(i).softradiuscb) { if (locallab.spots.at(i).softradiuscb) {
toEdit.locallab.spots.at(i).softradiuscb = mods.locallab.spots.at(i).softradiuscb; toEdit.locallab.spots.at(i).softradiuscb = mods.locallab.spots.at(i).softradiuscb;
} }
@ -6483,7 +6478,6 @@ LocallabParamsEdited::LocallabSpotEdited::LocallabSpotEdited(bool v) :
sensicb(v), sensicb(v),
clarityml(v), clarityml(v),
contresid(v), contresid(v),
blurcbdl(v),
softradiuscb(v), softradiuscb(v),
enacbMask(v), enacbMask(v),
CCmaskcbcurve(v), CCmaskcbcurve(v),
@ -6981,7 +6975,6 @@ void LocallabParamsEdited::LocallabSpotEdited::set(bool v)
CCmaskcbcurve = v; CCmaskcbcurve = v;
LLmaskcbcurve = v; LLmaskcbcurve = v;
HHmaskcbcurve = v; HHmaskcbcurve = v;
blurcbdl = v;
blendmaskcb = v; blendmaskcb = v;
radmaskcb = v; radmaskcb = v;
chromaskcb = v; chromaskcb = v;

View File

@ -810,7 +810,6 @@ public:
bool sensicb; bool sensicb;
bool clarityml; bool clarityml;
bool contresid; bool contresid;
bool blurcbdl;
bool softradiuscb; bool softradiuscb;
bool enacbMask; bool enacbMask;
bool CCmaskcbcurve; bool CCmaskcbcurve;