aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-08-07 22:40:10 +0200
committerMattias Andrée <maandree@operamail.com>2014-08-07 22:40:10 +0200
commit6690d4cdceb565515b248e169c09abaf756ab3fc (patch)
tree0de3bd72fa4eeedbd0d365f2ddb5b2131da460bd
parentm + doc (diff)
downloadcrt-calibrator-6690d4cdceb565515b248e169c09abaf756ab3fc.tar.gz
crt-calibrator-6690d4cdceb565515b248e169c09abaf756ab3fc.tar.bz2
crt-calibrator-6690d4cdceb565515b248e169c09abaf756ab3fc.tar.xz
derp
Signed-off-by: Mattias Andrée <maandree@operamail.com>
-rw-r--r--src/gamma.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/gamma.c b/src/gamma.c
index fa57fb4..66f2f38 100644
--- a/src/gamma.c
+++ b/src/gamma.c
@@ -38,7 +38,7 @@ void gamma_analyse(size_t stops, const uint16_t* restrict ramp, double* restrict
middle = (double)(ramp[stops / 2]) / (double)0xFFFF;
middle = (middle - min) / (max - min);
- *gamma = log(middle) / log(2.0);
+ *gamma = log(2.0) / log(middle);
}
@@ -55,6 +55,7 @@ void gamma_generate(size_t stops, uint16_t* restrict ramp, double gamma,
double contrast, double brightness)
{
double diff = contrast - brightness;
+ double gamma_ = 1.0 / gamma;
size_t i;
int32_t y;
double y_;
@@ -62,7 +63,7 @@ void gamma_generate(size_t stops, uint16_t* restrict ramp, double gamma,
for (i = 0; i < stops; i++)
{
y_ = (double)i / (double)stops;
- y_ = pow(y_, gamma) * diff + brightness;
+ y_ = pow(y_, gamma_) * diff + brightness;
y = (int32_t)(y * 0xFFFF);
if (y < 0x0000) y = 0x0000;
if (y > 0xFFFF) y = 0xFFFF;