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

SCM Repository

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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2188 - (download) (annotate)
Sun Feb 24 03:42:57 2013 UTC (6 years, 6 months ago) by glk
File size: 1699 byte(s)
hyperlic seems to be workign
/*
   generate and process output out.nrrd with:

./hlic -ei 0 ; mv sum.nrrd 0.nrrd
./hlic -ei 1 ; mv sum.nrrd 1.nrrd
unu join -i {0,1,0}.nrrd -a 0 -incr \
 | unu project -a 3 -m sum \
 | unu quantize -b 8 -min 1% -max 1% -o hlic.png

*/

int imgSize = 400;
real hh = 0.3;     // step size of integration
real anisoMin = 0.25;
int stepMax = 50;  // take at most this many steps
input int ei = 1;

field#1(2)[2,2] T = image("tor2slice.nrrd") ⊛ bspln3;
field#0(2)[] R = image("tor2slice-rand.nrrd") ⊛ tent;
field#0(2)[] ins = image("tor2slice-inside.nrrd") ⊛ tent;

function vec2 dir(vec2 reference, vec2 pos) {
    vec2 ev = evecs(T(pos)){ei};
    return ev if (ev•reference > 0) else -ev;
}

function real aniso(vec2 pos) = (evals(T(pos)){0} - evals(T(pos)){1})/|T(pos)|;

function real contrast(real ani) = clamp(0, 1, lerp(0, 1, anisoMin, ani, 1));

strand HLIC (real sign, vec2 pos0) {
    vec2 prev = hh*sign*evecs(T(pos0)){ei};
    vec2 pos = pos0;
    vec2 step = [0.0,0.0];
    output real sum = 0.0;
    int stepIdx = 0;

    update {
        // RK2
        step = hh*dir(prev, pos + 0.5*hh*dir(prev, pos));
        // Euler
        //step = hh*dir(prev, pos);
        pos += step;
        sum += contrast(aniso(pos))*R(pos);
        stepIdx += 1;
        prev = step;
        if (stepIdx == stepMax || !inside(pos, ins) || aniso(pos) < anisoMin) {
            stabilize;
        }
    }
    stabilize {
        sum *= contrast(aniso(pos0))/stepIdx;
    }
}

initially [ HLIC(lerp(-1, 1, 0, si, 1),
                 [lerp(0.0, 81.0, -0.5, xi, imgSize-0.5),
                  lerp(0.0, 81.0, -0.5, yi, imgSize-0.5)])
            | si in 0..1, yi in 0..imgSize-1, xi in 0..imgSize-1];

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