diff options
author | Thomas White <taw@physics.org> | 2010-06-21 17:06:20 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2012-02-22 15:26:50 +0100 |
commit | d82e45831a94cae99730ad8f7ff48b4cf8e1cfb9 (patch) | |
tree | 248361ab767b6273009f1fc98c11768cacf5441c /src | |
parent | 2ec9faae510e2eed77e60fbcf31f869a19fca9bf (diff) |
Noisy row improvements
Handle noisy pixels per panel only
Make the direction of elimination configurable
Diffstat (limited to 'src')
-rw-r--r-- | src/detector.c | 8 | ||||
-rw-r--r-- | src/detector.h | 1 | ||||
-rw-r--r-- | src/peaks.c | 67 |
3 files changed, 64 insertions, 12 deletions
diff --git a/src/detector.c b/src/detector.c index 55e9ec87..dcc5830d 100644 --- a/src/detector.c +++ b/src/detector.c @@ -248,6 +248,14 @@ struct detector *get_detector_geometry(const char *filename) det->panels[np].clen = atof(bits[2]); } else if ( strcmp(path[1], "res") == 0 ) { det->panels[np].res = atof(bits[2]); + } else if ( strcmp(path[1], "badrow_direction") == 0 ) { + det->panels[np].badrow = bits[2][0]; + if ( (det->panels[np].badrow != 'x') + && (det->panels[np].badrow != 'y') ) { + ERROR("badrow_direction must be 'x' or 'y'\n"); + ERROR("Assuming 'x'\n."); + det->panels[np].badrow = 'x'; + } } else { ERROR("Unrecognised field '%s'\n", path[1]); } diff --git a/src/detector.h b/src/detector.h index 057b70a8..92e10458 100644 --- a/src/detector.h +++ b/src/detector.h @@ -30,6 +30,7 @@ struct panel float cy; float clen; /* Camera length */ float res; /* Resolution */ + char badrow; /* 'x' or 'y' */ }; struct detector diff --git a/src/peaks.c b/src/peaks.c index a2ebeee7..161179df 100644 --- a/src/peaks.c +++ b/src/peaks.c @@ -82,8 +82,7 @@ static int is_hot_pixel(struct image *image, int x, int y) } -/* Post-processing of the peak list to remove noise */ -static void cull_peaks(struct image *image) +static int cull_peaks_in_panel(struct image *image, struct panel *p) { int i, n; int nelim = 0; @@ -98,7 +97,12 @@ static void cull_peaks(struct image *image) f = image_get_feature(image->features, i); if ( f == NULL ) continue; - /* How many peaks are in exactly the same column? */ + if ( f->x < p->min_x ) continue; + if ( f->x > p->max_x ) continue; + if ( f->y < p->min_y ) continue; + if ( f->y > p->max_y ) continue; + + /* How many peaks are in the same column? */ ncol = 0; for ( j=0; j<n; j++ ) { @@ -108,7 +112,15 @@ static void cull_peaks(struct image *image) g = image_get_feature(image->features, j); if ( g == NULL ) continue; - if ( fabs(f->y - g->y) < 2.0 ) ncol++; + + if ( p->badrow == 'x' ) { + if ( fabs(f->y - g->y) < 2.0 ) ncol++; + } else if ( p->badrow == 'y' ) { + if ( fabs(f->x - g->x) < 2.0 ) ncol++; + } else { + ERROR("Invalid badrow direction.\n"); + abort(); + } } @@ -121,15 +133,44 @@ static void cull_peaks(struct image *image) struct imagefeature *g; g = image_get_feature(image->features, j); if ( g == NULL ) continue; - if ( fabs(f->y - g->y) < 2.0 ) { - image_remove_feature(image->features, j); - nelim++; + if ( p->badrow == 'x' ) { + if ( fabs(f->y - g->y) < 2.0 ) { + image_remove_feature(image->features, + j); + nelim++; + } + } else if ( p->badrow == 'y' ) { + if ( fabs(f->x - g->x) < 2.0 ) { + image_remove_feature(image->features, + j); + nelim++; + } + } else { + ERROR("Invalid badrow direction.\n"); + abort(); } + } } - //STATUS("%i peaks eliminated\n", nelim); + return nelim; +} + + +/* Post-processing of the peak list to remove noise */ +static int cull_peaks(struct image *image) +{ + int nelim = 0; + struct panel *p; + int i; + + for ( i=0; i<image->det->n_panels; i++ ) { + p = &image->det->panels[i]; + nelim += cull_peaks_in_panel(image, p); + } + + return nelim; } @@ -247,6 +288,7 @@ void search_peaks(struct image *image) int nrej_fra = 0; int nrej_bad = 0; int nacc = 0; + int ncull; data = image->data; width = image->width; @@ -371,11 +413,12 @@ void search_peaks(struct image *image) } } - 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); + ncull = cull_peaks(image); + nacc -= ncull; - cull_peaks(image); + STATUS("%i accepted, %i box, %i hot, %i proximity, %i outside frame, " + "%i in bad regions, %i badrow culled.\n", + nacc, nrej_dis, nrej_hot, nrej_pro, nrej_fra, nrej_bad, ncull); } |