local contrast speedups by heckflosse

This commit is contained in:
Alberto Griggio 2017-12-19 09:43:44 +01:00
parent b8777b3d87
commit a2bd8acac9

View File

@ -27,11 +27,14 @@
#include "gauss.h" #include "gauss.h"
#include "boxblur.h" #include "boxblur.h"
#include "array2D.h" #include "array2D.h"
#define BENCHMARK
#include "StopWatch.h"
namespace rtengine { namespace rtengine {
void ImProcFunctions::localContrast(LabImage *lab) void ImProcFunctions::localContrast(LabImage *lab)
{ {
BENCHFUN
if (!params->localContrast.enabled) { if (!params->localContrast.enabled) {
return; return;
} }
@ -45,6 +48,9 @@ void ImProcFunctions::localContrast(LabImage *lab)
array2D<float> buf(width, height); array2D<float> buf(width, height);
const float sigma = params->localContrast.radius / scale; const float sigma = params->localContrast.radius / scale;
#ifdef _OPENMP
#pragma omp parallel
#endif
gaussianBlur(lab->L, buf, width, height, sigma); gaussianBlur(lab->L, buf, width, height, sigma);
#ifdef _OPENMP #ifdef _OPENMP
@ -52,14 +58,13 @@ void ImProcFunctions::localContrast(LabImage *lab)
#endif #endif
for (int y = 0; y < height; ++y) { for (int y = 0; y < height; ++y) {
for (int x = 0; x < width; ++x) { for (int x = 0; x < width; ++x) {
buf[y][x] -= lab->L[y][x]; float bufval = (buf[y][x] - lab->L[y][x]) * a;
buf[y][x] *= a;
if (dark != 1 || light != 1) { if (dark != 1 || light != 1) {
buf[y][x] = max(buf[y][x], half) * light + min(buf[y][x], half) * dark; bufval = max(bufval, half) * light + min(bufval, half) * dark;
} }
lab->L[y][x] += buf[y][x]; lab->L[y][x] += bufval;
} }
} }
} }