Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] Annotation of /trunk/test/MIP/mip.cl
ViewVC logotype

Annotation of /trunk/test/MIP/mip.cl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 218 - (view) (download)

1 : lamonts 203 __kernel void raycast ( float * img,
2 :     float * h1,
3 :     float * h2,
4 :     float * out,
5 : lamonts 177 float4 orig,
6 :     float4 eyeVector,
7 :     float4 cVec,
8 :     float4 rVec,
9 :     float16 transformMatrix,
10 :     float stepSize,
11 :     int length,
12 : lamonts 203 int width,
13 :     int height)
14 : lamonts 177 {
15 :     int row = get_global_id(0), col = get_global_id(1);
16 :    
17 : jhr 218 if(row <= 200 && col <= 200)
18 : lamonts 177 {
19 :     float t,x,y,z,probedVal, maxValue = -INFINITY;
20 : jhr 218 float4 t_i, t_j, t_k, value, f, imgPt, pt, v, nf;
21 : lamonts 191 int4 n1;
22 :     int4 n;
23 :    
24 : lamonts 177 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 : jhr 218 float4 pos = orig + (float)row * rVec + (float)col * cVec;
30 :     float4 dir = normalize(pos - eyeVector);
31 :     float4 NSize = (float4) ((float)height,(float)length,(float)width,1.0f);
32 :    
33 :     for(t = 0.0; t < 40; t+= stepSize)
34 : lamonts 177 {
35 :    
36 :     pos = pos + stepSize * dir;
37 :    
38 :     // Begin Probe Operation
39 :    
40 :     // Transform the value to image space position.
41 :     imgPt = (float4) (dot(pos,transformMatrix.s0123),
42 : jhr 218 dot(pos,transformMatrix.s4567),
43 :     dot(pos,transformMatrix.s89ab),
44 :     dot(pos,transformMatrix.scdef));
45 : lamonts 177
46 : jhr 218 nf = floor(imgPt);
47 :     f = imgPt - nf;
48 :     n1 = convert_int4(nf);
49 :    
50 : lamonts 203 if( (imgPt.x > 1 && imgPt.x < NSize.x - 2) &&
51 :     (imgPt.y > 1 && imgPt.y < NSize.y - 2) &&
52 :     (imgPt.z > 1 && imgPt.z < NSize.z - 2))
53 : lamonts 191 {
54 :     // the t value for h(fx - i)
55 : jhr 218 float4 t_i = (float4) (-1.0 - f.x, -f.x, f.x - 1.0, f.x - 2.0);
56 : lamonts 191 // the t value for h(fy - j)
57 : jhr 218 float4 t_j = (float4) (-1.0 - f.y, -f.y, f.y - 1.0, f.y - 2.0);
58 :     float4 t_k = (float4) (-1.0 - f.z, -f.z, f.z - 1.0, f.z - 2.0);
59 :     float tx[4], ty[4];
60 :     for (int i = -1; i <= 2; i++) {
61 :     for (int j = -1; j <= 2; j++) {
62 :     // compute z axis using vectors
63 :     v = (float4)(
64 :     img[(n1.x+i) * length * width + (n1.y+j) * width + n1.z-1],
65 :     img[(n1.x+i) * length * width + (n1.y+j) * width + n1.z],
66 :     img[(n1.x+i) * length * width + (n1.y+j) * width + n1.z+1],
67 :     img[(n1.x+i) * length * width + (n1.y+j) * width + n1.z+2]);
68 :     ty[j+1] = dot(v, d + t_k * (c + t_k * (b + t_k * a)));
69 :     }
70 :     tx[i+1] = dot((float4)(ty[0], ty[1], ty[2], ty[3]), d + t_j * (c + t_j * (b + t_j * a)));
71 :     }
72 :     probedVal = dot((float4)(tx[0],tx[1],tx[2],tx[3]), d + t_i * (c + t_i * (b + t_i * a)));
73 :    
74 :     if ((row == 100) && (col == 100))
75 :     printf("%f %f %f\n", t, f.z, probedVal);
76 : lamonts 203 // End Probe Operation
77 : jhr 218 if(maxValue < probedVal)
78 : lamonts 203 maxValue = probedVal;
79 : lamonts 191 }
80 : lamonts 203 }
81 :     if(row == 0 && col == 74)
82 :     printf("Max Value: %f\n", maxValue );
83 : jhr 218 out[row * 201 + col] = maxValue;
84 : lamonts 177 }
85 :     }

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0