Fattal: added anchor parameter

This commit is contained in:
Alberto Griggio
2018-01-25 22:13:17 +01:00
parent 83bc6140bd
commit 8a510315c2
12 changed files with 54 additions and 17 deletions

View File

@@ -1464,7 +1464,8 @@ bool EPDParams::operator !=(const EPDParams& other) const
FattalToneMappingParams::FattalToneMappingParams() :
enabled(false),
threshold(0),
amount(30)
amount(30),
anchor(50)
{
}
@@ -1473,7 +1474,8 @@ bool FattalToneMappingParams::operator ==(const FattalToneMappingParams& other)
return
enabled == other.enabled
&& threshold == other.threshold
&& amount == other.amount;
&& amount == other.amount
&& anchor == other.anchor;
}
bool FattalToneMappingParams::operator !=(const FattalToneMappingParams& other) const
@@ -3048,6 +3050,7 @@ int ProcParams::save(const Glib::ustring& fname, const Glib::ustring& fname2, bo
saveToKeyfile(!pedited || pedited->fattal.enabled, "FattalToneMapping", "Enabled", fattal.enabled, keyFile);
saveToKeyfile(!pedited || pedited->fattal.threshold, "FattalToneMapping", "Threshold", fattal.threshold, keyFile);
saveToKeyfile(!pedited || pedited->fattal.amount, "FattalToneMapping", "Amount", fattal.amount, keyFile);
saveToKeyfile(!pedited || pedited->fattal.anchor, "FattalToneMapping", "Anchor", fattal.anchor, keyFile);
// Shadows & highlights
saveToKeyfile(!pedited || pedited->sh.enabled, "Shadows & Highlights", "Enabled", sh.enabled, keyFile);
@@ -3945,6 +3948,7 @@ int ProcParams::load(const Glib::ustring& fname, ParamsEdited* pedited)
assignFromKeyfile(keyFile, "FattalToneMapping", "Enabled", pedited, fattal.enabled, pedited->fattal.enabled);
assignFromKeyfile(keyFile, "FattalToneMapping", "Threshold", pedited, fattal.threshold, pedited->fattal.threshold);
assignFromKeyfile(keyFile, "FattalToneMapping", "Amount", pedited, fattal.amount, pedited->fattal.amount);
assignFromKeyfile(keyFile, "FattalToneMapping", "Anchor", pedited, fattal.anchor, pedited->fattal.anchor);
}
if (keyFile.has_group ("Shadows & Highlights")) {

View File

@@ -728,6 +728,7 @@ struct FattalToneMappingParams {
bool enabled;
int threshold;
int amount;
int anchor;
FattalToneMappingParams();

View File

@@ -1104,7 +1104,8 @@ void ImProcFunctions::ToneMapFattal02 (Imagefloat *rgb)
}
float oldMedian;
findMinMaxPercentile (Yr.data(), Yr.getRows() * Yr.getCols(), 0.5f, oldMedian, 0.5f, oldMedian, multiThread);
const float percentile = float(LIM(1, params->fattal.anchor, 100)) / 100.f;
findMinMaxPercentile (Yr.data(), Yr.getRows() * Yr.getCols(), percentile, oldMedian, percentile, oldMedian, multiThread);
// median filter on the deep shadows, to avoid boosting noise
// because w2 >= w and h2 >= h, we can use the L buffer as temporary buffer for Median_Denoise()
int w2 = find_fast_dim (w) + 1;
@@ -1146,7 +1147,7 @@ void ImProcFunctions::ToneMapFattal02 (Imagefloat *rgb)
const float wr = float(w2) / float(w);
float newMedian;
findMinMaxPercentile (L.data(), L.getRows() * L.getCols(), 0.5f, newMedian, 0.5f, newMedian, multiThread);
findMinMaxPercentile (L.data(), L.getRows() * L.getCols(), percentile, newMedian, percentile, newMedian, multiThread);
const float scale = (oldMedian == 0.f || newMedian == 0.f) ? 65535.f : (oldMedian / newMedian); // avoid Nan
#ifdef _OPENMP