From e1211cba640110a5336e395c6d2319cf7c83de0e Mon Sep 17 00:00:00 2001 From: Thomas White Date: Tue, 24 Aug 2010 18:40:07 +0200 Subject: Integrate (for template matching) only when over a threshold --- src/templates.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/templates.c') diff --git a/src/templates.c b/src/templates.c index 99369cd5..879fb8b8 100644 --- a/src/templates.c +++ b/src/templates.c @@ -26,6 +26,7 @@ #define INTEGRATION_SQUARE_SIDE (10) +#define THRESHOLD (500) /* Private data for template indexing */ @@ -207,10 +208,15 @@ static int fast_integrate_peak(struct image *image, int xp, int yp) for ( x=xp-r; x<=xp+r; x++ ) { for ( y=yp-r; y<=yp+r; y++ ) { + int val; + if ( (x>=image->width) || (x<0) ) continue; if ( (y>=image->height) || (y<0) ) continue; - total += image->data[x+image->width*y]; + val = image->data[x+image->width*y]; + + if ( val < THRESHOLD ) continue; + total += val; } } @@ -273,7 +279,10 @@ void match_templates(struct image *image, IndexingPrivate *ipriv) tot = 0.0; for ( i=0; i<(image->width*image->height); i++ ) { - tot += image->data[i]; + int val; + val = image->data[i]; + if ( val < THRESHOLD ) continue; + tot += val; } STATUS("%i (%.2f, %.2f, %.2f): %.2f%%\n", max_i, -- cgit v1.2.3