aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2014-08-13 15:23:45 +0200
committerThomas White <taw@physics.org>2014-08-13 15:23:45 +0200
commit918316caca74df894193922b1e0bc132afcf6ee5 (patch)
tree3500b0503c8e320abe2c9c0856d3f753bf6986b2
parent6771d485ac6ed1bfa1cf813df8d3e45c571cdfad (diff)
Add mark_resolution_range_as_bad()
-rw-r--r--libcrystfel/src/detector.c39
-rw-r--r--libcrystfel/src/detector.h3
2 files changed, 42 insertions, 0 deletions
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; i<image->det->n_panels; i++ ) {
+
+ int fs, ss;
+ struct panel *p = &image->det->panels[i];
+
+ for ( ss=0; ss<p->h; ss++ ) {
+ for ( fs=0; fs<p->w; 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