histogram matching: cache the computed tone curve in RawImageSource

This commit is contained in:
Alberto Griggio 2018-01-19 21:43:55 +01:00
parent 8728e3f3f3
commit 8f76392885
5 changed files with 14 additions and 3 deletions

View File

@ -139,6 +139,14 @@ void RawImageSource::getAutoMatchedToneCurve(std::vector<double> &outCurve)
std::cout << "performing histogram matching for " << getFileName() << " on the embedded thumbnail" << std::endl;
}
if (!histMatchingCache.empty()) {
if (settings->verbose) {
std::cout << "tone curve found in cache" << std::endl;
outCurve = histMatchingCache;
return;
}
}
outCurve = { DCT_Linear };
int fw, fh;
@ -161,6 +169,7 @@ void RawImageSource::getAutoMatchedToneCurve(std::vector<double> &outCurve)
if (settings->verbose) {
std::cout << "histogram matching: no thumbnail found, generating a neutral curve" << std::endl;
}
histMatchingCache = outCurve;
return;
}
source.reset(thumb->quickProcessImage(neutral, fh / skip, TI_Nearest));
@ -233,6 +242,8 @@ void RawImageSource::getAutoMatchedToneCurve(std::vector<double> &outCurve)
if (settings->verbose) {
std::cout << "histogram matching: generated curve with " << outCurve.size()/2 << " control points" << std::endl;
}
histMatchingCache = outCurve;
}
} // namespace rtengine

View File

@ -449,7 +449,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall)
if (params.toneCurve.histmatching) {
imgsrc->getAutoMatchedToneCurve(params.toneCurve.curve);
params.toneCurve.histmatching = false;
params.toneCurve.autoexp = false;
params.toneCurve.curveMode = ToneCurveParams::TcMode::FILMLIKE;
params.toneCurve.curve2 = { 0 };
params.toneCurve.expcomp = 0.0;

View File

@ -95,6 +95,7 @@ protected:
float psGreenBrightness[4];
float psBlueBrightness[4];
std::vector<double> histMatchingCache;
void hphd_vertical (float** hpmap, int col_from, int col_to);
void hphd_horizontal (float** hpmap, int row_from, int row_to);

View File

@ -743,7 +743,7 @@ private:
if (params.toneCurve.histmatching) {
imgsrc->getAutoMatchedToneCurve(params.toneCurve.curve);
params.toneCurve.histmatching = false;
params.toneCurve.autoexp = false;
params.toneCurve.curveMode = ToneCurveParams::TcMode::FILMLIKE;
params.toneCurve.curve2 = { 0 };
params.toneCurve.expcomp = 0.0;

View File

@ -953,7 +953,6 @@ bool ToneCurve::histmatchingComputed()
autolevels->set_inconsistent(false);
}
histmatching->set_active(false);
toneCurveMode->set_active(rtengine::toUnderlying(nextToneCurveMode));
shape->setCurve(nextToneCurve);
shape2->setCurve({ DCT_Linear });