diff options
author | Thomas White <taw@physics.org> | 2020-03-19 15:32:15 +0100 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2020-07-29 18:42:57 +0200 |
commit | 8d9a3b7167960045b22566d095e73588b13da3b6 (patch) | |
tree | 2dcbe7ad5b200fdef990866eab4314949a0e1d49 /libcrystfel/src | |
parent | ca980fa6f060a7cde5e0a89882f4aefec2c0227b (diff) |
Remove bad pixel mask stuff from unpack_panels_dtempl and image_read_hdf5
Will be replaced shortly by dedicated routines
Diffstat (limited to 'libcrystfel/src')
-rw-r--r-- | libcrystfel/src/image.c | 70 |
1 files changed, 6 insertions, 64 deletions
diff --git a/libcrystfel/src/image.c b/libcrystfel/src/image.c index 0e820224..628ae543 100644 --- a/libcrystfel/src/image.c +++ b/libcrystfel/src/image.c @@ -1306,17 +1306,8 @@ static int unpack_panels_dtempl(struct image *image, { int pi; - /* FIXME: Load these masks from an HDF5 file, if filenames are - * given in the geometry file */ - uint16_t *flags = NULL; - float *sat = NULL; - image->dp = malloc(dtempl->n_panels * sizeof(float *)); - image->bad = malloc(dtempl->n_panels * sizeof(int *)); - image->sat = malloc(dtempl->n_panels * sizeof(float *)); - if ( (image->dp == NULL) || (image->bad == NULL) - || (image->sat == NULL) ) - { + if ( image->dp == NULL ) { ERROR("Failed to allocate panels.\n"); return 1; } @@ -1331,11 +1322,7 @@ static int unpack_panels_dtempl(struct image *image, p_w = p->orig_max_fs - p->orig_min_fs + 1; p_h = p->orig_max_ss - p->orig_min_ss + 1; image->dp[pi] = malloc(p_w*p_h*sizeof(float)); - image->bad[pi] = calloc(p_w*p_h, sizeof(int)); - image->sat[pi] = malloc(p_w*p_h*sizeof(float)); - if ( (image->dp[pi] == NULL) || (image->bad[pi] == NULL) - || (image->sat[pi] == NULL) ) - { + if ( image->dp[pi] == NULL ) { ERROR("Failed to allocate panel\n"); return 1; } @@ -1353,7 +1340,6 @@ static int unpack_panels_dtempl(struct image *image, int idx; int cfs, css; - int bad = 0; cfs = fs+p->orig_min_fs; css = ss+p->orig_min_ss; @@ -1361,36 +1347,6 @@ static int unpack_panels_dtempl(struct image *image, image->dp[pi][fs+p_w*ss] = data[idx]; - if ( sat != NULL ) { - image->sat[pi][fs+p_w*ss] = sat[idx]; - } else { - image->sat[pi][fs+p_w*ss] = INFINITY; - } - - if ( p->bad ) bad = 1; - - //if ( in_bad_region(image->det, p, cfs, css) ) { - // bad = 1; - //} - - if ( isnan(data[idx]) || isinf(data[idx]) ) bad = 1; - - if ( flags != NULL ) { - - int f; - - f = flags[idx]; - - /* Bad if it's missing any of the "good" bits */ - if ( (f & image->det->mask_good) - != image->det->mask_good ) bad = 1; - - /* Bad if it has any of the "bad" bits. */ - if ( f & image->det->mask_bad ) bad = 1; - - } - image->bad[pi][fs+p_w*ss] = bad; - } } @@ -1399,6 +1355,7 @@ static int unpack_panels_dtempl(struct image *image, return 0; } + static struct image *image_read_hdf5(DataTemplate *dtempl, const char *filename, const char *event) { @@ -1436,10 +1393,8 @@ static struct image *image_read_hdf5(DataTemplate *dtempl, const char *filename, } image->dp = malloc(dtempl->n_panels*sizeof(float *)); - image->bad = malloc(dtempl->n_panels*sizeof(int *)); - image->sat = malloc(dtempl->n_panels*sizeof(float *)); - if ( (image->dp==NULL) || (image->bad==NULL) || (image->sat==NULL) ) { - ERROR("Failed to allocate data arrays.\n"); + if ( image->dp==NULL ) { + ERROR("Failed to allocate data array.\n"); free_event(ev); H5Fclose(fh); free(image); @@ -1543,29 +1498,19 @@ static struct image *image_read_hdf5(DataTemplate *dtempl, const char *filename, memspace = H5Screate_simple(2, dims, NULL); image->dp[pi] = malloc(dims[0]*dims[1]*sizeof(float)); - image->sat[pi] = malloc(dims[0]*dims[1]*sizeof(float)); - image->bad[pi] = calloc(dims[0]*dims[1], sizeof(int)); - if ( (image->dp[pi] == NULL) - || (image->sat[pi] == NULL) - || (image->bad[pi] == NULL) ) - { + if ( image->dp[pi] == NULL ) { ERROR("Failed to allocate panel %s\n", p->name); free(f_offset); free(f_count); for ( i=0; i<=pi; i++ ) { free(image->dp[i]); - free(image->sat[i]); - free(image->bad[i]); } free(image->dp); - free(image->bad); - free(image->sat); free_event(ev); H5Fclose(fh); free(image); return NULL; } - for ( i=0; i<dims[0]*dims[1]; i++ ) image->sat[pi][i] = INFINITY; r = H5Dread(dh, H5T_NATIVE_FLOAT, memspace, dataspace, H5P_DEFAULT, image->dp[pi]); @@ -1576,11 +1521,8 @@ static struct image *image_read_hdf5(DataTemplate *dtempl, const char *filename, free(f_count); for ( i=0; i<=pi; i++ ) { free(image->dp[i]); - free(image->sat[i]); } free(image->dp); - free(image->bad); - free(image->sat); free_event(ev); H5Fclose(fh); free(image); |