SCM Repository
Annotation of /trunk/test/MIP/mip.cl
Parent Directory
|
Revision Log
Revision 177 - (view) (download)
1 : | lamonts | 177 | __kernel void raycast (__global float * img, |
2 : | __global float * h1, | ||
3 : | __global float * h2, | ||
4 : | __global float * out, | ||
5 : | float4 orig, | ||
6 : | float4 eyeVector, | ||
7 : | float4 cVec, | ||
8 : | float4 rVec, | ||
9 : | float16 transformMatrix, | ||
10 : | float stepSize, | ||
11 : | int length, | ||
12 : | int width) | ||
13 : | { | ||
14 : | int row = get_global_id(0), col = get_global_id(1); | ||
15 : | |||
16 : | if(row < 200 && col < 200) | ||
17 : | { | ||
18 : | int i; | ||
19 : | float t,x,y,z,probedVal, maxValue = -INFINITY; | ||
20 : | float4 t_i, t_j, t_k, value, f, imgPt, pt, v; | ||
21 : | int4 n; | ||
22 : | |||
23 : | |||
24 : | float4 d = (float4) (h2[0],h1[0],h1[0],h2[0]); | ||
25 : | float4 c = (float4) (h2[1],h1[1],h1[1],h2[1]); | ||
26 : | float4 b = (float4) (h2[2],h1[2],h1[2],h2[2]); | ||
27 : | float4 a = (float4) (h2[3],h1[3],h1[3],h2[3]); | ||
28 : | |||
29 : | float4 pos = orig + (float)row * rVec + (float)col * cVec; | ||
30 : | float4 dir = (pos - eyeVector) / fabs(pos - eyeVector); | ||
31 : | |||
32 : | pt.w = 1.0f; | ||
33 : | pos.w = 1.0f; | ||
34 : | dir.w = 1.0f; | ||
35 : | value.w = 1.0f; | ||
36 : | |||
37 : | for(t = 0.0; t < 20; t+= stepSize) | ||
38 : | { | ||
39 : | |||
40 : | pos = pos + stepSize * dir; | ||
41 : | |||
42 : | // Begin Probe Operation | ||
43 : | |||
44 : | // Transform the value to image space position. | ||
45 : | imgPt = (float4) (dot(pos,transformMatrix.s0123), | ||
46 : | dot(pos,transformMatrix.s4567), | ||
47 : | dot(pos,transformMatrix.s89ab), | ||
48 : | dot(pos,transformMatrix.scdef)); | ||
49 : | |||
50 : | |||
51 : | f.xyzw = (float4) (modf(imgPt.x,&x),modf(imgPt.y,&y),modf(imgPt.z,&z),1.0f); | ||
52 : | n = (int4)((int)x,(int)y,(int)z,1); | ||
53 : | |||
54 : | |||
55 : | // the t value for h(fx - i) | ||
56 : | t_i = (float4) (-1.0-f.x, -f.x,f.x - 1.0, f.x - 2.0); | ||
57 : | |||
58 : | // the t value for h(fy - j) | ||
59 : | t_j = (float4) (-1.0-f.y, -f.y, f.y - 1.0,f.x - 2.0); | ||
60 : | |||
61 : | // the t value for h(fx - k) | ||
62 : | t_k = (float4) (-1.0-f.z, -f.z, f.z - 1.0,f.z - 2.0); | ||
63 : | |||
64 : | |||
65 : | value = ( (d + t_i * (c + t_i * (b + t_i * a))) * // h(fx - i) * | ||
66 : | (d + t_j * (c + t_j * (b + t_j * a))) * // h(fy - j) * | ||
67 : | (d + t_k * (c + t_k * (b + t_k * a)))); // h(fz - k) | ||
68 : | |||
69 : | |||
70 : | n.x = abs((n.x-1) * length * width + n.y-1 * width + n.z-1); | ||
71 : | n.y = abs(n.x * length * width + n.y * width + n.z); | ||
72 : | n.z = abs((n.x+1) * length * width + n.y+1 * width + n.z+1); | ||
73 : | n.w = abs((n.x+2) * length * width + n.y+2 * width + n.z+2); | ||
74 : | |||
75 : | |||
76 : | /* if(n.x >= 2912 || n.y >= 2912 || n.z >= 2912 || n.w >= 2912) | ||
77 : | { | ||
78 : | printf("Row:%d, Col:%d\n",row,col); | ||
79 : | } | ||
80 : | else | ||
81 : | v = (float4)(img[n.x], | ||
82 : | img[n.y], | ||
83 : | img[n.z], | ||
84 : | img[n.w]); | ||
85 : | |||
86 : | */ | ||
87 : | |||
88 : | probedVal = dot(v,value); // V(n + <i,j,k>) * summations of h(x) components | ||
89 : | |||
90 : | |||
91 : | // End Probe Operation | ||
92 : | if(maxValue < probedVal) | ||
93 : | maxValue = probedVal; | ||
94 : | } | ||
95 : | |||
96 : | out[row * 200 + col] = maxValue; | ||
97 : | } | ||
98 : | } |
root@smlnj-gforge.cs.uchicago.edu | ViewVC Help |
Powered by ViewVC 1.0.0 |