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

SCM Repository

[diderot] Annotation of /tests/glk-tests/back/lic2d.diderot
ViewVC logotype

Annotation of /tests/glk-tests/back/lic2d.diderot

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4640 - (view) (download)

1 : glk 4640 /*
2 :     $DDRO_HOME/branches/vis12/bin/diderotc --exec lic2d.diderot \
3 :     $DDRO_HOME/branches/charisee/bin/diderotc lic2d.diderot \
4 :     && ./lic2d \
5 :     && unu project -i rgb.nrrd -a 1 -m mean \
6 :     | unu quantize -b 8 -min 0.2% -max 0.2% -o _lic2d.png \
7 :     && unu resample -i _lic2d.png -s = /1.5 /1.5 -o lic2d.png \
8 :     && xv lic2d.png
9 :    
10 :     */
11 :    
12 :     int sizeX = 1020*2;
13 :     int sizeY = 561*2;
14 :     real h0 = 0.003; // step size of integration
15 :     int stepNum = 80; // steps taken up or downstream
16 :     real stdv = sqrt(1.0/stepNum);
17 :    
18 :     field#1(2)[2] V = bspln3 ⊛ image("flow.nrrd");
19 :     field#1(2)[2] nV = normalize(V);
20 :     field#0(2)[] R = tent ⊛ image("rand.nrrd");
21 :     field#0(1)[3] cmap = tent ⊛ image("cmap.nrrd");
22 :     strand LIC(vec2 x0, real sign) {
23 :     real h = sign*h0;
24 :     vec2 x = x0;
25 :     int step = 0;
26 :     real sum = R(x0)/2;
27 :     output vec3 rgb = [0,0,0];
28 :     update {
29 :     x += h*nV(x + 0.5*h*nV(x)); // Midpoint method
30 :     if (step == stepNum || !inside(x, R))
31 :     stabilize;
32 :     sum += R(x);
33 :     step += 1;
34 :     }
35 :     stabilize {
36 :     sum *= sqrt(|V(x0)|)/stepNum;
37 :     real gray = lerp(0, 1, -stdv, sum, stdv);
38 :     rgb = cmap(∇×V(x0)) * clamp(0, 1, gray);
39 :     }
40 :     }
41 :     initially [ LIC([lerp(0, 6.78, -0.5, xi, sizeX-0.5),
42 :     lerp(0, 3.72, -0.5, yi, sizeY-0.5)],
43 :     lerp(-1, 1, 0, si, 1))
44 :     | yi in 0..(sizeY-1), xi in 0..(sizeX-1),
45 :     si in 0..1 ];

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