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

SCM Repository

[diderot] Annotation of /branches/vis12/test/ridge2d.diderot
ViewVC logotype

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1931 - (view) (download)

1 : jhr 1671 // ridge2d
2 :     //
3 :     // Process output with:
4 :     // unu jhisto -i ridge2d.txt -b 512 512 -min 0 0 -max 1 1 | unu 2op neq - 0 | unu quantize -b 8 -o ridge2d.png
5 :    
6 :     int gridSize = 200;
7 : jhr 1927 field#2(2)[] F = bspln3 ⊛ image("../data/ddro-80.nrrd");
8 : jhr 1931 input int stepsMax ("maximum number of steps") = 20;
9 : jhr 1671 real epsilon = 0.0001;
10 :     real travelMax = 0.1;
11 :    
12 :     strand sample (int ui, int vi) {
13 :     output vec2 pos = [lerp(0.0, 1.0, -0.5, real(ui), real(gridSize)-0.5),
14 :     lerp(0.0, 1.0, -0.5, real(vi), real(gridSize)-0.5)];
15 :     int steps = 0;
16 :     real travel = 0.0;
17 :     update {
18 :     if (!inside(pos, F) || steps > stepsMax || travel > travelMax) {
19 :     die;
20 :     }
21 :     real gmag = |∇F(pos)|;
22 :     if (gmag == 0.0) { // can't compute step if |∇F|, so have to bail
23 :     die;
24 :     }
25 :     tensor[2,2] hess = ∇⊗∇F(pos);
26 :     real{2} eval = evals(hess);
27 :     vec2{2} evec = evecs(hess);
28 :     real fdd = evec{1}•∇F(pos);
29 :     real sdd = evec{1}•hess•evec{1};
30 :     vec2 delta = (0.001 if sdd >= 0.0 else -fdd/sdd)*evec{1};
31 :     if (|delta| < epsilon) {
32 :     if (eval{1} < -800.0) {
33 :     stabilize;
34 :     }
35 :     die;
36 :     } // BUG: can't have: else {
37 :     pos += delta;
38 :     steps += 1;
39 :     travel += |delta|;
40 :     // BUG: can't have: }
41 :     }
42 :     }
43 :    
44 :     initially { sample(ui, vi) | vi in 0..(gridSize-1), ui in 0..(gridSize-1) };
45 :    

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0