aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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);
}