another patch set!
| Newsgroups | gmane.comp.gnu.gift.general |
|---|---|
| Message-ID | <[email protected]> |
the following are patch 81 and 82. remove some spacing problems in my last patch, change t_y into k, negative math hurts my head. added a memset() call i missed the chance to last time, reversed conv[]'s order in memory... swapped X and Y in the image stored in conv[], so as to sequentialize memory accesses. gift 0.0.15a performs a gabor filter on an image once every two seconds. once these patches are committed, the CVS version will perform a gabor filter on an image every second. 100% faster, new and improved! :) my personal tree contains another 20% speed boost (down to 0.8 seconds per image). this is all measured on a P4M 2.2Ghz machine. i like accomplishing things. :) Julia Longtin <[email protected]> _______________________________________________ help-GIFT mailing list [email protected] http://lists.gnu.org/mailman/listinfo/help-gift
81-Changelog
(text/plain, 396 B)
--- ../../dev2/gift/ChangeLog 2006-09-20 16:42:51.000000000 +0000 +++ ChangeLog 2006-09-20 20:55:52.000000000 +0000 @@ -1,3 +1,10 @@ +2006-09-20 <[email protected]> + + * FeatureExtraction/gabor.c + use one more memset. + reverse order of conv[] in memory. + swap conv[]'s x and y axis, to use in-order memory accesses. + 2006-09-19 <[email protected]> * FeatureExtraction/gabor.c
81-FeatureExtraction_gabor_c_swap_memory_order.patch
(text/plain, 2.8 KB)
--- ../../dev2/gift/FeatureExtraction/gabor.c 2006-09-20 16:42:51.000000000 +0000
+++ FeatureExtraction/gabor.c 2006-09-20 20:50:33.000000000 +0000
@@ -93,10 +93,10 @@
double conv[MAX_WIDTH*MAX_HEIGHT]; /* take advantage of our fixed image size. */
double * target_conv;
double * target_image;
- double temparray[kernal_size[2]];
+ double temparray[kernal_size[2]];
- memset(&conv, 0, MAX_WIDTH*MAX_HEIGHT*sizeof(double));
- memset(output, 0, MAX_WIDTH*MAX_HEIGHT*sizeof(double));
+ memset(&conv, 0, MAX_WIDTH*MAX_HEIGHT*sizeof(double));
+ memset(output, 0, MAX_WIDTH*MAX_HEIGHT*sizeof(double));
/* first convolution */
target_kernal=kernelsxy[filter_scale*num_gabors_per_scale+orientation];
@@ -108,13 +108,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[y*width+x] += 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[y*width + x] +=
+ conv[((width*height)-1)-(x*height+y)] +=
target_kernal[k]*target_image[k];
}
}
@@ -129,13 +129,12 @@
for (t_y = -kernal_size[filter_scale]/2; t_y <= kernal_size[filter_scale]/2; t_y++) {
if (((y - t_y) >= 0) && ((y - t_y) < height))
output[y*width + x] +=
- target_kernal[t_y + kernal_size[filter_scale]/2]*conv[(y - t_y)*width + x];
+ target_kernal[t_y + kernal_size[filter_scale]/2]*conv[((width*height)-1)-(x*height+(y - t_y))];
}
}
}
- for (i = 0; i < width*height; i++)
- conv[i] = 0;
+ memset(&conv, 0, MAX_WIDTH*MAX_HEIGHT*sizeof(double));
/* third convolution */
target_kernal=&target_kernal[kernal_size[filter_scale]];
@@ -147,13 +146,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[y*width+x] += 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[y*width + x] +=
+ conv[((width*height)-1)-(x*height+y)] +=
target_kernal[k]*target_image[k];
}
}
@@ -168,7 +167,7 @@
for (t_y = -kernal_size[filter_scale]/2; t_y <= kernal_size[filter_scale]/2; t_y++) {
if (((y - t_y) >= 0) && ((y - t_y) < height))
output[y*width + x] -=
- target_kernal[t_y + kernal_size[filter_scale]/2]*conv[(y - t_y)*width + x];
+ target_kernal[t_y + kernal_size[filter_scale]/2]*conv[((width*height)-1)-(x*height+(y - t_y))];
}
}
}
82-ChangeLog
(text/plain, 453 B)
--- ../../dev/gift/ChangeLog 2006-09-20 20:55:52.000000000 +0000 +++ ChangeLog 2006-09-20 21:33:38.000000000 +0000 @@ -1,6 +1,11 @@ 2006-09-20 <[email protected]> * FeatureExtraction/gabor.c + replace t_y with k. remove t_y and i, no longer in use. + +2006-09-20 <[email protected]> + + * FeatureExtraction/gabor.c use one more memset. reverse order of conv[] in memory. swap conv[]'s x and y axis, to use in-order memory accesses.
82-FeatureExtraction_gabor_c_remove_t_y_and_i.patch
(text/plain, 1.8 KB)
--- ../../dev/gift/FeatureExtraction/gabor.c 2006-09-20 20:50:33.000000000 +0000
+++ FeatureExtraction/gabor.c 2006-09-20 21:30:58.000000000 +0000
@@ -86,8 +86,6 @@
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;
- uint32_t i;
uint32_t k;
double * target_kernal;
double conv[MAX_WIDTH*MAX_HEIGHT]; /* take advantage of our fixed image size. */
@@ -126,10 +124,11 @@
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++) {
- if (((y - t_y) >= 0) && ((y - t_y) < height))
+ target_conv=&conv[((width*height)-1)-(x*height+y+(kernal_size[filter_scale]/2))];
+ for (k = 0; k < kernal_size[filter_scale]; k++) {
+ if (((y+(kernal_size[filter_scale]/2))>=k) && (y+(kernal_size[filter_scale]/2)<height+k))
output[y*width + x] +=
- target_kernal[t_y + kernal_size[filter_scale]/2]*conv[((width*height)-1)-(x*height+(y - t_y))];
+ target_kernal[k]*target_conv[k];
}
}
}
@@ -164,10 +163,11 @@
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++) {
- if (((y - t_y) >= 0) && ((y - t_y) < height))
+ target_conv=&conv[((width*height)-1)-(x*height+y+(kernal_size[filter_scale]/2))];
+ for (k = 0; k < kernal_size[filter_scale]; k++) {
+ if (((y+(kernal_size[filter_scale]/2))>=k) && (y+(kernal_size[filter_scale]/2)<height+k))
output[y*width + x] -=
- target_kernal[t_y + kernal_size[filter_scale]/2]*conv[((width*height)-1)-(x*height+(y - t_y))];
+ target_kernal[k]*target_conv[k];
}
}
}