/* * This file is part of RawTherapee. * * RawTherapee is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * RawTherapee is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with RawTherapee. If not, see . * * © 2010 Emil Martinec * */ //#include #include #include #include #include #include #include #include #ifdef _OPENMP #include #endif #define SQR(x) ((x)*(x)) #define CLIPTO(a,b,c) ((a)>(b)?((a)<(c)?(a):(c)):(b)) #define CLIPC(a) ((a)>-32000?((a)<32000?(a):32000):-32000) #define CLIP(a) (CLIPTO(a,0,65535)) #define DIRWT(i1,j1,i,j) ( domker[(i1-i)/scale+halfwin][(j1-j)/scale+halfwin] * rangefn[abs((int)data_fine[i1][j1]-data_fine[i][j])] ) namespace rtengine { static const int maxlevel = 4; static const float noise = 2000; static const float thresh = 1000; //sequence of scales static const int scales[8] = {1,2,4,8,16,32,64,128}; //sequence of scales //static const int scales[8] = {1,2,3,6,15,21,28,36}; //scale is spacing of directional averaging weights void ImProcFunctions :: dirpyr_equalizer(float ** src, float ** dst, int srcwidth, int srcheight, const double * mult ) { int lastlevel=maxlevel; while (fabs(mult[lastlevel-1]-1)<0.001 && lastlevel>0) { lastlevel--; //printf("last level to process %d \n",lastlevel); } if (lastlevel==0) return; //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LUTf rangefn(0x10000); int intfactor = 1024;//16384; //set up range functions for (int i=0; i<0x10000; i++) { rangefn[i] = (int)((thresh/((double)(i) + thresh))*intfactor); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% int level; array2D buffer (srcwidth, srcheight); multi_array2D dirpyrlo (srcwidth, srcheight); for (int i=0; i 0; level--) { idirpyr_eq_channel(dirpyrlo[level], dirpyrlo[level-1], buffer, srcwidth, srcheight, level, mult ); } scale = scales[0]; idirpyr_eq_channel(dirpyrlo[0], dst, buffer, srcwidth, srcheight, 0, mult ); //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% for (int i=0; inoisehi || mult[level]<1.0) { irangefn[i] = mult[level] ; } else { if (abs(i-0x10000)