Browse Source

Fix reconstruction and make offset straightforward

Matthias Vogelgesang 9 years ago
parent
commit
6d867e7d9d
1 changed files with 26 additions and 17 deletions
  1. 26 17
      lamino.c

+ 26 - 17
lamino.c

@@ -116,7 +116,9 @@ run_reconstruction (Params *params)
     guint xl, xr, yt, yb;
     guint padded_width;
     guint padded_height;
+    gdouble theta_rad;
     gdouble angle_step;
+    guint fwidth;
     gdouble time = 0.0;
     UfoPluginManager *pm = NULL;
     UfoTaskGraph *graph = NULL;
@@ -157,21 +159,27 @@ run_reconstruction (Params *params)
     g_object_set (fft2, "dimensions", 2, NULL);
     g_object_set (ifft, "dimensions", 2, NULL);
 
-    padded_width = next_power_of_two ((guint32) params->width);
-    padded_height = next_power_of_two ((guint32) params->height);
+    fwidth = ((guint) params->px) * 2;
+    padded_width = next_power_of_two (fwidth) * 2;
+    padded_height = next_power_of_two ((guint32) params->height + 1);
+
+    xl = params->px - params->width / 2;
+    xr = padded_width - params->width - xl;
+    yt = params->py - params->height / 2;
+    yb = padded_height - params->height - yt;
 
-    xl = (padded_width - params->width) / 2;
-    xr = xl;
-    yt = (padded_height - params->height) / 2;
-    yb = yt;
     angle_step = (G_PI * 2.0) / params->num_radios;
+    theta_rad = params->theta / 360. * G_PI * 2;
+
+    info ("Axis: x=%.1f  y=%.1f\n",
+          params->px, params->py);
+
+    info ("Lamino: theta=%.3f  tau=%.3f  step=%.5f  fwidth=%d\n",
+          theta_rad, params->tau, angle_step, fwidth);
 
     info ("Padding: size=[%d %d]  (xl=%d xr=%d yt=%d yb=%d)\n",
           padded_width, padded_height, xl, xr, yt, yb);
 
-    info ("Parameters: theta=%.3f  tau=%.3f  step=%.5f\n",
-          params->theta, params->tau, angle_step);
-
     info ("Volume: origin=[%.1f %.1f %.1f]  size=[%d %d %d]\n",
           params->v_origin[0], params->v_origin[1], params->v_origin[2],
           params->v_size[0], params->v_size[1], params->v_size[2]);
@@ -185,19 +193,20 @@ run_reconstruction (Params *params)
     g_object_set (ramp,
                   "width", padded_width,
                   "height", padded_height,
-                  "theta", G_PI * 2 / params->theta,
+                  "theta", theta_rad,
                   "tau", params->tau,
+                  "fwidth", fwidth,
                   NULL);
 
     g_object_set (reco,
                   "angle-step", angle_step,
-                  "theta", G_PI * 2 / params->theta,
+                  "theta", theta_rad,
                   "psi", params->psi,
-                  "proj-ox", params->px + xl,
+                  "proj-ox", params->px,
                   "proj-oy", params->py,
-                  "vol-ox", params->v_origin[0],
-                  "vol-oy", params->v_origin[1],
-                  "vol-oz", params->v_origin[2],
+                  "vol-ox", params->v_size[0] / 2 + params->v_origin[0],
+                  "vol-oy", params->v_size[1] / 2 + params->v_origin[1],
+                  "vol-oz", params->v_size[2] / 2 + params->v_origin[2],
                   "vol-sx", params->v_size[0],
                   "vol-sy", params->v_size[1],
                   "vol-sz", params->v_size[2],
@@ -278,8 +287,8 @@ parse_params (Params *params, int argc, char **argv)
         { "flats", 0, 0, G_OPTION_ARG_STRING, &params->flats, "Flats", "" },
         { "output", 0, 0, G_OPTION_ARG_STRING, &params->output, "Output", "" },
         { "theta", 0, 0, G_OPTION_ARG_DOUBLE, &params->theta, "Tilt (theta)", "" },
-        { "tau", 0, 0, G_OPTION_ARG_DOUBLE, &params->theta, "Pixel size (theta)", "" },
-        { "psi", 0, 0, G_OPTION_ARG_DOUBLE, &params->theta, "Misalignment (psi)", "" },
+        { "tau", 0, 0, G_OPTION_ARG_DOUBLE, &params->tau, "Pixel size (theta)", "" },
+        { "psi", 0, 0, G_OPTION_ARG_DOUBLE, &params->psi, "Misalignment (psi)", "" },
         { "px", 0, 0, G_OPTION_ARG_DOUBLE, &params->px, "X coordinate of axis", "" },
         { "py", 0, 0, G_OPTION_ARG_DOUBLE, &params->py, "Y coordinate of axis", "" },
         { "vx", 0, 0, G_OPTION_ARG_DOUBLE, &params->v_origin[0], "X coordinate of box origin", "" },