Decouple sharpening amount from contrast mask, #5075

This commit is contained in:
heckflosse
2018-12-17 13:26:14 +01:00
parent 58e332475f
commit 988d598d9d

View File

@@ -159,7 +159,7 @@ extern const Settings* settings;
void ImProcFunctions::deconvsharpening (float** luminance, float** tmp, int W, int H, const SharpeningParams &sharpenParam)
{
if (sharpenParam.deconvamount == 0) {
if (sharpenParam.deconvamount == 0 && sharpenParam.blurradius < 0.25f) {
return;
}
BENCHFUN
@@ -177,7 +177,7 @@ BENCHFUN
// calculate contrast based blend factors to reduce sharpening in regions with low contrast
JaggedArray<float> blend(W, H);
float contrast = sharpenParam.contrast / 100.f;
buildBlendMask(luminance, blend, W, H, contrast, sharpenParam.deconvamount / 100.f);
buildBlendMask(luminance, blend, W, H, contrast, 1.f);
JaggedArray<float>* blurbuffer = nullptr;
if (sharpenParam.blurradius >= 0.25f) {
@@ -201,6 +201,7 @@ BENCHFUN
const float damping = sharpenParam.deconvdamping / 5.0;
const bool needdamp = sharpenParam.deconvdamping > 0;
const double sigma = sharpenParam.deconvradius / scale;
const float amount = sharpenParam.deconvamount / 100.f;
#ifdef _OPENMP
#pragma omp parallel
@@ -224,7 +225,7 @@ BENCHFUN
for (int i = 0; i < H; ++i) {
for (int j = 0; j < W; ++j) {
luminance[i][j] = intp(blend[i][j], max(tmpI[i][j], 0.0f), luminance[i][j]);
luminance[i][j] = intp(blend[i][j] * amount, max(tmpI[i][j], 0.0f), luminance[i][j]);
}
}
@@ -256,7 +257,7 @@ void ImProcFunctions::sharpening (LabImage* lab, const SharpeningParams &sharpen
// calculate contrast based blend factors to reduce sharpening in regions with low contrast
JaggedArray<float> blend(W, H);
float contrast = sharpenParam.contrast / 100.f;
buildBlendMask(lab->L, blend, W, H, contrast, sharpenParam.method == "rld" ? sharpenParam.deconvamount / 100.f : 1.f);
buildBlendMask(lab->L, blend, W, H, contrast, 1.f);
#ifdef _OPENMP
#pragma omp parallel for
#endif