diff options
author | Thomas White <taw@physics.org> | 2011-03-08 15:24:56 +0100 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2012-02-22 15:27:18 +0100 |
commit | 5d916db27e826138312d59c9777a224e8f30771f (patch) | |
tree | cf508caf980ef174608b7035b9bf2c84f40d1ee2 /src/detector.c | |
parent | 89fd8dbe41ab7796811cf280fef2f3c79c5a1d40 (diff) |
Throw out detected peaks in bad regions
Diffstat (limited to 'src/detector.c')
-rw-r--r-- | src/detector.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/detector.c b/src/detector.c index b3ef6563..c5c56476 100644 --- a/src/detector.c +++ b/src/detector.c @@ -100,6 +100,42 @@ struct rvec get_q(struct image *image, double fs, double ss, } +int in_bad_region(struct detector *det, double fs, double ss) +{ + double rx, ry; + struct panel *p; + double xs, ys; + int i; + + /* Determine which panel to use */ + const unsigned int x = fs; + const unsigned int y = ss; + p = find_panel(det, x, y); + + /* No panel found -> definitely bad! */ + if ( p == NULL ) return 1; + + /* Convert xs and ys, which are in fast scan/slow scan coordinates, + * to x and y */ + xs = (fs-(double)p->min_fs)*p->fsx + (ss-(double)p->min_ss)*p->ssx; + ys = (fs-(double)p->min_fs)*p->fsy + (ss-(double)p->min_ss)*p->ssy; + + rx = (xs + p->cnx) / p->res; + ry = (ys + p->cny) / p->res; + + for ( i=0; i<det->n_bad; i++ ) { + struct badregion *b = &det->bad[i]; + if ( rx < b->min_x ) continue; + if ( rx > b->max_x ) continue; + if ( ry < b->min_y ) continue; + if ( ry > b->max_y ) continue; + return 1; + } + + return 0; +} + + double get_tt(struct image *image, double fs, double ss) { double r, rx, ry; |