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 1027 - (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 979 real h = 0.01; // step size of integration
12 : glk 938 int stepNum = 25; // take this many steps both upstream and downstream
13 : glk 934
14 : glk 1027 //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 : glk 934
19 : glk 1027 // HEY (BUG): the program compiles and run with these two field definitions
20 :     // but the results are NOT correct!!
21 :     // Correct result obtained with four-line field definition above
22 :     field#1(2)[2] V = load("../data/vorttest.nrrd") ⊛ ctmr;
23 :     field#0(2)[] R = load("../data/vorttest-rand.nrrd") ⊛ tent;
24 :    
25 :    
26 : glk 934 strand LIC (int xi, int yi) {
27 :     real xx = lerp(0.0, 3.0, -0.5, real(xi), real(imgSizeX)-0.5);
28 :     real yy = lerp(0.0, 2.0, -0.5, real(yi), real(imgSizeY)-0.5);
29 :     vec2 pos0 = [xx,yy];
30 : glk 937 vec2 forw = pos0;
31 :     vec2 back = pos0;
32 : glk 939 output real sum = R(pos0);
33 : glk 934 int step = 0;
34 :    
35 :     update {
36 : glk 937 // Euler integration step
37 :     // forw = forw + h*V(forw);
38 :     // back = back - h*V(back);
39 :     // Midpoint method step
40 :     forw = forw + h*V(forw + 0.5*h*V(forw));
41 :     back = back - h*V(back - 0.5*h*V(back));
42 : glk 939 sum = sum + R(forw) + R(back);
43 : glk 934 step = step + 1;
44 :     if (step == stepNum) {
45 :     // modulate output by velocity at initial position
46 : glk 939 sum = |V(pos0)|*sum/real(1 + 2*stepNum);
47 : glk 934 stabilize;
48 :     }
49 :     }
50 :     }
51 :    
52 :     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