--- ../../dev2/gift/FeatureExtraction/gabor.c 2006-11-15 07:55:50.000000000 -0600 +++ FeatureExtraction/gabor.c 2006-11-15 08:03:00.000000000 -0600 @@ -1,6 +1,7 @@ #include #include #include +/* for M_PI */ #include /* for memset(), others */ #include @@ -9,7 +10,7 @@ #include "gabor.h" -/* for uint32_t */ +/* for uint_fast32_t, int_fast32_t */ #include /* note that all this is taken from the paper JaH98 in ~/tex/bib/squizz.bib */ @@ -69,13 +70,13 @@ x_c = kernal_size[i]/2; /* since sizes are odd, this gives the centre value */ - kernelsxy[(i*num_gabors_per_scale+j)] = (double *)malloc(kernal_size[i]*sizeof(double)*4); + kernelsxy[i*num_gabors_per_scale+j] = (double *)malloc(kernal_size[i]*sizeof(double)*4); for (x = 0; x < kernal_size[i]; x++) { /* note that x is "y" for kernels 12 and 22 */ - kernelsxy[(i*num_gabors_per_scale+j)][x] = (1/(sqrt(2*M_PI)*sigma)*exp(-sq((x - x_c))/(2*sq(sigma)))*cos(2*M_PI*u*(x - x_c))); - kernelsxy[(i*num_gabors_per_scale+j)][x+kernal_size[i]] = (1/(sqrt(2*M_PI)*sigma)*exp(-sq((x - x_c))/(2*sq(sigma)))*cos(2*M_PI*v*(x - x_c))); - kernelsxy[(i*num_gabors_per_scale+j)][x+kernal_size[i]*2] = (1/(sqrt(2*M_PI)*sigma)*exp(-sq((x - x_c))/(2*sq(sigma)))*sin(2*M_PI*u*(x - x_c))); - kernelsxy[(i*num_gabors_per_scale+j)][x+kernal_size[i]*3] = (1/(sqrt(2*M_PI)*sigma)*exp(-sq((x - x_c))/(2*sq(sigma)))*sin(2*M_PI*v*(x - x_c))); + kernelsxy[i*num_gabors_per_scale+j][x] = (1/(sqrt(2*M_PI)*sigma)*exp(-sq((x - x_c))/(2*sq(sigma)))*cos(2*M_PI*u*(x - x_c))); + kernelsxy[i*num_gabors_per_scale+j][x+kernal_size[i]] = (1/(sqrt(2*M_PI)*sigma)*exp(-sq((x - x_c))/(2*sq(sigma)))*cos(2*M_PI*v*(x - x_c))); + kernelsxy[i*num_gabors_per_scale+j][x+kernal_size[i]*2] = (1/(sqrt(2*M_PI)*sigma)*exp(-sq((x - x_c))/(2*sq(sigma)))*sin(2*M_PI*u*(x - x_c))); + kernelsxy[i*num_gabors_per_scale+j][x+kernal_size[i]*3] = (1/(sqrt(2*M_PI)*sigma)*exp(-sq((x - x_c))/(2*sq(sigma)))*sin(2*M_PI*v*(x - x_c))); } } u0 = u0/2; @@ -103,13 +104,13 @@ for (k = 0; k < kernal_size[filter_scale]; k++) temparray[k]= target_kernal[k]*target_image[k]; for (k = 0; k < kernal_size[filter_scale]; k++) - conv[((width*height)-1)-(x*height+y)] += temparray[k]; + conv[(width*height-1)-(x*height+y)] += temparray[k]; } else { for (k=0; k < kernal_size[filter_scale]; k++) { if ((x+kernal_size[filter_scale]/2 >= k) && (x+kernal_size[filter_scale]/2 < width+k)) { - conv[((width*height)-1)-(x*height+y)] += + conv[(width*height-1)-(x*height+y)] += target_kernal[k]*target_image[k]; } } @@ -121,7 +122,7 @@ target_kernal=&target_kernal[kernal_size[filter_scale]]; for (x = 0; x < width; x++) { for (y = 0; y < height; y++) { - target_conv=&conv[((width*height)-1)-(x*height+y+(kernal_size[filter_scale]/2))]; + target_conv=&conv[(width*height-1)-(x*height+y+(kernal_size[filter_scale]/2))]; if (((y>=kernal_size[filter_scale]/2)) && ((y+kernal_size[filter_scale]/2)= k) && (x+kernal_size[filter_scale]/2 < width+k)) { - conv2[((width*height)-1)-(x*height+y)] += + conv2[(width*height-1)-(x*height+y)] += target_kernal[k]*target_image[k]; } } @@ -169,7 +170,7 @@ target_kernal=&target_kernal[kernal_size[filter_scale]]; for (x = 0; x < width; x++) { for (y = 0; y < height; y++) { - target_conv=&conv2[((width*height)-1)-(x*height+y+(kernal_size[filter_scale]/2))]; + target_conv=&conv2[(width*height-1)-(x*height+y+(kernal_size[filter_scale]/2))]; if (((y>=kernal_size[filter_scale]/2)) && ((y+kernal_size[filter_scale]/2)