"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/tmo/durand02/bilateral.cpp" between
pfstools-2.1.0.tgz and pfstools-2.2.0.tgz

About: pfstools are a set of command line programs (and one GUI program) for reading, writing, manipulating, and viewing high-dynamic range (HDR) images and video frames (similar as the netpbm package does for low-dynamic range images).

bilateral.cpp  (pfstools-2.1.0.tgz):bilateral.cpp  (pfstools-2.2.0.tgz)
skipping to change at line 47 skipping to change at line 47
inline int max( int a, int b ) inline int max( int a, int b )
{ return (a>b) ? a : b; } { return (a>b) ? a : b; }
inline int min( int a, int b ) inline int min( int a, int b )
{ return (a<b) ? a : b; } { return (a<b) ? a : b; }
// support functions // support functions
void gaussianKernel( pfstmo::Array2D *kern, float sigma ) void gaussianKernel( pfstmo::Array2D *kern, float sigma )
{ {
for( int y = 0; y < kern->getRows(); y++ ) { for( unsigned int y = 0; y < kern->getRows(); y++ ) {
for( int x = 0; x < kern->getCols(); x++ ) { for(unsigned int x = 0; x < kern->getCols(); x++ ) {
float rx = (float)(x - kern->getCols()/2); float rx = (float)(x - kern->getCols()/2);
float ry = (float)(y - kern->getRows()/2); float ry = (float)(y - kern->getRows()/2);
float d2 = rx*rx + ry*ry; float d2 = rx*rx + ry*ry;
(*kern)(x, y) = exp( -d2 / (2.*sigma*sigma) ); (*kern)(x, y) = (float)exp( -d2 / (2.*sigma*sigma) );
} }
} }
} }
class GaussLookup { class GaussLookup {
float *gauss; float *gauss;
float maxVal; float maxVal;
float scaleFactor; float scaleFactor;
int N; int N;
public: public:
GaussLookup( float sigma, int N ) : N(N) GaussLookup( float sigma, int N ) : N(N)
{ {
float sigma2 = sigma*sigma; float sigma2 = sigma*sigma;
maxVal = sqrt(-log(0.01)*2.0*sigma2); maxVal = sqrtf(-log(0.01f)*2.0f*sigma2);
gauss = new float[N]; gauss = new float[N];
for( int i = 0; i < N; i++ ) { for( int i = 0; i < N; i++ ) {
float x = (float)i/(float)(N-1)*maxVal; float x = (float)i/(float)(N-1)*maxVal;
gauss[i] = exp(-x*x/(2.0*sigma2)); gauss[i] = expf(-x*x/(2.0*sigma2));
} }
scaleFactor = (float)(N-1) / maxVal; scaleFactor = (float)(N-1) / maxVal;
} }
float getValue( float x ) float getValue( float x )
{ {
x = fabs( x ); x = fabs( x );
if( unlikely( x > maxVal ) ) return 0; if( unlikely( x > maxVal ) ) return 0;
return gauss[ (int)(x*scaleFactor) ]; return gauss[ (int)(x*scaleFactor) ];
} }
skipping to change at line 107 skipping to change at line 107
for( int y = 0; y < I->getRows(); y++ ) for( int y = 0; y < I->getRows(); y++ )
{ {
progress_cb( y * 100 / I->getRows() ); progress_cb( y * 100 / I->getRows() );
for( int x = 0; x < I->getCols(); x++ ) for( int x = 0; x < I->getCols(); x++ )
{ {
float val = 0; float val = 0;
float k = 0; float k = 0;
float I_s = (*X1)(x,y); //!! previously 'I' not 'X1' float I_s = (*X1)(x,y); //!! previously 'I' not 'X1'
if( unlikely( !finite( I_s ) ) ) if( unlikely( !isfinite( I_s ) ) )
I_s = 0.0f; I_s = 0.0f;
for( int py = max( 0, y - sKernelSize/2); for( int py = max( 0, y - sKernelSize/2);
py < min( I->getRows(), y + sKernelSize/2); py++ ) py < min( I->getRows(), y + sKernelSize/2); py++ )
{ {
for( int px = max( 0, x - sKernelSize/2); for( int px = max( 0, x - sKernelSize/2);
px < min( I->getCols(), x + sKernelSize/2); px++ ) px < min( I->getCols(), x + sKernelSize/2); px++ )
{ {
float I_p = (*X1)(px, py); //!! previously 'I' not 'X1' float I_p = (*X1)(px, py); //!! previously 'I' not 'X1'
if( unlikely( !finite( I_p ) ) ) if( unlikely( !isfinite( I_p ) ) )
I_p = 0.0f; I_p = 0.0f;
float mult = sKernel(px-x + sKernelSize/2, py-y + sKernelSize/2) * float mult = sKernel(px-x + sKernelSize/2, py-y + sKernelSize/2) *
gauss.getValue( I_p - I_s ); gauss.getValue( I_p - I_s );
float Ixy = (*I)(px, py); float Ixy = (*I)(px, py);
if( unlikely( !finite( Ixy ) ) ) if( unlikely( !isfinite( Ixy ) ) )
Ixy = 0.0f; Ixy = 0.0f;
val += Ixy*mult; //!! but here we want 'I' val += Ixy*mult; //!! but here we want 'I'
k += mult; k += mult;
} }
} }
//avoid division by 0 when k is close to 0 //avoid division by 0 when k is close to 0
// (*J)(x,y) = fabs(k) > 0.00000001 ? val/k : 0.; // (*J)(x,y) = fabs(k) > 0.00000001 ? val/k : 0.;
(*J)(x,y) = val/k; (*J)(x,y) = val/k;
} }
 End of changes. 7 change blocks. 
8 lines changed or deleted 8 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)