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 } }