Patches for CA correction and impulse denoise.
This commit is contained in:
@@ -390,8 +390,8 @@ void RawImageSource::CA_correct_RT() {
|
||||
|
||||
// along line segments, find the point along each segment that minimizes the color variance
|
||||
// averaged over the tile; evaluate for up/down and left/right away from R/B grid point
|
||||
for (rr=8; rr < rr1-8; rr++)
|
||||
for (cc=8+(FC(rr,2)&1), indx=rr*TS+cc, c = FC(rr,cc); cc < cc1-8; cc+=2, indx+=2) {
|
||||
for (rr=rrmin+8; rr < rrmax-8; rr++)
|
||||
for (cc=ccmin+8+(FC(rr,2)&1), indx=rr*TS+cc, c = FC(rr,cc); cc < ccmax-8; cc+=2, indx+=2) {
|
||||
|
||||
if (rgb[indx][c]>0.8*clip_pt || Gtmp[indx]>0.8*clip_pt) continue;
|
||||
|
||||
@@ -430,7 +430,9 @@ void RawImageSource::CA_correct_RT() {
|
||||
for (c=0; c<3; c+=2){
|
||||
for (j=0; j<2; j++) {// vert/hor
|
||||
//printf("hblock %d vblock %d j %d c %d areawt %d \n",hblock,vblock,j,c,areawt[j][c]);
|
||||
if (areawt[j][c]>500) {
|
||||
//printf("hblock %d vblock %d j %d c %d areawt %d ",hblock,vblock,j,c,areawt[j][c]);
|
||||
|
||||
if (areawt[j][c]>0) {
|
||||
CAshift[j][c]=coeff[j][1][c]/coeff[j][2][c];
|
||||
blockwt[vblock*hblsz+hblock]= areawt[j][c];//*coeff[j][2][c]/(eps+coeff[j][0][c]) ;
|
||||
} else {
|
||||
@@ -438,6 +440,8 @@ void RawImageSource::CA_correct_RT() {
|
||||
blockwt[vblock*hblsz+hblock]=0;
|
||||
}
|
||||
|
||||
//printf("%f \n",CAshift[j][c]);
|
||||
|
||||
//CAshift[j][c]=coeff[j][1][c]/coeff[j][2][c];
|
||||
//blockwt[vblock*hblsz+hblock] = (float)(rr1-8)*(cc1-8)/4 * coeff[j][2][c]/(eps+coeff[j][0][c]) ;
|
||||
|
||||
@@ -489,7 +493,7 @@ void RawImageSource::CA_correct_RT() {
|
||||
}
|
||||
}
|
||||
|
||||
//if (verbose) fprintf (stderr,_("tile variances %f %f %f %f \n"),blockvar[0][0],blockvar[1][0],blockvar[0][2],blockvar[1][2] );
|
||||
//printf ("tile variances %f %f %f %f \n",blockvar[0][0],blockvar[1][0],blockvar[0][2],blockvar[1][2] );
|
||||
|
||||
|
||||
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
@@ -24,15 +24,17 @@
|
||||
#include <algorithm>
|
||||
|
||||
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
// Gabor's implementation of bilateral filtering, without input pixel
|
||||
// modified version of Gabor's implementation of bilateral filtering, without input pixel
|
||||
|
||||
#define NBRWT(a,b) (src[i - a][j - b] * ec[src[i - a][j - b]-src[i][j]+0x10000])
|
||||
#define NORM(a,b) (1 + ec[src[i - a][j - b]-src[i][j]+0x10000])
|
||||
#define NORM(a,b) (ec[src[i - a][j - b]-src[i][j]+0x10000])
|
||||
|
||||
//ec[i] = (int)(exp(-(double)(i-0x10000)*(double)(i-0x10000) / (2.0*rangewidth*rangewidth))*scale); \
|
||||
|
||||
#define RB_BEGIN(a,b) double scale = (a); \
|
||||
int* ec = new int [0x20000]; \
|
||||
for (int i=0; i<0x20000; i++) \
|
||||
ec[i] = (int)(exp(-(double)(i-0x10000)*(double)(i-0x10000) / (2.0*rangewidth*rangewidth))*scale); \
|
||||
ec[i] = (int)(1 + 1024/(abs(i-0x10000) + 1)); \
|
||||
int rstart = b; \
|
||||
int rend = H-b; \
|
||||
int cstart = b; \
|
||||
@@ -97,7 +99,7 @@ template<class T> void impulse_nr (T** src, T** dst, int width, int height, doub
|
||||
//The cleaning algorithm starts here
|
||||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
// modified bilateral filter for lowpass image, omitting input pixel
|
||||
// modified bilateral filter for lowpass image, omitting input pixel; or Gaussian blur
|
||||
|
||||
static float eps = 1.0;
|
||||
float wtdsum, dirwt, norm;
|
||||
@@ -127,7 +129,7 @@ template<class T> void impulse_nr (T** src, T** dst, int width, int height, doub
|
||||
hfnbrave = (hfnbrave-hpfabs)/24;
|
||||
hpfabs>(hfnbrave*(5.5-thresh)) ? impish[i][j]=1 : impish[i][j]=0;
|
||||
|
||||
}//now impulsive values have been corrected
|
||||
}//now impulsive values have been identified
|
||||
|
||||
for (int i=0; i < height; i++)
|
||||
for (int j=0; j < width; j++) {
|
||||
|
Reference in New Issue
Block a user