123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- /*
- * Copyright (C) 2011-2014 Karlsruhe Institute of Technology
- *
- * This file is part of Ufo.
- *
- * This library is free software: you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation, either
- * version 3 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
- kernel void backproject (global float *volume,
- read_only image2d_t projection,
- const sampler_t sampler,
- const float2 x_region,
- const float2 y_region,
- const float2 z_region,
- const float8 tmatrix,
- const uint cumulate)
- {
- int3 id = (int3) (get_global_id (0), get_global_id (1), get_global_id (2));
- float2 pixel;
- float3 voxel;
- voxel.x = mad((float) id.x, x_region.y, x_region.x);
- voxel.y = mad((float) id.y, y_region.y, y_region.x);
- voxel.z = mad((float) id.z, z_region.y, z_region.x);
- pixel.x = mad(voxel.x, tmatrix.s0, mad(voxel.y, tmatrix.s1, tmatrix.s3));
- pixel.y = mad(voxel.x, tmatrix.s4, mad(voxel.y, tmatrix.s5, mad(voxel.z, tmatrix.s6, tmatrix.s7)));
-
- if (cumulate) {
- volume[id.z * get_global_size (0) * get_global_size (1) +
- id.y * get_global_size (0) + id.x] += read_imagef (projection, sampler, pixel).x;
- }
- else {
- volume[id.z * get_global_size (0) * get_global_size (1) +
- id.y * get_global_size (0) + id.x] = read_imagef (projection, sampler, pixel).x;
- }
- }
- kernel void backproject_from_3d (global float *volume,
- read_only image3d_t projections,
- const sampler_t sampler,
- const float2 x_region,
- const float2 y_region,
- const float2 z_region,
- constant float *sines,
- constant float *cosines,
- const float2 center,
- const float sin_lamino,
- const float cos_lamino)
- {
- int3 id = (int3) (get_global_id (0), get_global_id (1), get_global_id (2));
- int i;
- float result = 0.0f;
- float4 pixel;
- float3 voxel;
- voxel.x = mad((float) id.x, x_region.y, x_region.x);
- voxel.y = mad((float) id.y, y_region.y, y_region.x);
- voxel.z = mad((float) id.z, z_region.y, z_region.x);
- for (i = 0; i < get_image_depth (projections); i++) {
- pixel.x = voxel.x * cosines[i] + voxel.y * sines[i] + center.x;
- pixel.y = voxel.x * cos_lamino * sines[i] - voxel.y * cos_lamino * cosines[i] + voxel.z * sin_lamino + center.y;
- pixel.z = (float) i;
- result += read_imagef (projections, sampler, pixel).x;
- }
- volume[id.z * get_global_size (0) * get_global_size (1) + id.y * get_global_size (0) + id.x] = result;
- }
|