diff options
| author | Carl Hetherington <cth@carlh.net> | 2022-05-05 20:56:14 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2022-05-05 21:09:40 +0200 |
| commit | cbbb9e63b7ec7a5c34f186ceafe5da6be8faa739 (patch) | |
| tree | 79ccaa11973954138df02c2022b2ea25c0717b9d /src/gamma_transfer_function.cc | |
| parent | ad7244de981a7dd0b9b4f8f3d62d4704f1968012 (diff) | |
Allow LUTs to be created with a particular range.
Diffstat (limited to 'src/gamma_transfer_function.cc')
| -rw-r--r-- | src/gamma_transfer_function.cc | 5 |
1 files changed, 3 insertions, 2 deletions
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<double> -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<double>(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; |
