Clean and format code

This commit is contained in:
Desmis
2019-09-22 10:37:35 +02:00
parent 7ec3b17d7b
commit c10453b4ce
2 changed files with 80 additions and 72 deletions

View File

@@ -875,11 +875,8 @@ void ImProcFunctions::MSRLocal(int sp, bool fftw, int lum, LabImage * bufreti, L
float threslum = loc.spots.at(sp).limd;
const float elogt = 2.71828f;
if(!logli) {
if (!logli) {
useHslLin = true;
printf("logar\n");
} else {
printf("linear\n");
}
//empirical skip evaluation : very difficult because quasi all parameters interfere
@@ -894,11 +891,14 @@ void ImProcFunctions::MSRLocal(int sp, bool fftw, int lum, LabImage * bufreti, L
// variance vart
//not too bad proposition
float divsca = 1.f;
if(scal >=3) divsca = sqrt(scal / 3.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;
nei = (int)(nei / (1.5f * skip)) / divsca;
vart *= sqrt(skip);
} else if (skip > 1 && skip < 4) {
//nei = (int)(0.3f * nei + 2.f);
@@ -962,27 +962,34 @@ void ImProcFunctions::MSRLocal(int sp, bool fftw, int lum, LabImage * bufreti, L
float *buffer = new float[W_L * H_L];
float kr = 1.f;//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 adjustement between FFTW radius and Gaussainblur
//under 50 ==> 10.f
// 400 ==> 1.f
float sigm = 1.f;
if(settings->fftwsigma == false) {//empirical formula
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;
if (sigm < 50.f) {
kr = 10.f;
}
//above 400 at 5000 ==> 20.f
if(sigm > 400.f) {//increase ==> 5000
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) {
if (sigm > 5000.f) {
kr = ka * 5000.f + kb;
kg = kga * 5000.f + kgb;
}
@@ -992,7 +999,8 @@ void ImProcFunctions::MSRLocal(int sp, bool fftw, int lum, LabImage * bufreti, L
kg = 1.f;
kr = sigm;
}
if(!fftw) {
if (!fftw) {
#ifdef _OPENMP
#pragma omp parallel //disabled with FFTW
#endif
@@ -1008,23 +1016,22 @@ void ImProcFunctions::MSRLocal(int sp, bool fftw, int lum, LabImage * bufreti, L
}
}
} else {
if (scale == scal - 1)
{
if(settings->fftwsigma == false) {//empirical formula
if (scale == scal - 1) {
if (settings->fftwsigma == false) { //empirical formula
ImProcFunctions::fftw_convol_blur2(src, out, W_L, H_L, (kr * RetinexScales[scale]), 0, 0);
} else {
ImProcFunctions::fftw_convol_blur2(src, out, W_L, H_L, (SQR(RetinexScales[scale])), 0, 0);
}
} else // reuse result of last iteration
{
} 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, W_L, H_L,sqrtf(SQR(kr * RetinexScales[scale]) - SQR(kr * RetinexScales[scale + 1])), 0, 0);
if (settings->fftwsigma == false) { //empirical formula
ImProcFunctions::fftw_convol_blur2(out, out, W_L, H_L, sqrtf(SQR(kr * RetinexScales[scale]) - SQR(kr * RetinexScales[scale + 1])), 0, 0);
} else {
ImProcFunctions::fftw_convol_blur2(out, out, W_L, H_L,(SQR(RetinexScales[scale]) - SQR(RetinexScales[scale + 1])), 0, 0);
ImProcFunctions::fftw_convol_blur2(out, out, W_L, H_L, (SQR(RetinexScales[scale]) - SQR(RetinexScales[scale + 1])), 0, 0);
}
}
}
if (scale == 1) { //equalize last scale with darkness and lightness
if (dar != 1.f || lig != 1.f) {
@@ -1227,8 +1234,6 @@ void ImProcFunctions::MSRLocal(int sp, bool fftw, int lum, LabImage * bufreti, L
}
}
if(useHslLin) printf("Lineaiare!!!\n");
else printf("LOG\n");
#ifdef __SSE2__
vfloat pondv = F2V(pond);
@@ -1322,8 +1327,9 @@ else printf("LOG\n");
for (int j = 0; j < W_L; j++) {
luminance[i][j] = ble[i][j] * deltatran + mintran;
}
ble(0,0);
guid(0,0);
ble(0, 0);
guid(0, 0);
}
@@ -1398,10 +1404,10 @@ else printf("LOG\n");
if (scal == 1) {
float mintran = luminance[0][0];
float maxtran = mintran;
/*
#ifdef _OPENMP
/*
#ifdef _OPENMP
#pragma omp parallel for reduction(min:mintran) reduction(max:maxtran) schedule(dynamic,16)
#endif
#endif
for (int ir = 0; ir < H_L; ir++) {
for (int jr = 0; jr < W_L; jr++) {
@@ -1409,7 +1415,7 @@ else printf("LOG\n");
maxtran = rtengine::max(luminance[ir][jr], maxtran);
}
}
*/
*/
mintran = 0.f;
maxtran = 1.f;
float deltatran = maxtran - mintran;
@@ -1447,10 +1453,12 @@ else printf("LOG\n");
for (int j = 0; j < W_L; j++) {
luminance[i][j] = ble[i][j] * deltatran + mintran;
}
ble(0,0);
guid(0,0);
ble(0, 0);
guid(0, 0);
}
delete [] buffer;
// src(0,0);
// out(0,0);