First quick&dirty version of flat region blur, #5075

This commit is contained in:
heckflosse
2018-12-08 21:57:56 +01:00
parent 033b021b9b
commit 5162484517
8 changed files with 74 additions and 4 deletions

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 < 1) {
if (sharpenParam.deconvamount == 0) {
return;
}
BENCHFUN
@@ -178,7 +178,14 @@ BENCHFUN
JaggedArray<float> blend(W, H);
float contrast = sharpenParam.contrast / 100.f;
buildBlendMask(luminance, blend, W, H, contrast, sharpenParam.deconvamount / 100.f);
JaggedArray<float> blur(W, H);
if(sharpenParam.blurradius > 0) {
#pragma omp parallel
{
gaussianBlur(tmpI, blur, W, H, sharpenParam.blurradius);
}
}
const float damping = sharpenParam.deconvdamping / 5.0;
const bool needdamp = sharpenParam.deconvdamping > 0;
const double sigma = sharpenParam.deconvradius / scale;
@@ -208,6 +215,17 @@ BENCHFUN
luminance[i][j] = intp(blend[i][j], max(tmpI[i][j], 0.0f), luminance[i][j]);
}
}
if(sharpenParam.blurradius > 0) {
#ifdef _OPENMP
#pragma omp for
#endif
for (int i = 0; i < H; ++i) {
for (int j = 0; j < W; ++j) {
luminance[i][j] = intp(blend[i][j], luminance[i][j], max(blur[i][j], 0.0f));
}
}
}
} // end parallel
}
@@ -224,7 +242,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, sharpenParam.method == "rld" ? 1.f : 1.f);
#ifdef _OPENMP
#pragma omp parallel for
#endif
@@ -256,6 +274,15 @@ BENCHFUN
}
}
JaggedArray<float> blur(W, H);
if(sharpenParam.blurradius > 0) {
#pragma omp parallel
{
gaussianBlur(lab->L, blur, W, H, sharpenParam.blurradius);
}
}
// calculate contrast based blend factors to reduce sharpening in regions with low contrast
JaggedArray<float> blend(W, H);
float contrast = sharpenParam.contrast / 100.f;
@@ -322,6 +349,17 @@ BENCHFUN
delete [] b3;
}
if(sharpenParam.blurradius > 0) {
#ifdef _OPENMP
#pragma omp parallel for
#endif
for (int i = 0; i < H; ++i) {
for (int j = 0; j < W; ++j) {
lab->L[i][j] = intp(blend[i][j], lab->L[i][j], max(blur[i][j], 0.0f));
}
}
}
}
// To the extent possible under law, Manuel Llorens <manuelllorens@gmail.com>