// derivs2 // // for debugging transforms of derivatives from index to world, in 2D, // using synthetic data of a parabola. The Catmull-Rom can exactly // reconstruct quadratic functions, so this is a good test case. // // 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(2)[] Fimg = load ("../data/parab/parab2-150.nrrd"); field#1(2)[] F = Fimg ⊛ ctmr; // FX: one fifth as many samples along X image(2)[] FXimg = load ("../data/parab/parab2-x30.nrrd"); field#1(2)[] FX = FXimg ⊛ ctmr; // FY: one fifth as many samples along Y image(2)[] FYimg = load ("../data/parab/parab2-y30.nrrd"); field#1(2)[] FY = FYimg ⊛ 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)); vec2 p = [xx,yy]; real f = xx^2 + yy^2; // analytic parabola function vec2 g = [2.0*xx,2.0*yy]; // 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 = [|F(p)-f|, |FX(p)-f|, |FY(p)-f|]; // (2) These are magnitudes of the errors in the gradients val = [|∇F(p)-g|, |∇FX(p)-g|, |∇FY(p)-g|]; stabilize; } } initially [ sample(xi, yi) | yi in 0..(imgSize-1), xi in 0..(imgSize-1) ];
Click to toggle
does not end with </html> tag
does not end with </body> tag
The output has ended thus: stabilize; } } initially [ sample(xi, yi) | yi in 0..(imgSize-1), xi in 0..(imgSize-1) ];