From 234ebec9ac60c645b4118004a6e95a0ff73b08ec Mon Sep 17 00:00:00 2001 From: Thomas White Date: Fri, 10 Jul 2020 14:53:07 +0200 Subject: Unify creation of blank image data arrays --- libcrystfel/src/image.c | 80 +++++++++++++++++++++++-------------------------- 1 file changed, 37 insertions(+), 43 deletions(-) (limited to 'libcrystfel/src/image.c') diff --git a/libcrystfel/src/image.c b/libcrystfel/src/image.c index b41364d4..2b6f5b16 100644 --- a/libcrystfel/src/image.c +++ b/libcrystfel/src/image.c @@ -474,8 +474,8 @@ void create_detgeom(struct image *image, const DataTemplate *dtempl) } -static int zero_data_arrays(struct image *image, - const DataTemplate *dtempl) +int image_set_zero_data(struct image *image, + const DataTemplate *dtempl) { int pi; @@ -504,6 +504,40 @@ static int zero_data_arrays(struct image *image, } +int image_set_zero_mask(struct image *image, + const DataTemplate *dtempl) +{ + int pi; + + image->bad = malloc(dtempl->n_panels*sizeof(int *)); + image->sat = malloc(dtempl->n_panels*sizeof(float *)); + if ( (image->bad == NULL) || (image->sat == NULL) ) return 1; + + for ( pi=0; pin_panels; pi++ ) { + + struct panel_template *p; + int p_w, p_h; + long int i; + + p = &dtempl->panels[pi]; + p_w = p->orig_max_fs - p->orig_min_fs + 1; + p_h = p->orig_max_ss - p->orig_min_ss + 1; + + image->bad[pi] = malloc(p_w*p_h*sizeof(int)); + image->sat[pi] = malloc(p_w*p_h*sizeof(float)); + if ( image->bad[pi] == NULL ) return 1; + if ( image->sat[pi] == NULL ) return 1; + + for ( i=0; ibad[pi][i] = 0; + image->sat[pi][i] = INFINITY; + } + } + + return 0; +} + + struct image *image_read(DataTemplate *dtempl, const char *filename, const char *event, @@ -543,7 +577,7 @@ struct image *image_read(DataTemplate *dtempl, } else { - r = zero_data_arrays(image, dtempl); + r = image_set_zero_data(image, dtempl); } @@ -705,46 +739,6 @@ struct image *image_new() } -int create_blank_arrays(struct image *image) -{ - int pn; - int num_panels = image->detgeom->n_panels; - - image->dp = malloc(num_panels*sizeof(float *)); - image->bad = malloc(num_panels*sizeof(int *)); - image->sat = malloc(num_panels*sizeof(float *)); - - if ( (image->dp == NULL) || (image->bad == NULL) - || (image->sat == NULL) ) return 1; - - for ( pn=0; pndetgeom->panels[pn]; - - image->dp[pn] = malloc(p->w*p->h*sizeof(float)); - image->bad[pn] = malloc(p->w*p->h*sizeof(int)); - image->sat[pn] = malloc(p->w*p->h*sizeof(float)); - - if ( (image->dp[pn] == NULL) - || (image->bad[pn] == NULL) - || (image->sat[pn] == NULL) ) - { - return 1; - } - - for ( i=0; iw*p->h; i++ ) { - image->dp[pn][i] = 0.0; - image->bad[pn][i] = 0; - image->sat[pn][i] = INFINITY; - } - - } - - return 0; -} - - ImageFeatureList *image_read_peaks(const DataTemplate *dtempl, const char *filename, const char *event, -- cgit v1.2.3