/* * itrans-zaefferer.c * * Zaefferer peak search * * (c) 2007 Thomas White * * dtr - Diffraction Tomography Reconstruction * */ #ifdef HAVE_CONFIG_H #include #endif #include #include #include "control.h" #include "imagedisplay.h" #include "reflections.h" #include "utils.h" #define PEAK_WINDOW_SIZE 20 unsigned int itrans_peaksearch_zaefferer(ImageRecord *imagerecord, ControlContext *ctx) { int x, y; unsigned int n_reflections; int width, height; uint16_t *image; image = imagerecord->image; width = imagerecord->width; height = imagerecord->height; n_reflections = 0; for ( x=1; x 400 ) { int mask_x, mask_y; int sx, sy; double max; unsigned int did_something = 1; mask_x = x; mask_y = y; while ( (did_something) && (distance(mask_x, mask_y, x, y)<50) ) { max = image[mask_x+width*mask_y]; did_something = 0; for ( sy=biggest(mask_y-PEAK_WINDOW_SIZE/2, 0); sy max ) { max = image[sx+width*sy]; mask_x = sx; mask_y = sy; did_something = 1; } } } } if ( !did_something ) { assert(mask_x=0); assert(mask_y>=0); reflection_add_from_dp(ctx, (mask_x-imagerecord->x_centre), (mask_y-imagerecord->y_centre), imagerecord, image[mask_x + width*mask_y]); n_reflections++; } } } } return n_reflections; }