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

SCM Repository

[diderot] View of /branches/pure-cfg/test/derivs3.diderot
ViewVC logotype

View of /branches/pure-cfg/test/derivs3.diderot

Parent Directory Parent Directory | Revision Log Revision Log


Revision 959 - (download) (annotate)
Sat Apr 23 15:28:33 2011 UTC (8 years, 6 months ago) by glk
File size: 1805 byte(s)
for debugging index-to-world gradient transforms in 2D and 3D
// derivs3
//
// for debugging transforms of derivatives from index to world, in 3D.
//
// Can output image of errors in reconstructed values, or reconstructed
// gradients, according to which of (1) of (2) is uncommented below.
// In other case, output is processed with:
//
// unu reshape -i mip.txt -s 3 300 300 | unu quantize -b 8 -min 0 -max 1 -o derivs2.png
//
// This should produce an *ALL BLACK IMAGE* (modulo a few near-black
// pixels due to numerical precision issues)

// F: full isotropic resolution
image(3)[] Fimg = load ("../data/parab/parab3-150.nrrd");
field#1(3)[] F = Fimg ⊛ ctmr;

// FX: one fifth as many samples along X
image(3)[] FXimg = load ("../data/parab/parab3-x30.nrrd");
field#1(3)[] FX = FXimg ⊛ ctmr;

// FY: one fifth as many samples along Y
image(3)[] FYimg = load ("../data/parab/parab3-y30.nrrd");
field#1(3)[] FY = FYimg ⊛ ctmr;

// FZ: one fifth as many samples along Z
image(3)[] FZimg = load ("../data/parab/parab3-z30.nrrd");
field#1(3)[] FZ = FZimg ⊛ ctmr;

int imgSize = 300;

strand sample (int xi, int yi) {
    real xx = lerp(-50.0, 50.0, 0.0, real(xi), real(imgSize-1));
    real yy = lerp(-50.0, 50.0, 0.0, real(yi), real(imgSize-1));
    real zz = 25.0;
    vec3 p = [xx,yy,zz];
    real f = xx^2 + yy^2 + zz^2;     // analytic parabola function
    vec3 g = [2.0*xx,2.0*yy,2.0*zz]; // analytic gradient of parabola
    output vec3 val = [0.0,0.0,0.0];
    update {

        // Uncomment one of the following:
    
        // (1) These are the errors in the values
        //val = [|FX(p)-f|, |FY(p)-f|, |FZ(p)-f|];

        // (2) These are magnitudes of the errors in the gradients
        val = [|∇FX(p)-g|, |∇FY(p)-g|, |∇FZ(p)-g|];

        stabilize;
    }
}

initially [ sample(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