From 0b2555c9a3656b082ef31d19194d36f13cbe80c3 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Wed, 9 Oct 2013 15:34:29 +0200 Subject: Center peaks on maximum brightness pixel over 3*background --- libcrystfel/src/integration.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'libcrystfel/src') diff --git a/libcrystfel/src/integration.c b/libcrystfel/src/integration.c index 1e02d9c9..1f2bf25b 100644 --- a/libcrystfel/src/integration.c +++ b/libcrystfel/src/integration.c @@ -954,33 +954,33 @@ static int center_and_check_box(struct intcontext *ic, struct peak_box *bx, for ( i=0; i<10; i++ ) { int p, q; - double sum_fs = 0.0; - double sum_ss = 0.0; - double den = 0.0; + double max = -INFINITY; int t_offs_fs = 0; int t_offs_ss = 0; - double offs_fs, offs_ss; - int ifs, iss; + int ifs = 0; + int iss = 0; - for ( p=0; pw; p++ ) { for ( q=0; qw; q++ ) { + for ( p=0; pw; p++ ) { - double bi = boxi(ic, bx, p, q); + double bi, bg; if ( bx->bm[p + ic->w*q] == BM_BH ) continue; - sum_fs += bi * (p-ic->halfw); - sum_ss += bi * (q-ic->halfw); - den += bi; + bi = boxi(ic, bx, p, q); + bg = bx->a*p + bx->b*q + bx->c; + + if ( bi <= 3.0*bg ) continue; + + if ( bi > max ) { + max = bi; + ifs = p - ic->halfw; + iss = q - ic->halfw; + } } } - offs_fs = sum_fs / den; - offs_ss = sum_ss / den; - - ifs = rint(offs_fs); - iss = rint(offs_ss); bx->offs_fs += ifs; bx->offs_ss += iss; bx->cfs += ifs; -- cgit v1.2.3