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 934 - (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 :    
10 :     int imgSizeX = 300;
11 :     int imgSizeY = 200;
12 :     real h = 0.01;
13 :     int stepNum = 20;
14 :    
15 :     image(2)[2] Vimg = load("../data/vorttest.nrrd");
16 :     field#1(2)[2] V = Vimg ⊛ ctmr;
17 :     image(2)[] Rimg = load("../data/vorttest-rand.nrrd");
18 :     field#0(2)[] R = Rimg ⊛ tent;
19 :    
20 :     strand LIC (int xi, int yi) {
21 :     real xx = lerp(0.0, 3.0, -0.5, real(xi), real(imgSizeX)-0.5);
22 :     real yy = lerp(0.0, 2.0, -0.5, real(yi), real(imgSizeY)-0.5);
23 :     vec2 pos0 = [xx,yy];
24 :     vec2 pos = pos0;
25 :     output real avg = 0.0;
26 :     int step = 0;
27 :    
28 :     update {
29 :     avg = avg + R(pos);
30 :     // pos = pos + h*V(pos); // Euler step
31 :     pos = pos + h*V(pos + 0.5*h*V(pos)); // RK2 step
32 :     step = step + 1;
33 :     if (step == stepNum) {
34 :     // modulate output by velocity at initial position
35 :     avg = |V(pos0)|*avg/real(stepNum);
36 :     stabilize;
37 :     }
38 :     }
39 :     }
40 :    
41 :     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