From cbbb9e63b7ec7a5c34f186ceafe5da6be8faa739 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Thu, 5 May 2022 20:56:14 +0200 Subject: Allow LUTs to be created with a particular range. --- src/gamma_transfer_function.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/gamma_transfer_function.cc') diff --git a/src/gamma_transfer_function.cc b/src/gamma_transfer_function.cc index 4ec09afb..ff9073a1 100644 --- a/src/gamma_transfer_function.cc +++ b/src/gamma_transfer_function.cc @@ -56,13 +56,14 @@ GammaTransferFunction::GammaTransferFunction (double gamma) vector -GammaTransferFunction::make_lut (int bit_depth, bool inverse) const +GammaTransferFunction::make_lut (double from, double to, int bit_depth, bool inverse) const { int const bit_length = int(std::pow(2.0f, bit_depth)); auto lut = vector(bit_length); double const gamma = inverse ? (1 / _gamma) : _gamma; for (int i = 0; i < bit_length; ++i) { - lut[i] = pow(double(i) / (bit_length - 1), gamma); + double const x = double(i) / (bit_length - 1); + lut[i] = pow((x * (to - from)) + from, gamma); } return lut; -- cgit v1.2.3