Improve shadows-Highlight Residual

This commit is contained in:
Desmis
2019-05-27 09:23:56 +02:00
parent cfab29eb87
commit 83f487753c
13 changed files with 80 additions and 61 deletions

View File

@@ -71,6 +71,7 @@ struct cont_params {
float thH;
float conres;
float conresH;
float radius;
float chrores;
float hueres;
float sky;
@@ -435,6 +436,7 @@ void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int kall, const
cp.conres = waparams.rescon;
cp.conresH = waparams.resconH;
cp.radius = waparams.radius;
cp.chrores = waparams.reschro;
//cp.hueres=waparams.reshue;
cp.hueres = 2.f;
@@ -1782,7 +1784,7 @@ void ImProcFunctions::WaveletcontAllL(LabImage * labco, float ** varhue, float *
}
}
//
if (cp.tonemap && cp.contmet == 1 && cp.resena) {
float maxp = max0 * 256.f;
float minp = min0 * 256.f;
@@ -1791,54 +1793,40 @@ void ImProcFunctions::WaveletcontAllL(LabImage * labco, float ** varhue, float *
#endif
ContrastResid(WavCoeffs_L0, cp, W_L, H_L, maxp, minp);
}
#ifdef _OPENMP
#pragma omp barrier
#endif
}
if ((cp.conres != 0.f || cp.conresH != 0.f) && cp.resena) { // cp.conres = 0.f and cp.comresH = 0.f means that all will be multiplied by 1.f, so we can skip this step
LabImage *temp = nullptr;
temp = new LabImage(W_L, H_L);
#ifdef _OPENMP
#pragma omp for nowait
#pragma omp for
#endif
for (int i = 0; i < W_L * H_L; i++) {
float LL = WavCoeffs_L0[i];
float LL100 = LL / 327.68f;
float tran = 5.f;//transition
//shadow
float alp = 3.f; //increase contrast sahdow in lowlights between 1 and ??
if (cp.th > (100.f - tran)) {
tran = 100.f - cp.th;
for (int i = 0; i < H_L; i++) {
for (int j = 0; j < W_L; j++) {
temp->L[i][j] = WavCoeffs_L0[i * W_L + j];
}
}
{
ImProcFunctions::shadowsHighlights(temp, true, 1, cp.conresH, cp.conres, cp.radius, skip, cp.thH, cp.th);
}
#ifdef _OPENMP
#pragma omp for
#endif
for (int i = 0; i < H_L; i++) {
for (int j = 0; j < W_L; j++) {
WavCoeffs_L0[i * W_L + j] = temp->L[i][j];
}
}
if (LL100 < cp.th) {
float aalp = (1.f - alp) / cp.th; //no changes for LL100 = cp.th
float kk = aalp * LL100 + alp;
WavCoeffs_L0[i] *= (1.f + kk * cp.conres / 200.f);
} else if (LL100 < cp.th + tran) {
float ath = -cp.conres / tran;
float bth = cp.conres - ath * cp.th;
WavCoeffs_L0[i] *= (1.f + (LL100 * ath + bth) / 200.f);
}
delete temp;
//highlight
tran = 5.f;
if (cp.thH < (tran)) {
tran = cp.thH;
}
if (LL100 > cp.thH) {
WavCoeffs_L0[i] *= (1.f + cp.conresH / 200.f);
} else if (LL100 > (cp.thH - tran)) {
float athH = cp.conresH / tran;
float bthH = cp.conresH - athH * cp.thH;
WavCoeffs_L0[i] *= (1.f + (LL100 * athH + bthH) / 200.f);
}
}
}
#ifdef _OPENMP
#pragma omp parallel num_threads(wavNestedLevels) if(wavNestedLevels>1)
#endif
{
//enabled Lipschitz..replace simple by complex edge detection
// I found this concept on the web (doctoral thesis on medical Imaging)
// I was inspired by the principle of Canny and Lipschitz (continuity and derivability)