From 71a3af0c86a50e78cffce57be653a7d6d3c972c8 Mon Sep 17 00:00:00 2001 From: Alberto Griggio Date: Tue, 30 Jan 2018 10:06:57 +0100 Subject: [PATCH] improve generated curve in histogram matching on underexposed pictures --- rtengine/histmatching.cc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/rtengine/histmatching.cc b/rtengine/histmatching.cc index 1870d3180..6728e70ee 100644 --- a/rtengine/histmatching.cc +++ b/rtengine/histmatching.cc @@ -120,6 +120,15 @@ void mappingToCurve(const std::vector &mapping, std::vector &curve) curve.pop_back(); curve.pop_back(); } + // remove the plateau at the end (if any) + size_t j = curve.size() / 2; + for (; j > 1; --j) { + if (std::abs(curve[2*(j-1)-1] - curve.back()) > 0.01) { + break; + } + } + curve.resize(2*j); + curve.push_back(1.0); curve.push_back(1.0);