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

SCM Repository

[diderot] Diff of /branches/vis12/test/hlic/hlic.diderot
ViewVC logotype

Diff of /branches/vis12/test/hlic/hlic.diderot

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2187, Sun Feb 24 03:42:23 2013 UTC revision 2188, Sun Feb 24 03:42:57 2013 UTC
# Line 1  Line 1 
1  /*  /*
2     generate and process output out.nrrd with:     generate and process output out.nrrd with:
3     unu axdelete -i out.nrrd -a -1 | unu quantize -b 8 -o hlic.png  
4    ./hlic -ei 0 ; mv sum.nrrd 0.nrrd
5    ./hlic -ei 1 ; mv sum.nrrd 1.nrrd
6    unu join -i {0,1,0}.nrrd -a 0 -incr \
7     | unu project -a 3 -m sum \
8     | unu quantize -b 8 -min 1% -max 1% -o hlic.png
9    
10  */  */
11    
12  int imgSize = 400;  int imgSize = 400;
13  real hh = 0.15;    // step size of integration  real hh = 0.3;     // step size of integration
14  int stepNum = 40; // take this many steps both upstream and downstream  real anisoMin = 0.25;
15    int stepMax = 50;  // take at most this many steps
16    input int ei = 1;
17    
18  field#1(2)[2] V = image("tor2slice-evec.nrrd") ⊛ ctmr;  field#1(2)[2,2] T = image("tor2slice.nrrd") ⊛ bspln3;
 field#1(2)[2,2] T = image("tor2slice.nrrd") ⊛ ctmr;  
19  field#0(2)[] R = image("tor2slice-rand.nrrd") ⊛ tent;  field#0(2)[] R = image("tor2slice-rand.nrrd") ⊛ tent;
20  field#1(2)[2,2] T = load("tor2slice.nrrd") ⊛ ctmr;  field#0(2)[] ins = image("tor2slice-inside.nrrd") ⊛ tent;
21    
22    function vec2 dir(vec2 reference, vec2 pos) {
23        vec2 ev = evecs(T(pos)){ei};
24        return ev if (ev•reference > 0) else -ev;
25    }
26    
27    function real aniso(vec2 pos) = (evals(T(pos)){0} - evals(T(pos)){1})/|T(pos)|;
28    
29  strand LIC (int xi, int yi) {  function real contrast(real ani) = clamp(0, 1, lerp(0, 1, anisoMin, ani, 1));
30      vec2 pos0 = [lerp(0.0, 79.0, -0.5, real(xi), real(imgSize)-0.5),  
31                   lerp(0.0, 79.0, -0.5, real(yi), real(imgSize)-0.5)];  strand HLIC (real sign, vec2 pos0) {
32        vec2 prev = hh*sign*evecs(T(pos0)){ei};
33      vec2 pos = pos0;      vec2 pos = pos0;
34      vec2 step = [0.0,0.0];      vec2 step = [0.0,0.0];
35      output real out = 0.0;      output real sum = 0.0;
     real sum = 0.0;  
36      int stepIdx = 0;      int stepIdx = 0;
     real sign = 1.0;  
     vec2 refdir = [0.0,0.0];  
     vec2 dir = [0.0,0.0];  
     tensor[2,2,2] x = ∇⊗T(pos);  
37    
38      update {      update {
39        vec2 nondir = evecs(T(pos)){0};          // RK2
40        if (0 == stepIdx) {          step = hh*dir(prev, pos + 0.5*hh*dir(prev, pos));
41          refdir = sign*nondir;          // Euler
42          dir = refdir;          //step = hh*dir(prev, pos);
         // HEY want to be able to say:  
         // dir = refdir = sign*nondir;  
       } else {  
         dir = nondir if (nondir•refdir >= 0.0) else -nondir;  
         refdir = dir;  
       }  
       step = hh*dir;  
       if (inside(pos + step, V) && inside(pos + step, R)) {  
43          pos += step;          pos += step;
44          sum += R(pos);          sum += contrast(aniso(pos))*R(pos);
       }  
       if (stepIdx < stepNum) {  
45          stepIdx += 1;          stepIdx += 1;
46        } else {          prev = step;
47          if (sign > 0.0) {          if (stepIdx == stepMax || !inside(pos, ins) || aniso(pos) < anisoMin) {
           sign = -1.0;  
           stepIdx = 0;  
           pos = pos0;  
         } else {  
48            stabilize;            stabilize;
49          }          }
50        }        }
     }  
   
51      stabilize {      stabilize {
52        out = sum*(evals(T(pos0)){0} - evals(T(pos0)){1});          sum *= contrast(aniso(pos0))/stepIdx;
53      }      }
54  }  }
55    
56  initially [ LIC(xi, yi) | yi in 0..(imgSize-1), xi in 0..(imgSize-1) ];  initially [ HLIC(lerp(-1, 1, 0, si, 1),
57                     [lerp(0.0, 81.0, -0.5, xi, imgSize-0.5),
58                      lerp(0.0, 81.0, -0.5, yi, imgSize-0.5)])
59                | si in 0..1, yi in 0..imgSize-1, xi in 0..imgSize-1];

Legend:
Removed from v.2187  
changed lines
  Added in v.2188

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