diff --git a/rtengine/tmo_fattal02.cc b/rtengine/tmo_fattal02.cc index 71b47cdaf..9d7d2c6a4 100644 --- a/rtengine/tmo_fattal02.cc +++ b/rtengine/tmo_fattal02.cc @@ -215,7 +215,6 @@ void gaussianBlur(const Array2Df& I, Array2Df& L) void createGaussianPyramids( Array2Df* H, Array2Df** pyramids, int nlevels) { - BENCHFUN int width = H->getCols(); int height = H->getRows(); const int size = width*height; @@ -257,7 +256,6 @@ void createGaussianPyramids( Array2Df* H, Array2Df** pyramids, int nlevels) float calculateGradients(Array2Df* H, Array2Df* G, int k) { - BENCHFUN const int width = H->getCols(); const int height = H->getRows(); const float divider = pow( 2.0f, k+1 ); @@ -333,7 +331,6 @@ void calculateFiMatrix(Array2Df* FI, Array2Df* gradients[], float avgGrad[], int nlevels, int detail_level, float alfa, float beta, float noise) { - BENCHFUN const bool newfattal = true; int width = gradients[nlevels-1]->getCols(); int height = gradients[nlevels-1]->getRows(); @@ -349,7 +346,6 @@ void calculateFiMatrix(Array2Df* FI, Array2Df* gradients[], } } -StopWatch Stop1("test"); for ( int k = nlevels-1; k >= 0 ; k-- ) { width = gradients[k]->getCols(); @@ -395,7 +391,6 @@ StopWatch Stop1("test"); gaussianBlur(*fi[k-1], *fi[k-1]); } } -Stop1.stop(); for ( int k=1 ; k 0) { // interpolate + int count_ = count - histo[k - 1]; + float c0 = count - minPrct * size; + float c1 = minPrct * size - count_; + minLum = (c1 * k + c0 * (k - 1)) / ((c0 + c1) * 65535.f); + } else { + minLum = k /65535.f; + } + // find (maxPrct*size) smallest value while(count < maxPrct*size) { count += histo[k++]; } - maxLum = k /65535.f; + if(k > 0) { // interpolate + int count_ = count - histo[k - 1]; + float c0 = count - maxPrct * size; + float c1 = maxPrct * size - count_; + maxLum = (c1 * k + c0 * (k - 1)) / ((c0 + c1) * 65535.f); + } else { + maxLum = k /65535.f; + } } @@ -452,7 +482,6 @@ void tmo_fattal02(size_t width, int detail_level, bool multithread) { - BENCHFUN // #ifdef TIMER_PROFILING // msec_timer stop_watch; // stop_watch.start(); @@ -497,37 +526,28 @@ void tmo_fattal02(size_t width, maxLum = ( Y(i) > maxLum ) ? Y(i) : maxLum; } Array2Df* H = new Array2Df(width, height); - //#pragma omp parallel for private(i) shared(H, Y, maxLum) - StopWatch Stop1("logf"); + float temp = 100.f / maxLum; + float eps = 1e-4f; #pragma omp parallel { #ifdef __SSE2__ - vfloat epsv = F2V(1e-4); + vfloat epsv = F2V(eps); vfloat tempv = F2V(temp); #endif #pragma omp for schedule(dynamic,16) - for ( size_t i=0 ; i get_lambda(int n) void solve_pde_fft(Array2Df *F, Array2Df *U, bool multithread)/*, pfs::Progress &ph, bool adjust_bound)*/ { -BENCHFUN // ph.setValue(20); //DEBUG_STR << "solve_pde_fft: solving Laplace U = F ..." << std::endl; int width = F->getCols();