ufo-filter-lamino-bp-generic.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524
  1. #include <gmodule.h>
  2. #ifdef __APPLE__
  3. #include <OpenCL/cl.h>
  4. #else
  5. #include <CL/cl.h>
  6. #endif
  7. #include <ufo/ufo-filter-reduce.h>
  8. #include <ufo/ufo-buffer.h>
  9. #include <ufo/ufo-resource-manager.h>
  10. #include "ufo-filter-lamino-bp-generic.h"
  11. //#include <stdio.h> // TODO remove later
  12. #include "lamino-filter-def.h"
  13. #include <math.h>
  14. struct _UfoFilterLaminoBPGenericPrivate {
  15. // float theta;
  16. cl_kernel bp_kernel;
  17. cl_kernel clean_vol_kernel;
  18. cl_kernel norm_vol_kernel;
  19. cl_mem param_mem;
  20. gint proj_idx;
  21. CLParameters params;
  22. gboolean finished;
  23. size_t global_work_size[3];
  24. };
  25. GType ufo_filter_lamino_bp_generic_get_type(void) G_GNUC_CONST;
  26. G_DEFINE_TYPE(UfoFilterLaminoBPGeneric, ufo_filter_lamino_bp_generic, UFO_TYPE_FILTER_REDUCE);
  27. #define UFO_FILTER_LAMINO_BP_GENERIC_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), UFO_TYPE_FILTER_LAMINO_BP_GENERIC, UfoFilterLaminoBPGenericPrivate))
  28. enum {
  29. PROP_0 = 0,
  30. PROP_THETA,
  31. PROP_PSI,
  32. PROP_ANGLE_STEP,
  33. PROP_VOL_SX,
  34. PROP_VOL_SY,
  35. PROP_VOL_SZ,
  36. PROP_VOL_OX,
  37. PROP_VOL_OY,
  38. PROP_VOL_OZ,
  39. PROP_PROJ_OX,
  40. PROP_PROJ_OY,
  41. N_PROPERTIES
  42. };
  43. static GParamSpec *lamino_bp_generic_properties[N_PROPERTIES] = { NULL, };
  44. /* static void testing_cl_platform()
  45. {
  46. cl_int error = 0;
  47. //Platform Information
  48. cl_uint numPlatforms;
  49. cl_platform_id* clSelectedPlatformID = NULL;
  50. //get the number of available platforms
  51. clGetPlatformIDs(0, NULL, &numPlatforms);
  52. //alloc memory so we can get the whole list
  53. clSelectedPlatformID = (cl_platform_id*)malloc(sizeof(cl_platform_id)*numPlatforms);
  54. //get the list of available platforms
  55. error = clGetPlatformIDs(numPlatforms, clSelectedPlatformID, NULL);
  56. g_message("Available platforms number: %d", numPlatforms);
  57. char platform_info[128];
  58. clGetPlatformInfo(clSelectedPlatformID[0], CL_PLATFORM_NAME, sizeof(char)*128, platform_info, NULL);
  59. g_message("CL_PLATFORM_NAME: %s", platform_info);
  60. cl_uint ciDeviceCount;
  61. cl_device_id* clDevices = NULL;
  62. error = clGetDeviceIDs(clSelectedPlatformID[0], CL_DEVICE_TYPE_GPU, 0, NULL, &ciDeviceCount);
  63. clDevices = (cl_device_id*) malloc(sizeof(cl_device_id) * ciDeviceCount);
  64. error = clGetDeviceIDs(clSelectedPlatformID[0], CL_DEVICE_TYPE_GPU, ciDeviceCount, clDevices, &ciDeviceCount);
  65. g_message("Available Devices: %d.",ciDeviceCount);
  66. char device_info[128];
  67. cl_uint device_value = 0;
  68. cl_ulong device_value_ulong = 0;
  69. size_t device_sizet = 0;
  70. size_t dimsz[3];
  71. for(unsigned int i=0; i < ciDeviceCount ; i++)
  72. {
  73. if(clGetDeviceInfo(clDevices[i], CL_DEVICE_NAME, sizeof(char)*128, device_info, NULL) == CL_SUCCESS)
  74. g_message("#%d CL_DEVICE_NAME: %s", i+1, device_info);
  75. if(clGetDeviceInfo(clDevices[i], CL_DRIVER_VERSION, sizeof(char)*128, device_info, NULL) == CL_SUCCESS)
  76. g_message("#%d CL_DRIVER_VERSION: %s", i+1, device_info);
  77. if(clGetDeviceInfo(clDevices[i], CL_DEVICE_MAX_CLOCK_FREQUENCY, sizeof(cl_uint), &device_value, NULL) == CL_SUCCESS)
  78. g_message("#%d CL_DEVICE_MAX_CLOCK_FREQUENCY: %dMHz", i+1, device_value);
  79. if(clGetDeviceInfo(clDevices[i], CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE, sizeof(cl_ulong), &device_value_ulong, NULL) == CL_SUCCESS)
  80. g_message("#%d CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE: %d kB", i+1, device_value_ulong/(1024));
  81. if(clGetDeviceInfo(clDevices[i], CL_DEVICE_GLOBAL_MEM_SIZE, sizeof(cl_ulong), &device_value_ulong, NULL) == CL_SUCCESS)
  82. g_message("#%d CL_DEVICE_GLOBAL_MEM_SIZE: %d MB", i+1, device_value_ulong/(1024*1024));
  83. if(clGetDeviceInfo(clDevices[i], CL_DEVICE_LOCAL_MEM_SIZE, sizeof(cl_ulong), &device_value_ulong, NULL) == CL_SUCCESS)
  84. g_message("#%d CL_DEVICE_LOCAL_MEM_SIZE: %d kB", i+1, device_value_ulong/(1024));
  85. if(clGetDeviceInfo(clDevices[i], CL_DEVICE_MAX_MEM_ALLOC_SIZE, sizeof(cl_ulong), &device_value_ulong, NULL) == CL_SUCCESS)
  86. g_message("#%d CL_DEVICE_MAX_MEM_ALLOC_SIZE: %d MB", i+1, device_value_ulong/(1024*1024));
  87. if(clGetDeviceInfo(clDevices[i], CL_DEVICE_MAX_WORK_GROUP_SIZE, sizeof(size_t), &device_sizet, NULL) == CL_SUCCESS)
  88. g_message("#%d CL_DEVICE_MAX_WORK_GROUP_SIZE: %d", i+1, device_sizet);
  89. if(clGetDeviceInfo(clDevices[i], CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS, sizeof(cl_uint), &device_value, NULL) == CL_SUCCESS)
  90. g_message("#%d CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS: %d", i+1, device_value);
  91. if(clGetDeviceInfo(clDevices[i], CL_DEVICE_MAX_WORK_ITEM_SIZES, sizeof(size_t)*3, dimsz, NULL) == CL_SUCCESS)
  92. g_message("#%d CL_DEVICE_MAX_WORK_ITEM_SIZES: %d x %d x %d", i+1, dimsz[0], dimsz[1], dimsz[2]);
  93. g_message(" ");
  94. }
  95. if(error != CL_SUCCESS)
  96. g_message("OpenCL testing failed");
  97. else
  98. g_message("OpenCL testing succeded");
  99. }*/
  100. static void
  101. ufo_filter_lamino_bp_generic_initialize (UfoFilterReduce *filter, UfoBuffer *input[], guint **output_dims, gfloat *default_value, GError **error)
  102. {
  103. UfoFilterLaminoBPGenericPrivate *priv = UFO_FILTER_LAMINO_BP_GENERIC_GET_PRIVATE(filter);
  104. UfoResourceManager *manager = ufo_filter_get_resource_manager(UFO_FILTER(filter));
  105. GError *tmp_error = NULL;
  106. cl_context context;
  107. guint width, height;
  108. // TODO: how to solve 'include problem' for cl-files?
  109. // resource_manager_add_program
  110. // (UfoResourceManager *manager,
  111. // const gchar *filename, const gchar *options, GError **error)
  112. // ufo_resource_manager_add_program(manager, "lamino_bp_generic.cl",
  113. // "-I /home/timurttv/_UFO-Project/framework/ufo-filters-am-installed/lib/ufo", &error);
  114. priv->bp_kernel = ufo_resource_manager_get_kernel(manager, "lamino_bp_generic.cl", "lamino_bp_generic", &tmp_error);
  115. priv->norm_vol_kernel = ufo_resource_manager_get_kernel(manager, "lamino_bp_generic.cl", "lamino_norm_vol", &tmp_error);
  116. /* We don't need to clean the volume manually. All output buffers are
  117. * initialized with `default_value`. */
  118. /* priv->clean_vol_kernel = ufo_resource_manager_get_kernel(manager, "lamino_bp_generic.cl", "lamino_clean_vol", &tmp_error); */
  119. if (tmp_error != NULL) {
  120. g_propagate_error (error, tmp_error);
  121. return;
  122. }
  123. ufo_buffer_get_2d_dimensions (input[0], &width, &height);
  124. priv->params.proj_sx = (int) width;
  125. priv->params.proj_sy = (int) height;
  126. ////// init recon-parameters which are common for all projs
  127. // shift volume origin to the box center
  128. // moved to user scipt part
  129. // params->vol_ox += (float)vSX/2.0;
  130. // params->vol_oy += (float)vSY/2.0;
  131. // params->vol_oz += (float)vSZ/2.0;
  132. context = (cl_context) ufo_resource_manager_get_context(manager);
  133. priv->param_mem = clCreateBuffer(context, CL_MEM_READ_ONLY, sizeof(CLParameters), NULL, NULL);
  134. priv->proj_idx = 0;
  135. output_dims[0][0] = priv->params.vol_sx;
  136. output_dims[0][1] = priv->params.vol_sy;
  137. output_dims[0][2] = priv->params.vol_sz;
  138. priv->global_work_size[0] = (size_t) priv->params.vol_sx;
  139. priv->global_work_size[1] = (size_t) priv->params.vol_sy;
  140. priv->global_work_size[2] = (size_t) priv->params.vol_sz;
  141. *default_value = 0.0f;
  142. }
  143. static void
  144. ufo_filter_lamino_bp_generic_collect(UfoFilterReduce *filter, UfoBuffer *input[], UfoBuffer *output[], GError **error)
  145. {
  146. /////////////////// testing OpenCL platform
  147. // testing_cl_platform();
  148. g_return_if_fail(UFO_IS_FILTER(filter));
  149. UfoFilterLaminoBPGenericPrivate *priv = UFO_FILTER_LAMINO_BP_GENERIC_GET_PRIVATE(filter);
  150. CLParameters *params = &(priv->params);
  151. cl_command_queue command_queue = (cl_command_queue) ufo_filter_get_command_queue (UFO_FILTER (filter));
  152. cl_mem output_mem = (cl_mem) ufo_buffer_get_device_array(output[0], command_queue);
  153. const guint vol_num_dims = 3;
  154. // clean volume before reconstruction on the GPU side
  155. g_message("prepare the volume");
  156. /* cl_event event; */
  157. /* cl_kernel clean_vol_kernel = priv->clean_vol_kernel; */
  158. /* CHECK_OPENCL_ERROR(clSetKernelArg(clean_vol_kernel, 0, sizeof(cl_mem), (void *) &output_mem)); */
  159. /* CHECK_OPENCL_ERROR(clEnqueueNDRangeKernel(command_queue, clean_vol_kernel, */
  160. /* vol_num_dims, NULL, global_work_size, NULL, 0, NULL, &event)); */
  161. // clFinish(command_queue);
  162. // whait until kernel finishes its job
  163. /* ufo_buffer_attach_event(output, event); */
  164. // setup backprojection kernel
  165. cl_kernel kernel = priv->bp_kernel;
  166. // projection conter
  167. // allocate memory for parameters
  168. //
  169. ////// init recon-parameters which are individual for each projs
  170. params->alpha = - 3 * G_PI/2 + params->theta;
  171. params->phi = params->angle_step* ((float) priv->proj_idx);
  172. float sf = sin(params->phi), cf = cos(params->phi), ct=cos(params->alpha),
  173. st = sin(params->alpha), cg = cos(params->psi), sg=sin(params->psi);
  174. params->mat_0 = cg * cf - sg * st * sf;
  175. params->mat_1 = -cg * sf - sg * st * cf;
  176. params->mat_2 = -sg * ct;
  177. params->mat_3 = sg * cf + cg * st * sf;
  178. params->mat_4 = -sg * sf + cg * st * cf;
  179. params->mat_5 = cg * ct;
  180. //g_message("%d %d %d", vSX, vSY, vSZ);
  181. //g_message("%f %f %f", params->vol_ox, params->vol_oy, params->vol_oz);
  182. //g_message("%f %f %f %f ", params->theta, params->phi, params->psi, params->alpha);
  183. //g_message("%f %f %f", params->proj_ox, params->proj_oy, params->angle_step);
  184. // send parameters to GPU
  185. clEnqueueWriteBuffer(command_queue, priv->param_mem, CL_TRUE, 0, sizeof(CLParameters), params, 0, NULL, NULL);
  186. // copy projection to GPU
  187. cl_mem input_mem = (cl_mem) ufo_buffer_get_device_array(input[0], command_queue);
  188. CHECK_OPENCL_ERROR(clSetKernelArg(kernel, 0, sizeof(cl_mem), (void *) &input_mem));
  189. CHECK_OPENCL_ERROR(clSetKernelArg(kernel, 1, sizeof(cl_mem), (void *) &output_mem));
  190. CHECK_OPENCL_ERROR(clSetKernelArg(kernel, 2, sizeof(cl_mem), (void *) &priv->param_mem));
  191. // call backprojection routine
  192. g_message("processing of %d-th projection", priv->proj_idx);
  193. CHECK_OPENCL_ERROR(clEnqueueNDRangeKernel(command_queue, kernel,
  194. vol_num_dims, NULL, priv->global_work_size, NULL, 0, NULL, NULL));
  195. // clFinish(command_queue);
  196. priv->proj_idx++;
  197. }
  198. static gboolean
  199. ufo_filter_lamino_bp_generic_reduce (UfoFilterReduce *filter, UfoBuffer *output[], GError **error)
  200. {
  201. UfoFilterLaminoBPGenericPrivate *priv = UFO_FILTER_LAMINO_BP_GENERIC_GET_PRIVATE(filter);
  202. if (priv->finished)
  203. return FALSE;
  204. // normalize volume after reconstruction
  205. cl_command_queue cmd_queue = ufo_filter_get_command_queue (UFO_FILTER (filter));
  206. cl_kernel norm_vol_kernel = priv->norm_vol_kernel;
  207. cl_mem output_mem = ufo_buffer_get_device_array (output[0], cmd_queue);
  208. float stepPhi = priv->params.angle_step;
  209. const guint vol_num_dims = 3;
  210. CHECK_OPENCL_ERROR(clSetKernelArg(norm_vol_kernel, 0, sizeof(cl_mem), (void *) &output_mem));
  211. CHECK_OPENCL_ERROR(clSetKernelArg(norm_vol_kernel, 1, sizeof(float), &stepPhi));
  212. // call normalization kernel
  213. g_message("volume post-processing");
  214. CHECK_OPENCL_ERROR(clEnqueueNDRangeKernel((cl_command_queue) cmd_queue, norm_vol_kernel,
  215. vol_num_dims, NULL, priv->global_work_size, NULL, 0, NULL, NULL));
  216. priv->finished = TRUE;
  217. return TRUE;
  218. }
  219. static void
  220. ufo_filter_lamino_bp_generic_finalize (GObject *object)
  221. {
  222. UfoFilterLaminoBPGenericPrivate *priv = UFO_FILTER_LAMINO_BP_GENERIC_GET_PRIVATE (object);
  223. CHECK_OPENCL_ERROR (clReleaseMemObject (priv->param_mem));
  224. G_OBJECT_CLASS (ufo_filter_lamino_bp_generic_parent_class)->finalize (object);
  225. }
  226. static void
  227. ufo_filter_lamino_bp_generic_set_property(GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
  228. {
  229. UfoFilterLaminoBPGeneric *self = UFO_FILTER_LAMINO_BP_GENERIC(object);
  230. switch (property_id) {
  231. case PROP_THETA:
  232. self->priv->params.theta = (float) g_value_get_double(value);
  233. break;
  234. case PROP_PSI:
  235. self->priv->params.psi = (float) g_value_get_double(value);
  236. break;
  237. case PROP_ANGLE_STEP:
  238. self->priv->params.angle_step = (float) g_value_get_double(value);
  239. break;
  240. case PROP_VOL_SX:
  241. self->priv->params.vol_sx = g_value_get_uint(value);
  242. break;
  243. case PROP_VOL_SY:
  244. self->priv->params.vol_sy = g_value_get_uint(value);
  245. break;
  246. case PROP_VOL_SZ:
  247. self->priv->params.vol_sz = g_value_get_uint(value);
  248. break;
  249. case PROP_VOL_OX:
  250. self->priv->params.vol_ox = (float)g_value_get_double(value);
  251. break;
  252. case PROP_VOL_OY:
  253. self->priv->params.vol_oy = (float)g_value_get_double(value);
  254. break;
  255. case PROP_VOL_OZ:
  256. self->priv->params.vol_oz = (float)g_value_get_double(value);
  257. break;
  258. case PROP_PROJ_OX:
  259. self->priv->params.proj_ox = (float)g_value_get_double(value);
  260. break;
  261. case PROP_PROJ_OY:
  262. self->priv->params.proj_oy = (float)g_value_get_double(value);
  263. break;
  264. default:
  265. G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
  266. break;
  267. }
  268. }
  269. static void
  270. ufo_filter_lamino_bp_generic_get_property (GObject *object, guint property_id, GValue *value, GParamSpec*pspec)
  271. {
  272. UfoFilterLaminoBPGeneric *self = UFO_FILTER_LAMINO_BP_GENERIC(object);
  273. switch (property_id) {
  274. case PROP_THETA:
  275. g_value_set_double(value, (double) self->priv->params.theta);
  276. break;
  277. case PROP_PSI:
  278. g_value_set_double(value, (double) self->priv->params.psi);
  279. break;
  280. case PROP_ANGLE_STEP:
  281. g_value_set_double(value, (double) self->priv->params.angle_step);
  282. break;
  283. case PROP_VOL_SX:
  284. g_value_set_uint(value, self->priv->params.vol_sx);
  285. break;
  286. case PROP_VOL_SY:
  287. g_value_set_uint(value, self->priv->params.vol_sy);
  288. break;
  289. case PROP_VOL_SZ:
  290. g_value_set_uint(value, self->priv->params.vol_sz);
  291. break;
  292. case PROP_VOL_OX:
  293. g_value_set_double(value, (double)self->priv->params.vol_ox);
  294. break;
  295. case PROP_VOL_OY:
  296. g_value_set_double(value, (double)self->priv->params.vol_oy);
  297. break;
  298. case PROP_VOL_OZ:
  299. g_value_set_double(value, (double)self->priv->params.vol_oz);
  300. break;
  301. case PROP_PROJ_OX:
  302. g_value_set_double(value, (double)self->priv->params.proj_ox);
  303. break;
  304. case PROP_PROJ_OY:
  305. g_value_set_double(value, (double)self->priv->params.proj_oy);
  306. break;
  307. default:
  308. G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
  309. break;
  310. }
  311. }
  312. static void
  313. ufo_filter_lamino_bp_generic_class_init(UfoFilterLaminoBPGenericClass *klass)
  314. {
  315. GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
  316. UfoFilterReduceClass *filter_class = UFO_FILTER_REDUCE_CLASS(klass);
  317. gobject_class->set_property = ufo_filter_lamino_bp_generic_set_property;
  318. gobject_class->get_property = ufo_filter_lamino_bp_generic_get_property;
  319. gobject_class->finalize = ufo_filter_lamino_bp_generic_finalize;
  320. filter_class->initialize = ufo_filter_lamino_bp_generic_initialize;
  321. filter_class->collect = ufo_filter_lamino_bp_generic_collect;
  322. filter_class->reduce = ufo_filter_lamino_bp_generic_reduce;
  323. lamino_bp_generic_properties[PROP_THETA] =
  324. g_param_spec_double("theta",
  325. "Laminographic angle in radians",
  326. "Laminographic angle in radians",
  327. -4.0 * G_PI, +4.0 * G_PI, 0.0,
  328. G_PARAM_READWRITE);
  329. lamino_bp_generic_properties[PROP_PSI] =
  330. g_param_spec_double("psi",
  331. "Axis misalignment angle in radians",
  332. "Axis misalignment angle in radians",
  333. -4.0 * G_PI, +4.0 * G_PI, 0.0,
  334. G_PARAM_READWRITE);
  335. lamino_bp_generic_properties[PROP_ANGLE_STEP] =
  336. g_param_spec_double("angle-step",
  337. "Increment of rotation angle phi in radians",
  338. "Increment of rotation angle phi in radians",
  339. -4.0 * G_PI, +4.0 * G_PI, 0.0,
  340. G_PARAM_READWRITE);
  341. lamino_bp_generic_properties[PROP_VOL_SX] =
  342. g_param_spec_uint("vol-sx",
  343. "Size of reconstructed volume along the 0X-axis in voxels",
  344. "Size of reconstructed volume along the 0X-axis in voxels",
  345. 0, 1024*8, 512,
  346. G_PARAM_READWRITE);
  347. lamino_bp_generic_properties[PROP_VOL_SY] =
  348. g_param_spec_uint("vol-sy",
  349. "Size of reconstructed volume along the 0Y-axis in voxels",
  350. "Size of reconstructed volume along the 0Y-axis in voxels",
  351. 0, 1024*8, 512,
  352. G_PARAM_READWRITE);
  353. lamino_bp_generic_properties[PROP_VOL_SZ] =
  354. g_param_spec_uint("vol-sz",
  355. "Size of reconstructed volume along the 0Z-axis in voxels",
  356. "Size of reconstructed volume along the 0Z-axis in voxels",
  357. 0, 1024*8, 512,
  358. G_PARAM_READWRITE);
  359. lamino_bp_generic_properties[PROP_VOL_OX] =
  360. g_param_spec_double("vol-ox",
  361. "Volume origin offset from the center of a reco-box along the OX-axis in voxels",
  362. "Volume origin offset from the center of a reco-box along the OX-axis in voxels",
  363. -1024*8, 1024*8, 0,
  364. G_PARAM_READWRITE);
  365. lamino_bp_generic_properties[PROP_VOL_OY] =
  366. g_param_spec_double("vol-oy",
  367. "Volume origin offset from the center of a reco-box along the OY-axis in voxels",
  368. "Volume origin offset from the center of a reco-box along the OY-axis in voxels",
  369. -1024*8, 1024*8, 0,
  370. G_PARAM_READWRITE);
  371. lamino_bp_generic_properties[PROP_VOL_OZ] =
  372. g_param_spec_double("vol-oz",
  373. "Volume origin offset from the center of a reco-box along the OZ-axis in voxels",
  374. "Volume origin offset from the center of a reco-box along the OZ-axis in voxels",
  375. -1024*8, 1024*8, 0,
  376. G_PARAM_READWRITE);
  377. lamino_bp_generic_properties[PROP_PROJ_OX] =
  378. g_param_spec_double("proj-ox",
  379. "Projection of the rotation center on the radiograph origin on the OX-axis",
  380. "Projection of the rotation center on the radiograph origin on the OX-axis",
  381. -1024*8, 1024*8, 0,
  382. G_PARAM_READWRITE);
  383. lamino_bp_generic_properties[PROP_PROJ_OY] =
  384. g_param_spec_double("proj-oy",
  385. "Projection of the rotation center on the radiograph origin on the OY-axis",
  386. "Projection of the rotation center on the radiograph origin on the OY-axis",
  387. -1024*8, 1024*8, 0,
  388. G_PARAM_READWRITE);
  389. g_object_class_install_property(gobject_class, PROP_THETA, lamino_bp_generic_properties[PROP_THETA]);
  390. g_object_class_install_property(gobject_class, PROP_PSI, lamino_bp_generic_properties[PROP_PSI]);
  391. g_object_class_install_property(gobject_class, PROP_ANGLE_STEP, lamino_bp_generic_properties[PROP_ANGLE_STEP]);
  392. g_object_class_install_property(gobject_class, PROP_VOL_SX, lamino_bp_generic_properties[PROP_VOL_SX]);
  393. g_object_class_install_property(gobject_class, PROP_VOL_SY, lamino_bp_generic_properties[PROP_VOL_SY]);
  394. g_object_class_install_property(gobject_class, PROP_VOL_SZ, lamino_bp_generic_properties[PROP_VOL_SZ]);
  395. g_object_class_install_property(gobject_class, PROP_VOL_OX, lamino_bp_generic_properties[PROP_VOL_OX]);
  396. g_object_class_install_property(gobject_class, PROP_VOL_OY, lamino_bp_generic_properties[PROP_VOL_OY]);
  397. g_object_class_install_property(gobject_class, PROP_VOL_OZ, lamino_bp_generic_properties[PROP_VOL_OZ]);
  398. g_object_class_install_property(gobject_class, PROP_PROJ_OX, lamino_bp_generic_properties[PROP_PROJ_OX]);
  399. g_object_class_install_property(gobject_class, PROP_PROJ_OY, lamino_bp_generic_properties[PROP_PROJ_OY]);
  400. /* install private data */
  401. g_type_class_add_private(gobject_class, sizeof(UfoFilterLaminoBPGenericPrivate));
  402. }
  403. static void
  404. ufo_filter_lamino_bp_generic_init(UfoFilterLaminoBPGeneric *self)
  405. {
  406. UfoInputParameter input_params[] = {{2, UFO_FILTER_INFINITE_INPUT}};
  407. UfoOutputParameter output_params[] = {{3}};
  408. // initialize parameters here
  409. self->priv = UFO_FILTER_LAMINO_BP_GENERIC_GET_PRIVATE(self);
  410. self->priv->finished = FALSE;
  411. CLParameters * prms = &(self->priv->params);
  412. prms->theta = 0.0;
  413. prms->psi = 0.0;
  414. prms->angle_step = 0.0;
  415. prms->vol_sx = 512;
  416. prms->vol_sy = 512;
  417. prms->vol_sz = 512;
  418. prms->vol_ox = 0.0;
  419. prms->vol_oy = 0.0;
  420. prms->vol_oz = 0.0;
  421. prms->proj_ox = 0.0;
  422. prms->proj_oy = 0.0;
  423. ufo_filter_register_inputs (UFO_FILTER (self), 1, input_params);
  424. ufo_filter_register_outputs (UFO_FILTER (self), 1, output_params);
  425. }
  426. G_MODULE_EXPORT UfoFilter *
  427. ufo_filter_plugin_new(void)
  428. {
  429. return g_object_new(UFO_TYPE_FILTER_LAMINO_BP_GENERIC, NULL);
  430. }