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++) {
gammatab_26_11[i] = (65535.0 * gamma26_11 (i / 65535.0));
}
//gammatab_145_3
for (int i = 0; i < 65536; i++) {
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) {
dCurve = new DiagonalCurve (dehaclcurvePoints, CURVES_MIN_POLY_POINTS / skip);
if (outBeforeCurveHistogram) {
histNeeded = true;
}
@ -522,6 +523,7 @@ void CurveFactory::curveDehaContL ( bool & dehacontlutili, const std::vector<dou
dehacontlutili = true;
}
}
if (histNeeded) {
for (int i = 0; i < 32768; i++) {
double hval = CLIPD((double)i / 32767.0);

View File

@ -229,8 +229,13 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e
bool higplus = false ;
float elogt;
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
FlatCurve* shcurve = NULL;//curve L=f(H)
bool lhutili = false;
@ -243,14 +248,15 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e
delete shcurve;
shcurve = NULL;
}
}
else {
} else {
lhutili = true;
}
}
if(deh.retinexMethod == "highliplus") higplus = true;
if(deh.retinexMethod == "highliplus") {
higplus = true;
}
if (deh.retinexMethod == "uni") {
moderetinex = 0;
@ -259,9 +265,11 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e
if (deh.retinexMethod == "low") {
moderetinex = 1;
}
if (deh.retinexMethod == "highli" || deh.retinexMethod == "highliplus") {
moderetinex = 3;
}
float aahi = 49.f / 99.f; ////reduce sensibility 50%
float bbhi = 1.f - aahi;
float high;
@ -492,13 +500,20 @@ void RawImageSource::MSR(float** luminance, float** originalLuminance, float **e
if(cd < cdmin) {
cdmin = cd;
}
float str = strength;
if(lhutili) { // S=f(H)
{
float HH = exLuminance[i][j];
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) {
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);
}
}

View File

@ -1860,22 +1860,27 @@ void RawImageSource::retinexPrepareBuffers(ColorManagementParams cmp, RetinexPar
LUTf lutTonereti;
lutTonereti(65536);
if(retinexParams.gammaretinex == "low")
if(retinexParams.gammaretinex == "low") {
retinexgamtab = &(Color::gammatab_115_2);
else if(retinexParams.gammaretinex == "mid")
} else if(retinexParams.gammaretinex == "mid") {
retinexgamtab = &(Color::gammatab_13_2);
else if(retinexParams.gammaretinex == "hig")
} else if(retinexParams.gammaretinex == "hig") {
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 pwr = 1.0 / retinexParams.gam;
double gamm = retinexParams.gam;
double ts = retinexParams.slope;
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
// 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.;
@ -1883,15 +1888,21 @@ void RawImageSource::retinexPrepareBuffers(ColorManagementParams cmp, RetinexPar
double add = g_a4;
double mul = 1. + g_a4;
double x;
if(gamm2 < 1.) {start = g_a2; add = g_a4;
x = Color::igammareti (val, gamm, start, ts, mul , add);}
else
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
}
retinexgamtab = &lutTonereti;
}
/*
//test with amsterdam.pef and other files
float rr,gg,bb;
@ -1935,6 +1946,7 @@ 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 j = border; j < W - border; j++ ) {
float R_, G_, B_;
@ -2067,6 +2079,7 @@ if(retinexParams.gammaretinex != "none" && retinexParams.str != 0) {//gamma
conversionBuffer[1][i - border][j - border] = bb;
conversionBuffer[2][i - border][j - border] = L;
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(lhist16RETI) {
@ -2117,26 +2130,33 @@ void RawImageSource::retinex(ColorManagementParams cmp, RetinexParams deh, ToneC
if (settings->verbose) {
printf ("Applying Retinex\n");
}
LUTf lutToneireti;
lutToneireti(65536);
LUTf *retinexigamtab;//gamma before and after Retinex to restore tones
if(deh.gammaretinex == "low")
if(deh.gammaretinex == "low") {
retinexigamtab = &(Color::igammatab_115_2);
else if(deh.gammaretinex == "mid")
} else if(deh.gammaretinex == "mid") {
retinexigamtab = &(Color::igammatab_13_2);
else if(deh.gammaretinex == "hig")
} else if(deh.gammaretinex == "hig") {
retinexigamtab = &(Color::igammatab_145_3);
else if(deh.gammaretinex == "fre"){
} 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;}
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.;
@ -2144,15 +2164,21 @@ void RawImageSource::retinex(ColorManagementParams cmp, RetinexParams deh, ToneC
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
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
// red, green and blue still have original size of raw, but we can't use the borders
const int HNew = H - 2 * border;
@ -2183,8 +2209,7 @@ void RawImageSource::retinex(ColorManagementParams cmp, RetinexParams deh, ToneC
delete chcurve;
chcurve = NULL;
}
}
else {
} else {
chutili = true;
}
}
@ -2247,6 +2272,7 @@ void RawImageSource::retinex(ColorManagementParams cmp, RetinexParams deh, ToneC
histLRETI[hi] += hist16RET[i];
}
}
MSR(LBuffer, conversionBuffer[2], conversionBuffer[3], WNew, HNew, deh, dehatransmissionCurve, minCD, maxCD, mini, maxi, Tmean, Tsigma, Tmin, Tmax);
if(useHsl) {
@ -2254,8 +2280,10 @@ void RawImageSource::retinex(ColorManagementParams cmp, RetinexParams deh, ToneC
#ifdef _OPENMP
#pragma omp parallel for
#endif
for (int i = border; i < H - border; i++ ) {
int j = border;
for (; j < W - border; j++) {
float valp;
@ -2271,6 +2299,7 @@ void RawImageSource::retinex(ColorManagementParams cmp, RetinexParams deh, ToneC
}
}
}
#ifdef _OPENMP
#pragma omp parallel for
#endif
@ -2309,6 +2338,7 @@ void RawImageSource::retinex(ColorManagementParams cmp, RetinexParams deh, ToneC
#ifdef _OPENMP
#pragma omp parallel for
#endif
for (int i = border; i < H - border; i++ ) {
for (int j = border; j < W - border; j++) {
@ -2318,6 +2348,7 @@ void RawImageSource::retinex(ColorManagementParams cmp, RetinexParams deh, ToneC
float2 sincosval;
float valp;
float chr;
if(chutili) { // c=f(H)
{
valp = float((chcurve->getVal(Color::huelab_to_huehsv2(HH)) - 0.5f));
@ -2388,6 +2419,7 @@ void RawImageSource::retinex(ColorManagementParams cmp, RetinexParams deh, ToneC
}
}
}
if (chcurve) {
delete chcurve;
}
@ -2396,6 +2428,7 @@ if(deh.gammaretinex != "none" && deh.str !=0){//inverse gamma
#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_;

View File

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

View File

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

View File

@ -671,8 +671,11 @@ void Retinex::write (ProcParams* pp, ParamsEdited* pedited)
void Retinex::retinexMethodChanged()
{
if(retinexMethod->get_active_row_number() == 3) highl->show();
else highl->hide();
if(retinexMethod->get_active_row_number() == 3) {
highl->show();
} else {
highl->hide();
}
if (listener) {
listener->panelChanged (EvretinexMethod, retinexMethod->get_active_text ());