From 1a2b7d2cde1eec44eb8290b0f57882ee1d46c8a3 Mon Sep 17 00:00:00 2001 From: Alberto Griggio Date: Sun, 5 Nov 2017 21:32:06 +0100 Subject: [PATCH] Fattal: extract luminance using the current working space matrix, not the sRGB one Doesn't seem to make any practical difference though... --- rtengine/tmo_fattal02.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/rtengine/tmo_fattal02.cc b/rtengine/tmo_fattal02.cc index b69d4fcb1..32b93d79b 100644 --- a/rtengine/tmo_fattal02.cc +++ b/rtengine/tmo_fattal02.cc @@ -1110,6 +1110,12 @@ void rescale_bilinear(const Array2Df &src, Array2Df &dst, bool multithread) } } + +inline float luminance(float r, float g, float b, TMatrix ws) +{ + return r * ws[1][0] + g * ws[1][1] + b * ws[1][2]; +} + } // namespace @@ -1141,13 +1147,14 @@ void ImProcFunctions::ToneMapFattal02(Imagefloat *rgb) const float epsilon = 1e-4f; const float luminance_noise_floor = 65.535f; const float min_luminance = 1.f; + TMatrix ws = ICCStore::getInstance()->workingSpaceMatrix(params->icm.working); #ifdef _OPENMP #pragma omp parallel for if (multiThread) #endif for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++) { - Yr(x, y) = std::max(Color::rgbLuminance(rgb->r(y, x), rgb->g(y, x), rgb->b(y, x)), min_luminance); // clip really black pixels + Yr(x, y) = std::max(luminance(rgb->r(y, x), rgb->g(y, x), rgb->b(y, x), ws), min_luminance); // clip really black pixels } }