From a988540d804e46becd904e894f739423240e0937 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Thu, 21 Jan 2010 11:01:07 +0100 Subject: Filter peaks which are obviously due to common mode streaks --- src/dirax.c | 1 + src/image.c | 9 +++++++++ src/image.h | 5 +++++ src/index.c | 1 + src/peaks.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/render.c | 1 + 6 files changed, 72 insertions(+) diff --git a/src/dirax.c b/src/dirax.c index f7a4853c..8f381b8b 100644 --- a/src/dirax.c +++ b/src/dirax.c @@ -342,6 +342,7 @@ void run_dirax(struct image *image, int no_index) struct imagefeature *f; f = image_get_feature(image->features, i); + if ( f == NULL ) continue; fprintf(fh, "%10f %10f %10f %8f\n", f->rx/1e10, f->ry/1e10, f->rz/1e10, 1.0); diff --git a/src/image.c b/src/image.c index b2eaa6e3..b0869cce 100644 --- a/src/image.c +++ b/src/image.c @@ -88,6 +88,7 @@ void image_add_feature(ImageFeatureList *flist, double x, double y, flist->features[flist->n_features].parent = parent; flist->features[flist->n_features].partner = NULL; flist->features[flist->n_features].partner_d = 0.0; + flist->features[flist->n_features].valid = 1; flist->n_features++; @@ -161,5 +162,13 @@ struct imagefeature *image_get_feature(ImageFeatureList *flist, int idx) if ( flist == NULL ) return NULL; if ( idx > flist->n_features ) return NULL; + if ( flist->features[idx].valid == 0 ) return NULL; + return &flist->features[idx]; } + + +void image_remove_feature(ImageFeatureList *flist, int idx) +{ + flist->features[idx].valid = 0; +} diff --git a/src/image.h b/src/image.h index bb3ab438..ed4517ea 100644 --- a/src/image.h +++ b/src/image.h @@ -51,6 +51,9 @@ struct imagefeature { double ry; double rz; + /* Internal use only */ + int valid; + }; /* An opaque type representing a list of image features */ @@ -131,6 +134,8 @@ extern void image_feature_list_free(ImageFeatureList *flist); extern void image_add_feature(ImageFeatureList *flist, double x, double y, struct image *parent, double intensity); +extern void image_remove_feature(ImageFeatureList *flist, int idx); + extern struct imagefeature *image_feature_closest(ImageFeatureList *flist, double x, double y, double *d, int *idx); diff --git a/src/index.c b/src/index.c index f4f009bb..17756bb8 100644 --- a/src/index.c +++ b/src/index.c @@ -82,6 +82,7 @@ void index_pattern(struct image *image, int no_index, int use_dirax) struct imagefeature *f; f = image_get_feature(image->features, i); + if ( f == NULL ) continue; if ( f->y >=512 ) { /* Top half of CCD */ diff --git a/src/peaks.c b/src/peaks.c index 88a96461..96733ec2 100644 --- a/src/peaks.c +++ b/src/peaks.c @@ -214,6 +214,58 @@ 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) +{ + int i, n; + int nelim = 0; + + n = image_feature_count(image->features); + + for ( i=0; ifeatures, i); + if ( f == NULL ) continue; + + /* How many peaks are in exactly the same column? */ + ncol = 0; + for ( j=0; jfeatures, j); + if ( g == NULL ) continue; + if ( f->x == g->x ) ncol++; + + + } + + /* More than three? */ + if ( ncol <= 3 ) continue; + + /* Yes? Delete them all... */ + nelim = 0; + for ( j=0; jfeatures, j); + if ( g == NULL ) continue; + if ( f->x == g->x ) { + image_remove_feature(image->features, j); + nelim++; + } + } + + } + + STATUS("%i peaks eliminated\n", nelim); +} + + void search_peaks(struct image *image) { int x, y, width, height; @@ -322,6 +374,8 @@ void search_peaks(struct image *image) } } + + cull_peaks(image); } @@ -338,6 +392,7 @@ void dump_peaks(struct image *image) struct imagefeature *f; f = image_get_feature(image->features, i); + if ( f == NULL ) continue; x = f->x; y = f->y; diff --git a/src/render.c b/src/render.c index a946822e..842c1b86 100644 --- a/src/render.c +++ b/src/render.c @@ -101,6 +101,7 @@ static void show_marked_features(struct image *image, guchar *data, double th; f = image_get_feature(image->features, i); + if ( f == NULL ) continue; x = f->x; y = f->y; -- cgit v1.2.3