aboutsummaryrefslogtreecommitdiff
path: root/src/mapping.c
diff options
context:
space:
mode:
authortaw27 <taw27@bf6ca9ba-c028-0410-8290-897cf20841d1>2007-08-28 12:43:49 +0000
committertaw27 <taw27@bf6ca9ba-c028-0410-8290-897cf20841d1>2007-08-28 12:43:49 +0000
commit0ef8783c72948f9c8c4af1170ae2d8414a2bd13e (patch)
treee11e80ab4441480c9fb621202b70cc81b11cce32 /src/mapping.c
parent737154b1ef16ef037df988eaa64a5063df1d815c (diff)
Add skeleton prealignment procedure
git-svn-id: svn://cook.msm.cam.ac.uk:745/diff-tomo/dtr@79 bf6ca9ba-c028-0410-8290-897cf20841d1
Diffstat (limited to 'src/mapping.c')
-rw-r--r--src/mapping.c75
1 files changed, 40 insertions, 35 deletions
diff --git a/src/mapping.c b/src/mapping.c
index a8d50b3..d9ca94d 100644
--- a/src/mapping.c
+++ b/src/mapping.c
@@ -31,52 +31,57 @@ ReflectionContext *mapping_create(ControlContext *ctx) {
/* Create reflection context */
rctx = reflection_init();
- /* Find centre of image stack
- * Determine maximum size of image to accommodate, and allocate memory */
- twidth = 0; theight = 0;
- for ( i=0; i<ctx->n_images; i++ ) {
- if ( ctx->images[i].width > twidth ) twidth = ctx->images[i].width;
- if ( ctx->images[i].height > theight ) theight = ctx->images[i].height;
- }
- image_total = malloc(twidth * theight * sizeof(int16_t));
- memset(image_total, 0, twidth * theight * sizeof(int16_t));
-
- /* Add the image stack together */
- for ( i=0; i<ctx->n_images; i++ ) {
- int xoffs, yoffs;
- xoffs = (twidth - ctx->images[i].width)/2;
- yoffs = (theight - ctx->images[i].height)/2;
+ if ( !ctx->prealign ) {
+ /* Find centre of image stack
+ * Determine maximum size of image to accommodate, and allocate memory */
+ twidth = 0; theight = 0;
+ for ( i=0; i<ctx->n_images; i++ ) {
+ if ( ctx->images[i].width > twidth ) twidth = ctx->images[i].width;
+ if ( ctx->images[i].height > theight ) theight = ctx->images[i].height;
+ }
+ image_total = malloc(twidth * theight * sizeof(int16_t));
+ memset(image_total, 0, twidth * theight * sizeof(int16_t));
+
+ /* Add the image stack together */
+ for ( i=0; i<ctx->n_images; i++ ) {
+ int xoffs, yoffs;
+ xoffs = (twidth - ctx->images[i].width)/2;
+ yoffs = (theight - ctx->images[i].height)/2;
+ for ( y=0; y<theight; y++ ) {
+ for ( x=0; x<twidth; x++ ) {
+ image_total[x + twidth*y] += ctx->images[i].image[x + twidth*y]/ctx->n_images;
+ }
+ }
+ }
+
+ /* Locate the highest point */
+ max_val = 0; max_x = 0; max_y = 0;
for ( y=0; y<theight; y++ ) {
for ( x=0; x<twidth; x++ ) {
- image_total[x + twidth*y] += ctx->images[i].image[x + twidth*y]/ctx->n_images;
+ if ( image_total[x + twidth*y] > max_val ) {
+ max_val = image_total[x + twidth*y];
+ max_x = x; max_y = y;
+ }
}
}
- }
+ ctx->x_centre = max_x;
+ ctx->y_centre = max_y;
- /* Locate the highest point */
- max_val = 0; max_x = 0; max_y = 0;
- for ( y=0; y<theight; y++ ) {
- for ( x=0; x<twidth; x++ ) {
- if ( image_total[x + twidth*y] > max_val ) {
- max_val = image_total[x + twidth*y];
- max_x = x; max_y = y;
- }
- }
+ /* Display */
+ sum_id = imagedisplay_open(image_total, twidth, theight, "Sum of All Images");
+ imagedisplay_mark_point(sum_id, ctx->x_centre, ctx->y_centre);
+ imagedisplay_add_tilt_axis(sum_id, ctx, ctx->omega);
+
}
- ctx->x_centre = max_x;
- ctx->y_centre = max_y;
-
- /* Display */
- sum_id = imagedisplay_open(image_total, twidth, theight, "Sum of All Images");
- imagedisplay_mark_point(sum_id, ctx->x_centre, ctx->y_centre);
- imagedisplay_add_tilt_axis(sum_id, ctx, ctx->omega);
/* Pass all images through itrans
* (let itrans add the reflections to rctx for now) */
ctx->reflectionctx = rctx;
for ( i=0; i<ctx->n_images; i++ ) {
- ctx->images[i].x_centre = ctx->x_centre;
- ctx->images[i].y_centre = ctx->y_centre;
+ if ( !ctx->prealign ) {
+ ctx->images[i].x_centre = ctx->x_centre;
+ ctx->images[i].y_centre = ctx->y_centre;
+ }
itrans_process_image(ctx->images[i].image, ctx, ctx->images[i].tilt);
}