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

SCM Repository

[diderot] View of /tests/glk-tests/back/laplgrad.diderot
ViewVC logotype

View of /tests/glk-tests/back/laplgrad.diderot

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4640 - (download) (annotate)
Tue Sep 27 20:54:47 2016 UTC (2 years, 10 months ago) by glk
File size: 1347 byte(s)
initial result of svn export --username anonsvn --password=anonsvn https://svn.smlnj-gforge.cs.uchicago.edu/svn/diderot/branches/vis15/src/tests/
// laplgrad: tests if laplacian gradient is being computed correctly

// process output with:
// unu tile -i out.nrrd -a 0 1 2 -s 2 2 | unu quantize -b 8 -o laplgrad.png

input real epsilon = 0.0001;
int gridSize = 300;
field#4(2)[] F = bspln5 ⊛ image("../data/ddro-64.nrrd");
input bool norm = false;

strand sample (int ui, int vi) {
    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)];
    vec2 stepX = [epsilon,0.0];
    vec2 stepY = [0.0,epsilon];
    output vec4 out = [0.0,0.0,0.0,0.0];
    update {
        if (!(inside(pos, F)
              && inside(pos+stepX, F) && inside(pos-stepX, F)
              && inside(pos+stepY, F) && inside(pos-stepY, F) )) {
	    stabilize;
        }
        tensor[2] dgrad = [(trace(∇⊗∇F(pos+stepX)) - trace(∇⊗∇F(pos-stepX)))/(2.0*epsilon),
                           (trace(∇⊗∇F(pos+stepY)) - trace(∇⊗∇F(pos-stepY)))/(2.0*epsilon)];
        tensor[2] lgrad = identity[2]:∇⊗∇⊗∇F(pos);
        if (norm) {
          dgrad = normalize(dgrad);
          lgrad = normalize(lgrad);
        }
        out = [dgrad[0], dgrad[1],              
               lgrad[0], lgrad[1]];
        stabilize;
    }
}

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