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

SCM Repository

[diderot] Annotation of /trunk/test/lic2.diderot
ViewVC logotype

Annotation of /trunk/test/lic2.diderot

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2636 - (view) (download)

1 : glk 1334 // 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 :     real h = 0.01; // step size of integration
12 :     int stepNum = 25; // take this many steps both upstream and downstream
13 :    
14 : jhr 2636 field#1(2)[2] V = image("../data/vorttest.nrrd") ⊛ ctmr;
15 :     field#0(2)[] R = image("../data/vorttest-rand.nrrd") ⊛ tent;
16 : glk 1334
17 :     strand LIC (int xi, int yi) {
18 :     real xx = lerp(0.0, 3.0, -0.5, real(xi), real(imgSizeX)-0.5);
19 :     real yy = lerp(0.0, 2.0, -0.5, real(yi), real(imgSizeY)-0.5);
20 :     vec2 pos0 = [xx,yy];
21 :     vec2 pos = [xx,yy];
22 :     bool forw = true;
23 :     output real sum = R(pos0);
24 :     int step = 0;
25 :    
26 :     update {
27 :     if (forw) {
28 :     pos += h*V(pos + 0.5*h*V(pos));
29 :     sum += R(pos);
30 :     if (step == stepNum) {
31 :     forw = false;
32 :     pos = pos0;
33 :     }
34 :     } else { // going backwards, not forward
35 :     pos -= h*V(pos - 0.5*h*V(pos));
36 :     sum += R(pos);
37 :     if (step == stepNum) {
38 :     // modulate output by velocity at initial position
39 :     sum = |V(pos0)|*sum/real(1 + 2*stepNum);
40 :     stabilize;
41 :     }
42 :     }
43 :     }
44 :     }
45 :    
46 :     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