astyle all modified files in retinex branch

This commit is contained in:
Beep6581 2015-10-17 14:45:24 +02:00
parent 7e6d0d45f4
commit 7ca8de08ab
15 changed files with 324 additions and 268 deletions

View File

@ -233,6 +233,7 @@ void Color::init ()
for (int i = 0; i < 65536; i++) { for (int i = 0; i < 65536; i++) {
gammatab_26_11[i] = (65535.0 * gamma26_11 (i / 65535.0)); gammatab_26_11[i] = (65535.0 * gamma26_11 (i / 65535.0));
} }
//gammatab_145_3 //gammatab_145_3
for (int i = 0; i < 65536; i++) { for (int i = 0; i < 65536; i++) {
igammatab_26_11[i] = (65535.0 * igamma26_11 (i / 65535.0)); igammatab_26_11[i] = (65535.0 * igamma26_11 (i / 65535.0));

View File

@ -513,6 +513,7 @@ void CurveFactory::curveDehaContL ( bool & dehacontlutili, const std::vector<dou
if (!dehaclcurvePoints.empty() && dehaclcurvePoints[0] != 0) { if (!dehaclcurvePoints.empty() && dehaclcurvePoints[0] != 0) {
dCurve = new DiagonalCurve (dehaclcurvePoints, CURVES_MIN_POLY_POINTS / skip); dCurve = new DiagonalCurve (dehaclcurvePoints, CURVES_MIN_POLY_POINTS / skip);
if (outBeforeCurveHistogram) { if (outBeforeCurveHistogram) {
histNeeded = true; histNeeded = true;
} }
@ -522,6 +523,7 @@ void CurveFactory::curveDehaContL ( bool & dehacontlutili, const std::vector<dou
dehacontlutili = true; dehacontlutili = true;
} }
} }
if (histNeeded) { if (histNeeded) {
for (int i = 0; i < 32768; i++) { for (int i = 0; i < 32768; i++) {
double hval = CLIPD((double)i / 32767.0); double hval = CLIPD((double)i / 32767.0);

View File

@ -22,22 +22,22 @@ typedef __m128i vint2;
// //
#ifdef __GNUC__ #ifdef __GNUC__
#if (__GNUC__ == 4 && __GNUC_MINOR__ >= 9) || __GNUC__ > 4 #if (__GNUC__ == 4 && __GNUC_MINOR__ >= 9) || __GNUC__ > 4
#define LVF(x) _mm_load_ps(&x) #define LVF(x) _mm_load_ps(&x)
#define LVFU(x) _mm_loadu_ps(&x) #define LVFU(x) _mm_loadu_ps(&x)
#define STVF(x,y) _mm_store_ps(&x,y) #define STVF(x,y) _mm_store_ps(&x,y)
#define STVFU(x,y) _mm_storeu_ps(&x,y) #define STVFU(x,y) _mm_storeu_ps(&x,y)
#else // there is a bug in gcc 4.7.x when using openmp and aligned memory and -O3 #else // there is a bug in gcc 4.7.x when using openmp and aligned memory and -O3
#define LVF(x) _mm_loadu_ps(&x) #define LVF(x) _mm_loadu_ps(&x)
#define LVFU(x) _mm_loadu_ps(&x) #define LVFU(x) _mm_loadu_ps(&x)
#define STVF(x,y) _mm_storeu_ps(&x,y) #define STVF(x,y) _mm_storeu_ps(&x,y)
#define STVFU(x,y) _mm_storeu_ps(&x,y) #define STVFU(x,y) _mm_storeu_ps(&x,y)
#endif #endif
#else #else
#define LVF(x) _mm_load_ps(&x) #define LVF(x) _mm_load_ps(&x)
#define LVFU(x) _mm_loadu_ps(&x) #define LVFU(x) _mm_loadu_ps(&x)
#define STVF(x,y) _mm_store_ps(&x,y) #define STVF(x,y) _mm_store_ps(&x,y)
#define STVFU(x,y) _mm_storeu_ps(&x,y) #define STVFU(x,y) _mm_storeu_ps(&x,y)
#endif #endif
// Load 8 floats from a and combine a[0],a[2],a[4] and a[6] into a vector of 4 floats // Load 8 floats from a and combine a[0],a[2],a[4] and a[6] into a vector of 4 floats

View File

@ -94,7 +94,7 @@ void retinex_scales( float* scales, int nscales, int mode, int s, float high)
size_step = (float) log(s - 2.0f) / (float) nscales; size_step = (float) log(s - 2.0f) / (float) nscales;
for ( int i = 0; i < nscales; ++i ) { for ( int i = 0; i < nscales; ++i ) {
scales[i] = high*s - (float)pow (10.f, (i * size_step) / log (10.f)); scales[i] = high * s - (float)pow (10.f, (i * size_step) / log (10.f));
} }
} }
} }
@ -225,12 +225,17 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e
limD *= useHslLin ? 10.f : 1.f; limD *= useHslLin ? 10.f : 1.f;
float ilimD = 1.f / limD; float ilimD = 1.f / limD;
int moderetinex = 2; // default to 2 ( deh.retinexMethod == "high" ) int moderetinex = 2; // default to 2 ( deh.retinexMethod == "high" )
float hig = ((float) deh.highl)/100.f; float hig = ((float) deh.highl) / 100.f;
bool higplus = false ; bool higplus = false ;
float elogt; float elogt;
float hl = deh.baselog; float hl = deh.baselog;
if(hl >= 2.71828f) elogt = 2.71828f + SQR(SQR(hl - 2.71828f));
else elogt = hl; if(hl >= 2.71828f) {
elogt = 2.71828f + SQR(SQR(hl - 2.71828f));
} else {
elogt = hl;
}
elogt = 2.71828f;//disabled baselog elogt = 2.71828f;//disabled baselog
FlatCurve* shcurve = NULL;//curve L=f(H) FlatCurve* shcurve = NULL;//curve L=f(H)
bool lhutili = false; bool lhutili = false;
@ -243,14 +248,15 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e
delete shcurve; delete shcurve;
shcurve = NULL; shcurve = NULL;
} }
} } else {
else {
lhutili = true; lhutili = true;
} }
} }
if(deh.retinexMethod == "highliplus") higplus = true; if(deh.retinexMethod == "highliplus") {
higplus = true;
}
if (deh.retinexMethod == "uni") { if (deh.retinexMethod == "uni") {
moderetinex = 0; moderetinex = 0;
@ -259,13 +265,15 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e
if (deh.retinexMethod == "low") { if (deh.retinexMethod == "low") {
moderetinex = 1; moderetinex = 1;
} }
if (deh.retinexMethod == "highli" || deh.retinexMethod == "highliplus") { if (deh.retinexMethod == "highli" || deh.retinexMethod == "highliplus") {
moderetinex = 3; moderetinex = 3;
} }
float aahi = 49.f/99.f;////reduce sensibility 50%
float aahi = 49.f / 99.f; ////reduce sensibility 50%
float bbhi = 1.f - aahi; float bbhi = 1.f - aahi;
float high; float high;
high = bbhi + aahi*(float) deh.highl; high = bbhi + aahi * (float) deh.highl;
retinex_scales( RetinexScales, scal, moderetinex, nei, high ); retinex_scales( RetinexScales, scal, moderetinex, nei, high );
int H_L = height; int H_L = height;
@ -331,7 +339,7 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e
} }
} else { } else {
for (; j < W_L - 3; j += 4) { for (; j < W_L - 3; j += 4) {
_mm_storeu_ps(&luminance[i][j], LVFU(luminance[i][j]) + pondv * xlogf(LIMV(LVFU(src[i][j]) / LVFU(out[i][j]), limMinv, limMaxv) )/xlogf(elogtv)); _mm_storeu_ps(&luminance[i][j], LVFU(luminance[i][j]) + pondv * xlogf(LIMV(LVFU(src[i][j]) / LVFU(out[i][j]), limMinv, limMaxv) ) / xlogf(elogtv));
} }
} }
@ -343,7 +351,7 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e
} }
} else { } else {
for (; j < W_L; j++) { for (; j < W_L; j++) {
luminance[i][j] += pond * xlogf(LIM(src[i][j] / out[i][j], ilimD, limD))/log(elogt);// /logt ? luminance[i][j] += pond * xlogf(LIM(src[i][j] / out[i][j], ilimD, limD)) / log(elogt); // /logt ?
} }
} }
} }
@ -457,7 +465,7 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e
} }
delta = maxi - mini; delta = maxi - mini;
// printf("maxi=%f mini=%f mean=%f std=%f delta=%f maxtr=%f mintr=%f\n", maxi, mini, mean, stddv, delta, maxtr, mintr); // 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 ) { if ( !delta ) {
delta = 1.0f; delta = 1.0f;
@ -492,19 +500,26 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e
if(cd < cdmin) { if(cd < cdmin) {
cdmin = cd; cdmin = cd;
} }
float str = strength; float str = strength;
if(lhutili) { // S=f(H) if(lhutili) { // S=f(H)
{ {
float HH = exLuminance[i][j]; float HH = exLuminance[i][j];
float valparam; float valparam;
if(useHsl || useHslLin) valparam = float((shcurve->getVal(HH) - 0.5f));
else valparam = float((shcurve->getVal(Color::huelab_to_huehsv2(HH)) - 0.5f)); if(useHsl || useHslLin) {
str *= (1.f + 2.f*valparam); valparam = float((shcurve->getVal(HH) - 0.5f));
} else {
valparam = float((shcurve->getVal(Color::huelab_to_huehsv2(HH)) - 0.5f));
}
str *= (1.f + 2.f * valparam);
} }
} }
// if(exLuminance[i][j] > 65535.f*hig && higplus) str *= hig; // if(exLuminance[i][j] > 65535.f*hig && higplus) str *= hig;
luminance[i][j] = clipretinex( cd, 0.f, 32768.f ) * str + (1.f - str) * originalLuminance[i][j]; luminance[i][j] = clipretinex( cd, 0.f, 32768.f ) * str + (1.f - str) * originalLuminance[i][j];
} }
#ifdef _OPENMP #ifdef _OPENMP

