restore speed when not using auto itc wb and improve speed when using it

This commit is contained in:
Ingo Weyrich
2020-02-29 21:04:09 +01:00
parent 0a23e85868
commit cee41b9786
2 changed files with 77 additions and 32 deletions

View File

@@ -389,16 +389,11 @@ void ImProcCoordinator::updatePreviewImage(int todo, bool panningRelatedChange)
}
}
// bool autowb0 = false;
// autowb0 = (params->wb.method == "autold" || params->wb.method == "aut" || params->wb.method == "autosdw" || params->wb.method == "autedgsdw" || params->wb.method == "autitcgreen" || params->wb.method == "autedgrob" || params->wb.method == "autedg" || params->wb.method == "autorobust");
// autowb0 = (params->wb.method == "autold" || params->wb.method == "autitcgreen");//in some cases autowb0 does not work ....params->wb.method still at "camera" instead of auto !!!
// printf("autowb0=%s \n", params->wb.method.c_str());
// if (autowb0) {
if (todo & (M_INIT | M_LINDENOISE | M_HDR)) {
if (params->wb.method == "autitcgreen") {
imgsrc->getrgbloc(false, false, false, 0, 0, fh, fw, 0, 0, fh, fw);
// }
}
}
if ((todo & (M_RETINEX | M_INIT)) && params->retinex.enabled) {
bool dehacontlutili = false;

View File

@@ -5243,16 +5243,57 @@ void RawImageSource::getrgbloc(bool local, bool gamma, bool cat02, int begx, in
//center data on normal values
int nn = 0;
for (int i = 0; i < H; i ++)
if (!local) {
#ifdef _OPENMP
#pragma omp parallel sections
#endif
{
#ifdef _OPENMP
#pragma omp section
#endif
{
for (int i = 0; i < H; i ++) {
for (int j = 0; j < W; j++) {
redloc[i][j] = red[i][j];
}
}
}
#ifdef _OPENMP
#pragma omp section
#endif
{
for (int i = 0; i < H; i ++) {
for (int j = 0; j < W; j++) {
greenloc[i][j] = green[i][j];
}
}
}
#ifdef _OPENMP
#pragma omp section
#endif
{
for (int i = 0; i < H; i ++) {
for (int j = 0; j < W; j++) {
blueloc[i][j] = blue[i][j];
}
}
}
}
}
#ifdef _OPENMP
#pragma omp parallel for reduction(+:avgL, nn)
#endif
for (int i = 0; i < H; i ++) {
for (int j = 0; j < W; j++) {
int lox = cx + j;
int loy = cy + i;
if (!local) {
const float redmm = redloc[i][j] = red[i][j];
const float greenmm = greenloc[i][j] = green[i][j];
const float bluemm = blueloc[i][j] = blue[i][j];
const float LL = (0.299f * redmm + 0.587f * greenmm + 0.114f * bluemm);
const float redmm = redloc[i][j];
const float greenmm = greenloc[i][j];
const float bluemm = blueloc[i][j];
const float LL = 0.299f * redmm + 0.587f * greenmm + 0.114f * bluemm;
avgL += static_cast<double>(LL);
nn++;
} else {
@@ -5260,21 +5301,24 @@ void RawImageSource::getrgbloc(bool local, bool gamma, bool cat02, int begx, in
const float redmm = redloc[loy - begy][lox - begx] = red[i][j];
const float greenmm = greenloc[loy - begy][lox - begx] = green[i][j];
const float bluemm = blueloc[loy - begy][lox - begx] = blue[i][j];
const float LL = (0.299f * redmm + 0.587f * greenmm + 0.114f * bluemm);
const float LL = 0.299f * redmm + 0.587f * greenmm + 0.114f * bluemm;
avgL += static_cast<double>(LL);
nn++;
}
}
}
}
avgL /= nn;
float vari = 0.f;
double vari = 0.f;
int mm = 0;
#ifdef _OPENMP
#pragma omp parallel for reduction(+:vari, mm)
#endif
for (int i = 0; i < bfh; i++)
for (int j = 0; j < bfw; j++) {
float LL = (0.299f * redloc[i][j] + 0.587f * greenloc[i][j] + 0.114f * blueloc[i][j]);
float LL = 0.299f * redloc[i][j] + 0.587f * greenloc[i][j] + 0.114f * blueloc[i][j];
vari += SQR(LL - avgL);
mm++;
}
@@ -5282,6 +5326,9 @@ void RawImageSource::getrgbloc(bool local, bool gamma, bool cat02, int begx, in
const float sig = std::sqrt(vari / mm);
const float multip = 60000.f / (avgL + 2.f * sig);
#ifdef _OPENMP
#pragma omp parallel for
#endif
for (int i = 0; i < bfh; i++)
for (int j = 0; j < bfw; j++) {
redloc[i][j] *= multip;
@@ -5290,6 +5337,9 @@ void RawImageSource::getrgbloc(bool local, bool gamma, bool cat02, int begx, in
}
if (gamma) {
#ifdef _OPENMP
#pragma omp parallel for
#endif
for (int i = 0; i < bfh; i++)
for (int j = 0; j < bfw; j++) {
redloc[i][j] = Color::gammatab_srgb[redloc[i][j]];