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

SCM Repository

[diderot] View of /branches/lamont/test/ridge2d-bug.diderot
ViewVC logotype

View of /branches/lamont/test/ridge2d-bug.diderot

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2081 - (download) (annotate)
Mon Nov 5 23:26:06 2012 UTC (6 years, 9 months ago) by lamonts
File size: 1521 byte(s)
Creating new developmented branch based on vis12
// iso2d
//
// Process output with:
// unu jhisto -i iso2d.txt -b 512 512 -min 0 0 -max 1 1 | unu 2op neq - 0 | unu quantize -b 8  -o iso2d.png

int gridSize = 200;
field#2(2)[] F = bspln3 ⊛ image("../data/ddro-80.nrrd");
input int stepsMax = 30;
real epsilon = 0.0001;

strand sample (int ui, int vi) {
    output vec2 pos = [lerp(0.0, 1.0, -0.5, real(ui), real(gridSize)-0.5),
                       lerp(0.0, 1.0, -0.5, real(vi), real(gridSize)-0.5)];
    int steps = 0;
    update {
        /* */
        if (!inside(pos, F) || steps > stepsMax) {
	    die;
        }
        /* */
        /*
        if (!inside(pos, F)) {
	    die;
        }
        if (steps >= stepsMax) {
            stabilize;
        }
        */
        vec2 grad = ∇F(pos);
        real gmag = |grad|;
        if (gmag == 0.0) {    // can't compute step if |∇F|, so have to bail
	    die;
        }
        vec2 norm = normalize(grad);
        tensor[2,2] hess = ∇⊗∇F(pos);
        real{2} eval = evals(hess);
        vec2{2} evec = evecs(hess);
        real fdd = grad•evec{1};
        real sdd = evec{1}•hess•evec{1};
        vec2 delta = (0.001 if sdd >= 0.0 else -fdd/sdd)*evec{1};
        if (|delta| < epsilon) {    // we've converged if step is small enough
            if (eval{1} < -10000.0) {
               stabilize;
            } else {
               die;
            }
        }
        pos += delta;
        steps += 1;
    }
}

initially { sample(ui, vi) | vi in 0..(gridSize-1), ui in 0..(gridSize-1) };


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