From 235a4bb451ae9309594e59b6d62bb8acd6081ad2 Mon Sep 17 00:00:00 2001 From: Alberto Griggio Date: Tue, 19 Dec 2017 22:24:58 +0100 Subject: [PATCH] simplified the local contrast code and implemented the "proper" highlights and shadows scaling --- rtengine/iplocalcontrast.cc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/rtengine/iplocalcontrast.cc b/rtengine/iplocalcontrast.cc index b68f376ec..0445746a4 100644 --- a/rtengine/iplocalcontrast.cc +++ b/rtengine/iplocalcontrast.cc @@ -45,8 +45,7 @@ void ImProcFunctions::localContrast(LabImage *lab) const int width = lab->W; const int height = lab->H; - const float a = -params->localContrast.amount; - const float half = 0.5f; + const float a = params->localContrast.amount; const float dark = params->localContrast.darkness; const float light = params->localContrast.lightness; array2D buf(width, height); @@ -62,10 +61,10 @@ void ImProcFunctions::localContrast(LabImage *lab) #endif for (int y = 0; y < height; ++y) { for (int x = 0; x < width; ++x) { - float bufval = (buf[y][x] - lab->L[y][x]) * a; + float bufval = (lab->L[y][x] - buf[y][x]) * a; if (dark != 1 || light != 1) { - bufval = max(bufval, half) * light + min(bufval, half) * dark; + bufval *= (bufval > 0.f) ? light : dark; } lab->L[y][x] += bufval;