Some tweaks to curve extraction from histogram matching
This commit is contained in:
@@ -108,7 +108,7 @@ void mappingToCurve(const std::vector<int> &mapping, std::vector<double> &curve)
|
||||
int v = mapping[i];
|
||||
bool change = i > 0 && v != mapping[i-1];
|
||||
int diff = i - prev;
|
||||
if (change && std::abs(diff - step) <= 1) {
|
||||
if ((change && std::abs(diff - step) <= 1) || diff > step * 2) {
|
||||
curve.push_back(coord(i));
|
||||
curve.push_back(coord(v));
|
||||
prev = i;
|
||||
@@ -117,10 +117,13 @@ void mappingToCurve(const std::vector<int> &mapping, std::vector<double> &curve)
|
||||
};
|
||||
doit(0, idx, idx > step ? step : idx / 2, true);
|
||||
doit(idx, int(mapping.size()), step, idx - step > step / 2);
|
||||
if (curve.size() <= 2 || curve.back() < 0.99 || (1 - curve[curve.size()-2] > step / 512.0 && curve.back() < coord(mapping.back()))) {
|
||||
curve.emplace_back(1.0);
|
||||
curve.emplace_back(1.0);
|
||||
if (curve.size() > 2 && (1 - curve[curve.size()-2] <= step / (256.0 * 3))) {
|
||||
curve.pop_back();
|
||||
curve.pop_back();
|
||||
}
|
||||
curve.push_back(1.0);
|
||||
curve.push_back(1.0);
|
||||
|
||||
if (curve.size() < 4) {
|
||||
curve = { DCT_Linear }; // not enough points, fall back to linear
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user