diff --git a/rtengine/CA_correct_RT.cc b/rtengine/CA_correct_RT.cc index a687be2ff..e18cf75a9 100644 --- a/rtengine/CA_correct_RT.cc +++ b/rtengine/CA_correct_RT.cc @@ -905,7 +905,7 @@ void RawImageSource::CA_correct_RT(double cared, double cablue) { indx = row*width + col; c = FC(row,col); - rawData[row][col] = CLIP((int)(65535.0f*rgb[(rr)*TS+cc][c] + 0.5f)); + rawData[row][col] = 65535.0f*rgb[(rr)*TS+cc][c] + 0.5f; //image[indx][c] = CLIP((int)(65535.0*rgb[(rr)*TS+cc][c] + 0.5));//for dcraw implementation } diff --git a/rtengine/amaze_demosaic_RT.cc b/rtengine/amaze_demosaic_RT.cc index 7402887d1..d5fb01447 100644 --- a/rtengine/amaze_demosaic_RT.cc +++ b/rtengine/amaze_demosaic_RT.cc @@ -33,7 +33,6 @@ void RawImageSource::amaze_demosaic_RT(int winx, int winy, int winw, int winh) { //#define MAX(a,b) ((a) > (b) ? (a) : (b)) #define LIM(x,min,max) MAX(min,MIN(x,max)) #define ULIM(x,y,z) ((y) < (z) ? LIM(x,y,z) : LIM(x,z,y)) - //#define CLIP(x) LIM(x,0,65535) #define HCLIP(x) x //is this still necessary??? //MIN(clip_pt,x) diff --git a/rtengine/demosaic_algos.cc b/rtengine/demosaic_algos.cc index 4bd9f53dd..eab5f1b85 100644 --- a/rtengine/demosaic_algos.cc +++ b/rtengine/demosaic_algos.cc @@ -425,7 +425,7 @@ void RawImageSource::hphd_green (float** hpmap) { double e4 = 1.0 / (1.0 + ABS(dx) + ABS(d1) + ABS(d2) + ABS(d3) + ABS(d4)); - green[i][j] = CLIP((e2 * g2 + e4 * g4) / (e2 + e4)); + green[i][j] = (e2 * g2 + e4 * g4) / (e2 + e4); } else if (hpmap[i][j]==2) { int g1 = rawData[i-1][j] + ((rawData[i][j] - rawData[i-2][j]) /2); @@ -446,7 +446,7 @@ void RawImageSource::hphd_green (float** hpmap) { double e3 = 1.0 / (1.0 + ABS(dy) + ABS(d1) + ABS(d2) + ABS(d3) + ABS(d4)); - green[i][j] = CLIP((e1 * g1 + e3 * g3) / (e1 + e3)); + green[i][j] = (e1 * g1 + e3 * g3) / (e1 + e3); } else { int g1 = rawData[i-1][j] + ((rawData[i][j] - rawData[i-2][j]) /2); @@ -485,7 +485,7 @@ void RawImageSource::hphd_green (float** hpmap) { double e4 = 1.0 / (1.0 + ABS(dx) + ABS(d1) + ABS(d2) + ABS(d3) + ABS(d4)); - green[i][j] = CLIP((e1*g1 + e2*g2 + e3*g3 + e4*g4) / (e1 + e2 + e3 + e4)); + green[i][j] = (e1*g1 + e2*g2 + e3*g3 + e4*g4) / (e1 + e2 + e3 + e4); } } } @@ -723,7 +723,7 @@ void RawImageSource::vng4_demosaic () { t = pix[color]; if (c != color) t += (sum[c] - sum[color]) / num; - brow[2][col][c] = CLIP(t); + brow[2][col][c] = t; } } if (row > 3) /* Write buffer to image */ @@ -1213,37 +1213,28 @@ void RawImageSource::dcb_hid(float (*image)[4],float (*bufferH)[3], float (*buff // green pixels for (int row = rowMin; row < rowMax; row++) { for (int col = colMin+(FC(y0-TILEBORDER+row,x0-TILEBORDER+colMin)&1),indx=row*CACHESIZE+col,c=FC(y0-TILEBORDER+row,x0-TILEBORDER+col); col < colMax; col+=2, indx+=2) { - int current = ( image[indx-1][1] + image[indx+1][1])/2; - bufferH[indx][1] = CLIP(current); - current = (image[indx+u][1] + image[indx-u][1])/2; - bufferV[indx][1] = CLIP(current); + bufferH[indx][1] = ( image[indx-1][1] + image[indx+1][1]) * 0.5; + bufferV[indx][1] = (image[indx+u][1] + image[indx-u][1])*0.5; } } // red in blue pixel, blue in red pixel for (int row=rowMin; row < rowMax; row++) for (int col=colMin+(FC(y0-TILEBORDER+row,x0-TILEBORDER+colMin) & 1), indx=row*CACHESIZE+col, c=2-FC(y0-TILEBORDER+row,x0-TILEBORDER+col); col < colMax; col+=2, indx+=2) { - int current = ( 4*bufferH[indx][1] + bufferH[indx][c] = ( 4*bufferH[indx][1] - bufferH[indx+u+1][1] - bufferH[indx+u-1][1] - bufferH[indx-u+1][1] - bufferH[indx-u-1][1] - + image[indx+u+1][c] + image[indx+u-1][c] + image[indx-u+1][c] + image[indx-u-1][c] )/4; - bufferH[indx][c] = CLIP(current); - current = ( 4*bufferV[indx][1] + + image[indx+u+1][c] + image[indx+u-1][c] + image[indx-u+1][c] + image[indx-u-1][c] ) * 0.25; + bufferV[indx][c] = ( 4*bufferV[indx][1] - bufferV[indx+u+1][1] - bufferV[indx+u-1][1] - bufferV[indx-u+1][1] - bufferV[indx-u-1][1] - + image[indx+u+1][c] + image[indx+u-1][c] + image[indx-u+1][c] + image[indx-u-1][c] )/4; - bufferV[indx][c] = CLIP(current); - + + image[indx+u+1][c] + image[indx+u-1][c] + image[indx-u+1][c] + image[indx-u-1][c] ) * 0.25; } // red or blue in green pixels for (int row=rowMin; rowsetProgress(progress); diff --git a/rtengine/green_equil_RT.cc b/rtengine/green_equil_RT.cc index a2a4ee072..2bbccbeab 100644 --- a/rtengine/green_equil_RT.cc +++ b/rtengine/green_equil_RT.cc @@ -186,7 +186,7 @@ void RawImageSource::green_equilibrate(float thresh) col = cc + left; //c = FC(row,col); //image[row*width + col][c] = CLIP((int)(cfa[indx] + 0.5)); //for dcraw implementation - rawData[row][col] = CLIP(cfa[indx]); + rawData[row][col] = cfa[indx]; } // clean up diff --git a/rtengine/rawimagesource_i.h b/rtengine/rawimagesource_i.h index c3a210d56..12a79d870 100644 --- a/rtengine/rawimagesource_i.h +++ b/rtengine/rawimagesource_i.h @@ -118,8 +118,8 @@ inline void RawImageSource::interpolate_row_g (float* agh, float* agv, int i) { else if (i==H-2) gv = (rawData[H-1][j] + rawData[H-3][j]) / 2; - agh[j] = CLIP(gh); - agv[j] = CLIP(gv); + agh[j] = gh; + agv[j] = gv; } } } @@ -151,7 +151,7 @@ inline void RawImageSource::interpolate_row_rb (float* ar, float* ab, float* pg, n++; } b = cg[j] + b / n; - ab[j] = CLIP(b); + ab[j] = b; } else { // linear R-G interp. horizontally @@ -171,7 +171,7 @@ inline void RawImageSource::interpolate_row_rb (float* ar, float* ab, float* pg, b = pg[j] + rawData[H-2][j] - cg[j]; else b = cg[j] + (rawData[i-1][j] - pg[j] + rawData[i+1][j] - ng[j]) / 2; - ab[j] = CLIP(b); + ab[j] = b; } } } @@ -202,7 +202,7 @@ inline void RawImageSource::interpolate_row_rb (float* ar, float* ab, float* pg, } r = cg[j] + r / n; - ar[j] = CLIP(r); + ar[j] = r; } else { // linear B-G interp. horizontally @@ -222,7 +222,7 @@ inline void RawImageSource::interpolate_row_rb (float* ar, float* ab, float* pg, r = pg[j] + rawData[H-2][j] - cg[j]; else r = cg[j] + (rawData[i-1][j] - pg[j] + rawData[i+1][j] - ng[j]) / 2; - ar[j] = CLIP(r); + ar[j] = r; } } } @@ -235,7 +235,7 @@ inline void RawImageSource::interpolate_row_rb_mul_pp (float* ar, float* ab, flo for (int j=x1, jx=0; jxISRED(i,j)) { // red is simple - ar[jx] = CLIP(r_mul * rawData[i][j]); + ar[jx] = r_mul * rawData[i][j]; // blue: cross interpolation int b = 0; int n = 0; @@ -256,7 +256,7 @@ inline void RawImageSource::interpolate_row_rb_mul_pp (float* ar, float* ab, flo n++; } b = g_mul*cg[j] + b / n; - ab[jx] = CLIP(b); + ab[jx] = b; } else { // linear R-G interp. horizontally @@ -267,7 +267,7 @@ inline void RawImageSource::interpolate_row_rb_mul_pp (float* ar, float* ab, flo r = g_mul*cg[W-1] + r_mul*rawData[i][W-2] - g_mul*cg[W-2]; else r = g_mul*cg[j] + (r_mul*rawData[i][j-1] - g_mul*cg[j-1] + r_mul*rawData[i][j+1] - g_mul*cg[j+1]) / 2; - ar[jx] = CLIP(r); + ar[jx] = r; // linear B-G interp. vertically int b; if (i==0) @@ -276,7 +276,7 @@ inline void RawImageSource::interpolate_row_rb_mul_pp (float* ar, float* ab, flo b = g_mul*pg[j] + b_mul*rawData[H-2][j] - g_mul*cg[j]; else b = g_mul*cg[j] + (b_mul*rawData[i-1][j] - g_mul*pg[j] + b_mul*rawData[i+1][j] - g_mul*ng[j]) / 2; - ab[jx] = CLIP(b); + ab[jx] = b; } } } @@ -285,7 +285,7 @@ inline void RawImageSource::interpolate_row_rb_mul_pp (float* ar, float* ab, flo for (int j=x1, jx=0; jxISBLUE(i,j)) { // red is simple - ab[jx] = CLIP(b_mul*rawData[i][j]); + ab[jx] = b_mul*rawData[i][j]; // blue: cross interpolation int r = 0; int n = 0; @@ -307,7 +307,7 @@ inline void RawImageSource::interpolate_row_rb_mul_pp (float* ar, float* ab, flo } r = g_mul*cg[j] + r / n; - ar[jx] = CLIP(r); + ar[jx] = r; } else { // linear B-G interp. horizontally @@ -318,7 +318,7 @@ inline void RawImageSource::interpolate_row_rb_mul_pp (float* ar, float* ab, flo b = g_mul*cg[W-1] + b_mul*rawData[i][W-2] - g_mul*cg[W-2]; else b = g_mul*cg[j] + (b_mul*rawData[i][j-1] - g_mul*cg[j-1] + b_mul*rawData[i][j+1] - g_mul*cg[j+1]) / 2; - ab[jx] = CLIP(b); + ab[jx] = b; // linear R-G interp. vertically int r; if (i==0) @@ -327,7 +327,7 @@ inline void RawImageSource::interpolate_row_rb_mul_pp (float* ar, float* ab, flo r = g_mul*pg[j] + r_mul*rawData[H-2][j] - g_mul*cg[j]; else r = g_mul*cg[j] + (r_mul*rawData[i-1][j] - g_mul*pg[j] + r_mul*rawData[i+1][j] - g_mul*ng[j]) / 2; - ar[jx] = CLIP(r); + ar[jx] = r; } } } diff --git a/rtengine/shmap.cc b/rtengine/shmap.cc index 8afad563f..cd0dafce2 100644 --- a/rtengine/shmap.cc +++ b/rtengine/shmap.cc @@ -25,14 +25,12 @@ #undef MAXVAL -#undef CLIP #undef MAX #undef MIN #undef SQR #undef THREAD_PRIORITY_NORMAL #define MAXVAL 0xffff -#define CLIP(a) ((a)>0?((a)r[i][j] + lumi[1]*img->g[i][j] + lumi[2]*img->b[i][j]; - map[i][j] = CLIP(val); + map[i][j] = lumi[0]*img->r[i][j] + lumi[1]*img->g[i][j] + lumi[2]*img->b[i][j]; } #ifdef _OPENMP #pragma omp parallel @@ -222,7 +219,7 @@ void SHMap::dirpyr_shmap(float ** data_fine, float ** data_coarse, int width, in }*/ } } - data_coarse[i][j]=CLIP((int)(val/norm));//low pass filter + data_coarse[i][j] = val/norm; // low pass filter /*if (val<=0 || norm<=0) printf("val=%f norm=%f \n",val,norm); */ }