SCM Repository
[diderot] / trunk / test / derivs3.diderot |
View of /trunk/test/derivs3.diderot
Parent Directory | Revision Log
Revision 1119 -
(download)
(annotate)
Thu May 5 05:07:35 2011 UTC (9 years, 3 months ago) by jhr
File size: 2293 byte(s)
Thu May 5 05:07:35 2011 UTC (9 years, 3 months ago) by jhr
File size: 2293 byte(s)
one final merge
// 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), (2), (3) is uncommented below. // In all cases, 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)[] F0 = Fimg ⊛ ctmr; field#2(3)[] F = Fimg ⊛ bspln3; // FX: one fifth as many samples along X image(3)[] FXimg = load ("../data/parab/parab3-x30.nrrd"); field#1(3)[] F0X = FXimg ⊛ ctmr; field#2(3)[] FX = FXimg ⊛ bspln3; // FY: one fifth as many samples along Y image(3)[] FYimg = load ("../data/parab/parab3-y30.nrrd"); field#1(3)[] F0Y = FYimg ⊛ ctmr; field#2(3)[] FY = FYimg ⊛ bspln3; // FZ: one fifth as many samples along Z image(3)[] FZimg = load ("../data/parab/parab3-z30.nrrd"); field#1(3)[] F0Z = FZimg ⊛ ctmr; field#2(3)[] FZ = FZimg ⊛ bspln3; 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 tensor[3,3] h = [[2.0,0.0,0.0], // analytic hessian [0.0,2.0,0.0], [0.0,0.0,2.0]]; output vec3 val = [0.0,0.0,0.0]; tensor[3,3] mh = zeros[3,3]; update { // Uncomment one of the following: // (1) These are the errors in the values // This works fine; here as a sanity check // val = [|F0X(p)-f|, |F0Y(p)-f|, |F0Z(p)-f|]; // (2) These are magnitudes of the errors in the gradients val = [|∇FX(p)-g|, |∇FY(p)-g|, |∇FZ(p)-g|]; // (3) Magnitudes of errors in Hessians // val = [|∇(∇FX)(p)-h|, |∇(∇FY)(p)-h|, |∇(∇FZ)(p)-h|]/100.0; 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 |