aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2023-09-23 19:20:52 +0200
committerThomas White <taw@physics.org>2023-09-23 19:33:08 +0200
commitcee7ee0b8a4cafa1f8f3c67518f86c895520f5a6 (patch)
treee69fe9b2fda910fb0a9b2db4f5a109da73b8430a /libcrystfel
parent048fea1904c81f4682606ef410fba303b552cd07 (diff)
image_create_dp_bad_sat: Don't worry about "sat"
The saturation array is created by create_satmap when needed, which takes care that all panels get an array (so we only have to check image->sat != NULL). The array created by image_create_dp_bad_sat was actually leaked! In any case, saturation maps are rarely used. We can do without the extra allocations. The routine name has been changed accordingly, to prevent future confusion.
Diffstat (limited to 'libcrystfel')
-rw-r--r--libcrystfel/src/image.c31
-rw-r--r--libcrystfel/src/image.h4
-rw-r--r--libcrystfel/src/stream.c2
3 files changed, 9 insertions, 28 deletions
diff --git a/libcrystfel/src/image.c b/libcrystfel/src/image.c
index ee97397d..234b63c7 100644
--- a/libcrystfel/src/image.c
+++ b/libcrystfel/src/image.c
@@ -603,8 +603,8 @@ int image_set_zero_data(struct image *image,
}
-int image_create_dp_bad_sat(struct image *image,
- const DataTemplate *dtempl)
+int image_create_dp_bad(struct image *image,
+ const DataTemplate *dtempl)
{
int i;
@@ -621,49 +621,30 @@ int image_create_dp_bad_sat(struct image *image,
return 1;
}
- image->sat = malloc(dtempl->n_panels*sizeof(float *));
- if ( image->sat == NULL ) {
- ERROR("Failed to allocate saturation map\n");
- free(image->dp);
- free(image->bad);
- return 1;
- }
-
/* Set all pointers to NULL for easier clean-up */
for ( i=0; i<dtempl->n_panels; i++ ) {
image->dp[i] = NULL;
image->bad[i] = NULL;
- image->sat[i] = NULL;
}
for ( i=0; i<dtempl->n_panels; i++ ) {
- int j;
size_t nel = PANEL_WIDTH(&dtempl->panels[i]) * PANEL_HEIGHT(&dtempl->panels[i]);
image->dp[i] = malloc(nel*sizeof(float));
image->bad[i] = calloc(nel, sizeof(int));
- image->sat[i] = malloc(nel*sizeof(float));
- if ( (image->dp[i] == NULL)
- || (image->bad[i] == NULL)
- || (image->sat[i] == NULL) ) {
+ if ( (image->dp[i] == NULL) || (image->bad[i] == NULL) ) {
ERROR("Failed to allocate panel data arrays\n");
for ( i=0; i<dtempl->n_panels; i++ ) {
free(image->dp[i]);
free(image->bad[i]);
- free(image->sat[i]);
}
free(image->dp);
free(image->bad);
- free(image->sat);
return 1;
}
- for ( j=0; j<nel; j++ ) {
- image->sat[i][j] = INFINITY;
- }
-
}
return 0;
@@ -969,7 +950,7 @@ static int create_badmap(struct image *image,
{
int i;
- /* The bad pixel map array is already created (see image_create_dp_bad_sat),
+ /* The bad pixel map array is already created (see image_create_dp_bad),
* and a preliminary mask (with NaN/inf pixels marked) has already been
* created when the image data was loaded. */
@@ -1158,7 +1139,7 @@ struct image *image_create_for_simulation(const DataTemplate *dtempl)
return NULL;
}
- if ( image_create_dp_bad_sat(image, dtempl) ) {
+ if ( image_create_dp_bad(image, dtempl) ) {
image_free(image);
return NULL;
}
@@ -1199,7 +1180,7 @@ static int do_image_read(struct image *image, const DataTemplate *dtempl,
int i;
int r;
- if ( image_create_dp_bad_sat(image, dtempl) ) return 1;
+ if ( image_create_dp_bad(image, dtempl) ) return 1;
/* Load the image data */
if ( !no_image_data ) {
diff --git a/libcrystfel/src/image.h b/libcrystfel/src/image.h
index 949ac7d1..8930ffe7 100644
--- a/libcrystfel/src/image.h
+++ b/libcrystfel/src/image.h
@@ -265,8 +265,8 @@ extern ImageFeatureList *image_read_peaks(const DataTemplate *dtempl,
extern char **image_expand_frames(const DataTemplate *dtempl,
const char *filename, int *nframes);
-extern int image_create_dp_bad_sat(struct image *image,
- const DataTemplate *dtempl);
+extern int image_create_dp_bad(struct image *image,
+ const DataTemplate *dtempl);
extern int image_set_zero_data(struct image *image,
const DataTemplate *dtempl);
diff --git a/libcrystfel/src/stream.c b/libcrystfel/src/stream.c
index f58ff05e..0273c69b 100644
--- a/libcrystfel/src/stream.c
+++ b/libcrystfel/src/stream.c
@@ -902,7 +902,7 @@ struct image *stream_read_chunk(Stream *st, StreamFlags srf)
image_free(image);
return NULL;
}
- image_create_dp_bad_sat(image, st->dtempl_read);
+ image_create_dp_bad(image, st->dtempl_read);
image_set_zero_data(image, st->dtempl_read);
}
image->spectrum = spectrum_generate_gaussian(image->lambda,