Green channel equilibration algorithm, for cameras such as Olympus, Panasonic, Canon 7D, etc that have different properties for the G1/G2 channels of the Bayer color filter array. In addition, minor changes to line denoise and CA_correct.
This commit is contained in:
@@ -320,10 +320,10 @@ void RawImageSource::CA_correct_RT() {
|
||||
for (cc=4+(FC(rr,2)&1), indx=rr*TS+cc, c = FC(rr,cc); cc < cc1-4; cc+=2, indx+=2) {
|
||||
|
||||
|
||||
rbhpfv[indx] = fabs(fabs((rgb[indx][1]-rgb[indx][c])-(rgb[indx+v4][1]-rgb[indx+v4][c])) + \
|
||||
rbhpfv[indx] = SQR(fabs((rgb[indx][1]-rgb[indx][c])-(rgb[indx+v4][1]-rgb[indx+v4][c])) + \
|
||||
fabs((rgb[indx-v4][1]-rgb[indx-v4][c])-(rgb[indx][1]-rgb[indx][c])) - \
|
||||
fabs((rgb[indx-v4][1]-rgb[indx-v4][c])-(rgb[indx+v4][1]-rgb[indx+v4][c])));
|
||||
rbhpfh[indx] = fabs(fabs((rgb[indx][1]-rgb[indx][c])-(rgb[indx+4][1]-rgb[indx+4][c])) + \
|
||||
rbhpfh[indx] = SQR(fabs((rgb[indx][1]-rgb[indx][c])-(rgb[indx+4][1]-rgb[indx+4][c])) + \
|
||||
fabs((rgb[indx-4][1]-rgb[indx-4][c])-(rgb[indx][1]-rgb[indx][c])) - \
|
||||
fabs((rgb[indx-4][1]-rgb[indx-4][c])-(rgb[indx+4][1]-rgb[indx+4][c])));
|
||||
|
||||
@@ -358,7 +358,7 @@ void RawImageSource::CA_correct_RT() {
|
||||
gdiff=0.3125*(rgb[indx+TS][1]-rgb[indx-TS][1])+0.09375*(rgb[indx+TS+1][1]-rgb[indx-TS+1][1]+rgb[indx+TS-1][1]-rgb[indx-TS-1][1]);
|
||||
deltgrb=(rgb[indx][c]-rgb[indx][1]);
|
||||
|
||||
gradwt=fabs(0.25*rbhpfv[indx]+0.125*(rbhpfv[indx+2]+rbhpfv[indx-2]) )*(grblpfv[indx-v2]+grblpfv[indx+v2])/(eps+0.1*grblpfv[indx-v2]+rblpfv[indx-v2]+0.1*grblpfv[indx+v2]+rblpfv[indx+v2]);
|
||||
gradwt=fabs(0.25*rbhpfv[indx]+0.125*(rbhpfv[indx+2]+rbhpfv[indx-2]) );//*(grblpfv[indx-v2]+grblpfv[indx+v2])/(eps+0.1*grblpfv[indx-v2]+rblpfv[indx-v2]+0.1*grblpfv[indx+v2]+rblpfv[indx+v2]);
|
||||
|
||||
coeff[0][0][c] += gradwt*deltgrb*deltgrb;
|
||||
coeff[0][1][c] += gradwt*gdiff*deltgrb;
|
||||
@@ -370,7 +370,7 @@ void RawImageSource::CA_correct_RT() {
|
||||
gdiff=0.3125*(rgb[indx+1][1]-rgb[indx-1][1])+0.09375*(rgb[indx+1+TS][1]-rgb[indx-1+TS][1]+rgb[indx+1-TS][1]-rgb[indx-1-TS][1]);
|
||||
deltgrb=(rgb[indx][c]-rgb[indx][1]);
|
||||
|
||||
gradwt=fabs(0.25*rbhpfh[indx]+0.125*(rbhpfh[indx+v2]+rbhpfh[indx-v2]) )*(grblpfh[indx-2]+grblpfh[indx+2])/(eps+0.1*grblpfh[indx-2]+rblpfh[indx-2]+0.1*grblpfh[indx+2]+rblpfh[indx+2]);
|
||||
gradwt=fabs(0.25*rbhpfh[indx]+0.125*(rbhpfh[indx+v2]+rbhpfh[indx-v2]) );//*(grblpfh[indx-2]+grblpfh[indx+2])/(eps+0.1*grblpfh[indx-2]+rblpfh[indx-2]+0.1*grblpfh[indx+2]+rblpfh[indx+2]);
|
||||
|
||||
coeff[1][0][c] += gradwt*deltgrb*deltgrb;
|
||||
coeff[1][1][c] += gradwt*gdiff*deltgrb;
|
||||
@@ -502,7 +502,7 @@ void RawImageSource::CA_correct_RT() {
|
||||
//if (verbose) fprintf (stderr,_("tile vshift hshift (%d %d %4f %4f)...\n"),vblock, hblock, blockshifts[(vblock)*hblsz+hblock][c][0], blockshifts[(vblock)*hblsz+hblock][c][1]);
|
||||
|
||||
|
||||
//now prepare coefficient matrix
|
||||
//now prepare coefficient matrix; use only data points within two std devs of zero
|
||||
if (SQR(blockshifts[(vblock)*hblsz+hblock][c][0])>4.0*blockvar[0][c] || SQR(blockshifts[(vblock)*hblsz+hblock][c][1])>4.0*blockvar[1][c]) continue;
|
||||
numblox[c] += 1;
|
||||
for (dir=0; dir<2; dir++) {
|
||||
@@ -520,13 +520,11 @@ void RawImageSource::CA_correct_RT() {
|
||||
}//blocks
|
||||
|
||||
numblox[1]=MIN(numblox[0],numblox[2]);
|
||||
//if (numblox[1]<72) {
|
||||
// polyord=4; numpar=16;
|
||||
//if too few data points, restrict the order of the fit to linear
|
||||
if (numblox[1]<32) {
|
||||
polyord=2; numpar=4;
|
||||
if (numblox[1]< 10) return;
|
||||
}
|
||||
//}
|
||||
|
||||
//fit parameters to blockshifts
|
||||
for (c=0; c<3; c+=2)
|
||||
@@ -536,7 +534,7 @@ void RawImageSource::CA_correct_RT() {
|
||||
for (i=0; i<numpar; i++) fitparams[c][dir][i]=0;
|
||||
}
|
||||
}
|
||||
//fitparams[5*i+j] gives the coefficients of (vblock^i hblock^j) in a polynomial fit for i,j<=4
|
||||
//fitparams[polyord*i+j] gives the coefficients of (vblock^i hblock^j) in a polynomial fit for i,j<=4
|
||||
|
||||
//end of initialization for CA correction pass
|
||||
|
||||
|
Reference in New Issue
Block a user