aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2010-01-21 11:01:07 +0100
committerThomas White <taw@physics.org>2010-01-21 11:06:04 +0100
commita988540d804e46becd904e894f739423240e0937 (patch)
tree24d237b2e466843e5bf30e0a784b0649c8a011a0 /src
parent4f8424fd5406cdfd05a38b101f386fd6d57a2d8a (diff)
Filter peaks which are obviously due to common mode streaks
Diffstat (limited to 'src')
-rw-r--r--src/dirax.c1
-rw-r--r--src/image.c9
-rw-r--r--src/image.h5
-rw-r--r--src/index.c1
-rw-r--r--src/peaks.c55
-rw-r--r--src/render.c1
6 files changed, 72 insertions, 0 deletions
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; i<n; i++ ) {
+
+ struct imagefeature *f;
+ int j, ncol;
+
+ f = image_get_feature(image->features, i);
+ if ( f == NULL ) continue;
+
+ /* How many peaks are in exactly the same column? */
+ ncol = 0;
+ for ( j=0; j<n; j++ ) {
+
+ struct imagefeature *g;
+
+ if ( i==j ) continue;
+
+ g = image_get_feature(image->features, 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; j<n; j++ ) {
+ struct imagefeature *g;
+ g = image_get_feature(image->features, 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;