diff options
author | Thomas White <taw@bitwiz.org.uk> | 2010-03-28 13:41:34 +0200 |
---|---|---|
committer | Thomas White <taw@bitwiz.org.uk> | 2010-03-28 13:41:34 +0200 |
commit | bedc04ff825009d29abd6a3ac1cd1149db2cecc3 (patch) | |
tree | 0f3dd75a1b20e5d1f5d3b434f19a417d9fcf1ebe /src | |
parent | fede813224e32f690ba22c7f0a1f22d05b1de8a3 (diff) |
Remove image_fom()
Diffstat (limited to 'src')
-rw-r--r-- | src/peaks.c | 151 | ||||
-rw-r--r-- | src/peaks.h | 2 |
2 files changed, 0 insertions, 153 deletions
diff --git a/src/peaks.c b/src/peaks.c index a76ed78f..00e1cbdd 100644 --- a/src/peaks.c +++ b/src/peaks.c @@ -54,157 +54,6 @@ static int in_streak(int x, int y) } -struct peak { - int x; - int y; - int i; - int invalid; -}; - - -int image_fom(struct image *image) -{ - int x, y; - int integr, n; - float fintegr, mean, sd, th; - struct peak *peaks; - int i, n_peaks, n_nearby, n_valid; - - peaks = malloc(MAX_PEAKS * sizeof(struct peak)); - - /* Measure mean */ - integr = 0; - n = 0; - for ( x=0; x<1024; x++ ) { - for ( y=600; y<1024; y++ ) { - - int val; - if ( (x>400) && (x<600) ) continue; - val = image->data[x+image->height*y]; - if ( val < 0 ) continue; - integr += val; - n++; - - } - } - mean = (float)integr / n; /* As integer to keep maths fast */ - - /* Standard deviation */ - fintegr = 0; - for ( x=0; x<1024; x++ ) { - for ( y=600; y<1024; y++ ) { - - float val; - - if ( (x>400) && (x<600) ) continue; - val = (float)image->data[x+image->height*y]; - if ( val < 0 ) continue; - - val -= mean; - val = powf(val, 2.0); - fintegr += val; - - } - } - sd = sqrtf(fintegr / n); - - /* Threshold */ - th = mean + 5*sd; - - /* Find pixels above threshold */ - n_peaks = 0; - for ( x=0; x<1024; x++ ) { - for ( y=600; y<1024; y++ ) { - - int val; - - /* Chop out streaky region */ - if ( (x>400) && (x<600) ) continue; - - val = image->data[x+image->height*y]; - - if ( val > th ) { - if ( n_peaks < MAX_PEAKS ) { - peaks[n_peaks].x = x; - peaks[n_peaks].y = y; - peaks[n_peaks].i = val; - peaks[n_peaks].invalid = 0; - n_peaks++; - } - } - - } - } - if ( n_peaks < 1 ) return 0; - - do { - - int max, max_i = -1; - int adjacent; - - n_nearby = 0; - - /* Find brightest peak */ - max = 0; - for ( i=0; i<n_peaks; i++ ) { - if ( peaks[i].i > max ) { - max = peaks[i].i; - max_i = i; - } - } - - /* Must be at least one adjacent bright pixel */ - adjacent = 0; - for ( i=0; i<n_peaks; i++ ) { - - int td; - - td = abs(peaks[i].x - peaks[max_i].x) + - abs(peaks[i].y - peaks[max_i].y); - if ( td == 1 ) { - adjacent++; - break; /* One is enough */ - } - } - if ( adjacent < 1 ) { - peaks[max_i].invalid = 1; - /* If invalidated, don't remove nearby peaks */ - continue; - } - - /* Remove nearby (non-invalidated) peaks from list */ - n_nearby = 0; - for ( i=0; i<n_peaks; i++ ) { - - int dx, dy, ds; - - if ( peaks[i].invalid ) continue; - - dx = abs(peaks[i].x - peaks[max_i].x); - dy = abs(peaks[i].y - peaks[max_i].y); - ds = dx*dx + dy*dy; - if ( ds < 36 ) { - n_nearby++; - peaks[i].invalid = 1; - } - - } - - } while ( n_nearby ); - - n_valid = 0; - for ( i=0; i<n_peaks; i++ ) { - if ( peaks[i].invalid ) continue; - //printf("%i %i\n", peaks[i].x, peaks[i].y); - n_valid++; - } - - free(peaks); - - return n_valid; -} - - static int is_hot_pixel(struct image *image, int x, int y) { int dx, dy; diff --git a/src/peaks.h b/src/peaks.h index ba85f0f5..510282f8 100644 --- a/src/peaks.h +++ b/src/peaks.h @@ -17,8 +17,6 @@ #include <config.h> #endif - -extern int image_fom(struct image *image); extern void search_peaks(struct image *image); extern void dump_peaks(struct image *image); extern void output_intensities(struct image *image, UnitCell *cell); |