1 |
// vr.diderot |
// vr-MIP.diderot |
2 |
// |
// |
3 |
// maximum intensity projection in Diderot |
// maximum intensity projection in Diderot |
4 |
// |
// |
5 |
|
|
6 |
input string dataFile; // name of dataset |
input string dataFile; // name of dataset |
7 |
input real stepSz; // size of steps |
input real stepSz; // size of steps |
8 |
input vec<3> light; |
input vec3 eye; // location of eye point |
9 |
input int wid = 640; |
input vec3 orig; // location of pixel (0,0) |
10 |
input int ht = 480; |
input vec3 cVec; // vector between pixels horizontally |
11 |
|
input vec3 rVec; // vector between pixels vertically |
12 |
|
|
13 |
image[3] img = load (dataFile); |
image(3)[] img = load (dataFile); |
14 |
|
|
15 |
field#1[3] F = convolve (bspln3, img); |
//field#1(3)[] F = convolve (bspln3, img); |
16 |
|
field#2(3)[] F = convolve (bspln3, img); |
17 |
|
|
18 |
actor RayCast (int row, int col) |
actor RayCast (int row, int col) |
19 |
{ |
{ |
20 |
vec<3> dir = (real(row), real(col), 0.0); |
vec3 pos = orig + real(row)*rVec + real(col)*cVec; |
21 |
vec<3> pos = (0.0, 0.0, 0.0); |
vec3 dir = (pos - eye)/|pos - eye|; |
22 |
real t = 0.0; |
real t = 0.0; |
23 |
real maxval = -inf; |
real maxval = -inf; |
24 |
int num = 0; |
int num = 0; |
25 |
|
|
26 |
update |
update |
27 |
{ |
{ |
28 |
vec<3> pt = pos + t*dir; |
vec3 pt = pos + t*dir; |
29 |
real val = F@pt; |
real val = F@pt; |
30 |
maxval = max(val, maxval); |
maxval = max(val, maxval); |
31 |
if (t > 1) |
if (t > 1.0) |
32 |
stabilize; |
stabilize; |
33 |
t = t + stepSz; |
t = t + stepSz; |
34 |
num = num + 1; |
num = num + 1; |
36 |
|
|
37 |
/* render: output maxval */ |
/* render: output maxval */ |
38 |
} |
} |
39 |
|
|
40 |
|
initially [ RayCast(r, c) | r in 0..1023, c in 0..1023 ]; |