diff options
-rw-r--r-- | src/detector.c | 36 | ||||
-rw-r--r-- | src/detector.h | 2 | ||||
-rw-r--r-- | src/peaks.c | 13 |
3 files changed, 43 insertions, 8 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; diff --git a/src/detector.h b/src/detector.h index 4c849a77..6570ef50 100644 --- a/src/detector.h +++ b/src/detector.h @@ -80,6 +80,8 @@ extern struct rvec get_q(struct image *image, double fs, double ss, extern double get_tt(struct image *image, double xs, double ys); +extern int in_bad_region(struct detector *det, double fs, double ss); + extern void record_image(struct image *image, int do_poisson); extern struct panel *find_panel(struct detector *det, int x, int y); diff --git a/src/peaks.c b/src/peaks.c index d7e202ee..65bf01fb 100644 --- a/src/peaks.c +++ b/src/peaks.c @@ -47,14 +47,6 @@ #define PEAK_WINDOW_SIZE (10) -static int in_streak(int x, int y) -{ - if ( (y>512) && (y<600) && (abs(x-489)<15) ) return 1; - if ( (y>600) && (abs(x-480)<25) ) return 1; - return 0; -} - - static int is_hot_pixel(struct image *image, int x, int y) { int dx, dy; @@ -386,6 +378,11 @@ static void search_peaks_in_panel(struct image *image, float threshold, continue; } + if ( in_bad_region(image->det, f_fs, f_ss) ) { + nrej_bad++; + continue; + } + /* It is possible for the centroid to fall outside the image */ if ( (f_fs < p->min_fs) || (f_fs > p->max_fs) || (f_ss < p->min_ss) || (f_ss > p->max_ss) ) { |