diff options
author | Thomas White <taw@bitwiz.org.uk> | 2010-06-05 03:13:30 +0200 |
---|---|---|
committer | Thomas White <taw@bitwiz.org.uk> | 2010-06-05 03:13:30 +0200 |
commit | 3f4cf9279f0ff766448e3308d49e5cae58b6ef61 (patch) | |
tree | e408453175889068a28704b094fb796137e641e8 /src/peaks.c | |
parent | a04adfc169f312707f6f37b67b5560a829d1c98f (diff) | |
parent | b48699718c0626d3b58f576c82a0f31c47da07ec (diff) |
Merge branch 'master' of git.bitwiz.org.uk:crystfel
Diffstat (limited to 'src/peaks.c')
-rw-r--r-- | src/peaks.c | 63 |
1 files changed, 53 insertions, 10 deletions
diff --git a/src/peaks.c b/src/peaks.c index 22e12949..c6b79d25 100644 --- a/src/peaks.c +++ b/src/peaks.c @@ -133,7 +133,9 @@ static void cull_peaks(struct image *image) } -static void integrate_peak(struct image *image, int xp, int yp, +/* Returns non-zero if peak has been vetoed. + * i.e. don't use result if return value is not zero. */ +static int integrate_peak(struct image *image, int xp, int yp, float *xc, float *yc, float *intensity, int do_polar) { @@ -150,6 +152,7 @@ static void integrate_peak(struct image *image, int xp, int yp, double val, sa, pix_area, Lsq, dsq, proj_area; float tt; double phi, pa, pb, pol; + uint16_t flags; /* Circular mask */ if ( x*x + y*y > lim ) continue; @@ -157,6 +160,12 @@ static void integrate_peak(struct image *image, int xp, int yp, if ( ((x+xp)>=image->width) || ((x+xp)<0) ) continue; if ( ((y+yp)>=image->height) || ((y+yp)<0) ) continue; + /* Veto this peak if we tried to integrate in a bad region */ + if ( image->flags != NULL ) { + flags = image->flags[(x+xp)+image->width*(y+yp)]; + if ( !((flags & 0x01) && (flags & 0x04)) ) return 1; + } + p = find_panel(&image->det, x+xp, y+yp); /* Area of one pixel */ @@ -203,6 +212,8 @@ static void integrate_peak(struct image *image, int xp, int yp, *yc = (float)yp; *intensity = 0; } + + return 0; } @@ -219,6 +230,7 @@ void search_peaks(struct image *image) int nrej_hot = 0; int nrej_pro = 0; int nrej_fra = 0; + int nrej_bad = 0; int nacc = 0; data = image->data; @@ -240,6 +252,7 @@ void search_peaks(struct image *image) int sx, sy; double max; unsigned int did_something; + int r; /* Overall threshold */ if ( data[x+width*y] < 800 ) continue; @@ -313,7 +326,13 @@ void search_peaks(struct image *image) /* Centroid peak and get better coordinates. * Don't bother doing polarisation correction, because the * intensity of this peak is only an estimate at this stage. */ - integrate_peak(image, mask_x, mask_y, &fx, &fy, &intensity, 0); + r = integrate_peak(image, mask_x, mask_y, + &fx, &fy, &intensity, 0); + if ( r ) { + /* Bad region - don't detect peak */ + nrej_bad++; + continue; + } /* It is possible for the centroid to fall outside the image */ if ( (fx < 0.0) || (fx > image->width) @@ -337,8 +356,9 @@ void search_peaks(struct image *image) } } - STATUS("%i accepted, %i box, %i hot, %i proximity, %i outside frame\n", - nacc, nrej_dis, nrej_hot, nrej_pro, nrej_fra); + STATUS("%i accepted, %i box, %i hot, %i proximity, %i outside frame, " + "%i in bad regions.\n", + nacc, nrej_dis, nrej_hot, nrej_pro, nrej_fra, nrej_bad); cull_peaks(image); } @@ -492,6 +512,8 @@ void output_intensities(struct image *image, UnitCell *cell, int n_found; int n_indclose = 0; int n_foundclose = 0; + int n_veto = 0; + int n_veto_second = 0; double asx, asy, asz; double bsx, bsy, bsz; double csx, csy, csz; @@ -543,17 +565,35 @@ void output_intensities(struct image *image, UnitCell *cell, &d, &idx); if ( (f != NULL) && (d < PEAK_REALLY_CLOSE) ) { + int r; + /* f->intensity was measured on the filtered pattern, * so instead re-integrate using old coordinates. * This will produce further revised coordinates. */ - integrate_peak(image, f->x, f->y, &x, &y, &intensity, - !unpolar); + r = integrate_peak(image, f->x, f->y, &x, &y, + &intensity, !unpolar); + if ( r ) { + /* The original peak (which also went through + * integrate_peak(), but with the mangled + * image data) would have been rejected if it + * was in a bad region. Integration of the same + * peak included a bad region this time. */ + n_veto_second++; + continue; + } intensity = f->intensity; } else { - integrate_peak(image, hits[i].x, hits[i].y, - &x, &y, &intensity, !unpolar); + int r; + + r = integrate_peak(image, hits[i].x, hits[i].y, + &x, &y, &intensity, !unpolar); + if ( r ) { + /* Plain old ordinary peak veto */ + n_veto++; + continue; + } } @@ -592,9 +632,12 @@ void output_intensities(struct image *image, UnitCell *cell, printf("Peak statistics: %i peaks found by the peak search out of " "%i were close to indexed positions. " - "%i indexed positions out of %i were close to detected peaks\n", + "%i indexed positions out of %i were close to detected peaks.\n", n_foundclose, n_found, n_indclose, n_hits); - + printf("%i integrations using indexed locations were aborted because " + "they hit one or more bad pixels.\n", n_veto); + printf("%i integrations using peak search locations were aborted " + "because they hit one or more bad pixels.\n", n_veto_second); /* Blank line at end */ printf("\n"); |