add local blur flat region to sharpen - thanks to Ingo
This commit is contained in:
@@ -211,7 +211,7 @@ BENCHFUN
|
||||
} // end parallel
|
||||
}
|
||||
|
||||
void ImProcFunctions::deconvsharpeningloc (float** luminance, float** tmp, int W, int H, float** loctemp, int damp, double radi, int ite, int amo, int contrast)
|
||||
void ImProcFunctions::deconvsharpeningloc (float** luminance, float** tmp, int W, int H, float** loctemp, int damp, double radi, int ite, int amo, int contrast, double blurrad)
|
||||
{
|
||||
// BENCHFUN
|
||||
|
||||
@@ -236,18 +236,36 @@ void ImProcFunctions::deconvsharpeningloc (float** luminance, float** tmp, int W
|
||||
// calculate contrast based blend factors to reduce sharpening in regions with low contrast
|
||||
JaggedArray<float> blend(W, H);
|
||||
float contras = contrast / 100.f;
|
||||
buildBlendMask(luminance, blend, W, H, contras, amo / 100.f);
|
||||
buildBlendMask(luminance, blend, W, H, contras, 1.f);
|
||||
JaggedArray<float> blur(W, H);
|
||||
|
||||
if (blurrad >= 0.25) {
|
||||
#ifdef _OPENMP
|
||||
#pragma omp parallel
|
||||
#endif
|
||||
{
|
||||
gaussianBlur(tmpI, blur, W, H, blurrad);
|
||||
#ifdef _OPENMP
|
||||
#pragma omp for
|
||||
#endif
|
||||
for (int i = 0; i < H; ++i) {
|
||||
for (int j = 0; j < W; ++j) {
|
||||
blur[i][j] = intp(blend[i][j], luminance[i][j], std::max(blur[i][j], 0.0f));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
float damping = (float) damp / 5.0;
|
||||
bool needdamp = damp > 0;
|
||||
double sigma = radi / scale;
|
||||
const float amount = (float) amo / 100.f;
|
||||
|
||||
if (sigma < 0.26f) {
|
||||
sigma = 0.26f;
|
||||
}
|
||||
|
||||
int itera = ite;
|
||||
// printf("OK 2 damp=%f sigam=%f iter=%i\n", damping, sigma, itera);
|
||||
|
||||
#ifdef _OPENMP
|
||||
#pragma omp parallel
|
||||
@@ -266,8 +284,6 @@ void ImProcFunctions::deconvsharpeningloc (float** luminance, float** tmp, int W
|
||||
gaussianBlur (tmp, tmpI, W, H, sigma, nullptr, GAUSS_MULT);
|
||||
} // end for
|
||||
|
||||
// float p2 = (float) amo / 100.0;
|
||||
// float p1 = 1.0 - p2;
|
||||
|
||||
#ifdef _OPENMP
|
||||
#pragma omp for
|
||||
@@ -275,9 +291,20 @@ void ImProcFunctions::deconvsharpeningloc (float** luminance, float** tmp, int W
|
||||
|
||||
for (int i = 0; i < H; i++)
|
||||
for (int j = 0; j < W; j++) {
|
||||
// loctemp[i][j] = luminance[i][j] * p1 + max (tmpI[i][j], 0.0f) * p2;
|
||||
loctemp[i][j] = intp(blend[i][j], max(tmpI[i][j], 0.0f), luminance[i][j]);
|
||||
loctemp[i][j] = intp(blend[i][j] * amount, max(tmpI[i][j], 0.0f), luminance[i][j]);
|
||||
}
|
||||
|
||||
if (blurrad >= 0.25) {
|
||||
#ifdef _OPENMP
|
||||
#pragma omp for
|
||||
#endif
|
||||
for (int i = 0; i < H; ++i) {
|
||||
for (int j = 0; j < W; ++j) {
|
||||
loctemp[i][j] = intp(blend[i][j], loctemp[i][j], max(blur[i][j], 0.0f));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // end parallel
|
||||
|
||||
delete [] tmpI[0];
|
||||
|
||||
Reference in New Issue
Block a user