aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2019-04-02 15:55:51 +0200
committerThomas White <taw@physics.org>2019-04-03 15:53:07 +0200
commit0a1a129583fdd191045df501d22a0342f612e548 (patch)
tree30ae20f574ca091c14baa8d45e3b51ddfdf36152 /libcrystfel
parente64e2ec6879410dc90c5d87f58268dd3eb2ec521 (diff)
Consider pixel as bad if its value is NaN or infinity
Diffstat (limited to 'libcrystfel')
-rw-r--r--libcrystfel/src/hdf5-file.c16
-rw-r--r--libcrystfel/src/image.c2
2 files changed, 14 insertions, 4 deletions
diff --git a/libcrystfel/src/hdf5-file.c b/libcrystfel/src/hdf5-file.c
index 9c8038ea..7a8f359e 100644
--- a/libcrystfel/src/hdf5-file.c
+++ b/libcrystfel/src/hdf5-file.c
@@ -1149,7 +1149,8 @@ static void debodge_saturation(struct hdfile *f, struct image *image)
}
-static int *make_badmask(int *flags, struct panel *p, struct detector *det)
+static int *make_badmask(int *flags, struct detector *det, float *data,
+ struct panel *p)
{
int *badmap;
int fs, ss;
@@ -1184,6 +1185,7 @@ static int *make_badmask(int *flags, struct panel *p, struct detector *det)
int f = flags[fs+p->w*ss];
int bad = badmap[fs+p->w*ss];
+ float val = data[fs+p->w*ss];
/* Bad if it's missing any of the "good" bits */
if ( (f & det->mask_good) != det->mask_good ) bad = 1;
@@ -1191,6 +1193,9 @@ static int *make_badmask(int *flags, struct panel *p, struct detector *det)
/* Bad if it has any of the "bad" bits. */
if ( f & det->mask_bad ) bad = 1;
+ /* Bad if pixel value is NaN or inf */
+ if ( isnan(val) || isinf(val) ) bad = 1;
+
badmap[fs+p->w*ss] = bad;
}
@@ -1902,13 +1907,16 @@ int hdf5_read2(struct hdfile *f, struct image *image, struct event *ev,
if ( p->mask != NULL ) {
int *flags = malloc(p->w*p->h*sizeof(int));
if ( !load_mask(f, ev, p, flags, f_offset, f_count, hsd) ) {
- image->bad[pi] = make_badmask(flags, p, image->det);
+ image->bad[pi] = make_badmask(flags, image->det,
+ image->dp[pi], p);
} else {
- image->bad[pi] = make_badmask(NULL, p, image->det);
+ image->bad[pi] = make_badmask(NULL, image->det,
+ image->dp[pi], p);
}
free(flags);
} else {
- image->bad[pi] = make_badmask(NULL, p, image->det);
+ image->bad[pi] = make_badmask(NULL, image->det,
+ image->dp[pi], p);
}
if ( p->satmap != NULL ) {
diff --git a/libcrystfel/src/image.c b/libcrystfel/src/image.c
index 63fd54f9..8c47d3cf 100644
--- a/libcrystfel/src/image.c
+++ b/libcrystfel/src/image.c
@@ -521,6 +521,8 @@ static int unpack_panels(struct image *image, float *data, int data_width,
bad = 1;
}
+ if ( isnan(data[idx]) || isinf(data[idx]) ) bad = 1;
+
if ( flags != NULL ) {
int f;