aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel/src/image.c
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2020-07-10 14:53:07 +0200
committerThomas White <taw@physics.org>2020-07-29 18:53:45 +0200
commit234ebec9ac60c645b4118004a6e95a0ff73b08ec (patch)
tree14b4cd5c9e759be9adea6cf2a5f55f95abac80ae /libcrystfel/src/image.c
parent865959d6b3adaae1f80fb50da4bebdd9b5d31830 (diff)
Unify creation of blank image data arrays
Diffstat (limited to 'libcrystfel/src/image.c')
-rw-r--r--libcrystfel/src/image.c80
1 files changed, 37 insertions, 43 deletions
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; pi<dtempl->n_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; i<p_w*p_h; i++ ) {
+ image->bad[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; pn<num_panels; pn++ ) {
-
- long int i;
- struct detgeom_panel *p = &image->detgeom->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; i<p->w*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,