View File

@ -3915,14 +3915,14 @@ int ProcParams::load (Glib::ustring fname, ParamsEdited* pedited)
} }
} }
/* if (keyFile.has_key ("Retinex", "grbl")) { /* if (keyFile.has_key ("Retinex", "grbl")) {
retinex.grbl = keyFile.get_integer ("Retinex", "grbl"); retinex.grbl = keyFile.get_integer ("Retinex", "grbl");
if (pedited) { if (pedited) {
pedited->retinex.grbl = true; pedited->retinex.grbl = true;
} }
} }
*/ */
if (keyFile.has_key ("Retinex", "CDCurve")) { if (keyFile.has_key ("Retinex", "CDCurve")) {
retinex.cdcurve = keyFile.get_double_list ("Retinex", "CDCurve"); retinex.cdcurve = keyFile.get_double_list ("Retinex", "CDCurve");

View File

@ -1856,98 +1856,110 @@ void RawImageSource::retinexPrepareBuffers(ColorManagementParams cmp, RetinexPar
conversionBuffer[2] (W - 2 * border, H - 2 * border); conversionBuffer[2] (W - 2 * border, H - 2 * border);
conversionBuffer[3] (W - 2 * border, H - 2 * border); conversionBuffer[3] (W - 2 * border, H - 2 * border);
LUTf *retinexgamtab;//gamma before and after Retinex to restore tones LUTf *retinexgamtab;//gamma before and after Retinex to restore tones
LUTf lutTonereti; LUTf lutTonereti;
lutTonereti(65536); lutTonereti(65536);
if(retinexParams.gammaretinex == "low") if(retinexParams.gammaretinex == "low") {
retinexgamtab = &(Color::gammatab_115_2); retinexgamtab = &(Color::gammatab_115_2);
else if(retinexParams.gammaretinex == "mid") } else if(retinexParams.gammaretinex == "mid") {
retinexgamtab = &(Color::gammatab_13_2); retinexgamtab = &(Color::gammatab_13_2);
else if(retinexParams.gammaretinex == "hig") } else if(retinexParams.gammaretinex == "hig") {
retinexgamtab = &(Color::gammatab_145_3); retinexgamtab = &(Color::gammatab_145_3);
else if(retinexParams.gammaretinex == "fre"){ } else if(retinexParams.gammaretinex == "fre") {
double g_a0, g_a1, g_a2, g_a3, g_a4, g_a5; double g_a0, g_a1, g_a2, g_a3, g_a4, g_a5;
double pwr = 1.0 / retinexParams.gam; double pwr = 1.0 / retinexParams.gam;
double gamm = retinexParams.gam; double gamm = retinexParams.gam;
double ts = retinexParams.slope; double ts = retinexParams.slope;
double gamm2 = retinexParams.gam; double gamm2 = retinexParams.gam;
if(gamm2 < 1.) {pwr = 1./pwr; gamm = 1. / gamm;}
if(gamm2 < 1.) {
pwr = 1. / pwr;
gamm = 1. / gamm;
}
int mode = 0, imax = 0;
Color::calcGamma(pwr, ts, mode, imax, g_a0, g_a1, g_a2, g_a3, g_a4, g_a5); // call to calcGamma with selected gamma and slope
int mode = 0, imax = 0;
Color::calcGamma(pwr, ts, mode, imax, g_a0, g_a1, g_a2, g_a3, g_a4, g_a5); // 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); // 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);
for (int i = 0; i < 65536; i++) { for (int i = 0; i < 65536; i++) {
double val = (i) / 65535.; double val = (i) / 65535.;
double start = g_a3; double start = g_a3;
double add = g_a4; double add = g_a4;
double mul = 1. + g_a4; double mul = 1. + g_a4;
double x; double x;
if(gamm2 < 1.) {start = g_a2; add = g_a4;
x = Color::igammareti (val, gamm, start, ts, mul , add);}
else
x = Color::gammareti (val, gamm, start, ts, mul , add);
lutTonereti[i] = CLIP(x * 65535.);// CLIP avoid in some case extra values if(gamm2 < 1.) {
start = g_a2;
add = g_a4;
x = Color::igammareti (val, gamm, start, ts, mul , add);
} else {
x = Color::gammareti (val, gamm, start, ts, mul , add);
} }
retinexgamtab = &lutTonereti;
}
/*
//test with amsterdam.pef and other files
float rr,gg,bb;
rr=red[50][2300];
gg=green[50][2300];
bb=blue[50][2300];
printf("rr=%f gg=%f bb=%f \n",rr,gg,bb);
rr=red[1630][370];
gg=green[1630][370];
bb=blue[1630][370];
printf("rr1=%f gg1=%f bb1=%f \n",rr,gg,bb);
rr=red[380][1630];
gg=green[380][1630];
bb=blue[380][1630];
printf("rr2=%f gg2=%f bb2=%f \n",rr,gg,bb);
*/
/*
if(retinexParams.highlig < 100 && retinexParams.retinexMethod == "highliplus") {//try to recover magenta...very difficult !
float hig = ((float)retinexParams.highlig)/100.f;
float higgb = ((float)retinexParams.grbl)/100.f;
lutTonereti[i] = CLIP(x * 65535.);// CLIP avoid in some case extra values
}
retinexgamtab = &lutTonereti;
}
/*
//test with amsterdam.pef and other files
float rr,gg,bb;
rr=red[50][2300];
gg=green[50][2300];
bb=blue[50][2300];
printf("rr=%f gg=%f bb=%f \n",rr,gg,bb);
rr=red[1630][370];
gg=green[1630][370];
bb=blue[1630][370];
printf("rr1=%f gg1=%f bb1=%f \n",rr,gg,bb);
rr=red[380][1630];
gg=green[380][1630];
bb=blue[380][1630];
printf("rr2=%f gg2=%f bb2=%f \n",rr,gg,bb);
*/
/*
if(retinexParams.highlig < 100 && retinexParams.retinexMethod == "highliplus") {//try to recover magenta...very difficult !
float hig = ((float)retinexParams.highlig)/100.f;
float higgb = ((float)retinexParams.grbl)/100.f;
#ifdef _OPENMP
#pragma omp parallel for
#endif
for (int i = border; i < H - border; i++ ) {
for (int j = border; j < W - border; j++ ) {
float R_,G_,B_;
R_=red[i][j];
G_=green[i][j];
B_=blue[i][j];
//empirical method to find highlight magenta with no conversion RGB and no white balance
//red = master Gr and Bl default higgb=0.5
// if(R_>65535.f*hig && G_ > 65535.f*higgb && B_ > 65535.f*higgb) conversionBuffer[3][i - border][j - border] = R_;
// else conversionBuffer[3][i - border][j - border] = 0.f;
}
}
}
*/
if(retinexParams.gammaretinex != "none" && retinexParams.str != 0) {//gamma
#ifdef _OPENMP #ifdef _OPENMP
#pragma omp parallel for #pragma omp parallel for
#endif #endif
for (int i = border; i < H - border; i++ ) {
for (int j = border; j < W - border; j++ ) {
float R_,G_,B_;
R_=red[i][j];
G_=green[i][j];
B_=blue[i][j];
//empirical method to find highlight magenta with no conversion RGB and no white balance
//red = master Gr and Bl default higgb=0.5
// if(R_>65535.f*hig && G_ > 65535.f*higgb && B_ > 65535.f*higgb) conversionBuffer[3][i - border][j - border] = R_;
// else conversionBuffer[3][i - border][j - border] = 0.f;
}
}
}
*/
if(retinexParams.gammaretinex != "none" && retinexParams.str != 0) {//gamma
#ifdef _OPENMP
#pragma omp parallel for
#endif
for (int i = border; i < H - border; i++ ) { for (int i = border; i < H - border; i++ ) {
for (int j = border; j < W - border; j++ ) { for (int j = border; j < W - border; j++ ) {
float R_,G_,B_; float R_, G_, B_;
R_=red[i][j]; R_ = red[i][j];
G_=green[i][j]; G_ = green[i][j];
B_=blue[i][j]; B_ = blue[i][j];
red[i][j] = (*retinexgamtab)[R_]; red[i][j] = (*retinexgamtab)[R_];
green[i][j] = (*retinexgamtab)[G_]; green[i][j] = (*retinexgamtab)[G_];
blue[i][j] = (*retinexgamtab)[B_]; blue[i][j] = (*retinexgamtab)[B_];
} }
} }
} }
if(useHsl) { if(useHsl) {
#ifdef _OPENMP #ifdef _OPENMP
@ -2054,7 +2066,7 @@ if(retinexParams.gammaretinex != "none" && retinexParams.str != 0) {//gamma
for (int j = border; j < W - border; j++) { for (int j = border; j < W - border; j++) {
float X, Y, Z, L, aa, bb; float X, Y, Z, L, aa, bb;
int pos; int pos;
float R_,G_,B_; float R_, G_, B_;
R_ = red[i][j]; R_ = red[i][j];
G_ = green[i][j]; G_ = green[i][j];
B_ = blue[i][j]; B_ = blue[i][j];
@ -2066,9 +2078,10 @@ if(retinexParams.gammaretinex != "none" && retinexParams.str != 0) {//gamma
conversionBuffer[0][i - border][j - border] = aa; conversionBuffer[0][i - border][j - border] = aa;
conversionBuffer[1][i - border][j - border] = bb; conversionBuffer[1][i - border][j - border] = bb;
conversionBuffer[2][i - border][j - border] = L; conversionBuffer[2][i - border][j - border] = L;
conversionBuffer[3][i - border][j - border] = xatan2f(bb,aa); conversionBuffer[3][i - border][j - border] = xatan2f(bb, aa);
// if(R_>40000.f && G_ > 30000.f && B_ > 30000.f) conversionBuffer[3][i - border][j - border] = R_;
// else conversionBuffer[3][i - border][j - border] = 0.f; // if(R_>40000.f && G_ > 30000.f && B_ > 30000.f) conversionBuffer[3][i - border][j - border] = R_;
// else conversionBuffer[3][i - border][j - border] = 0.f;
if(lhist16RETI) { if(lhist16RETI) {
pos = (int) clipretinex(L, 0, 32768); pos = (int) clipretinex(L, 0, 32768);
lhist16RETIThr[pos]++;//histogram in Curve Lab lhist16RETIThr[pos]++;//histogram in Curve Lab
@ -2117,42 +2130,55 @@ void RawImageSource::retinex(ColorManagementParams cmp, RetinexParams deh, ToneC
if (settings->verbose) { if (settings->verbose) {
printf ("Applying Retinex\n"); printf ("Applying Retinex\n");
} }
LUTf lutToneireti;
lutToneireti(65536);
LUTf *retinexigamtab;//gamma before and after Retinex to restore tones LUTf lutToneireti;
if(deh.gammaretinex == "low") lutToneireti(65536);
retinexigamtab = &(Color::igammatab_115_2);
else if(deh.gammaretinex == "mid")
retinexigamtab = &(Color::igammatab_13_2);
else if(deh.gammaretinex == "hig")
retinexigamtab = &(Color::igammatab_145_3);
else if(deh.gammaretinex == "fre"){
double g_a0, g_a1, g_a2, g_a3, g_a4, g_a5;
double pwr = 1.0 / deh.gam;
double gamm = deh.gam;
double gamm2 = gamm;
double ts = deh.slope;
int mode = 0, imax = 0;
if(gamm2 < 1.) {pwr = 1./pwr; gamm = 1. / gamm;}
Color::calcGamma(pwr, ts, mode, imax, g_a0, g_a1, g_a2, g_a3, g_a4, g_a5); // call to calcGamma with selected gamma and slope LUTf *retinexigamtab;//gamma before and after Retinex to restore tones
// 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);
for (int i = 0; i < 65536; i++) {
double val = (i) / 65535.;
double x;
double mul = 1. + g_a4;
double add = g_a4;
double start = g_a2;
if(gamm2 < 1.) {start = g_a3; add = g_a3;
x = Color::gammareti (val, gamm, start, ts, mul , add);}
else
x = Color::igammareti (val, gamm, start, ts, mul , add);
lutToneireti[i] = CLIP(x * 65535.); if(deh.gammaretinex == "low") {
} retinexigamtab = &(Color::igammatab_115_2);
retinexigamtab = &lutToneireti; } else if(deh.gammaretinex == "mid") {
retinexigamtab = &(Color::igammatab_13_2);
} else if(deh.gammaretinex == "hig") {
retinexigamtab = &(Color::igammatab_145_3);
} else if(deh.gammaretinex == "fre") {
double g_a0, g_a1, g_a2, g_a3, g_a4, g_a5;
double pwr = 1.0 / deh.gam;
double gamm = deh.gam;
double gamm2 = gamm;
double ts = deh.slope;
int mode = 0, imax = 0;
if(gamm2 < 1.) {
pwr = 1. / pwr;
gamm = 1. / gamm;
} }
Color::calcGamma(pwr, ts, mode, imax, g_a0, g_a1, g_a2, g_a3, g_a4, g_a5); // 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);
for (int i = 0; i < 65536; i++) {
double val = (i) / 65535.;
double x;
double mul = 1. + g_a4;
double add = g_a4;
double start = g_a2;
if(gamm2 < 1.) {
start = g_a3;
add = g_a3;
x = Color::gammareti (val, gamm, start, ts, mul , add);
} else {
x = Color::igammareti (val, gamm, start, ts, mul , add);
}
lutToneireti[i] = CLIP(x * 65535.);
}
retinexigamtab = &lutToneireti;
}
// We need a buffer with original L data to allow correct blending // We need a buffer with original L data to allow correct blending
// red, green and blue still have original size of raw, but we can't use the borders // red, green and blue still have original size of raw, but we can't use the borders
const int HNew = H - 2 * border; const int HNew = H - 2 * border;
@ -2172,22 +2198,21 @@ void RawImageSource::retinex(ColorManagementParams cmp, RetinexParams deh, ToneC
dLcurve.clear(); dLcurve.clear();
} }
FlatCurve* chcurve = NULL;//curve c=f(H) FlatCurve* chcurve = NULL;//curve c=f(H)
bool chutili = false; bool chutili = false;
if (deh.enabled && deh.retinexMethod == "highli") { if (deh.enabled && deh.retinexMethod == "highli") {
chcurve = new FlatCurve(deh.lhcurve); chcurve = new FlatCurve(deh.lhcurve);
if (!chcurve || chcurve->isIdentity()) { if (!chcurve || chcurve->isIdentity()) {
if (chcurve) { if (chcurve) {
delete chcurve; delete chcurve;
chcurve = NULL; chcurve = NULL;
}
}
else {
chutili = true;
} }
} else {
chutili = true;
} }
}
@ -2247,30 +2272,34 @@ void RawImageSource::retinex(ColorManagementParams cmp, RetinexParams deh, ToneC
histLRETI[hi] += hist16RET[i]; histLRETI[hi] += hist16RET[i];
} }
} }
MSR(LBuffer, conversionBuffer[2], conversionBuffer[3], WNew, HNew, deh, dehatransmissionCurve, minCD, maxCD, mini, maxi, Tmean, Tsigma, Tmin, Tmax); MSR(LBuffer, conversionBuffer[2], conversionBuffer[3], WNew, HNew, deh, dehatransmissionCurve, minCD, maxCD, mini, maxi, Tmean, Tsigma, Tmin, Tmax);
if(useHsl) { if(useHsl) {
if(chutili) { if(chutili) {
#ifdef _OPENMP #ifdef _OPENMP
#pragma omp parallel for #pragma omp parallel for
#endif #endif
for (int i = border; i < H - border; i++ ) { for (int i = border; i < H - border; i++ ) {
int j = border; int j = border;
for (; j < W - border; j++) { for (; j < W - border; j++) {
float valp; float valp;
float chr; float chr;
// if(chutili) { // c=f(H) // if(chutili) { // c=f(H)
{ {
valp = float((chcurve->getVal(conversionBuffer[3][i - border][j - border]) - 0.5f)); valp = float((chcurve->getVal(conversionBuffer[3][i - border][j - border]) - 0.5f));
conversionBuffer[1][i - border][j - border] *= (1.f + 2.f*valp); conversionBuffer[1][i - border][j - border] *= (1.f + 2.f * valp);
} }
// } // }
} }
} }
} }
#ifdef _OPENMP #ifdef _OPENMP
#pragma omp parallel for #pragma omp parallel for
#endif #endif
@ -2309,39 +2338,41 @@ void RawImageSource::retinex(ColorManagementParams cmp, RetinexParams deh, ToneC
#ifdef _OPENMP #ifdef _OPENMP
#pragma omp parallel for #pragma omp parallel for
#endif #endif
for (int i = border; i < H - border; i++ ) {
for (int j= border; j < W - border; j++) {
float Lprov1 = (LBuffer[i - border][j - border])/327.68f; for (int i = border; i < H - border; i++ ) {
for (int j = border; j < W - border; j++) {
float Lprov1 = (LBuffer[i - border][j - border]) / 327.68f;
float Chprov1 = sqrt(SQR(conversionBuffer[0][i - border][j - border]) + SQR(conversionBuffer[1][i - border][j - border])) / 327.68f; float Chprov1 = sqrt(SQR(conversionBuffer[0][i - border][j - border]) + SQR(conversionBuffer[1][i - border][j - border])) / 327.68f;
float HH = xatan2f(conversionBuffer[1][i - border][j - border], conversionBuffer[0][i - border][j - border]); float HH = xatan2f(conversionBuffer[1][i - border][j - border], conversionBuffer[0][i - border][j - border]);
float2 sincosval; float2 sincosval;
float valp; float valp;
float chr; float chr;
if(chutili) { // c=f(H)
{ if(chutili) { // c=f(H)
valp = float((chcurve->getVal(Color::huelab_to_huehsv2(HH)) - 0.5f)); {
Chprov1 *= (1.f + 2.f*valp); valp = float((chcurve->getVal(Color::huelab_to_huehsv2(HH)) - 0.5f));
} Chprov1 *= (1.f + 2.f * valp);
} }
}
sincosval = xsincosf(HH); sincosval = xsincosf(HH);
float R,G,B; float R, G, B;
#ifdef _DEBUG #ifdef _DEBUG
bool neg = false; bool neg = false;
bool more_rgb = false; bool more_rgb = false;
//gamut control : Lab values are in gamut //gamut control : Lab values are in gamut
Color::gamutLchonly(HH, sincosval, Lprov1, Chprov1, R, G, B, wip, highlight, 0.15f, 0.96f, neg, more_rgb); Color::gamutLchonly(HH, sincosval, Lprov1, Chprov1, R, G, B, wip, highlight, 0.15f, 0.96f, neg, more_rgb);
#else #else
//gamut control : Lab values are in gamut //gamut control : Lab values are in gamut
Color::gamutLchonly(HH, sincosval, Lprov1, Chprov1, R, G, B, wip, highlight, 0.15f, 0.96f); Color::gamutLchonly(HH, sincosval, Lprov1, Chprov1, R, G, B, wip, highlight, 0.15f, 0.96f);
#endif #endif
conversionBuffer[0][i - border][j - border] = 327.68f * Chprov1 * sincosval.y; conversionBuffer[0][i - border][j - border] = 327.68f * Chprov1 * sincosval.y;
conversionBuffer[1][i - border][j - border] = 327.68f * Chprov1 * sincosval.x; conversionBuffer[1][i - border][j - border] = 327.68f * Chprov1 * sincosval.x;
LBuffer[i - border][j - border] = Lprov1 * 327.68f; LBuffer[i - border][j - border] = Lprov1 * 327.68f;
} }
} }
@ -2387,21 +2418,23 @@ void RawImageSource::retinex(ColorManagementParams cmp, RetinexParams deh, ToneC
blue[i][j] = B; blue[i][j] = B;
} }
} }
} }
if (chcurve) {
delete chcurve;
}
if(deh.gammaretinex != "none" && deh.str !=0){//inverse gamma if (chcurve) {
delete chcurve;
}
if(deh.gammaretinex != "none" && deh.str != 0) { //inverse gamma
#ifdef _OPENMP #ifdef _OPENMP
#pragma omp parallel for #pragma omp parallel for
#endif #endif
for (int i = border; i < H - border; i++ ) { for (int i = border; i < H - border; i++ ) {
for (int j = border; j < W - border; j++ ) { for (int j = border; j < W - border; j++ ) {
float R_,G_,B_; float R_, G_, B_;
R_=red[i][j]; R_ = red[i][j];
G_=green[i][j]; G_ = green[i][j];
B_=blue[i][j]; B_ = blue[i][j];
red[i][j] = (*retinexigamtab)[R_]; red[i][j] = (*retinexigamtab)[R_];
green[i][j] = (*retinexigamtab)[G_]; green[i][j] = (*retinexigamtab)[G_];
blue[i][j] = (*retinexigamtab)[B_]; blue[i][j] = (*retinexigamtab)[B_];

View File

@ -627,6 +627,7 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
Imagefloat* baseImg = new Imagefloat (fw, fh); Imagefloat* baseImg = new Imagefloat (fw, fh);
imgsrc->getImage (currWB, tr, baseImg, pp, params.toneCurve, params.icm, params.raw); imgsrc->getImage (currWB, tr, baseImg, pp, params.toneCurve, params.icm, params.raw);
if (pl) { if (pl) {
pl->setProgress (0.50); pl->setProgress (0.50);
} }

View File

@ -567,6 +567,7 @@ void EditorPanel::open (Thumbnail* tmb, rtengine::InitialImage* isrc)
Gtk::Allocation alloc; Gtk::Allocation alloc;
iareapanel->imageArea->on_resized(alloc); iareapanel->imageArea->on_resized(alloc);
} }
history->resetSnapShotNumber(); history->resetSnapShotNumber();
} }

View File

@ -1112,7 +1112,7 @@ void ParamsEdited::combine (rtengine::procparams::ProcParams& toEdit, const rten
if (retinex.gain) { if (retinex.gain) {
toEdit.retinex.gain = dontforceSet && options.baBehav[ADDSET_RETI_GAIN] ? toEdit.retinex.gain + mods.retinex.gain : mods.retinex.gain; toEdit.retinex.gain = dontforceSet && options.baBehav[ADDSET_RETI_GAIN] ? toEdit.retinex.gain + mods.retinex.gain : mods.retinex.gain;
} }
if (retinex.offs) { if (retinex.offs) {
toEdit.retinex.offs = dontforceSet && options.baBehav[ADDSET_RETI_OFFS] ? toEdit.retinex.offs + mods.retinex.offs : mods.retinex.offs; toEdit.retinex.offs = dontforceSet && options.baBehav[ADDSET_RETI_OFFS] ? toEdit.retinex.offs + mods.retinex.offs : mods.retinex.offs;

View File

@ -321,12 +321,12 @@ Retinex::Retinex () : FoldableToolPanel(this, "retinex", M("TP_RETINEX_LABEL"),
baselog->delay = 200; baselog->delay = 200;
} }
/* grbl->setAdjusterListener (this); /* grbl->setAdjusterListener (this);
if (grbl->delay < 200) { if (grbl->delay < 200) {
grbl->delay = 200; grbl->delay = 200;
} }
*/ */
pack_start (*retinexVBox); pack_start (*retinexVBox);
pack_start (*expsettings); pack_start (*expsettings);
pack_start (*neutrHBox); pack_start (*neutrHBox);
@ -671,18 +671,21 @@ void Retinex::write (ProcParams* pp, ParamsEdited* pedited)
void Retinex::retinexMethodChanged() void Retinex::retinexMethodChanged()
{ {
if(retinexMethod->get_active_row_number() == 3) highl->show(); if(retinexMethod->get_active_row_number() == 3) {
else highl->hide(); highl->show();
} else {
highl->hide();
}
if (listener) { if (listener) {
listener->panelChanged (EvretinexMethod, retinexMethod->get_active_text ()); listener->panelChanged (EvretinexMethod, retinexMethod->get_active_text ());
} }
} }
void Retinex::ColorSpaceUpdateUI () void Retinex::ColorSpaceUpdateUI ()
{ {
if (!batchMode) { if (!batchMode) {
curveEditorGH->show(); curveEditorGH->show();
if(retinexcolorspace->get_active_row_number() == 0) { if(retinexcolorspace->get_active_row_number() == 0) {
curveEditorGD->show(); curveEditorGD->show();
@ -941,9 +944,9 @@ void Retinex::colorForValue (double valX, double valY, enum ColorCaller::ElemTyp
float value = (1.f - 0.7f) * float(valX) + 0.7f; float value = (1.f - 0.7f) * float(valX) + 0.7f;
// whole hue range // whole hue range
// Y axis / from 0.15 up to 0.75 (arbitrary values; was 0.45 before) // Y axis / from 0.15 up to 0.75 (arbitrary values; was 0.45 before)
Color::hsv2rgb01(float(valY), float(valX), value, R, G, B); Color::hsv2rgb01(float(valY), float(valX), value, R, G, B);
} else if (callerId == 4) { // LH - bottom bar } else if (callerId == 4) { // LH - bottom bar
Color::hsv2rgb01(float(valX), 0.5f, float(valY), R, G, B); Color::hsv2rgb01(float(valX), 0.5f, float(valY), R, G, B);
} else if (callerId == 5) { // HH - bottom bar } else if (callerId == 5) { // HH - bottom bar