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

SCM Repository

[diderot] Annotation of /branches/vis12/test/derivs2.diderot
 [diderot] / branches / vis12 / test / derivs2.diderot

Annotation of /branches/vis12/test/derivs2.diderot

Revision 1115 - (view) (download)
Original Path: trunk/test/derivs2.diderot

 1 : jhr 1115 // 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), (2), (3) is uncommented below. 9 : // In all cases, 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)[] F0 = Fimg ⊛ ctmr; 19 : field#2(2)[] F = Fimg ⊛ bspln3; 20 : 21 : // FX: one fifth as many samples along X 22 : image(2)[] FXimg = load ("../data/parab/parab2-x30.nrrd"); 23 : field#1(2)[] F0X = FXimg ⊛ ctmr; 24 : field#2(2)[] FX = FXimg ⊛ bspln3; 25 : 26 : // FY: one fifth as many samples along Y 27 : image(2)[] FYimg = load ("../data/parab/parab2-y30.nrrd"); 28 : field#1(2)[] F0Y = FYimg ⊛ ctmr; 29 : field#2(2)[] FY = FYimg ⊛ bspln3; 30 : 31 : int imgSize = 300; 32 : strand sample (int xi, int yi) { 33 : real xx = lerp(-50.0, 50.0, 0.0, real(xi), real(imgSize-1)); 34 : real yy = lerp(-50.0, 50.0, 0.0, real(yi), real(imgSize-1)); 35 : vec2 p = [xx,yy]; 36 : real f = xx^2 + yy^2; // analytic parabola function 37 : vec2 g = [2.0*xx,2.0*yy]; // analytic gradient 38 : tensor[2,2] h = [[2.0,0.0],[0.0,2.0]]; // analytic hessian 39 : output vec3 val = [0.0,0.0,0.0]; 40 : update { 41 : 42 : // Uncomment one of the following: 43 : 44 : // (1) These are the errors in the values (this works fine) 45 : // This works fine; here as a sanity check 46 : //val = [|F0(p)-f|, |F0X(p)-f|, |F0Y(p)-f|]; 47 : 48 : // (2) These are magnitudes of the errors in the gradients 49 : val = [|∇F(p)-g|, |∇FX(p)-g|, |∇FY(p)-g|]; 50 : 51 : // (3) Magnitudes of errors in Hessians 52 : // The "/50.0" because of greater numerical error in the 53 : // second derivatives, which may warrant further study 54 : //val = [|∇(∇F)(p)-h|, |∇(∇FX)(p)-h|, |∇(∇FY)(p)-h|]/50.0; 55 : 56 : stabilize; 57 : } 58 : } 59 : 60 : 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