aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2010-03-05 14:47:07 +0100
committerThomas White <taw@physics.org>2010-03-05 14:47:07 +0100
commitf5fb1058c747651c0f06eadfdcac6d2fd17c7264 (patch)
tree10e6db03be647668c87d5a1fac0cdd04601a51fd /src
parentac04881c50c140dbf7207363ed7e7400e186334b (diff)
Fix problems with peak integration
Diffstat (limited to 'src')
-rw-r--r--src/peaks.c17
1 files changed, 8 insertions, 9 deletions
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_x<image->width);
assert(mask_y<image->height);
@@ -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);