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

SCM Repository

[diderot] Annotation of /branches/tash/test/lic.diderot
ViewVC logotype

Annotation of /branches/tash/test/lic.diderot

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3217 - (view) (download)

1 : jhr 1115 // 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 1927 field#1(2)[2] V = image("../data/vorttest.nrrd") ⊛ ctmr;
15 :     field#0(2)[] R = image("../data/vorttest-rand.nrrd") ⊛ tent;
16 : jhr 1115
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 : glk 1335 vec2 forw = pos0;
22 :     vec2 back = pos0;
23 : jhr 1115 output real sum = R(pos0);
24 :     int step = 0;
25 :    
26 :     update {
27 : glk 1335 // Euler integration step
28 :     // forw = forw + h*V(forw);
29 :     // back = back - h*V(back);
30 : jhr 1115 // Midpoint method step
31 : glk 1335 forw += h*V(forw + 0.5*h*V(forw));
32 :     back -= h*V(back - 0.5*h*V(back));
33 : glk 1330 sum += R(forw) + R(back);
34 : glk 1335 step += 1;
35 : jhr 1115 if (step == stepNum) {
36 :     // modulate output by velocity at initial position
37 :     sum = |V(pos0)|*sum/real(1 + 2*stepNum);
38 :     stabilize;
39 :     }
40 :     }
41 :     }
42 :    
43 :     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