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

SCM Repository

[diderot] Annotation of /branches/pure-cfg/test/lic.diderot
ViewVC logotype

Annotation of /branches/pure-cfg/test/lic.diderot

Parent Directory Parent Directory | Revision Log Revision Log


Revision 939 - (view) (download)

1 : glk 934 // lic.diderot
2 :     //
3 :     // simple demo of the line integral convolution (LIC) method
4 :     // of vector field viz
5 :     //
6 :     // process output with:
7 :     // unu reshape -i mip.txt -s 300 200 | unu quantize -b 8 -o lic.png
8 :    
9 :     int imgSizeX = 300;
10 :     int imgSizeY = 200;
11 : glk 938 real h = 0.01; // step size of integration
12 :     int stepNum = 25; // take this many steps both upstream and downstream
13 : glk 934
14 :     image(2)[2] Vimg = load("../data/vorttest.nrrd");
15 :     field#1(2)[2] V = Vimg ⊛ ctmr;
16 :     image(2)[] Rimg = load("../data/vorttest-rand.nrrd");
17 :     field#0(2)[] R = Rimg ⊛ tent;
18 :    
19 :     strand LIC (int xi, int yi) {
20 :     real xx = lerp(0.0, 3.0, -0.5, real(xi), real(imgSizeX)-0.5);
21 :     real yy = lerp(0.0, 2.0, -0.5, real(yi), real(imgSizeY)-0.5);
22 :     vec2 pos0 = [xx,yy];
23 : glk 937 vec2 forw = pos0;
24 :     vec2 back = pos0;
25 : glk 939 output real sum = R(pos0);
26 : glk 934 int step = 0;
27 :    
28 :     update {
29 : glk 937 // Euler integration step
30 :     // forw = forw + h*V(forw);
31 :     // back = back - h*V(back);
32 :     // Midpoint method step
33 :     forw = forw + h*V(forw + 0.5*h*V(forw));
34 :     back = back - h*V(back - 0.5*h*V(back));
35 : glk 939 sum = sum + R(forw) + R(back);
36 : glk 934 step = step + 1;
37 :     if (step == stepNum) {
38 :     // modulate output by velocity at initial position
39 : glk 939 sum = |V(pos0)|*sum/real(1 + 2*stepNum);
40 : glk 934 stabilize;
41 :     }
42 :     }
43 :     }
44 :    
45 :     initially [ LIC(xi, yi) | yi in 0..(imgSizeY-1), xi in 0..(imgSizeX-1) ];

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