aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/man/crystfel_geometry.54
-rw-r--r--libcrystfel/src/datatemplate.c8
-rw-r--r--libcrystfel/src/datatemplate_priv.h3
-rw-r--r--libcrystfel/src/image.c29
4 files changed, 44 insertions, 0 deletions
diff --git a/doc/man/crystfel_geometry.5 b/doc/man/crystfel_geometry.5
index e4edf06d..2588d65c 100644
--- a/doc/man/crystfel_geometry.5
+++ b/doc/man/crystfel_geometry.5
@@ -211,6 +211,10 @@ The saturation value for the panel. You can use this to exclude saturated peaks
Mark pixels as "bad" if their values are respectively less than, more than or equal to the given value. Note carefully that the inequalities are strict, not inclusive: "less than", not "less than or equal to".
.PD 0
+.IP \fBmask_edge_pixels\fR
+Mark the specified number of pixels, at the edge of the panel, as "bad".
+
+.PD 0
.IP \fBmaskN_data\fR
.IP \fBmaskN_file\fR
.IP \fBmaskN_goodbits\fR
diff --git a/libcrystfel/src/datatemplate.c b/libcrystfel/src/datatemplate.c
index 61ef408f..26ff77c1 100644
--- a/libcrystfel/src/datatemplate.c
+++ b/libcrystfel/src/datatemplate.c
@@ -581,6 +581,13 @@ static int parse_field_for_panel(struct panel_template *panel, const char *key,
free(panel->data);
panel->data = strdup(val);
+ } else if ( strcmp(key, "mask_edge_pixels") == 0 ) {
+ if ( convert_int(val, &panel->mask_edge_pixels) ) {
+ ERROR("Invalid value for %s/mask_edge_pixels (%s)\n",
+ panel->name, val);
+ reject = 1;
+ }
+
} else if ( strcmp(key, "mask_bad") == 0 ) {
parse_field_for_panel(panel, "mask0_badbits", val, det);
} else if ( strcmp(key, "mask_good") == 0 ) {
@@ -1071,6 +1078,7 @@ DataTemplate *data_template_new_from_string(const char *string_in)
defaults.cnz_offset = 0.0;
defaults.pixel_pitch = -1.0;
defaults.bad = 0;
+ defaults.mask_edge_pixels = 0;
defaults.fsx = NAN;
defaults.fsy = NAN;
defaults.fsz = NAN;
diff --git a/libcrystfel/src/datatemplate_priv.h b/libcrystfel/src/datatemplate_priv.h
index 053e9d13..ff383705 100644
--- a/libcrystfel/src/datatemplate_priv.h
+++ b/libcrystfel/src/datatemplate_priv.h
@@ -135,6 +135,9 @@ struct panel_template
/** Mark entire panel as bad if set */
int bad;
+ /** Mark this number of edge rows as bad */
+ int mask_edge_pixels;
+
/** Resolution in pixels per metre */
double pixel_pitch;
diff --git a/libcrystfel/src/image.c b/libcrystfel/src/image.c
index d31e99b6..ce924b35 100644
--- a/libcrystfel/src/image.c
+++ b/libcrystfel/src/image.c
@@ -1027,6 +1027,29 @@ static int load_mask(struct panel_template *p,
}
+static void mask_panel_edges(int *bad, int p_w, int p_h, int edgew)
+{
+ int i;
+
+ /* Silly values should not cause memory errors */
+ if ( edgew > p_w ) edgew = p_w/2 + 1;
+ if ( edgew > p_h ) edgew = p_h/2 + 1;
+ if ( edgew < 0 ) return;
+
+ for ( i=0; i<edgew; i++ ) {
+ int fs, ss;
+ for ( fs=i; fs<p_w-i; fs++ ) {
+ bad[fs+p_w*i] = 1;
+ bad[fs+p_w*(p_h-i-1)] = 1;
+ }
+ for ( ss=i; ss<p_h-i; ss++ ) {
+ bad[i+p_w*ss] = 1;
+ bad[(p_w-i-1)+p_w*ss] = 1;
+ }
+ }
+}
+
+
static int create_badmap(struct image *image,
const DataTemplate *dtempl,
int no_mask_data)
@@ -1066,6 +1089,12 @@ static int create_badmap(struct image *image,
image->bad[i]);
}
+ /* Mask panel edges (skip if panel is bad anyway) */
+ if ( (p->mask_edge_pixels > 0) && !p->bad ) {
+ mask_panel_edges(image->bad[i], p_w, p_h,
+ p->mask_edge_pixels);
+ }
+
/* Load masks (skip if panel is bad anyway) */
if ( (!no_mask_data) && (!p->bad) ) {