merge with dev - all warnings are not delete - come soon
This commit is contained in:
@@ -55,40 +55,40 @@ extern const Settings* settings;
|
||||
//sequence of scales
|
||||
|
||||
|
||||
SSEFUNCTION void ImProcFunctions :: dirpyr_equalizer(float ** src, float ** dst, int srcwidth, int srcheight, float ** l_a, float ** l_b, float ** dest_a, float ** dest_b, const double * mult, const double dirpyrThreshold, const double skinprot, const bool gamutlab, float b_l, float t_l, float t_r, float b_r, int choice, int scaleprev)
|
||||
SSEFUNCTION void ImProcFunctions :: dirpyr_equalizer (float ** src, float ** dst, int srcwidth, int srcheight, float ** l_a, float ** l_b, float ** dest_a, float ** dest_b, const double * mult, const double dirpyrThreshold, const double skinprot, const bool gamutlab, float b_l, float t_l, float t_r, float b_r, int choice, int scaleprev)
|
||||
{
|
||||
int lastlevel = maxlevel;
|
||||
|
||||
if(settings->verbose) {
|
||||
printf("Dirpyr scaleprev=%i\n", scaleprev);
|
||||
if (settings->verbose) {
|
||||
printf ("Dirpyr scaleprev=%i\n", scaleprev);
|
||||
}
|
||||
|
||||
float atten123 = (float) settings->level123_cbdl;
|
||||
|
||||
if(atten123 > 50.f) {
|
||||
if (atten123 > 50.f) {
|
||||
atten123 = 50.f;
|
||||
}
|
||||
|
||||
if(atten123 < 0.f) {
|
||||
if (atten123 < 0.f) {
|
||||
atten123 = 0.f;
|
||||
}
|
||||
|
||||
float atten0 = (float) settings->level0_cbdl;
|
||||
|
||||
if(atten0 > 40.f) {
|
||||
if (atten0 > 40.f) {
|
||||
atten123 = 40.f;
|
||||
}
|
||||
|
||||
if(atten0 < 0.f) {
|
||||
if (atten0 < 0.f) {
|
||||
atten0 = 0.f;
|
||||
}
|
||||
|
||||
if((t_r - t_l) < 0.55f) {
|
||||
if ((t_r - t_l) < 0.55f) {
|
||||
t_l = t_r + 0.55f; //avoid too small range
|
||||
}
|
||||
|
||||
|
||||
while (lastlevel > 0 && fabs(mult[lastlevel - 1] - 1) < 0.001) {
|
||||
while (lastlevel > 0 && fabs (mult[lastlevel - 1] - 1) < 0.001) {
|
||||
lastlevel--;
|
||||
//printf("last level to process %d \n",lastlevel);
|
||||
}
|
||||
@@ -101,17 +101,17 @@ SSEFUNCTION void ImProcFunctions :: dirpyr_equalizer(float ** src, float ** dst,
|
||||
float multi[6] = {1.f, 1.f, 1.f, 1.f, 1.f, 1.f};
|
||||
float scalefl[6];
|
||||
|
||||
for(int lv = 0; lv < 6; lv++) {
|
||||
for (int lv = 0; lv < 6; lv++) {
|
||||
scalefl[lv] = ((float) scales[lv]) / (float) scaleprev;
|
||||
|
||||
if(lv >= 1) {
|
||||
if(scalefl[lv] < 1.f) {
|
||||
if (lv >= 1) {
|
||||
if (scalefl[lv] < 1.f) {
|
||||
multi[lv] = (atten123 * ((float) mult[lv] - 1.f) / 100.f) + 1.f; //modulate action if zoom < 100%
|
||||
} else {
|
||||
multi[lv] = (float) mult[lv];
|
||||
}
|
||||
} else {
|
||||
if(scalefl[lv] < 1.f) {
|
||||
if (scalefl[lv] < 1.f) {
|
||||
multi[lv] = (atten0 * ((float) mult[lv] - 1.f) / 100.f) + 1.f; //modulate action if zoom < 100%
|
||||
} else {
|
||||
multi[lv] = (float) mult[lv];
|
||||
@@ -120,8 +120,8 @@ SSEFUNCTION void ImProcFunctions :: dirpyr_equalizer(float ** src, float ** dst,
|
||||
|
||||
}
|
||||
|
||||
if(settings->verbose) {
|
||||
printf("CbDL mult0=%f 1=%f 2=%f 3=%f 4=%f 5=%f\n", multi[0], multi[1], multi[2], multi[3], multi[4], multi[5]);
|
||||
if (settings->verbose) {
|
||||
printf ("CbDL mult0=%f 1=%f 2=%f 3=%f 4=%f 5=%f\n", multi[0], multi[1], multi[2], multi[3], multi[4], multi[5]);
|
||||
}
|
||||
|
||||
multi_array2D<float, maxlevel> dirpyrlo (srcwidth, srcheight);
|
||||
@@ -129,33 +129,33 @@ SSEFUNCTION void ImProcFunctions :: dirpyr_equalizer(float ** src, float ** dst,
|
||||
level = 0;
|
||||
|
||||
//int thresh = 100 * mult[5];
|
||||
int scale = (int)(scales[level]) / scaleprev;
|
||||
int scale = (int) (scales[level]) / scaleprev;
|
||||
|
||||
if(scale < 1) {
|
||||
if (scale < 1) {
|
||||
scale = 1;
|
||||
}
|
||||
|
||||
|
||||
dirpyr_channel(src, dirpyrlo[0], srcwidth, srcheight, 0, scale);
|
||||
dirpyr_channel (src, dirpyrlo[0], srcwidth, srcheight, 0, scale);
|
||||
|
||||
level = 1;
|
||||
|
||||
while(level < lastlevel) {
|
||||
while (level < lastlevel) {
|
||||
|
||||
scale = (int)(scales[level]) / scaleprev;
|
||||
scale = (int) (scales[level]) / scaleprev;
|
||||
|
||||
if(scale < 1) {
|
||||
if (scale < 1) {
|
||||
scale = 1;
|
||||
}
|
||||
|
||||
dirpyr_channel(dirpyrlo[level - 1], dirpyrlo[level], srcwidth, srcheight, level, scale);
|
||||
dirpyr_channel (dirpyrlo[level - 1], dirpyrlo[level], srcwidth, srcheight, level, scale);
|
||||
|
||||
level ++;
|
||||
}
|
||||
|
||||
float **tmpHue, **tmpChr;
|
||||
float **tmpHue = nullptr, **tmpChr = nullptr;
|
||||
|
||||
if(skinprot != 0.f) {
|
||||
if (skinprot != 0.f) {
|
||||
// precalculate hue and chroma, use SSE, if available
|
||||
// by precalculating these values we can greatly reduce the number of calculations in idirpyr_eq_channel()
|
||||
// but we need two additional buffers for this preprocessing
|
||||
@@ -168,24 +168,24 @@ SSEFUNCTION void ImProcFunctions :: dirpyr_equalizer(float ** src, float ** dst,
|
||||
#ifdef __SSE2__
|
||||
#pragma omp parallel for
|
||||
|
||||
for(int i = 0; i < srcheight; i++) {
|
||||
for (int i = 0; i < srcheight; i++) {
|
||||
int j;
|
||||
|
||||
for(j = 0; j < srcwidth - 3; j += 4) {
|
||||
_mm_storeu_ps(&tmpHue[i][j], xatan2f(LVFU(l_b[i][j]), LVFU(l_a[i][j])));
|
||||
for (j = 0; j < srcwidth - 3; j += 4) {
|
||||
_mm_storeu_ps (&tmpHue[i][j], xatan2f (LVFU (l_b[i][j]), LVFU (l_a[i][j])));
|
||||
}
|
||||
|
||||
for(; j < srcwidth; j++) {
|
||||
tmpHue[i][j] = xatan2f(l_b[i][j], l_a[i][j]);
|
||||
for (; j < srcwidth; j++) {
|
||||
tmpHue[i][j] = xatan2f (l_b[i][j], l_a[i][j]);
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
#pragma omp parallel for
|
||||
|
||||
for(int i = 0; i < srcheight; i++) {
|
||||
for(int j = 0; j < srcwidth; j++) {
|
||||
tmpHue[i][j] = xatan2f(l_b[i][j], l_a[i][j]);
|
||||
for (int i = 0; i < srcheight; i++) {
|
||||
for (int j = 0; j < srcwidth; j++) {
|
||||
tmpHue[i][j] = xatan2f (l_b[i][j], l_a[i][j]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -199,27 +199,27 @@ SSEFUNCTION void ImProcFunctions :: dirpyr_equalizer(float ** src, float ** dst,
|
||||
#ifdef __SSE2__
|
||||
#pragma omp parallel
|
||||
{
|
||||
__m128 div = _mm_set1_ps(327.68f);
|
||||
__m128 div = _mm_set1_ps (327.68f);
|
||||
#pragma omp for
|
||||
|
||||
for(int i = 0; i < srcheight; i++) {
|
||||
for (int i = 0; i < srcheight; i++) {
|
||||
int j;
|
||||
|
||||
for(j = 0; j < srcwidth - 3; j += 4) {
|
||||
_mm_storeu_ps(&tmpChr[i][j], _mm_sqrt_ps(SQRV(LVFU(l_b[i][j])) + SQRV(LVFU(l_a[i][j]))) / div);
|
||||
for (j = 0; j < srcwidth - 3; j += 4) {
|
||||
_mm_storeu_ps (&tmpChr[i][j], _mm_sqrt_ps (SQRV (LVFU (l_b[i][j])) + SQRV (LVFU (l_a[i][j]))) / div);
|
||||
}
|
||||
|
||||
for(; j < srcwidth; j++) {
|
||||
tmpChr[i][j] = sqrtf(SQR((l_b[i][j])) + SQR((l_a[i][j]))) / 327.68f;
|
||||
for (; j < srcwidth; j++) {
|
||||
tmpChr[i][j] = sqrtf (SQR ((l_b[i][j])) + SQR ((l_a[i][j]))) / 327.68f;
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
#pragma omp parallel for
|
||||
|
||||
for(int i = 0; i < srcheight; i++) {
|
||||
for(int j = 0; j < srcwidth; j++) {
|
||||
tmpChr[i][j] = sqrtf(SQR((l_b[i][j])) + SQR((l_a[i][j]))) / 327.68f;
|
||||
for (int i = 0; i < srcheight; i++) {
|
||||
for (int j = 0; j < srcwidth; j++) {
|
||||
tmpChr[i][j] = sqrtf (SQR ((l_b[i][j])) + SQR ((l_a[i][j]))) / 327.68f;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -229,15 +229,15 @@ SSEFUNCTION void ImProcFunctions :: dirpyr_equalizer(float ** src, float ** dst,
|
||||
// with the current implementation of idirpyr_eq_channel we can safely use the buffer from last level as buffer, saves some memory
|
||||
float ** buffer = dirpyrlo[lastlevel - 1];
|
||||
|
||||
for(int level = lastlevel - 1; level > 0; level--) {
|
||||
idirpyr_eq_channel(dirpyrlo[level], dirpyrlo[level - 1], buffer, srcwidth, srcheight, level, multi, dirpyrThreshold, tmpHue, tmpChr, skinprot, gamutlab, b_l, t_l, t_r, b_r, choice );
|
||||
for (int level = lastlevel - 1; level > 0; level--) {
|
||||
idirpyr_eq_channel (dirpyrlo[level], dirpyrlo[level - 1], buffer, srcwidth, srcheight, level, multi, dirpyrThreshold, tmpHue, tmpChr, skinprot, gamutlab, b_l, t_l, t_r, b_r, choice );
|
||||
}
|
||||
|
||||
scale = scales[0];
|
||||
|
||||
idirpyr_eq_channel(dirpyrlo[0], dst, buffer, srcwidth, srcheight, 0, multi, dirpyrThreshold, tmpHue, tmpChr, skinprot, gamutlab, b_l, t_l, t_r, b_r, choice );
|
||||
idirpyr_eq_channel (dirpyrlo[0], dst, buffer, srcwidth, srcheight, 0, multi, dirpyrThreshold, tmpHue, tmpChr, skinprot, gamutlab, b_l, t_l, t_r, b_r, choice );
|
||||
|
||||
if(skinprot != 0.f) {
|
||||
if (skinprot != 0.f) {
|
||||
for (int i = 0; i < srcheight; i++) {
|
||||
delete [] tmpChr[i];
|
||||
}
|
||||
@@ -256,44 +256,44 @@ SSEFUNCTION void ImProcFunctions :: dirpyr_equalizer(float ** src, float ** dst,
|
||||
|
||||
for (int i = 0; i < srcheight; i++)
|
||||
for (int j = 0; j < srcwidth; j++) {
|
||||
dst[i][j] = CLIP(buffer[i][j]); // TODO: Really a clip necessary?
|
||||
dst[i][j] = CLIP (buffer[i][j]); // TODO: Really a clip necessary?
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
SSEFUNCTION void ImProcFunctions :: cbdl_local_temp(float ** src, float ** dst, float ** loctemp, int srcwidth, int srcheight, const float * mult, const double dirpyrThreshold, const double skinprot, const bool gamutlab, float b_l, float t_l, float t_r, float b_r, int choice, int scaleprev)
|
||||
SSEFUNCTION void ImProcFunctions :: cbdl_local_temp (float ** src, float ** dst, float ** loctemp, int srcwidth, int srcheight, const float * mult, const double dirpyrThreshold, const double skinprot, const bool gamutlab, float b_l, float t_l, float t_r, float b_r, int choice, int scaleprev)
|
||||
{
|
||||
int lastlevel = maxlevelloc;
|
||||
|
||||
if(settings->verbose) {
|
||||
printf("Dirpyr scaleprev=%i\n", scaleprev);
|
||||
if (settings->verbose) {
|
||||
printf ("Dirpyr scaleprev=%i\n", scaleprev);
|
||||
}
|
||||
|
||||
float atten123 = (float) settings->level123_cbdl;
|
||||
|
||||
if(atten123 > 50.f) {
|
||||
if (atten123 > 50.f) {
|
||||
atten123 = 50.f;
|
||||
}
|
||||
|
||||
if(atten123 < 0.f) {
|
||||
if (atten123 < 0.f) {
|
||||
atten123 = 0.f;
|
||||
}
|
||||
|
||||
float atten0 = (float) settings->level0_cbdl;
|
||||
|
||||
if(atten0 > 40.f) {
|
||||
if (atten0 > 40.f) {
|
||||
atten123 = 40.f;
|
||||
}
|
||||
|
||||
if(atten0 < 0.f) {
|
||||
if (atten0 < 0.f) {
|
||||
atten0 = 0.f;
|
||||
}
|
||||
|
||||
if((t_r - t_l) < 0.55f) {
|
||||
if ((t_r - t_l) < 0.55f) {
|
||||
t_l = t_r + 0.55f; //avoid too small range
|
||||
}
|
||||
|
||||
while (lastlevel > 0 && fabs(mult[lastlevel - 1] - 1) < 0.001) {
|
||||
while (lastlevel > 0 && fabs (mult[lastlevel - 1] - 1) < 0.001) {
|
||||
|
||||
lastlevel--;
|
||||
//printf("last level to process %d \n",lastlevel);
|
||||
@@ -307,17 +307,17 @@ SSEFUNCTION void ImProcFunctions :: cbdl_local_temp(float ** src, float ** dst,
|
||||
float multi[5] = {1.f, 1.f, 1.f, 1.f, 1.f};
|
||||
float scalefl[5];
|
||||
|
||||
for(int lv = 0; lv < 5; lv++) {
|
||||
for (int lv = 0; lv < 5; lv++) {
|
||||
scalefl[lv] = ((float) scalesloc[lv]) / (float) scaleprev;
|
||||
|
||||
if(lv >= 1) {
|
||||
if(scalefl[lv] < 1.f) {
|
||||
if (lv >= 1) {
|
||||
if (scalefl[lv] < 1.f) {
|
||||
multi[lv] = (atten123 * ((float) mult[lv] - 1.f) / 100.f) + 1.f; //modulate action if zoom < 100%
|
||||
} else {
|
||||
multi[lv] = (float) mult[lv];
|
||||
}
|
||||
} else {
|
||||
if(scalefl[lv] < 1.f) {
|
||||
if (scalefl[lv] < 1.f) {
|
||||
multi[lv] = (atten0 * ((float) mult[lv] - 1.f) / 100.f) + 1.f; //modulate action if zoom < 100%
|
||||
} else {
|
||||
multi[lv] = (float) mult[lv];
|
||||
@@ -326,8 +326,8 @@ SSEFUNCTION void ImProcFunctions :: cbdl_local_temp(float ** src, float ** dst,
|
||||
|
||||
}
|
||||
|
||||
if(settings->verbose) {
|
||||
printf("CbDL local mult0=%f 1=%f 2=%f 3=%f 4=%f\n", multi[0], multi[1], multi[2], multi[3], multi[4]);
|
||||
if (settings->verbose) {
|
||||
printf ("CbDL local mult0=%f 1=%f 2=%f 3=%f 4=%f\n", multi[0], multi[1], multi[2], multi[3], multi[4]);
|
||||
}
|
||||
|
||||
multi_array2D<float, maxlevelloc> dirpyrlo (srcwidth, srcheight);
|
||||
@@ -335,26 +335,26 @@ SSEFUNCTION void ImProcFunctions :: cbdl_local_temp(float ** src, float ** dst,
|
||||
level = 0;
|
||||
|
||||
//int thresh = 100 * mult[5];
|
||||
int scale = (int)(scalesloc[level]) / scaleprev;
|
||||
int scale = (int) (scalesloc[level]) / scaleprev;
|
||||
|
||||
if(scale < 1) {
|
||||
if (scale < 1) {
|
||||
scale = 1;
|
||||
}
|
||||
|
||||
|
||||
dirpyr_channel(src, dirpyrlo[0], srcwidth, srcheight, 0, scale);
|
||||
dirpyr_channel (src, dirpyrlo[0], srcwidth, srcheight, 0, scale);
|
||||
|
||||
level = 1;
|
||||
|
||||
while(level < lastlevel) {
|
||||
while (level < lastlevel) {
|
||||
|
||||
scale = (int)(scalesloc[level]) / scaleprev;
|
||||
scale = (int) (scalesloc[level]) / scaleprev;
|
||||
|
||||
if(scale < 1) {
|
||||
if (scale < 1) {
|
||||
scale = 1;
|
||||
}
|
||||
|
||||
dirpyr_channel(dirpyrlo[level - 1], dirpyrlo[level], srcwidth, srcheight, level, scale);
|
||||
dirpyr_channel (dirpyrlo[level - 1], dirpyrlo[level], srcwidth, srcheight, level, scale);
|
||||
|
||||
level ++;
|
||||
}
|
||||
@@ -363,20 +363,20 @@ SSEFUNCTION void ImProcFunctions :: cbdl_local_temp(float ** src, float ** dst,
|
||||
// with the current implementation of idirpyr_eq_channel we can safely use the buffer from last level as buffer, saves some memory
|
||||
float ** buffer = dirpyrlo[lastlevel - 1];
|
||||
|
||||
for(int level = lastlevel - 1; level > 0; level--) {
|
||||
idirpyr_eq_channel_loc(dirpyrlo[level], dirpyrlo[level - 1], loctemp, buffer, srcwidth, srcheight, level, multi, dirpyrThreshold, tmpHue, tmpChr, skinprot, gamutlab, b_l, t_l, t_r, b_r, choice );
|
||||
for (int level = lastlevel - 1; level > 0; level--) {
|
||||
idirpyr_eq_channel_loc (dirpyrlo[level], dirpyrlo[level - 1], loctemp, buffer, srcwidth, srcheight, level, multi, dirpyrThreshold, tmpHue, tmpChr, skinprot, gamutlab, b_l, t_l, t_r, b_r, choice );
|
||||
}
|
||||
|
||||
scale = scalesloc[0];
|
||||
|
||||
idirpyr_eq_channel_loc(dirpyrlo[0], dst, loctemp, buffer, srcwidth, srcheight, 0, multi, dirpyrThreshold, tmpHue, tmpChr, skinprot, gamutlab, b_l, t_l, t_r, b_r, choice );
|
||||
idirpyr_eq_channel_loc (dirpyrlo[0], dst, loctemp, buffer, srcwidth, srcheight, 0, multi, dirpyrThreshold, tmpHue, tmpChr, skinprot, gamutlab, b_l, t_l, t_r, b_r, choice );
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
#pragma omp parallel for
|
||||
|
||||
for (int i = 0; i < srcheight; i++)
|
||||
for (int j = 0; j < srcwidth; j++) {
|
||||
dst[i][j] = src[i][j];
|
||||
loctemp[i][j] = CLIP(buffer[i][j]); // TODO: Really a clip necessary?
|
||||
loctemp[i][j] = CLIP (buffer[i][j]); // TODO: Really a clip necessary?
|
||||
}
|
||||
|
||||
}
|
||||
@@ -386,36 +386,36 @@ void ImProcFunctions :: dirpyr_equalizercam (CieImage *ncie, float ** src, float
|
||||
{
|
||||
int lastlevel = maxlevel;
|
||||
|
||||
if(settings->verbose) {
|
||||
printf("CAM dirpyr scaleprev=%i\n", scaleprev);
|
||||
if (settings->verbose) {
|
||||
printf ("CAM dirpyr scaleprev=%i\n", scaleprev);
|
||||
}
|
||||
|
||||
float atten123 = (float) settings->level123_cbdl;
|
||||
|
||||
if(atten123 > 50.f) {
|
||||
if (atten123 > 50.f) {
|
||||
atten123 = 50.f;
|
||||
}
|
||||
|
||||
if(atten123 < 0.f) {
|
||||
if (atten123 < 0.f) {
|
||||
atten123 = 0.f;
|
||||
}
|
||||
|
||||
// printf("atten=%f\n",atten);
|
||||
float atten0 = (float) settings->level0_cbdl;
|
||||
|
||||
if(atten0 > 40.f) {
|
||||
if (atten0 > 40.f) {
|
||||
atten123 = 40.f;
|
||||
}
|
||||
|
||||
if(atten0 < 0.f) {
|
||||
if (atten0 < 0.f) {
|
||||
atten0 = 0.f;
|
||||
}
|
||||
|
||||
if((t_r - t_l) < 0.55f) {
|
||||
if ((t_r - t_l) < 0.55f) {
|
||||
t_l = t_r + 0.55f; //avoid too small range
|
||||
}
|
||||
|
||||
while (fabs(mult[lastlevel - 1] - 1) < 0.001 && lastlevel > 0) {
|
||||
while (fabs (mult[lastlevel - 1] - 1) < 0.001 && lastlevel > 0) {
|
||||
lastlevel--;
|
||||
//printf("last level to process %d \n",lastlevel);
|
||||
}
|
||||
@@ -429,18 +429,18 @@ void ImProcFunctions :: dirpyr_equalizercam (CieImage *ncie, float ** src, float
|
||||
float multi[6] = {1.f, 1.f, 1.f, 1.f, 1.f, 1.f};
|
||||
float scalefl[6];
|
||||
|
||||
for(int lv = 0; lv < 6; lv++) {
|
||||
for (int lv = 0; lv < 6; lv++) {
|
||||
scalefl[lv] = ((float) scales[lv]) / (float) scaleprev;
|
||||
|
||||
// if(scalefl[lv] < 1.f) multi[lv] = 1.f; else multi[lv]=(float) mult[lv];
|
||||
if (lv >= 1) {
|
||||
if(scalefl[lv] < 1.f) {
|
||||
if (scalefl[lv] < 1.f) {
|
||||
multi[lv] = (atten123 * ((float) mult[lv] - 1.f) / 100.f) + 1.f;
|
||||
} else {
|
||||
multi[lv] = (float) mult[lv];
|
||||
}
|
||||
} else {
|
||||
if(scalefl[lv] < 1.f) {
|
||||
if (scalefl[lv] < 1.f) {
|
||||
multi[lv] = (atten0 * ((float) mult[lv] - 1.f) / 100.f) + 1.f;
|
||||
} else {
|
||||
multi[lv] = (float) mult[lv];
|
||||
@@ -450,8 +450,8 @@ void ImProcFunctions :: dirpyr_equalizercam (CieImage *ncie, float ** src, float
|
||||
|
||||
}
|
||||
|
||||
if(settings->verbose) {
|
||||
printf("CAM CbDL mult0=%f 1=%f 2=%f 3=%f 4=%f 5=%f\n", multi[0], multi[1], multi[2], multi[3], multi[4], multi[5]);
|
||||
if (settings->verbose) {
|
||||
printf ("CAM CbDL mult0=%f 1=%f 2=%f 3=%f 4=%f 5=%f\n", multi[0], multi[1], multi[2], multi[3], multi[4], multi[5]);
|
||||
}
|
||||
|
||||
|
||||
@@ -461,24 +461,24 @@ void ImProcFunctions :: dirpyr_equalizercam (CieImage *ncie, float ** src, float
|
||||
|
||||
level = 0;
|
||||
|
||||
int scale = (int)(scales[level]) / scaleprev;
|
||||
int scale = (int) (scales[level]) / scaleprev;
|
||||
|
||||
if(scale < 1) {
|
||||
if (scale < 1) {
|
||||
scale = 1;
|
||||
}
|
||||
|
||||
dirpyr_channel(src, dirpyrlo[0], srcwidth, srcheight, 0, scale);
|
||||
dirpyr_channel (src, dirpyrlo[0], srcwidth, srcheight, 0, scale);
|
||||
|
||||
level = 1;
|
||||
|
||||
while(level < lastlevel) {
|
||||
scale = (int)(scales[level]) / scaleprev;
|
||||
while (level < lastlevel) {
|
||||
scale = (int) (scales[level]) / scaleprev;
|
||||
|
||||
if(scale < 1) {
|
||||
if (scale < 1) {
|
||||
scale = 1;
|
||||
}
|
||||
|
||||
dirpyr_channel(dirpyrlo[level - 1], dirpyrlo[level], srcwidth, srcheight, level, scale);
|
||||
dirpyr_channel (dirpyrlo[level - 1], dirpyrlo[level], srcwidth, srcheight, level, scale);
|
||||
|
||||
level ++;
|
||||
}
|
||||
@@ -487,26 +487,26 @@ void ImProcFunctions :: dirpyr_equalizercam (CieImage *ncie, float ** src, float
|
||||
// with the current implementation of idirpyr_eq_channel we can safely use the buffer from last level as buffer, saves some memory
|
||||
float ** buffer = dirpyrlo[lastlevel - 1];
|
||||
|
||||
for(int level = lastlevel - 1; level > 0; level--) {
|
||||
idirpyr_eq_channelcam(dirpyrlo[level], dirpyrlo[level - 1], buffer, srcwidth, srcheight, level, multi, dirpyrThreshold , h_p, C_p, skinprot, b_l, t_l, t_r);
|
||||
for (int level = lastlevel - 1; level > 0; level--) {
|
||||
idirpyr_eq_channelcam (dirpyrlo[level], dirpyrlo[level - 1], buffer, srcwidth, srcheight, level, multi, dirpyrThreshold , h_p, C_p, skinprot, b_l, t_l, t_r);
|
||||
}
|
||||
|
||||
|
||||
scale = scales[0];
|
||||
|
||||
idirpyr_eq_channelcam(dirpyrlo[0], dst, buffer, srcwidth, srcheight, 0, multi, dirpyrThreshold, h_p, C_p, skinprot, b_l, t_l, t_r);
|
||||
idirpyr_eq_channelcam (dirpyrlo[0], dst, buffer, srcwidth, srcheight, 0, multi, dirpyrThreshold, h_p, C_p, skinprot, b_l, t_l, t_r);
|
||||
|
||||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
if(execdir) {
|
||||
if (execdir) {
|
||||
#ifdef _OPENMP
|
||||
#pragma omp parallel for schedule(dynamic,16)
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < srcheight; i++)
|
||||
for (int j = 0; j < srcwidth; j++) {
|
||||
if(ncie->J_p[i][j] > 8.f && ncie->J_p[i][j] < 92.f) {
|
||||
dst[i][j] = CLIP( buffer[i][j] ); // TODO: Really a clip necessary?
|
||||
if (ncie->J_p[i][j] > 8.f && ncie->J_p[i][j] < 92.f) {
|
||||
dst[i][j] = CLIP ( buffer[i][j] ); // TODO: Really a clip necessary?
|
||||
} else {
|
||||
dst[i][j] = src[i][j];
|
||||
}
|
||||
@@ -514,20 +514,20 @@ void ImProcFunctions :: dirpyr_equalizercam (CieImage *ncie, float ** src, float
|
||||
} else
|
||||
for (int i = 0; i < srcheight; i++)
|
||||
for (int j = 0; j < srcwidth; j++) {
|
||||
dst[i][j] = CLIP( buffer[i][j] ); // TODO: Really a clip necessary?
|
||||
dst[i][j] = CLIP ( buffer[i][j] ); // TODO: Really a clip necessary?
|
||||
}
|
||||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
}
|
||||
|
||||
|
||||
SSEFUNCTION void ImProcFunctions::dirpyr_channel(float ** data_fine, float ** data_coarse, int width, int height, int level, int scale)
|
||||
SSEFUNCTION void ImProcFunctions::dirpyr_channel (float ** data_fine, float ** data_coarse, int width, int height, int level, int scale)
|
||||
{
|
||||
//scale is spacing of directional averaging weights
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
// calculate weights, compute directionally weighted average
|
||||
|
||||
if(level > 1) {
|
||||
if (level > 1) {
|
||||
//generate domain kernel
|
||||
int domker[5][5] = {{1, 1, 1, 1, 1}, {1, 2, 2, 2, 1}, {1, 2, 2, 2, 1}, {1, 2, 2, 2, 1}, {1, 1, 1, 1, 1}};
|
||||
// int domker[5][5] = {{1,1,1,1,1},{1,1,1,1,1},{1,1,1,1,1},{1,1,1,1,1},{1,1,1,1,1}};
|
||||
@@ -538,7 +538,7 @@ SSEFUNCTION void ImProcFunctions::dirpyr_channel(float ** data_fine, float ** da
|
||||
#endif
|
||||
{
|
||||
#ifdef __SSE2__
|
||||
__m128 thousandv = _mm_set1_ps( 1000.0f );
|
||||
__m128 thousandv = _mm_set1_ps ( 1000.0f );
|
||||
__m128 dirwtv, valv, normv, dftemp1v, dftemp2v;
|
||||
// multiplied each value of domkerv by 1000 to avoid multiplication by 1000 inside the loop
|
||||
float domkerv[5][5][4] ALIGNED16 = {{{1000, 1000, 1000, 1000}, {1000, 1000, 1000, 1000}, {1000, 1000, 1000, 1000}, {1000, 1000, 1000, 1000}, {1000, 1000, 1000, 1000}}, {{1000, 1000, 1000, 1000}, {2000, 2000, 2000, 2000}, {2000, 2000, 2000, 2000}, {2000, 2000, 2000, 2000}, {1000, 1000, 1000, 1000}}, {{1000, 1000, 1000, 1000}, {2000, 2000, 2000, 2000}, {2000, 2000, 2000, 2000}, {2000, 2000, 2000, 2000}, {1000, 1000, 1000, 1000}}, {{1000, 1000, 1000, 1000}, {2000, 2000, 2000, 2000}, {2000, 2000, 2000, 2000}, {2000, 2000, 2000, 2000}, {1000, 1000, 1000, 1000}}, {{1000, 1000, 1000, 1000}, {1000, 1000, 1000, 1000}, {1000, 1000, 1000, 1000}, {1000, 1000, 1000, 1000}, {1000, 1000, 1000, 1000}}};
|
||||
@@ -549,18 +549,18 @@ SSEFUNCTION void ImProcFunctions::dirpyr_channel(float ** data_fine, float ** da
|
||||
#pragma omp for //schedule (dynamic,8)
|
||||
#endif
|
||||
|
||||
for(int i = 0; i < height; i++) {
|
||||
for (int i = 0; i < height; i++) {
|
||||
float dirwt;
|
||||
|
||||
for(j = 0; j < scalewin; j++) {
|
||||
for (j = 0; j < scalewin; j++) {
|
||||
float val = 0.f;
|
||||
float norm = 0.f;
|
||||
|
||||
|
||||
for(int inbr = max(0, i - scalewin); inbr <= min(height - 1, i + scalewin); inbr += scale) {
|
||||
for (int jnbr = max(0, j - scalewin); jnbr <= j + scalewin; jnbr += scale) {
|
||||
for (int inbr = max (0, i - scalewin); inbr <= min (height - 1, i + scalewin); inbr += scale) {
|
||||
for (int jnbr = max (0, j - scalewin); jnbr <= j + scalewin; jnbr += scale) {
|
||||
//printf("i=%d ",(inbr-i)/scale+halfwin);
|
||||
dirwt = DIRWT(inbr, jnbr, i, j);
|
||||
dirwt = DIRWT (inbr, jnbr, i, j);
|
||||
val += dirwt * data_fine[inbr][jnbr];
|
||||
norm += dirwt;
|
||||
}
|
||||
@@ -571,32 +571,32 @@ SSEFUNCTION void ImProcFunctions::dirpyr_channel(float ** data_fine, float ** da
|
||||
|
||||
#ifdef __SSE2__
|
||||
|
||||
for(; j < width - scalewin - 3; j += 4) {
|
||||
for (; j < width - scalewin - 3; j += 4) {
|
||||
valv = _mm_setzero_ps();
|
||||
normv = _mm_setzero_ps();
|
||||
dftemp1v = LVFU(data_fine[i][j]);
|
||||
dftemp1v = LVFU (data_fine[i][j]);
|
||||
|
||||
for(int inbr = MAX(0, i - scalewin); inbr <= MIN(height - 1, i + scalewin); inbr += scale) {
|
||||
for (int inbr = MAX (0, i - scalewin); inbr <= MIN (height - 1, i + scalewin); inbr += scale) {
|
||||
int indexihlp = (inbr - i) / scale + halfwin;
|
||||
|
||||
for (int jnbr = j - scalewin, indexjhlp = 0; jnbr <= j + scalewin; jnbr += scale, indexjhlp++) {
|
||||
dftemp2v = LVFU(data_fine[inbr][jnbr]);
|
||||
dirwtv = LVF(domkerv[indexihlp][indexjhlp]) / (vabsf(dftemp1v - dftemp2v) + thousandv);
|
||||
dftemp2v = LVFU (data_fine[inbr][jnbr]);
|
||||
dirwtv = LVF (domkerv[indexihlp][indexjhlp]) / (vabsf (dftemp1v - dftemp2v) + thousandv);
|
||||
valv += dirwtv * dftemp2v;
|
||||
normv += dirwtv;
|
||||
}
|
||||
}
|
||||
|
||||
_mm_storeu_ps( &data_coarse[i][j], valv / normv); //low pass filter
|
||||
_mm_storeu_ps ( &data_coarse[i][j], valv / normv); //low pass filter
|
||||
}
|
||||
|
||||
for(; j < width - scalewin; j++) {
|
||||
for (; j < width - scalewin; j++) {
|
||||
float val = 0.f;
|
||||
float norm = 0.f;
|
||||
|
||||
for(int inbr = max(0, i - scalewin); inbr <= min(height - 1, i + scalewin); inbr += scale) {
|
||||
for (int inbr = max (0, i - scalewin); inbr <= min (height - 1, i + scalewin); inbr += scale) {
|
||||
for (int jnbr = j - scalewin; jnbr <= j + scalewin; jnbr += scale) {
|
||||
dirwt = DIRWT(inbr, jnbr, i, j);
|
||||
dirwt = DIRWT (inbr, jnbr, i, j);
|
||||
val += dirwt * data_fine[inbr][jnbr];
|
||||
norm += dirwt;
|
||||
}
|
||||
@@ -607,13 +607,13 @@ SSEFUNCTION void ImProcFunctions::dirpyr_channel(float ** data_fine, float ** da
|
||||
|
||||
#else
|
||||
|
||||
for(; j < width - scalewin; j++) {
|
||||
for (; j < width - scalewin; j++) {
|
||||
float val = 0.f;
|
||||
float norm = 0.f;
|
||||
|
||||
for(int inbr = max(0, i - scalewin); inbr <= min(height - 1, i + scalewin); inbr += scale) {
|
||||
for (int inbr = max (0, i - scalewin); inbr <= min (height - 1, i + scalewin); inbr += scale) {
|
||||
for (int jnbr = j - scalewin; jnbr <= j + scalewin; jnbr += scale) {
|
||||
dirwt = DIRWT(inbr, jnbr, i, j);
|
||||
dirwt = DIRWT (inbr, jnbr, i, j);
|
||||
val += dirwt * data_fine[inbr][jnbr];
|
||||
norm += dirwt;
|
||||
}
|
||||
@@ -624,13 +624,13 @@ SSEFUNCTION void ImProcFunctions::dirpyr_channel(float ** data_fine, float ** da
|
||||
|
||||
#endif
|
||||
|
||||
for(; j < width; j++) {
|
||||
for (; j < width; j++) {
|
||||
float val = 0.f;
|
||||
float norm = 0.f;
|
||||
|
||||
for(int inbr = max(0, i - scalewin); inbr <= min(height - 1, i + scalewin); inbr += scale) {
|
||||
for (int jnbr = j - scalewin; jnbr <= min(width - 1, j + scalewin); jnbr += scale) {
|
||||
dirwt = DIRWT(inbr, jnbr, i, j);
|
||||
for (int inbr = max (0, i - scalewin); inbr <= min (height - 1, i + scalewin); inbr += scale) {
|
||||
for (int jnbr = j - scalewin; jnbr <= min (width - 1, j + scalewin); jnbr += scale) {
|
||||
dirwt = DIRWT (inbr, jnbr, i, j);
|
||||
val += dirwt * data_fine[inbr][jnbr];
|
||||
norm += dirwt;
|
||||
}
|
||||
@@ -647,7 +647,7 @@ SSEFUNCTION void ImProcFunctions::dirpyr_channel(float ** data_fine, float ** da
|
||||
#endif
|
||||
{
|
||||
#ifdef __SSE2__
|
||||
__m128 thousandv = _mm_set1_ps( 1000.0f );
|
||||
__m128 thousandv = _mm_set1_ps ( 1000.0f );
|
||||
__m128 dirwtv, valv, normv, dftemp1v, dftemp2v;
|
||||
#endif // __SSE2__
|
||||
int j;
|
||||
@@ -655,17 +655,17 @@ SSEFUNCTION void ImProcFunctions::dirpyr_channel(float ** data_fine, float ** da
|
||||
#pragma omp for schedule(dynamic,16)
|
||||
#endif
|
||||
|
||||
for(int i = 0; i < height; i++)
|
||||
for (int i = 0; i < height; i++)
|
||||
{
|
||||
float dirwt;
|
||||
|
||||
for(j = 0; j < scale; j++) {
|
||||
for (j = 0; j < scale; j++) {
|
||||
float val = 0.f;
|
||||
float norm = 0.f;
|
||||
|
||||
for(int inbr = max(0, i - scale); inbr <= min(height - 1, i + scale); inbr += scale) {
|
||||
for (int jnbr = max(0, j - scale); jnbr <= j + scale; jnbr += scale) {
|
||||
dirwt = RANGEFN(fabsf(data_fine[inbr][jnbr] - data_fine[i][j]));
|
||||
for (int inbr = max (0, i - scale); inbr <= min (height - 1, i + scale); inbr += scale) {
|
||||
for (int jnbr = max (0, j - scale); jnbr <= j + scale; jnbr += scale) {
|
||||
dirwt = RANGEFN (fabsf (data_fine[inbr][jnbr] - data_fine[i][j]));
|
||||
val += dirwt * data_fine[inbr][jnbr];
|
||||
norm += dirwt;
|
||||
}
|
||||
@@ -676,30 +676,30 @@ SSEFUNCTION void ImProcFunctions::dirpyr_channel(float ** data_fine, float ** da
|
||||
|
||||
#ifdef __SSE2__
|
||||
|
||||
for(; j < width - scale - 3; j += 4) {
|
||||
for (; j < width - scale - 3; j += 4) {
|
||||
valv = _mm_setzero_ps();
|
||||
normv = _mm_setzero_ps();
|
||||
dftemp1v = LVFU(data_fine[i][j]);
|
||||
dftemp1v = LVFU (data_fine[i][j]);
|
||||
|
||||
for(int inbr = MAX(0, i - scale); inbr <= MIN(height - 1, i + scale); inbr += scale) {
|
||||
for (int inbr = MAX (0, i - scale); inbr <= MIN (height - 1, i + scale); inbr += scale) {
|
||||
for (int jnbr = j - scale; jnbr <= j + scale; jnbr += scale) {
|
||||
dftemp2v = LVFU(data_fine[inbr][jnbr]);
|
||||
dirwtv = thousandv / (vabsf(dftemp2v - dftemp1v) + thousandv);
|
||||
dftemp2v = LVFU (data_fine[inbr][jnbr]);
|
||||
dirwtv = thousandv / (vabsf (dftemp2v - dftemp1v) + thousandv);
|
||||
valv += dirwtv * dftemp2v;
|
||||
normv += dirwtv;
|
||||
}
|
||||
}
|
||||
|
||||
_mm_storeu_ps( &data_coarse[i][j], valv / normv); //low pass filter
|
||||
_mm_storeu_ps ( &data_coarse[i][j], valv / normv); //low pass filter
|
||||
}
|
||||
|
||||
for(; j < width - scale; j++) {
|
||||
for (; j < width - scale; j++) {
|
||||
float val = 0.f;
|
||||
float norm = 0.f;
|
||||
|
||||
for(int inbr = max(0, i - scale); inbr <= min(height - 1, i + scale); inbr += scale) {
|
||||
for (int inbr = max (0, i - scale); inbr <= min (height - 1, i + scale); inbr += scale) {
|
||||
for (int jnbr = j - scale; jnbr <= j + scale; jnbr += scale) {
|
||||
dirwt = RANGEFN(fabsf(data_fine[inbr][jnbr] - data_fine[i][j]));
|
||||
dirwt = RANGEFN (fabsf (data_fine[inbr][jnbr] - data_fine[i][j]));
|
||||
val += dirwt * data_fine[inbr][jnbr];
|
||||
norm += dirwt;
|
||||
}
|
||||
@@ -710,13 +710,13 @@ SSEFUNCTION void ImProcFunctions::dirpyr_channel(float ** data_fine, float ** da
|
||||
|
||||
#else
|
||||
|
||||
for(; j < width - scale; j++) {
|
||||
for (; j < width - scale; j++) {
|
||||
float val = 0.f;
|
||||
float norm = 0.f;
|
||||
|
||||
for(int inbr = max(0, i - scale); inbr <= min(height - 1, i + scale); inbr += scale) {
|
||||
for (int inbr = max (0, i - scale); inbr <= min (height - 1, i + scale); inbr += scale) {
|
||||
for (int jnbr = j - scale; jnbr <= j + scale; jnbr += scale) {
|
||||
dirwt = RANGEFN(fabsf(data_fine[inbr][jnbr] - data_fine[i][j]));
|
||||
dirwt = RANGEFN (fabsf (data_fine[inbr][jnbr] - data_fine[i][j]));
|
||||
val += dirwt * data_fine[inbr][jnbr];
|
||||
norm += dirwt;
|
||||
}
|
||||
@@ -727,13 +727,13 @@ SSEFUNCTION void ImProcFunctions::dirpyr_channel(float ** data_fine, float ** da
|
||||
|
||||
#endif
|
||||
|
||||
for(; j < width; j++) {
|
||||
for (; j < width; j++) {
|
||||
float val = 0.f;
|
||||
float norm = 0.f;
|
||||
|
||||
for(int inbr = max(0, i - scale); inbr <= min(height - 1, i + scale); inbr += scale) {
|
||||
for (int jnbr = j - scale; jnbr <= min(width - 1, j + scale); jnbr += scale) {
|
||||
dirwt = RANGEFN(fabsf(data_fine[inbr][jnbr] - data_fine[i][j]));
|
||||
for (int inbr = max (0, i - scale); inbr <= min (height - 1, i + scale); inbr += scale) {
|
||||
for (int jnbr = j - scale; jnbr <= min (width - 1, j + scale); jnbr += scale) {
|
||||
dirwt = RANGEFN (fabsf (data_fine[inbr][jnbr] - data_fine[i][j]));
|
||||
val += dirwt * data_fine[inbr][jnbr];
|
||||
norm += dirwt;
|
||||
}
|
||||
@@ -747,14 +747,14 @@ SSEFUNCTION void ImProcFunctions::dirpyr_channel(float ** data_fine, float ** da
|
||||
}
|
||||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
void ImProcFunctions::idirpyr_eq_channel_loc(float ** data_coarse, float ** data_fine, float ** loctemp, float ** buffer, int width, int height, int level, float mult[5], const double dirpyrThreshold, float ** hue, float ** chrom, const double skinprot, const bool gamutlab, float b_l, float t_l, float t_r, float b_r , int choice)
|
||||
void ImProcFunctions::idirpyr_eq_channel_loc (float ** data_coarse, float ** data_fine, float ** loctemp, float ** buffer, int width, int height, int level, float mult[5], const double dirpyrThreshold, float ** hue, float ** chrom, const double skinprot, const bool gamutlab, float b_l, float t_l, float t_r, float b_r , int choice)
|
||||
{
|
||||
const float skinprotneg = -skinprot;
|
||||
const float factorHard = (1.f - skinprotneg / 100.f);
|
||||
// const float skinprotneg = -skinprot;
|
||||
// const float factorHard = (1.f - skinprotneg / 100.f);
|
||||
|
||||
float offs;
|
||||
|
||||
if(skinprot == 0.f) {
|
||||
if (skinprot == 0.f) {
|
||||
offs = 0.f;
|
||||
} else {
|
||||
offs = -1.f;
|
||||
@@ -764,7 +764,7 @@ void ImProcFunctions::idirpyr_eq_channel_loc(float ** data_coarse, float ** data
|
||||
|
||||
multbis[level] = mult[level]; //multbis to reduce artifacts for high values mult
|
||||
|
||||
if(level == 4 && mult[level] > 1.f) {
|
||||
if (level == 4 && mult[level] > 1.f) {
|
||||
multbis[level] = 1.f + 0.65f * (mult[level] - 1.f);
|
||||
}
|
||||
|
||||
@@ -774,28 +774,28 @@ void ImProcFunctions::idirpyr_eq_channel_loc(float ** data_coarse, float ** data
|
||||
|
||||
LUTf irangefn (0x20000);
|
||||
{
|
||||
const float noisehi = 1.33f * noise * dirpyrThreshold / expf(level * log(3.0)), noiselo = 0.66f * noise * dirpyrThreshold / expf(level * log(3.0));
|
||||
const float noisehi = 1.33f * noise * dirpyrThreshold / expf (level * log (3.0)), noiselo = 0.66f * noise * dirpyrThreshold / expf (level * log (3.0));
|
||||
//printf("level=%i multlev=%f noisehi=%f noiselo=%f skinprot=%f\n",level,mult[level], noisehi, noiselo, skinprot);
|
||||
|
||||
for (int i = 0; i < 0x20000; i++) {
|
||||
if (abs(i - 0x10000) > noisehi || multbis[level] < 1.0) {
|
||||
if (abs (i - 0x10000) > noisehi || multbis[level] < 1.0) {
|
||||
irangefn[i] = multbis[level] + offs;
|
||||
} else {
|
||||
if (abs(i - 0x10000) < noiselo) {
|
||||
if (abs (i - 0x10000) < noiselo) {
|
||||
irangefn[i] = 1.f + offs ;
|
||||
} else {
|
||||
irangefn[i] = 1.f + offs + (multbis[level] - 1.f) * (noisehi - abs(i - 0x10000)) / (noisehi - noiselo + 0.01f) ;
|
||||
irangefn[i] = 1.f + offs + (multbis[level] - 1.f) * (noisehi - abs (i - 0x10000)) / (noisehi - noiselo + 0.01f) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(skinprot == 0.f)
|
||||
if (skinprot == 0.f)
|
||||
#ifdef _OPENMP
|
||||
#pragma omp parallel for schedule(dynamic,16)
|
||||
#endif
|
||||
for(int i = 0; i < height; i++) {
|
||||
for(int j = 0; j < width; j++) {
|
||||
for (int i = 0; i < height; i++) {
|
||||
for (int j = 0; j < width; j++) {
|
||||
float hipass = (data_fine[i][j] - data_coarse[i][j]);
|
||||
buffer[i][j] += irangefn[hipass + 0x10000] * hipass;
|
||||
}
|
||||
@@ -844,14 +844,14 @@ void ImProcFunctions::idirpyr_eq_channel_loc(float ** data_coarse, float ** data
|
||||
|
||||
|
||||
|
||||
void ImProcFunctions::idirpyr_eq_channel(float ** data_coarse, float ** data_fine, float ** buffer, int width, int height, int level, float mult[5], const double dirpyrThreshold, float ** hue, float ** chrom, const double skinprot, const bool gamutlab, float b_l, float t_l, float t_r, float b_r , int choice)
|
||||
void ImProcFunctions::idirpyr_eq_channel (float ** data_coarse, float ** data_fine, float ** buffer, int width, int height, int level, float mult[5], const double dirpyrThreshold, float ** hue, float ** chrom, const double skinprot, const bool gamutlab, float b_l, float t_l, float t_r, float b_r , int choice)
|
||||
{
|
||||
const float skinprotneg = -skinprot;
|
||||
const float factorHard = (1.f - skinprotneg / 100.f);
|
||||
|
||||
float offs;
|
||||
|
||||
if(skinprot == 0.f) {
|
||||
if (skinprot == 0.f) {
|
||||
offs = 0.f;
|
||||
} else {
|
||||
offs = -1.f;
|
||||
@@ -861,48 +861,48 @@ void ImProcFunctions::idirpyr_eq_channel(float ** data_coarse, float ** data_fin
|
||||
|
||||
multbis[level] = mult[level]; //multbis to reduce artifacts for high values mult
|
||||
|
||||
if(level == 4 && mult[level] > 1.f) {
|
||||
if (level == 4 && mult[level] > 1.f) {
|
||||
multbis[level] = 1.f + 0.65f * (mult[level] - 1.f);
|
||||
}
|
||||
|
||||
if(level == 5 && mult[level] > 1.f) {
|
||||
if (level == 5 && mult[level] > 1.f) {
|
||||
multbis[level] = 1.f + 0.45f * (mult[level] - 1.f);
|
||||
}
|
||||
|
||||
LUTf irangefn (0x20000);
|
||||
{
|
||||
const float noisehi = 1.33f * noise * dirpyrThreshold / expf(level * log(3.0)), noiselo = 0.66f * noise * dirpyrThreshold / expf(level * log(3.0));
|
||||
const float noisehi = 1.33f * noise * dirpyrThreshold / expf (level * log (3.0)), noiselo = 0.66f * noise * dirpyrThreshold / expf (level * log (3.0));
|
||||
//printf("level=%i multlev=%f noisehi=%f noiselo=%f skinprot=%f\n",level,mult[level], noisehi, noiselo, skinprot);
|
||||
|
||||
for (int i = 0; i < 0x20000; i++) {
|
||||
if (abs(i - 0x10000) > noisehi || multbis[level] < 1.0) {
|
||||
if (abs (i - 0x10000) > noisehi || multbis[level] < 1.0) {
|
||||
irangefn[i] = multbis[level] + offs;
|
||||
} else {
|
||||
if (abs(i - 0x10000) < noiselo) {
|
||||
if (abs (i - 0x10000) < noiselo) {
|
||||
irangefn[i] = 1.f + offs ;
|
||||
} else {
|
||||
irangefn[i] = 1.f + offs + (multbis[level] - 1.f) * (noisehi - abs(i - 0x10000)) / (noisehi - noiselo + 0.01f) ;
|
||||
irangefn[i] = 1.f + offs + (multbis[level] - 1.f) * (noisehi - abs (i - 0x10000)) / (noisehi - noiselo + 0.01f) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(skinprot == 0.f)
|
||||
if (skinprot == 0.f)
|
||||
#ifdef _OPENMP
|
||||
#pragma omp parallel for schedule(dynamic,16)
|
||||
#endif
|
||||
for(int i = 0; i < height; i++) {
|
||||
for(int j = 0; j < width; j++) {
|
||||
for (int i = 0; i < height; i++) {
|
||||
for (int j = 0; j < width; j++) {
|
||||
float hipass = (data_fine[i][j] - data_coarse[i][j]);
|
||||
buffer[i][j] += irangefn[hipass + 0x10000] * hipass;
|
||||
}
|
||||
}
|
||||
else if(skinprot > 0.f)
|
||||
else if (skinprot > 0.f)
|
||||
#ifdef _OPENMP
|
||||
#pragma omp parallel for schedule(dynamic,16)
|
||||
#endif
|
||||
for(int i = 0; i < height; i++) {
|
||||
for(int j = 0; j < width; j++) {
|
||||
for (int i = 0; i < height; i++) {
|
||||
for (int j = 0; j < width; j++) {
|
||||
float scale = 1.f;
|
||||
float hipass = (data_fine[i][j] - data_coarse[i][j]);
|
||||
// These values are precalculated now
|
||||
@@ -916,8 +916,8 @@ void ImProcFunctions::idirpyr_eq_channel(float ** data_coarse, float ** data_fin
|
||||
#ifdef _OPENMP
|
||||
#pragma omp parallel for schedule(dynamic,16)
|
||||
#endif
|
||||
for(int i = 0; i < height; i++) {
|
||||
for(int j = 0; j < width; j++) {
|
||||
for (int i = 0; i < height; i++) {
|
||||
for (int j = 0; j < width; j++) {
|
||||
float scale = 1.f;
|
||||
float hipass = (data_fine[i][j] - data_coarse[i][j]);
|
||||
// These values are precalculated now
|
||||
@@ -936,7 +936,7 @@ void ImProcFunctions::idirpyr_eq_channel(float ** data_coarse, float ** data_fin
|
||||
}
|
||||
|
||||
|
||||
void ImProcFunctions::idirpyr_eq_channelcam(float ** data_coarse, float ** data_fine, float ** buffer, int width, int height, int level, float mult[5], const double dirpyrThreshold, float ** l_a_h, float ** l_b_c, const double skinprot, float b_l, float t_l, float t_r)
|
||||
void ImProcFunctions::idirpyr_eq_channelcam (float ** data_coarse, float ** data_fine, float ** buffer, int width, int height, int level, float mult[5], const double dirpyrThreshold, float ** l_a_h, float ** l_b_c, const double skinprot, float b_l, float t_l, float t_r)
|
||||
{
|
||||
|
||||
const float skinprotneg = -skinprot;
|
||||
@@ -944,7 +944,7 @@ void ImProcFunctions::idirpyr_eq_channelcam(float ** data_coarse, float ** data_
|
||||
|
||||
float offs;
|
||||
|
||||
if(skinprot == 0.f) {
|
||||
if (skinprot == 0.f) {
|
||||
offs = 0.f;
|
||||
} else {
|
||||
offs = -1.f;
|
||||
@@ -954,48 +954,48 @@ void ImProcFunctions::idirpyr_eq_channelcam(float ** data_coarse, float ** data_
|
||||
|
||||
multbis[level] = mult[level]; //multbis to reduce artifacts for high values mult
|
||||
|
||||
if(level == 4 && mult[level] > 1.f) {
|
||||
if (level == 4 && mult[level] > 1.f) {
|
||||
multbis[level] = 1.f + 0.65f * (mult[level] - 1.f);
|
||||
}
|
||||
|
||||
if(level == 5 && mult[level] > 1.f) {
|
||||
if (level == 5 && mult[level] > 1.f) {
|
||||
multbis[level] = 1.f + 0.45f * (mult[level] - 1.f);
|
||||
}
|
||||
|
||||
LUTf irangefn (0x20000);
|
||||
{
|
||||
const float noisehi = 1.33f * noise * dirpyrThreshold / expf(level * log(3.0)), noiselo = 0.66f * noise * dirpyrThreshold / expf(level * log(3.0));
|
||||
const float noisehi = 1.33f * noise * dirpyrThreshold / expf (level * log (3.0)), noiselo = 0.66f * noise * dirpyrThreshold / expf (level * log (3.0));
|
||||
|
||||
//printf("level=%i multlev=%f noisehi=%f noiselo=%f skinprot=%f\n",level,mult[level], noisehi, noiselo, skinprot);
|
||||
for (int i = 0; i < 0x20000; i++) {
|
||||
if (abs(i - 0x10000) > noisehi || multbis[level] < 1.0) {
|
||||
if (abs (i - 0x10000) > noisehi || multbis[level] < 1.0) {
|
||||
irangefn[i] = multbis[level] + offs;
|
||||
} else {
|
||||
if (abs(i - 0x10000) < noiselo) {
|
||||
if (abs (i - 0x10000) < noiselo) {
|
||||
irangefn[i] = 1.f + offs ;
|
||||
} else {
|
||||
irangefn[i] = 1.f + offs + (multbis[level] - 1.f) * (noisehi - abs(i - 0x10000)) / (noisehi - noiselo + 0.01f) ;
|
||||
irangefn[i] = 1.f + offs + (multbis[level] - 1.f) * (noisehi - abs (i - 0x10000)) / (noisehi - noiselo + 0.01f) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(skinprot == 0.f)
|
||||
if (skinprot == 0.f)
|
||||
#ifdef _OPENMP
|
||||
#pragma omp parallel for schedule(dynamic,16)
|
||||
#endif
|
||||
for(int i = 0; i < height; i++) {
|
||||
for(int j = 0; j < width; j++) {
|
||||
for (int i = 0; i < height; i++) {
|
||||
for (int j = 0; j < width; j++) {
|
||||
float hipass = (data_fine[i][j] - data_coarse[i][j]);
|
||||
buffer[i][j] += irangefn[hipass + 0x10000] * hipass ;
|
||||
}
|
||||
}
|
||||
else if(skinprot > 0.f)
|
||||
else if (skinprot > 0.f)
|
||||
#ifdef _OPENMP
|
||||
#pragma omp parallel for schedule(dynamic,16)
|
||||
#endif
|
||||
for(int i = 0; i < height; i++) {
|
||||
for(int j = 0; j < width; j++) {
|
||||
for (int i = 0; i < height; i++) {
|
||||
for (int j = 0; j < width; j++) {
|
||||
float hipass = (data_fine[i][j] - data_coarse[i][j]);
|
||||
float scale = 1.f;
|
||||
Color::SkinSatCbdlCam ((data_fine[i][j]) / 327.68f, l_a_h[i][j] , l_b_c[i][j], skinprot, scale, true, b_l, t_l, t_r);
|
||||
@@ -1006,8 +1006,8 @@ void ImProcFunctions::idirpyr_eq_channelcam(float ** data_coarse, float ** data_
|
||||
#ifdef _OPENMP
|
||||
#pragma omp parallel for schedule(dynamic,16)
|
||||
#endif
|
||||
for(int i = 0; i < height; i++) {
|
||||
for(int j = 0; j < width; j++) {
|
||||
for (int i = 0; i < height; i++) {
|
||||
for (int j = 0; j < width; j++) {
|
||||
float hipass = (data_fine[i][j] - data_coarse[i][j]);
|
||||
float scale = 1.f;
|
||||
float correct;
|
||||
|
Reference in New Issue
Block a user