--- FeatureExtraction/gabor.c 2006-08-14 01:56:25.000000000 +0000 +++ ../../dev2/gift/FeatureExtraction/gabor.c 2006-08-14 01:54:58.000000000 +0000 @@ -82,36 +82,33 @@ void gabor_filter(double *image, int width, int height, int filter_scale, int orientation, double **kernelsxy, double *output) { uint32_t x, y; - int32_t t_y; + int32_t t_x, t_y; uint32_t i; - uint32_t k; double * target_kernal; double conv[65536]; /* take advantage of our fixed image size. 65536 == width*height */ - double * target_conv; - double * target_image; for (i = 0; i < width*height; i++) { conv[i]= 0; /* needs to be zeroed */ - output[i]= 0; /* needs to be zeroed */ } - /* first convolution */ target_kernal=kernelsxy[filter_scale*num_gabors_per_scale+orientation]; + + /* first convolution */ for (x = 0; x < width; x++) { for (y = 0; y < height; y++) { - target_image=&image[(width*height)-(y*width+x+kernal_size[filter_scale]/2)]; - 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)) { + output[y*width + x] = 0; /* might as well be here */ + for (t_x = -kernal_size[filter_scale]/2; t_x <= kernal_size[filter_scale]/2; t_x++) { + if (((x - t_x) >= 0) && ((x - t_x) < width)) { conv[y*width + x] += - target_kernal[k]*target_image[k]; + target_kernal[t_x + kernal_size[filter_scale]/2]*image[65536-(y*width+ (x - t_x))]; } } } } - /* second convolution */ target_kernal=&target_kernal[kernal_size[filter_scale]]; + /* second convolution */ for (x = 0; x < width; x++) { for (y = 0; y < height; y++) { for (t_y = -kernal_size[filter_scale]/2; t_y <= kernal_size[filter_scale]/2; t_y++) { @@ -125,22 +122,21 @@ for (i = 0; i < width*height; i++) conv[i] = 0; - /* third convolution */ target_kernal=&target_kernal[kernal_size[filter_scale]]; + /* third convolution */ for (x = 0; x < width; x++) { for (y = 0; y < height; y++) { - target_image=&image[(width*height)-(y*width+x+kernal_size[filter_scale]/2)]; - 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)) { + for (t_x = -kernal_size[filter_scale]/2; t_x <= kernal_size[filter_scale]/2; t_x++) { + if (((x - t_x) >= 0) && ((x - t_x) < width)) { conv[y*width + x] += - target_kernal[k]*target_image[k]; + target_kernal[t_x + kernal_size[filter_scale]/2]*image[65536-(y*width + (x - t_x))]; } } } } - /* fourth convolution */ target_kernal=&target_kernal[kernal_size[filter_scale]]; + /* fourth convolution */ for (x = 0; x < width; x++) { for (y = 0; y < height; y++) { for (t_y = -kernal_size[filter_scale]/2; t_y <= kernal_size[filter_scale]/2; t_y++) {