Fattal: extract luminance using the current working space matrix, not the sRGB one

Doesn't seem to make any practical difference though...
This commit is contained in:
Alberto Griggio 2017-11-05 21:32:06 +01:00
parent facb37be91
commit 1a2b7d2cde

View File

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