From 97e73457ee07a2bfa93fb925adda1774f779e90d Mon Sep 17 00:00:00 2001 From: Alberto Griggio Date: Mon, 13 Aug 2018 14:18:59 +0200 Subject: [PATCH] histmatching: use better spaced points for the generated curve --- rtengine/histmatching.cc | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/rtengine/histmatching.cc b/rtengine/histmatching.cc index d4f236d0e..b2fe436fd 100644 --- a/rtengine/histmatching.cc +++ b/rtengine/histmatching.cc @@ -221,26 +221,17 @@ void mappingToCurve(const std::vector &mapping, std::vector &curve) curve = { DCT_Linear }; // not enough points, fall back to linear } else { CubicSplineCurve c(curve); - double mid = coord(idx); + double gap = 0.05; double x = 0.0; - constexpr double shgap = 0.075; curve = { DCT_Spline }; - while (mid - x > shgap / 2) { + while (x < 1.0) { curve.push_back(x); curve.push_back(c.getVal(x)); - x += shgap; - } - curve.push_back(mid); - curve.push_back(c.getVal(mid)); - constexpr double hlgap = 0.2; - x = mid + hlgap; - while (1 - x > hlgap / 2) { - curve.push_back(x); - curve.push_back(c.getVal(x)); - x += hlgap; + x += gap; + gap *= 1.4; } curve.push_back(1.0); - curve.push_back(1.0); + curve.push_back(c.getVal(1.0)); } }