From f5fb1058c747651c0f06eadfdcac6d2fd17c7264 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Fri, 5 Mar 2010 14:47:07 +0100 Subject: Fix problems with peak integration --- src/peaks.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'src/peaks.c') diff --git a/src/peaks.c b/src/peaks.c index 7e368100..49537e79 100644 --- a/src/peaks.c +++ b/src/peaks.c @@ -285,8 +285,8 @@ static void integrate_peak(struct image *image, int xp, int yp, /* Circular mask */ if ( x*x + y*y > lim ) continue; - if ( (x>=image->width) || (x<0) ) continue; - if ( (y>=image->height) || (y<0) ) continue; + if ( ((x+xp)>=image->width) || ((x+xp)<0) ) continue; + if ( ((y+yp)>=image->height) || ((y+yp)<0) ) continue; val = image->data[(x+xp)+image->width*(y+yp)]; @@ -382,6 +382,9 @@ void search_peaks(struct image *image) double d; int idx; + float x = 0.0; + float y = 0.0; + float intensity = 0.0; assert(mask_xwidth); assert(mask_yheight); @@ -394,19 +397,15 @@ void search_peaks(struct image *image) /* Isolated hot pixel? */ if ( is_hot_pixel(image, mask_x, mask_y) ) continue; + integrate_peak(image, mask_x, mask_y, + &x, &y, &intensity); + /* Check for a nearby feature */ image_feature_closest(image->features, mask_x, mask_y, &d, &idx); if ( d > 15.0 ) { - float x = 0.0; - float y = 0.0; - float intensity = 0.0; - - integrate_peak(image, mask_x, mask_y, - &x, &y, &intensity); - image_add_feature(image->features, x, y, image, intensity); -- cgit v1.2.3