From 624495eaec82eeef214bef24588602602173e096 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Thu, 18 Sep 2014 11:17:24 +0200 Subject: Get the proper middle of the gamma ramp when calculating the gamma correction MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/gamma.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/gamma.c') diff --git a/src/gamma.c b/src/gamma.c index f0dc05b..79a50f7 100644 --- a/src/gamma.c +++ b/src/gamma.c @@ -37,6 +37,12 @@ void gamma_analyse(size_t stops, const uint16_t* restrict ramp, double* restrict *contrast = max = (double)(ramp[stops - 1]) / (double)0xFFFF; middle = (double)(ramp[stops / 2]) / (double)0xFFFF; + if (stops % 2 == 0) + { + middle += (double)(ramp[stops / 2 - 1]) / (double)0xFFFF; + middle /= (double)2; + } + middle = (middle - min) / (max - min); *gamma = -log((double)2) / log(middle); } -- cgit v1.2.3-70-g09d2