From 93e57e1aa3088a21c750ddef9fd4d6ae219097db Mon Sep 17 00:00:00 2001 From: Thomas White Date: Fri, 20 Aug 2010 17:11:11 +0200 Subject: Use a faster integration when matching templates --- src/templates.c | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/templates.c b/src/templates.c index 943ddbd0..dbdfe21b 100644 --- a/src/templates.c +++ b/src/templates.c @@ -25,6 +25,9 @@ #include +#define INTEGRATION_SQUARE_SIDE (10) + + /* Private data for template indexing */ struct _indexingprivate_template { @@ -179,6 +182,27 @@ IndexingPrivate *generate_templates(UnitCell *cell, const char *filename, } +static int fast_integrate_peak(struct image *image, int xp, int yp) +{ + int x, y; + double total = 0; + int r = INTEGRATION_SQUARE_SIDE; + + for ( x=xp-r; x<=xp+r; x++ ) { + for ( y=yp-r; y<=yp+r; y++ ) { + + if ( (x>=image->width) || (x<0) ) continue; + if ( (y>=image->height) || (y<0) ) continue; + + total += image->data[x+image->width*y]; + + } + } + + return total; +} + + static double integrate_all_rot(struct image *image, struct reflhit *hits, int n, double rot) { @@ -187,16 +211,12 @@ static double integrate_all_rot(struct image *image, struct reflhit *hits, for ( i=0; i