Commit 0ce14ba4 authored by Thomas White's avatar Thomas White
Browse files

More fussiness

parent eedb9e2a
......@@ -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;
......
......@@ -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 {
......
......@@ -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);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment