aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2010-06-12 19:44:30 -0700
committerThomas White <taw@physics.org>2010-06-12 19:44:30 -0700
commita53f6c6bf41d897a6dafbbe9791ffe24196ec400 (patch)
tree34d024f905f063b1b6893f769917b05ccecafd58 /src
parentb0d6ab16490a4ba99231e1cbb35349c0a2813ca2 (diff)
calibrate-detector: Only integrate near peaks
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am2
-rw-r--r--src/calibrate-detector.c42
2 files changed, 38 insertions, 6 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 7a440ed8..c484d63e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -50,7 +50,7 @@ render_hkl_SOURCES = render_hkl.c cell.c reflections.c utils.c
render_hkl_LDADD = @LIBS@
calibrate_detector_SOURCES = calibrate-detector.c utils.c hdf5-file.c image.c \
- filters.c
+ filters.c peaks.c
calibrate_detector_LDADD = @LIBS@
INCLUDES = "-I$(top_srcdir)/data"
diff --git a/src/calibrate-detector.c b/src/calibrate-detector.c
index d411c2c6..1e6d88aa 100644
--- a/src/calibrate-detector.c
+++ b/src/calibrate-detector.c
@@ -27,8 +27,10 @@
#include "utils.h"
#include "hdf5-file.h"
#include "filters.h"
+#include "peaks.h"
+#define INTEGRATION_RADIUS (10)
#define MAX_THREADS (96)
struct process_args
@@ -70,7 +72,7 @@ static void *process_image(void *pargsv)
struct process_args *pargs = pargsv;
struct hdfile *hdfile;
struct image image;
- int x, y;
+ int x, y, i;
image.features = NULL;
image.data = NULL;
@@ -113,10 +115,40 @@ static void *process_image(void *pargsv)
goto out;
}
- for ( x=0; x<image.width; x++ ) {
- for ( y=0; y<image.height; y++ ) {
- pargs->sum[x+pargs->w*y] += image.data[x+image.width*y];
- }
+ search_peaks(&image);
+
+// for ( x=0; x<image.width; x++ ) {
+// for ( y=0; y<image.height; y++ ) {
+// float val = image.data[x+image.width*y];
+// if ( val > 100.0 ) {
+// pargs->sum[x+pargs->w*y] += val;
+// }
+// }
+// }
+
+ const int lim = INTEGRATION_RADIUS * INTEGRATION_RADIUS;
+
+ for ( i=0; i<image_feature_count(image.features); i++ ) {
+
+ struct imagefeature *f = image_get_feature(image.features, i);
+ int xp = f->x;
+ int yp = f->y;
+
+ for ( x=-INTEGRATION_RADIUS; x<+INTEGRATION_RADIUS; x++ ) {
+ for ( y=-INTEGRATION_RADIUS; y<+INTEGRATION_RADIUS; y++ ) {
+
+ /* Circular mask */
+ if ( x*x + y*y > lim ) continue;
+
+ if ( ((x+xp)>=image.width) || ((x+xp)<0) ) continue;
+ if ( ((y+yp)>=image.height) || ((y+yp)<0) ) continue;
+
+ float val = image.data[x+image.width*y];
+ pargs->sum[x+pargs->w*y] += val;
+
+ }
+ }
+
}
out: