aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2012-06-21 12:20:11 +0200
committerThomas White <taw@physics.org>2012-06-21 12:20:11 +0200
commit0ce14ba49cd6150e09a9dd32ea3451e3e47f16bf (patch)
tree3cf05a908578cc2f4eddacc4bc805d3cdd966c1b
parenteedb9e2a4a4305e89344453ff890c3b2a844b2ee (diff)
More fussiness
-rw-r--r--libcrystfel/src/peaks.c36
-rw-r--r--libcrystfel/src/reflist.c5
-rw-r--r--src/indexamajig.c1
3 files changed, 22 insertions, 20 deletions
diff --git a/libcrystfel/src/peaks.c b/libcrystfel/src/peaks.c
index 3ae7de8e..99a12ae5 100644
--- a/libcrystfel/src/peaks.c
+++ b/libcrystfel/src/peaks.c
@@ -146,14 +146,18 @@ static int cull_peaks(struct image *image)
return nelim;
}
+
static unsigned char *make_BgMask(struct image *image, struct panel *p,
double ir_out, int cfs, int css, double ir_in)
{
Reflection *refl;
RefListIterator *iter;
unsigned char *mask;
+ int w, h;
- mask = calloc(4*ir_out*ir_out, sizeof(unsigned char));
+ w = p->max_fs - p->min_fs + 1;
+ h = p->max_ss - p->min_ss + 1;
+ mask = calloc(w*h, sizeof(unsigned char));
if ( mask == NULL ) return NULL;
/* Loop over all reflections */
@@ -163,6 +167,7 @@ static unsigned char *make_BgMask(struct image *image, struct panel *p,
{
struct panel *p2;
double pk2_fs, pk2_ss;
+ signed int fs, ss;
get_detector_pos(refl, &pk2_fs, &pk2_ss);
@@ -170,31 +175,25 @@ static unsigned char *make_BgMask(struct image *image, struct panel *p,
p2 = find_panel(image->det, pk2_fs, pk2_ss);
if ( p2 != p ) continue;
- /* If other peak area overlaps larger bg area, set mask */
- if ( (fabs(pk2_fs-cfs)<ir_out+ir_in)
- && (fabs(pk2_ss-css)<ir_out+ir_in) ) {
-
- signed int fs, ss;
+ for ( fs=-ir_in; fs<=ir_in; fs++ ) {
+ for ( ss=-ir_in; ss<=ir_in; ss++ ) {
- for ( fs=-ir_out; fs<=ir_out; fs++ ) {
- for ( ss=-ir_out; ss<=ir_out; ss++ ) {
+ double d_fs, d_ss, distSq;
- double d_fs, d_ss, distSq;
+ d_fs = cfs + fs;
+ d_ss = css + ss;
+ distSq = d_fs*d_fs + d_ss*d_ss;
- d_fs = cfs + fs - pk2_fs;
- d_ss = css + ss - pk2_ss;
- distSq = d_fs*d_fs + d_ss*d_ss;
+ if ( distSq < ir_in*ir_in ) {
- if ( distSq < ir_in*ir_in ) {
+ int idx;
+ idx = fs+ir_out+2*ir_out*(ss+ir_out);
+ mask[idx] = 1;
- int idx;
- idx = fs+ir_out+2*ir_out*(ss+ir_out);
- mask[idx] = 1;
- }
- }
}
}
+ }
}
@@ -224,7 +223,6 @@ static int integrate_peak(struct image *image, int cfs, int css,
double aduph;
unsigned char *bgPkMask;
-
p = find_panel(image->det, cfs, css);
if ( p == NULL ) return 1;
if ( p->no_index ) return 1;
diff --git a/libcrystfel/src/reflist.c b/libcrystfel/src/reflist.c
index cea25bf3..64154774 100644
--- a/libcrystfel/src/reflist.c
+++ b/libcrystfel/src/reflist.c
@@ -900,6 +900,7 @@ struct _reflistiterator {
**/
Reflection *first_refl(RefList *list, RefListIterator **piter)
{
+ Reflection *refl;
RefListIterator *iter;
iter = malloc(sizeof(struct _reflistiterator));
@@ -908,7 +909,9 @@ Reflection *first_refl(RefList *list, RefListIterator **piter)
iter->stack_ptr = 0;
*piter = iter;
- Reflection *refl = list->head;
+ if ( list == NULL ) return NULL;
+
+ refl = list->head;
do {
diff --git a/src/indexamajig.c b/src/indexamajig.c
index 8c073e2c..c3e1bedf 100644
--- a/src/indexamajig.c
+++ b/src/indexamajig.c
@@ -264,6 +264,7 @@ static void process_image(void *pp, int cookie)
image.data = NULL;
image.flags = NULL;
image.indexed_cell = NULL;
+ image.reflections = NULL;
image.id = cookie;
image.filename = filename;
image.det = copy_geom(pargs->static_args.det);