From 918316caca74df894193922b1e0bc132afcf6ee5 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Wed, 13 Aug 2014 15:23:45 +0200 Subject: Add mark_resolution_range_as_bad() --- libcrystfel/src/detector.c | 39 +++++++++++++++++++++++++++++++++++++++ libcrystfel/src/detector.h | 3 +++ 2 files changed, 42 insertions(+) diff --git a/libcrystfel/src/detector.c b/libcrystfel/src/detector.c index c86f8351..93cca896 100644 --- a/libcrystfel/src/detector.c +++ b/libcrystfel/src/detector.c @@ -1405,3 +1405,42 @@ int write_detector_geometry(const char *filename, struct detector *det) return 0; } + + +/** + * mark_resolution_range_as_bad() + * @image: An image structure + * @min: Minimum value of 1/d to be marked as bad + * @max: Maximum value of 1/d to be marked as bad + * + * Flags, in the bad pixel mask for @image, every pixel whose resolution is + * between @min and @max. + * + */ + +void mark_resolution_range_as_bad(struct image *image, + double min, double max) +{ + int i; + + STATUS("Masking %e to %e\n", min, max); + + for ( i=0; idet->n_panels; i++ ) { + + int fs, ss; + struct panel *p = &image->det->panels[i]; + + for ( ss=0; ssh; ss++ ) { + for ( fs=0; fsw; fs++ ) { + struct rvec q; + double r; + q = get_q_for_panel(p, fs, ss, NULL, 1.0/image->lambda); + r = modulus(q.u, q.v, q.w); + if ( (r >= min) && (r <= max) ) { + image->bad[i][fs+p->w*ss] = 1; + } + } + } + + } +} diff --git a/libcrystfel/src/detector.h b/libcrystfel/src/detector.h index 0fc0610a..157c2edf 100644 --- a/libcrystfel/src/detector.h +++ b/libcrystfel/src/detector.h @@ -200,6 +200,9 @@ extern struct panel *find_panel_by_name(struct detector *det, const char *name); extern int write_detector_geometry(const char *filename, struct detector *det); +extern void mark_resolution_range_as_bad(struct image *image, + double min, double max); + #ifdef __cplusplus } #endif -- cgit v1.2.3