From 20a4ae775b80f6b425a95727b08efb4c3e3226ba Mon Sep 17 00:00:00 2001 From: Thomas White Date: Thu, 7 Jan 2010 18:00:56 +0100 Subject: Pretty-much working hit finding --- src/indexamajig.c | 94 +++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 85 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/indexamajig.c b/src/indexamajig.c index 1b1620c1..69813118 100644 --- a/src/indexamajig.c +++ b/src/indexamajig.c @@ -40,11 +40,21 @@ static void show_help(const char *s) } -static int sum_of_peaks(struct image *image) +struct peak { + int x; + int y; + int i; + int invalid; +}; + + +static int image_fom(struct image *image) { int x, y; int integr, n; float fintegr, mean, sd, th; + struct peak peaks[1024]; + int i, n_peaks, n_nearby, n_valid; /* Measure mean */ integr = 0; @@ -86,8 +96,8 @@ static int sum_of_peaks(struct image *image) th = mean + 5*sd; STATUS("mean=%f ,sd=%f, th=%f\n", mean, sd, th); - /* Sum intensity above threshold */ - integr = 0; + /* Find pixels above threshold */ + n_peaks = 0; for ( x=0; x<1024; x++ ) { for ( y=600; y<1024; y++ ) { @@ -98,12 +108,78 @@ static int sum_of_peaks(struct image *image) val = image->data[x+image->height*y]; - if ( val > th ) integr+=val; + if ( val > th ) { + peaks[n_peaks].x = x; + peaks[n_peaks].y = y; + peaks[n_peaks].i = val; + peaks[n_peaks].invalid = 0; + n_peaks++; + } } } - return integr; + do { + + int max, max_i; + int adjacent; + + n_nearby = 0; + + /* Find brightest peak */ + max = 0; + for ( i=0; i max ) { + max = peaks[i].i; + max_i = i; + } + } + + /* Must be at least one adjacent bright pixel */ + adjacent = 0; + for ( i=0; i 200000 ) { + fom = image_fom(&image); + printf("%6i %i\n", n_images, fom); + if ( fom > 0 ) { STATUS("Hit: %s\n", line); -- cgit v1.2.3