Additional correction to WB code.

This commit is contained in:
Emil Martinec 2010-09-27 21:06:20 -05:00
parent d62281b86f
commit 751ebdf0eb
2 changed files with 8 additions and 7 deletions

View File

@ -9381,29 +9381,29 @@ t5.set ();
double d = tpp->defGain * image[i* ::width+j][1]; double d = tpp->defGain * image[i* ::width+j][1];
if (d>64000) if (d>64000)
continue; continue;
avg_g += d*d*d*d*d*d; avg_g += d;
gn++; gn++;
} }
if (FISRED(filter,i,j)) { if (FISRED(filter,i,j)) {
double d = tpp->defGain * image[i* ::width+j][0]; double d = tpp->defGain * image[i* ::width+j][0];
if (d>64000) if (d>64000)
continue; continue;
avg_r += d*d*d*d*d*d; avg_r += d;
rn++; rn++;
} }
if (FISBLUE(filter,i,j)) { if (FISBLUE(filter,i,j)) {
double d = tpp->defGain * image[i* ::width+j][2]; double d = tpp->defGain * image[i* ::width+j][2];
if (d>64000) if (d>64000)
continue; continue;
avg_b += d*d*d*d*d*d; avg_b += d;
bn++; bn++;
} }
} }
} }
double reds = pow (avg_r/rn, 1.0/6.0) * tpp->camwbRed; double reds = avg_r/rn * tpp->camwbRed;
double greens = pow (avg_g/gn, 1.0/6.0) * tpp->camwbGreen; double greens = avg_g/gn * tpp->camwbGreen;
double blues = pow (avg_b/bn, 1.0/6.0) * tpp->camwbBlue; double blues = avg_b/bn * tpp->camwbBlue;
double rm = rgb_cam[0][0]*reds + rgb_cam[0][1]*greens + rgb_cam[0][2]*blues; double rm = rgb_cam[0][0]*reds + rgb_cam[0][1]*greens + rgb_cam[0][2]*blues;
double gm = rgb_cam[1][0]*reds + rgb_cam[1][1]*greens + rgb_cam[1][2]*blues; double gm = rgb_cam[1][0]*reds + rgb_cam[1][1]*greens + rgb_cam[1][2]*blues;

View File

@ -475,7 +475,8 @@ ColorTemp StdImageSource::getAutoWB () {
avg_b += intpow((double)img->b[i][j], p); avg_b += intpow((double)img->b[i][j], p);
n++; n++;
} }
return ColorTemp (pow(avg_r/n, 1.0/p), pow(avg_g/n, 1.0/p), pow(avg_b/n, 1.0/p)); return ColorTemp (avg_r/n, avg_g/n, avg_b/n);
//return ColorTemp (pow(avg_r/n, 1.0/p), pow(avg_g/n, 1.0/p), pow(avg_b/n, 1.0/p));
} }
void StdImageSource::transformPixel (int x, int y, int tran, int& tx, int& ty) { void StdImageSource::transformPixel (int x, int y, int tran, int& tx, int& ty) {