ankabackproject.cl 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * Copyright (C) 2011-2014 Karlsruhe Institute of Technology
  3. *
  4. * This file is part of Ufo.
  5. *
  6. * This library is free software: you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation, either
  9. * version 3 of the License, or (at your option) any later version.
  10. *
  11. * This library is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. __kernel void backproject (global float *volume,
  20. __read_only image2d_t projection,
  21. const sampler_t sampler,
  22. const int2 x_region,
  23. const int2 y_region,
  24. const int2 z_region,
  25. const float8 tmatrix,
  26. const int2 offset,
  27. const uint cumulate)
  28. {
  29. int3 id = (int3) (get_global_id (0), get_global_id (1), get_global_id (2));
  30. float2 pixel;
  31. float3 voxel;
  32. voxel.x = x_region.x + id.x * x_region.y;
  33. voxel.y = y_region.x + id.y * y_region.y;
  34. voxel.z = z_region.x + id.z * z_region.y;
  35. pixel.x = voxel.x * tmatrix.s0 + voxel.y * tmatrix.s1 + tmatrix.s3 - offset.x;
  36. pixel.y = voxel.x * tmatrix.s4 + voxel.y * tmatrix.s5 + voxel.z * tmatrix.s6 + tmatrix.s7 - offset.y;
  37. if (cumulate) {
  38. volume[id.z * get_global_size (0) * get_global_size (1) +
  39. id.y * get_global_size (0) + id.x] += read_imagef (projection, sampler, pixel).x;
  40. }
  41. else {
  42. volume[id.z * get_global_size (0) * get_global_size (1) +
  43. id.y * get_global_size (0) + id.x] = read_imagef (projection, sampler, pixel).x;
  44. }
  45. }