From c04150be35bbbc4591944593d438ed39ea4bca0c Mon Sep 17 00:00:00 2001 From: Alberto Griggio Date: Tue, 30 Jan 2018 15:27:56 +0100 Subject: [PATCH] histmatching: slightly improved match for the shadows part of the tone curve --- rtengine/histmatching.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/rtengine/histmatching.cc b/rtengine/histmatching.cc index 87eb672c8..60cbda287 100644 --- a/rtengine/histmatching.cc +++ b/rtengine/histmatching.cc @@ -86,12 +86,19 @@ void mappingToCurve(const std::vector &mapping, std::vector &curve) curve.clear(); const int npoints = 8; - int idx = 1; + int idx = 15; for (; idx < int(mapping.size()); ++idx) { if (mapping[idx] >= idx) { break; } } + if (idx == int(mapping.size())) { + for (idx = 1; idx < int(mapping.size()); ++idx) { + if (mapping[idx] >= idx) { + break; + } + } + } int step = max(int(mapping.size())/npoints, 1); auto coord = [](int v) -> double { return double(v)/255.0; };