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

SCM Repository

[diderot] Annotation of /branches/lamont/test/derivs3.diderot
ViewVC logotype

Annotation of /branches/lamont/test/derivs3.diderot

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1671 - (view) (download)
Original Path: trunk/test/derivs3.diderot

1 : jhr 1115 // derivs3
2 :     //
3 :     // for debugging transforms of derivatives from index to world, in 3D.
4 :     //
5 :     // Can output image of errors in reconstructed values, or reconstructed
6 :     // gradients, according to which of (1), (2), (3) is uncommented below.
7 :     // In all cases, output is processed with:
8 :     //
9 :     // unu reshape -i mip.txt -s 3 300 300 | unu quantize -b 8 -min 0 -max 1 -o derivs2.png
10 :     //
11 :     // This should produce an *ALL BLACK IMAGE* (modulo a few near-black
12 :     // pixels due to numerical precision issues)
13 :    
14 :     // F: full isotropic resolution
15 :     image(3)[] Fimg = load ("../data/parab/parab3-150.nrrd");
16 :     field#1(3)[] F0 = Fimg ⊛ ctmr;
17 :     field#2(3)[] F = Fimg ⊛ bspln3;
18 :    
19 :     // FX: one fifth as many samples along X
20 :     image(3)[] FXimg = load ("../data/parab/parab3-x30.nrrd");
21 :     field#1(3)[] F0X = FXimg ⊛ ctmr;
22 :     field#2(3)[] FX = FXimg ⊛ bspln3;
23 :    
24 :     // FY: one fifth as many samples along Y
25 :     image(3)[] FYimg = load ("../data/parab/parab3-y30.nrrd");
26 :     field#1(3)[] F0Y = FYimg ⊛ ctmr;
27 :     field#2(3)[] FY = FYimg ⊛ bspln3;
28 :    
29 :     // FZ: one fifth as many samples along Z
30 :     image(3)[] FZimg = load ("../data/parab/parab3-z30.nrrd");
31 :     field#1(3)[] F0Z = FZimg ⊛ ctmr;
32 :     field#2(3)[] FZ = FZimg ⊛ bspln3;
33 :    
34 :     int imgSize = 300;
35 :    
36 :     strand sample (int xi, int yi) {
37 :     real xx = lerp(-50.0, 50.0, 0.0, real(xi), real(imgSize-1));
38 :     real yy = lerp(-50.0, 50.0, 0.0, real(yi), real(imgSize-1));
39 :     real zz = 25.0;
40 :     vec3 p = [xx,yy,zz];
41 :     real f = xx^2 + yy^2 + zz^2; // analytic parabola function
42 :     vec3 g = [2.0*xx,2.0*yy,2.0*zz]; // analytic gradient
43 :     tensor[3,3] h = [[2.0,0.0,0.0], // analytic hessian
44 :     [0.0,2.0,0.0],
45 :     [0.0,0.0,2.0]];
46 :     output vec3 val = [0.0,0.0,0.0];
47 :     tensor[3,3] mh = zeros[3,3];
48 :     update {
49 :    
50 :     // Uncomment one of the following:
51 :    
52 :     // (1) These are the errors in the values
53 :     // This works fine; here as a sanity check
54 :     // val = [|F0X(p)-f|, |F0Y(p)-f|, |F0Z(p)-f|];
55 :    
56 :     // (2) These are magnitudes of the errors in the gradients
57 : jhr 1671 //val = [|∇FX(p)-g|, |∇FY(p)-g|, |∇FZ(p)-g|];
58 : jhr 1115
59 :     // (3) Magnitudes of errors in Hessians
60 : jhr 1671 val = [|∇(∇FX)(p)-h|, |∇(∇FY)(p)-h|, |∇(∇FZ)(p)-h|]/100.0;
61 : jhr 1115
62 :     stabilize;
63 :     }
64 :     }
65 :    
66 :     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