--- ../../dev2/gift/FeatureExtraction/gabor.c 2006-08-14 01:54:58.000000000 +0000 +++ FeatureExtraction/gabor.c 2006-08-14 01:56:25.000000000 +0000 @@ -82,33 +82,36 @@ 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_x, t_y; + int32_t 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 */ } - target_kernal=kernelsxy[filter_scale*num_gabors_per_scale+orientation]; - /* first convolution */ + target_kernal=kernelsxy[filter_scale*num_gabors_per_scale+orientation]; for (x = 0; x < width; x++) { for (y = 0; y < height; y++) { - 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)) { + 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)) { conv[y*width + x] += - target_kernal[t_x + kernal_size[filter_scale]/2]*image[65536-(y*width+ (x - t_x))]; + target_kernal[k]*target_image[k]; } } } } - target_kernal=&target_kernal[kernal_size[filter_scale]]; /* second convolution */ + target_kernal=&target_kernal[kernal_size[filter_scale]]; 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++) { @@ -122,21 +125,22 @@ for (i = 0; i < width*height; i++) conv[i] = 0; - target_kernal=&target_kernal[kernal_size[filter_scale]]; /* third convolution */ + target_kernal=&target_kernal[kernal_size[filter_scale]]; for (x = 0; x < width; x++) { for (y = 0; y < height; y++) { - 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)) { + 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)) { conv[y*width + x] += - target_kernal[t_x + kernal_size[filter_scale]/2]*image[65536-(y*width + (x - t_x))]; + target_kernal[k]*target_image[k]; } } } } - target_kernal=&target_kernal[kernal_size[filter_scale]]; /* fourth convolution */ + target_kernal=&target_kernal[kernal_size[filter_scale]]; 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++) {