1 |
__kernel void probe (float * img, |
__kernel void probe (float * img, |
2 |
|
float * h0, |
3 |
float * h1, |
float * h1, |
4 |
float * h2, |
float * h2, |
5 |
|
float * h3, |
6 |
float * posValues, |
float * posValues, |
7 |
float * out, |
float * out, |
8 |
float16 transformMatrix, |
float16 transformMatrix, |
16 |
posValues[(location *3) + 2],1.0f); |
posValues[(location *3) + 2],1.0f); |
17 |
|
|
18 |
float probedVal; |
float probedVal; |
19 |
float4 t_k, f, imgPt,nf,v, hx, hy, hz, h_tx, h_ty, hMult; |
float4 f, imgPt,nf,v, hx, hy, hz, h_tx, h_ty, hMult; |
20 |
int4 n1; |
int4 n1; |
21 |
|
|
22 |
float4 d = (float4) (h2[0],h1[0],h1[0],h2[0]); |
float4 d = (float4) (h0[0],h1[0],h2[0],h3[0]); |
23 |
float4 c = (float4) (h2[1],h1[1],h1[1],h2[1]); |
float4 c = (float4) (h0[1],h1[1],h2[1],h3[1]); |
24 |
float4 b = (float4) (h2[2],h1[2],h1[2],h2[2]); |
float4 b = (float4) (h0[2],h1[2],h2[2],h3[2]); |
25 |
float4 a = (float4) (h2[3],h1[3],h1[3],h2[3]); |
float4 a = (float4) (h0[3],h1[3],h2[3],h3[3]); |
26 |
|
|
27 |
// Transform the value to image space position. |
// Transform the value to image space position. |
28 |
imgPt = (float4) (dot(pos,transformMatrix.s0123), |
imgPt = (float4) (dot(pos,transformMatrix.s0123), |
45 |
*/ |
*/ |
46 |
|
|
47 |
// the t value for h(fx - i) |
// the t value for h(fx - i) |
48 |
float t_i[4] = {-1.0 - f.x, -f.x, f.x - 1.0, f.x - 2.0}; |
float4 t_i = (float4) (f.x + 1.0, f.x, f.x - 1.0, f.x - 2.0); |
49 |
|
|
50 |
// the t value for h(fy - j) |
// the t value for h(fy - j) |
51 |
float t_j[4] = {-1.0 - f.y, -f.y, f.y - 1.0, f.y - 2.0}; |
float4 t_j = (float4) (f.y + 1.0, f.y, f.y - 1.0, f.y - 2.0); |
|
|
|
|
t_k = (float4) (-1.0 - f.z, -f.z, f.z - 1.0, f.z - 2.0); |
|
52 |
|
|
53 |
|
float4 t_k = (float4) (f.z + 1.0, f.z, f.z - 1.0, f.z - 2.0); |
54 |
|
float4 h_k = d + t_k * (c + t_k * (b + t_k * a)); |
55 |
float tx[4], ty[4]; |
float tx[4], ty[4]; |
|
|
|
56 |
for (int i = -1; i <= 2; i++) { |
for (int i = -1; i <= 2; i++) { |
57 |
for (int j = -1; j <= 2; j++) { |
for (int j = -1; j <= 2; j++) { |
58 |
// compute z axis using vectors |
// compute z axis using vectors |
62 |
img[index+1], |
img[index+1], |
63 |
img[index+2], |
img[index+2], |
64 |
img[index+3]); |
img[index+3]); |
65 |
|
ty[j+1] = dot(v, h_k); |
|
|
|
|
h_tx = (float4) (t_i[i+1],t_i[i+1],t_i[i+1],t_i[i+1]); |
|
|
|
|
|
hx = (d + h_tx * (c + h_tx * (b + h_tx * a))); |
|
|
|
|
|
h_ty = (float4) (t_j[j+1],t_j[j+1],t_j[j+1],t_j[j+1]); |
|
|
|
|
|
hy = (d + h_ty * (c + h_ty * (b + h_ty * a))); |
|
|
|
|
|
hz = (d + t_k * (c + t_k * (b + t_k * a))); |
|
|
|
|
|
ty[j+1] = dot(v, (hx * hy * hz)); |
|
|
|
|
|
|
|
|
/* //Debugging |
|
|
if(location==1) |
|
|
{ |
|
|
printf("========J:%d======\nImage Data:(%f,%f,%f,%f)\n",j,v.x,v.y,v.z,v.w); |
|
|
printf("hx:(%f,%f,%f,%f)\nhx:(%f,%f,%f,%f)\nhz:(%f,%f,%f,%f)\n", |
|
|
hx.x,hx.y,hx.z,hx.w, |
|
|
hy.x,hy.y,hy.z,hy.w, |
|
|
hz.x,hz.y,hz.z,hz.w); |
|
|
printf("hMult:(%f,%f,%f,%f)\n",hMult.x,hMult.y,hMult.z,hMult.w); |
|
|
printf("ty[%d]: %f\n",j+1,ty[j+1]); |
|
|
|
|
66 |
} |
} |
67 |
*/ |
tx[i+1] = dot((float4)(ty[0], ty[1], ty[2], ty[3]), d + t_j * (c + t_j * (b + t_j * a))); |
|
|
|
68 |
} |
} |
69 |
//tx[i+1] = dot((float4)(ty[0], ty[1], ty[2], ty[3]), d + t_j * (c + t_j * (b + t_j * a))); |
probedVal = dot((float4)(tx[0],tx[1],tx[2],tx[3]), d + t_i * (c + t_i * (b + t_i * a))); |
|
tx[i+1] = ty[0] + ty[1] + ty[2] + ty[3]; |
|
|
} |
|
|
//probedVal = dot((float4)(tx[0],tx[1],tx[2],tx[3]), d + t_i * (c + t_i * (b + t_i * a))); |
|
|
|
|
|
probedVal = tx[0] + tx[1] + tx[2] + tx[3]; |
|
70 |
|
|
71 |
out[location] = probedVal; |
out[location] = probedVal; |
72 |
} |
} |