diff options
author | Thomas White <taw@physics.org> | 2011-03-31 11:04:40 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2012-02-22 15:27:23 +0100 |
commit | 3bd3007d172cb71684a328aeb064a1bed8f0ff1f (patch) | |
tree | 92e39c62f9be0d15097c0b6b3bcdfac81bfbf96c /src/peaks.c | |
parent | 0636814cc2c360fd9f37a1f7fe3e2be04cee8377 (diff) |
Fix a Grand Muppetry in integrate_peak()
Diffstat (limited to 'src/peaks.c')
-rw-r--r-- | src/peaks.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/peaks.c b/src/peaks.c index 453f46e9..65002538 100644 --- a/src/peaks.c +++ b/src/peaks.c @@ -146,7 +146,8 @@ int integrate_peak(struct image *image, int cfs, int css, int do_polar, int centroid) { signed int fs, ss; - int lim, out_lim; + double lim, out_lim; + double lim_sq, out_lim_sq; double total = 0.0; double fsct = 0.0; double ssct = 0.0; @@ -160,7 +161,9 @@ int integrate_peak(struct image *image, int cfs, int css, if ( p->no_index ) return 1; lim = p->peak_sep/4.0; - out_lim = lim + 1; + out_lim = 1.0 + lim; + lim_sq = pow(lim, 2.0); + out_lim_sq = pow(out_lim, 2.0); for ( fs=-out_lim; fs<+out_lim; fs++ ) { for ( ss=-out_lim; ss<+out_lim; ss++ ) { @@ -173,7 +176,7 @@ int integrate_peak(struct image *image, int cfs, int css, int idx; /* Outer mask radius */ - if ( fs*fs + ss*ss > out_lim ) continue; + if ( fs*fs + ss*ss > out_lim_sq ) continue; if ( ((fs+cfs)>=image->width) || ((fs+cfs)<0) ) continue; if ( ((ss+css)>=image->height) || ((ss+css)<0) ) continue; @@ -201,7 +204,7 @@ int integrate_peak(struct image *image, int cfs, int css, val = image->data[idx]; /* Inner mask */ - if ( fs*fs + ss*ss > lim ) { + if ( fs*fs + ss*ss > lim_sq ) { /* Estimate noise from this region */ noise += fabs(val); noise_counts++; |