Browse Source

Normalize volume

Tomas Farago 9 years ago
parent
commit
8c2d6cd06c
2 changed files with 6 additions and 2 deletions
  1. 2 1
      src/kernels/templates/common.in
  2. 4 1
      src/ufo-anka-backproject-task.c

+ 2 - 1
src/kernels/templates/common.in

@@ -13,6 +13,7 @@ kernel void backproject_burst_{0} (
                                     float cos_lamino,
                                     const float{2} sines,
                                     const float{2} cosines,
+                                    const float norm_factor,
                                     const int cumulate)
 {{
     int idx = get_global_id (0);
@@ -26,6 +27,6 @@ kernel void backproject_burst_{0} (
     if (idx < real_size.x && idy < real_size.y && idz < real_size.z) {{
 {3}
 
-        volume[idz * real_size.x * real_size.y + idy * real_size.x + idx] = old + result;
+        volume[idz * real_size.x * real_size.y + idy * real_size.x + idx] = old + result * norm_factor;
     }}
 }}

+ 4 - 1
src/ufo-anka-backproject-task.c

@@ -480,7 +480,8 @@ ufo_anka_backproject_task_process (UfoTask *task,
     gsize table_size;
     gboolean scalar;
     /* regions stripped off the "to" value */
-    gfloat x_region[2], y_region[2], z_region[2], x_center[2], z_ends[2], lamino_angles[2], y_center, sin_lamino, cos_lamino;
+    gfloat x_region[2], y_region[2], z_region[2], x_center[2], z_ends[2], lamino_angles[2],
+           y_center, sin_lamino, cos_lamino, norm_factor;
     gint x_copy_region[2], y_copy_region[2];
     cl_kernel kernel;
     cl_command_queue cmd_queue;
@@ -515,6 +516,7 @@ ufo_anka_backproject_task_process (UfoTask *task,
     index = priv->count % BURST;
     tomo_angle = priv->tomo_angle > -G_MAXFLOAT ? priv->tomo_angle :
                  priv->overall_angle * priv->count / priv->num_projections;
+    norm_factor = priv->overall_angle / priv->num_projections;
     priv->sines[index] = sin (tomo_angle);
     priv->cosines[index] = cos (tomo_angle);
     x_region[0] = (gfloat) EXTRACT_INT (priv->x_region, 0);
@@ -621,6 +623,7 @@ ufo_anka_backproject_task_process (UfoTask *task,
         UFO_RESOURCES_CHECK_CLERR (clSetKernelArg (kernel, i++, sizeof (cl_float), &cos_lamino));
         UFO_RESOURCES_CHECK_CLERR (clSetKernelArg (kernel, i++, table_size, sines));
         UFO_RESOURCES_CHECK_CLERR (clSetKernelArg (kernel, i++, table_size, cosines));
+        UFO_RESOURCES_CHECK_CLERR (clSetKernelArg (kernel, i++, sizeof (cl_float), &norm_factor));
         UFO_RESOURCES_CHECK_CLERR (clSetKernelArg (kernel, i, sizeof (cl_int), (cl_int *) &cumulate));
 
         profiler = ufo_task_node_get_profiler (UFO_TASK_NODE (task));