From 469518a4cc84348e859e226a8b4d9ef7d7a1479b Mon Sep 17 00:00:00 2001 From: Thomas White Date: Wed, 20 Jun 2012 16:00:17 +0200 Subject: Fussiness --- libcrystfel/src/peaks.c | 75 +++++++++++++++++++++++++++---------------------- 1 file changed, 42 insertions(+), 33 deletions(-) diff --git a/libcrystfel/src/peaks.c b/libcrystfel/src/peaks.c index 35cc1f96..e541ec47 100644 --- a/libcrystfel/src/peaks.c +++ b/libcrystfel/src/peaks.c @@ -145,53 +145,62 @@ static int cull_peaks(struct image *image) return nelim; } -static void make_BgMask(struct image *image, unsigned char *mask, - double ir_out, int cfs, int css, double ir_in, - struct panel *p) +static unsigned char *make_BgMask(struct image *image, struct panel *p, + double ir_out, int cfs, int css, double ir_in) { - signed int fs, ss; - RefList *list = image->reflections; Reflection *refl; RefListIterator *iter; - double pk2_fs, pk2_ss; - double d_fs, d_ss, distSq; - double limSq = ir_in*ir_in; - struct panel *p2; + unsigned char *mask; - if (num_reflections(list)==0) return; + mask = calloc(4*ir_out*ir_out, sizeof(unsigned char)); + if ( mask == NULL ) return NULL; /* Loop over all reflections */ - for ( refl = first_refl(list, &iter); - refl != NULL; - refl = next_refl(refl, iter) ) + for ( refl = first_refl(image->reflections, &iter); + refl != NULL; + refl = next_refl(refl, iter) ) { + struct panel *p2; + double pk2_fs, pk2_ss; + + get_detector_pos(refl, &pk2_fs, &pk2_ss); + + /* Determine if reflection is in the same panel */ + p2 = find_panel(image->det, pk2_fs, pk2_ss); + if ( p2 != p ) continue; + + /* If other peak area overlaps larger bg area, set mask */ + if ( (fabs(pk2_fs-cfs)det, pk2_fs, pk2_ss); - if ( p2 != p ) continue; + double d_fs, d_ss, distSq; - /* If other peak area overlaps larger bg area, color in the mask */ - if (fabs(pk2_fs-cfs)det, cfs, css); if ( p == NULL ) return 1; if ( p->no_index ) return 1; - /* Call function to block regions where there is expected to be a peak */ - make_BgMask(image, bgPkMask, ir_out, cfs, css, ir_inn, p); + /* Determine regions where there is expected to be a peak */ + bgPkMask = make_BgMask(image, p, ir_out, cfs, css, ir_inn); + if ( bgPkMask == NULL ) return 1; aduph = p->adu_per_eV * ph_lambda_to_eV(image->lambda); -- cgit v1.2.3