aboutsummaryrefslogtreecommitdiff
path: root/src/prealign.c
diff options
context:
space:
mode:
authortaw27 <taw27@bf6ca9ba-c028-0410-8290-897cf20841d1>2007-10-19 16:25:08 +0000
committertaw27 <taw27@bf6ca9ba-c028-0410-8290-897cf20841d1>2007-10-19 16:25:08 +0000
commit45864cb5113ec4dde6afe1d23ea53f75402b9ece (patch)
treeb3d4dad81bcfa34037cb067e1356303b32401df1 /src/prealign.c
parent7c4c25f2eda4f0a0780cf2edb087452ceb63f226 (diff)
Refactor image handling code
Remove itrans-lsq git-svn-id: svn://cook.msm.cam.ac.uk:745/diff-tomo/dtr@158 bf6ca9ba-c028-0410-8290-897cf20841d1
Diffstat (limited to 'src/prealign.c')
-rw-r--r--src/prealign.c57
1 files changed, 29 insertions, 28 deletions
diff --git a/src/prealign.c b/src/prealign.c
index b72943c..ef23c6e 100644
--- a/src/prealign.c
+++ b/src/prealign.c
@@ -17,6 +17,7 @@
#include "control.h"
#include "imagedisplay.h"
#include "main.h"
+#include "image.h"
typedef struct {
int n;
@@ -36,18 +37,18 @@ static gint prealign_clicked(GtkWidget *widget, GdkEventButton *event, PreAlignB
x -= xoffs; y -= yoffs;
x /= scale; y /= scale;
y = pb->id->imagerecord.height - y;
- pb->ctx->images[pb->n].x_centre = x;
- pb->ctx->images[pb->n].y_centre = y;
+ pb->ctx->images->images[pb->n].x_centre = x;
+ pb->ctx->images->images[pb->n].y_centre = y;
pb->n++;
- if ( pb->n >= pb->ctx->n_images ) {
+ if ( pb->n >= pb->ctx->images->n_images ) {
/* Finished */
imagedisplay_close(pb->id);
main_do_reconstruction(pb->ctx);
free(pb);
} else {
/* Display the next pattern */
- imagedisplay_put_data(pb->id, pb->ctx->images[pb->n]);
+ imagedisplay_put_data(pb->id, pb->ctx->images->images[pb->n]);
}
return 0;
@@ -65,13 +66,13 @@ void prealign_do_series(ControlContext *ctx) {
pb = malloc(sizeof(PreAlignBlock));
pb->n = 0;
pb->ctx = ctx;
- pb->id = imagedisplay_open_with_message(ctx->images[pb->n], "Image Pre-alignment",
+ pb->id = imagedisplay_open_with_message(ctx->images->images[pb->n], "Image Pre-alignment",
"Click the centre of the zero-order beam as accurately as you can.", IMAGEDISPLAY_QUIT_IF_CLOSED,
G_CALLBACK(prealign_clicked), pb);
}
-void prealign_sum_stack(ControlContext *ctx) {
+void prealign_sum_stack(ImageList *list, int have_centres) {
int twidth, theight;
int mnorth, msouth, mwest, meast;
@@ -82,11 +83,11 @@ void prealign_sum_stack(ControlContext *ctx) {
/* Determine maximum size of image to accommodate, and allocate memory */
mnorth = 0; msouth = 0; mwest = 0; meast = 0;
- for ( i=0; i<ctx->n_images; i++ ) {
- if ( ctx->images[i].width-ctx->images[i].x_centre > meast ) meast = ctx->images[i].width-ctx->images[i].x_centre;
- if ( ctx->images[i].x_centre > mwest ) mwest = ctx->images[i].x_centre;
- if ( ctx->images[i].height-ctx->images[i].y_centre > mnorth ) mnorth = ctx->images[i].height-ctx->images[i].y_centre;
- if ( ctx->images[i].y_centre > msouth ) msouth = ctx->images[i].y_centre;
+ for ( i=0; i<list->n_images; i++ ) {
+ if ( list->images[i].width-list->images[i].x_centre > meast ) meast = list->images[i].width-list->images[i].x_centre;
+ if ( list->images[i].x_centre > mwest ) mwest = list->images[i].x_centre;
+ if ( list->images[i].height-list->images[i].y_centre > mnorth ) mnorth = list->images[i].height-list->images[i].y_centre;
+ if ( list->images[i].y_centre > msouth ) msouth = list->images[i].y_centre;
}
twidth = mwest + meast;
theight = mnorth + msouth;
@@ -95,23 +96,23 @@ void prealign_sum_stack(ControlContext *ctx) {
memset(image_total, 0, twidth * theight * sizeof(uint16_t));
/* Add the image stack together */
- if ( !ctx->have_centres ) {
+ if ( !have_centres ) {
int max_x, max_y;
uint16_t max_val;
- for ( i=0; i<ctx->n_images; i++ ) {
+ for ( i=0; i<list->n_images; i++ ) {
int xoffs, yoffs;
- xoffs = (twidth - ctx->images[i].width)/2;
- yoffs = (theight - ctx->images[i].height)/2;
- for ( y=0; y<ctx->images[i].height; y++ ) {
- for ( x=0; x<ctx->images[i].width; x++ ) {
+ xoffs = (twidth - list->images[i].width)/2;
+ yoffs = (theight - list->images[i].height)/2;
+ for ( y=0; y<list->images[i].height; y++ ) {
+ for ( x=0; x<list->images[i].width; x++ ) {
assert(x+xoffs < twidth);
assert(y+yoffs < theight);
assert(x+xoffs >= 0);
assert(y+yoffs >= 0);
image_total[(x+xoffs) + twidth*(y+yoffs)] +=
- ctx->images[i].image[x + ctx->images[i].width*y]/ctx->n_images;
+ list->images[i].image[x + list->images[i].width*y]/list->n_images;
}
}
}
@@ -128,30 +129,31 @@ void prealign_sum_stack(ControlContext *ctx) {
}
/* Record this measurement on all images */
- for ( i=0; i<ctx->n_images; i++ ) {
- ctx->images[i].x_centre = max_x;
- ctx->images[i].y_centre = max_y;
+ for ( i=0; i<list->n_images; i++ ) {
+ list->images[i].x_centre = max_x;
+ list->images[i].y_centre = max_y;
}
total_record.x_centre = max_x;
total_record.y_centre = max_y;
} else {
- for ( i=0; i<ctx->n_images; i++ ) {
+ for ( i=0; i<list->n_images; i++ ) {
int xoffs, yoffs;
- xoffs = mwest - ctx->images[i].x_centre;
- yoffs = msouth - ctx->images[i].y_centre;
+ xoffs = mwest - list->images[i].x_centre;
+ yoffs = msouth - list->images[i].y_centre;
- for ( y=0; y<ctx->images[i].height; y++ ) {
- for ( x=0; x<ctx->images[i].width; x++ ) {
+ for ( y=0; y<list->images[i].height; y++ ) {
+ for ( x=0; x<list->images[i].width; x++ ) {
assert(x+xoffs < twidth);
assert(y+yoffs < theight);
assert(x+xoffs >= 0);
assert(y+yoffs >= 0);
image_total[(x+xoffs) + twidth*(y+yoffs)] +=
- ctx->images[i].image[x + ctx->images[i].width*y]/ctx->n_images;
+ list->images[i].image[x + list->images[i].width*y]/list->n_images;
+ total_record.omega = list->images[i].omega;
}
}
@@ -165,7 +167,6 @@ void prealign_sum_stack(ControlContext *ctx) {
total_record.image = image_total;
total_record.width = twidth;
total_record.height = theight;
- total_record.omega = ctx->omega;
sum_id = imagedisplay_open(total_record, "Sum of All Images", IMAGEDISPLAY_SHOW_CENTRE | IMAGEDISPLAY_SHOW_TILT_AXIS);
}