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

SCM Repository

[diderot] View of /branches/charisee/test/zslice-etest2.diderot
ViewVC logotype

View of /branches/charisee/test/zslice-etest2.diderot

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3063 - (download) (annotate)
Sat Mar 14 13:37:57 2015 UTC (4 years, 5 months ago) by jhr
File size: 1607 byte(s)
  change "load" to "image" in test programs
/* zslice-etest.diderot
 *
 * COPYRIGHT (c) 2011 The Diderot Project (http://diderot-language.cs.uchicago.edu)
 * All rights reserved.
 *
 * To check the output:
 *
 *      unu minmax zslice-etest2.nrrd
 *
 * should return a min value of 0 and a max value close to 0.
 */

int dataSizeX = 71;
int dataSizeY = 45;
int imgSizeX = 10*dataSizeX;
int imgSizeY = 10*dataSizeY;
vec3 orig = [0.0, 0.0, 6.0];
vec3 xVec = [1.0, 0.0, 0.0];
vec3 yVec = [0.0, 1.0, 0.0];
image(3)[] img = image("../data/etest.nrrd");
field#2(3)[] F = img ⊛ bspln3;

strand sample (int xi, int yi) {
    real xx = lerp(-0.5, real(dataSizeX)-0.5, -0.5, real(xi), real(imgSizeX)-0.5);
    real yy = lerp(-0.5, real(dataSizeY)-0.5, -0.5, real(yi), real(imgSizeY)-0.5);
    vec3 pos = orig + xx*xVec + yy*yVec;
    output real val = 0.0; 

    update
    {
        if (inside (pos,F)) {
	    tensor[3,3] J = ∇⊗∇F(pos);
	    tensor[2,2] H01 = [[J[0,0], J[0,1]], [J[1,0], J[1,1]]];
	    tensor[2,2] H02 = [[J[0,0], J[0,2]], [J[2,0], J[2,2]]];
	    tensor[2,2] H12 = [[J[1,1], J[1,2]], [J[1,2], J[2,2]]];
	    vec2{2} v = evecs(H01);
            real{2} l = evals(H01);
            tensor[2,2] R = l{0}*v{0}⊗v{0} + l{1}*v{1}⊗v{1};
            val += |H01 - R|;
	    v = evecs(H02);
            l = evals(H02);
            R = l{0}*v{0}⊗v{0} + l{1}*v{1}⊗v{1};
            val += |H02 - R|;
	    v = evecs(H12);
            l = evals(H12);
            R = l{0}*v{0}⊗v{0} + l{1}*v{1}⊗v{1};
            val += |H12 - R|;
	}
        stabilize;
    }
}

initially [ sample(xi, yi) | yi in 0..(imgSizeY-1), xi in 0..(imgSizeX-1) ];

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