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

SCM Repository

[diderot] Annotation of /branches/pure-cfg/test/derivs2.diderot
ViewVC logotype

Annotation of /branches/pure-cfg/test/derivs2.diderot

Parent Directory Parent Directory | Revision Log Revision Log


Revision 959 - (view) (download)

1 : glk 959 // derivs2
2 :     //
3 :     // for debugging transforms of derivatives from index to world, in 2D,
4 :     // using synthetic data of a parabola. The Catmull-Rom can exactly
5 :     // reconstruct quadratic functions, so this is a good test case.
6 :     //
7 :     // Can output image of errors in reconstructed values, or reconstructed
8 :     // gradients, according to which of (1) of (2) is uncommented below.
9 :     // In other case, output is processed with:
10 :     //
11 :     // unu reshape -i mip.txt -s 3 300 300 | unu quantize -b 8 -min 0 -max 1 -o derivs2.png
12 :     //
13 :     // This should produce an *ALL BLACK IMAGE* (modulo a few near-black
14 :     // pixels due to numerical precision issues)
15 :    
16 :     // F: full isotropic resolution
17 :     image(2)[] Fimg = load ("../data/parab/parab2-150.nrrd");
18 :     field#1(2)[] F = Fimg ⊛ ctmr;
19 :    
20 :     // FX: one fifth as many samples along X
21 :     image(2)[] FXimg = load ("../data/parab/parab2-x30.nrrd");
22 :     field#1(2)[] FX = FXimg ⊛ ctmr;
23 :    
24 :     // FY: one fifth as many samples along Y
25 :     image(2)[] FYimg = load ("../data/parab/parab2-y30.nrrd");
26 :     field#1(2)[] FY = FYimg ⊛ ctmr;
27 :    
28 :     int imgSize = 300;
29 :     strand sample (int xi, int yi) {
30 :     real xx = lerp(-50.0, 50.0, 0.0, real(xi), real(imgSize-1));
31 :     real yy = lerp(-50.0, 50.0, 0.0, real(yi), real(imgSize-1));
32 :     vec2 p = [xx,yy];
33 :     real f = xx^2 + yy^2; // analytic parabola function
34 :     vec2 g = [2.0*xx,2.0*yy]; // analytic gradient of parabola
35 :     output vec3 val = [0.0,0.0,0.0];
36 :     update {
37 :    
38 :     // Uncomment one of the following:
39 :    
40 :     // (1) These are the errors in the values
41 :     //val = [|F(p)-f|, |FX(p)-f|, |FY(p)-f|];
42 :    
43 :     // (2) These are magnitudes of the errors in the gradients
44 :     val = [|∇F(p)-g|, |∇FX(p)-g|, |∇FY(p)-g|];
45 :    
46 :     stabilize;
47 :     }
48 :     }
49 :    
50 :     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