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

SCM Repository

[diderot] View of /branches/lamont/test/hlic/hlic-deriv.diderot
ViewVC logotype

View of /branches/lamont/test/hlic/hlic-deriv.diderot

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2081 - (download) (annotate)
Mon Nov 5 23:26:06 2012 UTC (7 years ago) by lamonts
File size: 1719 byte(s)
Creating new developmented branch based on vis12
/*
   generate and process output out.nrrd with:
   unu axdelete -i out.nrrd -a -1 | unu quantize -b 8 -o hlic.png
*/

int imgSize = 400;
real hh = 0.15;    // step size of integration
int stepNum = 40; // take this many steps both upstream and downstream

field#1(2)[2] V = image("tor2slice-evec.nrrd") ⊛ ctmr;
field#1(2)[2,2] T = image("tor2slice.nrrd") ⊛ ctmr;
field#0(2)[] R = image("tor2slice-rand.nrrd") ⊛ tent;

strand LIC (int xi, int yi) {
    vec2 pos0 = [lerp(0.0, 79.0, -0.5, real(xi), real(imgSize)-0.5),
                 lerp(0.0, 79.0, -0.5, real(yi), real(imgSize)-0.5)];
    vec2 pos = pos0;
    vec2 step = [0.0,0.0];
    output real out = 0.0;
    real sum = 0.0;
    int stepIdx = 0;
    real sign = 1.0;
    vec2 refdir = [0.0,0.0];
    vec2 dir = [0.0,0.0];

    update {
      vec2 nondir = evecs(T(pos)){0};
      if (0 == stepIdx) {
        refdir = sign*nondir;
        dir = refdir;
        // 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)) {
        pos += step;
        sum += R(pos);
      }
      if (stepIdx < stepNum) {
        stepIdx += 1;
      } else {
        if (sign > 0.0) {
          sign = -1.0;
          stepIdx = 0;
          pos = pos0;
        } else {
          stabilize;
        }
      }
    }

    stabilize {
      tensor[2,2,2] tmp = ∇⊗T(pos0);
      tensor[2,2] tmpA = tmp•[1.0,0.0];
      tensor[2,2] tmpB = [1.0,0.0]•tmp;
      out = |tmp| + |tmpA| + |tmpB|;
    }
}

initially [ LIC(xi, yi) | yi in 0..(imgSize-1), xi in 0..(imgSize-1) ];

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