aboutsummaryrefslogtreecommitdiff
path: root/src/itrans-threshold.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/itrans-threshold.c')
-rw-r--r--src/itrans-threshold.c37
1 files changed, 19 insertions, 18 deletions
diff --git a/src/itrans-threshold.c b/src/itrans-threshold.c
index 3a1d788..6aadea2 100644
--- a/src/itrans-threshold.c
+++ b/src/itrans-threshold.c
@@ -19,27 +19,27 @@
#include "imagedisplay.h"
#include "reflections.h"
-unsigned int itrans_peaksearch_threshold(int16_t *image, ControlContext *ctx, double tilt_degrees, ImageDisplay *imagedisplay) {
+unsigned int itrans_peaksearch_threshold(ImageRecord imagerecord, ControlContext *ctx) {
int width, height;
int x, y;
unsigned int n_reflections = 0;
+ int16_t *image = imagerecord.image;
+ double tilt_degrees = imagerecord.tilt;
- width = ctx->width; height = ctx->height;
+ width = imagerecord.width;
+ height = imagerecord.height;
/* Simple Thresholding */
for ( y=0; y<height; y++ ) {
for ( x=0; x<width; x++ ) {
if ( image[x + width*y] > 10 ) {
- if ( ctx->fmode == FORMULATION_PIXELSIZE ) {
- reflection_add_from_reciprocal(ctx, (signed)(x-ctx->x_centre)*ctx->pixel_size, (signed)(y-ctx->y_centre)*ctx->pixel_size,
+ if ( imagerecord.fmode == FORMULATION_PIXELSIZE ) {
+ reflection_add_from_reciprocal(ctx, (signed)(x-imagerecord.x_centre)*imagerecord.pixel_size, (signed)(y-imagerecord.y_centre)*imagerecord.pixel_size,
tilt_degrees, image[x + width*y]);
} else {
- reflection_add_from_dp(ctx, (signed)(x-ctx->x_centre), (signed)(y-ctx->y_centre), tilt_degrees, image[x + width*y]);
- }
- if ( ctx->first_image ) {
- imagedisplay_mark_point(imagedisplay, x, y);
+ reflection_add_from_dp(ctx, (signed)(x-imagerecord.x_centre)/imagerecord.resolution, (signed)(y-imagerecord.y_centre)/imagerecord.resolution, tilt_degrees, image[x + width*y]);
}
n_reflections++;
}
@@ -51,14 +51,17 @@ unsigned int itrans_peaksearch_threshold(int16_t *image, ControlContext *ctx, do
}
-unsigned int itrans_peaksearch_adaptive_threshold(int16_t *image, ControlContext *ctx, double tilt_degrees, ImageDisplay *imagedisplay) {
+unsigned int itrans_peaksearch_adaptive_threshold(ImageRecord imagerecord, ControlContext *ctx) {
int16_t max_val = 0;
int width, height;
unsigned int n_reflections = 0;
+ int16_t *image = imagerecord.image;
+ double tilt_degrees = imagerecord.tilt;
+
+ width = imagerecord.width;
+ height = imagerecord.height;
- width = ctx->width; height = ctx->height;
-
/* Adaptive Thresholding */
do {
@@ -80,14 +83,11 @@ unsigned int itrans_peaksearch_adaptive_threshold(int16_t *image, ControlContext
}
if ( max_val > 50 ) {
- if ( ctx->fmode == FORMULATION_PIXELSIZE ) {
- reflection_add_from_reciprocal(ctx, (signed)(max_x-ctx->x_centre)*ctx->pixel_size, (signed)(max_y-ctx->y_centre)*ctx->pixel_size,
- tilt_degrees, max_val);
+ if ( imagerecord.fmode == FORMULATION_PIXELSIZE ) {
+ reflection_add_from_reciprocal(ctx, (signed)(x-imagerecord.x_centre)*imagerecord.pixel_size, (signed)(y-imagerecord.y_centre)*imagerecord.pixel_size,
+ tilt_degrees, image[x + width*y]);
} else {
- reflection_add_from_dp(ctx, (signed)(max_x-ctx->x_centre), (signed)(max_y-ctx->y_centre), tilt_degrees, max_val);
- }
- if ( ctx->first_image ) {
- imagedisplay_mark_point(imagedisplay, max_x, max_y);
+ reflection_add_from_dp(ctx, (signed)(x-imagerecord.x_centre)/imagerecord.resolution, (signed)(y-imagerecord.y_centre)/imagerecord.resolution, tilt_degrees, image[x + width*y]);
}
n_reflections++;
@@ -104,3 +104,4 @@ unsigned int itrans_peaksearch_adaptive_threshold(int16_t *image, ControlContext
return n_reflections;
}
+