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