aboutsummaryrefslogtreecommitdiffstats
path: root/src/gamma.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-09-18 11:17:24 +0200
committerMattias Andrée <maandree@operamail.com>2014-09-18 11:17:24 +0200
commit624495eaec82eeef214bef24588602602173e096 (patch)
tree23ae9671fbfcd9c8ceb6caea24724d6dc1ca79cf /src/gamma.c
parentdist (diff)
downloadcrt-calibrator-624495eaec82eeef214bef24588602602173e096.tar.gz
crt-calibrator-624495eaec82eeef214bef24588602602173e096.tar.bz2
crt-calibrator-624495eaec82eeef214bef24588602602173e096.tar.xz
Get the proper middle of the gamma ramp when calculating the gamma correction1.1
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src/gamma.c')
-rw-r--r--src/gamma.c6
1 files changed, 6 insertions, 0 deletions
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);
}