aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel/src/hdf5-file.c
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2016-10-10 16:51:50 +0200
committerThomas White <taw@physics.org>2016-10-10 16:51:50 +0200
commit31235652b5cf1c1f040c762c707a5c869a3722de (patch)
tree99f841a6b811ef096fd6f34e8d0d2175917b993d /libcrystfel/src/hdf5-file.c
parent89ff2319f1875ac73ec30fc89c837cf2715d4d8e (diff)
Fix bad regions
Previously, this was broken when not using a mask
Diffstat (limited to 'libcrystfel/src/hdf5-file.c')
-rw-r--r--libcrystfel/src/hdf5-file.c29
1 files changed, 20 insertions, 9 deletions
diff --git a/libcrystfel/src/hdf5-file.c b/libcrystfel/src/hdf5-file.c
index a9a85ce3..6542b360 100644
--- a/libcrystfel/src/hdf5-file.c
+++ b/libcrystfel/src/hdf5-file.c
@@ -1049,11 +1049,11 @@ static int *make_badmask(int *flags, struct panel *p, struct detector *det)
return NULL;
}
+ /* Defaults, then bad pixels arising from bad regions or panels */
for ( ss=0; ss<p->h; ss++ ) {
for ( fs=0; fs<p->w; fs++ ) {
int bad = 0;
- int f;
if ( p->no_index ) bad = 1;
@@ -1061,17 +1061,28 @@ static int *make_badmask(int *flags, struct panel *p, struct detector *det)
bad = 1;
}
- f = flags[fs+p->w*ss];
+ badmap[fs+p->w*ss] = bad;
+ }
+ }
- /* Bad if it's missing any of the "good" bits */
- if ( (f & det->mask_good) != det->mask_good ) bad = 1;
+ /* Bad pixels from mask */
+ if ( flags != NULL ) {
+ for ( ss=0; ss<p->h; ss++ ) {
+ for ( fs=0; fs<p->w; fs++ ) {
- /* Bad if it has any of the "bad" bits. */
- if ( f & det->mask_bad ) bad = 1;
+ int f = flags[fs+p->w*ss];
+ int bad = badmap[fs+p->w*ss];
- badmap[fs+p->w*ss] = bad;
+ /* Bad if it's missing any of the "good" bits */
+ if ( (f & det->mask_good) != det->mask_good ) bad = 1;
- }
+ /* Bad if it has any of the "bad" bits. */
+ if ( f & det->mask_bad ) bad = 1;
+
+ badmap[fs+p->w*ss] = bad;
+
+ }
+ }
}
return badmap;
@@ -1722,7 +1733,7 @@ int hdf5_read2(struct hdfile *f, struct image *image, struct event *ev,
image->bad[pi] = make_badmask(flags, p, image->det);
free(flags);
} else {
- image->bad[pi] = calloc(p->w*p->h, sizeof(int));
+ image->bad[pi] = make_badmask(NULL, p, image->det);
}
if ( p->satmap != NULL ) {